Diff
Modified: branches/safari-609-branch/LayoutTests/ChangeLog (261528 => 261529)
--- branches/safari-609-branch/LayoutTests/ChangeLog 2020-05-12 00:22:20 UTC (rev 261528)
+++ branches/safari-609-branch/LayoutTests/ChangeLog 2020-05-12 00:22:26 UTC (rev 261529)
@@ -1,3 +1,87 @@
+2020-05-11 Alan Coon <alanc...@apple.com>
+
+ Cherry-pick r259669. rdar://problem/63111225
+
+ Preventing touch events should not prevent gestures installed above WKWebView from recognizing
+ https://bugs.webkit.org/show_bug.cgi?id=210080
+ <rdar://problem/61365814>
+
+ Reviewed by Tim Horton.
+
+ Source/WebKit:
+
+ Makes a small adjustment to native gesture deferral logic, so that gestures installed above WKWebView (in the
+ view hierarchy) are not prevented from recognizing by WKDeferringGestureRecognizer. This makes it possible for
+ WebKit clients to install custom gestures outside of WKWebView that cannot be prevented by web content, without
+ having to create a separate window and pass touches through to the WKWebView.
+
+ Test: fast/events/touch/ios/prevent-default-with-window-tap-gesture.html
+
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView deferringGestureRecognizer:shouldDeferOtherGestureRecognizer:]):
+
+ Tools:
+
+ Add a UIScriptController helper method that allows a test to install a tap gesture recognizer on the UIWindow
+ containing the web view. This method additionally takes a _javascript_ callback, which is invoked when the tap
+ gesture is recognized.
+
+ * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
+ * TestRunnerShared/UIScriptContext/UIScriptContext.h:
+ * TestRunnerShared/UIScriptContext/UIScriptController.h:
+ (WTR::UIScriptController::installTapGestureOnWindow):
+ * WebKitTestRunner/cocoa/TestRunnerWKWebView.h:
+ * WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
+ (-[TestRunnerWKWebView resetInteractionCallbacks]):
+ (-[TestRunnerWKWebView didRecognizeTapOnWindow]):
+ (-[TestRunnerWKWebView windowTapRecognizedCallback]):
+ (-[TestRunnerWKWebView setWindowTapRecognizedCallback:]):
+ (-[TestRunnerWKWebView willMoveToWindow:]):
+ (-[TestRunnerWKWebView didMoveToWindow]):
+ (-[TestRunnerWKWebView gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
+ * WebKitTestRunner/ios/UIScriptControllerIOS.h:
+ * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+ (WTR::UIScriptControllerIOS::installTapGestureOnWindow):
+
+ LayoutTests:
+
+ Add a new layout test to verify that calling preventDefault() on touchstart doesn't prevent gesture recognizers
+ installed above the WKWebView from recognizing. To do this, we use the new UIScriptController method to add a
+ gesture recognizer to the window containing the web view, and then simulate a tap over an element that prevents
+ the touchstart event.
+
+ * fast/events/touch/ios/prevent-default-with-window-tap-gesture-expected.txt: Added.
+ * fast/events/touch/ios/prevent-default-with-window-tap-gesture.html: Added.
+ * resources/ui-helper.js:
+ (window.UIHelper.async activateElementAfterInstallingTapGestureOnWindow.return.new.Promise.):
+ (window.UIHelper.async activateElementAfterInstallingTapGestureOnWindow.return.new.Promise):
+ (window.UIHelper.async activateElementAfterInstallingTapGestureOnWindow):
+ (window.UIHelper):
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259669 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2020-04-07 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Preventing touch events should not prevent gestures installed above WKWebView from recognizing
+ https://bugs.webkit.org/show_bug.cgi?id=210080
+ <rdar://problem/61365814>
+
+ Reviewed by Tim Horton.
+
+ Add a new layout test to verify that calling preventDefault() on touchstart doesn't prevent gesture recognizers
+ installed above the WKWebView from recognizing. To do this, we use the new UIScriptController method to add a
+ gesture recognizer to the window containing the web view, and then simulate a tap over an element that prevents
+ the touchstart event.
+
+ * fast/events/touch/ios/prevent-default-with-window-tap-gesture-expected.txt: Added.
+ * fast/events/touch/ios/prevent-default-with-window-tap-gesture.html: Added.
+ * resources/ui-helper.js:
+ (window.UIHelper.async activateElementAfterInstallingTapGestureOnWindow.return.new.Promise.):
+ (window.UIHelper.async activateElementAfterInstallingTapGestureOnWindow.return.new.Promise):
+ (window.UIHelper.async activateElementAfterInstallingTapGestureOnWindow):
+ (window.UIHelper):
+
2020-05-07 Russell Epstein <repst...@apple.com>
Cherry-pick r260598. rdar://problem/62978929
Added: branches/safari-609-branch/LayoutTests/fast/events/touch/ios/prevent-default-with-window-tap-gesture-expected.txt (0 => 261529)
--- branches/safari-609-branch/LayoutTests/fast/events/touch/ios/prevent-default-with-window-tap-gesture-expected.txt (rev 0)
+++ branches/safari-609-branch/LayoutTests/fast/events/touch/ios/prevent-default-with-window-tap-gesture-expected.txt 2020-05-12 00:22:26 UTC (rev 261529)
@@ -0,0 +1,11 @@
+This test verifies that a gesture recognizer installed on the window containing the web view is not prevented from recognizing if the web page prevents default on touchstart. This test requires WebKitTestRunner.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Tap gesture on window recognized
+PASS receivedTouchStart is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: branches/safari-609-branch/LayoutTests/fast/events/touch/ios/prevent-default-with-window-tap-gesture.html (0 => 261529)
--- branches/safari-609-branch/LayoutTests/fast/events/touch/ios/prevent-default-with-window-tap-gesture.html (rev 0)
+++ branches/safari-609-branch/LayoutTests/fast/events/touch/ios/prevent-default-with-window-tap-gesture.html 2020-05-12 00:22:26 UTC (rev 261529)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+<style>
+ #target {
+ border: solid 1px tomato;
+ width: 200px;
+ height: 200px;
+ }
+</style>
+<script>
+ jsTestIsAsync = true;
+
+ addEventListener("load", async () => {
+ description("This test verifies that a gesture recognizer installed on the window containing the web view is not prevented from recognizing if the web page prevents default on touchstart. This test requires WebKitTestRunner.");
+
+ receivedTouchStart = false;
+ const target = document.getElementById("target");
+ target.addEventListener("touchstart", event => {
+ receivedTouchStart = true;
+ event.preventDefault();
+ });
+ await UIHelper.activateElementAfterInstallingTapGestureOnWindow(target);
+
+ testPassed("Tap gesture on window recognized");
+ shouldBeTrue("receivedTouchStart");
+ finishJSTest();
+ });
+</script>
+</head>
+<body>
+ <div id="target"></div>
+</body>
+</html>
\ No newline at end of file
Modified: branches/safari-609-branch/LayoutTests/resources/ui-helper.js (261528 => 261529)
--- branches/safari-609-branch/LayoutTests/resources/ui-helper.js 2020-05-12 00:22:20 UTC (rev 261528)
+++ branches/safari-609-branch/LayoutTests/resources/ui-helper.js 2020-05-12 00:22:26 UTC (rev 261529)
@@ -1118,6 +1118,27 @@
})();`, resolve);
});
}
+
+ static async activateElementAfterInstallingTapGestureOnWindow(element)
+ {
+ if (!this.isWebKit2() || !this.isIOSFamily())
+ return activateElement(element);
+
+ const x = element.offsetLeft + element.offsetWidth / 2;
+ const y = element.offsetTop + element.offsetHeight / 2;
+ return new Promise(resolve => {
+ testRunner.runUIScript(`
+ (function() {
+ let progress = 0;
+ function incrementProgress() {
+ if (++progress == 2)
+ uiController.uiScriptComplete();
+ }
+ uiController.installTapGestureOnWindow(incrementProgress);
+ uiController.singleTapAtPoint(${x}, ${y}, incrementProgress);
+ })();`, resolve);
+ });
+ }
}
UIHelper.EventStreamBuilder = class {
Modified: branches/safari-609-branch/Source/WebKit/ChangeLog (261528 => 261529)
--- branches/safari-609-branch/Source/WebKit/ChangeLog 2020-05-12 00:22:20 UTC (rev 261528)
+++ branches/safari-609-branch/Source/WebKit/ChangeLog 2020-05-12 00:22:26 UTC (rev 261529)
@@ -1,5 +1,86 @@
2020-05-11 Alan Coon <alanc...@apple.com>
+ Cherry-pick r259669. rdar://problem/63111225
+
+ Preventing touch events should not prevent gestures installed above WKWebView from recognizing
+ https://bugs.webkit.org/show_bug.cgi?id=210080
+ <rdar://problem/61365814>
+
+ Reviewed by Tim Horton.
+
+ Source/WebKit:
+
+ Makes a small adjustment to native gesture deferral logic, so that gestures installed above WKWebView (in the
+ view hierarchy) are not prevented from recognizing by WKDeferringGestureRecognizer. This makes it possible for
+ WebKit clients to install custom gestures outside of WKWebView that cannot be prevented by web content, without
+ having to create a separate window and pass touches through to the WKWebView.
+
+ Test: fast/events/touch/ios/prevent-default-with-window-tap-gesture.html
+
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView deferringGestureRecognizer:shouldDeferOtherGestureRecognizer:]):
+
+ Tools:
+
+ Add a UIScriptController helper method that allows a test to install a tap gesture recognizer on the UIWindow
+ containing the web view. This method additionally takes a _javascript_ callback, which is invoked when the tap
+ gesture is recognized.
+
+ * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
+ * TestRunnerShared/UIScriptContext/UIScriptContext.h:
+ * TestRunnerShared/UIScriptContext/UIScriptController.h:
+ (WTR::UIScriptController::installTapGestureOnWindow):
+ * WebKitTestRunner/cocoa/TestRunnerWKWebView.h:
+ * WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
+ (-[TestRunnerWKWebView resetInteractionCallbacks]):
+ (-[TestRunnerWKWebView didRecognizeTapOnWindow]):
+ (-[TestRunnerWKWebView windowTapRecognizedCallback]):
+ (-[TestRunnerWKWebView setWindowTapRecognizedCallback:]):
+ (-[TestRunnerWKWebView willMoveToWindow:]):
+ (-[TestRunnerWKWebView didMoveToWindow]):
+ (-[TestRunnerWKWebView gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
+ * WebKitTestRunner/ios/UIScriptControllerIOS.h:
+ * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+ (WTR::UIScriptControllerIOS::installTapGestureOnWindow):
+
+ LayoutTests:
+
+ Add a new layout test to verify that calling preventDefault() on touchstart doesn't prevent gesture recognizers
+ installed above the WKWebView from recognizing. To do this, we use the new UIScriptController method to add a
+ gesture recognizer to the window containing the web view, and then simulate a tap over an element that prevents
+ the touchstart event.
+
+ * fast/events/touch/ios/prevent-default-with-window-tap-gesture-expected.txt: Added.
+ * fast/events/touch/ios/prevent-default-with-window-tap-gesture.html: Added.
+ * resources/ui-helper.js:
+ (window.UIHelper.async activateElementAfterInstallingTapGestureOnWindow.return.new.Promise.):
+ (window.UIHelper.async activateElementAfterInstallingTapGestureOnWindow.return.new.Promise):
+ (window.UIHelper.async activateElementAfterInstallingTapGestureOnWindow):
+ (window.UIHelper):
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259669 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2020-04-07 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Preventing touch events should not prevent gestures installed above WKWebView from recognizing
+ https://bugs.webkit.org/show_bug.cgi?id=210080
+ <rdar://problem/61365814>
+
+ Reviewed by Tim Horton.
+
+ Makes a small adjustment to native gesture deferral logic, so that gestures installed above WKWebView (in the
+ view hierarchy) are not prevented from recognizing by WKDeferringGestureRecognizer. This makes it possible for
+ WebKit clients to install custom gestures outside of WKWebView that cannot be prevented by web content, without
+ having to create a separate window and pass touches through to the WKWebView.
+
+ Test: fast/events/touch/ios/prevent-default-with-window-tap-gesture.html
+
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView deferringGestureRecognizer:shouldDeferOtherGestureRecognizer:]):
+
+2020-05-11 Alan Coon <alanc...@apple.com>
+
Cherry-pick r255456. rdar://problem/63112259
REGRESSION (r253267): Swipe from edge on Twitter images no longer goes back
Modified: branches/safari-609-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (261528 => 261529)
--- branches/safari-609-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2020-05-12 00:22:20 UTC (rev 261528)
+++ branches/safari-609-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2020-05-12 00:22:26 UTC (rev 261529)
@@ -6835,6 +6835,20 @@
if ([_webView _isNavigationSwipeGestureRecognizer:gestureRecognizer])
return NO;
+ auto webView = _webView.getAutoreleased();
+ auto view = gestureRecognizer.view;
+ BOOL gestureIsInstalledOnOrUnderWebView = NO;
+ while (view) {
+ if (view == webView) {
+ gestureIsInstalledOnOrUnderWebView = YES;
+ break;
+ }
+ view = view.superview;
+ }
+
+ if (!gestureIsInstalledOnOrUnderWebView)
+ return NO;
+
#if ENABLE(IOS_TOUCH_EVENTS)
auto isOneFingerMultipleTapGesture = [](UIGestureRecognizer *gesture) -> BOOL {
if (![gesture isKindOfClass:UITapGestureRecognizer.class])
Modified: branches/safari-609-branch/Tools/ChangeLog (261528 => 261529)
--- branches/safari-609-branch/Tools/ChangeLog 2020-05-12 00:22:20 UTC (rev 261528)
+++ branches/safari-609-branch/Tools/ChangeLog 2020-05-12 00:22:26 UTC (rev 261529)
@@ -1,3 +1,95 @@
+2020-05-11 Alan Coon <alanc...@apple.com>
+
+ Cherry-pick r259669. rdar://problem/63111225
+
+ Preventing touch events should not prevent gestures installed above WKWebView from recognizing
+ https://bugs.webkit.org/show_bug.cgi?id=210080
+ <rdar://problem/61365814>
+
+ Reviewed by Tim Horton.
+
+ Source/WebKit:
+
+ Makes a small adjustment to native gesture deferral logic, so that gestures installed above WKWebView (in the
+ view hierarchy) are not prevented from recognizing by WKDeferringGestureRecognizer. This makes it possible for
+ WebKit clients to install custom gestures outside of WKWebView that cannot be prevented by web content, without
+ having to create a separate window and pass touches through to the WKWebView.
+
+ Test: fast/events/touch/ios/prevent-default-with-window-tap-gesture.html
+
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView deferringGestureRecognizer:shouldDeferOtherGestureRecognizer:]):
+
+ Tools:
+
+ Add a UIScriptController helper method that allows a test to install a tap gesture recognizer on the UIWindow
+ containing the web view. This method additionally takes a _javascript_ callback, which is invoked when the tap
+ gesture is recognized.
+
+ * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
+ * TestRunnerShared/UIScriptContext/UIScriptContext.h:
+ * TestRunnerShared/UIScriptContext/UIScriptController.h:
+ (WTR::UIScriptController::installTapGestureOnWindow):
+ * WebKitTestRunner/cocoa/TestRunnerWKWebView.h:
+ * WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
+ (-[TestRunnerWKWebView resetInteractionCallbacks]):
+ (-[TestRunnerWKWebView didRecognizeTapOnWindow]):
+ (-[TestRunnerWKWebView windowTapRecognizedCallback]):
+ (-[TestRunnerWKWebView setWindowTapRecognizedCallback:]):
+ (-[TestRunnerWKWebView willMoveToWindow:]):
+ (-[TestRunnerWKWebView didMoveToWindow]):
+ (-[TestRunnerWKWebView gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
+ * WebKitTestRunner/ios/UIScriptControllerIOS.h:
+ * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+ (WTR::UIScriptControllerIOS::installTapGestureOnWindow):
+
+ LayoutTests:
+
+ Add a new layout test to verify that calling preventDefault() on touchstart doesn't prevent gesture recognizers
+ installed above the WKWebView from recognizing. To do this, we use the new UIScriptController method to add a
+ gesture recognizer to the window containing the web view, and then simulate a tap over an element that prevents
+ the touchstart event.
+
+ * fast/events/touch/ios/prevent-default-with-window-tap-gesture-expected.txt: Added.
+ * fast/events/touch/ios/prevent-default-with-window-tap-gesture.html: Added.
+ * resources/ui-helper.js:
+ (window.UIHelper.async activateElementAfterInstallingTapGestureOnWindow.return.new.Promise.):
+ (window.UIHelper.async activateElementAfterInstallingTapGestureOnWindow.return.new.Promise):
+ (window.UIHelper.async activateElementAfterInstallingTapGestureOnWindow):
+ (window.UIHelper):
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259669 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2020-04-07 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Preventing touch events should not prevent gestures installed above WKWebView from recognizing
+ https://bugs.webkit.org/show_bug.cgi?id=210080
+ <rdar://problem/61365814>
+
+ Reviewed by Tim Horton.
+
+ Add a UIScriptController helper method that allows a test to install a tap gesture recognizer on the UIWindow
+ containing the web view. This method additionally takes a _javascript_ callback, which is invoked when the tap
+ gesture is recognized.
+
+ * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
+ * TestRunnerShared/UIScriptContext/UIScriptContext.h:
+ * TestRunnerShared/UIScriptContext/UIScriptController.h:
+ (WTR::UIScriptController::installTapGestureOnWindow):
+ * WebKitTestRunner/cocoa/TestRunnerWKWebView.h:
+ * WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
+ (-[TestRunnerWKWebView resetInteractionCallbacks]):
+ (-[TestRunnerWKWebView didRecognizeTapOnWindow]):
+ (-[TestRunnerWKWebView windowTapRecognizedCallback]):
+ (-[TestRunnerWKWebView setWindowTapRecognizedCallback:]):
+ (-[TestRunnerWKWebView willMoveToWindow:]):
+ (-[TestRunnerWKWebView didMoveToWindow]):
+ (-[TestRunnerWKWebView gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
+ * WebKitTestRunner/ios/UIScriptControllerIOS.h:
+ * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+ (WTR::UIScriptControllerIOS::installTapGestureOnWindow):
+
2020-05-08 Ryan Haddad <ryanhad...@apple.com>
Cherry-pick r260484. rdar://problem/62140724
Modified: branches/safari-609-branch/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl (261528 => 261529)
--- branches/safari-609-branch/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl 2020-05-12 00:22:20 UTC (rev 261528)
+++ branches/safari-609-branch/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl 2020-05-12 00:22:26 UTC (rev 261529)
@@ -322,6 +322,8 @@
void removeViewFromWindow(object callback);
void addViewToWindow(object callback);
+ void installTapGestureOnWindow(object callback);
+
void overridePreference(DOMString preference, DOMString value);
void setSafeAreaInsets(double top, double right, double bottom, double left);
Modified: branches/safari-609-branch/Tools/TestRunnerShared/UIScriptContext/UIScriptContext.h (261528 => 261529)
--- branches/safari-609-branch/Tools/TestRunnerShared/UIScriptContext/UIScriptContext.h 2020-05-12 00:22:20 UTC (rev 261528)
+++ branches/safari-609-branch/Tools/TestRunnerShared/UIScriptContext/UIScriptContext.h 2020-05-12 00:22:26 UTC (rev 261529)
@@ -64,6 +64,7 @@
CallbackTypeDidShowContextMenu,
CallbackTypeDidDismissContextMenu,
CallbackTypeWillCreateNewPage,
+ CallbackTypeWindowTapRecognized,
CallbackTypeNonPersistent = firstNonPersistentCallbackID
} CallbackType;
Modified: branches/safari-609-branch/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h (261528 => 261529)
--- branches/safari-609-branch/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h 2020-05-12 00:22:20 UTC (rev 261528)
+++ branches/safari-609-branch/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h 2020-05-12 00:22:26 UTC (rev 261529)
@@ -117,6 +117,8 @@
virtual void removeViewFromWindow(JSValueRef) { notImplemented(); }
virtual void addViewToWindow(JSValueRef) { notImplemented(); }
+ virtual void installTapGestureOnWindow(JSValueRef) { notImplemented(); }
+
// Compositing
virtual JSObjectRef propertiesOfLayerWithID(uint64_t layerID) const { notImplemented(); return nullptr; }
Modified: branches/safari-609-branch/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h (261528 => 261529)
--- branches/safari-609-branch/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h 2020-05-12 00:22:20 UTC (rev 261528)
+++ branches/safari-609-branch/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h 2020-05-12 00:22:26 UTC (rev 261529)
@@ -45,6 +45,7 @@
@property (nonatomic, copy) void (^didDismissPopoverCallback)(void);
@property (nonatomic, copy) void (^didEndScrollingCallback)(void);
@property (nonatomic, copy) void (^rotationDidEndCallback)(void);
+@property (nonatomic, copy) void (^windowTapRecognizedCallback)(void);
@property (nonatomic, copy) NSString *accessibilitySpeakSelectionContent;
- (void)setAllowedMenuActions:(NSArray<NSString *> *)actions;
Modified: branches/safari-609-branch/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm (261528 => 261529)
--- branches/safari-609-branch/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm 2020-05-12 00:22:20 UTC (rev 261528)
+++ branches/safari-609-branch/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm 2020-05-12 00:22:26 UTC (rev 261529)
@@ -55,12 +55,20 @@
BlockPtr<void()> callback;
};
-@interface TestRunnerWKWebView () <WKUIDelegatePrivate> {
+@interface TestRunnerWKWebView () <WKUIDelegatePrivate
+#if PLATFORM(IOS_FAMILY)
+ , UIGestureRecognizerDelegate
+#endif
+> {
RetainPtr<NSNumber> m_stableStateOverride;
BOOL _isInteractingWithFormControl;
BOOL _scrollingUpdatesDisabled;
Optional<CustomMenuActionInfo> _customMenuActionInfo;
RetainPtr<NSArray<NSString *>> _allowedMenuActions;
+#if PLATFORM(IOS_FAMILY)
+ RetainPtr<UITapGestureRecognizer> _windowTapGestureRecognizer;
+ BlockPtr<void()> _windowTapRecognizedCallback;
+#endif
}
@property (nonatomic, copy) void (^zoomToScaleCompletionHandler)(void);
@@ -172,6 +180,7 @@
self.didDismissPopoverCallback = nil;
self.didEndScrollingCallback = nil;
self.rotationDidEndCallback = nil;
+ self.windowTapRecognizedCallback = nil;
#endif // PLATFORM(IOS_FAMILY)
}
@@ -409,6 +418,50 @@
self.rotationDidEndCallback();
}
+- (void)didRecognizeTapOnWindow
+{
+ ASSERT(self.windowTapRecognizedCallback);
+ if (self.windowTapRecognizedCallback)
+ self.windowTapRecognizedCallback();
+}
+
+- (void(^)())windowTapRecognizedCallback
+{
+ return _windowTapRecognizedCallback.get();
+}
+
+- (void)setWindowTapRecognizedCallback:(void(^)())windowTapRecognizedCallback
+{
+ _windowTapRecognizedCallback = windowTapRecognizedCallback;
+
+ if (windowTapRecognizedCallback && !_windowTapGestureRecognizer) {
+ ASSERT(self.window);
+ _windowTapGestureRecognizer = adoptNS([[UITapGestureRecognizer alloc] init]);
+ [_windowTapGestureRecognizer setDelegate:self];
+ [_windowTapGestureRecognizer addTarget:self action:@selector(didRecognizeTapOnWindow)];
+ [self.window addGestureRecognizer:_windowTapGestureRecognizer.get()];
+ } else if (!windowTapRecognizedCallback && _windowTapGestureRecognizer) {
+ [self.window removeGestureRecognizer:_windowTapGestureRecognizer.get()];
+ _windowTapGestureRecognizer = nil;
+ }
+}
+
+- (void)willMoveToWindow:(UIWindow *)window
+{
+ [super willMoveToWindow:window];
+
+ if (_windowTapGestureRecognizer)
+ [self.window removeGestureRecognizer:_windowTapGestureRecognizer.get()];
+}
+
+- (void)didMoveToWindow
+{
+ [super didMoveToWindow];
+
+ if (_windowTapGestureRecognizer)
+ [self.window addGestureRecognizer:_windowTapGestureRecognizer.get()];
+}
+
- (void)_accessibilityDidGetSpeakSelectionContent:(NSString *)content
{
self.accessibilitySpeakSelectionContent = content;
@@ -449,6 +502,13 @@
[self _invokeHideKeyboardCallbackIfNecessary];
}
+#pragma mark - UIGestureRecognizerDelegate
+
+- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
+{
+ return gestureRecognizer == _windowTapGestureRecognizer;
+}
+
#endif // PLATFORM(IOS_FAMILY)
@end
Modified: branches/safari-609-branch/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h (261528 => 261529)
--- branches/safari-609-branch/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h 2020-05-12 00:22:20 UTC (rev 261528)
+++ branches/safari-609-branch/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h 2020-05-12 00:22:26 UTC (rev 261529)
@@ -140,6 +140,7 @@
void setHardwareKeyboardAttached(bool) override;
void setAllowsViewportShrinkToFit(bool) override;
void copyText(JSStringRef) override;
+ void installTapGestureOnWindow(JSValueRef) override;
void setDidStartFormControlInteractionCallback(JSValueRef) override;
void setDidEndFormControlInteractionCallback(JSValueRef) override;
Modified: branches/safari-609-branch/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm (261528 => 261529)
--- branches/safari-609-branch/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm 2020-05-12 00:22:20 UTC (rev 261528)
+++ branches/safari-609-branch/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm 2020-05-12 00:22:26 UTC (rev 261529)
@@ -1225,6 +1225,16 @@
UIPasteboard.generalPasteboard.string = text->string();
}
+void UIScriptControllerIOS::installTapGestureOnWindow(JSValueRef callback)
+{
+ m_context->registerCallback(callback, CallbackTypeWindowTapRecognized);
+ webView().windowTapRecognizedCallback = makeBlockPtr([this, strongThis = makeRef(*this)] {
+ if (!m_context)
+ return;
+ m_context->fireCallback(CallbackTypeWindowTapRecognized);
+ }).get();
}
+}
+
#endif // PLATFORM(IOS_FAMILY)