Title: [245695] trunk
Revision
245695
Author
[email protected]
Date
2019-05-23 11:02:13 -0700 (Thu, 23 May 2019)

Log Message

[Pointer Events] The mouseover, mouseout, mouseenter, and mouseleave events should not be prevented while the pointer is down
https://bugs.webkit.org/show_bug.cgi?id=198177

Patch by Antoine Quint <[email protected]> on 2019-05-23
Reviewed by Dean Jackson.

Source/WebCore:

Test: pointerevents/mouse/compatibility-mouse-events-prevention-mouse-pressed.html

The Pointer Event spec, in https://www.w3.org/TR/pointerevents/#compatibility-mapping-with-mouse-events, says that "the mouseover,
mouseout, mouseenter, and mouseleave events are never prevented (even if the pointer is down)." We add a new static function which
indicates what is "compatibility" mouse event since those should be excluded, along with "click", which we already excluded.

* dom/Element.cpp:
(WebCore::isCompatibilityMouseEvent):
(WebCore::Element::dispatchMouseEvent):

LayoutTests:

Add a test that listens to all mouse events and checks which are dispatched in the case preventDefault() is called when handling
"pointerdown" and when it isn't.

* platform/mac-wk1/TestExpectations: Skipping the test on WK1 where the sequence of dispatched mouse events does not match.
* pointerevents/mouse/compatibility-mouse-events-prevention-mouse-pressed-expected.txt: Added.
* pointerevents/mouse/compatibility-mouse-events-prevention-mouse-pressed.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (245694 => 245695)


--- trunk/LayoutTests/ChangeLog	2019-05-23 17:59:23 UTC (rev 245694)
+++ trunk/LayoutTests/ChangeLog	2019-05-23 18:02:13 UTC (rev 245695)
@@ -1,3 +1,17 @@
+2019-05-23  Antoine Quint  <[email protected]>
+
+        [Pointer Events] The mouseover, mouseout, mouseenter, and mouseleave events should not be prevented while the pointer is down
+        https://bugs.webkit.org/show_bug.cgi?id=198177
+
+        Reviewed by Dean Jackson.
+
+        Add a test that listens to all mouse events and checks which are dispatched in the case preventDefault() is called when handling
+        "pointerdown" and when it isn't.
+
+        * platform/mac-wk1/TestExpectations: Skipping the test on WK1 where the sequence of dispatched mouse events does not match.
+        * pointerevents/mouse/compatibility-mouse-events-prevention-mouse-pressed-expected.txt: Added.
+        * pointerevents/mouse/compatibility-mouse-events-prevention-mouse-pressed.html: Added.
+
 2019-05-23  Truitt Savell  <[email protected]>
 
         Add Mojave+ back to media/track/track-cue-rendering-vertical.html expectation

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (245694 => 245695)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2019-05-23 17:59:23 UTC (rev 245694)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2019-05-23 18:02:13 UTC (rev 245695)
@@ -699,3 +699,5 @@
 
 webkit.org/b/195623 http/tests/cache/link-prefetch-main-resource.html [ Skip ]
 webkit.org/b/195623 http/tests/cache/link-prefetch-main-resource-iframe.html [ Skip ]
+
+webkit.org/b/198177 pointerevents/mouse/compatibility-mouse-events-prevention-mouse-pressed.html [ Skip ]

Added: trunk/LayoutTests/pointerevents/mouse/compatibility-mouse-events-prevention-mouse-pressed-expected.txt (0 => 245695)


--- trunk/LayoutTests/pointerevents/mouse/compatibility-mouse-events-prevention-mouse-pressed-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/pointerevents/mouse/compatibility-mouse-events-prevention-mouse-pressed-expected.txt	2019-05-23 18:02:13 UTC (rev 245695)
@@ -0,0 +1,3 @@
+
+PASS Testing that calling preventDefault() when handling a "pointerdown" event only blocks expected events. 
+

Added: trunk/LayoutTests/pointerevents/mouse/compatibility-mouse-events-prevention-mouse-pressed.html (0 => 245695)


