WebKit Bugzilla
Attachment 370316 Details for
Bug 198072
: [macOS] Compatibility mouse events aren't prevented by calling preventDefault() on pointerdown
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198072-20190521160954.patch (text/plain), 8.14 KB, created by
Antoine Quint
on 2019-05-21 07:09:55 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Antoine Quint
Created:
2019-05-21 07:09:55 PDT
Size:
8.14 KB
patch
obsolete
>Subversion Revision: 245564 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 1dc6f1f7d3de311ddab05b3bca41eb3e984feb35..913f662edce98d4580d3cb207dc08e4046270abd 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,22 @@ >+2019-05-21 Antoine Quint <graouts@apple.com> >+ >+ [macOS] Compatibility mouse events aren't prevented by calling preventDefault() on pointerdown >+ https://bugs.webkit.org/show_bug.cgi?id=198072 >+ <rdar://problem/50983361> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ The Pointer Events spec says that "compatibility" mouse events, which means all mouse events save for "click", >+ should not be dispatched for a given pointer if preventDefault() was called during the dispatch of the "pointerdown" >+ event. Additionally, calling preventDefault() during the dispatch of "pointerup" has no effect. >+ >+ * dom/Element.cpp: >+ (WebCore::Element::dispatchMouseEvent): >+ * page/PointerCaptureController.cpp: >+ (WebCore::PointerCaptureController::preventsCompatibilityMouseEventsForIdentifier): >+ (WebCore::PointerCaptureController::pointerEventWasDispatched): >+ * page/PointerCaptureController.h: >+ > 2019-05-20 Ross Kirsling <ross.kirsling@sony.com> > > Make lossy LayoutUnit constructors explicit >diff --git a/Source/WebCore/dom/Element.cpp b/Source/WebCore/dom/Element.cpp >index c4913bebf58c05ef9ff2c594e684514f943f490e..6ac9bc3115222c306e5e79a00924d0708f36f212 100644 >--- a/Source/WebCore/dom/Element.cpp >+++ b/Source/WebCore/dom/Element.cpp >@@ -306,11 +306,14 @@ bool Element::dispatchMouseEvent(const PlatformMouseEvent& platformEvent, const > #if ENABLE(POINTER_EVENTS) && !ENABLE(TOUCH_EVENTS) > if (RuntimeEnabledFeatures::sharedFeatures().pointerEventsEnabled()) { > if (auto pointerEvent = PointerEvent::create(mouseEvent)) { >- if (auto* page = document().page()) >+ if (auto* page = document().page()) { > page->pointerCaptureController().dispatchEvent(*pointerEvent, this); >+ if (mouseEvent->type() != eventNames().clickEvent && page->pointerCaptureController().preventsCompatibilityMouseEventsForIdentifier(pointerEvent->pointerId())) >+ return false; >+ } > if (pointerEvent->defaultPrevented() || pointerEvent->defaultHandled()) { > didNotSwallowEvent = false; >- if (pointerEvent->type() == eventNames().pointerdownEvent || pointerEvent->type() == eventNames().pointerupEvent) >+ if (pointerEvent->type() == eventNames().pointerdownEvent) > return false; > } > } >diff --git a/Source/WebCore/page/PointerCaptureController.cpp b/Source/WebCore/page/PointerCaptureController.cpp >index c9453614b9d520f1aec66ff635d67ebcf21218f6..83ab79df45c555705f4c4c54c6940fe282cce5e9 100644 >--- a/Source/WebCore/page/PointerCaptureController.cpp >+++ b/Source/WebCore/page/PointerCaptureController.cpp >@@ -157,6 +157,12 @@ bool PointerCaptureController::hasCancelledPointerEventForIdentifier(PointerID p > return iterator != m_activePointerIdsToCapturingData.end() && iterator->value.cancelled; > } > >+bool PointerCaptureController::preventsCompatibilityMouseEventsForIdentifier(PointerID pointerId) >+{ >+ auto iterator = m_activePointerIdsToCapturingData.find(pointerId); >+ return iterator != m_activePointerIdsToCapturingData.end() && iterator->value.preventsCompatibilityMouseEvents; >+} >+ > #if ENABLE(TOUCH_EVENTS) && PLATFORM(IOS_FAMILY) > void PointerCaptureController::dispatchEventForTouchAtIndex(EventTarget& target, const PlatformTouchEvent& platformTouchEvent, unsigned index, bool isPrimary, WindowProxy& view) > { >@@ -249,8 +255,6 @@ void PointerCaptureController::pointerEventWillBeDispatched(const PointerEvent& > > void PointerCaptureController::pointerEventWasDispatched(const PointerEvent& event) > { >- // https://w3c.github.io/pointerevents/#implicit-release-of-pointer-capture >- > auto iterator = m_activePointerIdsToCapturingData.find(event.pointerId()); > if (iterator != m_activePointerIdsToCapturingData.end()) { > auto& capturingData = iterator->value; >@@ -259,8 +263,14 @@ void PointerCaptureController::pointerEventWasDispatched(const PointerEvent& eve > // Immediately after firing the pointerup or pointercancel events, a user agent MUST clear the pending pointer capture target > // override for the pointerId of the pointerup or pointercancel event that was just dispatched, and then run Process Pending > // Pointer Capture steps to fire lostpointercapture if necessary. >+ // https://w3c.github.io/pointerevents/#implicit-release-of-pointer-capture > if (event.type() == eventNames().pointerupEvent) > capturingData.pendingTargetOverride = nullptr; >+ >+ // If the pointer event dispatched was pointerdown and the event was canceled, then set the PREVENT MOUSE EVENT flag for this pointerType. >+ // https://www.w3.org/TR/pointerevents/#mapping-for-devices-that-support-hover >+ if (event.type() == eventNames().pointerdownEvent) >+ capturingData.preventsCompatibilityMouseEvents = event.defaultPrevented(); > } > > processPendingPointerCapture(event); >diff --git a/Source/WebCore/page/PointerCaptureController.h b/Source/WebCore/page/PointerCaptureController.h >index ab8279de93919b32f3903086be1f42c6243b5aad..4bcfadcf1b6c3eefe88f41f0e0e95468cb66ff0c 100644 >--- a/Source/WebCore/page/PointerCaptureController.h >+++ b/Source/WebCore/page/PointerCaptureController.h >@@ -54,6 +54,7 @@ public: > > void touchEndedOrWasCancelledForIdentifier(PointerID); > bool hasCancelledPointerEventForIdentifier(PointerID); >+ bool preventsCompatibilityMouseEventsForIdentifier(PointerID); > void dispatchEvent(PointerEvent&, EventTarget*); > WEBCORE_EXPORT void cancelPointer(PointerID, const IntPoint&); > >@@ -64,6 +65,7 @@ private: > String pointerType; > bool cancelled { false }; > bool isPrimary { false }; >+ bool preventsCompatibilityMouseEvents { false }; > }; > > void pointerEventWillBeDispatched(const PointerEvent&, EventTarget*); >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index b9152e70ec7431af4639ac248704d180f93bffd1..9452c99a131d9527cef9d9b47189906236d0bdfd 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1,3 +1,15 @@ >+2019-05-21 Antoine Quint <graouts@apple.com> >+ >+ [macOS] Compatibility mouse events aren't prevented by calling preventDefault() on pointerdown >+ https://bugs.webkit.org/show_bug.cgi?id=198072 >+ <rdar://problem/50983361> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Mark the WPT test progression after fixing this bug. >+ >+ * web-platform-tests/pointerevents/pointerevent_suppress_compat_events_on_click-expected.txt: >+ > 2019-05-17 Rob Buis <rbuis@igalia.com> > > Implement imagesrcset and imagesizes attributes on link rel=preload >diff --git a/LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_suppress_compat_events_on_click-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_suppress_compat_events_on_click-expected.txt >index feec75fa074e63ad927529b698cd4a3f00146d33..6d2d4ff83fead7e2f62ae99a336b7a9ac44c1a27 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_suppress_compat_events_on_click-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_suppress_compat_events_on_click-expected.txt >@@ -10,11 +10,11 @@ Target1 > Done > The following pointer types were detected: mouse. > >-The following events were logged: mouseup@target0, click@target0, mousedown@target1, mouseup@target1, click@target1. >+The following events were logged: click@target0, mousedown@target1, mouseup@target1, click@target1. > > > PASS Suppress compat mouse events on click > PASS primary pointer pointerdown@target0 > PASS primary pointer pointerdown@target1 >-FAIL Event log assert_equals: expected "click@target0, mousedown@target1, mouseup@target1, click@target1" but got "mouseup@target0, click@target0, mousedown@target1, mouseup@target1, click@target1" >+PASS Event log >
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
Flags:
dino
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198072
: 370316