Skip to content

fix(scroll): a wheel no longer traps on a scroll region inside another - #1123

Merged
Hona merged 1 commit into
devfrom
scroll-wheel-route
Nov 17, 2026
Merged

Hona merged 1 commit into
devfrom
scroll-wheel-route

Conversation

@Hona

@Hona Hona commented Nov 17, 2026

Copy link
Copy Markdown
Member

A wheel over a scroll region inside another one could get stuck: after the inner region reached its end, later notches moved nothing, and the outer region never moved. In the app this trapped the wheel on a Shell row's console, a failed command's full-text box and the script box in the View code dialog.

A run of wheel deltas now starts on the innermost viewport that still has room in its direction, and stays with that viewport until the wheel rests for 0.5 s or the pointer moves 10 pt away. The next run moves the viewport around it. This is Chromium's wheel latching (mouse_wheel_phase_handler.cc: kDefaultMouseWheelLatchingTransaction, kWheelLatchingSlopRegion). There is no glide in this change; notches jump as they do today.

Evidence

Check Result
macOS, whole suite at 8be66e36 3,088 passed, 1 failed: the known order-dependent scroll_children test, which also fails on dev
Windows, whole suite at 8be66e36 2,841 passed, 18 failed: all 18 also fail on dev
Tests added or changed None
Shell row's console, real window, official beside dev before and after Before: trapped after the first notch. After: as official
Failed command's full-text box; View code script box (headless) Before: trapped. After: the outer region moves on the next run

Base: 3468f3a3. It merges cleanly onto 47195cfa.

…ort, so a nested region never traps the wheel

A vertical wheel or trackpad delta used to scroll the innermost viewport under the pointer whether
or not it could move that way, so a region inside a page (a shell's output in a timeline) that
reached its end swallowed every later delta, and the page around it never moved. Now a run of
deltas starts on the innermost viewport with room in its direction, and keeps to that viewport
while each delta comes within 0.5 s of the last and the pointer stays within 10 pt of where the
run began, as Chromium latches a wheel's scroll (mouse_wheel_phase_handler.cc; cc scrolls only the
latched scroller). A region that reaches its end mid-run takes the rest of that run; the next run
moves the viewport around it. A new trackpad touch, or a lost pointer, starts a new run.
Copilot AI balanced review requested due to automatic review settings November 17, 2026 10:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@Hona
Hona merged commit 3d037b4 into dev Nov 17, 2026
1 check passed
Hona added a commit that referenced this pull request Nov 17, 2026
Whole notches of a mouse wheel (`WheelEvent::notch`, whole-line deltas on Windows) that no
`on_wheel` handler takes ease to where they send a viewport on Chromium's mouse-wheel curve
(cc/animation/scroll_offset_animation_curve.cc, kInverseDelta): cubic-bezier(0.42, 0, 0.58, 1)
over 200 ms up to 120 device pixels, 100 ms from 480. A notch that comes while it moves sends it
on from where it is with the speed it had (UpdateTarget, EaseInOutWithInitialSlope and the 2.5x
velocity bound), so stacked notches run as one motion and a notch back turns it round. The ease
is `ScrollMode::Wheel` on the vertical axis and `XMotion::Wheel` on the horizontal one, whose
velocity and optional glide are now one `XMotion`. It steps at every frame; a hand, a key, a
fling or `Tx::scroll_to` take the viewport over at once; reduced motion, or
`Runtime::set_wheel_glide(false)`, lands it at once. macOS, Linux, precise trackpads and
free-spinning wheels move 1:1 as before.

