Bug 1824877 Part 6 - Rename IsScrollContainer() to IsScrollContainerOrSubclass(). r=dholbert

This is to avoid confusion with `IsScrollContainerFrame()` introduced in Part 3.

A note to performance concern:

We've used `IsScrollContainerOrSubclass()` in bug 1873414 to avoid expensive
`nsIScrollableFrame* sf = do_QueryFrame()`. Per [1], casting from `nsIFrame*` to
`nsIScrollableFrame*` has no fast path.

Ideally, `ScrollContainerFrame* sf = do_QueryFrame()` should be fast, and we can
use it to implement `IsScrollContainerOrSubclass()` like
`IsImageFrameOrSubclass()`. However, in this patch, I intend to keep the
performance metrics unchanged.

Remove `GetAsScrollContainer()` since it's only used in `MOZ_ASSERT`, and I'm
planning to remove `nsIScrollableFrame` in bug 1896516.

[1] https://searchfox.org/mozilla-central/rev/dd6e430c1bc2db90d9b3b1dd7e5215b4edc4d51a/layout/generic/nsQueryFrame.h#117-121

Differential Revision: https://phabricator.services.mozilla.com/D210395
This commit is contained in:
Ting-Yu Lin 2024-05-15 17:50:50 +00:00
parent 927ea5f38a
commit a9b5e69d86
4 changed files with 16 additions and 15 deletions

View file

@ -854,7 +854,7 @@ bool DisplayPortUtils::MaybeCreateDisplayPortInFirstScrollFrameEncountered(
aFrame->GetContent()->GetID() == nsGkAtoms::tabbrowser_arrowscrollbox) {
return false;
}
if (aFrame->IsScrollContainer()) {
if (aFrame->IsScrollContainerOrSubclass()) {
if (nsIScrollableFrame* sf = do_QueryFrame(aFrame)) {
if (MaybeCreateDisplayPort(aBuilder, aFrame, sf, RepaintMode::Repaint)) {
// If this was the first displayport found in the first scroll frame

View file

@ -8042,7 +8042,7 @@ bool nsIFrame::ComputeCustomOverflow(OverflowAreas& aOverflowAreas) {
}
bool nsIFrame::DoesClipChildrenInBothAxes() const {
if (IsScrollContainer()) {
if (IsScrollContainerOrSubclass()) {
return true;
}
const nsStyleDisplay* display = StyleDisplay();
@ -8151,6 +8151,13 @@ bool nsIFrame::IsImageFrameOrSubclass() const {
return !!asImage;
}
bool nsIFrame::IsScrollContainerOrSubclass() const {
const bool result = IsScrollContainerFrame() || IsListControlFrame();
MOZ_ASSERT(result ==
!!static_cast<const ScrollContainerFrame*>(do_QueryFrame(this)));
return result;
}
bool nsIFrame::IsSubgrid() const {
return IsGridContainerFrame() &&
static_cast<const nsGridContainerFrame*>(this)->IsSubgrid();
@ -11522,10 +11529,6 @@ static bool HasNoVisibleDescendants(const nsIFrame* aFrame) {
return true;
}
nsIScrollableFrame* nsIFrame::GetAsScrollContainer() const {
return do_QueryFrame(this);
}
void nsIFrame::UpdateVisibleDescendantsState() {
if (StyleVisibility()->IsVisible()) {
// Notify invisible ancestors that a visible descendant exists now.

View file

@ -3520,6 +3520,12 @@ class nsIFrame : public nsQueryFrame {
*/
bool IsImageFrameOrSubclass() const;
/**
* Returns true if the frame is an instance of ScrollContainerFrame or one of
* its subclasses.
*/
bool IsScrollContainerOrSubclass() const;
/**
* Get this frame's CSS containing block.
*
@ -4649,14 +4655,6 @@ class nsIFrame : public nsQueryFrame {
return HasAnyStateBits(NS_FRAME_IS_SVG_TEXT);
}
// https://drafts.csswg.org/css-overflow-3/#scroll-container
bool IsScrollContainer() const {
const bool result = IsScrollContainerFrame() || IsListControlFrame();
MOZ_ASSERT(result == !!GetAsScrollContainer());
return result;
}
nsIScrollableFrame* GetAsScrollContainer() const;
/**
* Returns true if the frame is an SVG Rendering Observer container.
*/

View file

@ -1649,7 +1649,7 @@ bool nsDisplayListBuilder::IsAnimatedGeometryRoot(nsIFrame* aFrame,
}
}
if (parent->IsScrollContainer()) {
if (parent->IsScrollContainerOrSubclass()) {
nsIScrollableFrame* sf = do_QueryFrame(parent);
if (sf->GetScrolledFrame() == aFrame) {
MOZ_ASSERT(!aFrame->IsTransformed());