[iOS WK2] Hide previews when an inner overflow or frame scrollview scrolls
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Aug 2019 01:57:49 +0000 (01:57 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Aug 2019 01:57:49 +0000 (01:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200552
rdar://problem/54086338

Reviewed by Wenson Hsieh.

Give UITargetedPreview the UIScrollView that the target element is inside of,
so it can clean up if the user starts to scroll that view.

* Platform/spi/ios/UIKitSPI.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _createTargetedPreviewIfPossible]):

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

Source/WebKit/ChangeLog
Source/WebKit/Platform/spi/ios/UIKitSPI.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

index 391ea6e..7841aaa 100644 (file)
@@ -1,3 +1,18 @@
+2019-08-08  Simon Fraser  <simon.fraser@apple.com>
+
+        [iOS WK2] Hide previews when an inner overflow or frame scrollview scrolls
+        https://bugs.webkit.org/show_bug.cgi?id=200552
+        rdar://problem/54086338
+
+        Reviewed by Wenson Hsieh.
+
+        Give UITargetedPreview the UIScrollView that the target element is inside of,
+        so it can clean up if the user starts to scroll that view.
+
+        * Platform/spi/ios/UIKitSPI.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _createTargetedPreviewIfPossible]):
+
 2019-08-08  Chris Dumez  <cdumez@apple.com>
 
         Add threading assertions to WebStorage code
 2019-08-08  Chris Dumez  <cdumez@apple.com>
 
         Add threading assertions to WebStorage code
index dc1f68c..82a75c3 100644 (file)
 #import <UIKit/_UITextDragCaretView.h>
 #endif
 
 #import <UIKit/_UITextDragCaretView.h>
 #endif
 
+#if __has_include(<UIKit/UITargetedPreview_Private.h>)
+#import <UIKit/UITargetedPreview_Private.h>
+#endif
+
 #else // USE(APPLE_INTERNAL_SDK)
 
 #if ENABLE(DRAG_SUPPORT)
 #else // USE(APPLE_INTERNAL_SDK)
 
 #if ENABLE(DRAG_SUPPORT)
@@ -1157,6 +1161,12 @@ typedef NS_OPTIONS(NSInteger, UIWKDocumentRequestFlags) {
 @end
 #endif
 
 @end
 #endif
 
+#if USE(UICONTEXTMENU)
+@interface UITargetedPreview (Radar54086338)
+@property (nonatomic, strong, setter=_setOverridePositionTrackingView:) UIView *overridePositionTrackingView;
+@end
+#endif // USE(UICONTEXTMENU)
+
 @interface UIResponder ()
 - (UIResponder *)firstResponder;
 - (void)pasteAndMatchStyle:(id)sender;
 @interface UIResponder ()
 - (UIResponder *)firstResponder;
 - (void)pasteAndMatchStyle:(id)sender;
index 21299b1..9d87552 100644 (file)
@@ -8185,6 +8185,15 @@ static RetainPtr<UITargetedPreview> createFallbackTargetedPreview(UIView *rootVi
     if (!targetedPreview)
         targetedPreview = createFallbackTargetedPreview(self, self.containerViewForTargetedPreviews, _positionInformation.bounds);
 
     if (!targetedPreview)
         targetedPreview = createFallbackTargetedPreview(self, self.containerViewForTargetedPreviews, _positionInformation.bounds);
 
+    if (_positionInformation.containerScrollingNodeID) {
+        UIScrollView *positionTrackingView = _webView.scrollView;
+        if (auto* scrollingCoordinator = _page->scrollingCoordinatorProxy())
+            positionTrackingView = scrollingCoordinator->scrollViewForScrollingNodeID(_positionInformation.containerScrollingNodeID);
+
+        if ([targetedPreview respondsToSelector:@selector(_setOverridePositionTrackingView:)])
+            [targetedPreview _setOverridePositionTrackingView:positionTrackingView];
+    }
+
     _contextMenuInteractionTargetedPreview = WTFMove(targetedPreview);
     return _contextMenuInteractionTargetedPreview.get();
 }
     _contextMenuInteractionTargetedPreview = WTFMove(targetedPreview);
     return _contextMenuInteractionTargetedPreview.get();
 }