forked from mirrors/gecko-dev
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:
parent
31c3239b70
commit
df8ff2d9ac
17 changed files with 124 additions and 120 deletions
|
|
@ -30,7 +30,6 @@
|
|||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsImageFrame.h"
|
||||
#include "nsViewManager.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsFocusManager.h"
|
||||
|
|
@ -42,6 +41,7 @@
|
|||
#include "mozilla/ipc/ProcessChild.h"
|
||||
#include "mozilla/PerfStats.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/ScrollContainerFrame.h"
|
||||
#include "nsAccessibilityService.h"
|
||||
#include "mozilla/a11y/DocAccessibleChild.h"
|
||||
#include "mozilla/dom/AncestorIterator.h"
|
||||
|
|
@ -709,9 +709,9 @@ std::pair<nsPoint, nsRect> DocAccessible::ComputeScrollData(
|
|||
nsRect scrollRange;
|
||||
|
||||
if (nsIFrame* frame = aAcc->GetFrame()) {
|
||||
nsIScrollableFrame* sf = aAcc == this
|
||||
? mPresShell->GetRootScrollFrameAsScrollable()
|
||||
: frame->GetScrollTargetFrame();
|
||||
ScrollContainerFrame* sf = aAcc == this
|
||||
? mPresShell->GetRootScrollContainerFrame()
|
||||
: frame->GetScrollTargetFrame();
|
||||
|
||||
// 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
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@
|
|||
#include "nsTextFrame.h"
|
||||
#include "nsView.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsStyleStructInlines.h"
|
||||
#include "nsFocusManager.h"
|
||||
|
||||
|
|
@ -72,6 +71,7 @@
|
|||
#include "mozilla/FloatingPoint.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/ProfilerMarkers.h"
|
||||
#include "mozilla/ScrollContainerFrame.h"
|
||||
#include "mozilla/StaticPrefs_ui.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/HTMLLabelElement.h"
|
||||
|
|
@ -670,9 +670,9 @@ nsRect LocalAccessible::ParentRelativeBounds() {
|
|||
return result;
|
||||
}
|
||||
|
||||
if (nsIScrollableFrame* sf =
|
||||
if (ScrollContainerFrame* sf =
|
||||
mParent == mDoc
|
||||
? mDoc->PresShellPtr()->GetRootScrollFrameAsScrollable()
|
||||
? mDoc->PresShellPtr()->GetRootScrollContainerFrame()
|
||||
: boundingFrame->GetScrollTargetFrame()) {
|
||||
// If boundingFrame has a scroll position, result is currently relative
|
||||
// to that. Instead, we want result to remain the same regardless of
|
||||
|
|
|
|||
|
|
@ -33,11 +33,11 @@
|
|||
#include "mozilla/Preferences.h"
|
||||
#include "nsTextNode.h"
|
||||
#include "nsIController.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "mozilla/AutoRestore.h"
|
||||
#include "mozilla/InputEventOptions.h"
|
||||
#include "mozilla/NativeKeyBindingsType.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/ScrollContainerFrame.h"
|
||||
#include "mozilla/TextEvents.h"
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
|
|
@ -340,7 +340,7 @@ class TextInputSelectionController final : public nsSupportsWeakReference,
|
|||
|
||||
TextInputSelectionController(PresShell* aPresShell, nsIContent* aLimiter);
|
||||
|
||||
void SetScrollableFrame(nsIScrollableFrame* aScrollableFrame);
|
||||
void SetScrollContainerFrame(ScrollContainerFrame* aScrollContainerFrame);
|
||||
nsFrameSelection* GetConstFrameSelection() { return mFrameSelection; }
|
||||
// Will return null if !mFrameSelection.
|
||||
Selection* GetSelection(SelectionType aSelectionType);
|
||||
|
|
@ -383,7 +383,7 @@ class TextInputSelectionController final : public nsSupportsWeakReference,
|
|||
|
||||
private:
|
||||
RefPtr<nsFrameSelection> mFrameSelection;
|
||||
nsIScrollableFrame* mScrollFrame;
|
||||
ScrollContainerFrame* mScrollContainerFrame = nullptr;
|
||||
nsWeakPtr mPresShellWeak;
|
||||
};
|
||||
|
||||
|
|
@ -398,8 +398,7 @@ NS_INTERFACE_MAP_END
|
|||
NS_IMPL_CYCLE_COLLECTION_WEAK(TextInputSelectionController, mFrameSelection)
|
||||
|
||||
TextInputSelectionController::TextInputSelectionController(
|
||||
PresShell* aPresShell, nsIContent* aLimiter)
|
||||
: mScrollFrame(nullptr) {
|
||||
PresShell* aPresShell, nsIContent* aLimiter) {
|
||||
if (aPresShell) {
|
||||
bool accessibleCaretEnabled =
|
||||
PresShell::AccessibleCaretEnabled(aLimiter->OwnerDoc()->GetDocShell());
|
||||
|
|
@ -409,10 +408,10 @@ TextInputSelectionController::TextInputSelectionController(
|
|||
}
|
||||
}
|
||||
|
||||
void TextInputSelectionController::SetScrollableFrame(
|
||||
nsIScrollableFrame* aScrollableFrame) {
|
||||
mScrollFrame = aScrollableFrame;
|
||||
if (!mScrollFrame && mFrameSelection) {
|
||||
void TextInputSelectionController::SetScrollContainerFrame(
|
||||
ScrollContainerFrame* aScrollContainerFrame) {
|
||||
mScrollContainerFrame = aScrollContainerFrame;
|
||||
if (!mScrollContainerFrame && mFrameSelection) {
|
||||
mFrameSelection->DisconnectFromPresShell();
|
||||
mFrameSelection = nullptr;
|
||||
}
|
||||
|
|
@ -653,16 +652,15 @@ NS_IMETHODIMP
|
|||
TextInputSelectionController::PageMove(bool aForward, bool aExtend) {
|
||||
// expected behavior for PageMove is to scroll AND move the caret
|
||||
// and to remain relative position of the caret in view. see Bug 4302.
|
||||
if (mScrollFrame) {
|
||||
if (mScrollContainerFrame) {
|
||||
RefPtr<nsFrameSelection> frameSelection = mFrameSelection;
|
||||
nsIFrame* scrollFrame = do_QueryFrame(mScrollFrame);
|
||||
// We won't scroll parent scrollable element of mScrollFrame. Therefore,
|
||||
// this may be handled when mScrollFrame is completely outside of the view.
|
||||
// In such case, user may be confused since they might have wanted to
|
||||
// scroll a parent scrollable element. For making clearer which element
|
||||
// handles PageDown/PageUp, we should move selection into view even if
|
||||
// selection is not changed.
|
||||
return frameSelection->PageMove(aForward, aExtend, scrollFrame,
|
||||
// We won't scroll parent scrollable element of mScrollContainerFrame.
|
||||
// Therefore, this may be handled when mScrollContainerFrame is completely
|
||||
// outside of the view. In such case, user may be confused since they might
|
||||
// have wanted to scroll a parent scrollable element. For making clearer
|
||||
// which element handles PageDown/PageUp, we should move selection into view
|
||||
// even if selection is not changed.
|
||||
return frameSelection->PageMove(aForward, aExtend, mScrollContainerFrame,
|
||||
nsFrameSelection::SelectionIntoView::Yes);
|
||||
}
|
||||
// Similarly, if there is no scrollable frame, we should move the editor
|
||||
|
|
@ -677,12 +675,12 @@ TextInputSelectionController::PageMove(bool aForward, bool aExtend) {
|
|||
|
||||
NS_IMETHODIMP
|
||||
TextInputSelectionController::CompleteScroll(bool aForward) {
|
||||
if (!mScrollFrame) {
|
||||
if (!mScrollContainerFrame) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
mScrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::WHOLE,
|
||||
ScrollMode::Instant);
|
||||
mScrollContainerFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1),
|
||||
ScrollUnit::WHOLE, ScrollMode::Instant);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
@ -730,34 +728,34 @@ TextInputSelectionController::CompleteMove(bool aForward, bool aExtend) {
|
|||
|
||||
NS_IMETHODIMP
|
||||
TextInputSelectionController::ScrollPage(bool aForward) {
|
||||
if (!mScrollFrame) {
|
||||
if (!mScrollContainerFrame) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
mScrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::PAGES,
|
||||
ScrollMode::Smooth);
|
||||
mScrollContainerFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1),
|
||||
ScrollUnit::PAGES, ScrollMode::Smooth);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TextInputSelectionController::ScrollLine(bool aForward) {
|
||||
if (!mScrollFrame) {
|
||||
if (!mScrollContainerFrame) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
mScrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::LINES,
|
||||
ScrollMode::Smooth);
|
||||
mScrollContainerFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1),
|
||||
ScrollUnit::LINES, ScrollMode::Smooth);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TextInputSelectionController::ScrollCharacter(bool aRight) {
|
||||
if (!mScrollFrame) {
|
||||
if (!mScrollContainerFrame) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
mScrollFrame->ScrollBy(nsIntPoint(aRight ? 1 : -1, 0), ScrollUnit::LINES,
|
||||
ScrollMode::Smooth);
|
||||
mScrollContainerFrame->ScrollBy(nsIntPoint(aRight ? 1 : -1, 0),
|
||||
ScrollUnit::LINES, ScrollMode::Smooth);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
@ -2449,7 +2447,7 @@ void TextControlState::UnbindFromFrame(nsTextControlFrame* aFrame) {
|
|||
mTextListener->EndListeningToSelectionChange();
|
||||
}
|
||||
|
||||
mSelCon->SetScrollableFrame(nullptr);
|
||||
mSelCon->SetScrollContainerFrame(nullptr);
|
||||
mSelCon = nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -3037,7 +3035,7 @@ void TextControlState::InitializeKeyboardEventListeners() {
|
|||
TrustedEventsAtSystemGroupBubble());
|
||||
}
|
||||
|
||||
mSelCon->SetScrollableFrame(mBoundFrame->GetScrollTargetFrame());
|
||||
mSelCon->SetScrollContainerFrame(mBoundFrame->GetScrollTargetFrame());
|
||||
}
|
||||
|
||||
void TextControlState::SetPreviewText(const nsAString& aValue, bool aNotify) {
|
||||
|
|
|
|||
|
|
@ -196,10 +196,10 @@ static nsRect GetDisplayPortFromMarginsData(
|
|||
isRoot = true;
|
||||
}
|
||||
|
||||
nsIScrollableFrame* scrollableFrame = frame->GetScrollTargetFrame();
|
||||
ScrollContainerFrame* scrollContainerFrame = frame->GetScrollTargetFrame();
|
||||
nsPoint scrollPos;
|
||||
if (scrollableFrame) {
|
||||
scrollPos = scrollableFrame->GetScrollPosition();
|
||||
if (scrollContainerFrame) {
|
||||
scrollPos = scrollContainerFrame->GetScrollPosition();
|
||||
}
|
||||
|
||||
nsPresContext* presContext = frame->PresContext();
|
||||
|
|
@ -252,7 +252,7 @@ static nsRect GetDisplayPortFromMarginsData(
|
|||
MOZ_ASSERT(presShell);
|
||||
|
||||
ScreenMargin margins = aMarginsData->mMargins.GetRelativeToLayoutViewport(
|
||||
aOptions.mGeometryType, scrollableFrame,
|
||||
aOptions.mGeometryType, scrollContainerFrame,
|
||||
presContext->CSSToDevPixelScale() * res);
|
||||
|
||||
if (presShell->IsDisplayportSuppressed() ||
|
||||
|
|
@ -514,7 +514,7 @@ void DisplayPortUtils::InvalidateForDisplayPortChange(
|
|||
|
||||
nsIFrame* frame = nsLayoutUtils::GetScrollFrameFromContent(aContent);
|
||||
if (frame) {
|
||||
frame = do_QueryFrame(frame->GetScrollTargetFrame());
|
||||
frame = frame->GetScrollTargetFrame();
|
||||
}
|
||||
|
||||
if (changed && frame) {
|
||||
|
|
@ -625,9 +625,9 @@ bool DisplayPortUtils::SetDisplayPortMargins(
|
|||
aContent->RemoveProperty(nsGkAtoms::MinimalDisplayPort);
|
||||
}
|
||||
|
||||
nsIScrollableFrame* scrollableFrame =
|
||||
ScrollContainerFrame* scrollContainerFrame =
|
||||
scrollFrame ? scrollFrame->GetScrollTargetFrame() : nullptr;
|
||||
if (!scrollableFrame) {
|
||||
if (!scrollContainerFrame) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -657,13 +657,13 @@ bool DisplayPortUtils::SetDisplayPortMargins(
|
|||
InvalidateForDisplayPortChange(aContent, hadDisplayPort, oldDisplayPort,
|
||||
newDisplayPort, aRepaintMode);
|
||||
|
||||
scrollableFrame->TriggerDisplayPortExpiration();
|
||||
scrollContainerFrame->TriggerDisplayPortExpiration();
|
||||
|
||||
// Display port margins changing means that the set of visible frames may
|
||||
// have drastically changed. Check if we should schedule an update.
|
||||
hadDisplayPort =
|
||||
scrollableFrame->GetDisplayPortAtLastApproximateFrameVisibilityUpdate(
|
||||
&oldDisplayPort);
|
||||
hadDisplayPort = scrollContainerFrame
|
||||
->GetDisplayPortAtLastApproximateFrameVisibilityUpdate(
|
||||
&oldDisplayPort);
|
||||
|
||||
bool needVisibilityUpdate = !hadDisplayPort;
|
||||
// Check if the total size has changed by a large factor.
|
||||
|
|
|
|||
|
|
@ -8326,11 +8326,12 @@ nsMargin nsLayoutUtils::ScrollbarAreaToExcludeFromCompositionBoundsFor(
|
|||
if (presContext->UseOverlayScrollbars()) {
|
||||
return nsMargin();
|
||||
}
|
||||
nsIScrollableFrame* scrollableFrame = aScrollFrame->GetScrollTargetFrame();
|
||||
if (!scrollableFrame) {
|
||||
ScrollContainerFrame* scrollContainerFrame =
|
||||
aScrollFrame->GetScrollTargetFrame();
|
||||
if (!scrollContainerFrame) {
|
||||
return nsMargin();
|
||||
}
|
||||
return scrollableFrame->GetActualScrollbarSizes(
|
||||
return scrollContainerFrame->GetActualScrollbarSizes(
|
||||
nsIScrollableFrame::ScrollbarSizesOptions::
|
||||
INCLUDE_VISUAL_VIEWPORT_SCROLLBARS);
|
||||
}
|
||||
|
|
@ -8340,12 +8341,12 @@ nsSize nsLayoutUtils::CalculateCompositionSizeForFrame(
|
|||
nsIFrame* aFrame, bool aSubtractScrollbars,
|
||||
const nsSize* aOverrideScrollPortSize,
|
||||
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
|
||||
// bars, which we don't want to be part of the composition bounds.
|
||||
nsIScrollableFrame* scrollableFrame = aFrame->GetScrollTargetFrame();
|
||||
nsRect rect = scrollableFrame ? scrollableFrame->GetScrollPortRect()
|
||||
: aFrame->GetRect();
|
||||
ScrollContainerFrame* scrollContainerFrame = aFrame->GetScrollTargetFrame();
|
||||
nsRect rect = scrollContainerFrame ? scrollContainerFrame->GetScrollPortRect()
|
||||
: aFrame->GetRect();
|
||||
nsSize size =
|
||||
aOverrideScrollPortSize ? *aOverrideScrollPortSize : rect.Size();
|
||||
|
||||
|
|
@ -8778,16 +8779,16 @@ ScrollMetadata nsLayoutUtils::ComputeScrollMetadata(
|
|||
aContent->GetProperty(nsGkAtoms::MinimalDisplayPort));
|
||||
}
|
||||
|
||||
nsIScrollableFrame* scrollableFrame = nullptr;
|
||||
if (aScrollFrame) scrollableFrame = aScrollFrame->GetScrollTargetFrame();
|
||||
ScrollContainerFrame* scrollContainerFrame =
|
||||
aScrollFrame ? aScrollFrame->GetScrollTargetFrame() : nullptr;
|
||||
|
||||
metrics.SetScrollableRect(
|
||||
CSSRect::FromAppUnits(nsLayoutUtils::CalculateScrollableRectForFrame(
|
||||
scrollableFrame, aForFrame)));
|
||||
scrollContainerFrame, aForFrame)));
|
||||
|
||||
if (scrollableFrame) {
|
||||
if (scrollContainerFrame) {
|
||||
CSSPoint layoutScrollOffset =
|
||||
CSSPoint::FromAppUnits(scrollableFrame->GetScrollPosition());
|
||||
CSSPoint::FromAppUnits(scrollContainerFrame->GetScrollPosition());
|
||||
CSSPoint visualScrollOffset =
|
||||
aIsRootContent
|
||||
? CSSPoint::FromAppUnits(presShell->GetVisualViewportOffset())
|
||||
|
|
@ -8808,7 +8809,7 @@ ScrollMetadata nsLayoutUtils::ComputeScrollMetadata(
|
|||
}
|
||||
}
|
||||
|
||||
if (scrollableFrame->IsRootScrollFrameOfDocument()) {
|
||||
if (scrollContainerFrame->IsRootScrollFrameOfDocument()) {
|
||||
if (const Maybe<PresShell::VisualScrollUpdate>& visualUpdate =
|
||||
presShell->GetPendingVisualScrollUpdate()) {
|
||||
metrics.SetVisualDestination(
|
||||
|
|
@ -8848,19 +8849,20 @@ ScrollMetadata nsLayoutUtils::ComputeScrollMetadata(
|
|||
}
|
||||
}
|
||||
|
||||
metrics.SetScrollGeneration(scrollableFrame->CurrentScrollGeneration());
|
||||
metrics.SetScrollGeneration(
|
||||
scrollContainerFrame->CurrentScrollGeneration());
|
||||
|
||||
CSSRect viewport = metrics.GetLayoutViewport();
|
||||
viewport.MoveTo(layoutScrollOffset);
|
||||
metrics.SetLayoutViewport(viewport);
|
||||
|
||||
nsSize lineScrollAmount = scrollableFrame->GetLineScrollAmount();
|
||||
nsSize lineScrollAmount = scrollContainerFrame->GetLineScrollAmount();
|
||||
LayoutDeviceIntSize lineScrollAmountInDevPixels =
|
||||
LayoutDeviceIntSize::FromAppUnitsRounded(
|
||||
lineScrollAmount, presContext->AppUnitsPerDevPixel());
|
||||
metadata.SetLineScrollAmount(lineScrollAmountInDevPixels);
|
||||
|
||||
nsSize pageScrollAmount = scrollableFrame->GetPageScrollAmount();
|
||||
nsSize pageScrollAmount = scrollContainerFrame->GetPageScrollAmount();
|
||||
LayoutDeviceIntSize pageScrollAmountInDevPixels =
|
||||
LayoutDeviceIntSize::FromAppUnitsRounded(
|
||||
pageScrollAmount, presContext->AppUnitsPerDevPixel());
|
||||
|
|
@ -8872,10 +8874,10 @@ ScrollMetadata nsLayoutUtils::ComputeScrollMetadata(
|
|||
aScrollFrame->GetParent()));
|
||||
}
|
||||
|
||||
metadata.SetSnapInfo(scrollableFrame->GetScrollSnapInfo());
|
||||
metadata.SetSnapInfo(scrollContainerFrame->GetScrollSnapInfo());
|
||||
metadata.SetOverscrollBehavior(
|
||||
scrollableFrame->GetOverscrollBehaviorInfo());
|
||||
metadata.SetScrollUpdates(scrollableFrame->GetScrollUpdates());
|
||||
scrollContainerFrame->GetOverscrollBehaviorInfo());
|
||||
metadata.SetScrollUpdates(scrollContainerFrame->GetScrollUpdates());
|
||||
}
|
||||
|
||||
// If we have the scrollparent being the same as the scroll id, the
|
||||
|
|
@ -8967,11 +8969,11 @@ ScrollMetadata nsLayoutUtils::ComputeScrollMetadata(
|
|||
frameForCompositionBoundsCalculation->GetOffsetToCrossDoc(aItemFrame) +
|
||||
aOffsetToReferenceFrame,
|
||||
frameForCompositionBoundsCalculation->GetSize());
|
||||
if (scrollableFrame) {
|
||||
if (scrollContainerFrame) {
|
||||
// If we have a scrollable frame, restrict the composition bounds to its
|
||||
// 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.
|
||||
nsRect scrollPort = scrollableFrame->GetScrollPortRect();
|
||||
nsRect scrollPort = scrollContainerFrame->GetScrollPortRect();
|
||||
compositionBounds = nsRect(
|
||||
compositionBounds.TopLeft() + scrollPort.TopLeft(), scrollPort.Size());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/webrender/WebRenderAPI.h"
|
||||
#include "mozilla/ScrollContainerFrame.h"
|
||||
#include "nsBlockFrame.h"
|
||||
#include "nsCSSAnonBoxes.h"
|
||||
#include "nsCSSFrameConstructor.h"
|
||||
|
|
@ -22,7 +23,6 @@
|
|||
#include "nsDisplayList.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIFrameInlines.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsStyleConsts.h"
|
||||
|
||||
|
|
@ -856,7 +856,7 @@ Maybe<nscoord> nsFieldSetFrame::GetNaturalBaselineBOffset(
|
|||
return Some(*result + BSize(aWM) - (innerBStart + inner->BSize(aWM)));
|
||||
}
|
||||
|
||||
nsIScrollableFrame* nsFieldSetFrame::GetScrollTargetFrame() const {
|
||||
ScrollContainerFrame* nsFieldSetFrame::GetScrollTargetFrame() const {
|
||||
return do_QueryFrame(GetInner());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,10 @@
|
|||
#include "mozilla/Attributes.h"
|
||||
#include "ImgDrawResult.h"
|
||||
#include "nsContainerFrame.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
|
||||
namespace mozilla {
|
||||
class ScrollContainerFrame;
|
||||
} // namespace mozilla
|
||||
|
||||
class nsFieldSetFrame final : public nsContainerFrame {
|
||||
typedef mozilla::image::ImgDrawResult ImgDrawResult;
|
||||
|
|
@ -62,7 +65,7 @@ class nsFieldSetFrame final : public nsContainerFrame {
|
|||
nsIFrame* aOldFrame) override;
|
||||
#endif
|
||||
|
||||
nsIScrollableFrame* GetScrollTargetFrame() const override;
|
||||
mozilla::ScrollContainerFrame* GetScrollTargetFrame() const override;
|
||||
|
||||
// Return the block wrapper around our kids.
|
||||
void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
#include "nsNameSpaceManager.h"
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
|
|
@ -35,6 +34,7 @@
|
|||
#include "mozilla/EventStateManager.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/PresState.h"
|
||||
#include "mozilla/ScrollContainerFrame.h"
|
||||
#include "mozilla/TextEditor.h"
|
||||
#include "nsAttrValueInlines.h"
|
||||
#include "mozilla/dom/Selection.h"
|
||||
|
|
@ -120,7 +120,7 @@ nsTextControlFrame::nsTextControlFrame(ComputedStyle* aStyle,
|
|||
|
||||
nsTextControlFrame::~nsTextControlFrame() = default;
|
||||
|
||||
nsIScrollableFrame* nsTextControlFrame::GetScrollTargetFrame() const {
|
||||
ScrollContainerFrame* nsTextControlFrame::GetScrollTargetFrame() const {
|
||||
if (!mRootNode) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -1147,8 +1147,7 @@ nsTextControlFrame::GetOwnedSelectionController(
|
|||
}
|
||||
|
||||
UniquePtr<PresState> nsTextControlFrame::SaveState() {
|
||||
if (nsIStatefulFrame* scrollStateFrame =
|
||||
do_QueryFrame(GetScrollTargetFrame())) {
|
||||
if (nsIStatefulFrame* scrollStateFrame = GetScrollTargetFrame()) {
|
||||
return scrollStateFrame->SaveState();
|
||||
}
|
||||
|
||||
|
|
@ -1159,9 +1158,7 @@ NS_IMETHODIMP
|
|||
nsTextControlFrame::RestoreState(PresState* aState) {
|
||||
NS_ENSURE_ARG_POINTER(aState);
|
||||
|
||||
// Query the nsIStatefulFrame from the ScrollContainerFrame
|
||||
if (nsIStatefulFrame* scrollStateFrame =
|
||||
do_QueryFrame(GetScrollTargetFrame())) {
|
||||
if (nsIStatefulFrame* scrollStateFrame = GetScrollTargetFrame()) {
|
||||
return scrollStateFrame->RestoreState(aState);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class nsISelectionController;
|
|||
class EditorInitializerEntryTracker;
|
||||
namespace mozilla {
|
||||
class AutoTextControlHandlingState;
|
||||
class ScrollContainerFrame;
|
||||
class TextEditor;
|
||||
class TextControlState;
|
||||
enum class PseudoStyleType : uint8_t;
|
||||
|
|
@ -58,7 +59,7 @@ class nsTextControlFrame : public nsContainerFrame,
|
|||
*/
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY void Destroy(DestroyContext&) override;
|
||||
|
||||
nsIScrollableFrame* GetScrollTargetFrame() const override;
|
||||
mozilla::ScrollContainerFrame* GetScrollTargetFrame() const override;
|
||||
|
||||
nscoord GetMinISize(gfxContext* aRenderingContext) override;
|
||||
nscoord GetPrefISize(gfxContext* aRenderingContext) override;
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ class ScrollContainerFrame : public nsContainerFrame,
|
|||
|
||||
void Destroy(DestroyContext&) override;
|
||||
|
||||
nsIScrollableFrame* GetScrollTargetFrame() const final {
|
||||
ScrollContainerFrame* GetScrollTargetFrame() const final {
|
||||
return const_cast<ScrollContainerFrame*>(this);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1693,12 +1693,13 @@ nsresult nsFrameSelection::PageMove(bool aForward, bool aExtend,
|
|||
// expected behavior for PageMove is to scroll AND move the caret
|
||||
// and remain relative position of the caret in view. see Bug 4302.
|
||||
|
||||
// Get the scrollable frame. If aFrame is not scrollable, this is nullptr.
|
||||
nsIScrollableFrame* scrollableFrame = aFrame->GetScrollTargetFrame();
|
||||
// Get the scroll container frame. If aFrame is not scrollable, this is
|
||||
// nullptr.
|
||||
ScrollContainerFrame* scrollContainerFrame = aFrame->GetScrollTargetFrame();
|
||||
// Get the scrolled frame. If aFrame is not scrollable, this is aFrame
|
||||
// itself.
|
||||
nsIFrame* scrolledFrame =
|
||||
scrollableFrame ? scrollableFrame->GetScrolledFrame() : aFrame;
|
||||
scrollContainerFrame ? scrollContainerFrame->GetScrolledFrame() : aFrame;
|
||||
if (!scrolledFrame) {
|
||||
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
|
||||
// scroll amount.
|
||||
// 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 caret entirely.
|
||||
if (aForward) {
|
||||
caretPos.y += scrollableFrame->GetPageScrollAmount().height;
|
||||
caretPos.y += scrollContainerFrame->GetPageScrollAmount().height;
|
||||
} else {
|
||||
caretPos.y -= scrollableFrame->GetPageScrollAmount().height;
|
||||
caretPos.y -= scrollContainerFrame->GetPageScrollAmount().height;
|
||||
}
|
||||
} else {
|
||||
// Otherwise, adjust pseudo-click position with the frame size.
|
||||
|
|
@ -1788,10 +1789,10 @@ nsresult nsFrameSelection::PageMove(bool aForward, bool aExtend,
|
|||
aSelectionIntoView == SelectionIntoView::IfChanged && !selectionChanged);
|
||||
|
||||
// Then, scroll the given frame one page.
|
||||
if (scrollableFrame) {
|
||||
if (scrollContainerFrame) {
|
||||
// If we'll call ScrollSelectionIntoView later and selection wasn't
|
||||
// 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
|
||||
// pending smooth scroll. Therefore, if we used smooth scroll in such
|
||||
// case, ScrollSelectionIntoView would scroll to show caret instead of
|
||||
|
|
@ -1800,8 +1801,8 @@ nsresult nsFrameSelection::PageMove(bool aForward, bool aExtend,
|
|||
scrolledFrame != frameToClick
|
||||
? ScrollMode::Instant
|
||||
: ScrollMode::Smooth;
|
||||
scrollableFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1),
|
||||
ScrollUnit::PAGES, scrollMode);
|
||||
scrollContainerFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1),
|
||||
ScrollUnit::PAGES, scrollMode);
|
||||
}
|
||||
|
||||
// Finally, scroll selection into view if requested.
|
||||
|
|
|
|||
|
|
@ -3695,10 +3695,10 @@ static Subgrid* SubgridComputeMarginBorderPadding(
|
|||
|
||||
bool scroller = false;
|
||||
nsIFrame* outerFrame = [&]() -> nsIFrame* {
|
||||
if (ScrollContainerFrame* scrollFrame =
|
||||
do_QueryFrame(aGridItem.mFrame->GetScrollTargetFrame())) {
|
||||
if (ScrollContainerFrame* scrollContainerFrame =
|
||||
aGridItem.mFrame->GetScrollTargetFrame()) {
|
||||
scroller = true;
|
||||
return scrollFrame;
|
||||
return scrollContainerFrame;
|
||||
}
|
||||
if (nsHTMLButtonControlFrame* f = do_QueryFrame(aGridItem.mFrame)) {
|
||||
return f;
|
||||
|
|
|
|||
|
|
@ -108,7 +108,6 @@ class nsAtom;
|
|||
class nsView;
|
||||
class nsFrameSelection;
|
||||
class nsIWidget;
|
||||
class nsIScrollableFrame;
|
||||
class nsISelectionController;
|
||||
class nsILineIterator;
|
||||
class gfxSkipChars;
|
||||
|
|
@ -132,15 +131,15 @@ enum class PeekOffsetOption : uint16_t;
|
|||
enum class PseudoStyleType : uint8_t;
|
||||
enum class TableSelectionMode : uint32_t;
|
||||
|
||||
class EffectSet;
|
||||
class LazyLogModule;
|
||||
class nsDisplayItem;
|
||||
class nsDisplayList;
|
||||
class nsDisplayListBuilder;
|
||||
class nsDisplayListSet;
|
||||
|
||||
class ServoRestyleState;
|
||||
class EffectSet;
|
||||
class LazyLogModule;
|
||||
class PresShell;
|
||||
class ScrollContainerFrame;
|
||||
class ServoRestyleState;
|
||||
class WidgetGUIEvent;
|
||||
class WidgetMouseEvent;
|
||||
|
||||
|
|
@ -813,13 +812,14 @@ class nsIFrame : public nsQueryFrame {
|
|||
virtual bool DrainSelfOverflowList() { return false; }
|
||||
|
||||
/**
|
||||
* Get the frame that should be scrolled if the content associated
|
||||
* with this frame is targeted for scrolling. For frames implementing
|
||||
* nsIScrollableFrame this will return the frame itself. For frames
|
||||
* like nsTextControlFrame that contain a scrollframe, will return
|
||||
* that scrollframe.
|
||||
* Get the frame that should be scrolled if the content associated with this
|
||||
* frame is targeted for scrolling. For a scroll container frame, this will
|
||||
* just return the frame itself. For frames like nsTextControlFrame that
|
||||
* contain a scroll container frame, will return that scroll container frame.
|
||||
*/
|
||||
virtual nsIScrollableFrame* GetScrollTargetFrame() const { return nullptr; }
|
||||
virtual mozilla::ScrollContainerFrame* GetScrollTargetFrame() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the offsets of the frame. most will be 0,0
|
||||
|
|
|
|||
|
|
@ -5867,9 +5867,10 @@ UniquePtr<ScrollMetadata> nsDisplayScrollInfoLayer::ComputeScrollMetadata(
|
|||
ToReferenceFrame(), aLayerManager, mScrollParentId,
|
||||
mScrollFrame->GetSize(), false);
|
||||
metadata.GetMetrics().SetIsScrollInfoLayer(true);
|
||||
nsIScrollableFrame* scrollableFrame = mScrollFrame->GetScrollTargetFrame();
|
||||
if (scrollableFrame) {
|
||||
aBuilder->AddScrollFrameToNotify(scrollableFrame);
|
||||
ScrollContainerFrame* scrollContainerFrame =
|
||||
mScrollFrame->GetScrollTargetFrame();
|
||||
if (scrollContainerFrame) {
|
||||
aBuilder->AddScrollFrameToNotify(scrollContainerFrame);
|
||||
}
|
||||
|
||||
return UniquePtr<ScrollMetadata>(new ScrollMetadata(metadata));
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include "gfxUtils.h"
|
||||
#include "mozilla/ComputedStyle.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/ScrollContainerFrame.h"
|
||||
#include "mozilla/StaticPrefs_layout.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/gfx/Helpers.h"
|
||||
|
|
@ -23,7 +24,6 @@
|
|||
#include "nsIContent.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIFrameInlines.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsAttrValueInlines.h"
|
||||
#include "nsHTMLParts.h"
|
||||
|
|
@ -590,7 +590,7 @@ int32_t nsTableCellFrame::GetColSpan() {
|
|||
return colSpan;
|
||||
}
|
||||
|
||||
nsIScrollableFrame* nsTableCellFrame::GetScrollTargetFrame() const {
|
||||
ScrollContainerFrame* nsTableCellFrame::GetScrollTargetFrame() const {
|
||||
return do_QueryFrame(mFrames.FirstChild());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
namespace mozilla {
|
||||
class PresShell;
|
||||
class ScrollContainerFrame;
|
||||
} // namespace mozilla
|
||||
|
||||
/**
|
||||
|
|
@ -45,7 +46,7 @@ class nsTableCellFrame : public nsContainerFrame,
|
|||
NS_DECL_QUERYFRAME
|
||||
NS_DECL_FRAMEARENA_HELPERS(nsTableCellFrame)
|
||||
|
||||
nsIScrollableFrame* GetScrollTargetFrame() const final;
|
||||
mozilla::ScrollContainerFrame* GetScrollTargetFrame() const final;
|
||||
|
||||
nsTableRowFrame* GetTableRowFrame() const {
|
||||
nsIFrame* parent = GetParent();
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
#include "mozilla/dom/Document.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsNumberControlFrame.h"
|
||||
#include "nsPresContext.h"
|
||||
|
|
@ -27,6 +26,7 @@
|
|||
#include "mozilla/dom/HTMLInputElement.h"
|
||||
#include "mozilla/dom/HTMLProgressElement.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/ScrollContainerFrame.h"
|
||||
#include "mozilla/StaticPrefs_layout.h"
|
||||
#include "mozilla/dom/DocumentInlines.h"
|
||||
#include <algorithm>
|
||||
|
|
@ -534,13 +534,13 @@ bool nsNativeTheme::IsDarkBackgroundForScrollbar(nsIFrame* aFrame) {
|
|||
// might be none.
|
||||
{
|
||||
nsIFrame* frame = aFrame;
|
||||
nsIScrollableFrame* scrollFrame = nullptr;
|
||||
while (!scrollFrame && frame) {
|
||||
scrollFrame = frame->GetScrollTargetFrame();
|
||||
ScrollContainerFrame* scrollContainerFrame = nullptr;
|
||||
while (!scrollContainerFrame && frame) {
|
||||
scrollContainerFrame = frame->GetScrollTargetFrame();
|
||||
frame = frame->GetParent();
|
||||
}
|
||||
if (scrollFrame) {
|
||||
aFrame = scrollFrame->GetScrolledFrame();
|
||||
if (scrollContainerFrame) {
|
||||
aFrame = scrollContainerFrame->GetScrolledFrame();
|
||||
} else {
|
||||
// Leave aFrame untouched.
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue