Bug 1896516 Part 3 - Change GetScrollTargetFrame() to return ScrollContainerFrame. r=layout-reviewers,emilio

Also, simplify some callers of `GetScrollTargetFrame()` to drop
`nsIScrollableFrame*` and unnecessary `do_QueryFrame`. We'll continue removing
more `nsIScrollableFrame*` in later parts.

Differential Revision: https://phabricator.services.mozilla.com/D211490
This commit is contained in:
Ting-Yu Lin 2024-05-30 06:32:18 +00:00
parent 31c3239b70
commit df8ff2d9ac
17 changed files with 124 additions and 120 deletions

View file

@ -30,7 +30,6 @@
#include "nsIInterfaceRequestorUtils.h" #include "nsIInterfaceRequestorUtils.h"
#include "nsImageFrame.h" #include "nsImageFrame.h"
#include "nsViewManager.h" #include "nsViewManager.h"
#include "nsIScrollableFrame.h"
#include "nsIURI.h" #include "nsIURI.h"
#include "nsIWebNavigation.h" #include "nsIWebNavigation.h"
#include "nsFocusManager.h" #include "nsFocusManager.h"
@ -42,6 +41,7 @@
#include "mozilla/ipc/ProcessChild.h" #include "mozilla/ipc/ProcessChild.h"
#include "mozilla/PerfStats.h" #include "mozilla/PerfStats.h"
#include "mozilla/PresShell.h" #include "mozilla/PresShell.h"
#include "mozilla/ScrollContainerFrame.h"
#include "nsAccessibilityService.h" #include "nsAccessibilityService.h"
#include "mozilla/a11y/DocAccessibleChild.h" #include "mozilla/a11y/DocAccessibleChild.h"
#include "mozilla/dom/AncestorIterator.h" #include "mozilla/dom/AncestorIterator.h"
@ -709,9 +709,9 @@ std::pair<nsPoint, nsRect> DocAccessible::ComputeScrollData(
nsRect scrollRange; nsRect scrollRange;
if (nsIFrame* frame = aAcc->GetFrame()) { if (nsIFrame* frame = aAcc->GetFrame()) {
nsIScrollableFrame* sf = aAcc == this ScrollContainerFrame* sf = aAcc == this
? mPresShell->GetRootScrollFrameAsScrollable() ? mPresShell->GetRootScrollContainerFrame()
: frame->GetScrollTargetFrame(); : frame->GetScrollTargetFrame();
// If there is no scrollable frame, it's likely a scroll in a popup, like // If there is no scrollable frame, it's likely a scroll in a popup, like
// <select>. Return a scroll offset and range of 0. The scroll info // <select>. Return a scroll offset and range of 0. The scroll info

View file

@ -58,7 +58,6 @@
#include "nsTextFrame.h" #include "nsTextFrame.h"
#include "nsView.h" #include "nsView.h"
#include "nsIDocShellTreeItem.h" #include "nsIDocShellTreeItem.h"
#include "nsIScrollableFrame.h"
#include "nsStyleStructInlines.h" #include "nsStyleStructInlines.h"
#include "nsFocusManager.h" #include "nsFocusManager.h"
@ -72,6 +71,7 @@
#include "mozilla/FloatingPoint.h" #include "mozilla/FloatingPoint.h"
#include "mozilla/PresShell.h" #include "mozilla/PresShell.h"
#include "mozilla/ProfilerMarkers.h" #include "mozilla/ProfilerMarkers.h"
#include "mozilla/ScrollContainerFrame.h"
#include "mozilla/StaticPrefs_ui.h" #include "mozilla/StaticPrefs_ui.h"
#include "mozilla/dom/Element.h" #include "mozilla/dom/Element.h"
#include "mozilla/dom/HTMLLabelElement.h" #include "mozilla/dom/HTMLLabelElement.h"
@ -670,9 +670,9 @@ nsRect LocalAccessible::ParentRelativeBounds() {
return result; return result;
} }
if (nsIScrollableFrame* sf = if (ScrollContainerFrame* sf =
mParent == mDoc mParent == mDoc
? mDoc->PresShellPtr()->GetRootScrollFrameAsScrollable() ? mDoc->PresShellPtr()->GetRootScrollContainerFrame()
: boundingFrame->GetScrollTargetFrame()) { : boundingFrame->GetScrollTargetFrame()) {
// If boundingFrame has a scroll position, result is currently relative // If boundingFrame has a scroll position, result is currently relative
// to that. Instead, we want result to remain the same regardless of // to that. Instead, we want result to remain the same regardless of

View file

@ -33,11 +33,11 @@
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
#include "nsTextNode.h" #include "nsTextNode.h"
#include "nsIController.h" #include "nsIController.h"
#include "nsIScrollableFrame.h"
#include "mozilla/AutoRestore.h" #include "mozilla/AutoRestore.h"
#include "mozilla/InputEventOptions.h" #include "mozilla/InputEventOptions.h"
#include "mozilla/NativeKeyBindingsType.h" #include "mozilla/NativeKeyBindingsType.h"
#include "mozilla/PresShell.h" #include "mozilla/PresShell.h"
#include "mozilla/ScrollContainerFrame.h"
#include "mozilla/TextEvents.h" #include "mozilla/TextEvents.h"
#include "mozilla/dom/Event.h" #include "mozilla/dom/Event.h"
#include "mozilla/dom/ScriptSettings.h" #include "mozilla/dom/ScriptSettings.h"
@ -340,7 +340,7 @@ class TextInputSelectionController final : public nsSupportsWeakReference,
TextInputSelectionController(PresShell* aPresShell, nsIContent* aLimiter); TextInputSelectionController(PresShell* aPresShell, nsIContent* aLimiter);
void SetScrollableFrame(nsIScrollableFrame* aScrollableFrame); void SetScrollContainerFrame(ScrollContainerFrame* aScrollContainerFrame);
nsFrameSelection* GetConstFrameSelection() { return mFrameSelection; } nsFrameSelection* GetConstFrameSelection() { return mFrameSelection; }
// Will return null if !mFrameSelection. // Will return null if !mFrameSelection.
Selection* GetSelection(SelectionType aSelectionType); Selection* GetSelection(SelectionType aSelectionType);
@ -383,7 +383,7 @@ class TextInputSelectionController final : public nsSupportsWeakReference,
private: private:
RefPtr<nsFrameSelection> mFrameSelection; RefPtr<nsFrameSelection> mFrameSelection;
nsIScrollableFrame* mScrollFrame; ScrollContainerFrame* mScrollContainerFrame = nullptr;
nsWeakPtr mPresShellWeak; nsWeakPtr mPresShellWeak;
}; };
@ -398,8 +398,7 @@ NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_WEAK(TextInputSelectionController, mFrameSelection) NS_IMPL_CYCLE_COLLECTION_WEAK(TextInputSelectionController, mFrameSelection)
TextInputSelectionController::TextInputSelectionController( TextInputSelectionController::TextInputSelectionController(
PresShell* aPresShell, nsIContent* aLimiter) PresShell* aPresShell, nsIContent* aLimiter) {
: mScrollFrame(nullptr) {
if (aPresShell) { if (aPresShell) {
bool accessibleCaretEnabled = bool accessibleCaretEnabled =
PresShell::AccessibleCaretEnabled(aLimiter->OwnerDoc()->GetDocShell()); PresShell::AccessibleCaretEnabled(aLimiter->OwnerDoc()->GetDocShell());
@ -409,10 +408,10 @@ TextInputSelectionController::TextInputSelectionController(
} }
} }
void TextInputSelectionController::SetScrollableFrame( void TextInputSelectionController::SetScrollContainerFrame(
nsIScrollableFrame* aScrollableFrame) { ScrollContainerFrame* aScrollContainerFrame) {
mScrollFrame = aScrollableFrame; mScrollContainerFrame = aScrollContainerFrame;
if (!mScrollFrame && mFrameSelection) { if (!mScrollContainerFrame && mFrameSelection) {
mFrameSelection->DisconnectFromPresShell(); mFrameSelection->DisconnectFromPresShell();
mFrameSelection = nullptr; mFrameSelection = nullptr;
} }
@ -653,16 +652,15 @@ NS_IMETHODIMP
TextInputSelectionController::PageMove(bool aForward, bool aExtend) { TextInputSelectionController::PageMove(bool aForward, bool aExtend) {
// expected behavior for PageMove is to scroll AND move the caret // expected behavior for PageMove is to scroll AND move the caret
// and to remain relative position of the caret in view. see Bug 4302. // and to remain relative position of the caret in view. see Bug 4302.
if (mScrollFrame) { if (mScrollContainerFrame) {
RefPtr<nsFrameSelection> frameSelection = mFrameSelection; RefPtr<nsFrameSelection> frameSelection = mFrameSelection;
nsIFrame* scrollFrame = do_QueryFrame(mScrollFrame); // We won't scroll parent scrollable element of mScrollContainerFrame.
// We won't scroll parent scrollable element of mScrollFrame. Therefore, // Therefore, this may be handled when mScrollContainerFrame is completely
// this may be handled when mScrollFrame is completely outside of the view. // outside of the view. In such case, user may be confused since they might
// In such case, user may be confused since they might have wanted to // have wanted to scroll a parent scrollable element. For making clearer
// scroll a parent scrollable element. For making clearer which element // which element handles PageDown/PageUp, we should move selection into view
// handles PageDown/PageUp, we should move selection into view even if // even if selection is not changed.
// selection is not changed. return frameSelection->PageMove(aForward, aExtend, mScrollContainerFrame,
return frameSelection->PageMove(aForward, aExtend, scrollFrame,
nsFrameSelection::SelectionIntoView::Yes); nsFrameSelection::SelectionIntoView::Yes);
} }
// Similarly, if there is no scrollable frame, we should move the editor // Similarly, if there is no scrollable frame, we should move the editor
@ -677,12 +675,12 @@ TextInputSelectionController::PageMove(bool aForward, bool aExtend) {
NS_IMETHODIMP NS_IMETHODIMP
TextInputSelectionController::CompleteScroll(bool aForward) { TextInputSelectionController::CompleteScroll(bool aForward) {
if (!mScrollFrame) { if (!mScrollContainerFrame) {
return NS_ERROR_NOT_INITIALIZED; return NS_ERROR_NOT_INITIALIZED;
} }
mScrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::WHOLE, mScrollContainerFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1),
ScrollMode::Instant); ScrollUnit::WHOLE, ScrollMode::Instant);
return NS_OK; return NS_OK;
} }
@ -730,34 +728,34 @@ TextInputSelectionController::CompleteMove(bool aForward, bool aExtend) {
NS_IMETHODIMP NS_IMETHODIMP
TextInputSelectionController::ScrollPage(bool aForward) { TextInputSelectionController::ScrollPage(bool aForward) {
if (!mScrollFrame) { if (!mScrollContainerFrame) {
return NS_ERROR_NOT_INITIALIZED; return NS_ERROR_NOT_INITIALIZED;
} }
mScrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::PAGES, mScrollContainerFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1),
ScrollMode::Smooth); ScrollUnit::PAGES, ScrollMode::Smooth);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
TextInputSelectionController::ScrollLine(bool aForward) { TextInputSelectionController::ScrollLine(bool aForward) {
if (!mScrollFrame) { if (!mScrollContainerFrame) {
return NS_ERROR_NOT_INITIALIZED; return NS_ERROR_NOT_INITIALIZED;
} }
mScrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::LINES, mScrollContainerFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1),
ScrollMode::Smooth); ScrollUnit::LINES, ScrollMode::Smooth);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
TextInputSelectionController::ScrollCharacter(bool aRight) { TextInputSelectionController::ScrollCharacter(bool aRight) {
if (!mScrollFrame) { if (!mScrollContainerFrame) {
return NS_ERROR_NOT_INITIALIZED; return NS_ERROR_NOT_INITIALIZED;
} }
mScrollFrame->ScrollBy(nsIntPoint(aRight ? 1 : -1, 0), ScrollUnit::LINES, mScrollContainerFrame->ScrollBy(nsIntPoint(aRight ? 1 : -1, 0),
ScrollMode::Smooth); ScrollUnit::LINES, ScrollMode::Smooth);
return NS_OK; return NS_OK;
} }
@ -2449,7 +2447,7 @@ void TextControlState::UnbindFromFrame(nsTextControlFrame* aFrame) {
mTextListener->EndListeningToSelectionChange(); mTextListener->EndListeningToSelectionChange();
} }
mSelCon->SetScrollableFrame(nullptr); mSelCon->SetScrollContainerFrame(nullptr);
mSelCon = nullptr; mSelCon = nullptr;
} }
@ -3037,7 +3035,7 @@ void TextControlState::InitializeKeyboardEventListeners() {
TrustedEventsAtSystemGroupBubble()); TrustedEventsAtSystemGroupBubble());
} }
mSelCon->SetScrollableFrame(mBoundFrame->GetScrollTargetFrame()); mSelCon->SetScrollContainerFrame(mBoundFrame->GetScrollTargetFrame());
} }
void TextControlState::SetPreviewText(const nsAString& aValue, bool aNotify) { void TextControlState::SetPreviewText(const nsAString& aValue, bool aNotify) {

View file

@ -196,10 +196,10 @@ static nsRect GetDisplayPortFromMarginsData(
isRoot = true; isRoot = true;
} }
nsIScrollableFrame* scrollableFrame = frame->GetScrollTargetFrame(); ScrollContainerFrame* scrollContainerFrame = frame->GetScrollTargetFrame();
nsPoint scrollPos; nsPoint scrollPos;
if (scrollableFrame) { if (scrollContainerFrame) {
scrollPos = scrollableFrame->GetScrollPosition(); scrollPos = scrollContainerFrame->GetScrollPosition();
} }
nsPresContext* presContext = frame->PresContext(); nsPresContext* presContext = frame->PresContext();
@ -252,7 +252,7 @@ static nsRect GetDisplayPortFromMarginsData(
MOZ_ASSERT(presShell); MOZ_ASSERT(presShell);
ScreenMargin margins = aMarginsData->mMargins.GetRelativeToLayoutViewport( ScreenMargin margins = aMarginsData->mMargins.GetRelativeToLayoutViewport(
aOptions.mGeometryType, scrollableFrame, aOptions.mGeometryType, scrollContainerFrame,
presContext->CSSToDevPixelScale() * res); presContext->CSSToDevPixelScale() * res);
if (presShell->IsDisplayportSuppressed() || if (presShell->IsDisplayportSuppressed() ||
@ -514,7 +514,7 @@ void DisplayPortUtils::InvalidateForDisplayPortChange(
nsIFrame* frame = nsLayoutUtils::GetScrollFrameFromContent(aContent); nsIFrame* frame = nsLayoutUtils::GetScrollFrameFromContent(aContent);
if (frame) { if (frame) {
frame = do_QueryFrame(frame->GetScrollTargetFrame()); frame = frame->GetScrollTargetFrame();
} }
if (changed && frame) { if (changed && frame) {
@ -625,9 +625,9 @@ bool DisplayPortUtils::SetDisplayPortMargins(
aContent->RemoveProperty(nsGkAtoms::MinimalDisplayPort); aContent->RemoveProperty(nsGkAtoms::MinimalDisplayPort);
} }
nsIScrollableFrame* scrollableFrame = ScrollContainerFrame* scrollContainerFrame =
scrollFrame ? scrollFrame->GetScrollTargetFrame() : nullptr; scrollFrame ? scrollFrame->GetScrollTargetFrame() : nullptr;
if (!scrollableFrame) { if (!scrollContainerFrame) {
return true; return true;
} }
@ -657,13 +657,13 @@ bool DisplayPortUtils::SetDisplayPortMargins(
InvalidateForDisplayPortChange(aContent, hadDisplayPort, oldDisplayPort, InvalidateForDisplayPortChange(aContent, hadDisplayPort, oldDisplayPort,
newDisplayPort, aRepaintMode); newDisplayPort, aRepaintMode);
scrollableFrame->TriggerDisplayPortExpiration(); scrollContainerFrame->TriggerDisplayPortExpiration();
// Display port margins changing means that the set of visible frames may // Display port margins changing means that the set of visible frames may
// have drastically changed. Check if we should schedule an update. // have drastically changed. Check if we should schedule an update.
hadDisplayPort = hadDisplayPort = scrollContainerFrame
scrollableFrame->GetDisplayPortAtLastApproximateFrameVisibilityUpdate( ->GetDisplayPortAtLastApproximateFrameVisibilityUpdate(
&oldDisplayPort); &oldDisplayPort);
bool needVisibilityUpdate = !hadDisplayPort; bool needVisibilityUpdate = !hadDisplayPort;
// Check if the total size has changed by a large factor. // Check if the total size has changed by a large factor.

View file

@ -8326,11 +8326,12 @@ nsMargin nsLayoutUtils::ScrollbarAreaToExcludeFromCompositionBoundsFor(
if (presContext->UseOverlayScrollbars()) { if (presContext->UseOverlayScrollbars()) {
return nsMargin(); return nsMargin();
} }
nsIScrollableFrame* scrollableFrame = aScrollFrame->GetScrollTargetFrame(); ScrollContainerFrame* scrollContainerFrame =
if (!scrollableFrame) { aScrollFrame->GetScrollTargetFrame();
if (!scrollContainerFrame) {
return nsMargin(); return nsMargin();
} }
return scrollableFrame->GetActualScrollbarSizes( return scrollContainerFrame->GetActualScrollbarSizes(
nsIScrollableFrame::ScrollbarSizesOptions:: nsIScrollableFrame::ScrollbarSizesOptions::
INCLUDE_VISUAL_VIEWPORT_SCROLLBARS); INCLUDE_VISUAL_VIEWPORT_SCROLLBARS);
} }
@ -8340,12 +8341,12 @@ nsSize nsLayoutUtils::CalculateCompositionSizeForFrame(
nsIFrame* aFrame, bool aSubtractScrollbars, nsIFrame* aFrame, bool aSubtractScrollbars,
const nsSize* aOverrideScrollPortSize, const nsSize* aOverrideScrollPortSize,
IncludeDynamicToolbar aIncludeDynamicToolbar) { IncludeDynamicToolbar aIncludeDynamicToolbar) {
// If we have a scrollable frame, restrict the composition bounds to its // If we have a scroll container frame, restrict the composition bounds to its
// scroll port. The scroll port excludes the frame borders and the scroll // scroll port. The scroll port excludes the frame borders and the scroll
// bars, which we don't want to be part of the composition bounds. // bars, which we don't want to be part of the composition bounds.
nsIScrollableFrame* scrollableFrame = aFrame->GetScrollTargetFrame(); ScrollContainerFrame* scrollContainerFrame = aFrame->GetScrollTargetFrame();
nsRect rect = scrollableFrame ? scrollableFrame->GetScrollPortRect() nsRect rect = scrollContainerFrame ? scrollContainerFrame->GetScrollPortRect()
: aFrame->GetRect(); : aFrame->GetRect();
nsSize size = nsSize size =
aOverrideScrollPortSize ? *aOverrideScrollPortSize : rect.Size(); aOverrideScrollPortSize ? *aOverrideScrollPortSize : rect.Size();
@ -8778,16 +8779,16 @@ ScrollMetadata nsLayoutUtils::ComputeScrollMetadata(
aContent->GetProperty(nsGkAtoms::MinimalDisplayPort)); aContent->GetProperty(nsGkAtoms::MinimalDisplayPort));
} }
nsIScrollableFrame* scrollableFrame = nullptr; ScrollContainerFrame* scrollContainerFrame =
if (aScrollFrame) scrollableFrame = aScrollFrame->GetScrollTargetFrame(); aScrollFrame ? aScrollFrame->GetScrollTargetFrame() : nullptr;
metrics.SetScrollableRect( metrics.SetScrollableRect(
CSSRect::FromAppUnits(nsLayoutUtils::CalculateScrollableRectForFrame( CSSRect::FromAppUnits(nsLayoutUtils::CalculateScrollableRectForFrame(
scrollableFrame, aForFrame))); scrollContainerFrame, aForFrame)));
if (scrollableFrame) { if (scrollContainerFrame) {
CSSPoint layoutScrollOffset = CSSPoint layoutScrollOffset =
CSSPoint::FromAppUnits(scrollableFrame->GetScrollPosition()); CSSPoint::FromAppUnits(scrollContainerFrame->GetScrollPosition());
CSSPoint visualScrollOffset = CSSPoint visualScrollOffset =
aIsRootContent aIsRootContent
? CSSPoint::FromAppUnits(presShell->GetVisualViewportOffset()) ? CSSPoint::FromAppUnits(presShell->GetVisualViewportOffset())
@ -8808,7 +8809,7 @@ ScrollMetadata nsLayoutUtils::ComputeScrollMetadata(
} }
} }
if (scrollableFrame->IsRootScrollFrameOfDocument()) { if (scrollContainerFrame->IsRootScrollFrameOfDocument()) {
if (const Maybe<PresShell::VisualScrollUpdate>& visualUpdate = if (const Maybe<PresShell::VisualScrollUpdate>& visualUpdate =
presShell->GetPendingVisualScrollUpdate()) { presShell->GetPendingVisualScrollUpdate()) {
metrics.SetVisualDestination( metrics.SetVisualDestination(
@ -8848,19 +8849,20 @@ ScrollMetadata nsLayoutUtils::ComputeScrollMetadata(
} }
} }
metrics.SetScrollGeneration(scrollableFrame->CurrentScrollGeneration()); metrics.SetScrollGeneration(
scrollContainerFrame->CurrentScrollGeneration());
CSSRect viewport = metrics.GetLayoutViewport(); CSSRect viewport = metrics.GetLayoutViewport();
viewport.MoveTo(layoutScrollOffset); viewport.MoveTo(layoutScrollOffset);
metrics.SetLayoutViewport(viewport); metrics.SetLayoutViewport(viewport);
nsSize lineScrollAmount = scrollableFrame->GetLineScrollAmount(); nsSize lineScrollAmount = scrollContainerFrame->GetLineScrollAmount();
LayoutDeviceIntSize lineScrollAmountInDevPixels = LayoutDeviceIntSize lineScrollAmountInDevPixels =
LayoutDeviceIntSize::FromAppUnitsRounded( LayoutDeviceIntSize::FromAppUnitsRounded(
lineScrollAmount, presContext->AppUnitsPerDevPixel()); lineScrollAmount, presContext->AppUnitsPerDevPixel());
metadata.SetLineScrollAmount(lineScrollAmountInDevPixels); metadata.SetLineScrollAmount(lineScrollAmountInDevPixels);
nsSize pageScrollAmount = scrollableFrame->GetPageScrollAmount(); nsSize pageScrollAmount = scrollContainerFrame->GetPageScrollAmount();
LayoutDeviceIntSize pageScrollAmountInDevPixels = LayoutDeviceIntSize pageScrollAmountInDevPixels =
LayoutDeviceIntSize::FromAppUnitsRounded( LayoutDeviceIntSize::FromAppUnitsRounded(
pageScrollAmount, presContext->AppUnitsPerDevPixel()); pageScrollAmount, presContext->AppUnitsPerDevPixel());
@ -8872,10 +8874,10 @@ ScrollMetadata nsLayoutUtils::ComputeScrollMetadata(
aScrollFrame->GetParent())); aScrollFrame->GetParent()));
} }
metadata.SetSnapInfo(scrollableFrame->GetScrollSnapInfo()); metadata.SetSnapInfo(scrollContainerFrame->GetScrollSnapInfo());
metadata.SetOverscrollBehavior( metadata.SetOverscrollBehavior(
scrollableFrame->GetOverscrollBehaviorInfo()); scrollContainerFrame->GetOverscrollBehaviorInfo());
metadata.SetScrollUpdates(scrollableFrame->GetScrollUpdates()); metadata.SetScrollUpdates(scrollContainerFrame->GetScrollUpdates());
} }
// If we have the scrollparent being the same as the scroll id, the // If we have the scrollparent being the same as the scroll id, the
@ -8967,11 +8969,11 @@ ScrollMetadata nsLayoutUtils::ComputeScrollMetadata(
frameForCompositionBoundsCalculation->GetOffsetToCrossDoc(aItemFrame) + frameForCompositionBoundsCalculation->GetOffsetToCrossDoc(aItemFrame) +
aOffsetToReferenceFrame, aOffsetToReferenceFrame,
frameForCompositionBoundsCalculation->GetSize()); frameForCompositionBoundsCalculation->GetSize());
if (scrollableFrame) { if (scrollContainerFrame) {
// If we have a scrollable frame, restrict the composition bounds to its // If we have a scrollable frame, restrict the composition bounds to its
// scroll port. The scroll port excludes the frame borders and the scroll // scroll port. The scroll port excludes the frame borders and the scroll
// bars, which we don't want to be part of the composition bounds. // bars, which we don't want to be part of the composition bounds.
nsRect scrollPort = scrollableFrame->GetScrollPortRect(); nsRect scrollPort = scrollContainerFrame->GetScrollPortRect();
compositionBounds = nsRect( compositionBounds = nsRect(
compositionBounds.TopLeft() + scrollPort.TopLeft(), scrollPort.Size()); compositionBounds.TopLeft() + scrollPort.TopLeft(), scrollPort.Size());
} }

