Bug 1896516 Part 7 - Remove PresShell::GetRootScrollFrameAsScrollable(). r=layout-reviewers,emilio

`PresShell::GetRootScrollFrameAsScrollable()` is equivalent to
`PresShell::GetRootScrollContainerFrame()`.

In ScrollContainerFrame.h, `DecideScrollableLayer()` has two versions, one has
four parameters, and the other has five parameters with the fifth parameter
`aDirtyRectHasBeenOverriden` having a default value `nullptr`. When we switch
the caller from `nsIScrollableFrame` to `ScrollContainerFrame`, we need to
remove the default value for the fifth parameter to avoid ambiguity.

Differential Revision: https://phabricator.services.mozilla.com/D211494
This commit is contained in:
Ting-Yu Lin 2024-05-30 06:32:20 +00:00
parent 00acdab2d5
commit 6306934820
29 changed files with 138 additions and 166 deletions

View file

@ -21,6 +21,7 @@
#include "nsIDocShellTreeItem.h" #include "nsIDocShellTreeItem.h"
#include "mozilla/Maybe.h" #include "mozilla/Maybe.h"
#include "mozilla/PresShell.h" #include "mozilla/PresShell.h"
#include "mozilla/ScrollContainerFrame.h"
#include "mozilla/StackWalk.h" #include "mozilla/StackWalk.h"
#include "mozilla/ToString.h" #include "mozilla/ToString.h"
#include "mozilla/dom/BorrowedAttrInfo.h" #include "mozilla/dom/BorrowedAttrInfo.h"
@ -194,12 +195,12 @@ static void LogPresShell(dom::Document* aDocumentNode) {
PresShell* presShell = aDocumentNode->GetPresShell(); PresShell* presShell = aDocumentNode->GetPresShell();
printf("presshell: %p", static_cast<void*>(presShell)); printf("presshell: %p", static_cast<void*>(presShell));
nsIScrollableFrame* sf = nullptr; ScrollContainerFrame* sf = nullptr;
if (presShell) { if (presShell) {
printf(", is %s destroying", (presShell->IsDestroying() ? "" : "not")); printf(", is %s destroying", (presShell->IsDestroying() ? "" : "not"));
sf = presShell->GetRootScrollFrameAsScrollable(); sf = presShell->GetRootScrollContainerFrame();
} }
printf(", root scroll frame: %p", static_cast<void*>(sf)); printf(", root scroll container frame: %p", static_cast<void*>(sf));
} }
static void LogDocLoadGroup(dom::Document* aDocumentNode) { static void LogDocLoadGroup(dom::Document* aDocumentNode) {

View file

@ -581,7 +581,7 @@ nsRect DocAccessible::RelativeBounds(nsIFrame** aRelativeFrame) const {
} }
nsRect scrollPort; nsRect scrollPort;
nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable(); ScrollContainerFrame* sf = presShell->GetRootScrollContainerFrame();
if (sf) { if (sf) {
scrollPort = sf->GetScrollPortRect(); scrollPort = sf->GetScrollPortRect();
} else { } else {

View file

@ -3471,7 +3471,7 @@ already_AddRefed<AccAttributes> LocalAccessible::BundleFieldsForCache(
if (nsIFrame* rootFrame = presShell->GetRootFrame()) { if (nsIFrame* rootFrame = presShell->GetRootFrame()) {
nsTArray<nsIFrame*> frames; nsTArray<nsIFrame*> frames;
nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable(); ScrollContainerFrame* sf = presShell->GetRootScrollContainerFrame();
nsRect scrollPort = sf ? sf->GetScrollPortRect() : rootFrame->GetRect(); nsRect scrollPort = sf ? sf->GetScrollPortRect() : rootFrame->GetRect();
nsLayoutUtils::GetFramesForArea( nsLayoutUtils::GetFramesForArea(

View file

@ -4907,7 +4907,7 @@ void nsDocShell::SetTitleOnHistoryEntry(bool aUpdateEntryInSessionHistory) {
nsPoint nsDocShell::GetCurScrollPos() { nsPoint nsDocShell::GetCurScrollPos() {
nsPoint scrollPos; nsPoint scrollPos;
if (nsIScrollableFrame* sf = GetRootScrollFrame()) { if (ScrollContainerFrame* sf = GetRootScrollContainerFrame()) {
scrollPos = sf->GetVisualViewportOffset(); scrollPos = sf->GetVisualViewportOffset();
} }
return scrollPos; return scrollPos;
@ -4915,7 +4915,7 @@ nsPoint nsDocShell::GetCurScrollPos() {
nsresult nsDocShell::SetCurScrollPosEx(int32_t aCurHorizontalPos, nsresult nsDocShell::SetCurScrollPosEx(int32_t aCurHorizontalPos,
int32_t aCurVerticalPos) { int32_t aCurVerticalPos) {
nsIScrollableFrame* sf = GetRootScrollFrame(); ScrollContainerFrame* sf = GetRootScrollContainerFrame();
NS_ENSURE_TRUE(sf, NS_ERROR_FAILURE); NS_ENSURE_TRUE(sf, NS_ERROR_FAILURE);
ScrollMode scrollMode = ScrollMode scrollMode =
@ -7578,12 +7578,9 @@ nsresult nsDocShell::RestoreFromHistory() {
("resize widget(%d, %d, %d, %d)", newBounds.x, newBounds.y, ("resize widget(%d, %d, %d, %d)", newBounds.x, newBounds.y,
newBounds.width, newBounds.height)); newBounds.width, newBounds.height));
mDocumentViewer->SetBounds(newBounds); mDocumentViewer->SetBounds(newBounds);
} else { } else if (ScrollContainerFrame* sf =
nsIScrollableFrame* rootScrollFrame = presShell->GetRootScrollContainerFrame()) {
presShell->GetRootScrollFrameAsScrollable(); sf->PostScrolledAreaEventForCurrentArea();
if (rootScrollFrame) {
rootScrollFrame->PostScrolledAreaEventForCurrentArea();
}
} }
} }
@ -10707,7 +10704,7 @@ nsresult nsDocShell::ScrollToAnchor(bool aCurHasRef, bool aNewHasRef,
return NS_OK; return NS_OK;
} }
nsIScrollableFrame* rootScroll = presShell->GetRootScrollFrameAsScrollable(); ScrollContainerFrame* rootScroll = presShell->GetRootScrollContainerFrame();
if (rootScroll) { if (rootScroll) {
rootScroll->ClearDidHistoryRestore(); rootScroll->ClearDidHistoryRestore();
} }
@ -12352,11 +12349,11 @@ nsresult nsDocShell::GetPromptAndStringBundle(nsIPrompt** aPrompt,
return NS_OK; return NS_OK;
} }
nsIScrollableFrame* nsDocShell::GetRootScrollFrame() { ScrollContainerFrame* nsDocShell::GetRootScrollContainerFrame() {
PresShell* presShell = GetPresShell(); PresShell* presShell = GetPresShell();
NS_ENSURE_TRUE(presShell, nullptr); NS_ENSURE_TRUE(presShell, nullptr);
return presShell->GetRootScrollFrameAsScrollable(); return presShell->GetRootScrollContainerFrame();
} }
nsresult nsDocShell::EnsureScriptEnvironment() { nsresult nsDocShell::EnsureScriptEnvironment() {

View file

@ -42,6 +42,7 @@ namespace mozilla {
class Encoding; class Encoding;
class HTMLEditor; class HTMLEditor;
class ObservedDocShell; class ObservedDocShell;
class ScrollContainerFrame;
enum class TaskCategory; enum class TaskCategory;
namespace dom { namespace dom {
class ClientInfo; class ClientInfo;
@ -63,7 +64,6 @@ class nsIDocumentViewer;
class nsIHttpChannel; class nsIHttpChannel;
class nsIMutableArray; class nsIMutableArray;
class nsIPrompt; class nsIPrompt;
class nsIScrollableFrame;
class nsIStringBundle; class nsIStringBundle;
class nsIURIFixup; class nsIURIFixup;
class nsIURIFixupInfo; class nsIURIFixupInfo;
@ -970,7 +970,7 @@ class nsDocShell final : public nsDocLoader,
bool NavigationBlockedByPrinting(bool aDisplayErrorDialog = true); bool NavigationBlockedByPrinting(bool aDisplayErrorDialog = true);
bool IsNavigationAllowed(bool aDisplayPrintErrorDialog = true, bool IsNavigationAllowed(bool aDisplayPrintErrorDialog = true,
bool aCheckIfUnloadFired = true); bool aCheckIfUnloadFired = true);
nsIScrollableFrame* GetRootScrollFrame(); mozilla::ScrollContainerFrame* GetRootScrollContainerFrame();
nsIChannel* GetCurrentDocChannel(); nsIChannel* GetCurrentDocChannel();
nsresult EnsureScriptEnvironment(); nsresult EnsureScriptEnvironment();
nsresult EnsureEditorData(); nsresult EnsureEditorData();

View file

@ -504,9 +504,9 @@ static Maybe<OopIframeMetrics> GetOopIframeMetrics(
} }
nsRect inProcessRootRect; nsRect inProcessRootRect;
if (nsIScrollableFrame* scrollFrame = if (ScrollContainerFrame* rootScrollContainerFrame =
rootPresShell->GetRootScrollFrameAsScrollable()) { rootPresShell->GetRootScrollContainerFrame()) {
inProcessRootRect = scrollFrame->GetScrollPortRect(); inProcessRootRect = rootScrollContainerFrame->GetScrollPortRect();
} }
Maybe<LayoutDeviceRect> remoteDocumentVisibleRect = Maybe<LayoutDeviceRect> remoteDocumentVisibleRect =
@ -576,11 +576,11 @@ IntersectionInput DOMIntersectionObserver::ComputeInput(
// handle the OOP iframe positions. // handle the OOP iframe positions.
if (PresShell* presShell = rootDocument->GetPresShell()) { if (PresShell* presShell = rootDocument->GetPresShell()) {
rootFrame = presShell->GetRootFrame(); rootFrame = presShell->GetRootFrame();
// We use the root scrollable frame's scroll port to account the // We use the root scroll container frame's scroll port to account the
// scrollbars in rootRect, if needed. // scrollbars in rootRect, if needed.
if (nsIScrollableFrame* scrollFrame = if (ScrollContainerFrame* rootScrollContainerFrame =
presShell->GetRootScrollFrameAsScrollable()) { presShell->GetRootScrollContainerFrame()) {
rootRect = scrollFrame->GetScrollPortRect(); rootRect = rootScrollContainerFrame->GetScrollPortRect();
} else if (rootFrame) { } else if (rootFrame) {
rootRect = rootFrame->GetRectRelativeToSelf(); rootRect = rootFrame->GetRectRelativeToSelf();
} }

View file

@ -8,8 +8,8 @@
#include "mozilla/EventDispatcher.h" #include "mozilla/EventDispatcher.h"
#include "mozilla/PresShell.h" #include "mozilla/PresShell.h"
#include "mozilla/ScrollContainerFrame.h"
#include "mozilla/ToString.h" #include "mozilla/ToString.h"
#include "nsIScrollableFrame.h"
#include "nsIDocShell.h" #include "nsIDocShell.h"
#include "nsPresContext.h" #include "nsPresContext.h"
#include "nsRefreshDriver.h" #include "nsRefreshDriver.h"
@ -78,7 +78,7 @@ CSSSize VisualViewport::VisualViewportSize() const {
? presShell->GetVisualViewportSizeUpdatedByDynamicToolbar() ? presShell->GetVisualViewportSizeUpdatedByDynamicToolbar()
: presShell->GetVisualViewportSize()); : presShell->GetVisualViewportSize());
} else { } else {
nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable(); ScrollContainerFrame* sf = presShell->GetRootScrollContainerFrame();
if (sf) { if (sf) {
size = CSSRect::FromAppUnits(sf->GetScrollPortRect().Size()); size = CSSRect::FromAppUnits(sf->GetScrollPortRect().Size());
} }

View file

@ -1723,7 +1723,7 @@ static nsresult getScrollXYAppUnits(const nsWeakPtr& aWindow, bool aFlushLayout,
} }
if (PresShell* presShell = doc->GetPresShell()) { if (PresShell* presShell = doc->GetPresShell()) {
nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable(); ScrollContainerFrame* sf = presShell->GetRootScrollContainerFrame();
if (sf) { if (sf) {
aScrollPos = sf->GetScrollPosition(); aScrollPos = sf->GetScrollPosition();
} }
@ -2014,10 +2014,10 @@ nsDOMWindowUtils::GetScrollbarSize(bool aFlushLayout, int32_t* aWidth,
PresShell* presShell = doc->GetPresShell(); PresShell* presShell = doc->GetPresShell();
NS_ENSURE_TRUE(presShell, NS_ERROR_NOT_AVAILABLE); NS_ENSURE_TRUE(presShell, NS_ERROR_NOT_AVAILABLE);
nsIScrollableFrame* scrollFrame = presShell->GetRootScrollFrameAsScrollable(); ScrollContainerFrame* sf = presShell->GetRootScrollContainerFrame();
NS_ENSURE_TRUE(scrollFrame, NS_OK); NS_ENSURE_TRUE(sf, NS_OK);
nsMargin sizes = scrollFrame->GetActualScrollbarSizes(); nsMargin sizes = sf->GetActualScrollbarSizes();
*aWidth = nsPresContext::AppUnitsToIntCSSPixels(sizes.LeftRight()); *aWidth = nsPresContext::AppUnitsToIntCSSPixels(sizes.LeftRight());
*aHeight = nsPresContext::AppUnitsToIntCSSPixels(sizes.TopBottom()); *aHeight = nsPresContext::AppUnitsToIntCSSPixels(sizes.TopBottom());
@ -2093,7 +2093,7 @@ nsDOMWindowUtils::GetRootBounds(DOMRect** aResult) {
nsRect bounds(0, 0, 0, 0); nsRect bounds(0, 0, 0, 0);
PresShell* presShell = doc->GetPresShell(); PresShell* presShell = doc->GetPresShell();
if (presShell) { if (presShell) {
nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable(); ScrollContainerFrame* sf = presShell->GetRootScrollContainerFrame();
if (sf) { if (sf) {
bounds = sf->GetScrollRange(); bounds = sf->GetScrollRange();
bounds.SetWidth(bounds.Width() + sf->GetScrollPortRect().Width()); bounds.SetWidth(bounds.Width() + sf->GetScrollPortRect().Width());

View file

@ -72,6 +72,7 @@
#include "mozilla/ProcessHangMonitor.h" #include "mozilla/ProcessHangMonitor.h"
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
#include "mozilla/Result.h" #include "mozilla/Result.h"
#include "mozilla/ScrollContainerFrame.h"
#include "mozilla/ScrollTypes.h" #include "mozilla/ScrollTypes.h"
#include "mozilla/Components.h" #include "mozilla/Components.h"
#include "mozilla/SizeOfState.h" #include "mozilla/SizeOfState.h"
@ -263,7 +264,6 @@
#include "nsIScriptContext.h" #include "nsIScriptContext.h"
#include "nsIScriptGlobalObject.h" #include "nsIScriptGlobalObject.h"
#include "nsIScriptObjectPrincipal.h" #include "nsIScriptObjectPrincipal.h"
#include "nsIScrollableFrame.h"
#include "nsISerialEventTarget.h" #include "nsISerialEventTarget.h"
#include "nsISimpleEnumerator.h" #include "nsISimpleEnumerator.h"
#include "nsISizeOfEventTarget.h" #include "nsISizeOfEventTarget.h"
@ -3817,7 +3817,7 @@ void nsGlobalWindowInner::ScrollTo(const ScrollToOptions& aOptions) {
? FlushType::Layout ? FlushType::Layout
: FlushType::Frames; : FlushType::Frames;
FlushPendingNotifications(flushType); FlushPendingNotifications(flushType);
nsIScrollableFrame* sf = GetScrollFrame(); ScrollContainerFrame* sf = GetScrollContainerFrame();
if (sf) { if (sf) {
CSSIntPoint scrollPos = sf->GetRoundedScrollPositionCSSPixels(); CSSIntPoint scrollPos = sf->GetRoundedScrollPositionCSSPixels();
@ -3847,7 +3847,7 @@ void nsGlobalWindowInner::ScrollTo(const CSSIntPoint& aScroll,
FlushType flushType = FlushType flushType =
(aScroll.x || aScroll.y) ? FlushType::Layout : FlushType::Frames; (aScroll.x || aScroll.y) ? FlushType::Layout : FlushType::Frames;
FlushPendingNotifications(flushType); FlushPendingNotifications(flushType);
nsIScrollableFrame* sf = GetScrollFrame(); ScrollContainerFrame* sf = GetScrollContainerFrame();
if (sf) { if (sf) {
// Here we calculate what the max pixel value is that we can // Here we calculate what the max pixel value is that we can
@ -3876,7 +3876,7 @@ void nsGlobalWindowInner::ScrollTo(const CSSIntPoint& aScroll,
void nsGlobalWindowInner::ScrollBy(double aXScrollDif, double aYScrollDif) { void nsGlobalWindowInner::ScrollBy(double aXScrollDif, double aYScrollDif) {
FlushPendingNotifications(FlushType::Layout); FlushPendingNotifications(FlushType::Layout);
nsIScrollableFrame* sf = GetScrollFrame(); ScrollContainerFrame* sf = GetScrollContainerFrame();
if (sf) { if (sf) {
// It seems like it would make more sense for ScrollBy to use // It seems like it would make more sense for ScrollBy to use
@ -3891,7 +3891,7 @@ void nsGlobalWindowInner::ScrollBy(double aXScrollDif, double aYScrollDif) {
void nsGlobalWindowInner::ScrollBy(const ScrollToOptions& aOptions) { void nsGlobalWindowInner::ScrollBy(const ScrollToOptions& aOptions) {
FlushPendingNotifications(FlushType::Layout); FlushPendingNotifications(FlushType::Layout);
nsIScrollableFrame* sf = GetScrollFrame(); ScrollContainerFrame* sf = GetScrollContainerFrame();
if (sf) { if (sf) {
CSSIntPoint scrollDelta; CSSIntPoint scrollDelta;
@ -3915,7 +3915,7 @@ void nsGlobalWindowInner::ScrollBy(const ScrollToOptions& aOptions) {
void nsGlobalWindowInner::ScrollByLines(int32_t numLines, void nsGlobalWindowInner::ScrollByLines(int32_t numLines,
const ScrollOptions& aOptions) { const ScrollOptions& aOptions) {
FlushPendingNotifications(FlushType::Layout); FlushPendingNotifications(FlushType::Layout);
nsIScrollableFrame* sf = GetScrollFrame(); ScrollContainerFrame* sf = GetScrollContainerFrame();
if (sf) { if (sf) {
// It seems like it would make more sense for ScrollByLines to use // It seems like it would make more sense for ScrollByLines to use
// SMOOTH mode, but tests seem to depend on the synchronous behaviour. // SMOOTH mode, but tests seem to depend on the synchronous behaviour.
@ -3931,7 +3931,7 @@ void nsGlobalWindowInner::ScrollByLines(int32_t numLines,
void nsGlobalWindowInner::ScrollByPages(int32_t numPages, void nsGlobalWindowInner::ScrollByPages(int32_t numPages,
const ScrollOptions& aOptions) { const ScrollOptions& aOptions) {
FlushPendingNotifications(FlushType::Layout); FlushPendingNotifications(FlushType::Layout);
nsIScrollableFrame* sf = GetScrollFrame(); ScrollContainerFrame* sf = GetScrollContainerFrame();
if (sf) { if (sf) {
// It seems like it would make more sense for ScrollByPages to use // It seems like it would make more sense for ScrollByPages to use
// SMOOTH mode, but tests seem to depend on the synchronous behaviour. // SMOOTH mode, but tests seem to depend on the synchronous behaviour.
@ -3946,7 +3946,7 @@ void nsGlobalWindowInner::ScrollByPages(int32_t numPages,
void nsGlobalWindowInner::MozScrollSnap() { void nsGlobalWindowInner::MozScrollSnap() {
FlushPendingNotifications(FlushType::Layout); FlushPendingNotifications(FlushType::Layout);
nsIScrollableFrame* sf = GetScrollFrame(); ScrollContainerFrame* sf = GetScrollContainerFrame();
if (sf) { if (sf) {
sf->ScrollSnap(); sf->ScrollSnap();
} }
@ -6379,8 +6379,8 @@ nsGlobalWindowInner::GetWebBrowserChrome() {
return browserChrome.forget(); return browserChrome.forget();
} }
nsIScrollableFrame* nsGlobalWindowInner::GetScrollFrame() { ScrollContainerFrame* nsGlobalWindowInner::GetScrollContainerFrame() {
FORWARD_TO_OUTER(GetScrollFrame, (), nullptr); FORWARD_TO_OUTER(GetScrollContainerFrame, (), nullptr);
} }
bool nsGlobalWindowInner::IsPrivateBrowsing() { bool nsGlobalWindowInner::IsPrivateBrowsing() {
@ -7592,7 +7592,7 @@ void nsGlobalWindowInner::SetScrollMarks(const nsTArray<uint32_t>& aScrollMarks,
if (mDoc) { if (mDoc) {
PresShell* presShell = mDoc->GetPresShell(); PresShell* presShell = mDoc->GetPresShell();
if (presShell) { if (presShell) {
nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable(); ScrollContainerFrame* sf = presShell->GetRootScrollContainerFrame();
if (sf) { if (sf) {
sf->InvalidateScrollbars(); sf->InvalidateScrollbars();
} }

View file

@ -58,7 +58,6 @@ class nsIContent;
class nsICSSDeclaration; class nsICSSDeclaration;
class nsIDocShellTreeOwner; class nsIDocShellTreeOwner;
class nsIDOMWindowUtils; class nsIDOMWindowUtils;
class nsIScrollableFrame;
class nsIControllers; class nsIControllers;
class nsIScriptContext; class nsIScriptContext;
class nsIScriptTimeoutHandler; class nsIScriptTimeoutHandler;
@ -85,6 +84,7 @@ class PromiseDocumentFlushedResolver;
namespace mozilla { namespace mozilla {
class AbstractThread; class AbstractThread;
class ScrollContainerFrame;
class ErrorResult; class ErrorResult;
namespace glean { namespace glean {
@ -431,9 +431,10 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
bool IsChromeWindow() const { return mIsChrome; } bool IsChromeWindow() const { return mIsChrome; }
// GetScrollFrame does not flush. Callers should do it themselves as needed, // GetScrollContainerFrame does not flush. Callers should do it themselves as
// depending on which info they actually want off the scrollable frame. // needed, depending on which info they actually want off the scroll container
nsIScrollableFrame* GetScrollFrame(); // frame.
mozilla::ScrollContainerFrame* GetScrollContainerFrame();
nsresult Observe(nsISupports* aSubject, const char* aTopic, nsresult Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData); const char16_t* aData);

View file

@ -137,7 +137,6 @@
#include "nsDOMString.h" #include "nsDOMString.h"
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
#include "nsILoadContext.h" #include "nsILoadContext.h"
#include "nsIScrollableFrame.h"
#include "nsView.h" #include "nsView.h"
#include "nsViewManager.h" #include "nsViewManager.h"
#include "nsIPrompt.h" #include "nsIPrompt.h"
@ -164,6 +163,7 @@
#include "nsIURIMutator.h" #include "nsIURIMutator.h"
#include "mozilla/EventDispatcher.h" #include "mozilla/EventDispatcher.h"
#include "mozilla/EventStateManager.h" #include "mozilla/EventStateManager.h"
#include "mozilla/ScrollContainerFrame.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "nsFocusManager.h" #include "nsFocusManager.h"
#include "nsIAppWindow.h" #include "nsIAppWindow.h"
@ -3793,7 +3793,7 @@ void nsGlobalWindowOuter::CheckSecurityLeftAndTop(int32_t* aLeft, int32_t* aTop,
int32_t nsGlobalWindowOuter::GetScrollBoundaryOuter(Side aSide) { int32_t nsGlobalWindowOuter::GetScrollBoundaryOuter(Side aSide) {
FlushPendingNotifications(FlushType::Layout); FlushPendingNotifications(FlushType::Layout);
if (nsIScrollableFrame* sf = GetScrollFrame()) { if (ScrollContainerFrame* sf = GetScrollContainerFrame()) {
return nsPresContext::AppUnitsToIntCSSPixels( return nsPresContext::AppUnitsToIntCSSPixels(
sf->GetScrollRange().Edge(aSide)); sf->GetScrollRange().Edge(aSide));
} }
@ -3807,7 +3807,7 @@ CSSPoint nsGlobalWindowOuter::GetScrollXY(bool aDoFlush) {
EnsureSizeAndPositionUpToDate(); EnsureSizeAndPositionUpToDate();
} }
nsIScrollableFrame* sf = GetScrollFrame(); ScrollContainerFrame* sf = GetScrollContainerFrame();
if (!sf) { if (!sf) {
return CSSIntPoint(0, 0); return CSSIntPoint(0, 0);
} }
@ -7047,14 +7047,14 @@ nsPIDOMWindowOuter::GetWebBrowserChrome() {
return browserChrome.forget(); return browserChrome.forget();
} }
nsIScrollableFrame* nsGlobalWindowOuter::GetScrollFrame() { ScrollContainerFrame* nsGlobalWindowOuter::GetScrollContainerFrame() {
if (!mDocShell) { if (!mDocShell) {
return nullptr; return nullptr;
} }
PresShell* presShell = mDocShell->GetPresShell(); PresShell* presShell = mDocShell->GetPresShell();
if (presShell) { if (presShell) {
return presShell->GetRootScrollFrameAsScrollable(); return presShell->GetRootScrollContainerFrame();
} }
return nullptr; return nullptr;
} }

View file

@ -57,7 +57,6 @@ class nsIContent;
class nsICSSDeclaration; class nsICSSDeclaration;
class nsIDocShellTreeOwner; class nsIDocShellTreeOwner;
class nsIDOMWindowUtils; class nsIDOMWindowUtils;
class nsIScrollableFrame;
class nsIControllers; class nsIControllers;
class nsIPrintSettings; class nsIPrintSettings;
class nsIScriptContext; class nsIScriptContext;
@ -83,6 +82,7 @@ class AbstractThread;
class DOMEventTargetHelper; class DOMEventTargetHelper;
class ErrorResult; class ErrorResult;
class ThrottledEventQueue; class ThrottledEventQueue;
class ScrollContainerFrame;
namespace dom { namespace dom {
class BarProp; class BarProp;
struct ChannelPixelLayout; struct ChannelPixelLayout;
@ -412,9 +412,10 @@ class nsGlobalWindowOuter final : public mozilla::dom::EventTarget,
bool IsChromeWindow() const { return mIsChrome; } bool IsChromeWindow() const { return mIsChrome; }
// GetScrollFrame does not flush. Callers should do it themselves as needed, // GetScrollContainerFrame does not flush. Callers should do it themselves as
// depending on which info they actually want off the scrollable frame. // needed, depending on which info they actually want off the scroll container
nsIScrollableFrame* GetScrollFrame(); // frame.
mozilla::ScrollContainerFrame* GetScrollContainerFrame();
// Outer windows only. // Outer windows only.
void UnblockScriptedClosing(); void UnblockScriptedClosing();

View file

@ -29,6 +29,7 @@
#include "mozilla/dom/Event.h" #include "mozilla/dom/Event.h"
#include "mozilla/dom/ShadowRoot.h" #include "mozilla/dom/ShadowRoot.h"
#include "mozilla/dom/WorkerScope.h" #include "mozilla/dom/WorkerScope.h"
#include "mozilla/ScrollContainerFrame.h"
#include "mozilla/StaticPrefs_dom.h" #include "mozilla/StaticPrefs_dom.h"
#include "mozilla/SVGUtils.h" #include "mozilla/SVGUtils.h"
#include "mozilla/SVGOuterSVGFrame.h" #include "mozilla/SVGOuterSVGFrame.h"
@ -40,7 +41,6 @@
#include "nsIFrame.h" #include "nsIFrame.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "nsIContentInlines.h" #include "nsIContentInlines.h"
#include "nsIScrollableFrame.h"
#include "nsJSEnvironment.h" #include "nsJSEnvironment.h"
#include "nsLayoutUtils.h" #include "nsLayoutUtils.h"
#include "nsPIWindowRoot.h" #include "nsPIWindowRoot.h"
@ -617,11 +617,8 @@ CSSIntPoint Event::GetPageCoords(nsPresContext* aPresContext,
// If there is some scrolling, add scroll info to client point. // If there is some scrolling, add scroll info to client point.
if (aPresContext && aPresContext->GetPresShell()) { if (aPresContext && aPresContext->GetPresShell()) {
PresShell* presShell = aPresContext->PresShell(); PresShell* presShell = aPresContext->PresShell();
nsIScrollableFrame* scrollframe = if (ScrollContainerFrame* sf = presShell->GetRootScrollContainerFrame()) {
presShell->GetRootScrollFrameAsScrollable(); pagePoint += CSSIntPoint::FromAppUnitsRounded(sf->GetScrollPosition());
if (scrollframe) {
pagePoint +=
CSSIntPoint::FromAppUnitsRounded(scrollframe->GetScrollPosition());
} }
} }

View file

@ -3335,8 +3335,7 @@ nsSize EventStateManager::GetScrollAmount(
const bool isPage = aEvent->mDeltaMode == WheelEvent_Binding::DOM_DELTA_PAGE; const bool isPage = aEvent->mDeltaMode == WheelEvent_Binding::DOM_DELTA_PAGE;
if (!aScrollableFrame) { if (!aScrollableFrame) {
// If there is no scrollable frame, we should use root, see below. // If there is no scrollable frame, we should use root, see below.
aScrollableFrame = aScrollableFrame = aPresContext->PresShell()->GetRootScrollContainerFrame();
aPresContext->PresShell()->GetRootScrollFrameAsScrollable();
} }
if (aScrollableFrame) { if (aScrollableFrame) {

View file

@ -15,6 +15,7 @@
#include "mozilla/dom/MouseEvent.h" #include "mozilla/dom/MouseEvent.h"
#include "mozilla/LoadInfo.h" #include "mozilla/LoadInfo.h"
#include "mozilla/PresShell.h" #include "mozilla/PresShell.h"
#include "mozilla/ScrollContainerFrame.h"
#include "mozilla/StaticPrefs_browser.h" #include "mozilla/StaticPrefs_browser.h"
#include "nsICSSDeclaration.h" #include "nsICSSDeclaration.h"
#include "nsObjectLoadingContent.h" #include "nsObjectLoadingContent.h"
@ -41,7 +42,6 @@
#include "nsIDocShell.h" #include "nsIDocShell.h"
#include "nsIDocumentViewer.h" #include "nsIDocumentViewer.h"
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
#include "nsIScrollableFrame.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
#include <algorithm> #include <algorithm>
@ -297,7 +297,7 @@ void ImageDocument::ScrollImageTo(int32_t aX, int32_t aY) {
return; return;
} }
nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable(); ScrollContainerFrame* sf = presShell->GetRootScrollContainerFrame();
if (!sf) { if (!sf) {
return; return;
} }

View file

@ -687,14 +687,14 @@ static PartialPrerenderData GetPartialPrerenderData(
const nsIFrame* clipFrame = const nsIFrame* clipFrame =
nsLayoutUtils::GetNearestOverflowClipFrame(aFrame->GetParent()); nsLayoutUtils::GetNearestOverflowClipFrame(aFrame->GetParent());
const nsIScrollableFrame* scrollFrame = do_QueryFrame(clipFrame); const ScrollContainerFrame* scrollContainerFrame = do_QueryFrame(clipFrame);
if (!clipFrame) { if (!clipFrame) {
// If there is no suitable clip frame in the same document, use the // If there is no suitable clip frame in the same document, use the
// root one. // root one.
scrollFrame = aFrame->PresShell()->GetRootScrollFrameAsScrollable(); scrollContainerFrame = aFrame->PresShell()->GetRootScrollContainerFrame();
if (scrollFrame) { if (scrollContainerFrame) {
clipFrame = do_QueryFrame(scrollFrame); clipFrame = scrollContainerFrame;
} else { } else {
// If there is no root scroll frame, use the viewport frame. // If there is no root scroll frame, use the viewport frame.
clipFrame = aFrame->PresShell()->GetRootFrame(); clipFrame = aFrame->PresShell()->GetRootFrame();
@ -702,8 +702,8 @@ static PartialPrerenderData GetPartialPrerenderData(
} }
// If the scroll frame is asyncronously scrollable, try to find the scroll id. // If the scroll frame is asyncronously scrollable, try to find the scroll id.
if (scrollFrame && if (scrollContainerFrame &&
!scrollFrame->GetScrollStyles().IsHiddenInBothDirections() && !scrollContainerFrame->GetScrollStyles().IsHiddenInBothDirections() &&
nsLayoutUtils::AsyncPanZoomEnabled(aFrame)) { nsLayoutUtils::AsyncPanZoomEnabled(aFrame)) {
const bool isInPositionFixed = const bool isInPositionFixed =
nsLayoutUtils::IsInPositionFixedSubtree(aFrame); nsLayoutUtils::IsInPositionFixedSubtree(aFrame);
@ -728,7 +728,7 @@ static PartialPrerenderData GetPartialPrerenderData(
int32_t devPixelsToAppUnits = aFrame->PresContext()->AppUnitsPerDevPixel(); int32_t devPixelsToAppUnits = aFrame->PresContext()->AppUnitsPerDevPixel();
auto [clipRect, transformInClip] = GetClipRectAndTransformForPartialPrerender( auto [clipRect, transformInClip] = GetClipRectAndTransformForPartialPrerender(
aFrame, devPixelsToAppUnits, clipFrame, scrollFrame); aFrame, devPixelsToAppUnits, clipFrame, scrollContainerFrame);
return PartialPrerenderData{ return PartialPrerenderData{
LayoutDeviceRect::FromAppUnits(partialPrerenderedRect, LayoutDeviceRect::FromAppUnits(partialPrerenderedRect,

View file

@ -2463,17 +2463,6 @@ ScrollContainerFrame* PresShell::GetRootScrollContainerFrame() const {
return static_cast<ScrollContainerFrame*>(theFrame); return static_cast<ScrollContainerFrame*>(theFrame);
} }
nsIScrollableFrame* PresShell::GetRootScrollFrameAsScrollable() const {
nsIFrame* frame = GetRootScrollContainerFrame();
if (!frame) {
return nullptr;
}
nsIScrollableFrame* scrollableFrame = do_QueryFrame(frame);
NS_ASSERTION(scrollableFrame,
"All scroll frames must implement nsIScrollableFrame");
return scrollableFrame;
}
nsPageSequenceFrame* PresShell::GetPageSequenceFrame() const { nsPageSequenceFrame* PresShell::GetPageSequenceFrame() const {
return mFrameConstructor->GetPageSequenceFrame(); return mFrameConstructor->GetPageSequenceFrame();
} }
@ -2483,9 +2472,8 @@ nsCanvasFrame* PresShell::GetCanvasFrame() const {
} }
void PresShell::RestoreRootScrollPosition() { void PresShell::RestoreRootScrollPosition() {
nsIScrollableFrame* scrollableFrame = GetRootScrollFrameAsScrollable(); if (ScrollContainerFrame* sf = GetRootScrollContainerFrame()) {
if (scrollableFrame) { sf->ScrollToRestoredPosition();
scrollableFrame->ScrollToRestoredPosition();
} }
} }
@ -3125,7 +3113,7 @@ nsresult PresShell::GoToAnchor(const nsAString& aAnchorName, bool aScroll,
esm->SetContentState(target, ElementState::URLTARGET); esm->SetContentState(target, ElementState::URLTARGET);
// TODO: Spec probably needs a section to account for this. // TODO: Spec probably needs a section to account for this.
if (nsIScrollableFrame* rootScroll = GetRootScrollFrameAsScrollable()) { if (ScrollContainerFrame* rootScroll = GetRootScrollContainerFrame()) {
if (rootScroll->DidHistoryRestore()) { if (rootScroll->DidHistoryRestore()) {
// Scroll position restored from history trumps scrolling to anchor. // Scroll position restored from history trumps scrolling to anchor.
aScroll = false; aScroll = false;
@ -3146,7 +3134,7 @@ nsresult PresShell::GoToAnchor(const nsAString& aAnchorName, bool aScroll,
ScrollAxis(), ScrollAxis(),
ScrollFlags::AnchorScrollFlags | aAdditionalScrollFlags)); ScrollFlags::AnchorScrollFlags | aAdditionalScrollFlags));
if (nsIScrollableFrame* rootScroll = GetRootScrollFrameAsScrollable()) { if (ScrollContainerFrame* rootScroll = GetRootScrollContainerFrame()) {
mLastAnchorScrolledTo = target; mLastAnchorScrolledTo = target;
mLastAnchorScrollPositionY = rootScroll->GetScrollPosition().y; mLastAnchorScrollPositionY = rootScroll->GetScrollPosition().y;
} }
@ -3227,7 +3215,7 @@ nsresult PresShell::GoToAnchor(const nsAString& aAnchorName, bool aScroll,
#endif #endif
} else if (nsContentUtils::EqualsIgnoreASCIICase(aAnchorName, u"top"_ns)) { } else if (nsContentUtils::EqualsIgnoreASCIICase(aAnchorName, u"top"_ns)) {
// 2.2. Scroll to the beginning of the document for the Document. // 2.2. Scroll to the beginning of the document for the Document.
nsIScrollableFrame* sf = GetRootScrollFrameAsScrollable(); ScrollContainerFrame* sf = GetRootScrollContainerFrame();
// Check |aScroll| after setting |rv| so we set |rv| to the same // Check |aScroll| after setting |rv| so we set |rv| to the same
// thing whether or not |aScroll| is true. // thing whether or not |aScroll| is true.
if (aScroll && sf) { if (aScroll && sf) {
@ -3250,7 +3238,7 @@ nsresult PresShell::ScrollToAnchor() {
} }
NS_ASSERTION(mDidInitialize, "should have done initial reflow by now"); NS_ASSERTION(mDidInitialize, "should have done initial reflow by now");
nsIScrollableFrame* rootScroll = GetRootScrollFrameAsScrollable(); ScrollContainerFrame* rootScroll = GetRootScrollContainerFrame();
if (!rootScroll || if (!rootScroll ||
mLastAnchorScrollPositionY != rootScroll->GetScrollPosition().y) { mLastAnchorScrollPositionY != rootScroll->GetScrollPosition().y) {
return NS_OK; return NS_OK;
@ -5352,7 +5340,7 @@ void PresShell::AddCanvasBackgroundColorItem(nsDisplayListBuilder* aBuilder,
// nsDisplayCanvasBackground paint it. // nsDisplayCanvasBackground paint it.
bool addedScrollingBackgroundColor = false; bool addedScrollingBackgroundColor = false;
if (isViewport) { if (isViewport) {
if (nsIScrollableFrame* sf = GetRootScrollFrameAsScrollable()) { if (ScrollContainerFrame* sf = GetRootScrollContainerFrame()) {
nsCanvasFrame* canvasFrame = do_QueryFrame(sf->GetScrolledFrame()); nsCanvasFrame* canvasFrame = do_QueryFrame(sf->GetScrolledFrame());
if (canvasFrame && canvasFrame->IsVisibleForPainting()) { if (canvasFrame && canvasFrame->IsVisibleForPainting()) {
// TODO: We should be able to set canvas background color during display // TODO: We should be able to set canvas background color during display
@ -11362,9 +11350,8 @@ void PresShell::CompleteChangeToVisualViewportSize() {
// items). Callers that update the visual viewport during a reflow are // items). Callers that update the visual viewport during a reflow are
// responsible for maintaining these invariants. // responsible for maintaining these invariants.
if (!mIsReflowing) { if (!mIsReflowing) {
if (nsIScrollableFrame* rootScrollFrame = if (ScrollContainerFrame* sf = GetRootScrollContainerFrame()) {
GetRootScrollFrameAsScrollable()) { sf->MarkScrollbarsDirtyForReflow();
rootScrollFrame->MarkScrollbarsDirtyForReflow();
} }
MarkFixedFramesForReflow(IntrinsicDirty::None); MarkFixedFramesForReflow(IntrinsicDirty::None);
} }
@ -11402,11 +11389,13 @@ void PresShell::ResetVisualViewportSize() {
bool PresShell::SetVisualViewportOffset(const nsPoint& aScrollOffset, bool PresShell::SetVisualViewportOffset(const nsPoint& aScrollOffset,
const nsPoint& aPrevLayoutScrollPos) { const nsPoint& aPrevLayoutScrollPos) {
nsPoint newOffset = aScrollOffset; nsPoint newOffset = aScrollOffset;
nsIScrollableFrame* rootScrollFrame = GetRootScrollFrameAsScrollable(); ScrollContainerFrame* rootScrollContainerFrame =
if (rootScrollFrame) { GetRootScrollContainerFrame();
if (rootScrollContainerFrame) {
// See the comment in ScrollContainerFrame::Reflow above the call to // See the comment in ScrollContainerFrame::Reflow above the call to
// SetVisualViewportOffset for why we need to do this. // SetVisualViewportOffset for why we need to do this.
nsRect scrollRange = rootScrollFrame->GetScrollRangeForUserInputEvents(); nsRect scrollRange =
rootScrollContainerFrame->GetScrollRangeForUserInputEvents();
if (!scrollRange.Contains(newOffset)) { if (!scrollRange.Contains(newOffset)) {
newOffset.x = std::min(newOffset.x, scrollRange.XMost()); newOffset.x = std::min(newOffset.x, scrollRange.XMost());
newOffset.x = std::max(newOffset.x, scrollRange.x); newOffset.x = std::max(newOffset.x, scrollRange.x);
@ -11433,14 +11422,13 @@ bool PresShell::SetVisualViewportOffset(const nsPoint& aScrollOffset,
window->VisualViewport()->PostScrollEvent(prevOffset, aPrevLayoutScrollPos); window->VisualViewport()->PostScrollEvent(prevOffset, aPrevLayoutScrollPos);
} }
if (IsVisualViewportSizeSet() && rootScrollFrame) { if (IsVisualViewportSizeSet() && rootScrollContainerFrame) {
rootScrollFrame->Anchor()->UserScrolled(); rootScrollContainerFrame->Anchor()->UserScrolled();
} }
if (gfxPlatform::UseDesktopZoomingScrollbars()) { if (gfxPlatform::UseDesktopZoomingScrollbars()) {
if (nsIScrollableFrame* rootScrollFrame = if (rootScrollContainerFrame) {
GetRootScrollFrameAsScrollable()) { rootScrollContainerFrame->UpdateScrollbarPosition();
rootScrollFrame->UpdateScrollbarPosition();
} }
} }
@ -11455,7 +11443,7 @@ void PresShell::ScrollToVisual(const nsPoint& aVisualViewportOffset,
MOZ_ASSERT(aMode == ScrollMode::Instant || aMode == ScrollMode::SmoothMsd); MOZ_ASSERT(aMode == ScrollMode::Instant || aMode == ScrollMode::SmoothMsd);
if (aMode == ScrollMode::SmoothMsd) { if (aMode == ScrollMode::SmoothMsd) {
if (nsIScrollableFrame* sf = GetRootScrollFrameAsScrollable()) { if (ScrollContainerFrame* sf = GetRootScrollContainerFrame()) {
if (sf->SmoothScrollVisual(aVisualViewportOffset, aUpdateType)) { if (sf->SmoothScrollVisual(aVisualViewportOffset, aUpdateType)) {
return; return;
} }
@ -11497,7 +11485,7 @@ nsPoint PresShell::GetVisualViewportOffsetRelativeToLayoutViewport() const {
nsPoint PresShell::GetLayoutViewportOffset() const { nsPoint PresShell::GetLayoutViewportOffset() const {
nsPoint result; nsPoint result;
if (nsIScrollableFrame* sf = GetRootScrollFrameAsScrollable()) { if (ScrollContainerFrame* sf = GetRootScrollContainerFrame()) {
result = sf->GetScrollPosition(); result = sf->GetScrollPosition();
} }
return result; return result;
@ -11505,7 +11493,7 @@ nsPoint PresShell::GetLayoutViewportOffset() const {
nsSize PresShell::GetLayoutViewportSize() const { nsSize PresShell::GetLayoutViewportSize() const {
nsSize result; nsSize result;
if (nsIScrollableFrame* sf = GetRootScrollFrameAsScrollable()) { if (ScrollContainerFrame* sf = GetRootScrollContainerFrame()) {
result = sf->GetScrollPortRect().Size(); result = sf->GetScrollPortRect().Size();
} }
return result; return result;

View file

@ -436,11 +436,6 @@ class PresShell final : public nsStubDocumentObserver,
*/ */
ScrollContainerFrame* GetRootScrollContainerFrame() const; ScrollContainerFrame* GetRootScrollContainerFrame() const;
/*
* The same as GetRootScrollFrame, but returns an nsIScrollableFrame
*/
nsIScrollableFrame* GetRootScrollFrameAsScrollable() const;
/** /**
* Get the current focused content or DOM selection that should be the * Get the current focused content or DOM selection that should be the
* target for scrolling. * target for scrolling.

View file

@ -19,6 +19,7 @@
#include "mozilla/PresShell.h" #include "mozilla/PresShell.h"
#include "mozilla/PresShellInlines.h" #include "mozilla/PresShellInlines.h"
#include "mozilla/ProfilerLabels.h" #include "mozilla/ProfilerLabels.h"
#include "mozilla/ScrollContainerFrame.h"
#include "mozilla/ServoBindings.h" #include "mozilla/ServoBindings.h"
#include "mozilla/ServoStyleSetInlines.h" #include "mozilla/ServoStyleSetInlines.h"
#include "mozilla/StaticPrefs_layout.h" #include "mozilla/StaticPrefs_layout.h"
@ -1460,8 +1461,8 @@ static inline void TryToDealWithScrollbarChange(nsChangeHint& aHint,
// already exists, so we can simply reflow instead of reframing. // already exists, so we can simply reflow instead of reframing.
if (nsIScrollableFrame* sf = do_QueryFrame(aFrame)) { if (nsIScrollableFrame* sf = do_QueryFrame(aFrame)) {
sf->MarkScrollbarsDirtyForReflow(); sf->MarkScrollbarsDirtyForReflow();
} else if (nsIScrollableFrame* sf = } else if (ScrollContainerFrame* sf =
aPc->PresShell()->GetRootScrollFrameAsScrollable()) { aPc->PresShell()->GetRootScrollContainerFrame()) {
sf->MarkScrollbarsDirtyForReflow(); sf->MarkScrollbarsDirtyForReflow();
} }
aHint |= nsChangeHint_ReflowHintsForScrollbarChange; aHint |= nsChangeHint_ReflowHintsForScrollbarChange;

View file

@ -12,11 +12,11 @@
#include "mozilla/layers/ZoomConstraints.h" #include "mozilla/layers/ZoomConstraints.h"
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
#include "mozilla/PresShell.h" #include "mozilla/PresShell.h"
#include "mozilla/ScrollContainerFrame.h"
#include "mozilla/StaticPrefs_apz.h" #include "mozilla/StaticPrefs_apz.h"
#include "mozilla/dom/Document.h" #include "mozilla/dom/Document.h"
#include "mozilla/dom/Event.h" #include "mozilla/dom/Event.h"
#include "nsIFrame.h" #include "nsIFrame.h"
#include "nsIScrollableFrame.h"
#include "nsLayoutUtils.h" #include "nsLayoutUtils.h"
#include "nsPoint.h" #include "nsPoint.h"
#include "nsView.h" #include "nsView.h"
@ -275,8 +275,8 @@ void ZoomConstraintsClient::RefreshZoomConstraints() {
// We only ever create a ZoomConstraintsClient for an RCD, so the RSF of // We only ever create a ZoomConstraintsClient for an RCD, so the RSF of
// the presShell must be the RCD-RSF (if it exists). // the presShell must be the RCD-RSF (if it exists).
MOZ_ASSERT(mPresShell->GetPresContext()->IsRootContentDocumentCrossProcess()); MOZ_ASSERT(mPresShell->GetPresContext()->IsRootContentDocumentCrossProcess());
if (nsIScrollableFrame* rcdrsf = if (ScrollContainerFrame* rcdrsf =
mPresShell->GetRootScrollFrameAsScrollable()) { mPresShell->GetRootScrollContainerFrame()) {
ZCC_LOG("Notifying RCD-RSF that it is zoomable: %d\n", ZCC_LOG("Notifying RCD-RSF that it is zoomable: %d\n",
mZoomConstraints.mAllowZoom); mZoomConstraints.mAllowZoom);
rcdrsf->SetZoomableByAPZ(mZoomConstraints.mAllowZoom); rcdrsf->SetZoomableByAPZ(mZoomConstraints.mAllowZoom);

View file

@ -48,6 +48,7 @@
#include "mozilla/Encoding.h" #include "mozilla/Encoding.h"
#include "mozilla/ErrorResult.h" #include "mozilla/ErrorResult.h"
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
#include "mozilla/ScrollContainerFrame.h"
#include "mozilla/SpinEventLoopUntil.h" #include "mozilla/SpinEventLoopUntil.h"
#include "mozilla/WeakPtr.h" #include "mozilla/WeakPtr.h"
#include "mozilla/StaticPrefs_dom.h" #include "mozilla/StaticPrefs_dom.h"
@ -86,7 +87,6 @@
#include "nsJSEnvironment.h" #include "nsJSEnvironment.h"
#include "nsFocusManager.h" #include "nsFocusManager.h"
#include "nsIScrollableFrame.h"
#include "nsStyleSheetService.h" #include "nsStyleSheetService.h"
#include "nsILoadContext.h" #include "nsILoadContext.h"
#include "mozilla/ThrottledEventQueue.h" #include "mozilla/ThrottledEventQueue.h"
@ -2954,18 +2954,19 @@ static const nsIFrame* GetTargetPageFrame(int32_t aTargetPageNum,
} }
// Calculate the scroll position where the center of |aFrame| is positioned at // Calculate the scroll position where the center of |aFrame| is positioned at
// the center of |aScrollable|'s scroll port for the print preview. // the center of |aScrollContainerFrame|'s scroll port for the print preview.
// So what we do for that is; // So what we do for that is;
// 1) Calculate the position of the center of |aFrame| in the print preview // 1) Calculate the position of the center of |aFrame| in the print preview
// coordinates. // coordinates.
// 2) Reduce the half height of the scroll port from the result of 1. // 2) Reduce the half height of the scroll port from the result of 1.
static nscoord ScrollPositionForFrame(const nsIFrame* aFrame, static nscoord ScrollPositionForFrame(
nsIScrollableFrame* aScrollable, const nsIFrame* aFrame, ScrollContainerFrame* aScrollContainerFrame,
float aPreviewScale) { float aPreviewScale) {
// Note that even if the computed scroll position is out of the range of // Note that even if the computed scroll position is out of the range of
// the scroll port, it gets clamped in nsIScrollableFrame::ScrollTo. // the scroll port, it gets clamped in nsIScrollableFrame::ScrollTo.
return nscoord(aPreviewScale * aFrame->GetRect().Center().y - return nscoord(aPreviewScale * aFrame->GetRect().Center().y -
float(aScrollable->GetScrollPortRect().height) / 2.0f); float(aScrollContainerFrame->GetScrollPortRect().height) /
2.0f);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -2974,8 +2975,10 @@ nsDocumentViewer::PrintPreviewScrollToPage(int16_t aType, int32_t aPageNum) {
if (!GetIsPrintPreview() || mPrintJob->GetIsCreatingPrintPreview()) if (!GetIsPrintPreview() || mPrintJob->GetIsCreatingPrintPreview())
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
nsIScrollableFrame* sf = mPresShell->GetRootScrollFrameAsScrollable(); ScrollContainerFrame* sf = mPresShell->GetRootScrollContainerFrame();
if (!sf) return NS_OK; if (!sf) {
return NS_OK;
}
auto [seqFrame, sheetCount] = mPrintJob->GetSeqFrameAndCountSheets(); auto [seqFrame, sheetCount] = mPrintJob->GetSeqFrameAndCountSheets();
Unused << sheetCount; Unused << sheetCount;
@ -3048,7 +3051,7 @@ nsDocumentViewer::GetCurrentSheetFrameAndNumber() const {
return {nullptr, 0}; return {nullptr, 0};
} }
nsIScrollableFrame* sf = mPresShell->GetRootScrollFrameAsScrollable(); ScrollContainerFrame* sf = mPresShell->GetRootScrollContainerFrame();
if (!sf) { if (!sf) {
// No scrollable contents, returns 1 even if there are multiple sheets. // No scrollable contents, returns 1 even if there are multiple sheets.
return {seqFrame->PrincipalChildList().FirstChild(), 1}; return {seqFrame->PrincipalChildList().FirstChild(), 1};

View file

@ -3061,14 +3061,12 @@ void nsLayoutUtils::PaintFrame(gfxContext* aRenderingContext, nsIFrame* aFrame,
aFrame, builder); aFrame, builder);
} }
nsIFrame* rootScrollContainerFrame = presShell->GetRootScrollContainerFrame(); ScrollContainerFrame* rootScrollContainerFrame =
presShell->GetRootScrollContainerFrame();
if (rootScrollContainerFrame && !aFrame->GetParent()) { if (rootScrollContainerFrame && !aFrame->GetParent()) {
nsIScrollableFrame* rootScrollableFrame =
presShell->GetRootScrollFrameAsScrollable();
MOZ_ASSERT(rootScrollableFrame);
nsRect displayPortBase = rootInkOverflow; nsRect displayPortBase = rootInkOverflow;
nsRect temp = displayPortBase; nsRect temp = displayPortBase;
Unused << rootScrollableFrame->DecideScrollableLayer( Unused << rootScrollContainerFrame->DecideScrollableLayer(
builder, &displayPortBase, &temp, builder, &displayPortBase, &temp,
/* aSetBase = */ true); /* aSetBase = */ true);
} }
@ -3089,11 +3087,9 @@ void nsLayoutUtils::PaintFrame(gfxContext* aRenderingContext, nsIFrame* aFrame,
Maybe<nsPoint> originalScrollPosition; Maybe<nsPoint> originalScrollPosition;
auto maybeResetScrollPosition = MakeScopeExit([&]() { auto maybeResetScrollPosition = MakeScopeExit([&]() {
if (originalScrollPosition && rootScrollContainerFrame) { if (originalScrollPosition && rootScrollContainerFrame) {
nsIScrollableFrame* rootScrollableFrame = MOZ_ASSERT(rootScrollContainerFrame->GetScrolledFrame()->GetPosition() ==
presShell->GetRootScrollFrameAsScrollable();
MOZ_ASSERT(rootScrollableFrame->GetScrolledFrame()->GetPosition() ==
nsPoint()); nsPoint());
rootScrollableFrame->GetScrolledFrame()->SetPosition( rootScrollContainerFrame->GetScrolledFrame()->SetPosition(
*originalScrollPosition); *originalScrollPosition);
} }
}); });
@ -3109,21 +3105,19 @@ void nsLayoutUtils::PaintFrame(gfxContext* aRenderingContext, nsIFrame* aFrame,
} }
if (ignoreViewportScrolling && rootScrollContainerFrame) { if (ignoreViewportScrolling && rootScrollContainerFrame) {
nsIScrollableFrame* rootScrollableFrame =
presShell->GetRootScrollFrameAsScrollable();
if (aFlags & PaintFrameFlags::ResetViewportScrolling) { if (aFlags & PaintFrameFlags::ResetViewportScrolling) {
// Temporarily scroll the root scroll frame to 0,0 so that position:fixed // Temporarily scroll the root scroll frame to 0,0 so that position:fixed
// elements will appear fixed to the top-left of the document. We manually // elements will appear fixed to the top-left of the document. We manually
// set the position of the scrolled frame instead of using ScrollTo, since // set the position of the scrolled frame instead of using ScrollTo, since
// the latter fires scroll listeners, which we don't want. // the latter fires scroll listeners, which we don't want.
originalScrollPosition.emplace( originalScrollPosition.emplace(
rootScrollableFrame->GetScrolledFrame()->GetPosition()); rootScrollContainerFrame->GetScrolledFrame()->GetPosition());
rootScrollableFrame->GetScrolledFrame()->SetPosition(nsPoint()); rootScrollContainerFrame->GetScrolledFrame()->SetPosition(nsPoint());
} }
if (aFlags & PaintFrameFlags::DocumentRelative) { if (aFlags & PaintFrameFlags::DocumentRelative) {
// Make visibleRegion and aRenderingContext relative to the // Make visibleRegion and aRenderingContext relative to the
// scrolled frame instead of the root frame. // scrolled frame instead of the root frame.
nsPoint pos = rootScrollableFrame->GetScrollPosition(); nsPoint pos = rootScrollContainerFrame->GetScrollPosition();
visibleRegion.MoveBy(-pos); visibleRegion.MoveBy(-pos);
if (aRenderingContext) { if (aRenderingContext) {
gfxPoint devPixelOffset = nsLayoutUtils::PointToGfxPoint( gfxPoint devPixelOffset = nsLayoutUtils::PointToGfxPoint(
@ -3136,7 +3130,7 @@ void nsLayoutUtils::PaintFrame(gfxContext* aRenderingContext, nsIFrame* aFrame,
builder->SetIgnoreScrollFrame(rootScrollContainerFrame); builder->SetIgnoreScrollFrame(rootScrollContainerFrame);
nsCanvasFrame* canvasFrame = nsCanvasFrame* canvasFrame =
do_QueryFrame(rootScrollableFrame->GetScrolledFrame()); do_QueryFrame(rootScrollContainerFrame->GetScrolledFrame());
if (canvasFrame) { if (canvasFrame) {
// Use UnionRect here to ensure that areas where the scrollbars // Use UnionRect here to ensure that areas where the scrollbars
// were are still filled with the background color. // were are still filled with the background color.

View file

@ -723,8 +723,7 @@ class ScrollContainerFrame : public nsContainerFrame,
nsRect RestrictToRootDisplayPort(const nsRect& aDisplayportBase); nsRect RestrictToRootDisplayPort(const nsRect& aDisplayportBase);
bool DecideScrollableLayer(nsDisplayListBuilder* aBuilder, bool DecideScrollableLayer(nsDisplayListBuilder* aBuilder,
nsRect* aVisibleRect, nsRect* aDirtyRect, nsRect* aVisibleRect, nsRect* aDirtyRect,
bool aSetBase, bool aSetBase, bool* aDirtyRectHasBeenOverriden);
bool* aDirtyRectHasBeenOverriden = nullptr);
bool AllowDisplayPortExpiration(); bool AllowDisplayPortExpiration();
void ResetDisplayPortExpiryTimer(); void ResetDisplayPortExpiryTimer();

View file

@ -17,6 +17,7 @@
#include "mozilla/layers/RenderRootStateManager.h" #include "mozilla/layers/RenderRootStateManager.h"
#include "mozilla/layers/StackingContextHelper.h" #include "mozilla/layers/StackingContextHelper.h"
#include "mozilla/PresShell.h" #include "mozilla/PresShell.h"
#include "mozilla/ScrollContainerFrame.h"
#include "mozilla/StaticPrefs_browser.h" #include "mozilla/StaticPrefs_browser.h"
#include "mozilla/StaticPrefs_layout.h" #include "mozilla/StaticPrefs_layout.h"
#include "nsContainerFrame.h" #include "nsContainerFrame.h"
@ -27,7 +28,6 @@
#include "nsFrameManager.h" #include "nsFrameManager.h"
#include "nsGkAtoms.h" #include "nsGkAtoms.h"
#include "nsIFrameInlines.h" #include "nsIFrameInlines.h"
#include "nsIScrollableFrame.h"
#include "nsPresContext.h" #include "nsPresContext.h"
using namespace mozilla; using namespace mozilla;
@ -196,8 +196,7 @@ void nsCanvasFrame::AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
} }
void nsCanvasFrame::Destroy(DestroyContext& aContext) { void nsCanvasFrame::Destroy(DestroyContext& aContext) {
nsIScrollableFrame* sf = PresShell()->GetRootScrollFrameAsScrollable(); if (ScrollContainerFrame* sf = PresShell()->GetRootScrollContainerFrame()) {
if (sf) {
sf->RemoveScrollPositionListener(this); sf->RemoveScrollPositionListener(this);
} }
@ -222,8 +221,8 @@ nsCanvasFrame::SetHasFocus(bool aHasFocus) {
PresShell()->GetRootFrame()->InvalidateFrameSubtree(); PresShell()->GetRootFrame()->InvalidateFrameSubtree();
if (!mAddedScrollPositionListener) { if (!mAddedScrollPositionListener) {
nsIScrollableFrame* sf = PresShell()->GetRootScrollFrameAsScrollable(); if (ScrollContainerFrame* sf =
if (sf) { PresShell()->GetRootScrollContainerFrame()) {
sf->AddScrollPositionListener(this); sf->AddScrollPositionListener(this);
mAddedScrollPositionListener = true; mAddedScrollPositionListener = true;
} }

View file

@ -1257,9 +1257,9 @@ void nsIFrame::DidSetComputedStyle(ComputedStyle* aOldComputedStyle) {
} }
if (aOldComputedStyle->IsRootElementStyle() && if (aOldComputedStyle->IsRootElementStyle() &&
disp->mScrollSnapType != oldDisp->mScrollSnapType) { disp->mScrollSnapType != oldDisp->mScrollSnapType) {
if (nsIScrollableFrame* scrollableFrame = if (ScrollContainerFrame* sf =
PresShell()->GetRootScrollFrameAsScrollable()) { PresShell()->GetRootScrollContainerFrame()) {
scrollableFrame->PostPendingResnap(); sf->PostPendingResnap();
} }
} }
if (StyleUIReset()->mMozSubtreeHiddenOnlyVisually && if (StyleUIReset()->mMozSubtreeHiddenOnlyVisually &&

View file

@ -14,6 +14,7 @@
#include "mozilla/ComputedStyleInlines.h" #include "mozilla/ComputedStyleInlines.h"
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
#include "mozilla/PresShell.h" #include "mozilla/PresShell.h"
#include "mozilla/ScrollContainerFrame.h"
#include "mozilla/StaticPrefs_layout.h" #include "mozilla/StaticPrefs_layout.h"
#include "mozilla/Unused.h" #include "mozilla/Unused.h"
#include "mozilla/dom/Document.h" #include "mozilla/dom/Document.h"
@ -38,7 +39,6 @@
#include "nsFrameSetFrame.h" #include "nsFrameSetFrame.h"
#include "nsNameSpaceManager.h" #include "nsNameSpaceManager.h"
#include "nsDisplayList.h" #include "nsDisplayList.h"
#include "nsIScrollableFrame.h"
#include "nsIObjectLoadingContent.h" #include "nsIObjectLoadingContent.h"
#include "nsLayoutUtils.h" #include "nsLayoutUtils.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
@ -406,15 +406,13 @@ void nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
visible = visible.ScaleToOtherAppUnitsRoundOut(parentAPD, subdocAPD); visible = visible.ScaleToOtherAppUnitsRoundOut(parentAPD, subdocAPD);
dirty = dirty.ScaleToOtherAppUnitsRoundOut(parentAPD, subdocAPD); dirty = dirty.ScaleToOtherAppUnitsRoundOut(parentAPD, subdocAPD);
if (nsIScrollableFrame* rootScrollableFrame = if (ScrollContainerFrame* sf = presShell->GetRootScrollContainerFrame()) {
presShell->GetRootScrollFrameAsScrollable()) {
// Use a copy, so the rects don't get modified. // Use a copy, so the rects don't get modified.
nsRect copyOfDirty = dirty; nsRect copyOfDirty = dirty;
nsRect copyOfVisible = visible; nsRect copyOfVisible = visible;
// TODO(botond): Can we just axe this DecideScrollableLayer call? // TODO(botond): Can we just axe this DecideScrollableLayer call?
rootScrollableFrame->DecideScrollableLayer(aBuilder, &copyOfVisible, sf->DecideScrollableLayer(aBuilder, &copyOfVisible, &copyOfDirty,
&copyOfDirty, /* aSetBase = */ true);
/* aSetBase = */ true);
ignoreViewportScrolling = presShell->IgnoringViewportScrolling(); ignoreViewportScrolling = presShell->IgnoringViewportScrolling();
} }
@ -429,7 +427,7 @@ void nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
DisplayListClipState::AutoSaveRestore clipState(aBuilder); DisplayListClipState::AutoSaveRestore clipState(aBuilder);
clipState.ClipContainingBlockDescendantsToContentBox(aBuilder, this); clipState.ClipContainingBlockDescendantsToContentBox(aBuilder, this);
nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable(); ScrollContainerFrame* sf = presShell->GetRootScrollContainerFrame();
bool constructZoomItem = subdocRootFrame && parentAPD != subdocAPD; bool constructZoomItem = subdocRootFrame && parentAPD != subdocAPD;
bool needsOwnLayer = constructZoomItem || bool needsOwnLayer = constructZoomItem ||
presContext->IsRootContentDocumentCrossProcess() || presContext->IsRootContentDocumentCrossProcess() ||

View file

@ -8,10 +8,10 @@
#include "RetainedDisplayListBuilder.h" #include "RetainedDisplayListBuilder.h"
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/ScrollContainerFrame.h"
#include "mozilla/StaticPrefs_layout.h" #include "mozilla/StaticPrefs_layout.h"
#include "nsIFrame.h" #include "nsIFrame.h"
#include "nsIFrameInlines.h" #include "nsIFrameInlines.h"
#include "nsIScrollableFrame.h"
#include "nsPlaceholderFrame.h" #include "nsPlaceholderFrame.h"
#include "nsSubDocumentFrame.h" #include "nsSubDocumentFrame.h"
#include "nsViewManager.h" #include "nsViewManager.h"
@ -1611,8 +1611,8 @@ PartialUpdateResult RetainedDisplayListBuilder::AttemptPartialUpdate(
// This is normally handled by EnterPresShell, but we skipped it so that we // This is normally handled by EnterPresShell, but we skipped it so that we
// didn't call MarkFrameForDisplayIfVisible before ComputeRebuildRegion. // didn't call MarkFrameForDisplayIfVisible before ComputeRebuildRegion.
nsIScrollableFrame* sf = ScrollContainerFrame* sf =
RootReferenceFrame()->PresShell()->GetRootScrollFrameAsScrollable(); RootReferenceFrame()->PresShell()->GetRootScrollContainerFrame();
if (sf) { if (sf) {
nsCanvasFrame* canvasFrame = do_QueryFrame(sf->GetScrolledFrame()); nsCanvasFrame* canvasFrame = do_QueryFrame(sf->GetScrolledFrame());
if (canvasFrame) { if (canvasFrame) {

View file

@ -23,6 +23,7 @@
#include "mozilla/HashFunctions.h" #include "mozilla/HashFunctions.h"
#include "mozilla/MathAlgorithms.h" #include "mozilla/MathAlgorithms.h"
#include "mozilla/PresShell.h" #include "mozilla/PresShell.h"
#include "mozilla/ScrollContainerFrame.h"
#include "mozilla/StaticPtr.h" #include "mozilla/StaticPtr.h"
#include "mozilla/SVGImageContext.h" #include "mozilla/SVGImageContext.h"
#include "gfxFont.h" #include "gfxFont.h"
@ -43,7 +44,6 @@
#include "nsCSSAnonBoxes.h" #include "nsCSSAnonBoxes.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/DocumentInlines.h"
#include "nsIScrollableFrame.h"
#include "imgIContainer.h" #include "imgIContainer.h"
#include "ImageOps.h" #include "ImageOps.h"
#include "nsCSSColorUtils.h" #include "nsCSSColorUtils.h"
@ -2860,10 +2860,9 @@ nsRect nsCSSRendering::ComputeImageLayerPositioningArea(
if (!pageContentFrame) { if (!pageContentFrame) {
// Subtract the size of scrollbars. // Subtract the size of scrollbars.
nsIScrollableFrame* scrollableFrame = if (ScrollContainerFrame* sf =
aPresContext->PresShell()->GetRootScrollFrameAsScrollable(); aPresContext->PresShell()->GetRootScrollContainerFrame()) {
if (scrollableFrame) { nsMargin scrollbars = sf->GetActualScrollbarSizes();
nsMargin scrollbars = scrollableFrame->GetActualScrollbarSizes();
positionArea.Deflate(scrollbars); positionArea.Deflate(scrollbars);
} }
} }

View file

@ -1084,7 +1084,7 @@ void nsDisplayListBuilder::EnterPresShell(const nsIFrame* aReferenceFrame,
state->mFirstFrameMarkedForDisplay = mFramesMarkedForDisplay.Length(); state->mFirstFrameMarkedForDisplay = mFramesMarkedForDisplay.Length();
state->mFirstFrameWithOOFData = mFramesWithOOFData.Length(); state->mFirstFrameWithOOFData = mFramesWithOOFData.Length();
nsIScrollableFrame* sf = state->mPresShell->GetRootScrollFrameAsScrollable(); ScrollContainerFrame* sf = state->mPresShell->GetRootScrollContainerFrame();
if (sf && IsInSubdocument()) { if (sf && IsInSubdocument()) {
// We are forcing a rebuild of nsDisplayCanvasBackgroundColor to make sure // We are forcing a rebuild of nsDisplayCanvasBackgroundColor to make sure
// that the canvas background color will be set correctly, and that only one // that the canvas background color will be set correctly, and that only one