[Pointer Events] Respect pointer capture when dispatching mouse boundary events and...
authorgraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Jun 2019 10:45:34 +0000 (10:45 +0000)
committergraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Jun 2019 10:45:34 +0000 (10:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=198999
<rdar://problem/51979477>

Unreviewed.

Rolling back all changes made for this bug (r246728 + r246716 + r246674) as it regressed one test
(imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_pointercapture_in_frame.html).

LayoutTests/imported/w3c:

* web-platform-tests/pointerevents/pointerevent_boundary_events_at_implicit_release_hoverable_pointers-expected.txt:
* web-platform-tests/pointerevents/pointerevent_click_during_capture-expected.txt:
* web-platform-tests/pointerevents/pointerevent_mouse_capture_change_hover-expected.txt:
* web-platform-tests/pointerevents/pointerevent_setpointercapture_relatedtarget-expected.txt:

Source/WebCore:

* dom/Document.cpp:
(WebCore::Document::prepareMouseEvent):
(WebCore::Document::updateHoverActiveState):
* page/EventHandler.cpp:
(WebCore::EventHandler::handleMousePressEvent):
(WebCore::EventHandler::handleMouseMoveEvent):
(WebCore::EventHandler::handleMouseReleaseEvent):
(WebCore::EventHandler::setCapturingMouseEventsElement):
* page/EventHandler.h:
* page/PointerCaptureController.cpp:
(WebCore::PointerCaptureController::releasePointerCapture):
(WebCore::PointerCaptureController::hasPointerCapture):
(WebCore::PointerCaptureController::dispatchEventForTouchAtIndex):
(WebCore::PointerCaptureController::dispatchEvent):
(WebCore::PointerCaptureController::processPendingPointerCapture):
(WebCore::PointerCaptureController::pointerCaptureElement): Deleted.
* page/PointerCaptureController.h:
* rendering/HitTestRequest.h:
(WebCore::HitTestRequest::includesAllElementsUnderPoint const):
(WebCore::HitTestRequest::pointerCaptureElementChanged const): Deleted.

LayoutTests:

* platform/mac-highsierra-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_capture_change_hover-expected.txt: Added.
* platform/mac-highsierra/imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_capture_change_hover-expected.txt: Added.
* platform/mac-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_boundary_events_at_implicit_release_hoverable_pointers-expected.txt:
* platform/mac-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_click_during_capture-expected.txt: Removed.
* platform/mac-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_pointercapture_in_frame-expected.txt: Added.
* platform/mac-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_setpointercapture_relatedtarget-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@246729 268f45cc-cd09-0410-ab3c-d52691b4dbfc

20 files changed:
LayoutTests/ChangeLog
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_boundary_events_at_implicit_release_hoverable_pointers-expected.txt
LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_click_during_capture-expected.txt
LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_capture_change_hover-expected.txt
LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_pointercapture_in_frame-expected.txt
LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_setpointercapture_relatedtarget-expected.txt
LayoutTests/platform/mac-highsierra-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_capture_change_hover-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-highsierra/imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_capture_change_hover-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_boundary_events_at_implicit_release_hoverable_pointers-expected.txt
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_click_during_capture-expected.txt [deleted file]
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_pointercapture_in_frame-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_setpointercapture_relatedtarget-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/EventHandler.h
Source/WebCore/page/PointerCaptureController.cpp
Source/WebCore/page/PointerCaptureController.h
Source/WebCore/rendering/HitTestRequest.h

index c49086a..05057be 100644 (file)
@@ -1,3 +1,21 @@
+2019-06-24  Antoine Quint  <graouts@apple.com>
+
+        [Pointer Events] Respect pointer capture when dispatching mouse boundary events and updating :hover
+        https://bugs.webkit.org/show_bug.cgi?id=198999
+        <rdar://problem/51979477>
+
+        Unreviewed.
+
+        Rolling back all changes made for this bug (r246728 + r246716 + r246674) as it regressed one test
+        (imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_pointercapture_in_frame.html).
+
+        * platform/mac-highsierra-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_capture_change_hover-expected.txt: Added.
+        * platform/mac-highsierra/imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_capture_change_hover-expected.txt: Added.
+        * platform/mac-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_boundary_events_at_implicit_release_hoverable_pointers-expected.txt:
+        * platform/mac-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_click_during_capture-expected.txt: Removed.
+        * platform/mac-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_pointercapture_in_frame-expected.txt: Added.
+        * platform/mac-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_setpointercapture_relatedtarget-expected.txt:
+
 2019-06-23  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         [WinCairo] Unreviewed test gardening
index 6698ef0..372878c 100644 (file)
@@ -1,3 +1,19 @@
+2019-06-24  Antoine Quint  <graouts@apple.com>
+
+        [Pointer Events] Respect pointer capture when dispatching mouse boundary events and updating :hover
+        https://bugs.webkit.org/show_bug.cgi?id=198999
+        <rdar://problem/51979477>
+
+        Unreviewed.
+
+        Rolling back all changes made for this bug (r246728 + r246716 + r246674) as it regressed one test
+        (imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_pointercapture_in_frame.html).
+
+        * web-platform-tests/pointerevents/pointerevent_boundary_events_at_implicit_release_hoverable_pointers-expected.txt:
+        * web-platform-tests/pointerevents/pointerevent_click_during_capture-expected.txt:
+        * web-platform-tests/pointerevents/pointerevent_mouse_capture_change_hover-expected.txt:
+        * web-platform-tests/pointerevents/pointerevent_setpointercapture_relatedtarget-expected.txt:
+
 2019-06-23  Antoine Quint  <graouts@apple.com>
 
         [Pointer Events WPT] Unflake imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_pointercapture_in_frame.html
index 98a62ea..02f6a82 100644 (file)
@@ -6,5 +6,5 @@ When a captured pointer is implicitly released after a click, the boundary event
 
 Click on the black box with mouse and do not move the mouse after or during the click.
 
-FAIL mouse Event sequence at implicit release on click assert_equals: expected "pointerout@target, pointerleave@target, pointerover@capture-target, pointerenter@capture-target, gotpointercapture@capture-target, pointerup@capture-target, lostpointercapture@capture-target, pointerout@capture-target, pointerleave@capture-target, pointerover@target, pointerenter@target" but got "pointerout@target, pointerleave@target, pointerover@capture-target, pointerenter@capture-target, gotpointercapture@capture-target, pointerup@target, lostpointercapture@capture-target, pointerout@capture-target, pointerleave@capture-target, pointerover@target, pointerenter@target"
+FAIL mouse Event sequence at implicit release on click assert_equals: expected "pointerout@target, pointerleave@target, pointerover@capture-target, pointerenter@capture-target, gotpointercapture@capture-target, pointerup@capture-target, lostpointercapture@capture-target, pointerout@capture-target, pointerleave@capture-target, pointerover@target, pointerenter@target" but got "gotpointercapture@capture-target, pointerup@capture-target, lostpointercapture@capture-target"
 
index 9c13337..2db1bcc 100644 (file)
@@ -9,7 +9,7 @@ Repeat the two steps above once again.
 
 
 
-FAIL mouse click target during capture assert_equals: An element should only receive click when it is the first common ancestor of pointerdown and pointerup targets expected "pointerdown@green,gotpointercapture@blue,pointerup@blue,click@grey,lostpointercapture@blue" but got "pointerdown@green,gotpointercapture@blue,pointerup@green,lostpointercapture@blue"
+FAIL mouse click target during capture assert_equals: An element should only receive click when it is the first common ancestor of pointerdown and pointerup targets expected "pointerdown@green,gotpointercapture@blue,pointerup@blue,click@grey,lostpointercapture@blue" but got "pointerdown@green,gotpointercapture@blue,pointerup@blue,lostpointercapture@blue"
 PASS Click target when pointerup/down targeted at the same element with no capture 
 PASS Click target when pointerup/down targeted at different elements with no capture 
 
index 199239c..8ae0fa2 100644 (file)
@@ -1,5 +1,5 @@
 
-PASS Mouse down and capture to green. 
-PASS Mouse down at green and capture to blue. 
-PASS Mouse down and capture to green, move to blue and release capture 
+FAIL Mouse down and capture to green. assert_array_equals: Received events: green received pointerover,green received pointerenter,green received pointermove,green received pointerdown,green received gotpointercapture,green received pointermove,green received pointerout,green received pointerleave,green received pointerover,green received pointerenter,green received pointermove lengths differ, expected 7 got 11
+FAIL Mouse down at green and capture to blue. assert_array_equals: Received events: green received pointerout,green received pointerover,green received pointerenter,green received pointermove,green received pointermove,green received pointermove,green received pointermove lengths differ, expected 11 got 7
+FAIL Mouse down and capture to green, move to blue and release capture assert_array_equals: Received events: green received pointerout,green received pointerover,green received pointerenter,green received pointermove,green received lostpointercapture,green received pointermove,green received pointerout,green received pointerleave,blue received pointerover,blue received pointerenter,blue received pointermove,blue received pointermove property 0, expected "green received pointerover" but got "green received pointerout"
 
index 985a019..1e64cf1 100644 (file)
@@ -1,7 +1,7 @@
 
 
-FAIL Test pointer capture event route across the same-origin frame: Mouse down at inner frame and set pointer capture. assert_array_equals: Received events: innerFrame received pointermove,innerFrame received pointerdown,innerFrame received gotpointercapture,innerFrame received pointermove,innerFrameDocument received pointermove,innerFrameDocument received pointerup,innerFrame received lostpointercapture property 4, expected "innerFrame received pointermove" but got "innerFrameDocument received pointermove"
-FAIL Test pointer capture event route across the same-origin frame: Mouse down at outer frame body and set pointer capture. assert_array_equals: Received events: outerFrame received pointermove,outerFrame received pointerdown,outerFrame received gotpointercapture,outerFrame received pointermove,innerFrame received pointerup,outerFrame received lostpointercapture property 4, expected "outerFrame received pointerup" but got "innerFrame received pointerup"
-FAIL Test pointer capture event route across the same-origin frame: Mouse down with set capture at inner frame, then release on next mouse move. assert_array_equals: Received events: innerFrame received pointermove,innerFrame received pointerdown,innerFrame received gotpointercapture,innerFrame received pointermove,innerFrame received lostpointercapture,innerFrameDocument received pointermove,outerFrame received pointermove,outerFrame received pointerup lengths differ, expected 7 got 8
+PASS Test pointer capture event route across the same-origin frame: Mouse down at inner frame and set pointer capture. 
+PASS Test pointer capture event route across the same-origin frame: Mouse down at outer frame body and set pointer capture. 
+PASS Test pointer capture event route across the same-origin frame: Mouse down with set capture at inner frame, then release on next mouse move. 
 PASS Test pointercapture event route across the same-origin frame: Mouse down with set capture at outer frame, then release on next mouse move. 
 
index 36e040e..db8c51d 100644 (file)
@@ -16,11 +16,14 @@ Test complete: Scroll to Summary to view Pass/Fail Results.
 
 The following pointer types were detected: mouse.
 
-The following events were logged: pointerover@target1, pointerover@target0, gotpointercapture@target0, lostpointercapture@target0.
+The following events were logged: pointerover@target1, gotpointercapture@target0, pointerover@target0, pointerover@target0, lostpointercapture@target0.
 
 Refresh the page to run the tests again with a different pointer type.
 
 
+Harness Error (FAIL), message = 1 duplicate test name: "relatedTarget should not be null even when the capture is set."
+
 PASS pointerover shouldn't trigger for the purple rectangle while the black rectangle has capture 
 PASS relatedTarget should not be null even when the capture is set. 
+PASS relatedTarget should not be null even when the capture is set. 
 
diff --git a/LayoutTests/platform/mac-highsierra-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_capture_change_hover-expected.txt b/LayoutTests/platform/mac-highsierra-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_capture_change_hover-expected.txt
new file mode 100644 (file)
index 0000000..e0038c3
--- /dev/null
@@ -0,0 +1,5 @@
+
+FAIL Mouse down and capture to green. assert_array_equals: Received events: green received pointerover,green received pointerenter,green received pointermove,green received pointerdown,green received gotpointercapture lengths differ, expected 7 got 5
+FAIL Mouse down at green and capture to blue. assert_array_equals: Received events: green received pointermove lengths differ, expected 11 got 1
+FAIL Mouse down and capture to green, move to blue and release capture assert_array_equals: Received events: green received pointermove,green received lostpointercapture lengths differ, expected 12 got 2
+
diff --git a/LayoutTests/platform/mac-highsierra/imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_capture_change_hover-expected.txt b/LayoutTests/platform/mac-highsierra/imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_capture_change_hover-expected.txt
new file mode 100644 (file)
index 0000000..8ae0fa2
--- /dev/null
@@ -0,0 +1,5 @@
+
+FAIL Mouse down and capture to green. assert_array_equals: Received events: green received pointerover,green received pointerenter,green received pointermove,green received pointerdown,green received gotpointercapture,green received pointermove,green received pointerout,green received pointerleave,green received pointerover,green received pointerenter,green received pointermove lengths differ, expected 7 got 11
+FAIL Mouse down at green and capture to blue. assert_array_equals: Received events: green received pointerout,green received pointerover,green received pointerenter,green received pointermove,green received pointermove,green received pointermove,green received pointermove lengths differ, expected 11 got 7
+FAIL Mouse down and capture to green, move to blue and release capture assert_array_equals: Received events: green received pointerout,green received pointerover,green received pointerenter,green received pointermove,green received lostpointercapture,green received pointermove,green received pointerout,green received pointerleave,blue received pointerover,blue received pointerenter,blue received pointermove,blue received pointermove property 0, expected "green received pointerover" but got "green received pointerout"
+
index 77ca0f0..c93ebe6 100644 (file)
@@ -6,5 +6,5 @@ When a captured pointer is implicitly released after a click, the boundary event
 
 Click on the black box with mouse and do not move the mouse after or during the click.
 
-FAIL mouse Event sequence at implicit release on click assert_equals: expected "pointerout@target, pointerleave@target, pointerover@capture-target, pointerenter@capture-target, gotpointercapture@capture-target, pointerup@capture-target, lostpointercapture@capture-target, pointerout@capture-target, pointerleave@capture-target, pointerover@target, pointerenter@target" but got "pointerout@target, pointerleave@target, pointerover@capture-target, pointerenter@capture-target, gotpointercapture@capture-target, pointerup@target, lostpointercapture@capture-target, pointerout@capture-target, pointerleave@capture-target, pointerover@target, pointerenter@target, pointermove@target"
+FAIL mouse Event sequence at implicit release on click assert_equals: expected "pointerout@target, pointerleave@target, pointerover@capture-target, pointerenter@capture-target, gotpointercapture@capture-target, pointerup@capture-target, lostpointercapture@capture-target, pointerout@capture-target, pointerleave@capture-target, pointerover@target, pointerenter@target" but got "gotpointercapture@capture-target, pointerup@capture-target, lostpointercapture@capture-target, pointermove@target"
 
diff --git a/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_click_during_capture-expected.txt b/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_click_during_capture-expected.txt
deleted file mode 100644 (file)
index 2db1bcc..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-Pointer Event: click event during capture
-
-Follow the test instructions with mouse. If you don't have the device skip it.
-
-Test Description: Click event should be sent to the first common ancestor of the pointerdown and pointerup targets.
-Click on the green box with the left button of mouse.
-Press down the left button on the blue box and drag to the green box and release the button.
-Repeat the two steps above once again.
-
-
-
-FAIL mouse click target during capture assert_equals: An element should only receive click when it is the first common ancestor of pointerdown and pointerup targets expected "pointerdown@green,gotpointercapture@blue,pointerup@blue,click@grey,lostpointercapture@blue" but got "pointerdown@green,gotpointercapture@blue,pointerup@blue,lostpointercapture@blue"
-PASS Click target when pointerup/down targeted at the same element with no capture 
-PASS Click target when pointerup/down targeted at different elements with no capture 
-
diff --git a/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_pointercapture_in_frame-expected.txt b/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_pointercapture_in_frame-expected.txt
new file mode 100644 (file)
index 0000000..359c0a6
--- /dev/null
@@ -0,0 +1,7 @@
+
+
+FAIL Test pointer capture event route across the same-origin frame: Mouse down at inner frame and set pointer capture. assert_array_equals: Received events: innerFrame received pointermove,innerFrame received pointerdown,innerFrame received gotpointercapture,innerFrame received pointermove,innerFrame received pointermove,innerFrame received pointerup,innerFrame received lostpointercapture,outerFrame received pointermove lengths differ, expected 7 got 8
+FAIL Test pointer capture event route across the same-origin frame: Mouse down at outer frame body and set pointer capture. assert_array_equals: Received events: outerFrame received pointermove,outerFrame received pointerdown,outerFrame received gotpointercapture,outerFrame received pointermove,outerFrame received pointerup,outerFrame received lostpointercapture,innerFrame received pointermove lengths differ, expected 6 got 7
+FAIL Test pointer capture event route across the same-origin frame: Mouse down with set capture at inner frame, then release on next mouse move. assert_array_equals: Received events: innerFrame received pointermove,innerFrame received pointerdown,innerFrame received gotpointercapture,innerFrame received pointermove,innerFrame received lostpointercapture,innerFrameDocument received pointermove,outerFrame received pointerup,innerFrameDocument received pointermove,outerFrame received pointermove lengths differ, expected 7 got 9
+FAIL Test pointercapture event route across the same-origin frame: Mouse down with set capture at outer frame, then release on next mouse move. assert_array_equals: Received events: outerFrame received pointermove,outerFrame received pointerdown,outerFrame received gotpointercapture,outerFrame received pointermove,outerFrame received lostpointercapture,innerFrameElement received pointermove,innerFrameElement received pointerup,innerFrame received pointermove lengths differ, expected 7 got 8
+
index 36e040e..44e1be4 100644 (file)
@@ -16,11 +16,14 @@ Test complete: Scroll to Summary to view Pass/Fail Results.
 
 The following pointer types were detected: mouse.
 
-The following events were logged: pointerover@target1, pointerover@target0, gotpointercapture@target0, lostpointercapture@target0.
+The following events were logged: pointerover@target1, gotpointercapture@target0, pointerover@target0, pointerover@target0, lostpointercapture@target0, pointerover@target0.
 
 Refresh the page to run the tests again with a different pointer type.
 
 
+Harness Error (FAIL), message = 1 duplicate test name: "relatedTarget should not be null even when the capture is set."
+
 PASS pointerover shouldn't trigger for the purple rectangle while the black rectangle has capture 
 PASS relatedTarget should not be null even when the capture is set. 
+PASS relatedTarget should not be null even when the capture is set. 
 
index 0a476db..4b8818d 100644 (file)
@@ -1,3 +1,35 @@
+2019-06-24  Antoine Quint  <graouts@apple.com>
+
+        [Pointer Events] Respect pointer capture when dispatching mouse boundary events and updating :hover
+        https://bugs.webkit.org/show_bug.cgi?id=198999
+        <rdar://problem/51979477>
+
+        Unreviewed.
+
+        Rolling back all changes made for this bug (r246728 + r246716 + r246674) as it regressed one test
+        (imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_pointercapture_in_frame.html).
+
+        * dom/Document.cpp:
+        (WebCore::Document::prepareMouseEvent):
+        (WebCore::Document::updateHoverActiveState):
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleMousePressEvent):
+        (WebCore::EventHandler::handleMouseMoveEvent):
+        (WebCore::EventHandler::handleMouseReleaseEvent):
+        (WebCore::EventHandler::setCapturingMouseEventsElement):
+        * page/EventHandler.h:
+        * page/PointerCaptureController.cpp:
+        (WebCore::PointerCaptureController::releasePointerCapture):
+        (WebCore::PointerCaptureController::hasPointerCapture):
+        (WebCore::PointerCaptureController::dispatchEventForTouchAtIndex):
+        (WebCore::PointerCaptureController::dispatchEvent):
+        (WebCore::PointerCaptureController::processPendingPointerCapture):
+        (WebCore::PointerCaptureController::pointerCaptureElement): Deleted.
+        * page/PointerCaptureController.h:
+        * rendering/HitTestRequest.h:
+        (WebCore::HitTestRequest::includesAllElementsUnderPoint const):
+        (WebCore::HitTestRequest::pointerCaptureElementChanged const): Deleted.
+
 2019-06-23  Antoine Quint  <graouts@apple.com>
 
         [Pointer Events] Respect pointer capture when dispatching mouse boundary events and updating :hover
