Changeset 291886 in webkit


Ignore:
Timestamp:
Mar 25, 2022 1:54:28 PM (4 months ago)
Author:
Devin Rousso
Message:

PointerEvent.movementX always 0 (breaks https://noisecraft.app/)
https://bugs.webkit.org/show_bug.cgi?id=220194
<rdar://problem/72814440>

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

  • web-platform-tests/pointerevents/pointerlock/pointerevent_movementxy_with_pointerlock-expected.txt:

This change causes the test to progress further than before, but there still appear to be
other issues elsewhere, so adjust the expected output to reflect that.

Source/WebCore:

Test: pointer-lock/pointermove-movement-delta.html

  • dom/PointerEvent.cpp:

(WebCore::PointerEvent::PointerEvent):
Also pass along the movement delta in the constructor that takes a MouseEvent.

  • dom/MouseEvent.h:
  • dom/MouseEvent.cpp:

(WebCore::MouseEvent::create):
(WebCore::MouseEvent::MouseEvent):
Require that all constructors that aren't invoked from JS always provide a movement delta.

  • dom/MouseRelatedEvent.h:

(WebCore::MouseRelatedEvent::movementX const):
(WebCore::MouseRelatedEvent::movementY const):
Expose these methods even when !ENABLE(POINTER_LOCK) so that they can be called without
the callsite having to also have a #if.

  • page/EventHandler.cpp:

(WebCore::EventHandler::dispatchDragEvent):
Pass along the movement delta even when !ENABLE(POINTER_LOCK).

Tools:

  • DumpRenderTree/mac/EventSendingController.mm:

(-[EventSendingController mouseMoveToX:Y:]):

  • WebKitTestRunner/mac/EventSenderProxy.mm:

(WTR::EventSenderProxy::mouseMoveTo):
On macOS, the screen's origin is the bottom-left corner, so we need to flip the deltaY.

LayoutTests:

  • pointer-lock/pointermove-movement-delta.html: Added.
  • pointer-lock/pointermove-movement-delta-expected.txt: Added.
  • pointer-lock/mouse-event-delivery-expected.txt: Added.

On macOS, the screen's origin is the bottom-left corner, so we need to flip the deltaY.

  • platform/gtk/imported/w3c/web-platform-tests/pointerevents/pointerlock/pointerevent_movementxy_with_pointerlock-expected.txt: Added.

This change causes the test to progress further than before, but there still appear to be
other issues elsewhere, so adjust the expected output to reflect that.

  • platform/mac-wk1/TestExpectations:
Location:
trunk
Files:
3 added
15 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r291858 r291886  
     12022-03-25  Devin Rousso  <drousso@apple.com>
     2
     3        `PointerEvent.movementX` always 0 (breaks https://noisecraft.app/)
     4        https://bugs.webkit.org/show_bug.cgi?id=220194
     5        <rdar://problem/72814440>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * pointer-lock/pointermove-movement-delta.html: Added.
     10        * pointer-lock/pointermove-movement-delta-expected.txt: Added.
     11
     12        * pointer-lock/mouse-event-delivery-expected.txt: Added.
     13        On macOS, the screen's origin is the bottom-left corner, so we need to flip the `deltaY`.
     14
     15        * platform/gtk/imported/w3c/web-platform-tests/pointerevents/pointerlock/pointerevent_movementxy_with_pointerlock-expected.txt: Added.
     16        This change causes the test to progress further than before, but there still appear to be
     17        other issues elsewhere, so adjust the expected output to reflect that.
     18
     19        * platform/mac-wk1/TestExpectations:
     20
    1212022-03-25  Simon Fraser  <simon.fraser@apple.com>
    222
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r291867 r291886  
     12022-03-25  Devin Rousso  <drousso@apple.com>
     2
     3        `PointerEvent.movementX` always 0 (breaks https://noisecraft.app/)
     4        https://bugs.webkit.org/show_bug.cgi?id=220194
     5        <rdar://problem/72814440>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * web-platform-tests/pointerevents/pointerlock/pointerevent_movementxy_with_pointerlock-expected.txt:
     10        This change causes the test to progress further than before, but there still appear to be
     11        other issues elsewhere, so adjust the expected output to reflect that.
     12
    1132022-03-25  Alex Christensen  <achristensen@webkit.org>
    214
  • trunk/LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerlock/pointerevent_movementxy_with_pointerlock-expected.txt

    r264344 r291886  
    1313
    1414
    15 FAIL mouse pointerevent movementX/Y with pointerlock test assert_equals: expected 0 but got 10
     15FAIL mouse pointerevent movementX/Y with pointerlock test assert_equals: expected -9991 but got -9981
    1616
  • trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/pointerevents/pointerlock/pointerevent_movementxy_with_pointerlock-expected.txt

    r291885 r291886  
    1313
    1414
    15 FAIL mouse pointerevent movementX/Y with pointerlock test assert_equals: expected 0 but got 10
     15FAIL mouse pointerevent movementX/Y with pointerlock test assert_equals: expected 9 but got 19
    1616
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r291807 r291886  
    11331133webkit.org/b/195098 pointerevents/mouse/pointer-capture.html [ Failure ]
    11341134webkit.org/b/195098 pointerevents/mouse/pointer-events-before-mouse-events.html [ Failure ]
     1135webkit.org/b/195098 pointer-lock/pointermove-movement-delta.html [ Failure ]
    11351136
    11361137webkit.org/b/196915 [ Debug ] inspector/timeline/timeline-recording.html [ Pass Failure ]
  • trunk/LayoutTests/pointer-lock/mouse-event-delivery-expected.txt

    r211663 r291886  
    1010PASS event type: wheel, target: target1, received on: body
    1111     With a lock in place move the mouse.
    12 PASS event type: mousemove, movementX: 25, movementY: -30, target: target1, received on: target1
    13 PASS event type: mousemove, movementX: 25, movementY: -30, target: target1, received on: body
     12PASS event type: mousemove, movementX: 25, movementY: 30, target: target1, received on: target1
     13PASS event type: mousemove, movementX: 25, movementY: 30, target: target1, received on: body
    1414     With a lock in place send a click.
    1515PASS event type: mousedown, target: target1, received on: target1
  • trunk/Source/WebCore/ChangeLog

    r291883 r291886  
     12022-03-25  Devin Rousso  <drousso@apple.com>
     2
     3        `PointerEvent.movementX` always 0 (breaks https://noisecraft.app/)
     4        https://bugs.webkit.org/show_bug.cgi?id=220194
     5        <rdar://problem/72814440>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Test: pointer-lock/pointermove-movement-delta.html
     10
     11        * dom/PointerEvent.cpp:
     12        (WebCore::PointerEvent::PointerEvent):
     13        Also pass along the movement delta in the constructor that takes a `MouseEvent`.
     14
     15        * dom/MouseEvent.h:
     16        * dom/MouseEvent.cpp:
     17        (WebCore::MouseEvent::create):
     18        (WebCore::MouseEvent::MouseEvent):
     19        Require that all constructors that aren't invoked from JS always provide a movement delta.
     20
     21        * dom/MouseRelatedEvent.h:
     22        (WebCore::MouseRelatedEvent::movementX const):
     23        (WebCore::MouseRelatedEvent::movementY const):
     24        Expose these methods even when `!ENABLE(POINTER_LOCK)` so that they can be called without
     25        the callsite having to also have a `#if`.
     26
     27        * page/EventHandler.cpp:
     28        (WebCore::EventHandler::dispatchDragEvent):
     29        Pass along the movement delta even when `!ENABLE(POINTER_LOCK)`.
     30
    1312022-03-25  Chris Dumez  <cdumez@apple.com>
    232
  • trunk/Source/WebCore/dom/MouseEvent.cpp

    r288069 r291886  
    5757
    5858    return MouseEvent::create(eventType, canBubble, isCancelable, isComposed, event.timestamp().approximateMonotonicTime(), WTFMove(view), detail,
    59         event.globalPosition(), event.position(),
    60 #if ENABLE(POINTER_LOCK)
    61         event.movementDelta(),
    62 #else
    63         { },
    64 #endif
     59        event.globalPosition(), event.position(), event.movementDelta(),
    6560        event.modifiers(), event.button(), event.buttons(), relatedTarget, event.force(), event.syntheticClickType());
    6661}
     
    7873    unsigned short syntheticClickType, EventTarget* relatedTarget)
    7974{
    80     return adoptRef(*new MouseEvent(eventType, canBubble, isCancelable, isComposed, WTFMove(view), detail, { screenX, screenY }, { clientX, clientY }, modifiers, button, buttons, syntheticClickType, relatedTarget));
     75    return adoptRef(*new MouseEvent(eventType, canBubble, isCancelable, isComposed, WTFMove(view), detail, { screenX, screenY }, { clientX, clientY }, { }, modifiers, button, buttons, syntheticClickType, relatedTarget));
    8176}
    8277
     
    9893
    9994MouseEvent::MouseEvent(const AtomString& eventType, CanBubble canBubble, IsCancelable isCancelable, IsComposed isComposed,
    100     RefPtr<WindowProxy>&& view, int detail, const IntPoint& screenLocation, const IntPoint& clientLocation,
     95    RefPtr<WindowProxy>&& view, int detail, const IntPoint& screenLocation, const IntPoint& clientLocation, const IntPoint& movementDelta,
    10196    OptionSet<Modifier> modifiers, short button, unsigned short buttons, unsigned short syntheticClickType, EventTarget* relatedTarget)
    102     : MouseRelatedEvent(eventType, canBubble, isCancelable, isComposed, MonotonicTime::now(), WTFMove(view), detail, screenLocation, { }, { }, modifiers, IsSimulated::No)
     97    : MouseRelatedEvent(eventType, canBubble, isCancelable, isComposed, MonotonicTime::now(), WTFMove(view), detail, screenLocation, { }, movementDelta, modifiers, IsSimulated::No)
    10398    , m_button(button == -2 ? 0 : button)
    10499    , m_buttons(buttons)
  • trunk/Source/WebCore/dom/MouseEvent.h

    r269546 r291886  
    9494
    9595    MouseEvent(const AtomString& type, CanBubble, IsCancelable, IsComposed, RefPtr<WindowProxy>&&, int detail,
    96         const IntPoint& screenLocation, const IntPoint& clientLocation, OptionSet<Modifier>, short button, unsigned short buttons,
     96        const IntPoint& screenLocation, const IntPoint& clientLocation, const IntPoint& movementDelta, OptionSet<Modifier>, short button, unsigned short buttons,
    9797        unsigned short syntheticClickType, EventTarget* relatedTarget);
    9898
  • trunk/Source/WebCore/dom/MouseRelatedEvent.cpp

    r250060 r291886  
    4242    : UIEventWithKeyState(eventType, canBubble, isCancelable, isComposed, timestamp, WTFMove(view), detail, modifiers, isTrusted)
    4343    , m_screenLocation(screenLocation)
    44 #if ENABLE(POINTER_LOCK)
    4544    , m_movementDelta(movementDelta)
    46 #endif
    4745    , m_isSimulated(isSimulated == IsSimulated::Yes)
    4846{
    49 #if !ENABLE(POINTER_LOCK)
    50     UNUSED_PARAM(movementDelta);
    51 #endif
    5247    init(m_isSimulated, windowLocation);
    5348}
     
    6257    : UIEventWithKeyState(eventType, initializer)
    6358    , m_screenLocation(IntPoint(initializer.screenX, initializer.screenY))
    64 #if ENABLE(POINTER_LOCK)
    6559    , m_movementDelta(IntPoint(0, 0))
    66 #endif
    6760{
    6861    ASSERT_UNUSED(isTrusted, isTrusted == IsTrusted::No);
  • trunk/Source/WebCore/dom/MouseRelatedEvent.h

    r261457 r291886  
    4949    int clientX() const { return m_clientLocation.x(); }
    5050    int clientY() const { return m_clientLocation.y(); }
    51 #if ENABLE(POINTER_LOCK)
    5251    int movementX() const { return m_movementDelta.x(); }
    5352    int movementY() const { return m_movementDelta.y(); }
    54 #endif
     53
    5554    const LayoutPoint& clientLocation() const { return m_clientLocation; }
    5655    int layerX() override;
     
    9695    IntPoint m_screenLocation;
    9796    LayoutPoint m_clientLocation;
    98 #if ENABLE(POINTER_LOCK)
    9997    LayoutPoint m_movementDelta;
    100 #endif
    10198
    10299private:
  • trunk/Source/WebCore/dom/PointerEvent.cpp

    r273296 r291886  
    9393
    9494PointerEvent::PointerEvent(const AtomString& type, short button, const MouseEvent& mouseEvent, PointerID pointerId, const String& pointerType)
    95     : MouseEvent(type, typeCanBubble(type), typeIsCancelable(type), typeIsComposed(type), mouseEvent.view(), mouseEvent.detail(), mouseEvent.screenLocation(), { mouseEvent.clientX(), mouseEvent.clientY() }, mouseEvent.modifierKeys(), button, mouseEvent.buttons(), mouseEvent.syntheticClickType(), mouseEvent.relatedTarget())
     95    : MouseEvent(type, typeCanBubble(type), typeIsCancelable(type), typeIsComposed(type), mouseEvent.view(), mouseEvent.detail(), mouseEvent.screenLocation(), { mouseEvent.clientX(), mouseEvent.clientY() }, { mouseEvent.movementX(), mouseEvent.movementY() }, mouseEvent.modifierKeys(), button, mouseEvent.buttons(), mouseEvent.syntheticClickType(), mouseEvent.relatedTarget())
    9696    , m_pointerId(pointerId)
    9797    , m_pointerType(pointerType)
     
    101101
    102102PointerEvent::PointerEvent(const AtomString& type, PointerID pointerId, const String& pointerType, IsPrimary isPrimary)
    103     : MouseEvent(type, typeCanBubble(type), typeIsCancelable(type), typeIsComposed(type), nullptr, 0, { }, { }, { }, 0, 0, 0, nullptr)
     103    : MouseEvent(type, typeCanBubble(type), typeIsCancelable(type), typeIsComposed(type), nullptr, 0, { }, { }, { }, { }, 0, 0, 0, nullptr)
    104104    , m_pointerId(pointerId)
    105105    , m_pointerType(pointerType)
  • trunk/Source/WebCore/page/EventHandler.cpp

    r291807 r291886  
    22712271    auto dragEvent = DragEvent::create(eventType, Event::CanBubble::Yes, Event::IsCancelable::Yes, Event::IsComposed::Yes,
    22722272        event.timestamp().approximateMonotonicTime(), &m_frame.windowProxy(), 0,
    2273         event.globalPosition(), event.position(),
    2274 #if ENABLE(POINTER_LOCK)
    2275         event.movementDelta(),
    2276 #else
    2277         { },
    2278 #endif
     2273        event.globalPosition(), event.position(), event.movementDelta(),
    22792274        event.modifiers(), 0, 0, nullptr, event.force(), NoTap, &dataTransfer);
    22802275
  • trunk/Tools/ChangeLog

    r291882 r291886  
     12022-03-25  Devin Rousso  <drousso@apple.com>
     2
     3        `PointerEvent.movementX` always 0 (breaks https://noisecraft.app/)
     4        https://bugs.webkit.org/show_bug.cgi?id=220194
     5        <rdar://problem/72814440>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * DumpRenderTree/mac/EventSendingController.mm:
     10        (-[EventSendingController mouseMoveToX:Y:]):
     11        * WebKitTestRunner/mac/EventSenderProxy.mm:
     12        (WTR::EventSenderProxy::mouseMoveTo):
     13        On macOS, the screen's origin is the bottom-left corner, so we need to flip the `deltaY`.
     14
    1152022-03-25  J Pascoe  <j_pascoe@apple.com>
    216
  • trunk/Tools/DumpRenderTree/mac/EventSendingController.mm

    r285781 r291886  
    767767    CGEventRef cgEvent = [event CGEvent];
    768768    CGEventSetIntegerValueField(cgEvent, kCGMouseEventDeltaX, newMousePosition.x - lastMousePosition.x);
    769     CGEventSetIntegerValueField(cgEvent, kCGMouseEventDeltaY, newMousePosition.y - lastMousePosition.y);
     769    CGEventSetIntegerValueField(cgEvent, kCGMouseEventDeltaY, -1 * (newMousePosition.y - lastMousePosition.y));
    770770    event = retainPtr([NSEvent eventWithCGEvent:cgEvent]);
    771771    lastMousePosition = newMousePosition;
  • trunk/Tools/WebKitTestRunner/mac/EventSenderProxy.mm

    r290757 r291886  
    602602    CGEventRef cgEvent = event.CGEvent;
    603603    CGEventSetIntegerValueField(cgEvent, kCGMouseEventDeltaX, newMousePosition.x - m_position.x);
    604     CGEventSetIntegerValueField(cgEvent, kCGMouseEventDeltaY, newMousePosition.y - m_position.y);
     604    CGEventSetIntegerValueField(cgEvent, kCGMouseEventDeltaY, -1 * (newMousePosition.y - m_position.y));
    605605    event = [NSEvent eventWithCGEvent:cgEvent];
    606606    m_position.x = newMousePosition.x;
Note: See TracChangeset for help on using the changeset viewer.