Changeset 275546 in webkit
- Timestamp:
- Apr 6, 2021 1:39:10 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r275543 r275546 1 2021-04-06 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 REGRESSION (r274610): Unable to drag images when image extraction is enabled 4 https://bugs.webkit.org/show_bug.cgi?id=224211 5 <rdar://problem/76229563> 6 7 Reviewed by Tim Horton. 8 9 Add a new layout test that initiates dragging on an image using a synthesized event stream, and verifies that 10 "dragstart" and "dragend" events are dispatched on the image. 11 12 * fast/events/ios/dragstart-on-image-by-long-pressing-expected.txt: Added. 13 * fast/events/ios/dragstart-on-image-by-long-pressing.html: Added. 14 * resources/ui-helper.js: 15 (window.UIHelper.isAnimatingDragCancel): 16 17 Add a `UIHelper` method that returns whether or not the dragging animation is being cancelled. The new test uses 18 this hook to wait for the drag cancel animation to end before proceeding to the next test. 19 1 20 2021-04-06 Ryosuke Niwa <rniwa@webkit.org> 2 21 -
trunk/LayoutTests/resources/ui-helper.js
r274581 r275546 368 368 return new Promise(resolve => { 369 369 testRunner.runUIScript(`uiController.keyboardIsAutomaticallyShifted`, result => resolve(result === "true")); 370 }); 371 } 372 373 static isAnimatingDragCancel() 374 { 375 return new Promise(resolve => { 376 testRunner.runUIScript(`uiController.isAnimatingDragCancel`, result => resolve(result === "true")); 370 377 }); 371 378 } -
trunk/Source/WebKit/ChangeLog
r275540 r275546 1 2021-04-06 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 REGRESSION (r274610): Unable to drag images when image extraction is enabled 4 https://bugs.webkit.org/show_bug.cgi?id=224211 5 <rdar://problem/76229563> 6 7 Reviewed by Tim Horton. 8 9 r274610 introduced a new deferring gesture recognizer intended to prevent several text interaction gestures from 10 recognizing during pending image extraction. However, this also causes dragging on iOS to fail, since the 11 gesture used to initiate dragging is excluded by the new deferring gesture recognizer. To fix this, allow the 12 new deferring gesture to recognize simultaneously alongside all gestures with the exception of only the gestures 13 it is intended to defer (i.e. text interaction gestures). 14 15 Test: fast/events/ios/dragstart-on-image-by-long-pressing.html 16 17 * UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h: 18 * UIProcess/API/ios/WKWebViewTestingIOS.mm: 19 (-[WKWebView _isAnimatingDragCancel]): 20 * UIProcess/ios/WKContentViewInteraction.h: 21 * UIProcess/ios/WKContentViewInteraction.mm: 22 (-[UIGestureRecognizer _wk_isTapAndAHalf]): 23 24 Add a WebKit category method that returns whether or not a gesture recognizer is a tap-and-a-half gesture. 25 26 (-[WKContentView gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]): 27 28 Allow the image extraction deferring gesture to recognize alongside all other gestures, with the exception of 29 the text interaction gestures determined by `-shouldDeferGestureDueToImageExtraction:`. This limits the impact 30 of this new deferring gesture, such that it only affects the text interaction gestures it is intended to defer. 31 32 (-[WKContentView shouldDeferGestureDueToImageExtraction:]): 33 34 Add a helper method to determine whether or not a gesture recognizer should be deferred, due to pending image 35 extraction. We pull this logic behind a helper method because it's now consulted from two call sites. 36 37 (-[WKContentView deferringGestureRecognizer:shouldDeferOtherGestureRecognizer:]): 38 (-[WKContentView dragInteraction:item:willAnimateCancelWithAnimator:]): 39 (-[WKContentView isAnimatingDragCancel]): 40 41 Add a testing hook to return whether or not the drag cancel animation is running. See Tools/ChangeLog and the 42 new layout test for more detail. 43 44 (tapAndAHalfRecognizerClass): Deleted. 45 1 46 2021-04-06 Alex Christensen <achristensen@webkit.org> 2 47 -
trunk/Source/WebKit/UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h
r274581 r275546 43 43 @property (nonatomic, readonly) NSNumber *_stableStateOverride; 44 44 @property (nonatomic, readonly) CGRect _dragCaretRect; 45 @property (nonatomic, readonly, getter=_isAnimatingDragCancel) BOOL _animatingDragCancel; 45 46 46 47 - (void)keyboardAccessoryBarNext; -
trunk/Source/WebKit/UIProcess/API/ios/WKWebViewTestingIOS.mm
r274581 r275546 314 314 } 315 315 316 - (BOOL)_isAnimatingDragCancel 317 { 318 #if ENABLE(DRAG_SUPPORT) 319 return [_contentView isAnimatingDragCancel]; 320 #else 321 return NO; 322 #endif 323 } 324 316 325 - (void)_simulateElementAction:(_WKElementActionType)actionType atLocation:(CGPoint)location 317 326 { -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
r275270 r275546 439 439 RetainPtr<UIDragInteraction> _dragInteraction; 440 440 RetainPtr<UIDropInteraction> _dropInteraction; 441 BOOL _isAnimatingDragCancel; 441 442 BOOL _shouldRestoreCalloutBarAfterDrop; 442 443 RetainPtr<UIView> _visibleContentViewSnapshot; … … 736 737 @property (nonatomic, readonly) WKDateTimeInputControl *dateTimeInputControl; 737 738 @property (nonatomic, readonly) WKFormSelectControl *selectControl; 739 #if ENABLE(DRAG_SUPPORT) 740 @property (nonatomic, readonly, getter=isAnimatingDragCancel) BOOL animatingDragCancel; 741 #endif 738 742 739 743 @end -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r275397 r275546 682 682 } 683 683 684 - (BOOL)_wk_isTapAndAHalf 685 { 686 static dispatch_once_t onceToken; 687 static Class tapAndAHalfGestureRecognizerClass; 688 dispatch_once(&onceToken, ^{ 689 tapAndAHalfGestureRecognizerClass = NSClassFromString(@"UITapAndAHalfRecognizer"); 690 }); 691 return [self isKindOfClass:tapAndAHalfGestureRecognizerClass]; 692 } 693 684 694 @end 685 695 … … 2227 2237 } 2228 2238 2229 static Class tapAndAHalfRecognizerClass()2230 {2231 static dispatch_once_t onceToken;2232 static Class theClass;2233 dispatch_once(&onceToken, ^{2234 theClass = NSClassFromString(@"UITapAndAHalfRecognizer");2235 });2236 return theClass;2237 }2238 2239 2239 - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer*)otherGestureRecognizer 2240 2240 { … … 2246 2246 if ([gestureRecognizer isKindOfClass:WKDeferringGestureRecognizer.class] && [otherGestureRecognizer isKindOfClass:WKDeferringGestureRecognizer.class]) 2247 2247 return YES; 2248 2249 #if ENABLE(IMAGE_EXTRACTION) 2250 if (gestureRecognizer == _imageExtractionDeferringGestureRecognizer) 2251 return ![self shouldDeferGestureDueToImageExtraction:otherGestureRecognizer]; 2252 2253 if (otherGestureRecognizer == _imageExtractionDeferringGestureRecognizer) 2254 return ![self shouldDeferGestureDueToImageExtraction:gestureRecognizer]; 2255 #endif 2248 2256 2249 2257 if (isSamePair(gestureRecognizer, otherGestureRecognizer, _highlightLongPressGestureRecognizer.get(), _longPressGestureRecognizer.get())) … … 2275 2283 return YES; 2276 2284 2277 if ( [gestureRecognizer isKindOfClass:tapAndAHalfRecognizerClass()] || [otherGestureRecognizer isKindOfClass:tapAndAHalfRecognizerClass()])2285 if (gestureRecognizer._wk_isTapAndAHalf || otherGestureRecognizer._wk_isTapAndAHalf) 2278 2286 return YES; 2279 2287 } … … 7514 7522 } 7515 7523 7524 #if ENABLE(IMAGE_EXTRACTION) 7525 7526 - (BOOL)shouldDeferGestureDueToImageExtraction:(UIGestureRecognizer *)gesture 7527 { 7528 return gesture == [_textInteractionAssistant loupeGesture] || gesture._wk_isTapAndAHalf || gesture == [_textInteractionAssistant forcePressGesture]; 7529 } 7530 7531 #endif // ENABLE(IMAGE_EXTRACTION) 7532 7516 7533 #if HAVE(PASTEBOARD_DATA_OWNER) 7517 7534 … … 7660 7677 return NO; 7661 7678 7662 BOOL isLoupeGesture = gestureRecognizer == [_textInteractionAssistant loupeGesture];7663 BOOL isTapAndAHalfGesture = [gestureRecognizer isKindOfClass:tapAndAHalfRecognizerClass()];7664 7665 7679 #if ENABLE(IMAGE_EXTRACTION) 7666 7680 if (deferringGestureRecognizer == _imageExtractionDeferringGestureRecognizer) 7667 return isLoupeGesture || isTapAndAHalfGesture || gestureRecognizer == [_textInteractionAssistant forcePressGesture];7681 return [self shouldDeferGestureDueToImageExtraction:gestureRecognizer]; 7668 7682 #endif 7669 7683 … … 7679 7693 #endif 7680 7694 7681 if ( isTapAndAHalfGesture)7695 if (gestureRecognizer._wk_isTapAndAHalf) 7682 7696 return YES; 7683 7697 7684 if ( isLoupeGesture)7698 if (gestureRecognizer == [_textInteractionAssistant loupeGesture]) 7685 7699 return YES; 7686 7700 … … 8686 8700 - (void)dragInteraction:(UIDragInteraction *)interaction item:(UIDragItem *)item willAnimateCancelWithAnimator:(id <UIDragAnimating>)animator 8687 8701 { 8702 _isAnimatingDragCancel = YES; 8688 8703 RELEASE_LOG(DragAndDrop, "Drag interaction willAnimateCancelWithAnimator"); 8689 8704 [animator addCompletion:[protectedSelf = retainPtr(self), page = _page] (UIViewAnimatingPosition finalPosition) { … … 8691 8706 page->dragCancelled(); 8692 8707 if (auto completion = protectedSelf->_dragDropInteractionState.takeDragCancelSetDownBlock()) { 8693 page->callAfterNextPresentationUpdate([completion ] (WebKit::CallbackBase::Error) {8708 page->callAfterNextPresentationUpdate([completion, protectedSelf] (WebKit::CallbackBase::Error) { 8694 8709 completion(); 8710 protectedSelf->_isAnimatingDragCancel = NO; 8695 8711 }); 8696 8712 } … … 9543 9559 return nil; 9544 9560 } 9561 9562 #if ENABLE(DRAG_SUPPORT) 9563 9564 - (BOOL)isAnimatingDragCancel 9565 { 9566 return _isAnimatingDragCancel; 9567 } 9568 9569 #endif // ENABLE(DRAG_SUPPORT) 9545 9570 9546 9571 - (void)_simulateTextEntered:(NSString *)text -
trunk/Tools/ChangeLog
r275542 r275546 1 2021-04-06 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 REGRESSION (r274610): Unable to drag images when image extraction is enabled 4 https://bugs.webkit.org/show_bug.cgi?id=224211 5 <rdar://problem/76229563> 6 7 Reviewed by Tim Horton. 8 9 Add support for some new testing infrastructure; see below for more details. 10 11 * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: 12 * TestRunnerShared/UIScriptContext/UIScriptController.h: 13 (WTR::UIScriptController::isAnimatingDragCancel const): 14 15 Add a new testing hook to return whether or not the web view's drag interaction is currently animating a drag 16 cancel (i.e., the drag preview is animating back to its original frame). 17 18 * WebKitTestRunner/TestOptions.cpp: 19 (WTR::TestOptions::defaults): 20 (WTR::TestOptions::keyTypeMapping): 21 * WebKitTestRunner/TestOptions.h: 22 (WTR::TestOptions::dragInteractionPolicy const): 23 24 Add a test option that allows tests to override the drag interaction policy to "always-allow", 25 "always-disallow", and the default value. This option allows us to force drag and drop to be enabled when 26 testing on iPhone simulator. 27 28 * WebKitTestRunner/ios/TestControllerIOS.mm: 29 (WTR::dragInteractionPolicy): 30 (WTR::TestController::platformResetStateToConsistentValues): 31 * WebKitTestRunner/ios/UIScriptControllerIOS.h: 32 * WebKitTestRunner/ios/UIScriptControllerIOS.mm: 33 (WTR::UIScriptControllerIOS::isAnimatingDragCancel const): 34 1 35 2021-04-06 Yusuke Suzuki <ysuzuki@apple.com> 2 36 -
trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
r274581 r275546 90 90 undefined rawKeyDown(DOMString key); 91 91 undefined rawKeyUp(DOMString key); 92 93 readonly attribute boolean isAnimatingDragCancel; 92 94 93 95 // eventsJSON describes a series of user events in JSON form. For the keys, see HIDEventGenerator.mm. -
trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
r274581 r275546 177 177 } 178 178 179 virtual bool isAnimatingDragCancel() const 180 { 181 notImplemented(); 182 return false; 183 } 184 179 185 virtual void rawKeyDown(JSStringRef) { notImplemented(); } 180 186 virtual void rawKeyUp(JSStringRef) { notImplemented(); } -
trunk/Tools/WebKitTestRunner/TestOptions.cpp
r272304 r275546 114 114 { "applicationManifest", { } }, 115 115 { "contentMode", { } }, 116 { "dragInteractionPolicy", { } }, 116 117 { "jscOptions", { } }, 117 118 { "standaloneWebApplicationURL", { } }, … … 162 163 { "applicationManifest", TestHeaderKeyType::StringRelativePathTestRunner }, 163 164 { "contentMode", TestHeaderKeyType::StringTestRunner }, 165 { "dragInteractionPolicy", TestHeaderKeyType::StringTestRunner }, 164 166 { "jscOptions", TestHeaderKeyType::StringTestRunner }, 165 167 { "standaloneWebApplicationURL", TestHeaderKeyType::StringURLTestRunner }, -
trunk/Tools/WebKitTestRunner/TestOptions.h
r270446 r275546 79 79 std::string applicationManifest() const { return stringTestRunnerFeatureValue("applicationManifest"); } 80 80 std::string contentMode() const { return stringTestRunnerFeatureValue("contentMode"); } 81 std::string dragInteractionPolicy() const { return stringTestRunnerFeatureValue("dragInteractionPolicy"); } 81 82 std::string jscOptions() const { return stringTestRunnerFeatureValue("jscOptions"); } 82 83 std::string standaloneWebApplicationURL() const { return stringTestRunnerFeatureValue("standaloneWebApplicationURL"); } -
trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm
r273730 r275546 155 155 } 156 156 157 static _WKDragInteractionPolicy dragInteractionPolicy(const TestOptions& options) 158 { 159 auto policy = options.dragInteractionPolicy(); 160 if (policy == "always-enable") 161 return _WKDragInteractionPolicyAlwaysEnable; 162 if (policy == "always-disable") 163 return _WKDragInteractionPolicyAlwaysDisable; 164 return _WKDragInteractionPolicyDefault; 165 } 166 157 167 bool TestController::platformResetStateToConsistentValues(const TestOptions& options) 158 168 { … … 213 223 [webView resetCustomMenuAction]; 214 224 [webView setAllowedMenuActions:nil]; 225 webView._dragInteractionPolicy = dragInteractionPolicy(options); 215 226 216 227 UIScrollView *scrollView = webView.scrollView; -
trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h
r274581 r275546 135 135 void toggleCapsLock(JSValueRef) override; 136 136 bool keyboardIsAutomaticallyShifted() const override; 137 bool isAnimatingDragCancel() const override; 137 138 JSObjectRef attachmentInfo(JSStringRef) override; 138 139 UIView *platformContentView() const override; -
trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm
r274581 r275546 1171 1171 } 1172 1172 1173 bool UIScriptControllerIOS::isAnimatingDragCancel() const 1174 { 1175 return webView()._animatingDragCancel; 1176 } 1177 1173 1178 JSObjectRef UIScriptControllerIOS::attachmentInfo(JSStringRef jsAttachmentIdentifier) 1174 1179 {
Note: See TracChangeset
for help on using the changeset viewer.