--- trunk/LayoutTests/pointerevents/mouse/compatibility-mouse-events-prevention-mouse-pressed.html	                        (rev 0)
+++ trunk/LayoutTests/pointerevents/mouse/compatibility-mouse-events-prevention-mouse-pressed.html	2019-05-23 18:02:13 UTC (rev 245695)
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset=utf-8>
+</head>
+<body>
+<script src=""
+<script src=""
+<script src=""
+<script>
+
+'use strict';
+
+function runMouseSequence()
+{
+    eventSender.mouseDown();
+    eventSender.mouseMoveTo(25, 25);
+    eventSender.mouseMoveTo(75, 75);
+    eventSender.mouseUp();
+}
+
+target_test({ x: "50px", y: "50px", width: "100px", height: "100px" }, (target, test) => {
+    const eventTracker = new EventTracker(target, ["mousedown", "mouseover", "mouseenter", "mousemove", "mouseout", "mouseleave", "mouseup"]);
+
+    // First, move the mouse over the element to start in that state.
+    eventSender.mouseMoveTo(75, 75);
+    eventTracker.clear();
+    
+    // Then, press the mouse, don't call preventDefault() while handling "pointerdown", move the mouse out, then back over and finally release.
+    runMouseSequence();
+
+    eventTracker.assertMatchesEvents([
+        {"type": "mousedown" },
+        {"type": "mouseout" },
+        {"type": "mouseleave" },
+        {"type": "mouseover" },
+        {"type": "mouseenter" },
+        {"type": "mousemove" },
+        {"type": "mouseup" }
+    ]);
+
+    eventTracker.clear();
+
+    // Then do the same thing but calling preventDefault() while handling "pointerdown".
+    target.addEventListener("pointerdown", event => event.preventDefault());
+    runMouseSequence();
+
+    eventTracker.assertMatchesEvents([
+        {"type": "mouseout" },
+        {"type": "mouseleave" },
+        {"type": "mouseover" },
+        {"type": "mouseenter" },
+    ]);
+    test.done();
+}, `Testing that calling preventDefault() when handling a "pointerdown" event only blocks expected events.`);
+
+</script>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (245694 => 245695)


--- trunk/Source/WebCore/ChangeLog	2019-05-23 17:59:23 UTC (rev 245694)
+++ trunk/Source/WebCore/ChangeLog	2019-05-23 18:02:13 UTC (rev 245695)
@@ -1,3 +1,20 @@
+2019-05-23  Antoine Quint  <[email protected]>
+
+        [Pointer Events] The mouseover, mouseout, mouseenter, and mouseleave events should not be prevented while the pointer is down
+        https://bugs.webkit.org/show_bug.cgi?id=198177
+
+        Reviewed by Dean Jackson.
+
+        Test: pointerevents/mouse/compatibility-mouse-events-prevention-mouse-pressed.html
+
+        The Pointer Event spec, in https://www.w3.org/TR/pointerevents/#compatibility-mapping-with-mouse-events, says that "the mouseover,
+        mouseout, mouseenter, and mouseleave events are never prevented (even if the pointer is down)." We add a new static function which
+        indicates what is "compatibility" mouse event since those should be excluded, along with "click", which we already excluded.
+
+        * dom/Element.cpp:
+        (WebCore::isCompatibilityMouseEvent):
+        (WebCore::Element::dispatchMouseEvent):
+
 2019-05-23  Jon Davis  <[email protected]>
 
         Update feature status for shipped features

Modified: trunk/Source/WebCore/dom/Element.cpp (245694 => 245695)


--- trunk/Source/WebCore/dom/Element.cpp	2019-05-23 17:59:23 UTC (rev 245694)
+++ trunk/Source/WebCore/dom/Element.cpp	2019-05-23 18:02:13 UTC (rev 245695)
@@ -288,6 +288,13 @@
     return platformEvent.type() == PlatformEvent::MouseForceChanged || platformEvent.type() == PlatformEvent::MouseForceDown || platformEvent.type() == PlatformEvent::MouseForceUp;
 }
 
+static bool isCompatibilityMouseEvent(const MouseEvent& mouseEvent)
+{
+    // https://www.w3.org/TR/pointerevents/#compatibility-mapping-with-mouse-events
+    const auto& type = mouseEvent.type();
+    return type != eventNames().clickEvent && type != eventNames().mouseoverEvent && type != eventNames().mouseoutEvent && type != eventNames().mouseenterEvent && type != eventNames().mouseleaveEvent;
+}
+
 bool Element::dispatchMouseEvent(const PlatformMouseEvent& platformEvent, const AtomicString& eventType, int detail, Element* relatedTarget)
 {
     if (isDisabledFormControl())
@@ -314,7 +321,7 @@
         if (auto pointerEvent = PointerEvent::create(mouseEvent)) {
             if (auto* page = document().page()) {
                 page->pointerCaptureController().dispatchEvent(*pointerEvent, this);
-                if (mouseEvent->type() != eventNames().clickEvent && page->pointerCaptureController().preventsCompatibilityMouseEventsForIdentifier(pointerEvent->pointerId()))
+                if (isCompatibilityMouseEvent(mouseEvent) && page->pointerCaptureController().preventsCompatibilityMouseEventsForIdentifier(pointerEvent->pointerId()))
                     return false;
             }
             if (pointerEvent->defaultPrevented() || pointerEvent->defaultHandled()) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to