Clean up representation of scroll offsets in FrameMetrics and RepaintRequest
Categories
(Core :: Panning and Zooming, enhancement, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox81 | --- | fixed |
People
(Reporter: botond, Assigned: botond)
References
Details
Attachments
(14 files, 1 obsolete file)
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review |
As a follow-up to bug 1518584, I would like to clean up the representation of scroll offsets in FrameMetrics
and RepaintRequest
a bit more.
The general idea is:
- For the RCD-RSF, we will always store the layout scroll offset in
mLayoutViewport.TopLeft()
, and the visual scroll offset inmScrollOffset
. - For other scroll frames, which don't have a distinction between the two viewports, the scroll offset will be stored in
mScrollOffset
.mLayoutViewport
for such frames will not be used (in fact, I will make it aMaybe
). - Calls to
GetScrollOffset()
will be audited and replaced with calls to eitherGetLayoutScrollOffset()
orGetVisualScrollOffset()
, depending on which one the caller wants for the RCD-RSF. Likewise for setters. FrameMetrics::mVisualViewportOffset
, added in bug 1507279, can be removed.
Assignee | ||
Updated•6 years ago
|
Comment 1•4 years ago
|
||
In general the changes here seem reasonable to me, although I would prefer not making mLayoutViewport a Maybe, but instead just populating it with the rect that would be equivalent to the layout viewport, but for subframes (origin at mScrollOffset, size is composition bounds). This should reduce the specialness of the RCD metrics and reduce conditions at use sites.
Assignee | ||
Comment 2•4 years ago
|
||
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #1)
I would prefer not making mLayoutViewport a Maybe, but instead just populating it with the rect that would be equivalent to the layout viewport, but for subframes (origin at mScrollOffset, size is composition bounds). This should reduce the specialness of the RCD metrics and reduce conditions at use sites.
I suppose we could do that, although I feel like this just trades one piece of complexity (having to check whether mLayoutViewport
is populated or not in some places) with another (having to make sure mLayoutViewport.TopLeft()
is always in sync with mScrollOffset
for subframes).
Assignee | ||
Comment 3•4 years ago
|
||
Upon further thought, making mLayoutViewport
a Maybe
is not really consistent with the way we're current modelling things. We're currently modelling subframes as having a layout viewport that coincides with (i.e. tightly fits) the visual viewport, and is async-scrolled whenever the visual viewport is. (For example, in GetCurrentAsyncTransform()
, where the async transform is split into a "visual" component that represents the async scrolling of the visual viewport relative to the layout viewport, and a "layout" component that represents the async scrolling of the layout viewport itself, for subframes everything currently goes into the "layout" component.) It might be cleaner to just keep that model for the time being.
Assignee | ||
Comment 4•4 years ago
|
||
(And, while this is not a primary consideration, this is also the model that's more forward-compatible with potential things like the "root scroller" proposal or subframe zooming in the future.)
Assignee | ||
Comment 5•4 years ago
|
||
(In reply to Botond Ballo [:botond] from comment #3)
We're currently modelling subframes as having a layout viewport that coincides with (i.e. tightly fits) the visual viewport, and is async-scrolled whenever the visual viewport is. (For example, in
GetCurrentAsyncTransform()
, where the async transform is split into a "visual" component that represents the async scrolling of the visual viewport relative to the layout viewport, and a "layout" component that represents the async scrolling of the layout viewport itself, for subframes everything currently goes into the "layout" component.)
It turns out I was mistaken about this. Subframes' mLayoutViewport
is not async-scrolled with the visual viewport, due to the early-exit here.
In fact, given that the only other place where APZ's copy of mLayoutViewport
is updated is here, and that only happens under certain conditions (the layout viewport's size changed, or there was a main thread scroll offset update) -- subframes' mLayoutViewport
offset currently stores something like "an arbitrarily stale copy of the main-thread scroll offset" (which gets subtracted from the visual component of the async translation and added back as part of the layout component, making the staleness ok). It's certainly not doing anything useful.
Assignee | ||
Comment 6•4 years ago
|
||
Likewise for RepaintRequest (which only has getters).
Assignee | ||
Comment 7•4 years ago
|
||
This reduces the need for conditional logic, and clarifies the model that
AsyncPanZoomController::mFrameMetrics stores the up-to-date async-scrolled
versions of the visual and layout viewport offsets, while
mLastContentPaintMetrics stores the versions as of the last paint.
Depends on D87153
Assignee | ||
Comment 8•4 years ago
|
||
Depends on D87154
Assignee | ||
Comment 9•4 years ago
|
||
Take advantage of them in CalculateRectToZoomTo(), where we also fix
a previously-incorrect usage.
Depends on D87155
Assignee | ||
Comment 10•4 years ago
|
||
In a later patch, the main thread will start populating mScrollOffset
with its snapshot of the visual scroll offset, so to preserve the
meaning of the assertion, we'd have to call GetLayoutScrollOffset(),
making the assertion tautological.
Depends on D87156
Assignee | ||
Comment 11•4 years ago
•
|
||
Likewise for RepaintRequest, and direct usages of mScrollOffset
inside FrameMetrics.
The general idea is:
-
APZ's copy of the FrameMetrics stores the visual scroll offset,
so calls to GetScrollOffset() on it are replaced with
GetVisualScrollOffset() -
The layer tree's copy of the frame metrics (and copies derived
from that like mLastContentPaintMetrics) currently stores the
layout scroll offset, so calls to GetScrollOffset() on those
are replaced with GetLayoutScrollOffset().
The latter changes are particularly important, as they enable us
to modify the layer tree's copy to store (a main thread snapshot
of) the visual offset in mScrollOffset in a future patch.
This patch intends no functional changes. In the cases where we
change GetScrollOffset() to GetLayoutScrollOffset(), mScrollOffset
and mLayoutViewport.TopLeft() should already be storing the same
thing.
The patch identifies a few usages as suspicious but leaves them
functionally unchanged for now.
A few problematic usages of GetScrollOffset() remain, which will
require other fixes to remove.
Depends on D87157
Assignee | ||
Comment 12•4 years ago
|
||
Depends on D87159
Assignee | ||
Comment 13•4 years ago
|
||
It is now redundant with mScrollOffset which always stores the
visual scroll offset.
Depends on D87160
Assignee | ||
Comment 14•4 years ago
|
||
Based on the usage of this in GeckoView, it wants the visual scroll
offset. Now that we populate the visual scroll offset into the
layer tree FrameMetrics as well, this works correctly, but make it
explicit by using GetVisualScrollOffset().
Depends on D87162
Assignee | ||
Comment 15•4 years ago
|
||
Depends on D87163
Assignee | ||
Comment 16•4 years ago
|
||
All callers have now been transitioned to the more specific layout
or visual accessors.
Depends on D87164
Assignee | ||
Comment 17•4 years ago
|
||
Depends on D87165
Assignee | ||
Comment 18•4 years ago
|
||
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #1)
In general the changes here seem reasonable to me, although I would prefer not making mLayoutViewport a Maybe, but instead just populating it with the rect that would be equivalent to the layout viewport, but for subframes (origin at mScrollOffset, size is composition bounds). This should reduce the specialness of the RCD metrics and reduce conditions at use sites.
I did end up axing the Maybe, and I do think on balance it's nicer this way. Thanks for the suggestion!
Assignee | ||
Comment 19•4 years ago
|
||
Depends on D87166
Assignee | ||
Comment 20•4 years ago
|
||
See discussion at https://phabricator.services.mozilla.com/D87159#inline-496508
Depends on D87368
Assignee | ||
Comment 21•4 years ago
|
||
It does not need to be in APZUtils.h, and being there means long sad
recompiles if you change it since APZUtils.h is included everywhere.
Depends on D87369
Comment 22•4 years ago
|
||
Comment on attachment 9170563 [details]
Bug 1519285 - Move ExpectedGeckoMetrics to AsyncPanZoomController.h r=kats
Revision D87390 was moved to bug 1659642. Setting attachment 9170563 [details] to obsolete.
Comment 23•4 years ago
|
||
Comment 24•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/3866a68bf1f5
https://hg.mozilla.org/mozilla-central/rev/b6a81c4980db
https://hg.mozilla.org/mozilla-central/rev/b709eba05123
https://hg.mozilla.org/mozilla-central/rev/1a1f89a70ef5
https://hg.mozilla.org/mozilla-central/rev/38844975afd5
https://hg.mozilla.org/mozilla-central/rev/a5a7e4a3b268
https://hg.mozilla.org/mozilla-central/rev/6f91e577a1bd
https://hg.mozilla.org/mozilla-central/rev/9953c2c51153
https://hg.mozilla.org/mozilla-central/rev/0645db46bd9d
https://hg.mozilla.org/mozilla-central/rev/151eb78c5741
https://hg.mozilla.org/mozilla-central/rev/a61257563d2d
https://hg.mozilla.org/mozilla-central/rev/3073517e097d
https://hg.mozilla.org/mozilla-central/rev/371f36d920b6
https://hg.mozilla.org/mozilla-central/rev/603ca1324860
Description
•