Title: [275546] trunk
Revision
275546
Author
wenson_hs...@apple.com
Date
2021-04-06 13:39:10 -0700 (Tue, 06 Apr 2021)

Log Message

REGRESSION (r274610): Unable to drag images when image extraction is enabled
https://bugs.webkit.org/show_bug.cgi?id=224211
<rdar://problem/76229563>

Reviewed by Tim Horton.

Source/WebKit:

r274610 introduced a new deferring gesture recognizer intended to prevent several text interaction gestures from
recognizing during pending image extraction. However, this also causes dragging on iOS to fail, since the
gesture used to initiate dragging is excluded by the new deferring gesture recognizer. To fix this, allow the
new deferring gesture to recognize simultaneously alongside all gestures with the exception of only the gestures
it is intended to defer (i.e. text interaction gestures).

Test: fast/events/ios/dragstart-on-image-by-long-pressing.html

* UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h:
* UIProcess/API/ios/WKWebViewTestingIOS.mm:
(-[WKWebView _isAnimatingDragCancel]):
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[UIGestureRecognizer _wk_isTapAndAHalf]):

Add a WebKit category method that returns whether or not a gesture recognizer is a tap-and-a-half gesture.

(-[WKContentView gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):

Allow the image extraction deferring gesture to recognize alongside all other gestures, with the exception of
the text interaction gestures determined by `-shouldDeferGestureDueToImageExtraction:`. This limits the impact
of this new deferring gesture, such that it only affects the text interaction gestures it is intended to defer.

(-[WKContentView shouldDeferGestureDueToImageExtraction:]):

Add a helper method to determine whether or not a gesture recognizer should be deferred, due to pending image
extraction. We pull this logic behind a helper method because it's now consulted from two call sites.

(-[WKContentView deferringGestureRecognizer:shouldDeferOtherGestureRecognizer:]):
(-[WKContentView dragInteraction:item:willAnimateCancelWithAnimator:]):
(-[WKContentView isAnimatingDragCancel]):

Add a testing hook to return whether or not the drag cancel animation is running. See Tools/ChangeLog and the
new layout test for more detail.

(tapAndAHalfRecognizerClass): Deleted.

Tools:

Add support for some new testing infrastructure; see below for more details.

* TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* TestRunnerShared/UIScriptContext/UIScriptController.h:
(WTR::UIScriptController::isAnimatingDragCancel const):

Add a new testing hook to return whether or not the web view's drag interaction is currently animating a drag
cancel (i.e., the drag preview is animating back to its original frame).

* WebKitTestRunner/TestOptions.cpp:
(WTR::TestOptions::defaults):
(WTR::TestOptions::keyTypeMapping):
* WebKitTestRunner/TestOptions.h:
(WTR::TestOptions::dragInteractionPolicy const):

Add a test option that allows tests to override the drag interaction policy to "always-allow",
"always-disallow", and the default value. This option allows us to force drag and drop to be enabled when
testing on iPhone simulator.

* WebKitTestRunner/ios/TestControllerIOS.mm:
(WTR::dragInteractionPolicy):
(WTR::TestController::platformResetStateToConsistentValues):
* WebKitTestRunner/ios/UIScriptControllerIOS.h:
* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptControllerIOS::isAnimatingDragCancel const):

LayoutTests:

Add a new layout test that initiates dragging on an image using a synthesized event stream, and verifies that
"dragstart" and "dragend" events are dispatched on the image.

* fast/events/ios/dragstart-on-image-by-long-pressing-expected.txt: Added.
* fast/events/ios/dragstart-on-image-by-long-pressing.html: Added.
* resources/ui-helper.js:
(window.UIHelper.isAnimatingDragCancel):

Add a `UIHelper` method that returns whether or not the dragging animation is being cancelled. The new test uses
this hook to wait for the drag cancel animation to end before proceeding to the next test.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (275545 => 275546)


