WebKit Bugzilla
Attachment 371181 Details for
Bug 198479
: [Pointer Events] Only allow pointer capture if the pointer is in the active buttons state
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198479-20190603103251.patch (text/plain), 8.73 KB, created by
Antoine Quint
on 2019-06-03 01:32:52 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Antoine Quint
Created:
2019-06-03 01:32:52 PDT
Size:
8.73 KB
patch
obsolete
>Subversion Revision: 246020 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 196d2609c9e3d7207ffa92d1da2ea763f36a2105..ca0fe27ad45a56695cbaf0c7233c0f3987d0591e 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,32 @@ >+2019-06-03 Antoine Quint <graouts@apple.com> >+ >+ [Pointer Events] Only allow pointer capture if the pointer is in the active buttons state >+ https://bugs.webkit.org/show_bug.cgi?id=198479 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ The Pointer Events specification says that pointer capture can only be engaged provided the pointer is >+ in the active buttons state, which means that it has dispatched a "pointerdown" event more recently than >+ it has a "pointerup" event. >+ >+ This is tested by web-platform-tests/pointerevents/pointerevent_setpointercapture_inactive_button_mouse.html. >+ >+ That test showed a few issues that this patch addresses. First, we would update the pointerIsPressed state to >+ "true" only after a "pointerdown" event had been dispatched. This is incorrect since setPointerCapture() can, >+ and is likely to, be called during handling of a "pointerdown" event. So we now call pointerEventWillBeDispatched() >+ prior to dispatching a PointerEvent with a mouse type, which we only did previously for a PointerEvent with a >+ touch or pen type. If the event is "pointerdown", we set "pointerIsPressed" to true on the CapturingData object >+ matching the given pointer, and to false if the event is "pointerup". >+ >+ Finally, we must also ensure that "pointerIsPressed" is set to true when creating CapturingData for a PointerEvent >+ with a touch or pen type since these types of pointer events implictly set capture. >+ >+ * page/PointerCaptureController.cpp: >+ (WebCore::PointerCaptureController::setPointerCapture): >+ (WebCore::PointerCaptureController::dispatchEvent): >+ (WebCore::PointerCaptureController::pointerEventWillBeDispatched): >+ (WebCore::PointerCaptureController::pointerEventWasDispatched): >+ > 2019-06-01 Simon Fraser <simon.fraser@apple.com> > > [Async overflow scroll] Flashing content when scrolling async overflow with a negative z-index child >diff --git a/Source/WebCore/page/PointerCaptureController.cpp b/Source/WebCore/page/PointerCaptureController.cpp >index efa12a15d9bd7e19d2ae1841160a8694a0a66391..caf998c753c75fb20d75c05d6de63213e8b5fa3f 100644 >--- a/Source/WebCore/page/PointerCaptureController.cpp >+++ b/Source/WebCore/page/PointerCaptureController.cpp >@@ -69,10 +69,10 @@ ExceptionOr<void> PointerCaptureController::setPointerCapture(Element* capturing > #endif > > // 4. If the pointer is not in the active buttons state, then terminate these steps. >- // FIXME: implement when we support mouse events. >- > // 5. For the specified pointerId, set the pending pointer capture target override to the Element on which this method was invoked. >- iterator->value.pendingTargetOverride = capturingTarget; >+ auto& capturingData = iterator->value; >+ if (capturingData.pointerIsPressed) >+ capturingData.pendingTargetOverride = capturingTarget; > > return { }; > } >@@ -226,17 +226,39 @@ void PointerCaptureController::dispatchEvent(PointerEvent& event, EventTarget* t > if (iterator != m_activePointerIdsToCapturingData.end()) { > auto& capturingData = iterator->value; > if (capturingData.pendingTargetOverride && capturingData.targetOverride) >- capturingData.targetOverride->dispatchEvent(event); >+ target = capturingData.targetOverride.get(); > } > >- if (target && !event.target()) >- target->dispatchEvent(event); >+ if (!target || event.target()) >+ return; > >+ pointerEventWillBeDispatched(event, target); >+ target->dispatchEvent(event); > pointerEventWasDispatched(event); > } > > void PointerCaptureController::pointerEventWillBeDispatched(const PointerEvent& event, EventTarget* target) > { >+ if (!is<Element>(target)) >+ return; >+ >+ bool isPointerdown = event.type() == eventNames().pointerdownEvent; >+ bool isPointerup = event.type() == eventNames().pointerupEvent; >+ if (!isPointerdown && !isPointerup) >+ return; >+ >+ auto pointerId = event.pointerId(); >+ >+ if (event.pointerType() == PointerEvent::mousePointerType()) { >+ auto iterator = m_activePointerIdsToCapturingData.find(pointerId); >+ if (iterator != m_activePointerIdsToCapturingData.end()) >+ iterator->value.pointerIsPressed = isPointerdown; >+ return; >+ } >+ >+ if (!isPointerdown) >+ return; >+ > // https://w3c.github.io/pointerevents/#implicit-pointer-capture > > // Some input devices (such as touchscreens) implement a "direct manipulation" metaphor where a pointer is intended to act primarily on the UI >@@ -249,12 +271,9 @@ void PointerCaptureController::pointerEventWillBeDispatched(const PointerEvent& > // releasePointerCapture is not called for the pointer before the next pointer event is fired, then a gotpointercapture event will be dispatched > // to the target (as normal) indicating that capture is active. > >- if (!is<Element>(target) || event.type() != eventNames().pointerdownEvent) >- return; >- >- auto pointerId = event.pointerId(); > CapturingData capturingData; > capturingData.pointerType = event.pointerType(); >+ capturingData.pointerIsPressed = true; > m_activePointerIdsToCapturingData.set(pointerId, capturingData); > setPointerCapture(downcast<Element>(target), pointerId); > } >@@ -270,10 +289,8 @@ void PointerCaptureController::pointerEventWasDispatched(const PointerEvent& eve > // 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) { >+ if (event.type() == eventNames().pointerupEvent) > capturingData.pendingTargetOverride = nullptr; >- capturingData.pointerIsPressed = false; >- } > > // If a mouse pointer has moved while it isn't pressed, make sure we reset the preventsCompatibilityMouseEvents flag since > // we could otherwise prevent compatibility mouse events while those are only supposed to be prevented while the pointer is pressed. >@@ -282,10 +299,8 @@ void PointerCaptureController::pointerEventWasDispatched(const PointerEvent& eve > > // 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) { >+ if (event.type() == eventNames().pointerdownEvent) > capturingData.preventsCompatibilityMouseEvents = event.defaultPrevented(); >- capturingData.pointerIsPressed = true; >- } > } > > processPendingPointerCapture(event); >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index 9bc4229105c8c76c73951377639f653913759af3..a29896d1e8156a37925456f33ecec21ba572b7ef 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1,3 +1,14 @@ >+2019-06-03 Antoine Quint <graouts@apple.com> >+ >+ [Pointer Events] Only allow pointer capture if the pointer is in the active buttons state >+ https://bugs.webkit.org/show_bug.cgi?id=198479 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Mark WPT progression. >+ >+ * web-platform-tests/pointerevents/pointerevent_setpointercapture_inactive_button_mouse-expected.txt: >+ > 2019-05-31 Joonghun Park <jh718.park@samsung.com> > > Always min-width should win over max-width. >diff --git a/LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_setpointercapture_inactive_button_mouse-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_setpointercapture_inactive_button_mouse-expected.txt >index baccfe6d0d5cd7d47e43224df0d13f0aa124dd98..f2bce1a3ec42c4b5179e0b10f42f437ddc8a5c35 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_setpointercapture_inactive_button_mouse-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_setpointercapture_inactive_button_mouse-expected.txt >@@ -9,5 +9,5 @@ Pointer Events setPointerCapture Tests > The following pointer types were detected: mouse. > > >-FAIL pointer capture is not set while button state is inactive assert_false: pointer capture is not set while button state is inactive expected false got true >+PASS pointer capture is not set while button state is inactive >
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 198479
: 371181