View file

@ -15,6 +15,7 @@
#include "mozilla/PresShell.h" #include "mozilla/PresShell.h"
#include "mozilla/Maybe.h" #include "mozilla/Maybe.h"
#include "mozilla/webrender/WebRenderAPI.h" #include "mozilla/webrender/WebRenderAPI.h"
#include "mozilla/ScrollContainerFrame.h"
#include "nsBlockFrame.h" #include "nsBlockFrame.h"
#include "nsCSSAnonBoxes.h" #include "nsCSSAnonBoxes.h"
#include "nsCSSFrameConstructor.h" #include "nsCSSFrameConstructor.h"
@ -22,7 +23,6 @@
#include "nsDisplayList.h" #include "nsDisplayList.h"
#include "nsGkAtoms.h" #include "nsGkAtoms.h"
#include "nsIFrameInlines.h" #include "nsIFrameInlines.h"
#include "nsIScrollableFrame.h"
#include "nsLayoutUtils.h" #include "nsLayoutUtils.h"
#include "nsStyleConsts.h" #include "nsStyleConsts.h"
@ -856,7 +856,7 @@ Maybe<nscoord> nsFieldSetFrame::GetNaturalBaselineBOffset(
return Some(*result + BSize(aWM) - (innerBStart + inner->BSize(aWM))); return Some(*result + BSize(aWM) - (innerBStart + inner->BSize(aWM)));
} }
nsIScrollableFrame* nsFieldSetFrame::GetScrollTargetFrame() const { ScrollContainerFrame* nsFieldSetFrame::GetScrollTargetFrame() const {
return do_QueryFrame(GetInner()); return do_QueryFrame(GetInner());
} }

