⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 287593 in webkit


Ignore:
Timestamp:
Jan 4, 2022, 3:48:08 PM (5 years ago)
Author:
Simon Fraser
Message:

"canceled" wheel events to non-zero deltas cause scrolling jumps in PDFs and CodeMirror
​https://bugs.webkit.org/show_bug.cgi?id=234825

Reviewed by Tim Horton.

Source/WebKit:

On some macOS versions, interrupting a momentum scroll via a two-finger tap on the trackpad can
result in the following sequence of wheel events: momentumPhase:end -> phase:mayBegin -> phase:cancelled,
and that last canceled event can have non-zero deltas (rdar://86653042).

Protect against this by zeroing out the deltas for cancelled wheel events when constructing WebEvents
from NSEvents. Code in Element::dispatchWheelEvent() ensures that we don't dispatch wheel events with
zero deltas to script, fixing CodeMirror.

Jumps only affected PDFs (and scrollable selects) because those are the code paths that don't go via
ScrollingEffectsController, which already ignores Cancelled events.

Test: fast/scrolling/mac/canceled-event-with-non-zero-deltas.html

  • Shared/mac/WebEventFactory.mm:

(WebKit::WebEventFactory::createWebWheelEvent):

LayoutTests:

  • fast/scrolling/mac/canceled-event-with-non-zero-deltas-expected.txt: Added.
  • fast/scrolling/mac/canceled-event-with-non-zero-deltas.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r287590 r287593  
     12022-01-04  Simon Fraser  <simon.fraser@apple.com>
     2
     3        "canceled" wheel events to non-zero deltas cause scrolling jumps in PDFs and CodeMirror
     4        https://bugs.webkit.org/show_bug.cgi?id=234825
     5
     6        Reviewed by Tim Horton.
     7
     8        * fast/scrolling/mac/canceled-event-with-non-zero-deltas-expected.txt: Added.
     9        * fast/scrolling/mac/canceled-event-with-non-zero-deltas.html: Added.
     10
    1112022-01-04  Devin Rousso  <drousso@apple.com>
    212
  • trunk/Source/WebKit/ChangeLog

    r287592 r287593  
     12022-01-04  Simon Fraser  <simon.fraser@apple.com>
     2
     3        "canceled" wheel events to non-zero deltas cause scrolling jumps in PDFs and CodeMirror
     4        https://bugs.webkit.org/show_bug.cgi?id=234825
     5
     6        Reviewed by Tim Horton.
     7
     8        On some macOS versions, interrupting a momentum scroll via a two-finger tap on the trackpad can
     9        result in the following sequence of wheel events: momentumPhase:end -> phase:mayBegin -> phase:cancelled,
     10        and that last canceled event can have non-zero deltas (rdar://86653042).
     11
     12        Protect against this by zeroing out the deltas for cancelled wheel events when constructing WebEvents
     13        from NSEvents. Code in Element::dispatchWheelEvent() ensures that we don't dispatch wheel events with
     14        zero deltas to script, fixing CodeMirror.
     15
     16        Jumps only affected PDFs (and scrollable selects) because those are the code paths that don't go via
     17        ScrollingEffectsController, which already ignores Cancelled events.
     18
     19        Test: fast/scrolling/mac/canceled-event-with-non-zero-deltas.html
     20
     21        * Shared/mac/WebEventFactory.mm:
     22        (WebKit::WebEventFactory::createWebWheelEvent):
     23
    1242022-01-04  Wenson Hsieh  <wenson_hsieh@apple.com>
    225
  • trunk/Source/WebKit/Shared/mac/WebEventFactory.mm

    r286270 r287593  
    439439    auto ioHIDEventWallTime = WebCore::eventTimeStampSince1970(ioHIDEventTimestamp);
    440440
     441    if (phase == WebWheelEvent::PhaseCancelled) {
     442        deltaX = 0;
     443        deltaY = 0;
     444        wheelTicksX = 0;
     445        wheelTicksY = 0;
     446        unacceleratedScrollingDelta = { };
     447        rawPlatformDelta = std::nullopt;
     448    }
     449
    441450    return WebWheelEvent(WebEvent::Wheel, WebCore::IntPoint(position), WebCore::IntPoint(globalPosition), WebCore::FloatSize(deltaX, deltaY), WebCore::FloatSize(wheelTicksX, wheelTicksY),
    442451        granularity, directionInvertedFromDevice, phase, momentumPhase, hasPreciseScrollingDeltas,
Note: See TracChangeset for help on using the changeset viewer.