Bug 1896516 Part 6 - Remove nsIScrollableFrame usages in nsLayoutUtils. r=layout-reviewers,emilio

Convert `nsIScrollableFrame` to `ScrollContainerFrame` for all the APIs in
nsLayoutUtils, and then adapt other callers until everything compiles.

In `nsLayoutUtils::CalculateBasicFrameMetrics()`'s documentation,
s/ComputeFrameMetrics/ComputeScrollMetadata/ because the method was renamed in
https://hg.mozilla.org/mozilla-central/rev/cb2023f50288

Differential Revision: https://phabricator.services.mozilla.com/D211493
This commit is contained in:
Ting-Yu Lin
2024-05-30 06:32:20 +00:00
parent f59e487e79
commit 76523f97b1
24 changed files with 365 additions and 347 deletions

View File

@@ -4705,16 +4705,16 @@ nsresult nsIFrame::MoveCaretToEventPoint(nsPresContext* aPresContext,
if (isPrimaryButtonDown) {
// If the mouse is dragged outside the nearest enclosing scrollable area
// while making a selection, the area will be scrolled. To do this, capture
// the mouse on the nearest scrollable frame. If there isn't a scrollable
// frame, or something else is already capturing the mouse, there's no
// reason to capture.
// the mouse on the nearest scroll container frame. If there isn't a scroll
// container frame, or something else is already capturing the mouse,
// there's no reason to capture.
if (!PresShell::GetCapturingContent()) {
nsIScrollableFrame* scrollFrame =
nsLayoutUtils::GetNearestScrollableFrame(
ScrollContainerFrame* scrollContainerFrame =
nsLayoutUtils::GetNearestScrollContainerFrame(
this, nsLayoutUtils::SCROLLABLE_SAME_DOC |
nsLayoutUtils::SCROLLABLE_INCLUDE_HIDDEN);
if (scrollFrame) {
nsIFrame* capturingFrame = do_QueryFrame(scrollFrame);
if (scrollContainerFrame) {
nsIFrame* capturingFrame = scrollContainerFrame;
PresShell::SetCapturingContent(capturingFrame->GetContent(),
CaptureFlags::IgnoreAllowedState);
}
@@ -5209,13 +5209,14 @@ NS_IMETHODIMP nsIFrame::HandleDrag(nsPresContext* aPresContext,
return NS_OK;
}
// get the nearest scrollframe
nsIScrollableFrame* scrollFrame = nsLayoutUtils::GetNearestScrollableFrame(
this, nsLayoutUtils::SCROLLABLE_SAME_DOC |
nsLayoutUtils::SCROLLABLE_INCLUDE_HIDDEN);
// Get the nearest scroll container frame.
ScrollContainerFrame* scrollContainerFrame =
nsLayoutUtils::GetNearestScrollContainerFrame(
this, nsLayoutUtils::SCROLLABLE_SAME_DOC |
nsLayoutUtils::SCROLLABLE_INCLUDE_HIDDEN);
if (scrollFrame) {
nsIFrame* capturingFrame = scrollFrame->GetScrolledFrame();
if (scrollContainerFrame) {
nsIFrame* capturingFrame = scrollContainerFrame->GetScrolledFrame();
if (capturingFrame) {
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(
mouseEvent, RelativeTo{capturingFrame});
@@ -5356,14 +5357,14 @@ NS_IMETHODIMP nsIFrame::HandleRelease(nsPresContext* aPresContext,
frameSelection->SetDragState(false);
frameSelection->StopAutoScrollTimer();
if (wf.IsAlive()) {
nsIScrollableFrame* scrollFrame =
nsLayoutUtils::GetNearestScrollableFrame(
ScrollContainerFrame* scrollContainerFrame =
nsLayoutUtils::GetNearestScrollContainerFrame(
this, nsLayoutUtils::SCROLLABLE_SAME_DOC |
nsLayoutUtils::SCROLLABLE_INCLUDE_HIDDEN);
if (scrollFrame) {
if (scrollContainerFrame) {
// Perform any additional scrolling needed to maintain CSS snap point
// requirements when autoscrolling is over.
scrollFrame->ScrollSnap();
scrollContainerFrame->ScrollSnap();
}
}
}
@@ -11361,13 +11362,14 @@ void nsIFrame::AddSizeOfExcludingThisForTree(nsWindowSizes& aSizes) const {
nsRect nsIFrame::GetCompositorHitTestArea(nsDisplayListBuilder* aBuilder) {
nsRect area;
nsIScrollableFrame* scrollFrame = nsLayoutUtils::GetScrollableFrameFor(this);
if (scrollFrame) {
// If the frame is content of a scrollframe, then we need to pick up the
// area corresponding to the overflow rect as well. Otherwise the parts of
// the overflow that are not occupied by descendants get skipped and the
// APZ code sends touch events to the content underneath instead.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1127773#c15.
ScrollContainerFrame* scrollContainerFrame =
nsLayoutUtils::GetScrollContainerFrameFor(this);
if (scrollContainerFrame) {
// If this frame is the scrolled frame of a scroll container frame, then we
// need to pick up the area corresponding to the overflow rect as well.
// Otherwise the parts of the overflow that are not occupied by descendants
// get skipped and the APZ code sends touch events to the content underneath
// instead. See https://bugzilla.mozilla.org/show_bug.cgi?id=1127773#c15.
area = ScrollableOverflowRect();
} else {
area = GetRectRelativeToSelf();
@@ -11440,12 +11442,12 @@ CompositorHitTestInfo nsIFrame::GetCompositorHitTestInfo(
aBuilder->GetCompositorHitTestInfo() & CompositorHitTestTouchActionMask;
nsIFrame* touchActionFrame = this;
if (nsIScrollableFrame* scrollFrame =
nsLayoutUtils::GetScrollableFrameFor(this)) {
ScrollStyles ss = scrollFrame->GetScrollStyles();
if (ScrollContainerFrame* scrollContainerFrame =
nsLayoutUtils::GetScrollContainerFrameFor(this)) {
ScrollStyles ss = scrollContainerFrame->GetScrollStyles();
if (ss.mVertical != StyleOverflow::Hidden ||
ss.mHorizontal != StyleOverflow::Hidden) {
touchActionFrame = do_QueryFrame(scrollFrame);
touchActionFrame = scrollContainerFrame;
// On scrollframes, stop inheriting the pan-x and pan-y flags; instead,
// reset them back to zero to allow panning on the scrollframe unless we
// encounter an element that disables it that's inside the scrollframe.