[webkit-changes] [WebKit/WebKit] 18348e: PointerEvent.button should be -1 when mouse button...

Abrar Rahman Protyasha noreply at github.com
Tue Sep 26 10:15:59 PDT 2023


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

  Changed paths:
    M LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_attributes_hoverable_pointers_mouse-expected.txt
    M Source/WebCore/dom/MouseEvent.cpp
    M Source/WebCore/dom/PointerEvent.cpp
    M Source/WebCore/dom/PointerEvent.h
    M Source/WebCore/dom/ios/PointerEventIOS.cpp
    M Source/WebCore/page/PointerCaptureController.cpp
    M Source/WebCore/page/PointerCaptureController.h
    M Source/WebCore/platform/PlatformMouseEvent.h

  Log Message:
  -----------
  PointerEvent.button should be -1 when mouse buttons are in released state
https://bugs.webkit.org/show_bug.cgi?id=262089
rdar://116027480

Reviewed by Wenson Hsieh.

This commit fixes part of the failure in the
pointerevent_attributes_hoverable_pointers.html?mouse WPT, where the
failure mode suggests we're returning 0 for the button attribute of a
pointer event instead of -1.

This failure reflects an inconformity with the Pointer Events W3C spec
in our implementation of the button proprerty. As specified, an event's
button property should be -1 when "Neither buttons nor touch/pen contact
changed since last event", but it does _not_ suggest limiting this
behavior to pointermove events only, which is what we were doing.

To be better aligned with other browser vendors (and the spec), we make
our button property heuristic less restrictive and applicable for all
pointer event types (barring pointerup/pointerdown, since they represent
button change). In doing so, we also take the liberty to rename
MouseEvent::PointerMove to MouseEvent::PointerHasNotChanged, since the
latter case better reflects the meaning of the `-1` button value.

* LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_attributes_hoverable_pointers_mouse-expected.txt:
* Source/WebCore/dom/MouseEvent.cpp:
(WebCore::MouseEvent::button const):

* Source/WebCore/dom/PointerEvent.cpp:
(WebCore::PointerEvent::PointerEvent):
Do not unconditionally assign MouseButton::Left (0) to the button
property.

* Source/WebCore/dom/PointerEvent.h:
(WebCore::PointerEvent::typeIsUpOrDown):

Make `buttonForType` platform agnostic (and public), making it a more
useful utility and reducing code duplication.

* Source/WebCore/dom/ios/PointerEventIOS.cpp:
(WebCore::buttonForType): Deleted.
* Source/WebCore/page/PointerCaptureController.cpp:
(WebCore::pointerEventType):
(WebCore::PointerCaptureController::pointerEventForMouseEvent):
* Source/WebCore/page/PointerCaptureController.h:
* Source/WebCore/platform/PlatformMouseEvent.h:

Rename MouseButton::PointerMove to MouseButton::PointerHasNotChanged.

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




More information about the webkit-changes mailing list