Changeset 249368 in webkit
- Timestamp:
- Sep 1, 2019 1:42:36 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r249367 r249368 1 2019-09-01 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Long presses that interrupt accelerated scrolling dispatch clicks on apps linked against iOS 12 or earlier 4 https://bugs.webkit.org/show_bug.cgi?id=201346 5 <rdar://problem/54885784> 6 7 Reviewed by Dean Jackson. 8 9 Add a couple of new layout tests to verify that using a long press gesture to interrupt momentum scrolling in a 10 web view that uses API to disable link previews does not result in a click. 11 12 * fast/scrolling/ios/click-events-after-long-press-during-momentum-scroll-in-main-frame-expected.txt: Added. 13 * fast/scrolling/ios/click-events-after-long-press-during-momentum-scroll-in-main-frame.html: Added. 14 * fast/scrolling/ios/click-events-after-long-press-during-momentum-scroll-in-overflow-expected.txt: Added. 15 * fast/scrolling/ios/click-events-after-long-press-during-momentum-scroll-in-overflow.html: Added. 16 1 17 2019-09-01 Said Abou-Hallawa <sabouhallawa@apple.com> 2 18 -
trunk/Source/WebKit/ChangeLog
r249366 r249368 1 2019-09-01 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Long presses that interrupt accelerated scrolling dispatch clicks on apps linked against iOS 12 or earlier 4 https://bugs.webkit.org/show_bug.cgi?id=201346 5 <rdar://problem/54885784> 6 7 Reviewed by Dean Jackson. 8 9 For apps that are linked on or after iOS 13, we add a context menu interaction to the content view, which 10 requires us to disable (or avoid adding) the highlight long press gesture recognizer. However, for apps that are 11 linked on the iOS 12 SDK or prior, this gesture is still present, and fires when long pressing for (roughly) up 12 to 0.75 seconds if a tap gesture was not recognized instead. Firing this gesture sends a click event to the 13 page; this brings back some form of <rdar://problem/53889373>, but only when holding for slightly longer than a 14 normal tap, and also only in apps linked on iOS 12 or earlier. To fix this, we apply a similar solution as in 15 r248433 and detect whether a long press gesture interrupted scroll view deceleration in 16 -gestureRecognizerShouldBegin:. If so, we return NO to avoid clicking. See per-method comments below for more 17 details. 18 19 Testing this bug as-is was tricky, since there's no way in layout tests to simulate being linked on or before a 20 given SDK version. Luckily, recall that: 21 1. This bug occurs when the highlight gesture recognizer is enabled and added to the content view. 22 2. The highlight gesture recognizer only needs to be disabled or removed when context menu interaction is added. 23 As such, we should be able to restore the highlight gesture recognizer by suppressing the context menu 24 interaction in an app linked-on-or-after iOS 13, by setting allowsLinkPreview to NO. Unfortunately, this doesn't 25 quite work, since we currently always avoid adding the highlight gesture recognizer if the app is linked on 26 iOS 13 or later. 27 28 However, this means that the highlight gesture recognizer is absent from the content view in apps linked against 29 iOS 13 that disable link previews, even though its absence is not required. This means that long pressing a 30 clickable element in a web view that disables link previews does not show a tap highlight on iOS 13, whereas it 31 would on iOS 12; this is a regression, albeit a very subtle one. To fix this subtle issue and make it possible 32 to write a test for this bug, we refactor some logic for creating and configuring the highlight long press 33 gesture, such that we now unconditionally add the highlight gesture, but only enable it in apps linked on or 34 after iOS 13 if link previews (i.e. context menu interaction) are not allowed. 35 36 Test: fast/scrolling/ios/click-events-after-long-press-during-momentum-scroll-in-overflow.html 37 38 * SourcesCocoa.txt: 39 * UIProcess/API/Cocoa/WKWebView.mm: 40 (-[WKWebView setAllowsLinkPreview:]): 41 * UIProcess/ios/WKContentViewInteraction.h: 42 * UIProcess/ios/WKContentViewInteraction.mm: 43 (-[WKContentView setupInteraction]): 44 45 Refactor our gesture setup logic to always create and add the long press and highlight long press gestures, but 46 conditionally disable them based on whether or not (1) the context menu is available, and (2) WKWebView's 47 allowsLinkPreview property. 48 49 (-[WKContentView _didChangeLinkPreviewAvailability]): 50 (-[WKContentView _updateLongPressAndHighlightLongPressGestures]): 51 52 Add a new helper to update the enabled state of the long press and highlight long press gestures, by consulting 53 -_shouldUseContextMenu and -allowsLinkPreview. This is called when setting up the gestures, as well as whenever 54 -allowsLinkPreview changes. 55 56 (-[WKContentView gestureRecognizerShouldBegin:]): 57 58 Factor out logic to ascend the view hierarchy in search of a UIScrollView that was interrupted while 59 decelerating into a local lambda function; use this for both the highlight gesture and the single tap gesture, 60 to determine whether they should begin. 61 62 * UIProcess/ios/WKHighlightLongPressGestureRecognizer.h: Added. 63 * UIProcess/ios/WKHighlightLongPressGestureRecognizer.mm: Added. 64 65 In order to remember the UIScrollView (if any) tracked by the highlight long press gesture, we subclass 66 _UIWebHighlightLongPressGestureRecognizer. While UILongPressGestureRecognizer does have SPI to ask for a list of 67 UITouches, by the time the gesture has been recognized and the gesture delegates are invoked, these UITouches 68 no longer correspond to UIViews. As such, the only time we have access to the list of UITouches with their 69 UIViews is during the touches* subclass hooks. 70 71 (-[WKHighlightLongPressGestureRecognizer reset]): 72 73 Clear out the tracked UIScrollView here, when the gesture is reset (i.e. after ending, or being canceled). 74 75 (-[WKHighlightLongPressGestureRecognizer touchesBegan:withEvent:]): 76 77 Remember the last touched UIScrollView here. 78 79 (-[WKHighlightLongPressGestureRecognizer lastTouchedScrollView]): 80 * WebKit.xcodeproj/project.pbxproj: 81 1 82 2019-08-30 Brent Fulgham <bfulgham@apple.com> 2 83 -
trunk/Source/WebKit/SourcesCocoa.txt
r249155 r249368 423 423 UIProcess/ios/WKGeolocationProviderIOS.mm 424 424 UIProcess/ios/WKGeolocationProviderIOSObjCSecurityOrigin.mm 425 UIProcess/ios/WKHighlightLongPressGestureRecognizer.mm 425 426 UIProcess/ios/WKInspectorNodeSearchGestureRecognizer.mm 426 427 UIProcess/ios/WKKeyboardScrollingAnimator.mm -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
r249329 r249368 1268 1268 else 1269 1269 [_contentView _unregisterPreview]; 1270 [_contentView _didChangeLinkPreviewAvailability]; 1270 1271 #endif // HAVE(LINK_PREVIEW) 1271 1272 #endif // PLATFORM(IOS_FAMILY) -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
r249112 r249368 100 100 @class _UILookupGestureRecognizer; 101 101 @class _UIHighlightView; 102 @class _UIWebHighlightLongPressGestureRecognizer;103 102 @class UIHoverGestureRecognizer; 104 103 @class UITargetedPreview; … … 110 109 @class WKFormInputControl; 111 110 @class WKFormInputSession; 111 @class WKHighlightLongPressGestureRecognizer; 112 112 @class WKInspectorNodeSearchGestureRecognizer; 113 113 … … 214 214 215 215 RetainPtr<WKSyntheticTapGestureRecognizer> _singleTapGestureRecognizer; 216 RetainPtr< _UIWebHighlightLongPressGestureRecognizer> _highlightLongPressGestureRecognizer;216 RetainPtr<WKHighlightLongPressGestureRecognizer> _highlightLongPressGestureRecognizer; 217 217 RetainPtr<UILongPressGestureRecognizer> _longPressGestureRecognizer; 218 218 RetainPtr<WKSyntheticTapGestureRecognizer> _doubleTapGestureRecognizer; … … 549 549 @property (nonatomic, readonly) BOOL _shouldAvoidScrollingWhenFocusedContentIsVisible; 550 550 551 - (void)_didChangeLinkPreviewAvailability; 552 551 553 @end 552 554 -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r249275 r249368 53 53 #import "WKFormInputControl.h" 54 54 #import "WKFormSelectControl.h" 55 #import "WKHighlightLongPressGestureRecognizer.h" 55 56 #import "WKImagePreviewViewController.h" 56 57 #import "WKInspectorNodeSearchGestureRecognizer.h" … … 756 757 [self addGestureRecognizer:_twoFingerDoubleTapGestureRecognizer.get()]; 757 758 758 _highlightLongPressGestureRecognizer = adoptNS([[ _UIWebHighlightLongPressGestureRecognizer alloc] initWithTarget:self action:@selector(_highlightLongPressRecognized:)]);759 _highlightLongPressGestureRecognizer = adoptNS([[WKHighlightLongPressGestureRecognizer alloc] initWithTarget:self action:@selector(_highlightLongPressRecognized:)]); 759 760 [_highlightLongPressGestureRecognizer setDelay:highlightDelay]; 760 761 [_highlightLongPressGestureRecognizer setDelegate:self]; 762 [self addGestureRecognizer:_highlightLongPressGestureRecognizer.get()]; 763 764 [self _createAndConfigureLongPressGestureRecognizer]; 761 765 762 766 #if HAVE(LINK_PREVIEW) 763 if (!self._shouldUseContextMenus) { 764 [self addGestureRecognizer:_highlightLongPressGestureRecognizer.get()]; 765 [self _createAndConfigureLongPressGestureRecognizer]; 766 } 767 [self _updateLongPressAndHighlightLongPressGestures]; 767 768 #endif 768 769 … … 1005 1006 [self addGestureRecognizer:_touchActionGestureRecognizer.get()]; 1006 1007 #endif 1008 } 1009 1010 - (void)_didChangeLinkPreviewAvailability 1011 { 1012 [self _updateLongPressAndHighlightLongPressGestures]; 1013 } 1014 1015 - (void)_updateLongPressAndHighlightLongPressGestures 1016 { 1017 // We only disable the highlight long press gesture in the case where UIContextMenu is available and we 1018 // also allow link previews, since the context menu interaction's gestures need to take precedence over 1019 // highlight long press gestures. 1020 [_highlightLongPressGestureRecognizer setEnabled:!self._shouldUseContextMenus || !_webView.allowsLinkPreview]; 1021 1022 // We only enable the long press gesture in the case where the app is linked on iOS 12 or earlier (and 1023 // therefore prefers the legacy action sheet over context menus), and link previews are also enabled. 1024 [_longPressGestureRecognizer setEnabled:!self._shouldUseContextMenus && _webView.allowsLinkPreview]; 1007 1025 } 1008 1026 … … 2092 2110 return _webView._stylusTapGestureShouldCreateEditableImage; 2093 2111 2094 if (gestureRecognizer == _singleTapGestureRecognizer) {2112 auto isInterruptingDecelerationForScrollViewOrAncestor = [&] (UIScrollView *scrollView) { 2095 2113 UIScrollView *mainScroller = _webView.scrollView; 2096 UIView *view = [_singleTapGestureRecognizer lastTouchedScrollView]?: mainScroller;2114 UIView *view = scrollView ?: mainScroller; 2097 2115 while (view) { 2098 2116 if ([view isKindOfClass:UIScrollView.class] && [(UIScrollView *)view _isInterruptingDeceleration]) 2099 return NO;2117 return YES; 2100 2118 2101 2119 if (mainScroller == view) … … 2104 2122 view = view.superview; 2105 2123 } 2106 return YES; 2107 } 2124 return NO; 2125 }; 2126 2127 if (gestureRecognizer == _singleTapGestureRecognizer) 2128 return !isInterruptingDecelerationForScrollViewOrAncestor([_singleTapGestureRecognizer lastTouchedScrollView]); 2108 2129 2109 2130 if (gestureRecognizer == _highlightLongPressGestureRecognizer … … 2124 2145 2125 2146 if (gestureRecognizer == _highlightLongPressGestureRecognizer) { 2147 if (isInterruptingDecelerationForScrollViewOrAncestor([_highlightLongPressGestureRecognizer lastTouchedScrollView])) 2148 return NO; 2149 2126 2150 if (hasFocusedElement(_focusedElementInformation)) { 2127 2151 // This is a different element than the focused one. -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r249308 r249368 1708 1708 F4D5F51D206087A10038BBA8 /* WKTextInputListViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = F4D5F519206087A00038BBA8 /* WKTextInputListViewController.h */; }; 1709 1709 F4D5F51F206087A10038BBA8 /* WKQuickboardListViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = F4D5F51B206087A10038BBA8 /* WKQuickboardListViewController.h */; }; 1710 F4DB54E62319E733009E3155 /* WKHighlightLongPressGestureRecognizer.h in Headers */ = {isa = PBXBuildFile; fileRef = F4DB54E42319E733009E3155 /* WKHighlightLongPressGestureRecognizer.h */; }; 1710 1711 F6113E25126CE1820057D0A7 /* APIUserContentURLPattern.h in Headers */ = {isa = PBXBuildFile; fileRef = F6113E24126CE1820057D0A7 /* APIUserContentURLPattern.h */; }; 1711 1712 F6113E29126CE19B0057D0A7 /* WKUserContentURLPattern.h in Headers */ = {isa = PBXBuildFile; fileRef = F6113E27126CE19B0057D0A7 /* WKUserContentURLPattern.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 4765 4766 F4D5F51B206087A10038BBA8 /* WKQuickboardListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKQuickboardListViewController.h; path = ios/forms/WKQuickboardListViewController.h; sourceTree = "<group>"; }; 4766 4767 F4D5F51C206087A10038BBA8 /* WKQuickboardListViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKQuickboardListViewController.mm; path = ios/forms/WKQuickboardListViewController.mm; sourceTree = "<group>"; }; 4768 F4DB54E42319E733009E3155 /* WKHighlightLongPressGestureRecognizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKHighlightLongPressGestureRecognizer.h; path = ios/WKHighlightLongPressGestureRecognizer.h; sourceTree = "<group>"; }; 4769 F4DB54E52319E733009E3155 /* WKHighlightLongPressGestureRecognizer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKHighlightLongPressGestureRecognizer.mm; path = ios/WKHighlightLongPressGestureRecognizer.mm; sourceTree = "<group>"; }; 4767 4770 F4F59AD32065A5C9006CAA46 /* WKSelectMenuListViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKSelectMenuListViewController.mm; path = ios/forms/WKSelectMenuListViewController.mm; sourceTree = "<group>"; }; 4768 4771 F4F59AD42065A5CA006CAA46 /* WKSelectMenuListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKSelectMenuListViewController.h; path = ios/forms/WKSelectMenuListViewController.h; sourceTree = "<group>"; }; … … 6102 6105 0FCB4E4018BBE044000FCFC9 /* WKGeolocationProviderIOS.mm */, 6103 6106 0FCB4E4118BBE044000FCFC9 /* WKGeolocationProviderIOSObjCSecurityOrigin.mm */, 6107 F4DB54E42319E733009E3155 /* WKHighlightLongPressGestureRecognizer.h */, 6108 F4DB54E52319E733009E3155 /* WKHighlightLongPressGestureRecognizer.mm */, 6104 6109 933DF82D1B3BC09000AEA9E3 /* WKImagePreviewViewController.h */, 6105 6110 933DF82F1B3BC0B400AEA9E3 /* WKImagePreviewViewController.mm */, … … 9939 9944 C0CE72A11247E71D00BC0EC4 /* WebPageMessages.h in Headers */, 9940 9945 2D5C9D0619C81D8F00B3C5C1 /* WebPageOverlay.h in Headers */, 9946 46C392292316EC4D008EED9B /* WebPageProxyIdentifier.h in Headers */, 9941 9947 BCBD3915125BB1A800D2C29F /* WebPageProxyMessages.h in Headers */, 9942 9948 512127C41908239A00DAF35C /* WebPasteboardOverrides.h in Headers */, … … 10029 10035 2D12DAB520662C73006F00FB /* WKAnimationDelegate.h in Headers */, 10030 10036 BCDDB32D124EC2E10048D13C /* WKAPICast.h in Headers */, 10031 46C392292316EC4D008EED9B /* WebPageProxyIdentifier.h in Headers */,10032 10037 512E34E5130B4D0500ABD19A /* WKApplicationCacheManager.h in Headers */, 10033 10038 A13DC682207AA6B20066EF72 /* WKApplicationStateTrackingView.h in Headers */, … … 10179 10184 0FCB4E4F18BBE044000FCFC9 /* WKGeolocationProviderIOS.h in Headers */, 10180 10185 BCC8B374125FB69000DE46A4 /* WKGeometry.h in Headers */, 10186 F4DB54E62319E733009E3155 /* WKHighlightLongPressGestureRecognizer.h in Headers */, 10181 10187 1A422F8B18B29B5400D8CD96 /* WKHistoryDelegatePrivate.h in Headers */, 10182 10188 B62E7312143047B00069EC35 /* WKHitTestResult.h in Headers */, -
trunk/Tools/ChangeLog
r249366 r249368 1 2019-09-01 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Long presses that interrupt accelerated scrolling dispatch clicks on apps linked against iOS 12 or earlier 4 https://bugs.webkit.org/show_bug.cgi?id=201346 5 <rdar://problem/54885784> 6 7 Reviewed by Dean Jackson. 8 9 Add a new test option to allow tests to disable link previews. 10 11 * WebKitTestRunner/TestController.cpp: 12 (WTR::updateTestOptionsFromTestHeader): 13 * WebKitTestRunner/TestOptions.h: 14 15 Drive-by fix: also check enableLazyImageLoading when determining whether two TestOptions are the same. 16 17 (WTR::TestOptions::hasSameInitializationOptions const): 18 * WebKitTestRunner/cocoa/TestControllerCocoa.mm: 19 (WTR::TestController::platformCreateWebView): 20 1 21 2019-08-30 Brent Fulgham <bfulgham@apple.com> 2 22 -
trunk/Tools/WebKitTestRunner/TestController.cpp
r249096 r249368 1403 1403 else if (key == "enableLazyImageLoading") 1404 1404 testOptions.enableLazyImageLoading = parseBooleanTestHeaderValue(value); 1405 else if (key == "allowsLinkPreview") 1406 testOptions.allowsLinkPreview = parseBooleanTestHeaderValue(value); 1405 1407 pairStart = pairEnd + 1; 1406 1408 } -
trunk/Tools/WebKitTestRunner/TestOptions.h
r248960 r249368 96 96 bool enablePageCache { false }; 97 97 bool enableLazyImageLoading { false }; 98 bool allowsLinkPreview { true }; 98 99 99 100 double contentInsetTop { 0 }; … … 152 153 || contentMode != options.contentMode 153 154 || enableAppNap != options.enableAppNap 154 || enablePageCache != options.enablePageCache) 155 || enablePageCache != options.enablePageCache 156 || enableLazyImageLoading != options.enableLazyImageLoading 157 || allowsLinkPreview != options.allowsLinkPreview) 155 158 return false; 156 159 -
trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm
r249096 r249368 178 178 if (options.editable) 179 179 m_mainWebView->setEditable(true); 180 181 m_mainWebView->platformView().allowsLinkPreview = options.allowsLinkPreview; 180 182 } 181 183
Note: See TracChangeset
for help on using the changeset viewer.