Bug 1261299 - On e10s in nsChildView for OSX services, determine if there is a current selection (chrome/content). Send the selection to osx service menu.
MozReview-Commit-ID: G5iFo9GhyeA
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -5903,23 +5903,21 @@ PanGestureTypeForEvent(NSEvent* aEvent)
(!returnType || IsSupportedType(returnType))) {
if (mGeckoChild) {
// Assume that this object will be able to handle this request.
result = self;
// Keep the ChildView alive during this operation.
nsAutoRetainCocoaObject kungFuDeathGrip(self);
- // Determine if there is a selection (if sending to the service).
if (sendType) {
- WidgetQueryContentEvent event(true, eQueryContentState, mGeckoChild);
- // This might destroy our widget (and null out mGeckoChild).
- mGeckoChild->DispatchWindowEvent(event);
- if (!mGeckoChild || !event.mSucceeded || !event.mReply.mHasSelection)
+ // Determine if there is a current selection (chrome/content).
+ if (!nsClipboard::sSelectionCache) {
result = nil;
+ }
}
// Determine if we can paste (if receiving data from the service).
if (mGeckoChild && returnType) {
WidgetContentCommandEvent command(true,
eContentCommandPasteTransferable,
mGeckoChild, true);
// This might possibly destroy our widget (and null out mGeckoChild).
@@ -5952,25 +5950,22 @@ PanGestureTypeForEvent(NSEvent* aEvent)
if ([types containsObject:NSStringPboardType] == NO &&
[types containsObject:NSHTMLPboardType] == NO)
return NO;
// Bail out if there is no Gecko object.
if (!mGeckoChild)
return NO;
- // Obtain the current selection.
- WidgetQueryContentEvent event(true, eQuerySelectionAsTransferable,
- mGeckoChild);
- mGeckoChild->DispatchWindowEvent(event);
- if (!event.mSucceeded || !event.mReply.mTransferable)
- return NO;
-
// Transform the transferable to an NSDictionary.
- NSDictionary* pasteboardOutputDict = nsClipboard::PasteboardDictFromTransferable(event.mReply.mTransferable);
+ NSDictionary* pasteboardOutputDict = nullptr;
+
+ pasteboardOutputDict = nsClipboard::
+ PasteboardDictFromTransferable(nsClipboard::sSelectionCache);
+
if (!pasteboardOutputDict)
return NO;
// Declare the pasteboard types.
unsigned int typeCount = [pasteboardOutputDict count];
NSMutableArray* declaredTypes = [NSMutableArray arrayWithCapacity:typeCount];
[declaredTypes addObjectsFromArray:[pasteboardOutputDict allKeys]];
[pboard declareTypes:declaredTypes owner:nil];