Open Bug 1520121 Opened 6 years ago Updated 3 years ago

Confusion between logical and absolute scroll position for session history?

Categories

(Core :: Layout: Scrolling and Overflow, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: JanH, Unassigned)

Details

nsGfxScrollFrame normally uses GetLogicalVisualViewportOffset() when retrieving the current scroll position while dealing with session history.
Conversely, when restoring the scroll position we're transforming it back into an absolute one [1] before calling scrollTo().

There is one exception, though: If we're currently in a smooth scroll, the save logic just stores mDestination directly without turning it into a logical scroll position [2]. I suspect that this isn't correct.

[1] https://searchfox.org/mozilla-central/rev/b29663c6c9c61b0bf29e8add490cbd6bad293a67/layout/generic/nsGfxScrollFrame.cpp#4339
[2] https://searchfox.org/mozilla-central/rev/b29663c6c9c61b0bf29e8add490cbd6bad293a67/layout/generic/nsGfxScrollFrame.cpp#6149

And thoughts, Botond?

Flags: needinfo?(botond)
Priority: -- → P3

Jan's assessment seems accurate to me. It's likely an oversight.

One technique to avoid issues like this, that we've used with success elsewhere, is to represent logical vs. physical scroll offsets as different types. We have infrastructure to support this with out PointTyped and IntPointTyped classes [1], which allow encoding a "label" (Units) in the type of a point.

[1] https://searchfox.org/mozilla-central/rev/5c8ea961d04767db723a0a15e3a8f7fbca154129/gfx/2d/Point.h#123

Flags: needinfo?(botond)
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.