A run of notches picks and keeps its viewport as #1123's deltas do (`Runtime::wheel_run`); a
viewport that is gliding counts its room from where its ease heads, so a run that begins while
one glides to its end starts on the viewport around it.
Hona added a commit that referenced this pull request Nov 17, 2026
A run of vertical wheel deltas ended when the window lost the pointer or focus (#1123). Chromium's
latch never hears a mouse leave: MouseWheelPhaseHandler ends it only when the wheel rests (500 ms),
the pointer is outside the slop region (10 px) from where it began, the modifiers change, or the
direction turns after a first event that scrolled nothing; RenderWidgetHostViewEventHandler sends
kMouseExited only to the page. So a pointer that leaves the window mid-run and comes back near where
the run began keeps it on its region, as in official (driven: official's Shell console keeps a
burst while the page hears a mouseleave after every notch). A new trackpad touch still starts a new
run; momentum keeps it.
Hona added a commit that referenced this pull request Nov 17, 2026
…hromium chains a scroll (#1137)

* Scroll: a wheel passes only to a region around the one under it, as Chromium chains a scroll

#1123 started a wheel run on the innermost viewport under the pointer with room in its direction,
searching every viewport under the point. A viewport that only lies beneath one (the timeline under
the open / command list, which is drawn over it but is not inside it) took the wheel once the list
reached its end, so the timeline scrolled behind an open menu. Chromium chains a scroll from the
scroller under the pointer up its own ancestors; official's list (composer-suggestions) has none, and
three notches at either end of it move nothing. Now the run starts on the innermost viewport under
the pointer or the nearest of its scroll ancestors with room. The Shell console, a failed command's
text and the View code script box are inside the region they hand on to, so they hand on as before.

* Scroll: a wheel run starts where a gesture does, on the topmost hit

The chain up the ancestors started on the last viewport in tree order that contains the point.
That is not what is painted on top there: a menu with no scroll view of its own over the timeline
(every in-window menu on Windows, `popover::MENU`) let the timeline behind it scroll, and the peeked
sidebar, raised over the timeline but before it in the tree, lost the wheel to it. The start is
now `Runtime::chain_start`, shared with `gesture_chain`: the topmost hit (`hits`, in paint order),
or a scroll view inside it; with no hit, the scroll view there. on_wheel routing and the scroll
target now begin at the same element.

* Scroll: a wheel starts on the topmost of what takes input, scrolls or paints there

`chain_start` picked the topmost interactive hit in paint order, but the scroll view only as the
last in tree order, and `hits` holds only what takes input. Over a raised list's section header
or the gap between its rows, the run started on a hit beneath it and the timeline scrolled. Now
the paint pass also lists, in the same order, every visible scroll view and every painted surface
without a handler (`wheel_hits`), and a run starts at the topmost entry containing the point; a
row inside a list paints after the list, so it still wins, and a box that paints nothing (a
full-window layer) is never one. `find_map` skips an entry whose node is already gone. The start
is found once per delta and handed on to the scroll (`WheelStart`).

* Scroll: the wheel's record survives paint reuse, and holds only what is drawn over others

`wheel_hits` was filled by `register_node_hits`, which a release build's paint skips for every
subtree it reuses, and `keep` restored `hits` and the other hit lists but not it: after a hover
repaint, a wheel over a reused message's console box or a reused popover started on whatever lay
beneath. It is now kept as `hits` is: a range in each `PaintRec`, swapped and twinned in the
swap, opened, closed, copied and shifted with a reused subtree, and compared in a debug build's
check. And of what takes no input, it now holds only the roots of what is drawn over others (an
anchored overlay, a `raise()`d panel, a sticky element), not every filled box: a box without a
handler elsewhere lets the wheel through, as one with `pointer-events: none` does.
Hona added a commit that referenced this pull request Nov 17, 2026
Whole notches of a mouse wheel (`WheelEvent::notch`, whole-line deltas on Windows) that no
`on_wheel` handler takes ease to where they send a viewport on Chromium's mouse-wheel curve
(cc/animation/scroll_offset_animation_curve.cc, kInverseDelta): cubic-bezier(0.42, 0, 0.58, 1)
over 200 ms up to 120 device pixels, 100 ms from 480. A notch that comes while it moves sends it
on from where it is with the speed it had (UpdateTarget, EaseInOutWithInitialSlope and the 2.5x
velocity bound), so stacked notches run as one motion and a notch back turns it round. The ease
is `ScrollMode::Wheel` on the vertical axis and `XMotion::Wheel` on the horizontal one, whose
velocity and optional glide are now one `XMotion`. It steps at every frame; a hand, a key, a
fling or `Tx::scroll_to` take the viewport over at once; reduced motion, or
`Runtime::set_wheel_glide(false)`, lands it at once. macOS, Linux, precise trackpads and
free-spinning wheels move 1:1 as before.

A run of notches picks and keeps its viewport as #1123's deltas do (`Runtime::wheel_run`); a
viewport that is gliding counts its room from where its ease heads, so a run that begins while
one glides to its end starts on the viewport around it.
Hona added a commit that referenced this pull request Nov 18, 2026
…e grid (#1150)

* Scroll: a notched mouse wheel glides as Chromium's does on Windows

Whole notches of a mouse wheel (`WheelEvent::notch`, whole-line deltas on Windows) that no
`on_wheel` handler takes ease to where they send a viewport on Chromium's mouse-wheel curve
(cc/animation/scroll_offset_animation_curve.cc, kInverseDelta): cubic-bezier(0.42, 0, 0.58, 1)
over 200 ms up to 120 device pixels, 100 ms from 480. A notch that comes while it moves sends it
on from where it is with the speed it had (UpdateTarget, EaseInOutWithInitialSlope and the 2.5x
velocity bound), so stacked notches run as one motion and a notch back turns it round. The ease
is `ScrollMode::Wheel` on the vertical axis and `XMotion::Wheel` on the horizontal one, whose
velocity and optional glide are now one `XMotion`. It steps at every frame; a hand, a key, a
fling or `Tx::scroll_to` take the viewport over at once; reduced motion, or
`Runtime::set_wheel_glide(false)`, lands it at once. macOS, Linux, precise trackpads and
free-spinning wheels move 1:1 as before.

A run of notches picks and keeps its viewport as #1123's deltas do (`Runtime::wheel_run`); a
viewport that is gliding counts its room from where its ease heads, so a run that begins while
one glides to its end starts on the viewport around it.

* Scroll: a wheel's ease lands on whole device pixels, and a new notch takes no catch-up time

As Chromium's scroll offsets are (measured at 1.875x: every offset of a notch's ease is a whole
device pixel), so everything in the viewport moves by the same whole pixels each frame and draws
as it did instead of at a new fraction of a pixel every frame. The time a frame charges to motion
that was already running (`frame::clock::split`'s catch-up) no longer advances an ease a notch
started or retargeted since the last frame.

* Scroll: a wheel's ease moves with its viewport when rows above measure or an anchor holds

What moved the offset under a running ease since it last stepped (rows mounting and measuring
above the reader, content arriving above, an anchor keeping what's on screen) now moves the
ease's start and end by the same amount, as Chromium's ApplyAdjustment does, so the next frame
doesn't pull the content back by what the measurement moved.

* Scroll: a wheel's ease keeps to a list's end, starts on its first frame, and stays put when sent back

The two reads of #1150, together:

- An extra notch at an end no longer starts an empty ease that lets go of a streaming reply: a
  notch with no ease running starts from a finished curve (`WheelCurve::still`), and one that
  sends it nowhere new changes no mode.
- An ease sent to the end of a viewport that follows its bottom remembers it (`to_end`): as the
  end grows under it (a reply streaming) it takes its target with the end, lands there and pins.
- Within a device pixel of the end, the end wins over the device grid (`on_grid_or_end`), so the
  room test hands the next run on and the pin threshold holds at any zoom.
- A notch that sends a running ease back to where it is (a flick back before the next frame)
  lands it where it is, as Chromium's stays put, rather than finishing the ease before it.
- A retarget of a moving ease is the same motion going on and keeps the frame's catch-up (it
  was a half step at 60 Hz after each stacked notch); a zero step doesn't count as a frame; and an
  ease from rest starts at its first frame, which draws where it was, as Chromium's does.
- A notch or not is decided by a run's first delta and kept for the run (`DeltaKind`), so a fast
  touchpad swipe's whole-line delta doesn't start an ease the next fraction throws away.
- Linux eases too: winit gives a wheel's detents there as whole lines (X11 buttons 4-7 and
  XInput2's position over its increment, Wayland's discrete values) and a touchpad's as fractions
  or pixels.
- A `scroll_to` glide that starts during an ease keeps the ease's speed, and an app's keep (rows
  above measured, an anchor holding what's on screen) moves the ease with it rather than ending it,
  as Chromium's `ApplyAdjustment` does.

* Scroll: a wheel's ease pins the frame it reaches a following list's end

The first read's confirmation of #1150 at 5e4e46b:

- An ease sent to the end of a viewport that follows its bottom pins on the frame it gets there.
  The end growing under it restarts its segment every frame a reply grows, so waiting for the
  curve to finish left the list trailing the end until the stream paused.
- A retarget keeps whether its ease's first frame has come: two notches before that frame still
  start the ease on it, rather than the second's retarget charging that frame's catch-up.
- A run of wheel deltas is notched only while every delta is whole: a touchpad swipe whose first
  delta was exactly a line is precise from its first fraction on.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants