iOSMac Share Sheet shows up at the wrong place
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 May 2019 19:04:00 +0000 (19:04 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 May 2019 19:04:00 +0000 (19:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197649
<rdar://problem/49922942>

Reviewed by Megan Gardner.

* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _showShareSheet:inRect:completionHandler:]):
(-[WKContentView _hoverGestureRecognizerChanged:]):
Pass the last mouse-over location as the presentation location for the
share sheet, if we don't have a rect to present from. Centering the popover
like we do on iPad doesn't work so well (at all) with a macOS context menu.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245022 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

index 3fb03b1..f3e753c 100644 (file)
@@ -1,3 +1,19 @@
+2019-05-07  Tim Horton  <timothy_horton@apple.com>
+
+        iOSMac Share Sheet shows up at the wrong place
+        https://bugs.webkit.org/show_bug.cgi?id=197649
+        <rdar://problem/49922942>
+
+        Reviewed by Megan Gardner.
+
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _showShareSheet:inRect:completionHandler:]):
+        (-[WKContentView _hoverGestureRecognizerChanged:]):
+        Pass the last mouse-over location as the presentation location for the 
+        share sheet, if we don't have a rect to present from. Centering the popover
+        like we do on iPad doesn't work so well (at all) with a macOS context menu.
+
 2019-05-07  Chris Dumez  <cdumez@apple.com>
 
         Rename ConnectionMac.mm to ConnectionCocoa.mm since it is used on both macOS and iOS
index 68cfc5b..99839a2 100644 (file)
@@ -230,6 +230,7 @@ struct WKAutoCorrectionData {
 #if PLATFORM(IOSMAC)
     RetainPtr<UIHoverGestureRecognizer> _hoverGestureRecognizer;
     RetainPtr<_UILookupGestureRecognizer> _lookupGestureRecognizer;
+    CGPoint _lastHoverLocation;
 #endif
 
     RetainPtr<UIWKTextInteractionAssistant> _textSelectionAssistant;
index f302baf..abf883c 100644 (file)
@@ -5864,6 +5864,13 @@ static BOOL allPasteboardItemOriginsMatchOrigin(UIPasteboard *pasteboard, const
     
     _shareSheet = adoptNS([[WKShareSheet alloc] initWithView:_webView]);
     [_shareSheet setDelegate:self];
+
+#if PLATFORM(IOSMAC)
+    if (!rect) {
+        auto hoverLocationInWebView = [self convertPoint:_lastHoverLocation toView:_webView];
+        rect = WebCore::FloatRect(hoverLocationInWebView.x, hoverLocationInWebView.y, 1, 1);
+    }
+#endif
     
     [_shareSheet presentWithParameters:data inRect:rect completionHandler:WTFMove(completionHandler)];
 #endif
@@ -7075,6 +7082,7 @@ static WebEventFlags webEventFlagsForUIKeyModifierFlags(UIKeyModifierFlags flags
     case UIGestureRecognizerStateBegan:
     case UIGestureRecognizerStateChanged:
         point = [gestureRecognizer locationInView:self];
+        _lastHoverLocation = point;
         break;
     case UIGestureRecognizerStateEnded:
     case UIGestureRecognizerStateCancelled: