WebKit Bugzilla
Attachment 358570 Details for
Bug 193229
: [iOS] Dispatch a synthetic mousedown event prior to starting drags
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193229-20190107215926.patch (text/plain), 7.76 KB, created by
Wenson Hsieh
on 2019-01-07 21:59:27 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Wenson Hsieh
Created:
2019-01-07 21:59:27 PST
Size:
7.76 KB
patch
obsolete
>Subversion Revision: 239685 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 000950b6e561d9208b0c1d795d2999aa112432a8..e72a6fdad80684c0ad3092e47edc61ea244ee189 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,34 @@ >+2019-01-07 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ [iOS] Dispatch a synthetic mousedown event prior to starting drags >+ https://bugs.webkit.org/show_bug.cgi?id=193229 >+ <rdar://problem/46717097> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Tweaks some drag initiation logic on iOS to actually send a "mousedown" event to the page prior to drag start. >+ This improves drag and drop compatibility with web pages that expect a mousedown to always precede dragging. >+ Additionally, ensure that preventing the "mousedown" event also prevents "dragstart", which matches macOS >+ behavior. >+ >+ Test: DragAndDropTests.PreventingMouseDownShouldPreventDragStart >+ >+ * page/EventHandler.cpp: >+ >+ Make the text drag delay 0 on iOS. This was introduced on iOS when originally bringing up drag and drop, and was >+ made to simply match macOS. However, it doesn't make sense to respect the delay here, since the purpose of this >+ delay is to disambiguate between making a text selection and starting a drag when pressing on text that is >+ already selected; on iOS (including iOSMac), this gesture conflict is already resolved by platform gesture >+ recognizers in the client layer, so there is always no delay between mouse down and drag here. >+ >+ * page/ios/EventHandlerIOS.mm: >+ >+ Instead of fiddling with EventHandler state directly when starting a drag on iOS, just dispatch a mousedown and >+ inspect the value of `m_mouseDownMayStartDrag`. This also simplifies the drag initiation logic significantly and >+ brings our behavior closer in line with macOS. >+ >+ (WebCore::EventHandler::tryToBeginDataInteractionAtPoint): >+ > 2019-01-04 Wenson Hsieh <wenson_hsieh@apple.com> > > [Cocoa] Allow the page to add to the platform undo stack via UndoManager.addItem() >diff --git a/Source/WebCore/page/EventHandler.cpp b/Source/WebCore/page/EventHandler.cpp >index ed3fe937c9a26d1b79916426b7fc2235730be3df..8946e950a15616d15c3a91f4abbd3265f43584b1 100644 >--- a/Source/WebCore/page/EventHandler.cpp >+++ b/Source/WebCore/page/EventHandler.cpp >@@ -138,7 +138,7 @@ const int ImageDragHysteresis = 5; > const int TextDragHysteresis = 3; > const int ColorDragHystersis = 3; > const int GeneralDragHysteresis = 3; >-#if PLATFORM(COCOA) >+#if PLATFORM(MAC) > const Seconds EventHandler::TextDragDelay { 150_ms }; > #else > const Seconds EventHandler::TextDragDelay { 0_s }; >diff --git a/Source/WebCore/page/ios/EventHandlerIOS.mm b/Source/WebCore/page/ios/EventHandlerIOS.mm >index caec8ee8e2c7531ce18af6183eebfaf50c6254a6..dcd33c78881773f7b82a6ddc01b19dd0fc094a40 100644 >--- a/Source/WebCore/page/ios/EventHandlerIOS.mm >+++ b/Source/WebCore/page/ios/EventHandlerIOS.mm >@@ -676,17 +676,8 @@ bool EventHandler::tryToBeginDataInteractionAtPoint(const IntPoint& clientPositi > if (subframe && subframe->eventHandler().tryToBeginDataInteractionAtPoint(adjustedClientPosition, adjustedGlobalPosition)) > return true; > >- // FIXME: This needs to be refactored, along with handleMousePressEvent and handleMouseMoveEvent, so that state associated only with dragging >- // lives solely in the DragController, and so that we don't need to pretend that a mouse press and mouse move have already occurred here. >- m_mouseDownMayStartDrag = eventMayStartDrag(syntheticMousePressEvent); >- if (!m_mouseDownMayStartDrag) >- return false; >- >- SetForScope<bool> mousePressed(m_mousePressed, true); >- dragState().source = nullptr; >- m_mouseDownPos = protectedFrame->view()->windowToContents(syntheticMouseMoveEvent.position()); >- >- return handleMouseDraggedEvent(hitTestedMouseEvent, DontCheckDragHysteresis); >+ handleMousePressEvent(syntheticMousePressEvent); >+ return m_mouseDownMayStartDrag && handleMouseDraggedEvent(hitTestedMouseEvent, DontCheckDragHysteresis); > } > > #endif >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 25b8f43d939db58c5bfa4cebc79dfa62ec4d9a9f..15964c4ab688b59c7399893f888284881f287049 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,19 @@ >+2019-01-07 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ [iOS] Dispatch a synthetic mousedown event prior to starting drags >+ https://bugs.webkit.org/show_bug.cgi?id=193229 >+ <rdar://problem/46717097> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add a cross-platform drag and drop test to verify that calling `preventDefault()` on the mousedown event >+ prevents a drag from starting. >+ >+ * TestWebKitAPI/Tests/WebKitCocoa/DragAndDropTests.mm: >+ * TestWebKitAPI/Tests/WebKitCocoa/link-and-target-div.html: >+ >+ Tweak this test to make it robust when dragging the link to the target element multiple times in a single test. >+ > 2019-01-04 Wenson Hsieh <wenson_hsieh@apple.com> > > [Cocoa] Allow the page to add to the platform undo stack via UndoManager.addItem() >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/DragAndDropTests.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/DragAndDropTests.mm >index dc46f73997a5d92433eb23f74852002231326973..cdfbb7b442a8d1f7207edceb025186fea234f2c0 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/DragAndDropTests.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/DragAndDropTests.mm >@@ -116,6 +116,25 @@ TEST(DragAndDropTests, ExposeMultipleURLsInDataTransfer) > EXPECT_WK_STREQ("https://webkit.org/\nhttps://apple.com/", [webView stringByEvaluatingJavaScript:@"urlData.textContent"]); > } > >+TEST(DragAndDropTests, PreventingMouseDownShouldPreventDragStart) >+{ >+ auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebViewFrame:CGRectMake(0, 0, 320, 500)]); >+ auto webView = [simulator webView]; >+ WKPreferencesSetCustomPasteboardDataEnabled((__bridge WKPreferencesRef)[webView configuration].preferences, true); >+ [webView synchronouslyLoadTestPageNamed:@"link-and-target-div"]; >+ [simulator runFrom:CGPointMake(160, 100) to:CGPointMake(160, 300)]; >+ EXPECT_WK_STREQ("PASS", [webView stringByEvaluatingJavaScript:@"target.textContent"]); >+ EXPECT_WK_STREQ("dragstart dragend", [webView stringByEvaluatingJavaScript:@"output.textContent"]); >+ >+ // Now verify that preventing default on the 'mousedown' event cancels the drag altogether. >+ [webView evaluateJavaScript:@"target.textContent = output.textContent = ''" completionHandler:nil]; >+ [webView evaluateJavaScript:@"source.addEventListener('mousedown', event => { event.preventDefault(); window.observedMousedown = true; })" completionHandler:nil]; >+ [simulator runFrom:CGPointMake(160, 100) to:CGPointMake(160, 300)]; >+ EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"target.textContent"]); >+ EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"output.textContent"]); >+ EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"observedMousedown"].boolValue); >+} >+ > #if ENABLE(INPUT_TYPE_COLOR) > > TEST(DragAndDropTests, ColorInputToColorInput) >@@ -188,6 +207,6 @@ TEST(DragAndDropTests, ColorInputEvents) > TestWebKitAPI::Util::run(&changeEventFired); > } > >-#endif >+#endif // ENABLE(INPUT_TYPE_COLOR) > > #endif // WK_API_ENABLED && ENABLE(DRAG_SUPPORT) >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/link-and-target-div.html b/Tools/TestWebKitAPI/Tests/WebKitCocoa/link-and-target-div.html >index 35294c64af4378887582138cbf2d4f6c55039b3f..de8adb86c08281bb2624de77a00b5b4bca285252 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/link-and-target-div.html >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/link-and-target-div.html >@@ -4,6 +4,7 @@ body { > width: 100%; > height: 100%; > margin: 0; >+ overflow: hidden; > } > > a, #target {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193229
:
358570
|
358580
|
358637