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. draft
authorJimmy Wang <jimmyw22@gmail.com>
Fri, 08 Jul 2016 11:22:42 -0400
changeset 401293 000d45638cf2da6e40ecad4e097eeeed3cfaa8d8
parent 401292 d8665bd32fba1af940db4cd8f8b7c2c8b85e8df6
child 401294 52923cdfa21ff9482e74e52d5de4e454fe4e8856
push id26424
push userjimmyw22@gmail.com
push dateTue, 16 Aug 2016 21:05:59 +0000
bugs1261299
milestone51.0a1
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
widget/cocoa/nsChildView.mm
--- 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];