From 5aa562501248e886dc73241205ae99610b2594d7 Mon Sep 17 00:00:00 2001 From: "joshmoz@gmail.com" Date: Mon, 28 May 2007 22:06:12 -0700 Subject: [PATCH] fix "can't drag and drop buttons when customizing toolbars", patch by Stan Shebs. b=358446 r=josh sr=pav --- widget/src/cocoa/nsChildView.mm | 1 + widget/src/cocoa/nsDragService.h | 2 ++ widget/src/cocoa/nsDragService.mm | 13 ++++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/widget/src/cocoa/nsChildView.mm b/widget/src/cocoa/nsChildView.mm index 896789d5a20..656ac79ffad 100644 --- a/widget/src/cocoa/nsChildView.mm +++ b/widget/src/cocoa/nsChildView.mm @@ -1819,6 +1819,7 @@ NSEvent* globalDragEvent = nil; [self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, NSStringPboardType, NSURLPboardType, + kWildcardPboardType, nil]]; return self; diff --git a/widget/src/cocoa/nsDragService.h b/widget/src/cocoa/nsDragService.h index e7f290b26b8..9abceda3e36 100644 --- a/widget/src/cocoa/nsDragService.h +++ b/widget/src/cocoa/nsDragService.h @@ -43,6 +43,8 @@ #include +extern NSString* const kWildcardPboardType; + class nsILocalFile; class nsIDOMDragEvent; diff --git a/widget/src/cocoa/nsDragService.mm b/widget/src/cocoa/nsDragService.mm index d7e3c7e0303..7bb4d885572 100644 --- a/widget/src/cocoa/nsDragService.mm +++ b/widget/src/cocoa/nsDragService.mm @@ -69,6 +69,8 @@ extern NSPasteboard* globalDragPboard; extern NSView* globalDragView; extern NSEvent* globalDragEvent; +NSString* const kWildcardPboardType = @"MozillaWildcard"; + NS_IMPL_ADDREF_INHERITED(nsDragService, nsBaseDragService) NS_IMPL_RELEASE_INHERITED(nsDragService, nsBaseDragService) NS_IMPL_QUERY_INTERFACE2(nsDragService, nsIDragService, nsIDragSession) @@ -224,8 +226,17 @@ static nsresult SetUpDragClipboard(nsISupportsArray* aTransferableArray) id currentValue = [pasteboardOutputDict valueForKey:currentKey]; if (currentKey == NSStringPboardType) [generalPBoard setString:currentValue forType:currentKey]; - else + else { [generalPBoard setData:currentValue forType:currentKey]; + // Record miscellaneous types of data a second time, under a + // generic type that is always registered with Cocoa as + // draggable. This allows types dynamically synthesized from + // JS to work; if in the future several different types of + // drag data need to be distinguished, it will be the + // responsibility of higher-level drag code to detect the + // situation (which it would normally have to do anyway.) + [generalPBoard setData:nil forType:kWildcardPboardType]; + } } }