Changeset 246074 in webkit
- Timestamp:
- Jun 4, 2019, 12:00:12 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_setpointercapture_inactive_button_mouse-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/page/PointerCaptureController.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r246045 r246074 1 2019-06-04 Antoine Quint <graouts@apple.com> 2 3 [Pointer Events] Only allow pointer capture if the pointer is in the active buttons state 4 https://bugs.webkit.org/show_bug.cgi?id=198479 5 6 Reviewed by Dean Jackson. 7 8 Mark WPT progression. 9 10 * web-platform-tests/pointerevents/pointerevent_setpointercapture_inactive_button_mouse-expected.txt: 11 1 12 2019-06-03 Rob Buis <rbuis@igalia.com> 2 13 -
trunk/LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_setpointercapture_inactive_button_mouse-expected.txt
r244393 r246074 10 10 11 11 12 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 12 PASS pointer capture is not set while button state is inactive 13 13 -
trunk/Source/WebCore/ChangeLog
r246072 r246074 1 2019-06-04 Antoine Quint <graouts@apple.com> 2 3 [Pointer Events] Only allow pointer capture if the pointer is in the active buttons state 4 https://bugs.webkit.org/show_bug.cgi?id=198479 5 6 Reviewed by Dean Jackson. 7 8 The Pointer Events specification says that pointer capture can only be engaged provided the pointer is 9 in the active buttons state, which means that it has dispatched a "pointerdown" event more recently than 10 it has a "pointerup" event. 11 12 This is tested by web-platform-tests/pointerevents/pointerevent_setpointercapture_inactive_button_mouse.html. 13 14 That test showed a few issues that this patch addresses. First, we would update the pointerIsPressed state to 15 "true" only after a "pointerdown" event had been dispatched. This is incorrect since setPointerCapture() can, 16 and is likely to, be called during handling of a "pointerdown" event. So we now call pointerEventWillBeDispatched() 17 prior to dispatching a PointerEvent with a mouse type, which we only did previously for a PointerEvent with a 18 touch or pen type. If the event is "pointerdown", we set "pointerIsPressed" to true on the CapturingData object 19 matching the given pointer, and to false if the event is "pointerup". 20 21 Finally, we must also ensure that "pointerIsPressed" is set to true when creating CapturingData for a PointerEvent 22 with a touch or pen type since these types of pointer events implictly set capture. 23 24 * page/PointerCaptureController.cpp: 25 (WebCore::PointerCaptureController::setPointerCapture): 26 (WebCore::PointerCaptureController::dispatchEvent): 27 (WebCore::PointerCaptureController::pointerEventWillBeDispatched): 28 (WebCore::PointerCaptureController::pointerEventWasDispatched): 29 1 30 2019-06-04 Keith Rollin <krollin@apple.com> 2 31 -
trunk/Source/WebCore/page/PointerCaptureController.cpp
r246072 r246074 71 71 72 72 // 4. If the pointer is not in the active buttons state, then terminate these steps. 73 // FIXME: implement when we support mouse events.74 75 73 // 5. For the specified pointerId, set the pending pointer capture target override to the Element on which this method was invoked. 76 iterator->value.pendingTargetOverride = capturingTarget; 74 auto& capturingData = iterator->value; 75 if (capturingData.pointerIsPressed) 76 capturingData.pendingTargetOverride = capturingTarget; 77 77 78 78 return { }; … … 238 238 auto& capturingData = iterator->value; 239 239 if (capturingData.pendingTargetOverride && capturingData.targetOverride) 240 capturingData.targetOverride->dispatchEvent(event); 241 } 242 243 if (target && !event.target()) 244 target->dispatchEvent(event); 245 240 target = capturingData.targetOverride.get(); 241 } 242 243 if (!target || event.target()) 244 return; 245 246 pointerEventWillBeDispatched(event, target); 247 target->dispatchEvent(event); 246 248 pointerEventWasDispatched(event); 247 249 } … … 249 251 void PointerCaptureController::pointerEventWillBeDispatched(const PointerEvent& event, EventTarget* target) 250 252 { 253 if (!is<Element>(target)) 254 return; 255 256 bool isPointerdown = event.type() == eventNames().pointerdownEvent; 257 bool isPointerup = event.type() == eventNames().pointerupEvent; 258 if (!isPointerdown && !isPointerup) 259 return; 260 261 auto pointerId = event.pointerId(); 262 263 if (event.pointerType() == PointerEvent::mousePointerType()) { 264 auto iterator = m_activePointerIdsToCapturingData.find(pointerId); 265 if (iterator != m_activePointerIdsToCapturingData.end()) 266 iterator->value.pointerIsPressed = isPointerdown; 267 return; 268 } 269 270 if (!isPointerdown) 271 return; 272 251 273 // https://w3c.github.io/pointerevents/#implicit-pointer-capture 252 274 … … 261 283 // to the target (as normal) indicating that capture is active. 262 284 263 if (!is<Element>(target) || event.type() != eventNames().pointerdownEvent)264 return;265 266 auto pointerId = event.pointerId();267 285 CapturingData capturingData; 268 286 capturingData.pointerType = event.pointerType(); 287 capturingData.pointerIsPressed = true; 269 288 m_activePointerIdsToCapturingData.set(pointerId, capturingData); 270 289 setPointerCapture(downcast<Element>(target), pointerId); … … 282 301 // Pointer Capture steps to fire lostpointercapture if necessary. 283 302 // https://w3c.github.io/pointerevents/#implicit-release-of-pointer-capture 284 if (event.type() == eventNames().pointerupEvent) {303 if (event.type() == eventNames().pointerupEvent) 285 304 capturingData.pendingTargetOverride = nullptr; 286 capturingData.pointerIsPressed = false;287 }288 305 289 306 // If a mouse pointer has moved while it isn't pressed, make sure we reset the preventsCompatibilityMouseEvents flag since … … 294 311 // If the pointer event dispatched was pointerdown and the event was canceled, then set the PREVENT MOUSE EVENT flag for this pointerType. 295 312 // https://www.w3.org/TR/pointerevents/#mapping-for-devices-that-support-hover 296 if (event.type() == eventNames().pointerdownEvent) {313 if (event.type() == eventNames().pointerdownEvent) 297 314 capturingData.preventsCompatibilityMouseEvents = event.defaultPrevented(); 298 capturingData.pointerIsPressed = true;299 }300 315 } 301 316
Note:
See TracChangeset
for help on using the changeset viewer.