View file

@ -10,7 +10,10 @@
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "ImgDrawResult.h" #include "ImgDrawResult.h"
#include "nsContainerFrame.h" #include "nsContainerFrame.h"
#include "nsIScrollableFrame.h"
namespace mozilla {
class ScrollContainerFrame;
} // namespace mozilla
class nsFieldSetFrame final : public nsContainerFrame { class nsFieldSetFrame final : public nsContainerFrame {
typedef mozilla::image::ImgDrawResult ImgDrawResult; typedef mozilla::image::ImgDrawResult ImgDrawResult;
@ -62,7 +65,7 @@ class nsFieldSetFrame final : public nsContainerFrame {
nsIFrame* aOldFrame) override; nsIFrame* aOldFrame) override;
#endif #endif
nsIScrollableFrame* GetScrollTargetFrame() const override; mozilla::ScrollContainerFrame* GetScrollTargetFrame() const override;
// Return the block wrapper around our kids. // Return the block wrapper around our kids.
void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override; void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override;

View file

@ -19,7 +19,6 @@
#include "nsNameSpaceManager.h" #include "nsNameSpaceManager.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "nsIScrollableFrame.h"
#include "nsPresContext.h" #include "nsPresContext.h"
#include "nsGkAtoms.h" #include "nsGkAtoms.h"
#include "nsLayoutUtils.h" #include "nsLayoutUtils.h"
@ -35,6 +34,7 @@
#include "mozilla/EventStateManager.h" #include "mozilla/EventStateManager.h"
#include "mozilla/PresShell.h" #include "mozilla/PresShell.h"
#include "mozilla/PresState.h" #include "mozilla/PresState.h"
#include "mozilla/ScrollContainerFrame.h"
#include "mozilla/TextEditor.h" #include "mozilla/TextEditor.h"
#include "nsAttrValueInlines.h" #include "nsAttrValueInlines.h"
#include "mozilla/dom/Selection.h" #include "mozilla/dom/Selection.h"
@ -120,7 +120,7 @@ nsTextControlFrame::nsTextControlFrame(ComputedStyle* aStyle,
nsTextControlFrame::~nsTextControlFrame() = default; nsTextControlFrame::~nsTextControlFrame() = default;
nsIScrollableFrame* nsTextControlFrame::GetScrollTargetFrame() const { ScrollContainerFrame* nsTextControlFrame::GetScrollTargetFrame() const {
if (!mRootNode) { if (!mRootNode) {
return nullptr; return nullptr;
} }
@ -1147,8 +1147,7 @@ nsTextControlFrame::GetOwnedSelectionController(
} }
UniquePtr<PresState> nsTextControlFrame::SaveState() { UniquePtr<PresState> nsTextControlFrame::SaveState() {
if (nsIStatefulFrame* scrollStateFrame = if (nsIStatefulFrame* scrollStateFrame = GetScrollTargetFrame()) {
do_QueryFrame(GetScrollTargetFrame())) {
return scrollStateFrame->SaveState(); return scrollStateFrame->SaveState();
} }
@ -1159,9 +1158,7 @@ NS_IMETHODIMP
nsTextControlFrame::RestoreState(PresState* aState) { nsTextControlFrame::RestoreState(PresState* aState) {
NS_ENSURE_ARG_POINTER(aState); NS_ENSURE_ARG_POINTER(aState);
// Query the nsIStatefulFrame from the ScrollContainerFrame if (nsIStatefulFrame* scrollStateFrame = GetScrollTargetFrame()) {
if (nsIStatefulFrame* scrollStateFrame =
do_QueryFrame(GetScrollTargetFrame())) {
return scrollStateFrame->RestoreState(aState); return scrollStateFrame->RestoreState(aState);
} }

View file

@ -19,6 +19,7 @@ class nsISelectionController;
class EditorInitializerEntryTracker; class EditorInitializerEntryTracker;
namespace mozilla { namespace mozilla {
class AutoTextControlHandlingState; class AutoTextControlHandlingState;
class ScrollContainerFrame;
class TextEditor; class TextEditor;
class TextControlState; class TextControlState;
enum class PseudoStyleType : uint8_t; enum class PseudoStyleType : uint8_t;
@ -58,7 +59,7 @@ class nsTextControlFrame : public nsContainerFrame,
*/ */
MOZ_CAN_RUN_SCRIPT_BOUNDARY void Destroy(DestroyContext&) override; MOZ_CAN_RUN_SCRIPT_BOUNDARY void Destroy(DestroyContext&) override;
nsIScrollableFrame* GetScrollTargetFrame() const override; mozilla::ScrollContainerFrame* GetScrollTargetFrame() const override;
nscoord GetMinISize(gfxContext* aRenderingContext) override; nscoord GetMinISize(gfxContext* aRenderingContext) override;
nscoord GetPrefISize(gfxContext* aRenderingContext) override; nscoord GetPrefISize(gfxContext* aRenderingContext) override;

View file

@ -161,7 +161,7 @@ class ScrollContainerFrame : public nsContainerFrame,
void Destroy(DestroyContext&) override; void Destroy(DestroyContext&) override;
nsIScrollableFrame* GetScrollTargetFrame() const final { ScrollContainerFrame* GetScrollTargetFrame() const final {
return const_cast<ScrollContainerFrame*>(this); return const_cast<ScrollContainerFrame*>(this);
} }

View file

@ -1693,12 +1693,13 @@ nsresult nsFrameSelection::PageMove(bool aForward, bool aExtend,
// expected behavior for PageMove is to scroll AND move the caret // expected behavior for PageMove is to scroll AND move the caret
// and remain relative position of the caret in view. see Bug 4302. // and remain relative position of the caret in view. see Bug 4302.
// Get the scrollable frame. If aFrame is not scrollable, this is nullptr. // Get the scroll container frame. If aFrame is not scrollable, this is
nsIScrollableFrame* scrollableFrame = aFrame->GetScrollTargetFrame(); // nullptr.
ScrollContainerFrame* scrollContainerFrame = aFrame->GetScrollTargetFrame();
// Get the scrolled frame. If aFrame is not scrollable, this is aFrame // Get the scrolled frame. If aFrame is not scrollable, this is aFrame
// itself. // itself.
nsIFrame* scrolledFrame = nsIFrame* scrolledFrame =
scrollableFrame ? scrollableFrame->GetScrolledFrame() : aFrame; scrollContainerFrame ? scrollContainerFrame->GetScrolledFrame() : aFrame;
if (!scrolledFrame) { if (!scrolledFrame) {
return NS_OK; return NS_OK;
} }
@ -1727,7 +1728,7 @@ nsresult nsFrameSelection::PageMove(bool aForward, bool aExtend,
} }
} }
if (scrollableFrame) { if (scrollContainerFrame) {
// If there is a scrollable frame, adjust pseudo-click position with page // If there is a scrollable frame, adjust pseudo-click position with page
// scroll amount. // scroll amount.
// XXX This may scroll more than one page if ScrollSelectionIntoView is // XXX This may scroll more than one page if ScrollSelectionIntoView is
@ -1736,9 +1737,9 @@ nsresult nsFrameSelection::PageMove(bool aForward, bool aExtend,
// the frame, ScrollSelectionIntoView additionally scrolls to show // the frame, ScrollSelectionIntoView additionally scrolls to show
// the caret entirely. // the caret entirely.
if (aForward) { if (aForward) {
caretPos.y += scrollableFrame->GetPageScrollAmount().height; caretPos.y += scrollContainerFrame->GetPageScrollAmount().height;
} else { } else {
caretPos.y -= scrollableFrame->GetPageScrollAmount().height; caretPos.y -= scrollContainerFrame->GetPageScrollAmount().height;
} }
} else { } else {
// Otherwise, adjust pseudo-click position with the frame size. // Otherwise, adjust pseudo-click position with the frame size.
@ -1788,10 +1789,10 @@ nsresult nsFrameSelection::PageMove(bool aForward, bool aExtend,
aSelectionIntoView == SelectionIntoView::IfChanged && !selectionChanged); aSelectionIntoView == SelectionIntoView::IfChanged && !selectionChanged);
// Then, scroll the given frame one page. // Then, scroll the given frame one page.
if (scrollableFrame) { if (scrollContainerFrame) {
// If we'll call ScrollSelectionIntoView later and selection wasn't // If we'll call ScrollSelectionIntoView later and selection wasn't
// changed and we scroll outside of selection limiter, we shouldn't use // changed and we scroll outside of selection limiter, we shouldn't use
// smooth scroll here because nsIScrollableFrame uses normal runnable, // smooth scroll here because ScrollContainerFrame uses normal runnable,
// but ScrollSelectionIntoView uses early runner and it cancels the // but ScrollSelectionIntoView uses early runner and it cancels the
// pending smooth scroll. Therefore, if we used smooth scroll in such // pending smooth scroll. Therefore, if we used smooth scroll in such
// case, ScrollSelectionIntoView would scroll to show caret instead of // case, ScrollSelectionIntoView would scroll to show caret instead of
@ -1800,8 +1801,8 @@ nsresult nsFrameSelection::PageMove(bool aForward, bool aExtend,
scrolledFrame != frameToClick scrolledFrame != frameToClick
? ScrollMode::Instant ? ScrollMode::Instant
: ScrollMode::Smooth; : ScrollMode::Smooth;
scrollableFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), scrollContainerFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1),
ScrollUnit::PAGES, scrollMode); ScrollUnit::PAGES, scrollMode);
} }
// Finally, scroll selection into view if requested. // Finally, scroll selection into view if requested.

View file

@ -3695,10 +3695,10 @@ static Subgrid* SubgridComputeMarginBorderPadding(
bool scroller = false; bool scroller = false;
nsIFrame* outerFrame = [&]() -> nsIFrame* { nsIFrame* outerFrame = [&]() -> nsIFrame* {
if (ScrollContainerFrame* scrollFrame = if (ScrollContainerFrame* scrollContainerFrame =
do_QueryFrame(aGridItem.mFrame->GetScrollTargetFrame())) { aGridItem.mFrame->GetScrollTargetFrame()) {
scroller = true; scroller = true;
return scrollFrame; return scrollContainerFrame;
} }
if (nsHTMLButtonControlFrame* f = do_QueryFrame(aGridItem.mFrame)) { if (nsHTMLButtonControlFrame* f = do_QueryFrame(aGridItem.mFrame)) {
return f; return f;

View file

@ -108,7 +108,6 @@ class nsAtom;
class nsView; class nsView;
class nsFrameSelection; class nsFrameSelection;
class nsIWidget; class nsIWidget;
class nsIScrollableFrame;
class nsISelectionController; class nsISelectionController;
class nsILineIterator; class nsILineIterator;
class gfxSkipChars; class gfxSkipChars;
@ -132,15 +131,15 @@ enum class PeekOffsetOption : uint16_t;
enum class PseudoStyleType : uint8_t; enum class PseudoStyleType : uint8_t;
enum class TableSelectionMode : uint32_t; enum class TableSelectionMode : uint32_t;
class EffectSet;
class LazyLogModule;
class nsDisplayItem; class nsDisplayItem;
class nsDisplayList; class nsDisplayList;
class nsDisplayListBuilder; class nsDisplayListBuilder;
class nsDisplayListSet; class nsDisplayListSet;
class ServoRestyleState;
class EffectSet;
class LazyLogModule;
class PresShell; class PresShell;
class ScrollContainerFrame;
class ServoRestyleState;
class WidgetGUIEvent; class WidgetGUIEvent;
class WidgetMouseEvent; class WidgetMouseEvent;
@ -813,13 +812,14 @@ class nsIFrame : public nsQueryFrame {
virtual bool DrainSelfOverflowList() { return false; } virtual bool DrainSelfOverflowList() { return false; }
/** /**
* Get the frame that should be scrolled if the content associated * Get the frame that should be scrolled if the content associated with this
* with this frame is targeted for scrolling. For frames implementing * frame is targeted for scrolling. For a scroll container frame, this will
* nsIScrollableFrame this will return the frame itself. For frames * just return the frame itself. For frames like nsTextControlFrame that
* like nsTextControlFrame that contain a scrollframe, will return * contain a scroll container frame, will return that scroll container frame.
* that scrollframe.
*/ */
virtual nsIScrollableFrame* GetScrollTargetFrame() const { return nullptr; } virtual mozilla::ScrollContainerFrame* GetScrollTargetFrame() const {
return nullptr;
}
/** /**
* Get the offsets of the frame. most will be 0,0 * Get the offsets of the frame. most will be 0,0

View file

@ -5867,9 +5867,10 @@ UniquePtr<ScrollMetadata> nsDisplayScrollInfoLayer::ComputeScrollMetadata(
ToReferenceFrame(), aLayerManager, mScrollParentId, ToReferenceFrame(), aLayerManager, mScrollParentId,
mScrollFrame->GetSize(), false); mScrollFrame->GetSize(), false);
metadata.GetMetrics().SetIsScrollInfoLayer(true); metadata.GetMetrics().SetIsScrollInfoLayer(true);
nsIScrollableFrame* scrollableFrame = mScrollFrame->GetScrollTargetFrame(); ScrollContainerFrame* scrollContainerFrame =
if (scrollableFrame) { mScrollFrame->GetScrollTargetFrame();
aBuilder->AddScrollFrameToNotify(scrollableFrame); if (scrollContainerFrame) {
aBuilder->AddScrollFrameToNotify(scrollContainerFrame);
} }
return UniquePtr<ScrollMetadata>(new ScrollMetadata(metadata)); return UniquePtr<ScrollMetadata>(new ScrollMetadata(metadata));

View file

@ -10,6 +10,7 @@
#include "gfxUtils.h" #include "gfxUtils.h"
#include "mozilla/ComputedStyle.h" #include "mozilla/ComputedStyle.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/gfx/2D.h" #include "mozilla/gfx/2D.h"
#include "mozilla/gfx/Helpers.h" #include "mozilla/gfx/Helpers.h"
@ -23,7 +24,6 @@
#include "nsIContent.h" #include "nsIContent.h"
#include "nsIFrame.h" #include "nsIFrame.h"
#include "nsIFrameInlines.h" #include "nsIFrameInlines.h"
#include "nsIScrollableFrame.h"
#include "nsGenericHTMLElement.h" #include "nsGenericHTMLElement.h"
#include "nsAttrValueInlines.h" #include "nsAttrValueInlines.h"
#include "nsHTMLParts.h" #include "nsHTMLParts.h"
@ -590,7 +590,7 @@ int32_t nsTableCellFrame::GetColSpan() {
return colSpan; return colSpan;
} }
nsIScrollableFrame* nsTableCellFrame::GetScrollTargetFrame() const { ScrollContainerFrame* nsTableCellFrame::GetScrollTargetFrame() const {
return do_QueryFrame(mFrames.FirstChild()); return do_QueryFrame(mFrames.FirstChild());
} }

View file

@ -18,6 +18,7 @@
namespace mozilla { namespace mozilla {
class PresShell; class PresShell;
class ScrollContainerFrame;
} // namespace mozilla } // namespace mozilla
/** /**
@ -45,7 +46,7 @@ class nsTableCellFrame : public nsContainerFrame,
NS_DECL_QUERYFRAME NS_DECL_QUERYFRAME
NS_DECL_FRAMEARENA_HELPERS(nsTableCellFrame) NS_DECL_FRAMEARENA_HELPERS(nsTableCellFrame)
nsIScrollableFrame* GetScrollTargetFrame() const final; mozilla::ScrollContainerFrame* GetScrollTargetFrame() const final;
nsTableRowFrame* GetTableRowFrame() const { nsTableRowFrame* GetTableRowFrame() const {
nsIFrame* parent = GetParent(); nsIFrame* parent = GetParent();

View file

@ -8,7 +8,6 @@
#include "mozilla/dom/Document.h" #include "mozilla/dom/Document.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "nsIFrame.h" #include "nsIFrame.h"
#include "nsIScrollableFrame.h"
#include "nsLayoutUtils.h" #include "nsLayoutUtils.h"
#include "nsNumberControlFrame.h" #include "nsNumberControlFrame.h"
#include "nsPresContext.h" #include "nsPresContext.h"
@ -27,6 +26,7 @@
#include "mozilla/dom/HTMLInputElement.h" #include "mozilla/dom/HTMLInputElement.h"
#include "mozilla/dom/HTMLProgressElement.h" #include "mozilla/dom/HTMLProgressElement.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/dom/DocumentInlines.h" #include "mozilla/dom/DocumentInlines.h"
#include <algorithm> #include <algorithm>
@ -534,13 +534,13 @@ bool nsNativeTheme::IsDarkBackgroundForScrollbar(nsIFrame* aFrame) {
// might be none. // might be none.
{ {
nsIFrame* frame = aFrame; nsIFrame* frame = aFrame;
nsIScrollableFrame* scrollFrame = nullptr; ScrollContainerFrame* scrollContainerFrame = nullptr;
while (!scrollFrame && frame) { while (!scrollContainerFrame && frame) {
scrollFrame = frame->GetScrollTargetFrame(); scrollContainerFrame = frame->GetScrollTargetFrame();
frame = frame->GetParent(); frame = frame->GetParent();
} }
if (scrollFrame) { if (scrollContainerFrame) {
aFrame = scrollFrame->GetScrolledFrame(); aFrame = scrollContainerFrame->GetScrolledFrame();
} else { } else {
// Leave aFrame untouched. // Leave aFrame untouched.
} }