[webkit-changes] [WebKit/WebKit] a13dcf: [PointerEvents] pressure property is not spec-comp...

Abrar Rahman Protyasha noreply at github.com
Wed Sep 27 17:36:03 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a13dcf305bd1d474c02191d1e4c3c9a517bb6603
      https://github.com/WebKit/WebKit/commit/a13dcf305bd1d474c02191d1e4c3c9a517bb6603
  Author: Abrar Rahman Protyasha <a_protyasha at apple.com>
  Date:   2023-09-27 (Wed, 27 Sep 2023)

  Changed paths:
    M LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_attributes_hoverable_pointers_mouse-expected.txt
    M Source/WebCore/dom/PointerEvent.cpp
    M Source/WebCore/dom/PointerEvent.h
    M Source/WebKit/Shared/WebEventConversion.cpp
    M Tools/DumpRenderTree/mac/EventSendingController.mm
    M Tools/WebKitTestRunner/mac/EventSenderProxy.mm

  Log Message:
  -----------
  [PointerEvents] pressure property is not spec-compliant when constructed from mouse event
https://bugs.webkit.org/show_bug.cgi?id=262159
rdar://116094696

Reviewed by Tim Nguyen.

Every PointerEvent object created from a backing MouseEvent object in
PointerCaptureController has an incorrect pressure value, namely 0. This
is the result of the coming together of a few issues:

1. We simply don't consult MouseEvent.force to initialize
   PointerEvent.pressure when creating a PointerEvent object from a
   backing MouseEvent. This is not the case when constructing from a
   PlatformTouchEvent, where we do correctly consult the force at given
   touch indices.
2. When creating a PointerEvent in a pressure insensitive context, we
   default to initializing the pressure property as zero, which is not
   compliant with the PointerEvents spec.
3. We don't populate the pressure attribute of NSEvent instances sent by
   EventSenderProxy, so even if we had consulted MouseEvent.force in
   the first issue, we would still be getting the wrong pressure values.

To address these issues, we define a helper static method
`PointerEvent::pressureForPressureInsensitiveInputDevices` that returns
the pressure value defined in the PointerEvents spec, conditioned on the
button currently being pressed. This method is then called if we are in
a pressure insensitive context (i.e. we're generating a PointerEvent
with Mouse pointer type, rather than Pen/Touch). However, if we're in a
pressure sensitive context, we simply consult the pressure attribute of
the backing event. Finally, to close the loop and plumb pressure values
from WKTR to generated pointer events, we make sure to supply the
appropriate pressure argument to NSEvent initializers for mouseDown
events.

This patch allows us to pass the following pressure-related assertion in
the pointerevents/pointerevent_attributes_hoverable_pointers.html?mouse WPT.

```
FAIL mouse pointerdown.pressure value is valid assert_greater_than: pressure is greater than 0 with a button pressed expected a number greater than 0 but got 0
```

* LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_attributes_hoverable_pointers_mouse-expected.txt:

Update test expectations with newly passing assertion.

* Source/WebCore/dom/PointerEvent.cpp:
* Source/WebCore/dom/PointerEvent.h:
* Source/WebKit/Shared/WebEventConversion.cpp:
(WebKit::WebKit2PlatformMouseEvent::WebKit2PlatformMouseEvent):
* Tools/DumpRenderTree/mac/EventSendingController.mm:
(-[EventSendingController mouseDown:withModifiers:]):
(-[EventSendingController contextClick]):
* Tools/WebKitTestRunner/mac/EventSenderProxy.mm:
(WTR::EventSenderProxy::mouseDown):
(WTR::EventSenderProxy::sendMouseDownToStartPressureEvents):

Canonical link: https://commits.webkit.org/268552@main




More information about the webkit-changes mailing list