--- trunk/LayoutTests/ChangeLog	2021-04-06 20:26:30 UTC (rev 275545)
+++ trunk/LayoutTests/ChangeLog	2021-04-06 20:39:10 UTC (rev 275546)
@@ -1,3 +1,22 @@
+2021-04-06  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        REGRESSION (r274610): Unable to drag images when image extraction is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=224211
+        <rdar://problem/76229563>
+
+        Reviewed by Tim Horton.
+
+        Add a new layout test that initiates dragging on an image using a synthesized event stream, and verifies that
+        "dragstart" and "dragend" events are dispatched on the image.
+
+        * fast/events/ios/dragstart-on-image-by-long-pressing-expected.txt: Added.
+        * fast/events/ios/dragstart-on-image-by-long-pressing.html: Added.
+        * resources/ui-helper.js:
+        (window.UIHelper.isAnimatingDragCancel):
+
+        Add a `UIHelper` method that returns whether or not the dragging animation is being cancelled. The new test uses
+        this hook to wait for the drag cancel animation to end before proceeding to the next test.
+
 2021-04-06  Ryosuke Niwa  <rn...@webkit.org>
 
         Assert failure in isCloneInShadowTreeOfSVGUseElement

Added: trunk/LayoutTests/fast/events/ios/dragstart-on-image-by-long-pressing-expected.txt (0 => 275546)


--- trunk/LayoutTests/fast/events/ios/dragstart-on-image-by-long-pressing-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/ios/dragstart-on-image-by-long-pressing-expected.txt	2021-04-06 20:39:10 UTC (rev 275546)
@@ -0,0 +1,12 @@
+
+This test requires WebKitTestRunner. To manually test, load the page in a configuration where drag and drop is enabled by default; start a drag on the image above by long-pressing it, and then drag the image off to the side of the screen and let go. 'dragstart' and 'dragend' events should be dispatched.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Started drag
+PASS Ended drag
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/events/ios/dragstart-on-image-by-long-pressing.html (0 => 275546)


--- trunk/LayoutTests/fast/events/ios/dragstart-on-image-by-long-pressing.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/ios/dragstart-on-image-by-long-pressing.html	2021-04-06 20:39:10 UTC (rev 275546)
@@ -0,0 +1,53 @@
+<!DOCTYPE HTML><!-- webkit-test-runner [ dragInteractionPolicy=always-enable useFlexibleViewport=true ] -->
+<html>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<head>
+<style>
+body, html {
+    margin: 0;
+}
+</style>
+<script src=""
+<script src=""
+<script>
+jsTestIsAsync = true;
+
+addEventListener("load", async () => {
+    description("This test requires WebKitTestRunner. To manually test, load the page in a configuration where drag and drop is enabled by default; start a drag on the image above by long-pressing it, and then drag the image off to the side of the screen and let go. 'dragstart' and 'dragend' events should be dispatched.");
+
+    let image = document.querySelector("img");
+    image.addEventListener("dragstart", () => {
+        testPassed("Started drag");
+    });
+
+    image.addEventListener("dragend", () => {
+        testPassed("Ended drag");
+    });
+
+    if (!window.testRunner)
+        return;
+
+    let clientRect = image.getBoundingClientRect();
+    await UIHelper.sendEventStream(new UIHelper.EventStreamBuilder()
+        .begin(clientRect.left + (clientRect.width / 2), clientRect.top + (clientRect.height / 2))
+        .wait(1.5)
+        .move(300, 300, 1)
+        .wait(0.5)
+        .end()
+        .takeResult());
+
+    while (true) {
+        if (!await UIHelper.isAnimatingDragCancel())
+            break;
+    }
+
+    finishJSTest();
+});
+</script>
+</head>
+<body>
+    <img src=""
+    <p id="description"></p>
+    <p id="console"></p>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/LayoutTests/resources/ui-helper.js (275545 => 275546)


--- trunk/LayoutTests/resources/ui-helper.js	2021-04-06 20:26:30 UTC (rev 275545)
+++ trunk/LayoutTests/resources/ui-helper.js	2021-04-06 20:39:10 UTC (rev 275546)
@@ -370,6 +370,13 @@
         });
     }
 