index 720cc45..4457d13 100644 (file)
 #include "GPUCanvasContext.h"
 #endif
 
-#if ENABLE(POINTER_EVENTS)
-#include "PointerCaptureController.h"
-#endif
-
 namespace WebCore {
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(Document);
@@ -3736,16 +3732,8 @@ MouseEventWithHitTestResults Document::prepareMouseEvent(const HitTestRequest& r
     HitTestResult result(documentPoint);
     hitTest(request, result);
 
-    if (!request.readOnly()) {
-        auto targetElement = makeRefPtr(result.targetElement());
-#if ENABLE(POINTER_EVENTS)
-        if (auto* page = this->page()) {
-            if (auto* captureElement = page->pointerCaptureController().pointerCaptureElement(mousePointerID))
-                targetElement = captureElement;
-        }
-#endif
-        updateHoverActiveState(request, targetElement.get());
-    }
+    if (!request.readOnly())
+        updateHoverActiveState(request, result.targetElement());
 
     return MouseEventWithHitTestResults(event, result);
 }
@@ -6788,9 +6776,8 @@ void Document::updateHoverActiveState(const HitTestRequest& request, Element* in
 
     // If the mouse is down and if this is a mouse move event, we want to restrict changes in
     // :hover/:active to only apply to elements that are in the :active chain that we froze
-    // at the time the mouse went down. Unless the pointer capture element was changed, in which
-    // case we want to invalidate the chains anyway.
-    bool mustBeInActiveChain = request.active() && request.move() && !request.pointerCaptureElementChanged();
+    // at the time the mouse went down.
+    bool mustBeInActiveChain = request.active() && request.move();
 
     RefPtr<Element> oldHoveredElement = WTFMove(m_hoveredElement);
 
index bb97344..a30c9e9 100644 (file)
 #include "PointerLockController.h"
 #endif
 
-#if ENABLE(POINTER_EVENTS)
-#include "PointerCaptureController.h"
-#include "Quirks.h"
-#include "RuntimeEnabledFeatures.h"
-#endif
-
 namespace WebCore {
 
 using namespace HTMLNames;
@@ -1795,11 +1789,7 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& platformMouse
 
     m_frame.selection().setCaretBlinkingSuspended(true);
 
-#if ENABLE(POINTER_EVENTS)
-    bool swallowEvent = !dispatchMouseEvent(eventNames().mousedownEvent, mouseEvent.targetNode(), true, m_clickCount, platformMouseEvent, true, request, mouseEvent);
-#else
     bool swallowEvent = !dispatchMouseEvent(eventNames().mousedownEvent, mouseEvent.targetNode(), true, m_clickCount, platformMouseEvent, true);
-#endif
     m_capturesDragging = !swallowEvent || mouseEvent.scrollbar();
 
     // If the hit testing originally determined the event was in a scrollbar, refetch the MouseEventWithHitTestResults
@@ -2045,12 +2035,7 @@ bool EventHandler::handleMouseMoveEvent(const PlatformMouseEvent& platformMouseE
     if (swallowEvent)
         return true;
     
-#if ENABLE(POINTER_EVENTS)
-    swallowEvent = !dispatchMouseEvent(eventNames().mousemoveEvent, mouseEvent.targetNode(), false, 0, platformMouseEvent, true, request, mouseEvent);
-#else
     swallowEvent = !dispatchMouseEvent(eventNames().mousemoveEvent, mouseEvent.targetNode(), false, 0, platformMouseEvent, true);
-#endif
-
 #if ENABLE(DRAG_SUPPORT)
     if (!swallowEvent)
         swallowEvent = handleMouseDraggedEvent(mouseEvent);
@@ -2154,20 +2139,6 @@ bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& platformMou
         return !dispatchMouseEvent(eventNames().mouseupEvent, m_lastElementUnderMouse.get(), cancelable, m_clickCount, platformMouseEvent, setUnder);
     }
 
-    bool shouldFireBoundaryEventsWithClick = true;
-#if ENABLE(POINTER_EVENTS)
-    if (m_frame.page()->pointerCaptureController().hasPointerCapture(m_capturingMouseEventsElement.get(), mousePointerID)) {
-        // If we have pointer capture enabled, it will be disabled by virtue of receiving a "pointerup" event. For :active and :hover
-        // styles to be set correctly when prepareMouseEvent() is called below, we should already reset pointer capture.
-        // We must also reset m_capturingMouseEventsElement to ensure boundary mouse events are dispatched on the hit-testing target.
-        // Finally, the click event target may differ from the hit-testing target, so let's not dispatch boundary mouse events as part of
-        // dispatching the click event below.
-        m_frame.page()->pointerCaptureController().releasePointerCapture(m_capturingMouseEventsElement.get(), mousePointerID);
-        m_capturingMouseEventsElement = nullptr;
-        shouldFireBoundaryEventsWithClick = false;
-    }
-#endif
-
     HitTestRequest request(HitTestRequest::Release | HitTestRequest::DisallowUserAgentShadowContent);
     MouseEventWithHitTestResults mouseEvent = prepareMouseEvent(request, platformMouseEvent);
     Frame* subframe = m_capturingMouseEventsElement.get() ? subframeForTargetNode(m_capturingMouseEventsElement.get()) : subframeForHitTestResult(mouseEvent);
@@ -2181,12 +2152,7 @@ bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& platformMou
     bool contextMenuEvent = platformMouseEvent.button() == RightButton;
 
     Node* nodeToClick = targetNodeForClickEvent(m_clickNode.get(), mouseEvent.targetNode());
-    bool swallowClickEvent = m_clickCount > 0 && !contextMenuEvent && nodeToClick && !dispatchMouseEvent(eventNames().clickEvent, nodeToClick, true, m_clickCount, platformMouseEvent, shouldFireBoundaryEventsWithClick);
-
-    // Since we did not dispatch boundary mouse events while dispatching the click event, since the click node would have been used,
-    // we need to dispatch them now accounting for the hit-testing node.
-    if (!shouldFireBoundaryEventsWithClick)
-        updateMouseEventTargetNode(mouseEvent.targetNode(), platformMouseEvent, FireMouseOverOut::Yes);
+    bool swallowClickEvent = m_clickCount > 0 && !contextMenuEvent && nodeToClick && !dispatchMouseEvent(eventNames().clickEvent, nodeToClick, true, m_clickCount, platformMouseEvent, true);
 
     if (m_resizeLayer) {
         m_resizeLayer->setInResizeMode(false);
@@ -2512,17 +2478,8 @@ void EventHandler::clearDragState()
 
 void EventHandler::setCapturingMouseEventsElement(Element* element)
 {
-    if (m_capturingMouseEventsElement == element)
-        return;
-
     m_capturingMouseEventsElement = element;
     m_eventHandlerWillResetCapturingMouseEventsElement = false;
-
-#if ENABLE(POINTER_EVENTS)
-    // If we have a new capture element, we need to dispatch boundary mouse events.
-    if (element && !element->document().quirks().shouldDisablePointerEventsQuirk() && RuntimeEnabledFeatures::sharedFeatures().pointerEventsEnabled())
-        updateMouseEventTargetNode(element, m_mouseDown, FireMouseOverOut::Yes);
-#endif
 }
 
 MouseEventWithHitTestResults EventHandler::prepareMouseEvent(const HitTestRequest& request, const PlatformMouseEvent& mouseEvent)
@@ -2646,22 +2603,6 @@ void EventHandler::updateMouseEventTargetNode(Node* targetNode, const PlatformMo
     }
 }
 
-#if ENABLE(POINTER_EVENTS)
-bool EventHandler::dispatchMouseEvent(const AtomString& eventType, Node* targetNode, bool cancelable, int clickCount, const PlatformMouseEvent& platformMouseEvent, bool setUnder, const HitTestRequest& request, MouseEventWithHitTestResults& mouseEvent)
-{
-    if (!RuntimeEnabledFeatures::sharedFeatures().pointerEventsEnabled() || (targetNode && targetNode->ownerDocument() && targetNode->document().quirks().shouldDisablePointerEventsQuirk()))
-        return dispatchMouseEvent(eventType, targetNode, cancelable, clickCount, platformMouseEvent, setUnder);
-
-    auto& pointerCaptureController = m_frame.page()->pointerCaptureController();
-    auto* oldCaptureElement = pointerCaptureController.pointerCaptureElement(mousePointerID);
-    bool defaultPrevented = dispatchMouseEvent(eventType, targetNode, cancelable, clickCount, platformMouseEvent, setUnder);
-    auto* newCaptureElement = pointerCaptureController.pointerCaptureElement(mousePointerID);
-    if (oldCaptureElement != newCaptureElement)
-        mouseEvent = prepareMouseEvent(HitTestRequest(request.type() | HitTestRequest::PointerCaptureElementChanged), platformMouseEvent);
-    return defaultPrevented;
-}
-#endif
-
 bool EventHandler::dispatchMouseEvent(const AtomString& eventType, Node* targetNode, bool /*cancelable*/, int clickCount, const PlatformMouseEvent& platformMouseEvent, bool setUnder)
 {
     Ref<Frame> protectedFrame(m_frame);
index ab72afa..34149e1 100644 (file)
@@ -413,9 +413,6 @@ private:
     MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const PlatformMouseEvent&);
 
     bool dispatchMouseEvent(const AtomString& eventType, Node* target, bool cancelable, int clickCount, const PlatformMouseEvent&, bool setUnder);
-#if ENABLE(POINTER_EVENTS)
-    bool dispatchMouseEvent(const AtomString& eventType, Node* target, bool cancelable, int clickCount, const PlatformMouseEvent&, bool setUnder, const HitTestRequest&, MouseEventWithHitTestResults&);
-#endif
 
 #if ENABLE(DRAG_SUPPORT)
     bool dispatchDragEvent(const AtomString& eventType, Element& target, const PlatformMouseEvent&, DataTransfer&);
index 99353e3..f822abd 100644 (file)
@@ -48,14 +48,6 @@ PointerCaptureController::PointerCaptureController(Page& page)
     reset();
 }
 
-Element* PointerCaptureController::pointerCaptureElement(PointerID pointerId)
-{
-    auto iterator = m_activePointerIdsToCapturingData.find(pointerId);
-    if (iterator != m_activePointerIdsToCapturingData.end())
-        return iterator->value.pendingTargetOverride.get();
-    return nullptr;
-}
-
 ExceptionOr<void> PointerCaptureController::setPointerCapture(Element* capturingTarget, PointerID pointerId)
 {
     // https://w3c.github.io/pointerevents/#setting-pointer-capture
@@ -104,14 +96,7 @@ ExceptionOr<void> PointerCaptureController::releasePointerCapture(Element* captu
         return { };
 
     // 3. For the specified pointerId, clear the pending pointer capture target override, if set.
-    auto& capturingData = iterator->value;
-    capturingData.pendingTargetOverride = nullptr;
-
-    // Since we may not call processPendingPointerCapture() until the dispatch of the next event,
-    // we must reset EventHandler's capturing mouse element right now so that the next event processed
-    // does not use it as an overriding target.
-    if (capturingData.pointerType == PointerEvent::mousePointerType())
-        m_page.mainFrame().eventHandler().setCapturingMouseEventsElement(nullptr);
+    iterator->value.pendingTargetOverride = nullptr;
 
     return { };
 }
@@ -124,9 +109,6 @@ bool PointerCaptureController::hasPointerCapture(Element* capturingTarget, Point
     // In particular, returns true if the pending pointer capture target override for pointerId is set to the element on which this method is
     // invoked, and false otherwise.
 
-    if (!capturingTarget)
-        return false;
-
     auto iterator = m_activePointerIdsToCapturingData.find(pointerId);
     return iterator != m_activePointerIdsToCapturingData.end() && iterator->value.pendingTargetOverride == capturingTarget;
 }
@@ -192,7 +174,7 @@ bool PointerCaptureController::preventsCompatibilityMouseEventsForIdentifier(Poi
 #if ENABLE(TOUCH_EVENTS) && PLATFORM(IOS_FAMILY)
 void PointerCaptureController::dispatchEventForTouchAtIndex(EventTarget& target, const PlatformTouchEvent& platformTouchEvent, unsigned index, bool isPrimary, WindowProxy& view)
 {
-    auto dispatchOverOrOutEvent = [&](const String& type) {
+    auto dispatchEvent = [&](const String& type) {
         target.dispatchEvent(PointerEvent::create(type, platformTouchEvent, index, isPrimary, view));
     };
 
@@ -231,17 +213,19 @@ void PointerCaptureController::dispatchEventForTouchAtIndex(EventTarget& target,
         // https://w3c.github.io/pointerevents/#the-pointerdown-event
         // For input devices that do not support hover, a user agent MUST also fire a pointer event named pointerover followed by a pointer event named
         // pointerenter prior to dispatching the pointerdown event.
-        dispatchOverOrOutEvent(eventNames().pointeroverEvent);
+        dispatchEvent(eventNames().pointeroverEvent);
         dispatchEnterOrLeaveEvent(eventNames().pointerenterEvent);
     }
 
-    dispatchEvent(pointerEvent, &target);
+    pointerEventWillBeDispatched(pointerEvent, &target);
+    target.dispatchEvent(pointerEvent);
+    pointerEventWasDispatched(pointerEvent);
 
     if (pointerEvent->type() == eventNames().pointerupEvent) {
         // https://w3c.github.io/pointerevents/#the-pointerup-event
         // For input devices that do not support hover, a user agent MUST also fire a pointer event named pointerout followed by a
         // pointer event named pointerleave after dispatching the pointerup event.
-        dispatchOverOrOutEvent(eventNames().pointeroutEvent);
+        dispatchEvent(eventNames().pointeroutEvent);
         dispatchEnterOrLeaveEvent(eventNames().pointerleaveEvent);
     }
 }
@@ -284,6 +268,16 @@ RefPtr<PointerEvent> PointerCaptureController::pointerEventForMouseEvent(const M
 
 void PointerCaptureController::dispatchEvent(PointerEvent& event, EventTarget* target)
 {
+    auto iterator = m_activePointerIdsToCapturingData.find(event.pointerId());
+    if (iterator != m_activePointerIdsToCapturingData.end()) {
+        auto& capturingData = iterator->value;
+        if (capturingData.pendingTargetOverride && capturingData.targetOverride)
+            target = capturingData.targetOverride.get();
+    }
+
+    if (!target || event.target())
+        return;
+
     pointerEventWillBeDispatched(event, target);
     target->dispatchEvent(event);
     pointerEventWasDispatched(event);
@@ -407,11 +401,6 @@ void PointerCaptureController::cancelPointer(PointerID pointerId, const IntPoint
 
 void PointerCaptureController::processPendingPointerCapture(const PointerEvent& event)
 {
-    if (m_processingPendingPointerCapture)
-        return;
-    
-    m_processingPendingPointerCapture = true;
-    
     // https://w3c.github.io/pointerevents/#process-pending-pointer-capture
 
     auto iterator = m_activePointerIdsToCapturingData.find(event.pointerId());
@@ -422,25 +411,17 @@ void PointerCaptureController::processPendingPointerCapture(const PointerEvent&
 
     // 1. If the pointer capture target override for this pointer is set and is not equal to the pending pointer capture target override,
     // then fire a pointer event named lostpointercapture at the pointer capture target override node.
-    if (capturingData.targetOverride && capturingData.targetOverride != capturingData.pendingTargetOverride) {
-        if (event.pointerType() == PointerEvent::mousePointerType())
-            m_page.mainFrame().eventHandler().setCapturingMouseEventsElement(nullptr);
+    if (capturingData.targetOverride && capturingData.targetOverride != capturingData.pendingTargetOverride)
         capturingData.targetOverride->dispatchEvent(PointerEvent::createForPointerCapture(eventNames().lostpointercaptureEvent, event));
-    }
 
     // 2. If the pending pointer capture target override for this pointer is set and is not equal to the pointer capture target override,
     // then fire a pointer event named gotpointercapture at the pending pointer capture target override.
-    if (capturingData.pendingTargetOverride && capturingData.targetOverride != capturingData.pendingTargetOverride) {
-        if (event.pointerType() == PointerEvent::mousePointerType())
-            m_page.mainFrame().eventHandler().setCapturingMouseEventsElement(capturingData.pendingTargetOverride.get());
+    if (capturingData.pendingTargetOverride && capturingData.targetOverride != capturingData.pendingTargetOverride)
         capturingData.pendingTargetOverride->dispatchEvent(PointerEvent::createForPointerCapture(eventNames().gotpointercaptureEvent, event));
-    }
 
     // 3. Set the pointer capture target override to the pending pointer capture target override, if set. Otherwise, clear the pointer
     // capture target override.
     capturingData.targetOverride = capturingData.pendingTargetOverride;
-
-    m_processingPendingPointerCapture = false;
 }
 
 } // namespace WebCore
index 0b1a05d..3041e3a 100644 (file)
@@ -60,7 +60,6 @@ public:
     bool preventsCompatibilityMouseEventsForIdentifier(PointerID);
     void dispatchEvent(PointerEvent&, EventTarget*);
     WEBCORE_EXPORT void cancelPointer(PointerID, const IntPoint&);
-    Element* pointerCaptureElement(PointerID);
 
 private:
     struct CapturingData {
@@ -83,7 +82,6 @@ private:
     // empty and removed values, allowing any int32_t to be provided through the API for lookup in this hashmap.
     using PointerIdToCapturingDataMap = HashMap<int64_t, CapturingData, WTF::IntHash<int64_t>, WTF::SignedWithZeroKeyHashTraits<int64_t>>;
     PointerIdToCapturingDataMap m_activePointerIdsToCapturingData;
-    bool m_processingPendingPointerCapture { false };
 };
 
 } // namespace WebCore
index b3c076e..1cf5144 100644 (file)
@@ -44,9 +44,7 @@ public:
         // Collect a list of nodes instead of just one. Used for elementsFromPoint and rect-based tests.
         CollectMultipleElements = 1 << 13,
         // When using list-based testing, continue hit testing even after a hit has been found.
-        IncludeAllElementsUnderPoint = 1 << 14,
-        // When the pointer capture target has changed, we should disregard the move and active bits when invalidating the :active and :hover chains.
-        PointerCaptureElementChanged = 1 << 15
+        IncludeAllElementsUnderPoint = 1 << 14
     };
 
     typedef unsigned HitTestRequestType;
@@ -71,7 +69,6 @@ public:
     bool isChildFrameHitTest() const { return m_requestType & ChildFrameHitTest; }
     bool resultIsElementList() const { return m_requestType & CollectMultipleElements; }
     bool includesAllElementsUnderPoint() const { return m_requestType & IncludeAllElementsUnderPoint; }
-    bool pointerCaptureElementChanged() const { return m_requestType & PointerCaptureElementChanged; }
 
     // Convenience functions
     bool touchMove() const { return move() && touchEvent(); }