From fb92ee5f648f07ee525bdce15a6590d02bdfd770 Mon Sep 17 00:00:00 2001 From: Ting-Yu Lin Date: Wed, 15 May 2024 17:50:48 +0000 Subject: [PATCH] Bug 1824877 Part 2 - Rename nsHTMLScrollFrame to mozilla::ScrollContainerFrame. r=dholbert Also, change the ScrollContainerFrame::GetFrameName() to return "ScrollContainer" instead of "HTMLScroll". Differential Revision: https://phabricator.services.mozilla.com/D210233 --- dom/animation/ScrollTimeline.h | 2 +- dom/base/DOMIntersectionObserver.cpp | 2 +- gfx/layers/apz/src/AsyncPanZoomController.cpp | 2 +- layout/base/PresShell.cpp | 4 +- layout/base/RestyleManager.cpp | 2 +- layout/base/nsCSSFrameConstructor.cpp | 18 +- layout/base/nsLayoutUtils.cpp | 6 +- layout/forms/nsListControlFrame.cpp | 28 +- layout/forms/nsListControlFrame.h | 4 +- layout/forms/nsTextControlFrame.cpp | 2 +- layout/generic/FrameClasses.py | 2 +- layout/generic/ScrollAnchorContainer.cpp | 20 +- layout/generic/ScrollAnchorContainer.h | 9 +- layout/generic/ScrollContainerFrame.cpp | 652 +++++++++--------- layout/generic/ScrollContainerFrame.h | 52 +- layout/generic/nsGridContainerFrame.cpp | 4 +- layout/generic/nsIFrame.cpp | 6 +- layout/generic/nsIFrame.h | 2 +- layout/generic/nsIScrollableFrame.h | 4 +- layout/style/nsStyleStruct.cpp | 2 +- layout/xul/nsIScrollbarMediator.h | 4 +- layout/xul/nsScrollbarFrame.cpp | 2 +- python/lldbutils/README.txt | 4 +- servo/ports/geckolib/glue.rs | 4 +- 24 files changed, 428 insertions(+), 409 deletions(-) diff --git a/dom/animation/ScrollTimeline.h b/dom/animation/ScrollTimeline.h index 58ab9586d946..d26c9345d1e7 100644 --- a/dom/animation/ScrollTimeline.h +++ b/dom/animation/ScrollTimeline.h @@ -244,7 +244,7 @@ class ScrollTimeline : public AnimationTimeline { * of scroll driven animations. This is used for all kinds of progress * timelines, i.e. anonymous/named scroll timelines and anonymous/named view * timelines. And this object is owned by the scroll source (See - * ElementAnimationData and nsGfxScrollFrame for the usage). + * ElementAnimationData and ScrollContainerFrame for the usage). */ class ProgressTimelineScheduler { public: diff --git a/dom/base/DOMIntersectionObserver.cpp b/dom/base/DOMIntersectionObserver.cpp index 37d17ddcd372..13f597df82fb 100644 --- a/dom/base/DOMIntersectionObserver.cpp +++ b/dom/base/DOMIntersectionObserver.cpp @@ -351,7 +351,7 @@ static Maybe ComputeTheIntersection( nsLayoutUtils::GetCrossDocParentFrameInProcess(target); while (containerFrame && containerFrame != aRoot) { // FIXME(emilio): What about other scroll frames that inherit from - // nsHTMLScrollFrame but have a different type, like nsListControlFrame? + // ScrollContainerFrame but have a different type, like nsListControlFrame? // This looks bogus in that case, but different bug. if (nsIScrollableFrame* scrollFrame = do_QueryFrame(containerFrame)) { if (containerFrame->GetParent() == aRoot && !aRoot->GetParent()) { diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 84b4a95b9e15..22d633828c4b 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -6543,7 +6543,7 @@ Maybe AsyncPanZoomController::FindSnapPointNear( // GetSnapPointForDestination() can produce a destination that's outside // of the scroll frame's scroll range. Clamp it here (this matches the // behaviour of the main-thread code path, which clamps it in - // nsGfxScrollFrame::ScrollTo()). + // ScrollContainerFrame::ScrollTo()). return Some(CSSSnapDestination{scrollRange.ClampPoint(cssSnapPoint), snapDestination->mTargetIds}); } diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index a3a36c7473aa..e612492fc1a5 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -6079,7 +6079,7 @@ void PresShell::MarkFramesInSubtreeApproximatelyVisible( // We can properly set the base rect for root scroll frames on top level // and root content documents. Otherwise the base rect we compute might // be way too big without the limiting that - // nsHTMLScrollFrame::DecideScrollableLayer does, so we just ignore the + // ScrollContainerFrame::DecideScrollableLayer does, so we just ignore the // displayport in that case. nsPresContext* pc = aFrame->PresContext(); if (scrollFrame->IsRootScrollFrameOfDocument() && @@ -11476,7 +11476,7 @@ bool PresShell::SetVisualViewportOffset(const nsPoint& aScrollOffset, nsPoint newOffset = aScrollOffset; nsIScrollableFrame* rootScrollFrame = GetRootScrollFrameAsScrollable(); if (rootScrollFrame) { - // See the comment in nsHTMLScrollFrame::Reflow above the call to + // See the comment in ScrollContainerFrame::Reflow above the call to // SetVisualViewportOffset for why we need to do this. nsRect scrollRange = rootScrollFrame->GetScrollRangeForUserInputEvents(); if (!scrollRange.Contains(newOffset)) { diff --git a/layout/base/RestyleManager.cpp b/layout/base/RestyleManager.cpp index e00493467fae..89cc48a2b17e 100644 --- a/layout/base/RestyleManager.cpp +++ b/layout/base/RestyleManager.cpp @@ -769,7 +769,7 @@ static nsIFrame* GetFrameForChildrenOnlyTransformHint(nsIFrame* aFrame) { // GetContent() returns nullptr for ViewportFrame. aFrame = aFrame->PrincipalChildList().FirstChild(); } - // For an nsHTMLScrollFrame, this will get the SVG frame that has the + // For a ScrollContainerFrame, this will get the SVG frame that has the // children-only transforms: aFrame = aFrame->GetContent()->GetPrimaryFrame(); if (aFrame->IsSVGOuterSVGFrame()) { diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 9c14d334d70a..007b237ec015 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -213,9 +213,6 @@ nsIFrame* NS_NewMenuPopupFrame(PresShell* aPresShell, ComputedStyle* aStyle); nsIFrame* NS_NewTreeBodyFrame(PresShell* aPresShell, ComputedStyle* aStyle); -nsHTMLScrollFrame* NS_NewHTMLScrollFrame(PresShell* aPresShell, - ComputedStyle* aStyle, bool aIsRoot); - nsIFrame* NS_NewSliderFrame(PresShell* aPresShell, ComputedStyle* aStyle); nsIFrame* NS_NewScrollbarFrame(PresShell* aPresShell, ComputedStyle* aStyle); @@ -468,10 +465,10 @@ static nsIFrame* GetIBContainingBlockFor(nsIFrame* aFrame) { // Find the multicol containing block suitable for reframing. // // Note: this function may not return a ColumnSetWrapperFrame. For example, if -// the multicol containing block has "overflow:scroll" style, HTMLScrollFrame is -// returned because ColumnSetWrapperFrame is the scrolled frame which has the -// -moz-scrolled-content pseudo style. We may walk up "too far", but in terms of -// correctness of reframing, it's OK. +// the multicol containing block has "overflow:scroll" style, +// ScrollContainerFrame is returned because ColumnSetWrapperFrame is the +// scrolled frame which has the -moz-scrolled-content pseudo style. We may walk +// up "too far", but in terms of correctness of reframing, it's OK. static nsContainerFrame* GetMultiColumnContainingBlockFor(nsIFrame* aFrame) { MOZ_ASSERT(aFrame->HasAnyStateBits(NS_FRAME_HAS_MULTI_COLUMN_ANCESTOR), "Should only be called if the frame has a multi-column ancestor!"); @@ -2684,7 +2681,7 @@ void nsCSSFrameConstructor::SetUpDocElementContainingBlock( Galley presentation, with scrolling: ViewportFrame [fixed-cb] - nsHTMLScrollFrame (if needed) + ScrollContainerFrame (if needed) nsCanvasFrame [abs-cb] root element frame (nsBlockFrame, SVGOuterSVGFrame, nsTableWrapperFrame, nsPlaceholderFrame) @@ -2704,7 +2701,7 @@ void nsCSSFrameConstructor::SetUpDocElementContainingBlock( Print-preview presentation, non-XUL ViewportFrame - nsHTMLScrollFrame + ScrollContainerFrame nsCanvasFrame nsPageSequenceFrame PrintedSheetFrame @@ -4179,7 +4176,8 @@ already_AddRefed nsCSSFrameConstructor::BeginBuildingScrollFrame( nsContainerFrame* gfxScrollFrame = aNewFrame; if (!gfxScrollFrame) { - gfxScrollFrame = NS_NewHTMLScrollFrame(mPresShell, aContentStyle, aIsRoot); + gfxScrollFrame = + NS_NewScrollContainerFrame(mPresShell, aContentStyle, aIsRoot); InitAndRestoreFrame(aState, aContent, aParentFrame, gfxScrollFrame); } diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 14e80c57e887..f6bbc3151594 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -1398,7 +1398,7 @@ nsRect nsLayoutUtils::GetScrolledRect(nsIFrame* aScrolledFrame, StyleDirection aDirection) { WritingMode wm = aScrolledFrame->GetWritingMode(); // Potentially override the frame's direction to use the direction found - // by nsHTMLScrollFrame::GetScrolledFrameDir() + // by ScrollContainerFrame::GetScrolledFrameDir() wm.SetDirectionFromBidiLevel(aDirection == StyleDirection::Rtl ? mozilla::intl::BidiEmbeddingLevel::RTL() : mozilla::intl::BidiEmbeddingLevel::LTR()); @@ -3165,7 +3165,7 @@ void nsLayoutUtils::PaintFrame(gfxContext* aRenderingContext, nsIFrame* aFrame, // In cases where the root document is a XUL document, we want to take // the ViewID from the root element, as that will be the ViewID of the // root APZC in the tree. Skip doing this in cases where we know - // nsGfxScrollFrame::BuilDisplayList will do it instead. + // ScrollContainerFrame::BuilDisplayList will do it instead. if (dom::Element* element = presShell->GetDocument()->GetDocumentElement()) { id = nsLayoutUtils::FindOrCreateIDFor(element); @@ -4162,7 +4162,7 @@ static bool GetPercentBSize(const LengthPercentage& aStyle, nsIFrame* aFrame, MOZ_ASSERT(!aStyle.ConvertsToLength(), "GetAbsoluteCoord should have handled this"); - // During reflow, nsHTMLScrollFrame::ReflowScrolledFrame uses + // During reflow, ScrollContainerFrame::ReflowScrolledFrame uses // SetComputedHeight on the reflow input for its child to propagate its // computed height to the scrolled content. So here we skip to the scroll // frame that contains this scrolled content in order to get the same diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index 3020e998884d..75c33dab6b43 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -55,7 +55,7 @@ NS_IMPL_FRAMEARENA_HELPERS(nsListControlFrame) nsListControlFrame::nsListControlFrame(ComputedStyle* aStyle, nsPresContext* aPresContext) - : nsHTMLScrollFrame(aStyle, aPresContext, kClassID, false), + : ScrollContainerFrame(aStyle, aPresContext, kClassID, false), mMightNeedSecondPass(false), mHasPendingInterruptAtStartOfReflow(false), mForceSelection(false) { @@ -85,7 +85,7 @@ void nsListControlFrame::Destroy(DestroyContext& aContext) { // event listener can outlive the frame. mEventListener->Detach(); - nsHTMLScrollFrame::Destroy(aContext); + ScrollContainerFrame::Destroy(aContext); } void nsListControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, @@ -99,7 +99,7 @@ void nsListControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, DO_GLOBAL_REFLOW_COUNT_DSP("nsListControlFrame"); - nsHTMLScrollFrame::BuildDisplayList(aBuilder, aLists); + ScrollContainerFrame::BuildDisplayList(aBuilder, aLists); } HTMLOptionElement* nsListControlFrame::GetCurrentOption() const { @@ -170,7 +170,7 @@ NS_QUERYFRAME_HEAD(nsListControlFrame) NS_QUERYFRAME_ENTRY(nsIFormControlFrame) NS_QUERYFRAME_ENTRY(nsISelectControlFrame) NS_QUERYFRAME_ENTRY(nsListControlFrame) -NS_QUERYFRAME_TAIL_INHERITING(nsHTMLScrollFrame) +NS_QUERYFRAME_TAIL_INHERITING(ScrollContainerFrame) #ifdef ACCESSIBILITY a11y::AccType nsListControlFrame::AccessibleType() { @@ -340,7 +340,7 @@ void nsListControlFrame::Reflow(nsPresContext* aPresContext, state.SetComputedBSize(*containBSize); } - nsHTMLScrollFrame::Reflow(aPresContext, aDesiredSize, state, aStatus); + ScrollContainerFrame::Reflow(aPresContext, aDesiredSize, state, aStatus); if (!mMightNeedSecondPass) { NS_ASSERTION(!autoBSize || BSizeOfARow() == oldBSizeOfARow, @@ -384,9 +384,9 @@ void nsListControlFrame::Reflow(nsPresContext* aPresContext, // XXXbz We're just changing the block size here; do we need to dirty // ourselves or anything like that? We might need to, per the letter // of the reflow protocol, but things seem to work fine without it... - // Is that just an implementation detail of nsHTMLScrollFrame that + // Is that just an implementation detail of ScrollContainerFrame that // we're depending on? - nsHTMLScrollFrame::DidReflow(aPresContext, &state); + ScrollContainerFrame::DidReflow(aPresContext, &state); // Now compute the block size we want to have nscoord computedBSize = CalcIntrinsicBSize(BSizeOfARow(), length); @@ -395,9 +395,9 @@ void nsListControlFrame::Reflow(nsPresContext* aPresContext, // XXXbz to make the ascent really correct, we should add our // mComputedPadding.top to it (and subtract it from descent). Need that - // because nsGfxScrollFrame just adds in the border.... + // because ScrollContainerFrame just adds in the border.... aStatus.Reset(); - nsHTMLScrollFrame::Reflow(aPresContext, aDesiredSize, state, aStatus); + ScrollContainerFrame::Reflow(aPresContext, aDesiredSize, state, aStatus); } bool nsListControlFrame::ShouldPropagateComputedBSizeToScrolledContent() const { @@ -646,12 +646,12 @@ nsresult nsListControlFrame::HandleEvent(nsPresContext* aPresContext, if (nsEventStatus_eConsumeNoDefault == *aEventStatus) return NS_OK; // disabled state affects how we're selected, but we don't want to go through - // nsHTMLScrollFrame if we're disabled. + // ScrollContainerFrame if we're disabled. if (IsContentDisabled()) { return nsIFrame::HandleEvent(aPresContext, aEvent, aEventStatus); } - return nsHTMLScrollFrame::HandleEvent(aPresContext, aEvent, aEventStatus); + return ScrollContainerFrame::HandleEvent(aPresContext, aEvent, aEventStatus); } //--------------------------------------------------------- @@ -665,7 +665,7 @@ void nsListControlFrame::SetInitialChildList(ChildListID aListID, mHasBeenInitialized = false; } } - nsHTMLScrollFrame::SetInitialChildList(aListID, std::move(aChildList)); + ScrollContainerFrame::SetInitialChildList(aListID, std::move(aChildList)); } HTMLSelectElement& nsListControlFrame::Select() const { @@ -675,7 +675,7 @@ HTMLSelectElement& nsListControlFrame::Select() const { //--------------------------------------------------------- void nsListControlFrame::Init(nsIContent* aContent, nsContainerFrame* aParent, nsIFrame* aPrevInFlow) { - nsHTMLScrollFrame::Init(aContent, aParent, aPrevInFlow); + ScrollContainerFrame::Init(aContent, aParent, aPrevInFlow); // we shouldn't have to unregister this listener because when // our frame goes away all these content node go away as well @@ -978,7 +978,7 @@ void nsListControlFrame::DidReflow(nsPresContext* aPresContext, bool wasInterrupted = !mHasPendingInterruptAtStartOfReflow && aPresContext->HasPendingInterrupt(); - nsHTMLScrollFrame::DidReflow(aPresContext, aReflowInput); + ScrollContainerFrame::DidReflow(aPresContext, aReflowInput); if (mNeedToReset && !wasInterrupted) { mNeedToReset = false; diff --git a/layout/forms/nsListControlFrame.h b/layout/forms/nsListControlFrame.h index 6834c67e32ad..393fecfb18d9 100644 --- a/layout/forms/nsListControlFrame.h +++ b/layout/forms/nsListControlFrame.h @@ -43,7 +43,7 @@ class HTMLOptionsCollection; * Frame-based listbox. */ -class nsListControlFrame final : public nsHTMLScrollFrame, +class nsListControlFrame final : public mozilla::ScrollContainerFrame, public nsIFormControlFrame, public nsISelectControlFrame { public: @@ -195,7 +195,7 @@ class nsListControlFrame final : public nsHTMLScrollFrame, bool MightNeedSecondPass() const { return mMightNeedSecondPass; } void SetSuppressScrollbarUpdate(bool aSuppress) { - nsHTMLScrollFrame::SetSuppressScrollbarUpdate(aSuppress); + ScrollContainerFrame::SetSuppressScrollbarUpdate(aSuppress); } /** diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index 3c44038d897d..fa297a5bf0e1 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -1145,7 +1145,7 @@ NS_IMETHODIMP nsTextControlFrame::RestoreState(PresState* aState) { NS_ENSURE_ARG_POINTER(aState); - // Query the nsIStatefulFrame from the HTMLScrollFrame + // Query the nsIStatefulFrame from the ScrollContainerFrame if (nsIStatefulFrame* scrollStateFrame = do_QueryFrame(GetScrollTargetFrame())) { return scrollStateFrame->RestoreState(aState); diff --git a/layout/generic/FrameClasses.py b/layout/generic/FrameClasses.py index 36c1af10d138..f1f18b08e734 100644 --- a/layout/generic/FrameClasses.py +++ b/layout/generic/FrameClasses.py @@ -75,7 +75,6 @@ FRAME_CLASSES = [ Frame("nsHTMLFramesetBlankFrame", "None", COMMON | LEAF), Frame("nsHTMLFramesetBorderFrame", "None", COMMON | LEAF), Frame("nsHTMLFramesetFrame", "FrameSet", COMMON | LEAF), - Frame("nsHTMLScrollFrame", "Scroll", COMMON), Frame("nsImageControlFrame", "ImageControl", REPLACED_SIZING | LEAF), Frame("nsImageFrame", "Image", REPLACED_SIZING | {"LeafDynamic"}), Frame("nsInlineFrame", "Inline", INLINE), @@ -112,6 +111,7 @@ FRAME_CLASSES = [ Frame("nsRubyFrame", "Ruby", RUBY_CONTENT), Frame("nsRubyTextContainerFrame", "RubyTextContainer", {"None"}), Frame("nsRubyTextFrame", "RubyText", RUBY_CONTENT), + Frame("ScrollContainerFrame", "Scroll", COMMON), Frame("SimpleXULLeafFrame", "SimpleXULLeaf", COMMON | LEAF), Frame("nsScrollbarButtonFrame", "SimpleXULLeaf", COMMON | LEAF), Frame("nsScrollbarFrame", "Scrollbar", COMMON), diff --git a/layout/generic/ScrollAnchorContainer.cpp b/layout/generic/ScrollAnchorContainer.cpp index 1d3d5ca90ed6..e162e52eeb79 100644 --- a/layout/generic/ScrollAnchorContainer.cpp +++ b/layout/generic/ScrollAnchorContainer.cpp @@ -45,12 +45,12 @@ static mozilla::LazyLogModule sAnchorLog("scrollanchor"); namespace mozilla::layout { -nsHTMLScrollFrame* ScrollAnchorContainer::Frame() const { - return reinterpret_cast( - ((char*)this) - offsetof(nsHTMLScrollFrame, mAnchor)); +ScrollContainerFrame* ScrollAnchorContainer::Frame() const { + return reinterpret_cast( + ((char*)this) - offsetof(ScrollContainerFrame, mAnchor)); } -ScrollAnchorContainer::ScrollAnchorContainer(nsHTMLScrollFrame* aScrollFrame) +ScrollAnchorContainer::ScrollAnchorContainer(ScrollContainerFrame* aScrollFrame) : mDisabled(false), mAnchorMightBeSubOptimal(false), mAnchorNodeIsDirty(true), @@ -199,16 +199,16 @@ static nsRect FindScrollAnchoringBoundingRect(const nsIFrame* aScrollFrame, /** * Compute the offset between the scrollable overflow rect start edge of - * aCandidate and the scroll-port start edge of aScrollFrame, in the block axis - * of aScrollFrame. + * aCandidate and the scroll-port start edge of aScrollContainerFrame, in the + * block axis of aScrollContainerFrame. */ static nscoord FindScrollAnchoringBoundingOffset( - const nsHTMLScrollFrame* aScrollFrame, nsIFrame* aCandidate) { - WritingMode writingMode = aScrollFrame->GetWritingMode(); + const ScrollContainerFrame* aScrollContainerFrame, nsIFrame* aCandidate) { + WritingMode writingMode = aScrollContainerFrame->GetWritingMode(); nsRect physicalBounding = - FindScrollAnchoringBoundingRect(aScrollFrame, aCandidate); + FindScrollAnchoringBoundingRect(aScrollContainerFrame, aCandidate); LogicalRect logicalBounding(writingMode, physicalBounding, - aScrollFrame->mScrolledFrame->GetSize()); + aScrollContainerFrame->mScrolledFrame->GetSize()); return logicalBounding.BStart(writingMode); } diff --git a/layout/generic/ScrollAnchorContainer.h b/layout/generic/ScrollAnchorContainer.h index e86a937da644..1b919fe2a72d 100644 --- a/layout/generic/ScrollAnchorContainer.h +++ b/layout/generic/ScrollAnchorContainer.h @@ -12,10 +12,13 @@ #include "mozilla/TimeStamp.h" class nsFrameList; -class nsHTMLScrollFrame; class nsIFrame; class nsIScrollableFrame; +namespace mozilla { +class ScrollContainerFrame; +} + namespace mozilla::layout { /** @@ -27,7 +30,7 @@ namespace mozilla::layout { */ class ScrollAnchorContainer final { public: - explicit ScrollAnchorContainer(nsHTMLScrollFrame* aScrollFrame); + explicit ScrollAnchorContainer(ScrollContainerFrame* aScrollFrame); ~ScrollAnchorContainer(); /** @@ -43,7 +46,7 @@ class ScrollAnchorContainer final { nsIFrame* AnchorNode() const { return mAnchorNode; } // The owner of this scroll anchor container. - nsHTMLScrollFrame* Frame() const; + ScrollContainerFrame* Frame() const; /** * Returns the frame that owns this scroll anchor container as a scrollable diff --git a/layout/generic/ScrollContainerFrame.cpp b/layout/generic/ScrollContainerFrame.cpp index 5c11fabde9c3..e3eb040d0723 100644 --- a/layout/generic/ScrollContainerFrame.cpp +++ b/layout/generic/ScrollContainerFrame.cpp @@ -157,81 +157,79 @@ static ScrollDirections GetOverflowChange(const nsRect& aCurScrolledRect, * ScrollEvents are one-shot runnables; the refresh driver drops them after * running them. */ -class nsHTMLScrollFrame::ScrollEvent : public Runnable { +class ScrollContainerFrame::ScrollEvent : public Runnable { public: NS_DECL_NSIRUNNABLE - explicit ScrollEvent(nsHTMLScrollFrame* aHelper, bool aDelayed); + explicit ScrollEvent(ScrollContainerFrame* aHelper, bool aDelayed); void Revoke() { mHelper = nullptr; } private: - nsHTMLScrollFrame* mHelper; + ScrollContainerFrame* mHelper; }; -class nsHTMLScrollFrame::ScrollEndEvent : public Runnable { +class ScrollContainerFrame::ScrollEndEvent : public Runnable { public: NS_DECL_NSIRUNNABLE - explicit ScrollEndEvent(nsHTMLScrollFrame* aHelper, bool aDelayed); + explicit ScrollEndEvent(ScrollContainerFrame* aHelper, bool aDelayed); void Revoke() { mHelper = nullptr; } private: - nsHTMLScrollFrame* mHelper; + ScrollContainerFrame* mHelper; }; -class nsHTMLScrollFrame::AsyncScrollPortEvent : public Runnable { +class ScrollContainerFrame::AsyncScrollPortEvent : public Runnable { public: NS_DECL_NSIRUNNABLE - explicit AsyncScrollPortEvent(nsHTMLScrollFrame* helper) - : Runnable("nsHTMLScrollFrame::AsyncScrollPortEvent"), mHelper(helper) {} + explicit AsyncScrollPortEvent(ScrollContainerFrame* helper) + : Runnable("ScrollContainerFrame::AsyncScrollPortEvent"), + mHelper(helper) {} void Revoke() { mHelper = nullptr; } private: - nsHTMLScrollFrame* mHelper; + ScrollContainerFrame* mHelper; }; -class nsHTMLScrollFrame::ScrolledAreaEvent : public Runnable { +class ScrollContainerFrame::ScrolledAreaEvent : public Runnable { public: NS_DECL_NSIRUNNABLE - explicit ScrolledAreaEvent(nsHTMLScrollFrame* helper) - : Runnable("nsHTMLScrollFrame::ScrolledAreaEvent"), mHelper(helper) {} + explicit ScrolledAreaEvent(ScrollContainerFrame* helper) + : Runnable("ScrollContainerFrame::ScrolledAreaEvent"), mHelper(helper) {} void Revoke() { mHelper = nullptr; } private: - nsHTMLScrollFrame* mHelper; + ScrollContainerFrame* mHelper; }; -//---------------------------------------------------------------------- - -//----------nsHTMLScrollFrame------------------------------------------- - class ScrollFrameActivityTracker final - : public nsExpirationTracker { + : public nsExpirationTracker { public: // Wait for 3-4s between scrolls before we remove our layers. // That's 4 generations of 1s each. enum { TIMEOUT_MS = 1000 }; explicit ScrollFrameActivityTracker(nsIEventTarget* aEventTarget) - : nsExpirationTracker( + : nsExpirationTracker( TIMEOUT_MS, "ScrollFrameActivityTracker", aEventTarget) {} ~ScrollFrameActivityTracker() { AgeAllGenerations(); } - virtual void NotifyExpired(nsHTMLScrollFrame* aObject) override { + virtual void NotifyExpired(ScrollContainerFrame* aObject) override { RemoveObject(aObject); aObject->MarkNotRecentlyScrolled(); } }; static StaticAutoPtr gScrollFrameActivityTracker; -nsHTMLScrollFrame* NS_NewHTMLScrollFrame(PresShell* aPresShell, - ComputedStyle* aStyle, bool aIsRoot) { +ScrollContainerFrame* NS_NewScrollContainerFrame(mozilla::PresShell* aPresShell, + ComputedStyle* aStyle, + bool aIsRoot) { return new (aPresShell) - nsHTMLScrollFrame(aStyle, aPresShell->GetPresContext(), aIsRoot); + ScrollContainerFrame(aStyle, aPresShell->GetPresContext(), aIsRoot); } -NS_IMPL_FRAMEARENA_HELPERS(nsHTMLScrollFrame) +NS_IMPL_FRAMEARENA_HELPERS(ScrollContainerFrame) -nsHTMLScrollFrame::nsHTMLScrollFrame(ComputedStyle* aStyle, - nsPresContext* aPresContext, - nsIFrame::ClassID aID, bool aIsRoot) +ScrollContainerFrame::ScrollContainerFrame(ComputedStyle* aStyle, + nsPresContext* aPresContext, + nsIFrame::ClassID aID, bool aIsRoot) : nsContainerFrame(aStyle, aPresContext, aID), mHScrollbarBox(nullptr), mVScrollbarBox(nullptr), @@ -302,21 +300,21 @@ nsHTMLScrollFrame::nsHTMLScrollFrame(ComputedStyle* aStyle, } } -nsHTMLScrollFrame::~nsHTMLScrollFrame() = default; +ScrollContainerFrame::~ScrollContainerFrame() = default; -void nsHTMLScrollFrame::ScrollbarActivityStarted() const { +void ScrollContainerFrame::ScrollbarActivityStarted() const { if (mScrollbarActivity) { mScrollbarActivity->ActivityStarted(); } } -void nsHTMLScrollFrame::ScrollbarActivityStopped() const { +void ScrollContainerFrame::ScrollbarActivityStopped() const { if (mScrollbarActivity) { mScrollbarActivity->ActivityStopped(); } } -void nsHTMLScrollFrame::Destroy(DestroyContext& aContext) { +void ScrollContainerFrame::Destroy(DestroyContext& aContext) { DestroyAbsoluteFrames(aContext); if (mIsRoot) { PresShell()->ResetVisualViewportOffset(); @@ -365,23 +363,23 @@ void nsHTMLScrollFrame::Destroy(DestroyContext& aContext) { nsContainerFrame::Destroy(aContext); } -void nsHTMLScrollFrame::SetInitialChildList(ChildListID aListID, - nsFrameList&& aChildList) { +void ScrollContainerFrame::SetInitialChildList(ChildListID aListID, + nsFrameList&& aChildList) { nsContainerFrame::SetInitialChildList(aListID, std::move(aChildList)); ReloadChildFrames(); } -void nsHTMLScrollFrame::AppendFrames(ChildListID aListID, - nsFrameList&& aFrameList) { +void ScrollContainerFrame::AppendFrames(ChildListID aListID, + nsFrameList&& aFrameList) { NS_ASSERTION(aListID == FrameChildListID::Principal, "Only main list supported"); mFrames.AppendFrames(nullptr, std::move(aFrameList)); ReloadChildFrames(); } -void nsHTMLScrollFrame::InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame, - const nsLineList::iterator* aPrevFrameLine, - nsFrameList&& aFrameList) { +void ScrollContainerFrame::InsertFrames( + ChildListID aListID, nsIFrame* aPrevFrame, + const nsLineList::iterator* aPrevFrameLine, nsFrameList&& aFrameList) { NS_ASSERTION(aListID == FrameChildListID::Principal, "Only main list supported"); NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this, @@ -390,8 +388,9 @@ void nsHTMLScrollFrame::InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame, ReloadChildFrames(); } -void nsHTMLScrollFrame::RemoveFrame(DestroyContext& aContext, - ChildListID aListID, nsIFrame* aOldFrame) { +void ScrollContainerFrame::RemoveFrame(DestroyContext& aContext, + ChildListID aListID, + nsIFrame* aOldFrame) { NS_ASSERTION(aListID == FrameChildListID::Principal, "Only main list supported"); mFrames.DestroyFrame(aContext, aOldFrame); @@ -474,7 +473,8 @@ struct MOZ_STACK_CLASS ScrollReflowInput { bool mOnlyNeedHScrollbarToScrollVVInsideLV = false; bool mOnlyNeedVScrollbarToScrollVVInsideLV = false; - ScrollReflowInput(nsHTMLScrollFrame* aFrame, const ReflowInput& aReflowInput); + ScrollReflowInput(ScrollContainerFrame* aFrame, + const ReflowInput& aReflowInput); nscoord VScrollbarMinHeight() const { return mVScrollbarPrefSize.height; } nscoord VScrollbarPrefWidth() const { return mVScrollbarPrefSize.width; } @@ -518,7 +518,7 @@ struct MOZ_STACK_CLASS ScrollReflowInput { nsMargin mScrollbarGutter; }; -ScrollReflowInput::ScrollReflowInput(nsHTMLScrollFrame* aFrame, +ScrollReflowInput::ScrollReflowInput(ScrollContainerFrame* aFrame, const ReflowInput& aReflowInput) : mReflowInput(aReflowInput), mComputedBorder(aReflowInput.ComputedPhysicalBorderPadding() - @@ -620,10 +620,10 @@ static nsSize ComputeInsideBorderSize(const ScrollReflowInput& aState, * * @param aForce if true, then we just assume the layout is consistent. */ -bool nsHTMLScrollFrame::TryLayout(ScrollReflowInput& aState, - ReflowOutput* aKidMetrics, - bool aAssumeHScroll, bool aAssumeVScroll, - bool aForce) { +bool ScrollContainerFrame::TryLayout(ScrollReflowInput& aState, + ReflowOutput* aKidMetrics, + bool aAssumeHScroll, bool aAssumeVScroll, + bool aForce) { if ((aState.mVScrollbar == ShowScrollbar::Never && aAssumeVScroll) || (aState.mHScrollbar == ShowScrollbar::Never && aAssumeHScroll)) { NS_ASSERTION(!aForce, "Shouldn't be forcing a hidden scrollbar to show!"); @@ -828,7 +828,7 @@ bool nsHTMLScrollFrame::TryLayout(ScrollReflowInput& aState, return true; } -bool nsHTMLScrollFrame::ScrolledContentDependsOnBSize( +bool ScrollContainerFrame::ScrolledContentDependsOnBSize( const ScrollReflowInput& aState) const { return mScrolledFrame->HasAnyStateBits( NS_FRAME_CONTAINS_RELATIVE_BSIZE | @@ -838,10 +838,10 @@ bool nsHTMLScrollFrame::ScrolledContentDependsOnBSize( aState.mReflowInput.ComputedMaxBSize() != NS_UNCONSTRAINEDSIZE; } -void nsHTMLScrollFrame::ReflowScrolledFrame(ScrollReflowInput& aState, - bool aAssumeHScroll, - bool aAssumeVScroll, - ReflowOutput* aMetrics) { +void ScrollContainerFrame::ReflowScrolledFrame(ScrollReflowInput& aState, + bool aAssumeHScroll, + bool aAssumeVScroll, + ReflowOutput* aMetrics) { const WritingMode wm = GetWritingMode(); // these could be NS_UNCONSTRAINEDSIZE ... std::min arithmetic should @@ -977,7 +977,8 @@ void nsHTMLScrollFrame::ReflowScrolledFrame(ScrollReflowInput& aState, aState.mReflowedContentsWithVScrollbar = aAssumeVScroll; } -bool nsHTMLScrollFrame::GuessHScrollbarNeeded(const ScrollReflowInput& aState) { +bool ScrollContainerFrame::GuessHScrollbarNeeded( + const ScrollReflowInput& aState) { if (aState.mHScrollbar != ShowScrollbar::Auto) { // no guessing required return aState.mHScrollbar == ShowScrollbar::Always; @@ -989,7 +990,8 @@ bool nsHTMLScrollFrame::GuessHScrollbarNeeded(const ScrollReflowInput& aState) { return mHasHorizontalScrollbar && !mOnlyNeedHScrollbarToScrollVVInsideLV; } -bool nsHTMLScrollFrame::GuessVScrollbarNeeded(const ScrollReflowInput& aState) { +bool ScrollContainerFrame::GuessVScrollbarNeeded( + const ScrollReflowInput& aState) { if (aState.mVScrollbar != ShowScrollbar::Auto) { // no guessing required return aState.mVScrollbar == ShowScrollbar::Always; @@ -1031,7 +1033,7 @@ bool nsHTMLScrollFrame::GuessVScrollbarNeeded(const ScrollReflowInput& aState) { return false; } -bool nsHTMLScrollFrame::InInitialReflow() const { +bool ScrollContainerFrame::InInitialReflow() const { // We're in an initial reflow if NS_FRAME_FIRST_REFLOW is set, unless we're a // root scrollframe. In that case we want to skip this clause altogether. // The guess here is that there are lots of overflow:auto divs out there that @@ -1041,8 +1043,8 @@ bool nsHTMLScrollFrame::InInitialReflow() const { return !mIsRoot && HasAnyStateBits(NS_FRAME_FIRST_REFLOW); } -void nsHTMLScrollFrame::ReflowContents(ScrollReflowInput& aState, - const ReflowOutput& aDesiredSize) { +void ScrollContainerFrame::ReflowContents(ScrollReflowInput& aState, + const ReflowOutput& aDesiredSize) { const WritingMode desiredWm = aDesiredSize.GetWritingMode(); ReflowOutput kidDesiredSize(desiredWm); ReflowScrolledFrame(aState, GuessHScrollbarNeeded(aState), @@ -1132,8 +1134,8 @@ void nsHTMLScrollFrame::ReflowContents(ScrollReflowInput& aState, aState.mVScrollbar != ShowScrollbar::Never, true); } -void nsHTMLScrollFrame::PlaceScrollArea(ScrollReflowInput& aState, - const nsPoint& aScrollPosition) { +void ScrollContainerFrame::PlaceScrollArea(ScrollReflowInput& aState, + const nsPoint& aScrollPosition) { // Set the x,y of the scrolled frame to the correct value mScrolledFrame->SetPosition(ScrollPort().TopLeft() - aScrollPosition); @@ -1172,13 +1174,14 @@ void nsHTMLScrollFrame::PlaceScrollArea(ScrollReflowInput& aState, scrolledArea, ReflowChildFlags::Default); } -nscoord nsHTMLScrollFrame::IntrinsicScrollbarGutterSizeAtInlineEdges() const { +nscoord ScrollContainerFrame::IntrinsicScrollbarGutterSizeAtInlineEdges() + const { const auto wm = GetWritingMode(); const LogicalMargin gutter(wm, IntrinsicScrollbarGutterSize()); return gutter.IStartEnd(wm); } -nsMargin nsHTMLScrollFrame::IntrinsicScrollbarGutterSize() const { +nsMargin ScrollContainerFrame::IntrinsicScrollbarGutterSize() const { if (PresContext()->UseOverlayScrollbars()) { // Overlay scrollbars do not consume space per spec. return {}; @@ -1215,7 +1218,7 @@ nsMargin nsHTMLScrollFrame::IntrinsicScrollbarGutterSize() const { return gutter; } -nsMargin nsHTMLScrollFrame::ComputeStableScrollbarGutter( +nsMargin ScrollContainerFrame::ComputeStableScrollbarGutter( const StyleScrollbarWidth& aStyleScrollbarWidth, const StyleScrollbarGutter& aStyleScrollbarGutter) const { if (PresContext()->UseOverlayScrollbars()) { @@ -1269,7 +1272,7 @@ static bool IsMarqueeScrollbox(const nsIFrame& aScrollFrame) { } /* virtual */ -nscoord nsHTMLScrollFrame::GetMinISize(gfxContext* aRenderingContext) { +nscoord ScrollContainerFrame::GetMinISize(gfxContext* aRenderingContext) { nscoord result = [&] { if (const Maybe containISize = ContainIntrinsicISize()) { return *containISize; @@ -1284,7 +1287,7 @@ nscoord nsHTMLScrollFrame::GetMinISize(gfxContext* aRenderingContext) { } /* virtual */ -nscoord nsHTMLScrollFrame::GetPrefISize(gfxContext* aRenderingContext) { +nscoord ScrollContainerFrame::GetPrefISize(gfxContext* aRenderingContext) { const Maybe containISize = ContainIntrinsicISize(); nscoord result = containISize ? *containISize @@ -1417,11 +1420,12 @@ static void GetScrollableOverflowForPerspective( } } -BaselineSharingGroup nsHTMLScrollFrame::GetDefaultBaselineSharingGroup() const { +BaselineSharingGroup ScrollContainerFrame::GetDefaultBaselineSharingGroup() + const { return mScrolledFrame->GetDefaultBaselineSharingGroup(); } -nscoord nsHTMLScrollFrame::SynthesizeFallbackBaseline( +nscoord ScrollContainerFrame::SynthesizeFallbackBaseline( mozilla::WritingMode aWM, BaselineSharingGroup aBaselineGroup) const { // Marign-end even for central baselines. if (aWM.IsLineInverted()) { @@ -1432,7 +1436,7 @@ nscoord nsHTMLScrollFrame::SynthesizeFallbackBaseline( : -GetLogicalUsedMargin(aWM).BEnd(aWM); } -Maybe nsHTMLScrollFrame::GetNaturalBaselineBOffset( +Maybe ScrollContainerFrame::GetNaturalBaselineBOffset( WritingMode aWM, BaselineSharingGroup aBaselineGroup, BaselineExportContext aExportContext) const { // Block containers that are scrollable always have a last baseline @@ -1466,7 +1470,7 @@ Maybe nsHTMLScrollFrame::GetNaturalBaselineBOffset( }); } -void nsHTMLScrollFrame::AdjustForPerspective(nsRect& aScrollableOverflow) { +void ScrollContainerFrame::AdjustForPerspective(nsRect& aScrollableOverflow) { // If we have perspective that is being applied to our children, then // the effective transform on the child depends on the relative position // of the child to us and changes during scrolling. @@ -1479,12 +1483,12 @@ void nsHTMLScrollFrame::AdjustForPerspective(nsRect& aScrollableOverflow) { aScrollableOverflow); } -void nsHTMLScrollFrame::Reflow(nsPresContext* aPresContext, - ReflowOutput& aDesiredSize, - const ReflowInput& aReflowInput, - nsReflowStatus& aStatus) { +void ScrollContainerFrame::Reflow(nsPresContext* aPresContext, + ReflowOutput& aDesiredSize, + const ReflowInput& aReflowInput, + nsReflowStatus& aStatus) { MarkInReflow(); - DO_GLOBAL_REFLOW_COUNT("nsHTMLScrollFrame"); + DO_GLOBAL_REFLOW_COUNT("ScrollContainerFrame"); MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!"); HandleScrollbarStyleSwitching(); @@ -1562,10 +1566,10 @@ void nsHTMLScrollFrame::Reflow(nsPresContext* aPresContext, !oldScrolledAreaBounds.IsEqualEdges(newScrolledAreaBounds)) { if (!mSuppressScrollbarUpdate) { mSkippedScrollbarLayout = false; - nsHTMLScrollFrame::SetScrollbarVisibility(mHScrollbarBox, - state.mShowHScrollbar); - nsHTMLScrollFrame::SetScrollbarVisibility(mVScrollbarBox, - state.mShowVScrollbar); + ScrollContainerFrame::SetScrollbarVisibility(mHScrollbarBox, + state.mShowHScrollbar); + ScrollContainerFrame::SetScrollbarVisibility(mVScrollbarBox, + state.mShowVScrollbar); // place and reflow scrollbars const nsRect insideBorderArea( nsPoint(state.mComputedBorder.left, state.mComputedBorder.top), @@ -1639,8 +1643,8 @@ void nsHTMLScrollFrame::Reflow(nsPresContext* aPresContext, PostOverflowEvent(); } -void nsHTMLScrollFrame::DidReflow(nsPresContext* aPresContext, - const ReflowInput* aReflowInput) { +void ScrollContainerFrame::DidReflow(nsPresContext* aPresContext, + const ReflowInput* aReflowInput) { nsContainerFrame::DidReflow(aPresContext, aReflowInput); if (NeedsResnap()) { PostPendingResnap(); @@ -1652,13 +1656,13 @@ void nsHTMLScrollFrame::DidReflow(nsPresContext* aPresContext, //////////////////////////////////////////////////////////////////////////////// #ifdef DEBUG_FRAME_DUMP -nsresult nsHTMLScrollFrame::GetFrameName(nsAString& aResult) const { - return MakeFrameName(u"HTMLScroll"_ns, aResult); +nsresult ScrollContainerFrame::GetFrameName(nsAString& aResult) const { + return MakeFrameName(u"ScrollContainer"_ns, aResult); } #endif #ifdef ACCESSIBILITY -a11y::AccType nsHTMLScrollFrame::AccessibleType() { +a11y::AccType ScrollContainerFrame::AccessibleType() { if (IsTableCaption()) { return GetRect().IsEmpty() ? a11y::eNoType : a11y::eHTMLCaptionType; } @@ -1674,15 +1678,15 @@ a11y::AccType nsHTMLScrollFrame::AccessibleType() { } #endif -NS_QUERYFRAME_HEAD(nsHTMLScrollFrame) +NS_QUERYFRAME_HEAD(ScrollContainerFrame) NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator) NS_QUERYFRAME_ENTRY(nsIScrollableFrame) NS_QUERYFRAME_ENTRY(nsIStatefulFrame) NS_QUERYFRAME_ENTRY(nsIScrollbarMediator) - NS_QUERYFRAME_ENTRY(nsHTMLScrollFrame) + NS_QUERYFRAME_ENTRY(ScrollContainerFrame) NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame) -nsMargin nsHTMLScrollFrame::GetDesiredScrollbarSizes() const { +nsMargin ScrollContainerFrame::GetDesiredScrollbarSizes() const { nsPresContext* pc = PresContext(); if (pc->UseOverlayScrollbars()) { return {}; @@ -1715,14 +1719,14 @@ nsMargin nsHTMLScrollFrame::GetDesiredScrollbarSizes() const { return result; } -nscoord nsHTMLScrollFrame::GetNonOverlayScrollbarSize( +nscoord ScrollContainerFrame::GetNonOverlayScrollbarSize( const nsPresContext* aPc, StyleScrollbarWidth aScrollbarWidth) { const auto size = aPc->Theme()->GetScrollbarSize(aPc, aScrollbarWidth, nsITheme::Overlay::No); return aPc->DevPixelsToAppUnits(size); } -void nsHTMLScrollFrame::HandleScrollbarStyleSwitching() { +void ScrollContainerFrame::HandleScrollbarStyleSwitching() { // Check if we switched between scrollbar styles. if (mScrollbarActivity && !UsesOverlayScrollbars()) { mScrollbarActivity->Destroy(); @@ -1746,11 +1750,11 @@ static bool IsFocused(nsIContent* aContent) { } #endif -void nsHTMLScrollFrame::SetScrollableByAPZ(bool aScrollable) { +void ScrollContainerFrame::SetScrollableByAPZ(bool aScrollable) { mScrollableByAPZ = aScrollable; } -void nsHTMLScrollFrame::SetZoomableByAPZ(bool aZoomable) { +void ScrollContainerFrame::SetZoomableByAPZ(bool aZoomable) { if (!nsLayoutUtils::UsesAsyncScrolling(this)) { // If APZ is disabled on this window, then we're never actually going to // do any zooming. So we don't need to do any of the setup for it. Note @@ -1766,11 +1770,11 @@ void nsHTMLScrollFrame::SetZoomableByAPZ(bool aZoomable) { } } -void nsHTMLScrollFrame::SetHasOutOfFlowContentInsideFilter() { +void ScrollContainerFrame::SetHasOutOfFlowContentInsideFilter() { mHasOutOfFlowContentInsideFilter = true; } -bool nsHTMLScrollFrame::WantAsyncScroll() const { +bool ScrollContainerFrame::WantAsyncScroll() const { ScrollStyles styles = GetScrollStyles(); // First, as an optimization because getting the scrollrange is @@ -1831,23 +1835,23 @@ static nsRect GetOnePixelRangeAroundPoint(const nsPoint& aPoint, return allowedRange; } -void nsHTMLScrollFrame::ScrollByPage(nsScrollbarFrame* aScrollbar, - int32_t aDirection, - ScrollSnapFlags aSnapFlags) { +void ScrollContainerFrame::ScrollByPage(nsScrollbarFrame* aScrollbar, + int32_t aDirection, + ScrollSnapFlags aSnapFlags) { ScrollByUnit(aScrollbar, ScrollMode::Smooth, aDirection, ScrollUnit::PAGES, aSnapFlags); } -void nsHTMLScrollFrame::ScrollByWhole(nsScrollbarFrame* aScrollbar, - int32_t aDirection, - ScrollSnapFlags aSnapFlags) { +void ScrollContainerFrame::ScrollByWhole(nsScrollbarFrame* aScrollbar, + int32_t aDirection, + ScrollSnapFlags aSnapFlags) { ScrollByUnit(aScrollbar, ScrollMode::Instant, aDirection, ScrollUnit::WHOLE, aSnapFlags); } -void nsHTMLScrollFrame::ScrollByLine(nsScrollbarFrame* aScrollbar, - int32_t aDirection, - ScrollSnapFlags aSnapFlags) { +void ScrollContainerFrame::ScrollByLine(nsScrollbarFrame* aScrollbar, + int32_t aDirection, + ScrollSnapFlags aSnapFlags) { bool isHorizontal = aScrollbar->IsHorizontal(); nsIntPoint delta; if (isHorizontal) { @@ -1879,12 +1883,12 @@ void nsHTMLScrollFrame::ScrollByLine(nsScrollbarFrame* aScrollbar, ScrollOrigin::Other, nsIScrollableFrame::NOT_MOMENTUM, aSnapFlags); } -void nsHTMLScrollFrame::RepeatButtonScroll(nsScrollbarFrame* aScrollbar) { +void ScrollContainerFrame::RepeatButtonScroll(nsScrollbarFrame* aScrollbar) { aScrollbar->MoveToNewPosition(nsScrollbarFrame::ImplementsScrollByUnit::Yes); } -void nsHTMLScrollFrame::ThumbMoved(nsScrollbarFrame* aScrollbar, - nscoord aOldPos, nscoord aNewPos) { +void ScrollContainerFrame::ThumbMoved(nsScrollbarFrame* aScrollbar, + nscoord aOldPos, nscoord aNewPos) { MOZ_ASSERT(aScrollbar != nullptr); bool isHorizontal = aScrollbar->IsHorizontal(); nsPoint current = GetScrollPosition(); @@ -1908,7 +1912,7 @@ void nsHTMLScrollFrame::ThumbMoved(nsScrollbarFrame* aScrollbar, ScrollOperationParams{ScrollMode::Instant, ScrollOrigin::Other}); } -void nsHTMLScrollFrame::ScrollbarReleased(nsScrollbarFrame* aScrollbar) { +void ScrollContainerFrame::ScrollbarReleased(nsScrollbarFrame* aScrollbar) { // Scrollbar scrolling does not result in fling gestures, clear any // accumulated velocity mVelocityQueue.Reset(); @@ -1918,10 +1922,10 @@ void nsHTMLScrollFrame::ScrollbarReleased(nsScrollbarFrame* aScrollbar) { ScrollSnap(mDestination, ScrollMode::Smooth); } -void nsHTMLScrollFrame::ScrollByUnit(nsScrollbarFrame* aScrollbar, - ScrollMode aMode, int32_t aDirection, - ScrollUnit aUnit, - ScrollSnapFlags aSnapFlags) { +void ScrollContainerFrame::ScrollByUnit(nsScrollbarFrame* aScrollbar, + ScrollMode aMode, int32_t aDirection, + ScrollUnit aUnit, + ScrollSnapFlags aSnapFlags) { MOZ_ASSERT(aScrollbar != nullptr); bool isHorizontal = aScrollbar->IsHorizontal(); nsIntPoint delta; @@ -1938,7 +1942,7 @@ void nsHTMLScrollFrame::ScrollByUnit(nsScrollbarFrame* aScrollbar, //-------------------- Helper ---------------------- // AsyncSmoothMSDScroll has ref counting. -class nsHTMLScrollFrame::AsyncSmoothMSDScroll final +class ScrollContainerFrame::AsyncSmoothMSDScroll final : public nsARefreshObserver { public: AsyncSmoothMSDScroll(const nsPoint& aInitialPosition, @@ -2027,14 +2031,14 @@ class nsHTMLScrollFrame::AsyncSmoothMSDScroll final // The callback may release "this". // We don't access members after returning, so no need for KungFuDeathGrip. - nsHTMLScrollFrame::AsyncSmoothMSDScrollCallback(mCallee, deltaTime); + ScrollContainerFrame::AsyncSmoothMSDScrollCallback(mCallee, deltaTime); } /* * Set a refresh observer for smooth scroll iterations (and start observing). * Should be used at most once during the lifetime of this object. */ - void SetRefreshObserver(nsHTMLScrollFrame* aCallee) { + void SetRefreshObserver(ScrollContainerFrame* aCallee) { MOZ_ASSERT(aCallee, "AsyncSmoothMSDScroll::SetRefreshObserver needs " "a non-null aCallee in order to get a refresh driver"); @@ -2076,7 +2080,7 @@ class nsHTMLScrollFrame::AsyncSmoothMSDScroll final Telemetry::FX_REFRESH_DRIVER_SYNC_SCROLL_FRAME_DELAY_MS, false); } - nsRefreshDriver* RefreshDriver(nsHTMLScrollFrame* aCallee) { + nsRefreshDriver* RefreshDriver(ScrollContainerFrame* aCallee) { return aCallee->PresContext()->RefreshDriver(); } @@ -2084,14 +2088,14 @@ class nsHTMLScrollFrame::AsyncSmoothMSDScroll final nsRect mRange; nsPoint mStartPosition; mozilla::TimeStamp mLastRefreshTime; - nsHTMLScrollFrame* mCallee; + ScrollContainerFrame* mCallee; nscoord mOneDevicePixelInAppUnits; UniquePtr mSnapTargetIds; ScrollTriggeredByScript mTriggeredByScript; }; // AsyncScroll has ref counting. -class nsHTMLScrollFrame::AsyncScroll final : public nsARefreshObserver { +class ScrollContainerFrame::AsyncScroll final : public nsARefreshObserver { public: typedef mozilla::TimeStamp TimeStamp; typedef mozilla::TimeDuration TimeDuration; @@ -2158,8 +2162,8 @@ class nsHTMLScrollFrame::AsyncScroll final : public nsARefreshObserver { UniquePtr mAnimationPhysics; // The next section is observer/callback management - // Bodies of WillRefresh and RefreshDriver contain nsHTMLScrollFrame specific - // code. + // Bodies of WillRefresh and RefreshDriver contain ScrollContainerFrame + // specific code. public: NS_INLINE_DECL_REFCOUNTING(AsyncScroll, override) @@ -2167,7 +2171,7 @@ class nsHTMLScrollFrame::AsyncScroll final : public nsARefreshObserver { * Set a refresh observer for smooth scroll iterations (and start observing). * Should be used at most once during the lifetime of this object. */ - void SetRefreshObserver(nsHTMLScrollFrame* aCallee) { + void SetRefreshObserver(ScrollContainerFrame* aCallee) { MOZ_ASSERT(aCallee, "AsyncScroll::SetRefreshObserver needs " "a non-null aCallee in order to get a refresh driver"); @@ -2187,7 +2191,7 @@ class nsHTMLScrollFrame::AsyncScroll final : public nsARefreshObserver { virtual void WillRefresh(mozilla::TimeStamp aTime) override { // The callback may release "this". // We don't access members after returning, so no need for KungFuDeathGrip. - nsHTMLScrollFrame::AsyncScrollCallback(mCallee, aTime); + ScrollContainerFrame::AsyncScrollCallback(mCallee, aTime); } /** @@ -2214,16 +2218,16 @@ class nsHTMLScrollFrame::AsyncScroll final : public nsARefreshObserver { } private: - nsHTMLScrollFrame* mCallee; + ScrollContainerFrame* mCallee; UniquePtr mSnapTargetIds; ScrollTriggeredByScript mTriggeredByScript; - nsRefreshDriver* RefreshDriver(nsHTMLScrollFrame* aCallee) { + nsRefreshDriver* RefreshDriver(ScrollContainerFrame* aCallee) { return aCallee->PresContext()->RefreshDriver(); } }; -void nsHTMLScrollFrame::AsyncScroll::InitSmoothScroll( +void ScrollContainerFrame::AsyncScroll::InitSmoothScroll( TimeStamp aTime, nsPoint aInitialPosition, nsPoint aDestination, ScrollOrigin aOrigin, const nsRect& aRange, const nsSize& aCurrentVelocity) { @@ -2268,10 +2272,10 @@ void nsHTMLScrollFrame::AsyncScroll::InitSmoothScroll( /* * Callback function from AsyncSmoothMSDScroll, used in - * nsHTMLScrollFrame::ScrollTo + * ScrollContainerFrame::ScrollTo */ -void nsHTMLScrollFrame::AsyncSmoothMSDScrollCallback( - nsHTMLScrollFrame* aInstance, mozilla::TimeDuration aDeltaTime) { +void ScrollContainerFrame::AsyncSmoothMSDScrollCallback( + ScrollContainerFrame* aInstance, mozilla::TimeDuration aDeltaTime) { NS_ASSERTION(aInstance != nullptr, "aInstance must not be null"); NS_ASSERTION(aInstance->mAsyncSmoothMSDScroll, "Did not expect AsyncSmoothMSDScrollCallback without an active " @@ -2298,10 +2302,10 @@ void nsHTMLScrollFrame::AsyncSmoothMSDScrollCallback( } /* - * Callback function from AsyncScroll, used in nsHTMLScrollFrame::ScrollTo + * Callback function from AsyncScroll, used in ScrollContainerFrame::ScrollTo */ -void nsHTMLScrollFrame::AsyncScrollCallback(nsHTMLScrollFrame* aInstance, - mozilla::TimeStamp aTime) { +void ScrollContainerFrame::AsyncScrollCallback(ScrollContainerFrame* aInstance, + mozilla::TimeStamp aTime) { MOZ_ASSERT(aInstance != nullptr, "aInstance must not be null"); MOZ_ASSERT( aInstance->mAsyncScroll, @@ -2331,7 +2335,7 @@ void nsHTMLScrollFrame::AsyncScrollCallback(nsHTMLScrollFrame* aInstance, aInstance->mAsyncScroll->TakeSnapTargetIds()); } -void nsHTMLScrollFrame::SetTransformingByAPZ(bool aTransforming) { +void ScrollContainerFrame::SetTransformingByAPZ(bool aTransforming) { if (mTransformingByAPZ && !aTransforming) { PostScrollEndEvent(); } @@ -2344,7 +2348,7 @@ void nsHTMLScrollFrame::SetTransformingByAPZ(bool aTransforming) { } } -void nsHTMLScrollFrame::CompleteAsyncScroll( +void ScrollContainerFrame::CompleteAsyncScroll( const nsPoint& aStartPosition, const nsRect& aRange, UniquePtr aSnapTargetIds, ScrollOrigin aOrigin) { SetLastSnapTargetIds(std::move(aSnapTargetIds)); @@ -2379,12 +2383,12 @@ void nsHTMLScrollFrame::CompleteAsyncScroll( } } -bool nsHTMLScrollFrame::HasBgAttachmentLocal() const { +bool ScrollContainerFrame::HasBgAttachmentLocal() const { const nsStyleBackground* bg = StyleBackground(); return bg->HasLocalBackground(); } -void nsHTMLScrollFrame::ScrollToInternal( +void ScrollContainerFrame::ScrollToInternal( nsPoint aScrollPosition, ScrollMode aMode, ScrollOrigin aOrigin, const nsRect* aRange, ScrollSnapFlags aSnapFlags, ScrollTriggeredByScript aTriggeredByScript) { @@ -2396,8 +2400,8 @@ void nsHTMLScrollFrame::ScrollToInternal( ScrollOperationParams{aMode, aOrigin, aSnapFlags, aTriggeredByScript}); } -void nsHTMLScrollFrame::ScrollToCSSPixels(const CSSIntPoint& aScrollPosition, - ScrollMode aMode) { +void ScrollContainerFrame::ScrollToCSSPixels(const CSSIntPoint& aScrollPosition, + ScrollMode aMode) { CSSIntPoint currentCSSPixels = GetRoundedScrollPositionCSSPixels(); // Transmogrify this scroll to a relative one if there's any on-going // animation in APZ triggered by __user__. @@ -2447,7 +2451,7 @@ void nsHTMLScrollFrame::ScrollToCSSPixels(const CSSIntPoint& aScrollPosition, // 'this' might be destroyed here } -void nsHTMLScrollFrame::ScrollToCSSPixelsForApz( +void ScrollContainerFrame::ScrollToCSSPixelsForApz( const CSSPoint& aScrollPosition, ScrollSnapTargetIds&& aLastSnapTargetIds) { nsPoint pt = CSSPoint::ToAppUnits(aScrollPosition); nscoord halfRange = nsPresContext::CSSPixelsToAppUnits(1000); @@ -2460,7 +2464,7 @@ void nsHTMLScrollFrame::ScrollToCSSPixelsForApz( // 'this' might be destroyed here } -CSSIntPoint nsHTMLScrollFrame::GetRoundedScrollPositionCSSPixels() { +CSSIntPoint ScrollContainerFrame::GetRoundedScrollPositionCSSPixels() { return CSSIntPoint::FromAppUnitsRounded(GetScrollPosition()); } @@ -2468,9 +2472,9 @@ CSSIntPoint nsHTMLScrollFrame::GetRoundedScrollPositionCSSPixels() { * this method wraps calls to ScrollToImpl(), either in one shot or * incrementally, based on the setting of the smoothness scroll pref */ -void nsHTMLScrollFrame::ScrollToWithOrigin(nsPoint aScrollPosition, - const nsRect* aRange, - ScrollOperationParams&& aParams) { +void ScrollContainerFrame::ScrollToWithOrigin(nsPoint aScrollPosition, + const nsRect* aRange, + ScrollOperationParams&& aParams) { // None is never a valid scroll origin to be passed in. MOZ_ASSERT(aParams.mOrigin != ScrollOrigin::None); @@ -2635,7 +2639,7 @@ static void AdjustViews(nsIFrame* aFrame) { } } -void nsHTMLScrollFrame::MarkScrollbarsDirtyForReflow() const { +void ScrollContainerFrame::MarkScrollbarsDirtyForReflow() const { auto* presShell = PresShell(); if (mVScrollbarBox) { presShell->FrameNeedsReflow(mVScrollbarBox, @@ -2649,7 +2653,7 @@ void nsHTMLScrollFrame::MarkScrollbarsDirtyForReflow() const { } } -void nsHTMLScrollFrame::InvalidateScrollbars() const { +void ScrollContainerFrame::InvalidateScrollbars() const { if (mHScrollbarBox) { mHScrollbarBox->InvalidateFrameSubtree(); } @@ -2658,7 +2662,7 @@ void nsHTMLScrollFrame::InvalidateScrollbars() const { } } -bool nsHTMLScrollFrame::IsAlwaysActive() const { +bool ScrollContainerFrame::IsAlwaysActive() const { if (nsDisplayItem::ForceActiveLayers()) { return true; } @@ -2683,7 +2687,7 @@ bool nsHTMLScrollFrame::IsAlwaysActive() const { } static void RemoveDisplayPortCallback(nsITimer* aTimer, void* aClosure) { - nsHTMLScrollFrame* sf = static_cast(aClosure); + ScrollContainerFrame* sf = static_cast(aClosure); // This function only ever gets called from the expiry timer, so it must // be non-null here. Set it to null here so that we don't keep resetting @@ -2716,7 +2720,7 @@ static void RemoveDisplayPortCallback(nsITimer* aTimer, void* aClosure) { nsIContent* content = sf->GetContent(); - if (nsHTMLScrollFrame::ShouldActivateAllScrollFrames()) { + if (ScrollContainerFrame::ShouldActivateAllScrollFrames()) { // If we are activating all scroll frames then we only want to remove the // regular display port and downgrade to a minimal display port. MOZ_ASSERT(!content->GetProperty(nsGkAtoms::MinimalDisplayPort)); @@ -2734,7 +2738,7 @@ static void RemoveDisplayPortCallback(nsITimer* aTimer, void* aClosure) { sf->SchedulePaint(); } -void nsHTMLScrollFrame::MarkEverScrolled() { +void ScrollContainerFrame::MarkEverScrolled() { // Mark this frame as having been scrolled. If this is the root // scroll frame of a content document, then IsAlwaysActive() // will return true from now on and MarkNotRecentlyScrolled() won't @@ -2742,14 +2746,14 @@ void nsHTMLScrollFrame::MarkEverScrolled() { mHasBeenScrolled = true; } -void nsHTMLScrollFrame::MarkNotRecentlyScrolled() { +void ScrollContainerFrame::MarkNotRecentlyScrolled() { if (!mHasBeenScrolledRecently) return; mHasBeenScrolledRecently = false; SchedulePaint(); } -void nsHTMLScrollFrame::MarkRecentlyScrolled() { +void ScrollContainerFrame::MarkRecentlyScrolled() { mHasBeenScrolledRecently = true; if (IsAlwaysActive()) { return; @@ -2770,16 +2774,16 @@ void nsHTMLScrollFrame::MarkRecentlyScrolled() { ResetDisplayPortExpiryTimer(); } -void nsHTMLScrollFrame::ResetDisplayPortExpiryTimer() { +void ScrollContainerFrame::ResetDisplayPortExpiryTimer() { if (mDisplayPortExpiryTimer) { mDisplayPortExpiryTimer->InitWithNamedFuncCallback( RemoveDisplayPortCallback, this, StaticPrefs::apz_displayport_expiry_ms(), nsITimer::TYPE_ONE_SHOT, - "nsHTMLScrollFrame::ResetDisplayPortExpiryTimer"); + "ScrollContainerFrame::ResetDisplayPortExpiryTimer"); } } -bool nsHTMLScrollFrame::AllowDisplayPortExpiration() { +bool ScrollContainerFrame::AllowDisplayPortExpiration() { if (IsAlwaysActive()) { return false; } @@ -2801,7 +2805,7 @@ bool nsHTMLScrollFrame::AllowDisplayPortExpiration() { return true; } -void nsHTMLScrollFrame::TriggerDisplayPortExpiration() { +void ScrollContainerFrame::TriggerDisplayPortExpiration() { if (!AllowDisplayPortExpiration()) { return; } @@ -2817,7 +2821,7 @@ void nsHTMLScrollFrame::TriggerDisplayPortExpiration() { ResetDisplayPortExpiryTimer(); } -void nsHTMLScrollFrame::ScrollVisual() { +void ScrollContainerFrame::ScrollVisual() { MarkEverScrolled(); AdjustViews(mScrolledFrame); @@ -2917,9 +2921,9 @@ static nsPoint ClampAndAlignWithLayerPixels(const nsPoint& aPt, } /* static */ -void nsHTMLScrollFrame::ScrollActivityCallback(nsITimer* aTimer, - void* anInstance) { - nsHTMLScrollFrame* self = static_cast(anInstance); +void ScrollContainerFrame::ScrollActivityCallback(nsITimer* aTimer, + void* anInstance) { + auto* self = static_cast(anInstance); // Fire the synth mouse move. self->mScrollActivityTimer->Cancel(); @@ -2927,7 +2931,7 @@ void nsHTMLScrollFrame::ScrollActivityCallback(nsITimer* aTimer, self->PresShell()->SynthesizeMouseMove(true); } -void nsHTMLScrollFrame::ScheduleSyntheticMouseMove() { +void ScrollContainerFrame::ScheduleSyntheticMouseMove() { if (!mScrollActivityTimer) { mScrollActivityTimer = NS_NewTimer(GetMainThreadSerialEventTarget()); if (!mScrollActivityTimer) { @@ -2937,10 +2941,10 @@ void nsHTMLScrollFrame::ScheduleSyntheticMouseMove() { mScrollActivityTimer->InitWithNamedFuncCallback( ScrollActivityCallback, this, 100, nsITimer::TYPE_ONE_SHOT, - "nsHTMLScrollFrame::ScheduleSyntheticMouseMove"); + "ScrollContainerFrame::ScheduleSyntheticMouseMove"); } -void nsHTMLScrollFrame::NotifyApproximateFrameVisibilityUpdate( +void ScrollContainerFrame::NotifyApproximateFrameVisibilityUpdate( bool aIgnoreDisplayPort) { mLastUpdateFramesPos = GetScrollPosition(); if (aIgnoreDisplayPort) { @@ -2952,7 +2956,7 @@ void nsHTMLScrollFrame::NotifyApproximateFrameVisibilityUpdate( } } -bool nsHTMLScrollFrame::GetDisplayPortAtLastApproximateFrameVisibilityUpdate( +bool ScrollContainerFrame::GetDisplayPortAtLastApproximateFrameVisibilityUpdate( nsRect* aDisplayPort) { if (mHadDisplayPortAtLastFrameUpdate) { *aDisplayPort = mDisplayPortAtLastFrameUpdate; @@ -2994,7 +2998,7 @@ MatrixScales GetPaintedLayerScaleForFrame(nsIFrame* aFrame, return transformToAncestorScale.ToUnknownScale(); } -void nsHTMLScrollFrame::ScrollToImpl( +void ScrollContainerFrame::ScrollToImpl( nsPoint aPt, const nsRect& aRange, ScrollOrigin aOrigin, ScrollTriggeredByScript aTriggeredByScript) { // None is never a valid scroll origin to be passed in. @@ -3459,10 +3463,10 @@ struct HoveredStateComparator { } }; -void nsHTMLScrollFrame::AppendScrollPartsTo(nsDisplayListBuilder* aBuilder, - const nsDisplayListSet& aLists, - bool aCreateLayer, - bool aPositioned) { +void ScrollContainerFrame::AppendScrollPartsTo(nsDisplayListBuilder* aBuilder, + const nsDisplayListSet& aLists, + bool aCreateLayer, + bool aPositioned) { const bool overlayScrollbars = UsesOverlayScrollbars(); AutoTArray scrollParts; @@ -3592,7 +3596,8 @@ void nsHTMLScrollFrame::AppendScrollPartsTo(nsDisplayListBuilder* aBuilder, } } -nsRect nsHTMLScrollFrame::ExpandRectToNearlyVisible(const nsRect& aRect) const { +nsRect ScrollContainerFrame::ExpandRectToNearlyVisible( + const nsRect& aRect) const { // We don't want to expand a rect in a direction that we can't scroll, so we // check the scroll range. nsRect scrollRange = GetLayoutScrollRange(); @@ -3719,7 +3724,7 @@ class MOZ_RAII AutoContainsBlendModeCapturer { } }; -void nsHTMLScrollFrame::MaybeCreateTopLayerAndWrapRootItems( +void ScrollContainerFrame::MaybeCreateTopLayerAndWrapRootItems( nsDisplayListBuilder* aBuilder, nsDisplayListCollection& aSet, bool aCreateAsyncZoom, AutoContainsBlendModeCapturer* aAsyncZoomBlendCapture, @@ -3836,8 +3841,8 @@ void nsHTMLScrollFrame::MaybeCreateTopLayerAndWrapRootItems( } } -void nsHTMLScrollFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, - const nsDisplayListSet& aLists) { +void ScrollContainerFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, + const nsDisplayListSet& aLists) { SetAndNullOnExit tmpBuilder( mReferenceFrameDuringPainting, aBuilder->GetCurrentReferenceFrame()); if (aBuilder->IsForFrameVisibility()) { @@ -4338,7 +4343,7 @@ void nsHTMLScrollFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, set.MoveTo(aLists); } -nsRect nsHTMLScrollFrame::RestrictToRootDisplayPort( +nsRect ScrollContainerFrame::RestrictToRootDisplayPort( const nsRect& aDisplayportBase) { // This function clips aDisplayportBase so that it is no larger than the // root frame's displayport (or the root composition bounds, if we can't @@ -4475,13 +4480,13 @@ nsRect nsHTMLScrollFrame::RestrictToRootDisplayPort( return aDisplayportBase.Intersect(rootDisplayPort); } -/* static */ bool nsHTMLScrollFrame::ShouldActivateAllScrollFrames() { +/* static */ bool ScrollContainerFrame::ShouldActivateAllScrollFrames() { return (StaticPrefs::apz_wr_activate_all_scroll_frames() || (StaticPrefs::apz_wr_activate_all_scroll_frames_when_fission() && FissionAutostart())); } -bool nsHTMLScrollFrame::DecideScrollableLayer( +bool ScrollContainerFrame::DecideScrollableLayer( nsDisplayListBuilder* aBuilder, nsRect* aVisibleRect, nsRect* aDirtyRect, bool aSetBase, bool* aDirtyRectHasBeenOverriden) { nsIContent* content = GetContent(); @@ -4609,7 +4614,7 @@ bool nsHTMLScrollFrame::DecideScrollableLayer( return mWillBuildScrollableLayer; } -void nsHTMLScrollFrame::NotifyApzTransaction() { +void ScrollContainerFrame::NotifyApzTransaction() { mAllowScrollOriginDowngrade = true; mApzScrollPos = GetScrollPosition(); mApzAnimationRequested = IsLastScrollUpdateAnimating(); @@ -4621,7 +4626,7 @@ void nsHTMLScrollFrame::NotifyApzTransaction() { } } -Maybe nsHTMLScrollFrame::ComputeScrollMetadata( +Maybe ScrollContainerFrame::ComputeScrollMetadata( WebRenderLayerManager* aLayerManager, const nsIFrame* aItemFrame, const nsPoint& aOffsetToReferenceFrame) const { if (!mWillBuildScrollableLayer) { @@ -4638,7 +4643,7 @@ Maybe nsHTMLScrollFrame::ComputeScrollMetadata( aLayerManager, mScrollParentID, mScrollPort.Size(), isRootContent)); } -bool nsHTMLScrollFrame::IsRectNearlyVisible(const nsRect& aRect) const { +bool ScrollContainerFrame::IsRectNearlyVisible(const nsRect& aRect) const { // Use the right rect depending on if a display port is set. nsRect displayPort; bool usingDisplayport = DisplayPortUtils::GetDisplayPort( @@ -4659,7 +4664,7 @@ bool nsHTMLScrollFrame::IsRectNearlyVisible(const nsRect& aRect) const { ExpandRectToNearlyVisible(usingDisplayport ? displayPort : mScrollPort)); } -OverscrollBehaviorInfo nsHTMLScrollFrame::GetOverscrollBehaviorInfo() const { +OverscrollBehaviorInfo ScrollContainerFrame::GetOverscrollBehaviorInfo() const { nsIFrame* frame = GetFrameForStyle(); if (!frame) { return {}; @@ -4670,7 +4675,7 @@ OverscrollBehaviorInfo nsHTMLScrollFrame::GetOverscrollBehaviorInfo() const { disp.mOverscrollBehaviorY); } -ScrollStyles nsHTMLScrollFrame::GetScrollStyles() const { +ScrollStyles ScrollContainerFrame::GetScrollStyles() const { nsPresContext* presContext = PresContext(); if (!presContext->IsDynamic() && !(mIsRoot && presContext->HasPaginatedScrolling())) { @@ -4695,24 +4700,24 @@ ScrollStyles nsHTMLScrollFrame::GetScrollStyles() const { return result; } -nsRect nsHTMLScrollFrame::GetLayoutScrollRange() const { +nsRect ScrollContainerFrame::GetLayoutScrollRange() const { return GetScrollRange(mScrollPort.width, mScrollPort.height); } -nsRect nsHTMLScrollFrame::GetScrollRange(nscoord aWidth, - nscoord aHeight) const { +nsRect ScrollContainerFrame::GetScrollRange(nscoord aWidth, + nscoord aHeight) const { nsRect range = GetScrolledRect(); range.width = std::max(range.width - aWidth, 0); range.height = std::max(range.height - aHeight, 0); return range; } -nsRect nsHTMLScrollFrame::GetVisualScrollRange() const { +nsRect ScrollContainerFrame::GetVisualScrollRange() const { nsSize visualViewportSize = GetVisualViewportSize(); return GetScrollRange(visualViewportSize.width, visualViewportSize.height); } -nsSize nsHTMLScrollFrame::GetVisualViewportSize() const { +nsSize ScrollContainerFrame::GetVisualViewportSize() const { auto* presShell = PresShell(); if (mIsRoot && presShell->IsVisualViewportSizeSet()) { return presShell->GetVisualViewportSize(); @@ -4720,7 +4725,7 @@ nsSize nsHTMLScrollFrame::GetVisualViewportSize() const { return mScrollPort.Size(); } -nsPoint nsHTMLScrollFrame::GetVisualViewportOffset() const { +nsPoint ScrollContainerFrame::GetVisualViewportOffset() const { if (mIsRoot) { auto* presShell = PresShell(); if (auto pendingUpdate = presShell->GetPendingVisualScrollUpdate()) { @@ -4738,8 +4743,8 @@ nsPoint nsHTMLScrollFrame::GetVisualViewportOffset() const { return GetScrollPosition(); } -bool nsHTMLScrollFrame::SetVisualViewportOffset(const nsPoint& aOffset, - bool aRepaint) { +bool ScrollContainerFrame::SetVisualViewportOffset(const nsPoint& aOffset, + bool aRepaint) { MOZ_ASSERT(mIsRoot); AutoWeakFrame weakFrame(this); AutoScrollbarRepaintSuppression repaintSuppression(this, weakFrame, @@ -4753,7 +4758,7 @@ bool nsHTMLScrollFrame::SetVisualViewportOffset(const nsPoint& aOffset, return retVal; } -nsRect nsHTMLScrollFrame::GetVisualOptimalViewingRect() const { +nsRect ScrollContainerFrame::GetVisualOptimalViewingRect() const { auto* presShell = PresShell(); nsRect rect = mScrollPort; if (mIsRoot && presShell->IsVisualViewportSizeSet() && @@ -4806,11 +4811,10 @@ static void CalcRangeForScrollBy(int32_t aDelta, nscoord aPos, (aDelta > 0 ? aPosTolerance : aNegTolerance)); } -void nsHTMLScrollFrame::ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, - ScrollMode aMode, nsIntPoint* aOverflow, - ScrollOrigin aOrigin, - nsIScrollableFrame::ScrollMomentum aMomentum, - ScrollSnapFlags aSnapFlags) { +void ScrollContainerFrame::ScrollBy( + nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode, + nsIntPoint* aOverflow, ScrollOrigin aOrigin, + nsIScrollableFrame::ScrollMomentum aMomentum, ScrollSnapFlags aSnapFlags) { // When a smooth scroll is being processed on a frame, mouse wheel and // trackpad momentum scroll event updates must notcancel the SMOOTH or // SMOOTH_MSD scroll animations, enabling Javascript that depends on them to @@ -4998,9 +5002,8 @@ void nsHTMLScrollFrame::ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, } } -void nsHTMLScrollFrame::ScrollByCSSPixelsInternal(const CSSIntPoint& aDelta, - ScrollMode aMode, - ScrollSnapFlags aSnapFlags) { +void ScrollContainerFrame::ScrollByCSSPixelsInternal( + const CSSIntPoint& aDelta, ScrollMode aMode, ScrollSnapFlags aSnapFlags) { nsPoint current = GetScrollPosition(); // `current` value above might be a value which was aligned to in // layer-pixels, so starting from such points will make the difference between @@ -5042,7 +5045,7 @@ void nsHTMLScrollFrame::ScrollByCSSPixelsInternal(const CSSIntPoint& aDelta, // 'this' might be destroyed here } -void nsHTMLScrollFrame::ScrollSnap(ScrollMode aMode) { +void ScrollContainerFrame::ScrollSnap(ScrollMode aMode) { float flingSensitivity = StaticPrefs::layout_css_scroll_snap_prediction_sensitivity(); int maxVelocity = @@ -5059,8 +5062,8 @@ void nsHTMLScrollFrame::ScrollSnap(ScrollMode aMode) { ScrollSnap(destinationPos, aMode); } -void nsHTMLScrollFrame::ScrollSnap(const nsPoint& aDestination, - ScrollMode aMode) { +void ScrollContainerFrame::ScrollSnap(const nsPoint& aDestination, + ScrollMode aMode) { nsRect scrollRange = GetLayoutScrollRange(); nsPoint pos = GetScrollPosition(); nsPoint destination = scrollRange.ClampPoint(aDestination); @@ -5082,7 +5085,7 @@ void nsHTMLScrollFrame::ScrollSnap(const nsPoint& aDestination, } } -nsSize nsHTMLScrollFrame::GetLineScrollAmount() const { +nsSize ScrollContainerFrame::GetLineScrollAmount() const { RefPtr fm = nsLayoutUtils::GetInflatedFontMetricsForFrame(this); NS_ASSERTION(fm, "FontMetrics is null, assuming fontHeight == 1 appunit"); @@ -5193,7 +5196,7 @@ static nsSize GetScrollPortSizeExcludingHeadersAndFooters( return nsSize(aScrollPort.width, footerTop - headerBottom); } -nsSize nsHTMLScrollFrame::GetPageScrollAmount() const { +nsSize ScrollContainerFrame::GetPageScrollAmount() const { nsSize effectiveScrollPortSize; if (GetVisualViewportSize() != mScrollPort.Size()) { @@ -5206,7 +5209,7 @@ nsSize nsHTMLScrollFrame::GetPageScrollAmount() const { // Reduce effective scrollport height by the height of any // fixed-pos/sticky-pos headers or footers effectiveScrollPortSize = GetScrollPortSizeExcludingHeadersAndFooters( - const_cast(this), + const_cast(this), mIsRoot ? PresShell()->GetRootFrame() : nullptr, mScrollPort); } @@ -5233,7 +5236,7 @@ nsSize nsHTMLScrollFrame::GetPageScrollAmount() const { * mind that content could incrementally be coming in. we only want to stop * when we reach our new position. */ -void nsHTMLScrollFrame::ScrollToRestoredPosition() { +void ScrollContainerFrame::ScrollToRestoredPosition() { if (mRestorePos.y == -1 || mLastPos.x == -1 || mLastPos.y == -1) { return; } @@ -5329,7 +5332,7 @@ void nsHTMLScrollFrame::ScrollToRestoredPosition() { } } -auto nsHTMLScrollFrame::GetPageLoadingState() -> LoadingState { +ScrollContainerFrame::LoadingState ScrollContainerFrame::GetPageLoadingState() { bool loadCompleted = false, stopped = false; nsCOMPtr ds = GetContent()->GetComposedDoc()->GetDocShell(); if (ds) { @@ -5345,7 +5348,8 @@ auto nsHTMLScrollFrame::GetPageLoadingState() -> LoadingState { : LoadingState::Loading; } -nsHTMLScrollFrame::OverflowState nsHTMLScrollFrame::GetOverflowState() const { +ScrollContainerFrame::OverflowState ScrollContainerFrame::GetOverflowState() + const { nsSize scrollportSize = mScrollPort.Size(); nsSize childSize = GetScrolledRect().Size(); @@ -5362,7 +5366,7 @@ nsHTMLScrollFrame::OverflowState nsHTMLScrollFrame::GetOverflowState() const { return result; } -nsresult nsHTMLScrollFrame::FireScrollPortEvent() { +nsresult ScrollContainerFrame::FireScrollPortEvent() { mAsyncScrollPortEvent.Forget(); // TODO(emilio): why do we need the whole WillPaintObserver infrastructure and @@ -5420,7 +5424,7 @@ nsresult nsHTMLScrollFrame::FireScrollPortEvent() { return EventDispatcher::Dispatch(content, presContext, &event); } -void nsHTMLScrollFrame::PostScrollEndEvent(bool aDelayed) { +void ScrollContainerFrame::PostScrollEndEvent(bool aDelayed) { if (mScrollEndEvent) { return; } @@ -5429,7 +5433,7 @@ void nsHTMLScrollFrame::PostScrollEndEvent(bool aDelayed) { mScrollEndEvent = new ScrollEndEvent(this, aDelayed); } -void nsHTMLScrollFrame::FireScrollEndEvent() { +void ScrollContainerFrame::FireScrollEndEvent() { RefPtr content = GetContent(); MOZ_ASSERT(content); @@ -5454,7 +5458,7 @@ void nsHTMLScrollFrame::FireScrollEndEvent() { EventDispatcher::Dispatch(target, presContext, &event, nullptr, &status); } -void nsHTMLScrollFrame::ReloadChildFrames() { +void ScrollContainerFrame::ReloadChildFrames() { mScrolledFrame = nullptr; mHScrollbarBox = nullptr; mVScrollbarBox = nullptr; @@ -5495,7 +5499,7 @@ void nsHTMLScrollFrame::ReloadChildFrames() { } } -already_AddRefed nsHTMLScrollFrame::MakeScrollbar( +already_AddRefed ScrollContainerFrame::MakeScrollbar( NodeInfo* aNodeInfo, bool aVertical, AnonymousContentKey& aKey) { MOZ_ASSERT(aNodeInfo); MOZ_ASSERT( @@ -5537,7 +5541,7 @@ already_AddRefed nsHTMLScrollFrame::MakeScrollbar( return e.forget(); } -bool nsHTMLScrollFrame::IsForTextControlWithNoScrollbars() const { +bool ScrollContainerFrame::IsForTextControlWithNoScrollbars() const { // FIXME(emilio): we should probably make the scroller inside an // internal pseudo-element, and then this would be simpler. // @@ -5550,7 +5554,7 @@ bool nsHTMLScrollFrame::IsForTextControlWithNoScrollbars() const { return input && input->IsHTMLElement(nsGkAtoms::input); } -auto nsHTMLScrollFrame::GetCurrentAnonymousContent() const +auto ScrollContainerFrame::GetCurrentAnonymousContent() const -> EnumSet { EnumSet result; if (mHScrollbarContent) { @@ -5565,7 +5569,7 @@ auto nsHTMLScrollFrame::GetCurrentAnonymousContent() const return result; } -auto nsHTMLScrollFrame::GetNeededAnonymousContent() const +auto ScrollContainerFrame::GetNeededAnonymousContent() const -> EnumSet { nsPresContext* pc = PresContext(); @@ -5621,7 +5625,7 @@ auto nsHTMLScrollFrame::GetNeededAnonymousContent() const return result; } -nsresult nsHTMLScrollFrame::CreateAnonymousContent( +nsresult ScrollContainerFrame::CreateAnonymousContent( nsTArray& aElements) { typedef nsIAnonymousContentCreator::ContentInfo ContentInfo; @@ -5726,7 +5730,7 @@ nsresult nsHTMLScrollFrame::CreateAnonymousContent( return NS_OK; } -void nsHTMLScrollFrame::AppendAnonymousContentTo( +void ScrollContainerFrame::AppendAnonymousContentTo( nsTArray& aElements, uint32_t aFilter) { if (mHScrollbarContent) { aElements.AppendElement(mHScrollbarContent); @@ -5745,7 +5749,8 @@ void nsHTMLScrollFrame::AppendAnonymousContentTo( } } -void nsHTMLScrollFrame::DidSetComputedStyle(ComputedStyle* aOldComputedStyle) { +void ScrollContainerFrame::DidSetComputedStyle( + ComputedStyle* aOldComputedStyle) { nsContainerFrame::DidSetComputedStyle(aOldComputedStyle); if (aOldComputedStyle && !mIsRoot && StyleDisplay()->mScrollSnapType != @@ -5754,7 +5759,7 @@ void nsHTMLScrollFrame::DidSetComputedStyle(ComputedStyle* aOldComputedStyle) { } } -void nsHTMLScrollFrame::RemoveObservers() { +void ScrollContainerFrame::RemoveObservers() { if (mAsyncScroll) { mAsyncScroll->RemoveObserver(); mAsyncScroll = nullptr; @@ -5772,7 +5777,7 @@ void nsHTMLScrollFrame::RemoveObservers() { * scrolling, so we need to put the thumb back to its initial position for the * start of the smooth sequence). */ -void nsHTMLScrollFrame::UpdateScrollbarPosition() { +void ScrollContainerFrame::UpdateScrollbarPosition() { AutoWeakFrame weakFrame(this); mFrameIsUpdatingScrollbar = true; @@ -5802,8 +5807,8 @@ void nsHTMLScrollFrame::UpdateScrollbarPosition() { mFrameIsUpdatingScrollbar = false; } -void nsHTMLScrollFrame::CurPosAttributeChangedInternal(nsIContent* aContent, - bool aDoScroll) { +void ScrollContainerFrame::CurPosAttributeChangedInternal(nsIContent* aContent, + bool aDoScroll) { NS_ASSERTION(aContent, "aContent must not be null"); NS_ASSERTION((mHScrollbarBox && mHScrollbarBox->GetContent() == aContent) || (mVScrollbarBox && mVScrollbarBox->GetContent() == aContent), @@ -5879,36 +5884,36 @@ void nsHTMLScrollFrame::CurPosAttributeChangedInternal(nsIContent* aContent, /* ============= Scroll events ========== */ -nsHTMLScrollFrame::ScrollEvent::ScrollEvent(nsHTMLScrollFrame* aHelper, - bool aDelayed) - : Runnable("nsHTMLScrollFrame::ScrollEvent"), mHelper(aHelper) { +ScrollContainerFrame::ScrollEvent::ScrollEvent(ScrollContainerFrame* aHelper, + bool aDelayed) + : Runnable("ScrollContainerFrame::ScrollEvent"), mHelper(aHelper) { mHelper->PresContext()->RefreshDriver()->PostScrollEvent(this, aDelayed); } // TODO: Convert this to MOZ_CAN_RUN_SCRIPT (bug 1415230, bug 1535398) MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHODIMP -nsHTMLScrollFrame::ScrollEvent::Run() { +ScrollContainerFrame::ScrollEvent::Run() { if (mHelper) { mHelper->FireScrollEvent(); } return NS_OK; } -nsHTMLScrollFrame::ScrollEndEvent::ScrollEndEvent(nsHTMLScrollFrame* aHelper, - bool aDelayed) - : Runnable("nsHTMLScrollFrame::ScrollEndEvent"), mHelper(aHelper) { +ScrollContainerFrame::ScrollEndEvent::ScrollEndEvent( + ScrollContainerFrame* aHelper, bool aDelayed) + : Runnable("ScrollContainerFrame::ScrollEndEvent"), mHelper(aHelper) { mHelper->PresContext()->RefreshDriver()->PostScrollEvent(this, aDelayed); } MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHODIMP -nsHTMLScrollFrame::ScrollEndEvent::Run() { +ScrollContainerFrame::ScrollEndEvent::Run() { if (mHelper) { mHelper->FireScrollEndEvent(); } return NS_OK; } -void nsHTMLScrollFrame::FireScrollEvent() { +void ScrollContainerFrame::FireScrollEvent() { RefPtr content = GetContent(); RefPtr presContext = PresContext(); AUTO_PROFILER_TRACING_MARKER_DOCSHELL("Paint", "FireScrollEvent", GRAPHICS, @@ -5957,7 +5962,7 @@ void nsHTMLScrollFrame::FireScrollEvent() { } } -void nsHTMLScrollFrame::PostScrollEvent(bool aDelayed) { +void ScrollContainerFrame::PostScrollEvent(bool aDelayed) { if (mScrollEvent) { return; } @@ -5968,11 +5973,11 @@ void nsHTMLScrollFrame::PostScrollEvent(bool aDelayed) { // TODO: Convert this to MOZ_CAN_RUN_SCRIPT (bug 1415230, bug 1535398) MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHODIMP -nsHTMLScrollFrame::AsyncScrollPortEvent::Run() { +ScrollContainerFrame::AsyncScrollPortEvent::Run() { return mHelper ? mHelper->FireScrollPortEvent() : NS_OK; } -void nsHTMLScrollFrame::PostOverflowEvent() { +void ScrollContainerFrame::PostOverflowEvent() { if (mAsyncScrollPortEvent.IsPending()) { return; } @@ -5998,7 +6003,7 @@ void nsHTMLScrollFrame::PostOverflowEvent() { rpc->AddWillPaintObserver(mAsyncScrollPortEvent.get()); } -nsIFrame* nsHTMLScrollFrame::GetFrameForStyle() const { +nsIFrame* ScrollContainerFrame::GetFrameForStyle() const { nsIFrame* styleFrame = nullptr; if (mIsRoot) { if (const Element* rootElement = @@ -6006,13 +6011,13 @@ nsIFrame* nsHTMLScrollFrame::GetFrameForStyle() const { styleFrame = rootElement->GetPrimaryFrame(); } } else { - styleFrame = const_cast(this); + styleFrame = const_cast(this); } return styleFrame; } -bool nsHTMLScrollFrame::NeedsScrollSnap() const { +bool ScrollContainerFrame::NeedsScrollSnap() const { nsIFrame* scrollSnapFrame = GetFrameForStyle(); if (!scrollSnapFrame) { return false; @@ -6021,14 +6026,14 @@ bool nsHTMLScrollFrame::NeedsScrollSnap() const { StyleScrollSnapStrictness::None; } -nsSize nsHTMLScrollFrame::GetSnapportSize() const { +nsSize ScrollContainerFrame::GetSnapportSize() const { nsRect snapport = GetScrollPortRect(); nsMargin scrollPadding = GetScrollPadding(); snapport.Deflate(scrollPadding); return snapport.Size(); } -bool nsHTMLScrollFrame::IsScrollbarOnRight() const { +bool ScrollContainerFrame::IsScrollbarOnRight() const { // The position of the scrollbar in top-level windows depends on the pref // layout.scrollbar.side. For non-top-level elements, it depends only on the // directionaliy of the element (equivalent to a value of "1" for the pref). @@ -6048,7 +6053,7 @@ bool nsHTMLScrollFrame::IsScrollbarOnRight() const { } } -bool nsHTMLScrollFrame::IsScrollingActive() const { +bool ScrollContainerFrame::IsScrollingActive() const { const nsStyleDisplay* disp = StyleDisplay(); if (disp->mWillChange.bits & StyleWillChangeBits::SCROLL) { return true; @@ -6060,11 +6065,9 @@ bool nsHTMLScrollFrame::IsScrollingActive() const { nsContentUtils::HasScrollgrab(content); } -void nsHTMLScrollFrame::FinishReflowForScrollbar(Element* aElement, - nscoord aMinXY, nscoord aMaxXY, - nscoord aCurPosXY, - nscoord aPageIncrement, - nscoord aIncrement) { +void ScrollContainerFrame::FinishReflowForScrollbar( + Element* aElement, nscoord aMinXY, nscoord aMaxXY, nscoord aCurPosXY, + nscoord aPageIncrement, nscoord aIncrement) { // Scrollbars assume zero is the minimum position, so translate for them. SetCoordAttribute(aElement, nsGkAtoms::curpos, aCurPosXY - aMinXY); SetScrollbarEnabled(aElement, aMaxXY - aMinXY); @@ -6076,14 +6079,13 @@ void nsHTMLScrollFrame::FinishReflowForScrollbar(Element* aElement, class MOZ_RAII AutoMinimumScaleSizeChangeDetector final { public: explicit AutoMinimumScaleSizeChangeDetector( - nsHTMLScrollFrame* ansHTMLScrollFrame) - : mHelper(ansHTMLScrollFrame) { + ScrollContainerFrame* aScrollFrame) + : mHelper(aScrollFrame) { MOZ_ASSERT(mHelper); MOZ_ASSERT(mHelper->mIsRoot); - mPreviousMinimumScaleSize = ansHTMLScrollFrame->mMinimumScaleSize; - mPreviousIsUsingMinimumScaleSize = - ansHTMLScrollFrame->mIsUsingMinimumScaleSize; + mPreviousMinimumScaleSize = aScrollFrame->mMinimumScaleSize; + mPreviousIsUsingMinimumScaleSize = aScrollFrame->mIsUsingMinimumScaleSize; } ~AutoMinimumScaleSizeChangeDetector() { if (mPreviousMinimumScaleSize != mHelper->mMinimumScaleSize || @@ -6093,13 +6095,14 @@ class MOZ_RAII AutoMinimumScaleSizeChangeDetector final { } private: - nsHTMLScrollFrame* mHelper; + ScrollContainerFrame* mHelper; nsSize mPreviousMinimumScaleSize; bool mPreviousIsUsingMinimumScaleSize; }; -nsSize nsHTMLScrollFrame::TrueOuterSize(nsDisplayListBuilder* aBuilder) const { +nsSize ScrollContainerFrame::TrueOuterSize( + nsDisplayListBuilder* aBuilder) const { if (!PresShell()->UsesMobileViewportSizing()) { return GetSize(); } @@ -6126,7 +6129,7 @@ nsSize nsHTMLScrollFrame::TrueOuterSize(nsDisplayListBuilder* aBuilder) const { PresContext()->AppUnitsPerDevPixel()); } -void nsHTMLScrollFrame::UpdateMinimumScaleSize( +void ScrollContainerFrame::UpdateMinimumScaleSize( const nsRect& aScrollableOverflow, const nsSize& aICBSize) { MOZ_ASSERT(mIsRoot); @@ -6195,7 +6198,7 @@ void nsHTMLScrollFrame::UpdateMinimumScaleSize( mIsUsingMinimumScaleSize = true; } -bool nsHTMLScrollFrame::ReflowFinished() { +bool ScrollContainerFrame::ReflowFinished() { mPostedReflowCallback = false; TryScheduleScrollAnimations(); @@ -6252,13 +6255,13 @@ bool nsHTMLScrollFrame::ReflowFinished() { // scroll position by the end of the reflow, but without going through // RestoreState. In particular this can happen with RTL XUL scrollframes, // see https://bugzilla.mozilla.org/show_bug.cgi?id=1664638#c14. - // Upon construction, the nsHTMLScrollFrame constructor will have inserted - // a ScrollPositionUpdate into mScrollUpdates with origin None and a zero - // scroll position, but here we update that to hold the correct scroll - // position. Otherwise APZ may end up resetting the scroll position to - // zero incorrectly. If we ever hit this codepath, it must be on a reflow - // immediately following the scrollframe construction, so there should be - // exactly one ScrollPositionUpdate in mScrollUpdates. + // Upon construction, the ScrollContainerFrame constructor will have + // inserted a ScrollPositionUpdate into mScrollUpdates with origin None + // and a zero scroll position, but here we update that to hold the correct + // scroll position. Otherwise APZ may end up resetting the scroll position + // to zero incorrectly. If we ever hit this codepath, it must be on a + // reflow immediately following the scrollframe construction, so there + // should be exactly one ScrollPositionUpdate in mScrollUpdates. MOZ_ASSERT(mScrollUpdates.Length() == 1); MOZ_ASSERT(mScrollUpdates.LastElement().GetGeneration() == mScrollGeneration); @@ -6396,11 +6399,12 @@ bool nsHTMLScrollFrame::ReflowFinished() { return doScroll; } -void nsHTMLScrollFrame::ReflowCallbackCanceled() { +void ScrollContainerFrame::ReflowCallbackCanceled() { mPostedReflowCallback = false; } -bool nsHTMLScrollFrame::ComputeCustomOverflow(OverflowAreas& aOverflowAreas) { +bool ScrollContainerFrame::ComputeCustomOverflow( + OverflowAreas& aOverflowAreas) { ScrollStyles ss = GetScrollStyles(); // Reflow when the change in overflow leads to one of our scrollbars @@ -6432,7 +6436,7 @@ bool nsHTMLScrollFrame::ComputeCustomOverflow(OverflowAreas& aOverflowAreas) { // have to do that here. Only this frame needs to be reflowed. PresShell()->FrameNeedsReflow(this, IntrinsicDirty::None, NS_FRAME_HAS_DIRTY_CHILDREN); - // Ensure that next time nsHTMLScrollFrame::Reflow runs, we don't skip + // Ensure that next time ScrollContainerFrame::Reflow runs, we don't skip // updating the scrollbars. (Because the overflow area of the scrolled // frame has probably just been updated, Reflow won't see it change.) mSkippedScrollbarLayout = true; @@ -6442,7 +6446,7 @@ bool nsHTMLScrollFrame::ComputeCustomOverflow(OverflowAreas& aOverflowAreas) { return nsContainerFrame::ComputeCustomOverflow(aOverflowAreas); } -void nsHTMLScrollFrame::UpdateSticky() { +void ScrollContainerFrame::UpdateSticky() { StickyScrollContainer* ssc = StickyScrollContainer::GetStickyScrollContainerForScrollFrame(this); if (ssc) { @@ -6450,7 +6454,7 @@ void nsHTMLScrollFrame::UpdateSticky() { } } -void nsHTMLScrollFrame::UpdatePrevScrolledRect() { +void ScrollContainerFrame::UpdatePrevScrolledRect() { // The layout scroll range is determinated by the scrolled rect and the scroll // port, so if the scrolled rect is updated, we may have to schedule the // associated scroll-driven animations' restyles. @@ -6461,7 +6465,7 @@ void nsHTMLScrollFrame::UpdatePrevScrolledRect() { mPrevScrolledRect = currScrolledRect; } -void nsHTMLScrollFrame::AdjustScrollbarRectForResizer( +void ScrollContainerFrame::AdjustScrollbarRectForResizer( nsIFrame* aFrame, nsPresContext* aPresContext, nsRect& aRect, bool aHasResizer, ScrollDirection aDirection) { if ((aDirection == ScrollDirection::eVertical ? aRect.width : aRect.height) == @@ -6530,7 +6534,7 @@ static void AdjustOverlappingScrollbars(nsRect& aVRect, nsRect& aHRect) { } } -void nsHTMLScrollFrame::LayoutScrollbarPartAtRect( +void ScrollContainerFrame::LayoutScrollbarPartAtRect( const ScrollReflowInput& aState, ReflowInput& aKidReflowInput, const nsRect& aRect) { nsPresContext* pc = PresContext(); @@ -6557,9 +6561,9 @@ void nsHTMLScrollFrame::LayoutScrollbarPartAtRect( containerSize, flags); } -void nsHTMLScrollFrame::LayoutScrollbars(ScrollReflowInput& aState, - const nsRect& aInsideBorderArea, - const nsRect& aOldScrollPort) { +void ScrollContainerFrame::LayoutScrollbars(ScrollReflowInput& aState, + const nsRect& aInsideBorderArea, + const nsRect& aOldScrollPort) { NS_ASSERTION(!mSuppressScrollbarUpdate, "This should have been suppressed"); const bool scrollbarOnLeft = !IsScrollbarOnRight(); @@ -6742,8 +6746,8 @@ static bool ShellIsAlive(nsWeakPtr& aWeakPtr) { } #endif -void nsHTMLScrollFrame::SetScrollbarEnabled(Element* aElement, - nscoord aMaxPos) { +void ScrollContainerFrame::SetScrollbarEnabled(Element* aElement, + nscoord aMaxPos) { DebugOnly weakShell(do_GetWeakReference(PresShell())); if (aMaxPos) { aElement->UnsetAttr(kNameSpaceID_None, nsGkAtoms::disabled, true); @@ -6753,8 +6757,8 @@ void nsHTMLScrollFrame::SetScrollbarEnabled(Element* aElement, MOZ_ASSERT(ShellIsAlive(weakShell), "pres shell was destroyed by scrolling"); } -void nsHTMLScrollFrame::SetCoordAttribute(Element* aElement, nsAtom* aAtom, - nscoord aSize) { +void ScrollContainerFrame::SetCoordAttribute(Element* aElement, nsAtom* aAtom, + nscoord aSize) { DebugOnly weakShell(do_GetWeakReference(PresShell())); // convert to pixels int32_t pixelSize = nsPresContext::AppUnitsToIntCSSPixels(aSize); @@ -6804,10 +6808,10 @@ static void ReduceRadii(nscoord aXBorder, nscoord aYBorder, nscoord& aXRadius, * inner border radius at the inner edge of the border is 0 wherever we * have scrollbars. */ -bool nsHTMLScrollFrame::GetBorderRadii(const nsSize& aFrameSize, - const nsSize& aBorderArea, - Sides aSkipSides, - nscoord aRadii[8]) const { +bool ScrollContainerFrame::GetBorderRadii(const nsSize& aFrameSize, + const nsSize& aBorderArea, + Sides aSkipSides, + nscoord aRadii[8]) const { if (!nsContainerFrame::GetBorderRadii(aFrameSize, aBorderArea, aSkipSides, aRadii)) { return false; @@ -6852,7 +6856,7 @@ static nscoord SnapCoord(nscoord aCoord, double aRes, aRes); } -nsRect nsHTMLScrollFrame::GetScrolledRect() const { +nsRect ScrollContainerFrame::GetScrolledRect() const { nsRect result = GetUnsnappedScrolledRectInternal( mScrolledFrame->ScrollableOverflowRect(), mScrollPort.Size()); @@ -6879,9 +6883,10 @@ nsRect nsHTMLScrollFrame::GetScrolledRect() const { // snapping. nsSize visualViewportSize = GetVisualViewportSize(); const nsIFrame* referenceFrame = - mReferenceFrameDuringPainting ? mReferenceFrameDuringPainting - : nsLayoutUtils::GetReferenceFrame( - const_cast(this)); + mReferenceFrameDuringPainting + ? mReferenceFrameDuringPainting + : nsLayoutUtils::GetReferenceFrame( + const_cast(this)); nsPoint toReferenceFrame = GetOffsetToCrossDoc(referenceFrame); nsRect scrollPort(mScrollPort.TopLeft() + toReferenceFrame, visualViewportSize); @@ -6936,7 +6941,7 @@ nsRect nsHTMLScrollFrame::GetScrolledRect() const { return result; } -StyleDirection nsHTMLScrollFrame::GetScrolledFrameDir() const { +StyleDirection ScrollContainerFrame::GetScrolledFrameDir() const { // If the scrolled frame has unicode-bidi: plaintext, the paragraph // direction set by the text content overrides the direction of the frame if (mScrolledFrame->StyleTextReset()->mUnicodeBidi == @@ -6951,13 +6956,13 @@ StyleDirection nsHTMLScrollFrame::GetScrolledFrameDir() const { return IsBidiLTR() ? StyleDirection::Ltr : StyleDirection::Rtl; } -nsRect nsHTMLScrollFrame::GetUnsnappedScrolledRectInternal( +nsRect ScrollContainerFrame::GetUnsnappedScrolledRectInternal( const nsRect& aScrolledOverflowArea, const nsSize& aScrollPortSize) const { return nsLayoutUtils::GetScrolledRect(mScrolledFrame, aScrolledOverflowArea, aScrollPortSize, GetScrolledFrameDir()); } -nsMargin nsHTMLScrollFrame::GetActualScrollbarSizes( +nsMargin ScrollContainerFrame::GetActualScrollbarSizes( nsIScrollableFrame::ScrollbarSizesOptions aOptions /* = nsIScrollableFrame::ScrollbarSizesOptions::NONE */) const { @@ -6991,8 +6996,8 @@ nsMargin nsHTMLScrollFrame::GetActualScrollbarSizes( return m; } -void nsHTMLScrollFrame::SetScrollbarVisibility(nsIFrame* aScrollbar, - bool aVisible) { +void ScrollContainerFrame::SetScrollbarVisibility(nsIFrame* aScrollbar, + bool aVisible) { nsScrollbarFrame* scrollbar = do_QueryFrame(aScrollbar); if (scrollbar) { // See if we have a mediator. @@ -7004,10 +7009,10 @@ void nsHTMLScrollFrame::SetScrollbarVisibility(nsIFrame* aScrollbar, } } -nscoord nsHTMLScrollFrame::GetCoordAttribute(nsIFrame* aBox, nsAtom* aAtom, - nscoord aDefaultValue, - nscoord* aRangeStart, - nscoord* aRangeLength) { +nscoord ScrollContainerFrame::GetCoordAttribute(nsIFrame* aBox, nsAtom* aAtom, + nscoord aDefaultValue, + nscoord* aRangeStart, + nscoord* aRangeLength) { if (aBox) { nsIContent* content = aBox->GetContent(); @@ -7035,7 +7040,7 @@ nscoord nsHTMLScrollFrame::GetCoordAttribute(nsIFrame* aBox, nsAtom* aAtom, return aDefaultValue; } -bool nsHTMLScrollFrame::IsLastScrollUpdateAnimating() const { +bool ScrollContainerFrame::IsLastScrollUpdateAnimating() const { if (!mScrollUpdates.IsEmpty()) { switch (mScrollUpdates.LastElement().GetMode()) { case ScrollMode::Smooth: @@ -7049,7 +7054,8 @@ bool nsHTMLScrollFrame::IsLastScrollUpdateAnimating() const { return false; } -bool nsHTMLScrollFrame::IsLastScrollUpdateTriggeredByScriptAnimating() const { +bool ScrollContainerFrame::IsLastScrollUpdateTriggeredByScriptAnimating() + const { if (!mScrollUpdates.IsEmpty()) { const ScrollPositionUpdate& lastUpdate = mScrollUpdates.LastElement(); if (lastUpdate.WasTriggeredByScript() && @@ -7062,7 +7068,7 @@ bool nsHTMLScrollFrame::IsLastScrollUpdateTriggeredByScriptAnimating() const { } using AnimationState = nsIScrollableFrame::AnimationState; -EnumSet nsHTMLScrollFrame::ScrollAnimationState() const { +EnumSet ScrollContainerFrame::ScrollAnimationState() const { EnumSet retval; if (IsApzAnimationInProgress()) { retval += AnimationState::APZInProgress; @@ -7101,7 +7107,7 @@ EnumSet nsHTMLScrollFrame::ScrollAnimationState() const { return retval; } -void nsHTMLScrollFrame::ResetScrollInfoIfNeeded( +void ScrollContainerFrame::ResetScrollInfoIfNeeded( const MainThreadScrollGeneration& aGeneration, const APZScrollGeneration& aGenerationOnApz, APZScrollAnimationType aAPZScrollAnimationType, @@ -7120,7 +7126,7 @@ void nsHTMLScrollFrame::ResetScrollInfoIfNeeded( mInScrollingGesture = aInScrollingGesture; } -UniquePtr nsHTMLScrollFrame::SaveState() { +UniquePtr ScrollContainerFrame::SaveState() { nsIScrollbarMediator* mediator = do_QueryFrame(GetScrolledFrame()); if (mediator) { // child handles its own scroll state, so don't bother saving state here @@ -7171,7 +7177,7 @@ UniquePtr nsHTMLScrollFrame::SaveState() { return state; } -NS_IMETHODIMP nsHTMLScrollFrame::RestoreState(PresState* aState) { +NS_IMETHODIMP ScrollContainerFrame::RestoreState(PresState* aState) { mRestorePos = aState->scrollState(); MOZ_ASSERT(mLastScrollOrigin == ScrollOrigin::None); mAllowScrollOriginDowngrade = aState->allowScrollOriginDowngrade(); @@ -7200,7 +7206,7 @@ NS_IMETHODIMP nsHTMLScrollFrame::RestoreState(PresState* aState) { return NS_OK; } -void nsHTMLScrollFrame::PostScrolledAreaEvent() { +void ScrollContainerFrame::PostScrolledAreaEvent() { if (mScrolledAreaEvent.IsPending()) { return; } @@ -7213,14 +7219,14 @@ void nsHTMLScrollFrame::PostScrolledAreaEvent() { // TODO: Convert this to MOZ_CAN_RUN_SCRIPT (bug 1415230, bug 1535398) MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHODIMP -nsHTMLScrollFrame::ScrolledAreaEvent::Run() { +ScrollContainerFrame::ScrolledAreaEvent::Run() { if (mHelper) { mHelper->FireScrolledAreaEvent(); } return NS_OK; } -void nsHTMLScrollFrame::FireScrolledAreaEvent() { +void ScrollContainerFrame::FireScrolledAreaEvent() { mScrolledAreaEvent.Forget(); InternalScrollAreaEvent event(true, eScrolledAreaChanged, nullptr); @@ -7247,7 +7253,7 @@ ScrollDirections nsIScrollableFrame::GetAvailableScrollingDirections() const { return directions; } -nsRect nsHTMLScrollFrame::GetScrollRangeForUserInputEvents() const { +nsRect ScrollContainerFrame::GetScrollRangeForUserInputEvents() const { // This function computes a scroll range based on a scrolled rect and scroll // port defined as follows: // scrollable rect = overflow:hidden ? layout viewport : scrollable rect @@ -7280,7 +7286,8 @@ nsRect nsHTMLScrollFrame::GetScrollRangeForUserInputEvents() const { } ScrollDirections -nsHTMLScrollFrame::GetAvailableScrollingDirectionsForUserInputEvents() const { +ScrollContainerFrame::GetAvailableScrollingDirectionsForUserInputEvents() + const { nsRect scrollRange = GetScrollRangeForUserInputEvents(); // We check if there is at least one half of a screen pixel of scroll range to @@ -7310,7 +7317,8 @@ static void AppendScrollPositionsForSnap( const nsIFrame* aFrame, const nsIFrame* aScrolledFrame, const nsRect& aScrolledRect, const nsMargin& aScrollPadding, const nsRect& aScrollRange, WritingMode aWritingModeOnScroller, - ScrollSnapInfo& aSnapInfo, nsHTMLScrollFrame::SnapTargetSet* aSnapTargets) { + ScrollSnapInfo& aSnapInfo, + ScrollContainerFrame::SnapTargetSet* aSnapTargets) { ScrollSnapTargetId targetId = ScrollSnapUtils::GetTargetIdFor(aFrame); nsRect snapArea = @@ -7461,7 +7469,7 @@ static void CollectScrollPositionsForSnap( nsIFrame* aFrame, nsIFrame* aScrolledFrame, const nsRect& aScrolledRect, const nsMargin& aScrollPadding, const nsRect& aScrollRange, WritingMode aWritingModeOnScroller, ScrollSnapInfo& aSnapInfo, - nsHTMLScrollFrame::SnapTargetSet* aSnapTargets) { + ScrollContainerFrame::SnapTargetSet* aSnapTargets) { // Snap positions only affect the nearest ancestor scroll container on the // element's containing block chain. nsIScrollableFrame* sf = do_QueryFrame(aFrame); @@ -7526,7 +7534,7 @@ static nsMargin ResolveScrollPaddingStyle( aScrollPortSize)); } -nsMargin nsHTMLScrollFrame::GetScrollPadding() const { +nsMargin ScrollContainerFrame::GetScrollPadding() const { nsIFrame* styleFrame = GetFrameForStyle(); if (!styleFrame) { return nsMargin(); @@ -7538,7 +7546,7 @@ nsMargin nsHTMLScrollFrame::GetScrollPadding() const { GetScrollPortRect().Size()); } -ScrollSnapInfo nsHTMLScrollFrame::ComputeScrollSnapInfo() { +ScrollSnapInfo ScrollContainerFrame::ComputeScrollSnapInfo() { ScrollSnapInfo result; nsIFrame* scrollSnapFrame = GetFrameForStyle(); @@ -7562,12 +7570,12 @@ ScrollSnapInfo nsHTMLScrollFrame::ComputeScrollSnapInfo() { return result; } -ScrollSnapInfo nsHTMLScrollFrame::GetScrollSnapInfo() { +ScrollSnapInfo ScrollContainerFrame::GetScrollSnapInfo() { // TODO(botond): Should we cache it? return ComputeScrollSnapInfo(); } -Maybe nsHTMLScrollFrame::GetSnapPointForDestination( +Maybe ScrollContainerFrame::GetSnapPointForDestination( ScrollUnit aUnit, ScrollSnapFlags aFlags, const nsPoint& aStartPos, const nsPoint& aDestination) { // We can release the strong references for the previous snap target @@ -7581,7 +7589,7 @@ Maybe nsHTMLScrollFrame::GetSnapPointForDestination( aDestination); } -Maybe nsHTMLScrollFrame::GetSnapPointForResnap() { +Maybe ScrollContainerFrame::GetSnapPointForResnap() { // Same as in GetSnapPointForDestination, We can release the strong references // for the previous snap targets here. mSnapTargets.Clear(); @@ -7592,7 +7600,7 @@ Maybe nsHTMLScrollFrame::GetSnapPointForResnap() { mLastSnapTargetIds, focusedContent); } -bool nsHTMLScrollFrame::NeedsResnap() { +bool ScrollContainerFrame::NeedsResnap() { nsIContent* focusedContent = GetContent()->GetComposedDoc()->GetUnretargetedFocusedContent(); return ScrollSnapUtils::GetSnapPointForResnap( @@ -7601,7 +7609,7 @@ bool nsHTMLScrollFrame::NeedsResnap() { .isSome(); } -void nsHTMLScrollFrame::SetLastSnapTargetIds( +void ScrollContainerFrame::SetLastSnapTargetIds( UniquePtr aIds) { if (!aIds) { mLastSnapTargetIds = nullptr; @@ -7628,7 +7636,7 @@ void nsHTMLScrollFrame::SetLastSnapTargetIds( mLastSnapTargetIds = std::move(aIds); } -bool nsHTMLScrollFrame::IsLastSnappedTarget(const nsIFrame* aFrame) const { +bool ScrollContainerFrame::IsLastSnappedTarget(const nsIFrame* aFrame) const { ScrollSnapTargetId id = ScrollSnapUtils::GetTargetIdFor(aFrame); MOZ_ASSERT(id != ScrollSnapTargetId::None, "This function is supposed to be called for contents"); @@ -7641,7 +7649,7 @@ bool nsHTMLScrollFrame::IsLastSnappedTarget(const nsIFrame* aFrame) const { mLastSnapTargetIds->mIdsOnY.Contains(id); } -void nsHTMLScrollFrame::TryResnap() { +void ScrollContainerFrame::TryResnap() { // If there's any async scroll is running or we are processing pan/touch // gestures or scroll thumb dragging, don't clobber the scroll. if (!ScrollAnimationState().isEmpty() || @@ -7663,7 +7671,7 @@ void nsHTMLScrollFrame::TryResnap() { } } -void nsHTMLScrollFrame::PostPendingResnapIfNeeded(const nsIFrame* aFrame) { +void ScrollContainerFrame::PostPendingResnapIfNeeded(const nsIFrame* aFrame) { if (!IsLastSnappedTarget(aFrame)) { return; } @@ -7671,12 +7679,12 @@ void nsHTMLScrollFrame::PostPendingResnapIfNeeded(const nsIFrame* aFrame) { PostPendingResnap(); } -void nsHTMLScrollFrame::PostPendingResnap() { +void ScrollContainerFrame::PostPendingResnap() { PresShell()->PostPendingScrollResnap(this); } nsIScrollableFrame::PhysicalScrollSnapAlign -nsHTMLScrollFrame::GetScrollSnapAlignFor(const nsIFrame* aFrame) const { +ScrollContainerFrame::GetScrollSnapAlignFor(const nsIFrame* aFrame) const { StyleScrollSnapAlignKeyword alignForY = StyleScrollSnapAlignKeyword::None; StyleScrollSnapAlignKeyword alignForX = StyleScrollSnapAlignKeyword::None; @@ -7746,11 +7754,11 @@ nsHTMLScrollFrame::GetScrollSnapAlignFor(const nsIFrame* aFrame) const { return {alignForX, alignForY}; } -bool nsHTMLScrollFrame::UsesOverlayScrollbars() const { +bool ScrollContainerFrame::UsesOverlayScrollbars() const { return PresContext()->UseOverlayScrollbars(); } -bool nsHTMLScrollFrame::DragScroll(WidgetEvent* aEvent) { +bool ScrollContainerFrame::DragScroll(WidgetEvent* aEvent) { // Dragging is allowed while within a 20 pixel border. Note that device pixels // are used so that the same margin is used even when zoomed in or out. nscoord margin = 20 * PresContext()->AppUnitsPerDevPixel(); @@ -7832,7 +7840,7 @@ static void AsyncScrollbarDragInitiated(uint64_t aDragBlockId, } } -void nsHTMLScrollFrame::AsyncScrollbarDragInitiated( +void ScrollContainerFrame::AsyncScrollbarDragInitiated( uint64_t aDragBlockId, ScrollDirection aDirection) { switch (aDirection) { case ScrollDirection::eVertical: @@ -7850,14 +7858,14 @@ static void AsyncScrollbarDragRejected(nsIFrame* aScrollbar) { } } -void nsHTMLScrollFrame::AsyncScrollbarDragRejected() { +void ScrollContainerFrame::AsyncScrollbarDragRejected() { // We don't get told which scrollbar requested the async drag, // so we notify both. ::AsyncScrollbarDragRejected(mHScrollbarBox); ::AsyncScrollbarDragRejected(mVScrollbarBox); } -void nsHTMLScrollFrame::ApzSmoothScrollTo( +void ScrollContainerFrame::ApzSmoothScrollTo( const nsPoint& aDestination, ScrollMode aMode, ScrollOrigin aOrigin, ScrollTriggeredByScript aTriggeredByScript, UniquePtr aSnapTargetIds) { @@ -7912,7 +7920,7 @@ void nsHTMLScrollFrame::ApzSmoothScrollTo( SchedulePaint(); } -bool nsHTMLScrollFrame::CanApzScrollInTheseDirections( +bool ScrollContainerFrame::CanApzScrollInTheseDirections( ScrollDirections aDirections) { ScrollStyles styles = GetScrollStyles(); if (aDirections.contains(ScrollDirection::eHorizontal) && @@ -7924,7 +7932,7 @@ bool nsHTMLScrollFrame::CanApzScrollInTheseDirections( return true; } -bool nsHTMLScrollFrame::SmoothScrollVisual( +bool ScrollContainerFrame::SmoothScrollVisual( const nsPoint& aVisualViewportOffset, FrameMetrics::ScrollOffsetUpdateType aUpdateType) { bool canDoApzSmoothScroll = @@ -7956,7 +7964,7 @@ bool nsHTMLScrollFrame::SmoothScrollVisual( return true; } -bool nsHTMLScrollFrame::IsSmoothScroll(dom::ScrollBehavior aBehavior) const { +bool ScrollContainerFrame::IsSmoothScroll(dom::ScrollBehavior aBehavior) const { if (aBehavior == dom::ScrollBehavior::Instant) { return false; } @@ -7989,17 +7997,17 @@ bool nsHTMLScrollFrame::IsSmoothScroll(dom::ScrollBehavior aBehavior) const { StyleScrollBehavior::Smooth); } -nsTArray nsHTMLScrollFrame::GetScrollUpdates() const { +nsTArray ScrollContainerFrame::GetScrollUpdates() const { return mScrollUpdates.Clone(); } -void nsHTMLScrollFrame::AppendScrollUpdate( +void ScrollContainerFrame::AppendScrollUpdate( const ScrollPositionUpdate& aUpdate) { mScrollGeneration = aUpdate.GetGeneration(); mScrollUpdates.AppendElement(aUpdate); } -void nsHTMLScrollFrame::ScheduleScrollAnimations() { +void ScrollContainerFrame::ScheduleScrollAnimations() { nsIContent* content = GetContent(); MOZ_ASSERT(content && content->IsElement(), "The nsIScrollableFrame should have the element."); diff --git a/layout/generic/ScrollContainerFrame.h b/layout/generic/ScrollContainerFrame.h index 411fb3bf01d9..fd47ea70fd05 100644 --- a/layout/generic/ScrollContainerFrame.h +++ b/layout/generic/ScrollContainerFrame.h @@ -35,6 +35,7 @@ class AutoContainsBlendModeCapturer; namespace mozilla { class PresShell; enum class StyleScrollbarWidth : uint8_t; +class ScrollContainerFrame; struct ScrollReflowInput; struct StyleScrollSnapAlign; namespace layers { @@ -47,6 +48,12 @@ class ScrollbarActivity; } // namespace mozilla +mozilla::ScrollContainerFrame* NS_NewScrollContainerFrame( + mozilla::PresShell* aPresShell, mozilla::ComputedStyle* aStyle, + bool aIsRoot); + +namespace mozilla { + /** * The scroll frame creates and manages the scrolling view * @@ -56,11 +63,11 @@ class ScrollbarActivity; * Scroll frames don't support incremental changes, i.e. you can't replace * or remove the scrolled frame */ -class nsHTMLScrollFrame : public nsContainerFrame, - public nsIScrollableFrame, - public nsIAnonymousContentCreator, - public nsIReflowCallback, - public nsIStatefulFrame { +class ScrollContainerFrame : public nsContainerFrame, + public nsIScrollableFrame, + public nsIAnonymousContentCreator, + public nsIReflowCallback, + public nsIStatefulFrame { public: using Sides = nsIFrame::Sides; using ScrollbarActivity = mozilla::layout::ScrollbarActivity; @@ -82,12 +89,13 @@ class nsHTMLScrollFrame : public nsContainerFrame, using CSSPoint = mozilla::CSSPoint; using ScrollReflowInput = mozilla::ScrollReflowInput; using ScrollAnchorContainer = mozilla::layout::ScrollAnchorContainer; - friend nsHTMLScrollFrame* NS_NewHTMLScrollFrame( + + friend ScrollContainerFrame* ::NS_NewScrollContainerFrame( mozilla::PresShell* aPresShell, ComputedStyle* aStyle, bool aIsRoot); friend class mozilla::layout::ScrollAnchorContainer; NS_DECL_QUERYFRAME - NS_DECL_FRAMEARENA_HELPERS(nsHTMLScrollFrame) + NS_DECL_FRAMEARENA_HELPERS(ScrollContainerFrame) void BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) override; @@ -170,7 +178,7 @@ class nsHTMLScrollFrame : public nsContainerFrame, void Destroy(DestroyContext&) override; nsIScrollableFrame* GetScrollTargetFrame() const final { - return const_cast(this); + return const_cast(this); } nsContainerFrame* GetContentInsertionFrame() override { @@ -445,12 +453,12 @@ class nsHTMLScrollFrame : public nsContainerFrame, #endif protected: - nsHTMLScrollFrame(ComputedStyle* aStyle, nsPresContext* aPresContext, - bool aIsRoot) - : nsHTMLScrollFrame(aStyle, aPresContext, kClassID, aIsRoot) {} - nsHTMLScrollFrame(ComputedStyle* aStyle, nsPresContext* aPresContext, - nsIFrame::ClassID aID, bool aIsRoot); - ~nsHTMLScrollFrame(); + ScrollContainerFrame(ComputedStyle* aStyle, nsPresContext* aPresContext, + bool aIsRoot) + : ScrollContainerFrame(aStyle, aPresContext, kClassID, aIsRoot) {} + ScrollContainerFrame(ComputedStyle* aStyle, nsPresContext* aPresContext, + nsIFrame::ClassID aID, bool aIsRoot); + ~ScrollContainerFrame(); void SetSuppressScrollbarUpdate(bool aSuppress) { mSuppressScrollbarUpdate = aSuppress; } @@ -602,9 +610,9 @@ class nsHTMLScrollFrame : public nsContainerFrame, bool IsProcessingScrollEvent() const { return mProcessingScrollEvent; } public: - static void AsyncScrollCallback(nsHTMLScrollFrame* aInstance, + static void AsyncScrollCallback(ScrollContainerFrame* aInstance, mozilla::TimeStamp aTime); - static void AsyncSmoothMSDScrollCallback(nsHTMLScrollFrame* aInstance, + static void AsyncSmoothMSDScrollCallback(ScrollContainerFrame* aInstance, mozilla::TimeDuration aDeltaTime); /** * @note This method might destroy the frame, pres shell and other objects. @@ -664,8 +672,8 @@ class nsHTMLScrollFrame : public nsContainerFrame, * behavior. * * Currently it allows scrolling down and to the right for - * nsHTMLScrollFrames with LTR directionality, and allows scrolling down and - * to the left for nsHTMLScrollFrames with RTL directionality. + * ScrollContainerFrames with LTR directionality, and allows scrolling down + * and to the left for ScrollContainerFrames with RTL directionality. */ nsRect GetUnsnappedScrolledRectInternal(const nsRect& aScrolledOverflowArea, const nsSize& aScrollPortSize) const; @@ -995,7 +1003,7 @@ class nsHTMLScrollFrame : public nsContainerFrame, friend class AutoScrollbarRepaintSuppression; class AutoScrollbarRepaintSuppression { public: - AutoScrollbarRepaintSuppression(nsHTMLScrollFrame* aFrame, + AutoScrollbarRepaintSuppression(ScrollContainerFrame* aFrame, AutoWeakFrame& aWeakOuter, bool aSuppress) : mFrame(aFrame), mWeakOuter(aWeakOuter), @@ -1010,7 +1018,7 @@ class nsHTMLScrollFrame : public nsContainerFrame, } private: - nsHTMLScrollFrame* mFrame; + ScrollContainerFrame* mFrame; AutoWeakFrame& mWeakOuter; bool mOldSuppressValue; }; @@ -1091,6 +1099,8 @@ class nsHTMLScrollFrame : public nsContainerFrame, mozilla::UniquePtr mLastSnapTargetIds; }; -MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(nsHTMLScrollFrame::OverflowState) +MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(ScrollContainerFrame::OverflowState) + +} // namespace mozilla #endif /* mozilla_ScrollContainerFrame_h_ */ diff --git a/layout/generic/nsGridContainerFrame.cpp b/layout/generic/nsGridContainerFrame.cpp index e69b8fd1c533..ea9b4802539c 100644 --- a/layout/generic/nsGridContainerFrame.cpp +++ b/layout/generic/nsGridContainerFrame.cpp @@ -3695,7 +3695,7 @@ static Subgrid* SubgridComputeMarginBorderPadding( bool scroller = false; nsIFrame* outerFrame = [&]() -> nsIFrame* { - if (nsHTMLScrollFrame* scrollFrame = + if (ScrollContainerFrame* scrollFrame = do_QueryFrame(aGridItem.mFrame->GetScrollTargetFrame())) { scroller = true; return scrollFrame; @@ -3720,7 +3720,7 @@ static Subgrid* SubgridComputeMarginBorderPadding( subgrid->mMarginBorderPadding += szOuterFrame.ComputedLogicalMargin(cbWM) + szOuterFrame.ComputedLogicalBorder(cbWM); if (scroller) { - nsMargin ssz = static_cast(outerFrame) + nsMargin ssz = static_cast(outerFrame) ->IntrinsicScrollbarGutterSize(); subgrid->mMarginBorderPadding += LogicalMargin(cbWM, ssz); } else { diff --git a/layout/generic/nsIFrame.cpp b/layout/generic/nsIFrame.cpp index ffb1e1cf59e5..f3cf5efc4f81 100644 --- a/layout/generic/nsIFrame.cpp +++ b/layout/generic/nsIFrame.cpp @@ -3219,8 +3219,8 @@ void nsIFrame::BuildDisplayListForStackingContext( AutoSaveRestoreContainsBlendMode autoRestoreBlendMode(*aBuilder); aBuilder->SetContainsBlendMode(false); - // NOTE: When changing this condition make sure to tweak nsGfxScrollFrame as - // well. + // NOTE: When changing this condition make sure to tweak ScrollContainerFrame + // as well. bool usingBackdropFilter = effects->HasBackdropFilters() && IsVisibleForPainting() && !style.IsRootElementStyle(); @@ -11579,7 +11579,7 @@ nsIFrame::PhysicalAxes nsIFrame::ShouldApplyOverflowClipping( } // clip overflow:clip, except for nsListControlFrame which is - // an nsHTMLScrollFrame sub-class. + // a ScrollContainerFrame sub-class. if (MOZ_UNLIKELY((aDisp->mOverflowX == mozilla::StyleOverflow::Clip || aDisp->mOverflowY == mozilla::StyleOverflow::Clip) && !IsListControlFrame())) { diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index 801e80c7e05c..536e584e995e 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -991,7 +991,7 @@ class nsIFrame : public nsQueryFrame { * from the parent. * (@see nsIFrame::Init) * * a scrolled frame propagates its value to its ancestor scroll frame - * (@see nsHTMLScrollFrame::ReloadChildFrames) + * (@see ScrollContainerFrame::ReloadChildFrames) */ mozilla::WritingMode GetWritingMode() const { return mWritingMode; } diff --git a/layout/generic/nsIScrollableFrame.h b/layout/generic/nsIScrollableFrame.h index 8d8f20030e05..ab67edb358b7 100644 --- a/layout/generic/nsIScrollableFrame.h +++ b/layout/generic/nsIScrollableFrame.h @@ -152,8 +152,8 @@ class nsIScrollableFrame : public nsIScrollbarMediator { * reflowed with the scroll port size given in mScrollPort. * * Currently it allows scrolling down and to the right for - * nsHTMLScrollFrames with LTR directionality, and allows scrolling down and - * to the left for nsHTMLScrollFrames with RTL directionality. + * ScrollContainerFrames with LTR directionality, and allows scrolling down + * and to the left for ScrollContainerFrames with RTL directionality. */ virtual nsRect GetScrolledRect() const = 0; /** diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 94d120e378b5..d3a14d63cf2e 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -2332,7 +2332,7 @@ nsChangeHint nsStyleDisplay::CalcDifference( } else if (isScrollable) { if (ScrollbarGenerationChanged(*this, aNewData)) { // We might need to reframe in the case of hidden -> non-hidden case - // though, since nsHTMLScrollFrame::CreateAnonymousContent avoids + // though, since ScrollContainerFrame::CreateAnonymousContent avoids // creating scrollbars altogether for overflow: hidden. That seems it // could create some interesting perf cliffs... hint |= nsChangeHint_ScrollbarChange; diff --git a/layout/xul/nsIScrollbarMediator.h b/layout/xul/nsIScrollbarMediator.h index 510580403cfd..a49e5dc39d25 100644 --- a/layout/xul/nsIScrollbarMediator.h +++ b/layout/xul/nsIScrollbarMediator.h @@ -47,7 +47,7 @@ class nsIScrollbarMediator : public nsQueryFrame { mozilla::ScrollSnapFlags aSnapFlags = mozilla::ScrollSnapFlags::Disabled) = 0; - // Only implemented for nsGfxScrollFrame, not nsTreeBodyFrame. + // Only implemented for ScrollContainerFrame, not nsTreeBodyFrame. virtual void ScrollByUnit(nsScrollbarFrame* aScrollbar, mozilla::ScrollMode aMode, int32_t aDirection, mozilla::ScrollUnit aUnit, @@ -65,7 +65,7 @@ class nsIScrollbarMediator : public nsQueryFrame { * aOldPos and aNewPos are scroll positions. * The scroll positions start with zero at the left edge; implementors that * want zero at the right edge for RTL content will need to adjust - * accordingly. (See nsHTMLScrollFrame::ThumbMoved in + * accordingly. (See ScrollContainerFrame::ThumbMoved in * ScrollContainerFrame.cpp.) * @note This method might destroy the frame, pres shell, and other objects. */ diff --git a/layout/xul/nsScrollbarFrame.cpp b/layout/xul/nsScrollbarFrame.cpp index 76304bf50273..211b239bd21e 100644 --- a/layout/xul/nsScrollbarFrame.cpp +++ b/layout/xul/nsScrollbarFrame.cpp @@ -160,7 +160,7 @@ nsresult nsScrollbarFrame::AttributeChanged(int32_t aNameSpaceID, // Update value in our children UpdateChildrenAttributeValue(aAttribute, true); - // if the current position changes, notify any nsGfxScrollFrame + // if the current position changes, notify any ScrollContainerFrame // parent we may have if (aAttribute != nsGkAtoms::curpos) { return rv; diff --git a/python/lldbutils/README.txt b/python/lldbutils/README.txt index fd7e90675ccd..183065836bfd 100644 --- a/python/lldbutils/README.txt +++ b/python/lldbutils/README.txt @@ -37,7 +37,7 @@ called with a smart pointer like nsRefPtr or nsCOMPtr. > (lldb) ft this Viewport(-1)@0x116017430 [view=0x115efe190] {0,0,60,60} [state=000b063000002623] [sc=0x1160170f8:-moz-viewport]< - HTMLScroll(html)(-1)@0x1160180d0 {0,0,0,0} [state=000b020000000403] [content=0x115e4d640] [sc=0x116017768:-moz-viewport-scroll]< + ScrollContainer(html)(-1)@0x1160180d0 {0,0,0,0} [state=000b020000000403] [content=0x115e4d640] [sc=0x116017768:-moz-viewport-scroll]< ... Canvas(html)(-1)@0x116017e08 {0,0,60,60} ink-overflow=0,0,8340,2196 scr-overflow=0,0,8220,2196 [state=000b002000000601] [content=0x115e4d640] [sc=0x11687e0f8:-moz-scrolled-canvas]< Block(html)(-1)@0x11687e578 {0,0,60,2196} ink-overflow=0,0,8340,2196 scr-overflow=0,0,8220,2196 [state=000b100000d00601] [content=0x115e4d640] [sc=0x11687e4b8,parent=0x0]< @@ -45,7 +45,7 @@ called with a smart pointer like nsRefPtr or nsCOMPtr. Block(body)(1)@0x11687ebb0 {480,480,0,1236} ink-overflow=-120,-54,7980,1410 scr-overflow=0,0,7740,1236 [state=000b120000100601] [content=0x115ed8980] [sc=0x11687e990]< line 0x116899170: count=1 state=inline,clean,prevmarginclean,not impacted,not wrapped,before:nobr,after:nobr[0x0] {0,0,7740,1236} ink-overflow=-120,-54,7980,1410 scr-overflow=0,0,7740,1236 < nsTextControlFrame@0x11687f068 {0,66,7740,1170} ink-overflow=-120,-120,7980,1410 scr-overflow=0,0,7740,1170 [state=0002000000004621] [content=0x115ca2c50] [sc=0x11687ea40]< - HTMLScroll(div)(-1)@0x11687f6b0 {180,240,7380,690} [state=0002000000084409] [content=0x11688c0c0] [sc=0x11687eb00]< + ScrollContainer(div)(-1)@0x11687f6b0 {180,240,7380,690} [state=0002000000084409] [content=0x11688c0c0] [sc=0x11687eb00]< Block(div)(-1)@0x11687fcb8 {0,0,7380,690} [state=0002100000d04601] [content=0x11688c0c0] [sc=0x11687f990:-moz-scrolled-content]< line 0x116899130: count=1 state=inline,clean,prevmarginclean,not impacted,not wrapped,before:nobr,after:nobr[0x100] {60,0,0,690} ink-overflow=60,510,0,0 scr-overflow=60,510,0,0 < Text(0)""@0x1168990c0 {60,510,0,0} [state=0001000020404000] [content=0x11687ca10] [sc=0x11687fd88:-moz-non-element,parent=0x11687eb00] [run=0x115115e80][0,0,T] diff --git a/servo/ports/geckolib/glue.rs b/servo/ports/geckolib/glue.rs index 6efa274b4620..929f4da00ab3 100644 --- a/servo/ports/geckolib/glue.rs +++ b/servo/ports/geckolib/glue.rs @@ -4445,8 +4445,8 @@ pub extern "C" fn Servo_ComputedValues_EqualForCachedAnonymousContentStyle( // // If you do need a pref-controlled, inherited property to have an effect on these elements, // then you will need to add some checks to the - // nsIAnonymousContentCreator::CreateAnonymousContent implementations of nsHTMLScrollFrame and - // nsScrollbarFrame to clear the AnonymousContentKey if a non-initial value is used. + // nsIAnonymousContentCreator::CreateAnonymousContent implementations of ScrollContainerFrame + // and nsScrollbarFrame to clear the AnonymousContentKey if a non-initial value is used. differing_properties.remove_all(&LonghandIdSet::has_no_effect_on_gecko_scrollbars()); if !differing_properties.is_empty() {