+    static isAnimatingDragCancel()
+    {
+        return new Promise(resolve => {
+            testRunner.runUIScript(`uiController.isAnimatingDragCancel`, result => resolve(result === "true"));
+        });
+    }
+
     static ensurePresentationUpdate()
     {
         if (!this.isWebKit2()) {

Modified: trunk/Source/WebKit/ChangeLog (275545 => 275546)


--- trunk/Source/WebKit/ChangeLog	2021-04-06 20:26:30 UTC (rev 275545)
+++ trunk/Source/WebKit/ChangeLog	2021-04-06 20:39:10 UTC (rev 275546)
@@ -1,3 +1,48 @@
+2021-04-06  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        REGRESSION (r274610): Unable to drag images when image extraction is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=224211
+        <rdar://problem/76229563>
+
+        Reviewed by Tim Horton.
+
+        r274610 introduced a new deferring gesture recognizer intended to prevent several text interaction gestures from
+        recognizing during pending image extraction. However, this also causes dragging on iOS to fail, since the
+        gesture used to initiate dragging is excluded by the new deferring gesture recognizer. To fix this, allow the
+        new deferring gesture to recognize simultaneously alongside all gestures with the exception of only the gestures
+        it is intended to defer (i.e. text interaction gestures).
+
+        Test: fast/events/ios/dragstart-on-image-by-long-pressing.html
+
+        * UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h:
+        * UIProcess/API/ios/WKWebViewTestingIOS.mm:
+        (-[WKWebView _isAnimatingDragCancel]):
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[UIGestureRecognizer _wk_isTapAndAHalf]):
+
+        Add a WebKit category method that returns whether or not a gesture recognizer is a tap-and-a-half gesture.
+
+        (-[WKContentView gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
+
+        Allow the image extraction deferring gesture to recognize alongside all other gestures, with the exception of
+        the text interaction gestures determined by `-shouldDeferGestureDueToImageExtraction:`. This limits the impact
+        of this new deferring gesture, such that it only affects the text interaction gestures it is intended to defer.
+
+        (-[WKContentView shouldDeferGestureDueToImageExtraction:]):
+
+        Add a helper method to determine whether or not a gesture recognizer should be deferred, due to pending image
+        extraction. We pull this logic behind a helper method because it's now consulted from two call sites.
+
+        (-[WKContentView deferringGestureRecognizer:shouldDeferOtherGestureRecognizer:]):
+        (-[WKContentView dragInteraction:item:willAnimateCancelWithAnimator:]):
+        (-[WKContentView isAnimatingDragCancel]):
+
+        Add a testing hook to return whether or not the drag cancel animation is running. See Tools/ChangeLog and the
+        new layout test for more detail.
+
+        (tapAndAHalfRecognizerClass): Deleted.
+
 2021-04-06  Alex Christensen  <achristen...@webkit.org>
 
         Hold strong reference to xpc_connection_t in XPCServiceEventHandler

Modified: trunk/Source/WebKit/UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h (275545 => 275546)


--- trunk/Source/WebKit/UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h	2021-04-06 20:26:30 UTC (rev 275545)
+++ trunk/Source/WebKit/UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h	2021-04-06 20:39:10 UTC (rev 275546)
@@ -42,6 +42,7 @@
 @property (nonatomic, readonly) NSString *_scrollingTreeAsText;
 @property (nonatomic, readonly) NSNumber *_stableStateOverride;
 @property (nonatomic, readonly) CGRect _dragCaretRect;
+@property (nonatomic, readonly, getter=_isAnimatingDragCancel) BOOL _animatingDragCancel;
 
 - (void)keyboardAccessoryBarNext;
 - (void)keyboardAccessoryBarPrevious;

Modified: trunk/Source/WebKit/UIProcess/API/ios/WKWebViewTestingIOS.mm (275545 => 275546)


--- trunk/Source/WebKit/UIProcess/API/ios/WKWebViewTestingIOS.mm	2021-04-06 20:26:30 UTC (rev 275545)
+++ trunk/Source/WebKit/UIProcess/API/ios/WKWebViewTestingIOS.mm	2021-04-06 20:39:10 UTC (rev 275546)
@@ -313,6 +313,15 @@
 #endif
 }
 
+- (BOOL)_isAnimatingDragCancel
+{
+#if ENABLE(DRAG_SUPPORT)
+    return [_contentView isAnimatingDragCancel];
+#else
+    return NO;
+#endif
+}
+
 - (void)_simulateElementAction:(_WKElementActionType)actionType atLocation:(CGPoint)location
 {
     [_contentView _simulateElementAction:actionType atLocation:location];

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (275545 => 275546)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2021-04-06 20:26:30 UTC (rev 275545)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2021-04-06 20:39:10 UTC (rev 275546)
@@ -438,6 +438,7 @@
     WebKit::DragDropInteractionState _dragDropInteractionState;
     RetainPtr<UIDragInteraction> _dragInteraction;
     RetainPtr<UIDropInteraction> _dropInteraction;
+    BOOL _isAnimatingDragCancel;
     BOOL _shouldRestoreCalloutBarAfterDrop;
     RetainPtr<UIView> _visibleContentViewSnapshot;
     RetainPtr<UIView> _unselectedContentSnapshot;
@@ -735,6 +736,9 @@
 @property (nonatomic, readonly) NSString *formInputLabel;
 @property (nonatomic, readonly) WKDateTimeInputControl *dateTimeInputControl;
 @property (nonatomic, readonly) WKFormSelectControl *selectControl;
+#if ENABLE(DRAG_SUPPORT)
+@property (nonatomic, readonly, getter=isAnimatingDragCancel) BOOL animatingDragCancel;
+#endif
 
 @end
 

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (275545 => 275546)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-04-06 20:26:30 UTC (rev 275545)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-04-06 20:39:10 UTC (rev 275546)
@@ -681,6 +681,16 @@
     [self setEnabled:YES];
 }
 
+- (BOOL)_wk_isTapAndAHalf
+{
+    static dispatch_once_t onceToken;
+    static Class tapAndAHalfGestureRecognizerClass;
+    dispatch_once(&onceToken, ^{
+        tapAndAHalfGestureRecognizerClass = NSClassFromString(@"UITapAndAHalfRecognizer");
+    });
+    return [self isKindOfClass:tapAndAHalfGestureRecognizerClass];
+}
+
 @end
 
 @interface WKContentView (WKInteractionPrivate)
@@ -2226,16 +2236,6 @@
     return (a == x && b == y) || (b == x && a == y);
 }
 
-static Class tapAndAHalfRecognizerClass()
-{
-    static dispatch_once_t onceToken;
-    static Class theClass;
-    dispatch_once(&onceToken, ^{
-        theClass = NSClassFromString(@"UITapAndAHalfRecognizer");
-    });
-    return theClass;
-}
-
 - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer*)otherGestureRecognizer
 {
     for (WKDeferringGestureRecognizer *gesture in self.deferringGestures) {
@@ -2246,6 +2246,14 @@
     if ([gestureRecognizer isKindOfClass:WKDeferringGestureRecognizer.class] && [otherGestureRecognizer isKindOfClass:WKDeferringGestureRecognizer.class])
         return YES;
 
+#if ENABLE(IMAGE_EXTRACTION)
+    if (gestureRecognizer == _imageExtractionDeferringGestureRecognizer)
+        return ![self shouldDeferGestureDueToImageExtraction:otherGestureRecognizer];
+
+    if (otherGestureRecognizer == _imageExtractionDeferringGestureRecognizer)
+        return ![self shouldDeferGestureDueToImageExtraction:gestureRecognizer];
+#endif
+
     if (isSamePair(gestureRecognizer, otherGestureRecognizer, _highlightLongPressGestureRecognizer.get(), _longPressGestureRecognizer.get()))
         return YES;
 
@@ -2274,7 +2282,7 @@
         if (gestureRecognizer == loupeGesture || otherGestureRecognizer == loupeGesture)
             return YES;
 
-        if ([gestureRecognizer isKindOfClass:tapAndAHalfRecognizerClass()] || [otherGestureRecognizer isKindOfClass:tapAndAHalfRecognizerClass()])
+        if (gestureRecognizer._wk_isTapAndAHalf || otherGestureRecognizer._wk_isTapAndAHalf)
             return YES;
     }
 
@@ -7513,6 +7521,15 @@
     return WebCore::IOSApplication::isDataActivation();
 }
 
