summaryrefslogtreecommitdiff
path: root/layout/base/nsPresShell.cpp
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2022-09-30 12:24:19 +0000
committerMoonchild <moonchild@palemoon.org>2022-09-30 12:24:19 +0000
commitbdc924d25ee6d0bbe6c780c1d88b60db573562e7 (patch)
tree426c983ca8bb4dd32d4f8db93625a9a07e11367d /layout/base/nsPresShell.cpp
parentb83dd4e5e8b95f61fa2c25b1635793f919e4f101 (diff)
downloaduxp-scroll-anchoring-wip.tar.gz
WIP: basic scroll-anchoring attempt.scroll-anchoring-wip
This is incomplete and won't build due to prerequisites.
Diffstat (limited to 'layout/base/nsPresShell.cpp')
-rw-r--r--layout/base/nsPresShell.cpp32
1 files changed, 27 insertions, 5 deletions
diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp
index 23876cc112..0fc84d736c 100644
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -1225,6 +1225,7 @@ PresShell::Destroy()
}
mFramesToDirty.Clear();
+ mScrollAnchorAdjustments.Clear();
if (mViewManager) {
// Clear the view manager's weak pointer back to |this| in case it
@@ -2049,6 +2050,11 @@ PresShell::NotifyDestroyingFrame(nsIFrame* aFrame)
}
mFramesToDirty.RemoveEntry(aFrame);
+
+ nsIScrollableFrame* scrollableFrame = do_QueryFrame(aFrame);
+ if (scrollableFrame) {
+ mScrollAnchorAdjustments.RemoveEntry(scrollableFrame);
+ }
} else {
// We must delete this property in situ so that its destructor removes the
// frame from FrameLayerBuilder::DisplayItemData::mFrameList -- otherwise
@@ -2584,6 +2590,12 @@ PresShell::VerifyHasDirtyRootAncestor(nsIFrame* aFrame)
#endif
void
+PresShell::ScrollableFrameNeedsAnchorAdjustment(nsIScrollableFrame* aFrame)
+{
+ mScrollAnchorAdjustments.PutEntry(aFrame);
+}
+
+void
PresShell::FrameNeedsReflow(nsIFrame *aFrame, IntrinsicDirty aIntrinsicDirty,
nsFrameState aBitToAdd,
ReflowRootHandling aRootHandling)
@@ -4106,12 +4118,21 @@ PresShell::FlushPendingNotifications(mozilla::ChangesToFlush aFlush)
didLayoutFlush = true;
mFrameConstructor->RecalcQuotesAndCounters();
viewManager->FlushDelayedResize(true);
- if (ProcessReflowCommands(flushType < Flush_Layout) && mContentToScrollTo) {
- // We didn't get interrupted. Go ahead and scroll to our content
- DoScrollContentIntoView();
+ if (ProcessReflowCommands(flushType < Flush_Layout)) {
+ // Apply scroll offset updates for scroll anchors.
+ for (auto iter = mScrollAnchorAdjustments.Iter(); !iter.Done(); iter.Next()) {
+ nsIScrollableFrame* frame = iter.Get()->GetKey();
+ frame->ApplyScrollAnchorOffsetAdjustment();
+ }
+ mScrollAnchorAdjustments.Clear();
+
if (mContentToScrollTo) {
- mContentToScrollTo->DeleteProperty(nsGkAtoms::scrolling);
- mContentToScrollTo = nullptr;
+ // We didn't get interrupted; go ahead and scroll to our content.
+ DoScrollContentIntoView();
+ if (mContentToScrollTo) {
+ mContentToScrollTo->DeleteProperty(nsGkAtoms::scrolling);
+ mContentToScrollTo = nullptr;
+ }
}
}
}
@@ -10833,6 +10854,7 @@ PresShell::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
}
*aPresShellSize += mApproximatelyVisibleFrames.ShallowSizeOfExcludingThis(aMallocSizeOf);
*aPresShellSize += mFramesToDirty.ShallowSizeOfExcludingThis(aMallocSizeOf);
+ *aPresShellSize += mScrollAnchorAdjustments.ShallowSizeOfExcludingThis(aMallocSizeOf);
*aPresShellSize += aArenaObjectsSize->mOther;
if (nsStyleSet* styleSet = StyleSet()->GetAsGecko()) {