summaryrefslogtreecommitdiff
path: root/layout/generic/nsFrame.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/generic/nsFrame.cpp
parentb83dd4e5e8b95f61fa2c25b1635793f919e4f101 (diff)
downloaduxp-bdc924d25ee6d0bbe6c780c1d88b60db573562e7.tar.gz
WIP: basic scroll-anchoring attempt.scroll-anchoring-wip
This is incomplete and won't build due to prerequisites.
Diffstat (limited to 'layout/generic/nsFrame.cpp')
-rw-r--r--layout/generic/nsFrame.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp
index 43ad970890..5524b726de 100644
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -688,6 +688,20 @@ nsFrame::DestroyFrom(nsIFrame* aDestructRoot)
}
}
+ if (HasAnyStateBits(NS_FRAME_IS_SCROLL_ANCHOR)) {
+ // Find the nearest scroll frame, that's the one that marked us as a
+ // scroll anchor
+ nsIFrame* currentFrame = this;
+ while (currentFrame) {
+ nsIScrollableFrame* scrollTarget = currentFrame->GetScrollTargetFrame();
+ if (scrollTarget) {
+ scrollTarget->ScrollAnchorWillDestroy();
+ break;
+ }
+ currentFrame = currentFrame->GetParent();
+ }
+ }
+
if (HasCSSAnimations() || HasCSSTransitions() ||
EffectSet::GetEffectSet(this)) {
// If no new frame for this element is created by the end of the
@@ -814,6 +828,35 @@ AddAndRemoveImageAssociations(nsFrame* aFrame,
}
}
+void
+nsIFrame::MaybeNotifyScrollAnchor()
+{
+ bool isScrollAnchor = HasAnyStateBits(NS_FRAME_IS_SCROLL_ANCHOR);
+ bool containsScrollAnchor = HasAnyStateBits(NS_FRAME_CONTAINS_SCROLL_ANCHOR);
+
+ if (isScrollAnchor) {
+ printf_stderr("nsIFrame(%p)::MaybeNotifyScrollAnchor scroll anchor offset changed, queueing adjustment.\n", this);
+ }
+ if (containsScrollAnchor) {
+ printf_stderr("nsIFrame(%p)::MaybeNotifyScrollAnchor offset for scroll anchor container changed, queueing adjustment.\n", this);
+ }
+ MOZ_ASSERT(!(isScrollAnchor && containsScrollAnchor));
+
+ if (isScrollAnchor || containsScrollAnchor) {
+ // Find the nearest scroll frame, that's the one that marked us as a
+ // scroll anchor
+ nsIFrame* currentFrame = this;
+ while (currentFrame) {
+ nsIScrollableFrame* scrollTarget = currentFrame->GetScrollTargetFrame();
+ if (scrollTarget) {
+ PresShell().ScrollableFrameNeedsAnchorAdjustment(scrollTarget);
+ break;
+ }
+ currentFrame = currentFrame->GetParent();
+ }
+ }
+}
+
// Subclass hook for style post processing
/* virtual */ void
nsFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
@@ -2902,6 +2945,13 @@ nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder,
aBuilder->AdjustWindowDraggingRegion(child);
child->BuildDisplayList(aBuilder, aLists);
+/* // Visualise scroll anchor
+ if (child->HasAnyStateBits(NS_FRAME_IS_SCROLL_ANCHOR)) {
+ nsRect bounds = child->GetContentRectRelativeToSelf() +
+ aBuilder->ToReferenceFrame(child);
+ list.AppendToTop(MakeDisplayItem<nsDisplaySolidColor>(aBuilder, child, bounds, NS_RGBA(255, 0, 0, 55)));
+ }
+ // */
aBuilder->DisplayCaret(child, aLists.Content());
#ifdef DEBUG
DisplayDebugBorders(aBuilder, child, aLists);
@@ -2916,6 +2966,13 @@ nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder,
nsDisplayListCollection pseudoStack(aBuilder);
aBuilder->AdjustWindowDraggingRegion(child);
child->BuildDisplayList(aBuilder, pseudoStack);
+/* // Visualise scroll anchor
+ if (child->HasAnyStateBits(NS_FRAME_IS_SCROLL_ANCHOR)) {
+ nsRect bounds = child->GetContentRectRelativeToSelf() +
+ aBuilder->ToReferenceFrame(child);
+ list.AppendToTop(MakeDisplayItem<nsDisplaySolidColor>(aBuilder, child, bounds, NS_RGBA(255, 0, 0, 55)));
+ }
+ // */
aBuilder->DisplayCaret(child, pseudoStack.Content());
list.AppendToTop(pseudoStack.BorderBackground());