+#if ENABLE(IMAGE_EXTRACTION)
+
+- (BOOL)shouldDeferGestureDueToImageExtraction:(UIGestureRecognizer *)gesture
+{
+    return gesture == [_textInteractionAssistant loupeGesture] || gesture._wk_isTapAndAHalf || gesture == [_textInteractionAssistant forcePressGesture];
+}
+
+#endif // ENABLE(IMAGE_EXTRACTION)
+
 #if HAVE(PASTEBOARD_DATA_OWNER)
 
 static WebCore::DataOwnerType coreDataOwnerType(_UIDataOwner platformType)
@@ -7659,12 +7676,9 @@
     if (gestureRecognizer == _touchEventGestureRecognizer)
         return NO;
 
-    BOOL isLoupeGesture = gestureRecognizer == [_textInteractionAssistant loupeGesture];
-    BOOL isTapAndAHalfGesture = [gestureRecognizer isKindOfClass:tapAndAHalfRecognizerClass()];
-
 #if ENABLE(IMAGE_EXTRACTION)
     if (deferringGestureRecognizer == _imageExtractionDeferringGestureRecognizer)
-        return isLoupeGesture || isTapAndAHalfGesture || gestureRecognizer == [_textInteractionAssistant forcePressGesture];
+        return [self shouldDeferGestureDueToImageExtraction:gestureRecognizer];
 #endif
 
     auto mayDelayResetOfContainingSubgraph = [&](UIGestureRecognizer *gesture) -> BOOL {
@@ -7678,10 +7692,10 @@
             return YES;
 #endif
 
-        if (isTapAndAHalfGesture)
+        if (gestureRecognizer._wk_isTapAndAHalf)
             return YES;
 
-        if (isLoupeGesture)
+        if (gestureRecognizer == [_textInteractionAssistant loupeGesture])
             return YES;
 
         if ([gesture isKindOfClass:UITapGestureRecognizer.class]) {
@@ -8685,13 +8699,15 @@
 
 - (void)dragInteraction:(UIDragInteraction *)interaction item:(UIDragItem *)item willAnimateCancelWithAnimator:(id <UIDragAnimating>)animator
 {
+    _isAnimatingDragCancel = YES;
     RELEASE_LOG(DragAndDrop, "Drag interaction willAnimateCancelWithAnimator");
     [animator addCompletion:[protectedSelf = retainPtr(self), page = _page] (UIViewAnimatingPosition finalPosition) {
         RELEASE_LOG(DragAndDrop, "Drag interaction willAnimateCancelWithAnimator (animation completion block fired)");
         page->dragCancelled();
         if (auto completion = protectedSelf->_dragDropInteractionState.takeDragCancelSetDownBlock()) {
-            page->callAfterNextPresentationUpdate([completion] (WebKit::CallbackBase::Error) {
+            page->callAfterNextPresentationUpdate([completion, protectedSelf] (WebKit::CallbackBase::Error) {
                 completion();
+                protectedSelf->_isAnimatingDragCancel = NO;
             });
         }
     }];
@@ -9543,6 +9559,15 @@
     return nil;
 }
 
+#if ENABLE(DRAG_SUPPORT)
+
+- (BOOL)isAnimatingDragCancel
+{
+    return _isAnimatingDragCancel;
+}
+
+#endif // ENABLE(DRAG_SUPPORT)
+
 - (void)_simulateTextEntered:(NSString *)text
 {
 #if HAVE(PEPPER_UI_CORE)

Modified: trunk/Tools/ChangeLog (275545 => 275546)


--- trunk/Tools/ChangeLog	2021-04-06 20:26:30 UTC (rev 275545)
+++ trunk/Tools/ChangeLog	2021-04-06 20:39:10 UTC (rev 275546)
@@ -1,3 +1,37 @@
+2021-04-06  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        REGRESSION (r274610): Unable to drag images when image extraction is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=224211
+        <rdar://problem/76229563>
+
+        Reviewed by Tim Horton.
+
+        Add support for some new testing infrastructure; see below for more details.
+
+        * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
+        * TestRunnerShared/UIScriptContext/UIScriptController.h:
+        (WTR::UIScriptController::isAnimatingDragCancel const):
+
+        Add a new testing hook to return whether or not the web view's drag interaction is currently animating a drag
+        cancel (i.e., the drag preview is animating back to its original frame).
+
+        * WebKitTestRunner/TestOptions.cpp:
+        (WTR::TestOptions::defaults):
+        (WTR::TestOptions::keyTypeMapping):
+        * WebKitTestRunner/TestOptions.h:
+        (WTR::TestOptions::dragInteractionPolicy const):
+
+        Add a test option that allows tests to override the drag interaction policy to "always-allow",
+        "always-disallow", and the default value. This option allows us to force drag and drop to be enabled when
+        testing on iPhone simulator.
+
+        * WebKitTestRunner/ios/TestControllerIOS.mm:
+        (WTR::dragInteractionPolicy):
+        (WTR::TestController::platformResetStateToConsistentValues):
+        * WebKitTestRunner/ios/UIScriptControllerIOS.h:
+        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptControllerIOS::isAnimatingDragCancel const):
+
 2021-04-06  Yusuke Suzuki  <ysuz...@apple.com>
 
         [WTF] Introduce FixedVector and use it for FixedOperands

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl (275545 => 275546)


--- trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl	2021-04-06 20:26:30 UTC (rev 275545)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl	2021-04-06 20:39:10 UTC (rev 275546)
@@ -90,6 +90,8 @@
     undefined rawKeyDown(DOMString key);
     undefined rawKeyUp(DOMString key);
 
+    readonly attribute boolean isAnimatingDragCancel;
+
     // eventsJSON describes a series of user events in JSON form. For the keys, see HIDEventGenerator.mm.
     // For example, this JSON describes a touch down followed by a touch up (i.e. a single tap).
     //  {

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h (275545 => 275546)


--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h	2021-04-06 20:26:30 UTC (rev 275545)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h	2021-04-06 20:39:10 UTC (rev 275546)
@@ -176,6 +176,12 @@
         return false;
     }
 
+    virtual bool isAnimatingDragCancel() const
+    {
+        notImplemented();
+        return false;
+    }
+
     virtual void rawKeyDown(JSStringRef) { notImplemented(); }
     virtual void rawKeyUp(JSStringRef) { notImplemented(); }
 

Modified: trunk/Tools/WebKitTestRunner/TestOptions.cpp (275545 => 275546)


--- trunk/Tools/WebKitTestRunner/TestOptions.cpp	2021-04-06 20:26:30 UTC (rev 275545)
+++ trunk/Tools/WebKitTestRunner/TestOptions.cpp	2021-04-06 20:39:10 UTC (rev 275546)
@@ -113,6 +113,7 @@
             { "applicationBundleIdentifier", { } },
             { "applicationManifest", { } },
             { "contentMode", { } },
+            { "dragInteractionPolicy", { } },
             { "jscOptions", { } },
             { "standaloneWebApplicationURL", { } },
         };
@@ -161,6 +162,7 @@
         { "applicationBundleIdentifier", TestHeaderKeyType::StringTestRunner },
         { "applicationManifest", TestHeaderKeyType::StringRelativePathTestRunner },
         { "contentMode", TestHeaderKeyType::StringTestRunner },
+        { "dragInteractionPolicy", TestHeaderKeyType::StringTestRunner },
         { "jscOptions", TestHeaderKeyType::StringTestRunner },
         { "standaloneWebApplicationURL", TestHeaderKeyType::StringURLTestRunner },
 

Modified: trunk/Tools/WebKitTestRunner/TestOptions.h (275545 => 275546)


--- trunk/Tools/WebKitTestRunner/TestOptions.h	2021-04-06 20:26:30 UTC (rev 275545)
+++ trunk/Tools/WebKitTestRunner/TestOptions.h	2021-04-06 20:39:10 UTC (rev 275546)
@@ -78,6 +78,7 @@
     std::string applicationBundleIdentifier() const { return stringTestRunnerFeatureValue("applicationBundleIdentifier"); }
     std::string applicationManifest() const { return stringTestRunnerFeatureValue("applicationManifest"); }
     std::string contentMode() const { return stringTestRunnerFeatureValue("contentMode"); }
+    std::string dragInteractionPolicy() const { return stringTestRunnerFeatureValue("dragInteractionPolicy"); }
     std::string jscOptions() const { return stringTestRunnerFeatureValue("jscOptions"); }
     std::string standaloneWebApplicationURL() const { return stringTestRunnerFeatureValue("standaloneWebApplicationURL"); }
     std::vector<std::string> overrideLanguages() const { return stringVectorTestRunnerFeatureValue("language"); }

Modified: trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm (275545 => 275546)


--- trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm	2021-04-06 20:26:30 UTC (rev 275545)
+++ trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm	2021-04-06 20:39:10 UTC (rev 275546)
@@ -154,6 +154,16 @@
 #endif
 }
 
+static _WKDragInteractionPolicy dragInteractionPolicy(const TestOptions& options)
+{
+    auto policy = options.dragInteractionPolicy();
+    if (policy == "always-enable")
+        return _WKDragInteractionPolicyAlwaysEnable;
+    if (policy == "always-disable")
+        return _WKDragInteractionPolicyAlwaysDisable;
+    return _WKDragInteractionPolicyDefault;
+}
+
 bool TestController::platformResetStateToConsistentValues(const TestOptions& options)
 {
     cocoaResetStateToConsistentValues(options);
@@ -212,6 +222,7 @@
         [webView _clearInterfaceOrientationOverride];
         [webView resetCustomMenuAction];
         [webView setAllowedMenuActions:nil];
+        webView._dragInteractionPolicy = dragInteractionPolicy(options);
 
         UIScrollView *scrollView = webView.scrollView;
         [scrollView _removeAllAnimations:YES];

Modified: trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h (275545 => 275546)


--- trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h	2021-04-06 20:26:30 UTC (rev 275545)
+++ trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h	2021-04-06 20:39:10 UTC (rev 275546)
@@ -134,6 +134,7 @@
     void setKeyboardInputModeIdentifier(JSStringRef) override;
     void toggleCapsLock(JSValueRef) override;
     bool keyboardIsAutomaticallyShifted() const override;
+    bool isAnimatingDragCancel() const override;
     JSObjectRef attachmentInfo(JSStringRef) override;
     UIView *platformContentView() const override;
     JSObjectRef calendarType() const override;

Modified: trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm (275545 => 275546)


--- trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm	2021-04-06 20:26:30 UTC (rev 275545)
+++ trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm	2021-04-06 20:39:10 UTC (rev 275546)
@@ -1170,6 +1170,11 @@
     return UIKeyboardImpl.activeInstance.isAutoShifted;
 }
 
+bool UIScriptControllerIOS::isAnimatingDragCancel() const
+{
+    return webView()._animatingDragCancel;
+}
+
 JSObjectRef UIScriptControllerIOS::attachmentInfo(JSStringRef jsAttachmentIdentifier)
 {
     auto attachmentIdentifier = toWTFString(jsAttachmentIdentifier);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to