Bug 1896516 Part 10 - Remove nsIScrollableFrame usages under gfx/. r=layout-reviewers,emilio

Differential Revision: https://phabricator.services.mozilla.com/D211497
This commit is contained in:
Ting-Yu Lin 2024-05-30 06:32:21 +00:00
Родитель 58991f71c0
Коммит f390af5424
11 изменённых файлов: 72 добавлений и 72 удалений

Просмотреть файл

@ -653,27 +653,28 @@ static SideBits GetOverflowedSides(const nsRect& aOverflow,
static std::pair<ParentLayerRect, gfx::Matrix4x4>
GetClipRectAndTransformForPartialPrerender(
const nsIFrame* aFrame, int32_t aDevPixelsToAppUnits,
const nsIFrame* aClipFrame, const nsIScrollableFrame* aScrollFrame) {
const nsIFrame* aClipFrame,
const ScrollContainerFrame* aScrollContainerFrame) {
MOZ_ASSERT(aClipFrame);
gfx::Matrix4x4 transformInClip =
nsLayoutUtils::GetTransformToAncestor(RelativeTo{aFrame->GetParent()},
RelativeTo{aClipFrame})
.GetMatrix();
if (aScrollFrame) {
if (aScrollContainerFrame) {
transformInClip.PostTranslate(
LayoutDevicePoint::FromAppUnits(aScrollFrame->GetScrollPosition(),
aDevPixelsToAppUnits)
LayoutDevicePoint::FromAppUnits(
aScrollContainerFrame->GetScrollPosition(), aDevPixelsToAppUnits)
.ToUnknownPoint());
}
// We don't necessarily use nsLayoutUtils::CalculateCompositionSizeForFrame
// since this is a case where we don't use APZ at all.
return std::make_pair(
LayoutDeviceRect::FromAppUnits(aScrollFrame
? aScrollFrame->GetScrollPortRect()
: aClipFrame->GetRectRelativeToSelf(),
aDevPixelsToAppUnits) *
LayoutDeviceRect::FromAppUnits(
aScrollContainerFrame ? aScrollContainerFrame->GetScrollPortRect()
: aClipFrame->GetRectRelativeToSelf(),
aDevPixelsToAppUnits) *
LayoutDeviceToLayerScale2D() * LayerToParentLayerScale(),
transformInClip);
}
@ -708,12 +709,10 @@ static PartialPrerenderData GetPartialPrerenderData(
const bool isInPositionFixed =
nsLayoutUtils::IsInPositionFixedSubtree(aFrame);
const ActiveScrolledRoot* asr = aItem->GetActiveScrolledRoot();
const nsIFrame* asrScrollableFrame =
asr ? do_QueryFrame(asr->mScrollableFrame) : nullptr;
if (!isInPositionFixed && asr &&
aFrame->PresContext() == asrScrollableFrame->PresContext()) {
aFrame->PresContext() == asr->mScrollContainerFrame->PresContext()) {
scrollId = asr->GetViewId();
MOZ_ASSERT(clipFrame == asrScrollableFrame);
MOZ_ASSERT(clipFrame == asr->mScrollContainerFrame);
} else {
// Use the root scroll id in the same document if the target frame is in
// position:fixed subtree or there is no ASR or the ASR is in a different

Просмотреть файл

@ -10,7 +10,6 @@
#include <stdint.h> // for uint32_t
#include "InputData.h" // for KeyboardInput
#include "nsIScrollableFrame.h" // for nsIScrollableFrame::ScrollUnit
#include "nsTArray.h" // for nsTArray
#include "mozilla/Maybe.h" // for mozilla::Maybe
#include "KeyboardScrollAction.h" // for KeyboardScrollAction

Просмотреть файл

@ -65,7 +65,7 @@ static PresShell* GetPresShell(const nsIContent* aContent) {
return nullptr;
}
static CSSPoint ScrollFrameTo(nsIScrollableFrame* aFrame,
static CSSPoint ScrollFrameTo(ScrollContainerFrame* aFrame,
const RepaintRequest& aRequest,
bool& aSuccessOut) {
aSuccessOut = false;
@ -160,7 +160,7 @@ static DisplayPortMargins ScrollFrame(nsIContent* aContent,
sf->ResetScrollInfoIfNeeded(aRequest.GetScrollGeneration(),
aRequest.GetScrollGenerationOnApz(),
aRequest.GetScrollAnimationType(),
nsIScrollableFrame::InScrollingGesture(
ScrollContainerFrame::InScrollingGesture(
aRequest.IsInScrollingGesture()));
sf->SetScrollableByAPZ(!aRequest.IsScrollInfoLayer());
if (sf->IsRootScrollFrameOfDocument()) {
@ -580,11 +580,11 @@ void APZCCallbackHelper::FireSingleTapEvent(
}
static dom::Element* GetDisplayportElementFor(
nsIScrollableFrame* aScrollableFrame) {
if (!aScrollableFrame) {
ScrollContainerFrame* aScrollContainerFrame) {
if (!aScrollContainerFrame) {
return nullptr;
}
nsIFrame* scrolledFrame = aScrollableFrame->GetScrolledFrame();
nsIFrame* scrolledFrame = aScrollContainerFrame->GetScrolledFrame();
if (!scrolledFrame) {
return nullptr;
}
@ -827,8 +827,8 @@ void APZCCallbackHelper::NotifyFlushComplete(PresShell* aPresShell) {
}
/* static */
bool APZCCallbackHelper::IsScrollInProgress(nsIScrollableFrame* aFrame) {
using AnimationState = nsIScrollableFrame::AnimationState;
bool APZCCallbackHelper::IsScrollInProgress(ScrollContainerFrame* aFrame) {
using AnimationState = ScrollContainerFrame::AnimationState;
return aFrame->ScrollAnimationState().contains(AnimationState::MainThread) ||
nsLayoutUtils::CanScrollOriginClobberApz(aFrame->LastScrollOrigin());

Просмотреть файл

@ -16,7 +16,6 @@
#include <functional>
class nsIContent;
class nsIScrollableFrame;
class nsIWidget;
class nsPresContext;
template <class T>
@ -27,6 +26,7 @@ class nsCOMPtr;
namespace mozilla {
class PresShell;
class ScrollContainerFrame;
enum class PreventDefaultResult : uint8_t;
namespace layers {
@ -176,14 +176,14 @@ class APZCCallbackHelper {
float aScale);
/*
* Check if the scrollable frame is currently in the middle of a main thread
* async or smooth scroll, or has already requested some other apz scroll that
* hasn't been acknowledged by apz.
* Check if the scroll container frame is currently in the middle of a main
* thread async or smooth scroll, or has already requested some other apz
* scroll that hasn't been acknowledged by apz.
*
* We want to discard apz updates to the main-thread scroll offset if this is
* true to prevent clobbering higher priority origins.
*/
static bool IsScrollInProgress(nsIScrollableFrame* aFrame);
static bool IsScrollInProgress(ScrollContainerFrame* aFrame);
/* Notify content of the progress of a pinch gesture that APZ won't do
* zooming for (because the apz.allow_zooming pref is false). This function

Просмотреть файл

@ -8,6 +8,7 @@
#include "DisplayItemClipChain.h"
#include "FrameMetrics.h"
#include "mozilla/ScrollContainerFrame.h"
#include "mozilla/dom/Document.h"
#include "mozilla/layers/StackingContextHelper.h"
#include "mozilla/layers/WebRenderLayerManager.h"
@ -319,9 +320,9 @@ Maybe<wr::WrSpatialId> ClipManager::DefineScrollLayers(
Maybe<wr::WrSpatialId> ancestorSpace =
DefineScrollLayers(aASR->mParent, aItem);
Maybe<ScrollMetadata> metadata =
aASR->mScrollableFrame->ComputeScrollMetadata(mManager, aItem->Frame(),
aItem->ToReferenceFrame());
ScrollContainerFrame* scrollContainerFrame = aASR->mScrollContainerFrame;
Maybe<ScrollMetadata> metadata = scrollContainerFrame->ComputeScrollMetadata(
mManager, aItem->Frame(), aItem->ToReferenceFrame());
if (!metadata) {
MOZ_ASSERT_UNREACHABLE("Expected scroll metadata to be available!");
return ancestorSpace;
@ -333,12 +334,10 @@ Maybe<wr::WrSpatialId> ClipManager::DefineScrollLayers(
return ancestorSpace;
}
nsIScrollableFrame* scrollableFrame = aASR->mScrollableFrame;
nsIFrame* scrollFrame = do_QueryFrame(scrollableFrame);
nsPoint offset = scrollFrame->GetOffsetToCrossDoc(aItem->Frame()) +
nsPoint offset = scrollContainerFrame->GetOffsetToCrossDoc(aItem->Frame()) +
aItem->ToReferenceFrame();
int32_t auPerDevPixel = aItem->Frame()->PresContext()->AppUnitsPerDevPixel();
nsRect scrollPort = scrollableFrame->GetScrollPortRect() + offset;
nsRect scrollPort = scrollContainerFrame->GetScrollPortRect() + offset;
LayoutDeviceRect clipBounds =
LayoutDeviceRect::FromAppUnits(scrollPort, auPerDevPixel);
@ -370,9 +369,9 @@ Maybe<wr::WrSpatialId> ClipManager::DefineScrollLayers(
LayoutDevicePoint scrollOffset =
useRoundedOffset
? LayoutDevicePoint::FromAppUnitsRounded(
scrollableFrame->GetScrollPosition(), auPerDevPixel)
scrollContainerFrame->GetScrollPosition(), auPerDevPixel)
: LayoutDevicePoint::FromAppUnits(
scrollableFrame->GetScrollPosition(), auPerDevPixel);
scrollContainerFrame->GetScrollPosition(), auPerDevPixel);
// Currently we track scroll-linked effects at the granularity of documents,
// not scroll frames, so we consider a scroll frame to have a scroll-linked
@ -385,9 +384,11 @@ Maybe<wr::WrSpatialId> ClipManager::DefineScrollLayers(
return Some(mBuilder->DefineScrollLayer(
viewId, parent, wr::ToLayoutRect(contentRect),
wr::ToLayoutRect(clipBounds), wr::ToLayoutVector2D(scrollOffset),
wr::ToWrAPZScrollGeneration(scrollableFrame->ScrollGenerationOnApz()),
wr::ToWrAPZScrollGeneration(
scrollContainerFrame->ScrollGenerationOnApz()),
wr::ToWrHasScrollLinkedEffect(hasScrollLinkedEffect),
wr::SpatialKey(uint64_t(scrollFrame), 0, wr::SpatialKeyKind::Scroll)));
wr::SpatialKey(uint64_t(scrollContainerFrame), 0,
wr::SpatialKeyKind::Scroll)));
}
Maybe<wr::WrClipChainId> ClipManager::DefineClipChain(
@ -400,7 +401,7 @@ Maybe<wr::WrClipChainId> ClipManager::DefineClipChain(
for (const DisplayItemClipChain* chain = aChain; chain;
chain = chain->mParent) {
MOZ_DIAGNOSTIC_ASSERT(chain->mOnStack || !chain->mASR ||
chain->mASR->mScrollableFrame);
chain->mASR->mScrollContainerFrame);
if (!chain->mClip.HasClip()) {
// This item in the chain is a no-op, skip over it

Просмотреть файл

@ -11,6 +11,7 @@
#include "Units.h"
#include "mozilla/layers/LayersMessageUtils.h"
#include "mozilla/layers/WebRenderLayerManager.h"
#include "mozilla/ScrollContainerFrame.h"
#include "mozilla/ToString.h"
#include "mozilla/Unused.h"
#include "nsDisplayList.h"
@ -71,9 +72,9 @@ void WebRenderLayerScrollData::Initialize(
mScrollIds.AppendElement(index.ref());
} else {
Maybe<ScrollMetadata> metadata =
asr->mScrollableFrame->ComputeScrollMetadata(
asr->mScrollContainerFrame->ComputeScrollMetadata(
aOwner.GetManager(), aItem->Frame(), aItem->ToReferenceFrame());
aOwner.GetBuilder()->AddScrollFrameToNotify(asr->mScrollableFrame);
aOwner.GetBuilder()->AddScrollFrameToNotify(asr->mScrollContainerFrame);
if (metadata) {
MOZ_ASSERT(metadata->GetMetrics().GetScrollId() == scrollId);
mScrollIds.AppendElement(aOwner.AddMetadata(metadata.ref()));

Просмотреть файл

@ -3800,7 +3800,7 @@ void nsIFrame::BuildDisplayListForStackingContext(
// inhibits paint skipping).
if (aBuilder->GetFilterASR() && aBuilder->GetFilterASR() == stickyASR) {
aBuilder->GetFilterASR()
->mScrollableFrame->SetHasOutOfFlowContentInsideFilter();
->mScrollContainerFrame->SetHasOutOfFlowContentInsideFilter();
}
}

Просмотреть файл

@ -69,7 +69,7 @@ nsCString DisplayItemClipChain::ToString(
for (auto* sc = aClipChain; sc; sc = sc->mParent) {
if (sc->mASR) {
str.AppendPrintf("0x%p <%s> [0x%p]", sc, sc->mClip.ToString().get(),
sc->mASR->mScrollableFrame);
sc->mASR->mScrollContainerFrame);
} else {
str.AppendPrintf("0x%p <%s> [root asr]", sc, sc->mClip.ToString().get());
}

Просмотреть файл

@ -305,8 +305,8 @@ bool RetainedDisplayListBuilder::PreProcessDisplayList(
!item->GetActiveScrolledRoot()) {
agrFrame = aAsyncAncestor;
} else {
agrFrame =
item->GetActiveScrolledRoot()->mScrollableFrame->GetScrolledFrame();
agrFrame = item->GetActiveScrolledRoot()
->mScrollContainerFrame->GetScrolledFrame();
}
if (aAGR && agrFrame != aAGR) {
@ -363,7 +363,7 @@ static Maybe<const ActiveScrolledRoot*> SelectContainerASR(
aClipChain ? aClipChain->mASR : nullptr;
MOZ_DIAGNOSTIC_ASSERT(!aClipChain || aClipChain->mOnStack || !itemClipASR ||
itemClipASR->mScrollableFrame);
itemClipASR->mScrollContainerFrame);
const ActiveScrolledRoot* finiteBoundsASR =
ActiveScrolledRoot::PickDescendant(itemClipASR, aItemASR);

Просмотреть файл

@ -169,13 +169,11 @@ void InitializeHitTestInfo(nsDisplayListBuilder* aBuilder,
/* static */
already_AddRefed<ActiveScrolledRoot> ActiveScrolledRoot::CreateASRForFrame(
const ActiveScrolledRoot* aParent, nsIScrollableFrame* aScrollableFrame,
bool aIsRetained) {
nsIFrame* f = do_QueryFrame(aScrollableFrame);
const ActiveScrolledRoot* aParent,
ScrollContainerFrame* aScrollContainerFrame, bool aIsRetained) {
RefPtr<ActiveScrolledRoot> asr;
if (aIsRetained) {
asr = f->GetProperty(ActiveScrolledRootCache());
asr = aScrollContainerFrame->GetProperty(ActiveScrolledRootCache());
}
if (!asr) {
@ -183,11 +181,12 @@ already_AddRefed<ActiveScrolledRoot> ActiveScrolledRoot::CreateASRForFrame(
if (aIsRetained) {
RefPtr<ActiveScrolledRoot> ref = asr;
f->SetProperty(ActiveScrolledRootCache(), ref.forget().take());
aScrollContainerFrame->SetProperty(ActiveScrolledRootCache(),
ref.forget().take());
}
}
asr->mParent = aParent;
asr->mScrollableFrame = aScrollableFrame;
asr->mScrollContainerFrame = aScrollContainerFrame;
asr->mDepth = aParent ? aParent->mDepth + 1 : 1;
asr->mRetained = aIsRetained;
@ -226,7 +225,7 @@ nsCString ActiveScrolledRoot::ToString(
const ActiveScrolledRoot* aActiveScrolledRoot) {
nsAutoCString str;
for (const auto* asr = aActiveScrolledRoot; asr; asr = asr->mParent) {
str.AppendPrintf("<0x%p>", asr->mScrollableFrame);
str.AppendPrintf("<0x%p>", asr->mScrollContainerFrame);
if (asr->mParent) {
str.AppendLiteral(", ");
}
@ -235,14 +234,13 @@ nsCString ActiveScrolledRoot::ToString(
}
ScrollableLayerGuid::ViewID ActiveScrolledRoot::ComputeViewId() const {
nsIContent* content = mScrollableFrame->GetScrolledFrame()->GetContent();
nsIContent* content = mScrollContainerFrame->GetScrolledFrame()->GetContent();
return nsLayoutUtils::FindOrCreateIDFor(content);
}
ActiveScrolledRoot::~ActiveScrolledRoot() {
if (mScrollableFrame && mRetained) {
nsIFrame* f = do_QueryFrame(mScrollableFrame);
f->RemoveProperty(ActiveScrolledRootCache());
if (mScrollContainerFrame && mRetained) {
mScrollContainerFrame->RemoveProperty(ActiveScrolledRootCache());
}
}
@ -455,7 +453,7 @@ void nsDisplayListBuilder::AutoCurrentActiveScrolledRootSetter::
aActiveScrolledRoot, mBuilder->mFilterASR)) {
for (const ActiveScrolledRoot* asr = mBuilder->mFilterASR;
asr && asr != aActiveScrolledRoot; asr = asr->mParent) {
asr->mScrollableFrame->SetHasOutOfFlowContentInsideFilter();
asr->mScrollContainerFrame->SetHasOutOfFlowContentInsideFilter();
}
}
@ -463,12 +461,12 @@ void nsDisplayListBuilder::AutoCurrentActiveScrolledRootSetter::
}
void nsDisplayListBuilder::AutoCurrentActiveScrolledRootSetter::
InsertScrollFrame(nsIScrollableFrame* aScrollableFrame) {
InsertScrollFrame(ScrollContainerFrame* aScrollContainerFrame) {
MOZ_ASSERT(!mUsed);
size_t descendantsEndIndex = mBuilder->mActiveScrolledRoots.Length();
const ActiveScrolledRoot* parentASR = mBuilder->mCurrentActiveScrolledRoot;
const ActiveScrolledRoot* asr =
mBuilder->AllocateActiveScrolledRoot(parentASR, aScrollableFrame);
mBuilder->AllocateActiveScrolledRoot(parentASR, aScrollContainerFrame);
mBuilder->mCurrentActiveScrolledRoot = asr;
// All child ASRs of parentASR that were created while this
@ -1450,9 +1448,10 @@ void nsDisplayListBuilder::MarkPreserve3DFramesForDisplayList(
}
ActiveScrolledRoot* nsDisplayListBuilder::AllocateActiveScrolledRoot(
const ActiveScrolledRoot* aParent, nsIScrollableFrame* aScrollableFrame) {
const ActiveScrolledRoot* aParent,
ScrollContainerFrame* aScrollContainerFrame) {
RefPtr<ActiveScrolledRoot> asr = ActiveScrolledRoot::CreateASRForFrame(
aParent, aScrollableFrame, IsRetainingDisplayList());
aParent, aScrollContainerFrame, IsRetainingDisplayList());
mActiveScrolledRoots.AppendElement(asr);
return asr;
}
@ -7443,7 +7442,7 @@ bool nsDisplayPerspective::CreateWebRenderCommands(
// document is always active, so using IsAncestorFrameCrossDocInProcess
// should be fine here.
if (nsLayoutUtils::IsAncestorFrameCrossDocInProcess(
asr->mScrollableFrame->GetScrolledFrame(), perspectiveFrame)) {
asr->mScrollContainerFrame->GetScrolledFrame(), perspectiveFrame)) {
scrollingRelativeTo.emplace(asr->GetViewId());
break;
}

Просмотреть файл

@ -80,6 +80,7 @@ enum class nsDisplayOwnLayerFlags;
class nsDisplayCompositorHitTestInfo;
class nsDisplayScrollInfoLayer;
class PresShell;
class ScrollContainerFrame;
class StickyScrollContainer;
namespace layers {
@ -189,8 +190,8 @@ LazyLogModule& GetLoggerByProcess();
*/
struct ActiveScrolledRoot {
static already_AddRefed<ActiveScrolledRoot> CreateASRForFrame(
const ActiveScrolledRoot* aParent, nsIScrollableFrame* aScrollableFrame,
bool aIsRetained);
const ActiveScrolledRoot* aParent,
ScrollContainerFrame* aScrollContainerFrame, bool aIsRetained);
static const ActiveScrolledRoot* PickAncestor(
const ActiveScrolledRoot* aOne, const ActiveScrolledRoot* aTwo) {
@ -226,19 +227,18 @@ struct ActiveScrolledRoot {
}
RefPtr<const ActiveScrolledRoot> mParent;
nsIScrollableFrame* mScrollableFrame;
ScrollContainerFrame* mScrollContainerFrame = nullptr;
NS_INLINE_DECL_REFCOUNTING(ActiveScrolledRoot)
private:
ActiveScrolledRoot()
: mScrollableFrame(nullptr), mDepth(0), mRetained(false) {}
ActiveScrolledRoot() : mDepth(0), mRetained(false) {}
~ActiveScrolledRoot();
static void DetachASR(ActiveScrolledRoot* aASR) {
aASR->mParent = nullptr;
aASR->mScrollableFrame = nullptr;
aASR->mScrollContainerFrame = nullptr;
NS_RELEASE(aASR);
}
NS_DECLARE_FRAME_PROPERTY_WITH_DTOR(ActiveScrolledRootCache,
@ -946,7 +946,8 @@ class nsDisplayListBuilder {
* automatically when the arena goes away.
*/
ActiveScrolledRoot* AllocateActiveScrolledRoot(
const ActiveScrolledRoot* aParent, nsIScrollableFrame* aScrollableFrame);
const ActiveScrolledRoot* aParent,
ScrollContainerFrame* aScrollContainerFrame);
/**
* Allocate a new DisplayItemClipChain object in the arena. Will be cleaned
@ -1178,15 +1179,15 @@ class nsDisplayListBuilder {
void SetCurrentActiveScrolledRoot(
const ActiveScrolledRoot* aActiveScrolledRoot);
void EnterScrollFrame(nsIScrollableFrame* aScrollableFrame) {
void EnterScrollFrame(ScrollContainerFrame* aScrollContainerFrame) {
MOZ_ASSERT(!mUsed);
ActiveScrolledRoot* asr = mBuilder->AllocateActiveScrolledRoot(
mBuilder->mCurrentActiveScrolledRoot, aScrollableFrame);
mBuilder->mCurrentActiveScrolledRoot, aScrollContainerFrame);
mBuilder->mCurrentActiveScrolledRoot = asr;
mUsed = true;
}
void InsertScrollFrame(nsIScrollableFrame* aScrollableFrame);
void InsertScrollFrame(ScrollContainerFrame* aScrollContainerFrame);
private:
nsDisplayListBuilder* mBuilder;