Changeset 244056 in webkit
- Timestamp:
- Apr 8, 2019, 3:49:20 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/page/DragController.cpp (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/WebPageProxy.h (modified) (1 diff)
-
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (modified) (5 diffs)
-
Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (modified) (1 diff)
-
Source/WebKit/WebProcess/WebCoreSupport/WebDragClient.cpp (modified) (1 diff)
-
Source/WebKit/WebProcess/WebPage/WebPage.h (modified) (4 diffs)
-
Source/WebKit/WebProcess/WebPage/WebPage.messages.in (modified) (1 diff)
-
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm (modified) (1 diff)
-
Tools/TestWebKitAPI/cocoa/DragAndDropSimulator.h (modified) (1 diff)
-
Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r244054 r244056 1 2019-04-08 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [iOS] Do not allow starting selection drags when selection views are not visible 4 https://bugs.webkit.org/show_bug.cgi?id=196686 5 <rdar://problem/49399192> 6 7 Reviewed by Tim Horton. 8 9 See WebKit ChangeLog for more details. 10 11 Tests: DragAndDropTests.CanDragImageWhenNotFirstResponder 12 DragAndDropTests.DoNotPerformSelectionDragWhenNotFirstResponder 13 14 * page/DragController.cpp: 15 (WebCore::DragController::draggableElement const): 16 17 Make this respect the case where m_dragSourceAction does not include DragSourceActionSelection. All the other 18 drag source types are currently consulted in this method, with the exception of DragSourceActionSelection. 19 1 20 2019-04-08 Youenn Fablet <youenn@apple.com> 2 21 -
trunk/Source/WebCore/page/DragController.cpp
r243785 r244056 827 827 828 828 // We either have nothing to drag or we have a selection and we're not over a draggable element. 829 return (state.type & DragSourceActionSelection) ? startElement : nullptr; 829 if (state.type & DragSourceActionSelection && m_dragSourceAction & DragSourceActionSelection) 830 return startElement; 831 832 return nullptr; 830 833 } 831 834 -
trunk/Source/WebKit/ChangeLog
r244050 r244056 1 2019-04-08 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [iOS] Do not allow starting selection drags when selection views are not visible 4 https://bugs.webkit.org/show_bug.cgi?id=196686 5 <rdar://problem/49399192> 6 7 Reviewed by Tim Horton. 8 9 Currently, on iOS, it's possible to start dragging selected text in a web view even if the selection itself is 10 not visible. This can happen if the user selects some text, focuses a native text field, and then long presses 11 the previously selected text. This is because the text is still selected in the document since we don't clear 12 the selection when resigning first responder on iOS, despite the fact that the native selection view is no 13 longer present. 14 15 To fix this, we add plumbing to specify the set of allowed drag source actions when requesting drag start; this 16 set of allowed drag source actions only includes DragSourceActionSelection if the selection view can be visible 17 (i.e. the content view is first responder, and isn't suppressing text interactions). We then update WebPage's 18 allowed drag source actions with this given set of actions, while sending "dragstart" to the page. 19 20 * UIProcess/WebPageProxy.h: 21 * UIProcess/ios/WKContentViewInteraction.mm: 22 (-[WKContentView hasSelectablePositionAtPoint:]): 23 (-[WKContentView textInteractionGesture:shouldBeginAtPoint:]): 24 25 Only bail out of text selection in text that is already selected if the web view allows dragging text selections 26 (i.e. the web view is first responder, and is not suppressing text interactions). 27 28 (-[WKContentView _allowedDragSourceActions]): 29 (-[WKContentView _dragInteraction:itemsForAddingToSession:withTouchAtPoint:completion:]): 30 (-[WKContentView _dragInteraction:prepareForSession:completion:]): 31 32 Pass the set of allowed drag source actions when requesting a drag start or adding items to an existing session. 33 34 * UIProcess/ios/WebPageProxyIOS.mm: 35 (WebKit::WebPageProxy::requestDragStart): 36 (WebKit::WebPageProxy::requestAdditionalItemsForDragSession): 37 38 Plumb the allowed drag source actions from the UI process (WKContentView) over to the web process (WebPage). 39 40 * WebProcess/WebCoreSupport/WebDragClient.cpp: 41 (WebKit::WebDragClient::dragSourceActionMaskForPoint): 42 43 Instead of always returning Any, consult WebPage's allowed drag source actions. 44 45 * WebProcess/WebPage/WebPage.h: 46 (WebKit::WebPage::allowedDragSourceActions const): 47 * WebProcess/WebPage/WebPage.messages.in: 48 * WebProcess/WebPage/ios/WebPageIOS.mm: 49 (WebKit::WebPage::requestDragStart): 50 (WebKit::WebPage::requestAdditionalItemsForDragSession): 51 52 Set WebPage's allowed drag source actions to the given set of actions when sending a drag start to the page. 53 1 54 2019-04-08 Justin Fan <justin_fan@apple.com> 2 55 -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r243961 r244056 717 717 void didHandleDragStartRequest(bool started); 718 718 void didHandleAdditionalDragItemsRequest(bool added); 719 void requestDragStart(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition );720 void requestAdditionalItemsForDragSession(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition );719 void requestDragStart(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, WebCore::DragSourceAction allowedActions); 720 void requestAdditionalItemsForDragSession(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, WebCore::DragSourceAction allowedActions); 721 721 void didConcludeEditDrag(Optional<WebCore::TextIndicatorData>); 722 722 #endif -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r243963 r244056 2054 2054 return NO; 2055 2055 2056 #if ENABLE(D ATA_INTERACTION)2057 if (_positionInformation.hasSelectionAtPosition ) {2058 // If the position might initiate a d ata interaction, we don't want to consider the content at this position to be selectable.2056 #if ENABLE(DRAG_SUPPORT) 2057 if (_positionInformation.hasSelectionAtPosition && self._allowedDragSourceActions & WebCore::DragSourceActionSelection) { 2058 // If the position might initiate a drag, we don't want to consider the content at this position to be selectable. 2059 2059 // FIXME: This should be renamed to something more precise, such as textSelectionShouldRecognizeGestureAtPoint: 2060 2060 return NO; … … 2094 2094 return NO; 2095 2095 2096 #if ENABLE(D ATA_INTERACTION)2097 if (_positionInformation.hasSelectionAtPosition && gesture == UIWKGestureLoupe ) {2098 // If the position might initiate data interaction, we don't want to change the selection.2096 #if ENABLE(DRAG_SUPPORT) 2097 if (_positionInformation.hasSelectionAtPosition && gesture == UIWKGestureLoupe && self._allowedDragSourceActions & WebCore::DragSourceActionSelection) { 2098 // If the position might initiate a drag, we don't want to change the selection. 2099 2099 return NO; 2100 2100 } … … 6290 6290 } 6291 6291 6292 - (WebCore::DragSourceAction)_allowedDragSourceActions 6293 { 6294 auto allowedActions = WebCore::DragSourceActionAny; 6295 if (!self.isFirstResponder || !_suppressSelectionAssistantReasons.isEmpty()) { 6296 // Don't allow starting a drag on a selection when selection views are not visible. 6297 allowedActions = static_cast<WebCore::DragSourceAction>(allowedActions & ~WebCore::DragSourceActionSelection); 6298 } 6299 return allowedActions; 6300 } 6301 6292 6302 - (id <UIDragDropSession>)currentDragOrDropSession 6293 6303 { … … 6449 6459 6450 6460 _dragDropInteractionState.dragSessionWillRequestAdditionalItem(completion); 6451 _page->requestAdditionalItemsForDragSession(WebCore::roundedIntPoint(point), WebCore::roundedIntPoint(point) );6461 _page->requestAdditionalItemsForDragSession(WebCore::roundedIntPoint(point), WebCore::roundedIntPoint(point), self._allowedDragSourceActions); 6452 6462 } 6453 6463 … … 6469 6479 6470 6480 auto dragOrigin = WebCore::roundedIntPoint([session locationInView:self]); 6471 _page->requestDragStart(dragOrigin, WebCore::roundedIntPoint([self convertPoint:dragOrigin toView:self.window]) );6481 _page->requestDragStart(dragOrigin, WebCore::roundedIntPoint([self convertPoint:dragOrigin toView:self.window]), self._allowedDragSourceActions); 6472 6482 6473 6483 RELEASE_LOG(DragAndDrop, "Drag session requested: %p at origin: {%d, %d}", session, dragOrigin.x(), dragOrigin.y()); -
trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
r243961 r244056 1178 1178 } 1179 1179 1180 void WebPageProxy::requestDragStart(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition )1180 void WebPageProxy::requestDragStart(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, WebCore::DragSourceAction allowedActions) 1181 1181 { 1182 1182 if (hasRunningProcess()) 1183 m_process->send(Messages::WebPage::RequestDragStart(clientPosition, globalPosition ), m_pageID);1184 } 1185 1186 void WebPageProxy::requestAdditionalItemsForDragSession(const IntPoint& clientPosition, const IntPoint& globalPosition )1183 m_process->send(Messages::WebPage::RequestDragStart(clientPosition, globalPosition, allowedActions), m_pageID); 1184 } 1185 1186 void WebPageProxy::requestAdditionalItemsForDragSession(const IntPoint& clientPosition, const IntPoint& globalPosition, WebCore::DragSourceAction allowedActions) 1187 1187 { 1188 1188 if (hasRunningProcess()) 1189 m_process->send(Messages::WebPage::RequestAdditionalItemsForDragSession(clientPosition, globalPosition ), m_pageID);1189 m_process->send(Messages::WebPage::RequestAdditionalItemsForDragSession(clientPosition, globalPosition, allowedActions), m_pageID); 1190 1190 } 1191 1191 -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebDragClient.cpp
r235205 r244056 48 48 DragSourceAction WebDragClient::dragSourceActionMaskForPoint(const IntPoint&) 49 49 { 50 return DragSourceActionAny;50 return m_page->allowedDragSourceActions(); 51 51 } 52 52 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r243863 r244056 58 58 #include <WebCore/DictionaryPopupInfo.h> 59 59 #include <WebCore/DisabledAdaptations.h> 60 #include <WebCore/DragActions.h> 60 61 #include <WebCore/FrameLoaderTypes.h> 61 62 #include <WebCore/HTMLMenuElement.h> … … 847 848 void didStartDrag(); 848 849 void dragCancelled(); 850 WebCore::DragSourceAction allowedDragSourceActions() const { return m_allowedDragSourceActions; } 849 851 #endif 850 852 … … 1230 1232 1231 1233 #if PLATFORM(IOS_FAMILY) && ENABLE(DATA_INTERACTION) 1232 void requestDragStart(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition );1233 void requestAdditionalItemsForDragSession(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition );1234 void requestDragStart(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t allowedActions); 1235 void requestAdditionalItemsForDragSession(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t allowedActions); 1234 1236 #endif 1235 1237 … … 1733 1735 #if ENABLE(DRAG_SUPPORT) 1734 1736 bool m_isStartingDrag { false }; 1737 WebCore::DragSourceAction m_allowedDragSourceActions { WebCore::DragSourceActionAny }; 1735 1738 #endif 1736 1739 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in
r243354 r244056 302 302 303 303 #if ENABLE(DATA_INTERACTION) 304 RequestDragStart(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition )305 RequestAdditionalItemsForDragSession(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition )304 RequestDragStart(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t allowedActions) 305 RequestAdditionalItemsForDragSession(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t allowedActions) 306 306 #endif 307 307 -
trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
r243855 r244056 715 715 716 716 #if ENABLE(DATA_INTERACTION) 717 void WebPage::requestDragStart(const IntPoint& clientPosition, const IntPoint& globalPosition) 718 { 717 void WebPage::requestDragStart(const IntPoint& clientPosition, const IntPoint& globalPosition, uint64_t allowedActions) 718 { 719 SetForScope<WebCore::DragSourceAction> allowedActionsForScope(m_allowedDragSourceActions, static_cast<WebCore::DragSourceAction>(allowedActions)); 719 720 bool didStart = m_page->mainFrame().eventHandler().tryToBeginDragAtPoint(clientPosition, globalPosition); 720 721 send(Messages::WebPageProxy::DidHandleDragStartRequest(didStart)); 721 722 } 722 723 723 void WebPage::requestAdditionalItemsForDragSession(const IntPoint& clientPosition, const IntPoint& globalPosition) 724 { 724 void WebPage::requestAdditionalItemsForDragSession(const IntPoint& clientPosition, const IntPoint& globalPosition, uint64_t allowedActions) 725 { 726 SetForScope<WebCore::DragSourceAction> allowedActionsForScope(m_allowedDragSourceActions, static_cast<WebCore::DragSourceAction>(allowedActions)); 725 727 // To augment the platform drag session with additional items, end the current drag session and begin a new drag session with the new drag item. 726 728 // This process is opaque to the UI process, which still maintains the old drag item in its drag session. Similarly, this persistent drag session -
trunk/Tools/ChangeLog
r244050 r244056 1 2019-04-08 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [iOS] Do not allow starting selection drags when selection views are not visible 4 https://bugs.webkit.org/show_bug.cgi?id=196686 5 <rdar://problem/49399192> 6 7 Reviewed by Tim Horton. 8 9 Adjust some existing API tests to make the web view become first responder before trying to begin dragging, and 10 also add some new API tests to cover scenarios where the web view is not first responder. 11 12 * TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm: 13 (TestWebKitAPI::TEST): 14 * TestWebKitAPI/cocoa/DragAndDropSimulator.h: 15 16 Add a switch to optionally make the web view first responder when starting the simulated drag. 17 18 * TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm: 19 (-[DragAndDropSimulator initWithWebView:]): 20 (-[DragAndDropSimulator runFrom:to:additionalItemRequestLocations:]): 21 1 22 2019-04-08 Justin Fan <justin_fan@apple.com> 2 23 -
trunk/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm
r242530 r244056 431 431 } 432 432 433 TEST(DragAndDropTests, DoNotPerformSelectionDragWhenNotFirstResponder) 434 { 435 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 436 auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:webView.get()]); 437 [simulator setShouldBecomeFirstResponder:NO]; 438 439 [webView synchronouslyLoadTestPageNamed:@"selected-text-and-textarea"]; 440 [simulator runFrom:CGPointMake(160, 100) to:CGPointMake(160, 300)]; 441 442 EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"destination.value"]); 443 } 444 445 TEST(DragAndDropTests, CanDragImageWhenNotFirstResponder) 446 { 447 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 448 auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:webView.get()]); 449 [simulator setShouldBecomeFirstResponder:NO]; 450 451 [webView synchronouslyLoadTestPageNamed:@"image-and-contenteditable"]; 452 [simulator runFrom:CGPointMake(100, 50) to:CGPointMake(100, 250)]; 453 454 NSURL *droppedImageURL = [NSURL URLWithString:[webView stringByEvaluatingJavaScript:@"editor.querySelector('img').src"]]; 455 EXPECT_WK_STREQ("blob", droppedImageURL.scheme); 456 } 457 433 458 TEST(DragAndDropTests, ContentEditableMoveParagraphs) 434 459 { -
trunk/Tools/TestWebKitAPI/cocoa/DragAndDropSimulator.h
r242339 r244056 96 96 @property (nonatomic) BOOL allowsFocusToStartInputSession; 97 97 @property (nonatomic) BOOL shouldEnsureUIApplication; 98 @property (nonatomic) BOOL shouldBecomeFirstResponder; 98 99 @property (nonatomic) BOOL shouldAllowMoveOperation; 99 100 @property (nonatomic, strong) NSArray *externalItemProviders; -
trunk/Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm
r243519 r244056 344 344 _webView = webView; 345 345 _shouldEnsureUIApplication = NO; 346 _shouldBecomeFirstResponder = YES; 346 347 _shouldAllowMoveOperation = YES; 347 348 [_webView setUIDelegate:self]; … … 416 417 UIApplicationInstantiateSingleton([DragAndDropSimulatorApplication class]); 417 418 419 if (_shouldBecomeFirstResponder) 420 [_webView becomeFirstResponder]; 421 418 422 [self _resetSimulatedState]; 419 423
Note:
See TracChangeset
for help on using the changeset viewer.