Bug 1915474 - Make SVG rendering observer container a class flag. r=longsonr

Drive-by, but it's only set on creation, so no need to make it a state bit.

Differential Revision: https://phabricator.services.mozilla.com/D220296
This commit is contained in:
Emilio Cobos Álvarez 2024-08-28 20:16:03 +00:00
Родитель 7bc16868a1
Коммит a61132e626
11 изменённых файлов: 25 добавлений и 40 удалений

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

@ -28,6 +28,7 @@ TABLE_CELL = TABLE_PART | {"SupportsContainLayoutAndPaint"}
MATHML_CONTAINER = (COMMON - {"SupportsContainLayoutAndPaint"}) | MATHML
SVG_CONTENT = (COMMON - {"SupportsContainLayoutAndPaint"}) | SVG
SVG_CONTAINER = SVG_CONTENT | {"SVGContainer"}
SVG_RENDERING_OBSERVER_CONTAINER = SVG_CONTAINER | {"SVGRenderingObserverContainer"}
# NOTE: Intentionally not including "COMMON" here.
INLINE = LINE_PARTICIPANT | {"BidiInlineContainer"}
@ -121,33 +122,36 @@ FRAME_CLASSES = [
Frame("nsSubDocumentFrame", "SubDocument", REPLACED_SIZING | LEAF),
Frame("PrintedSheetFrame", "PrintedSheet", COMMON),
Frame("SVGAFrame", "SVGA", SVG_CONTAINER),
Frame("SVGClipPathFrame", "SVGClipPath", SVG_CONTAINER),
Frame("SVGContainerFrame", "None", SVG_CONTAINER),
Frame("SVGClipPathFrame", "SVGClipPath", SVG_RENDERING_OBSERVER_CONTAINER),
# Note that not all the SVGContainerFrame classes should have the rendering
# observer flag, but the specific instances (used for <svg:defs>) should.
Frame("SVGContainerFrame", "None", SVG_RENDERING_OBSERVER_CONTAINER),
Frame("SVGFEContainerFrame", "SVGFEContainer", SVG_CONTENT),
Frame("SVGFEImageFrame", "SVGFEImage", SVG_CONTENT | LEAF),
Frame("SVGFELeafFrame", "SVGFELeaf", SVG_CONTENT | LEAF),
Frame("SVGFEUnstyledLeafFrame", "SVGFEUnstyledLeaf", SVG_CONTENT | LEAF),
Frame("SVGFilterFrame", "SVGFilter", SVG_CONTAINER),
Frame("SVGFilterFrame", "SVGFilter", SVG_RENDERING_OBSERVER_CONTAINER),
Frame("SVGForeignObjectFrame", "SVGForeignObject", SVG_CONTENT),
Frame("SVGGeometryFrame", "SVGGeometry", SVG_CONTENT | LEAF),
Frame("SVGGFrame", "SVGG", SVG_CONTAINER),
Frame("SVGImageFrame", "SVGImage", SVG_CONTENT | LEAF),
Frame("SVGInnerSVGFrame", "SVGInnerSVG", SVG_CONTAINER),
Frame("SVGLinearGradientFrame", "SVGLinearGradient", SVG_CONTAINER),
Frame("SVGMarkerFrame", "SVGMarker", SVG_CONTAINER),
Frame("SVGMarkerFrame", "SVGMarker", SVG_RENDERING_OBSERVER_CONTAINER),
Frame("SVGMarkerAnonChildFrame", "SVGMarkerAnonChild", SVG_CONTAINER),
Frame("SVGMaskFrame", "SVGMask", SVG_CONTAINER),
Frame("SVGMaskFrame", "SVGMask", SVG_RENDERING_OBSERVER_CONTAINER),
Frame(
"SVGOuterSVGFrame",
"SVGOuterSVG",
SVG_CONTAINER | {"Replaced", "ReplacedSizing", "SupportsContainLayoutAndPaint"},
SVG_RENDERING_OBSERVER_CONTAINER
| {"Replaced", "ReplacedSizing", "SupportsContainLayoutAndPaint"},
),
Frame("SVGOuterSVGAnonChildFrame", "SVGOuterSVGAnonChild", SVG_CONTAINER),
Frame("SVGPatternFrame", "SVGPattern", SVG_CONTAINER),
Frame("SVGRadialGradientFrame", "SVGRadialGradient", SVG_CONTAINER),
Frame("SVGStopFrame", "SVGStop", SVG_CONTENT | LEAF),
Frame("SVGSwitchFrame", "SVGSwitch", SVG_CONTAINER),
Frame("SVGSymbolFrame", "SVGSymbol", SVG_CONTAINER),
Frame("SVGSymbolFrame", "SVGSymbol", SVG_RENDERING_OBSERVER_CONTAINER),
Frame("SVGTextFrame", "SVGText", SVG_CONTAINER),
# Not a leaf, though it always has a ShadowRoot, so in practice light DOM
# children never render.

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

@ -437,10 +437,6 @@ FRAME_STATE_BIT(SVG, 23, NS_STATE_SVG_TEXT_IN_REFLOW)
// to update the cached nsTextNode indexes that they correspond to.
FRAME_STATE_BIT(SVG, 24, NS_STATE_SVG_TEXT_CORRESPONDENCE_DIRTY)
// We can stop ancestor traversal of rendering observers when we hit
// one a frame with this state bit.
FRAME_STATE_BIT(SVG, 25, NS_STATE_SVG_RENDERING_OBSERVER_CONTAINER)
// == Frame state bits that apply to text frames ==============================
FRAME_STATE_GROUP(Text, nsTextFrame)

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

@ -575,6 +575,8 @@ enum class LayoutFrameClassFlags : uint16_t {
SupportsAspectRatio = 1 << 13,
// Whether this frame class is always a BFC.
BlockFormattingContext = 1 << 14,
// Whether we're a SVG rendering observer container.
SVGRenderingObserverContainer = 1 << 15,
};
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(LayoutFrameClassFlags)
@ -3449,6 +3451,8 @@ class nsIFrame : public nsQueryFrame {
CLASS_FLAG_METHOD0(SupportsCSSTransforms);
CLASS_FLAG_METHOD0(SupportsContainLayoutAndPaint)
CLASS_FLAG_METHOD0(SupportsAspectRatio)
CLASS_FLAG_METHOD(IsSVGRenderingObserverContainer,
SVGRenderingObserverContainer);
#undef CLASS_FLAG_METHOD
#undef CLASS_FLAG_METHOD0
@ -4675,17 +4679,6 @@ class nsIFrame : public nsQueryFrame {
return HasAnyStateBits(NS_FRAME_IS_SVG_TEXT);
}
/**
* Returns true if the frame is an SVG Rendering Observer container.
*/
bool IsRenderingObserverContainer() const {
// NS_FRAME_SVG_LAYOUT is used as a proxy to check for an SVG frame because
// NS_STATE_SVG_RENDERING_OBSERVER_CONTAINER is an SVG specific state bit.
return HasAllStateBits(NS_FRAME_SVG_LAYOUT |
NS_STATE_SVG_RENDERING_OBSERVER_CONTAINER) ||
IsSVGOuterSVGFrame();
}
/**
* Return whether this frame keeps track of overflow areas. (Frames for
* non-display SVG elements -- e.g. <clipPath> -- do not maintain overflow

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

@ -36,8 +36,7 @@ class SVGClipPathFrame final : public SVGContainerFrame {
: SVGContainerFrame(aStyle, aPresContext, kClassID),
mIsBeingProcessed(false) {
AddStateBits(NS_FRAME_IS_NONDISPLAY | NS_STATE_SVG_CLIPPATH_CHILD |
NS_FRAME_MAY_BE_TRANSFORMED |
NS_STATE_SVG_RENDERING_OBSERVER_CONTAINER);
NS_FRAME_MAY_BE_TRANSFORMED);
}
public:

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

@ -29,8 +29,7 @@ nsIFrame* NS_NewSVGContainerFrame(mozilla::PresShell* aPresShell,
// If we were called directly, then the frame is for a <defs> or
// an unknown element type. In both cases we prevent the content
// from displaying directly.
frame->AddStateBits(NS_FRAME_IS_NONDISPLAY |
NS_STATE_SVG_RENDERING_OBSERVER_CONTAINER);
frame->AddStateBits(NS_FRAME_IS_NONDISPLAY);
return frame;
}

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

@ -41,8 +41,7 @@ class SVGFilterFrame final : public SVGContainerFrame {
: SVGContainerFrame(aStyle, aPresContext, kClassID),
mLoopFlag(false),
mNoHRefURI(false) {
AddStateBits(NS_FRAME_IS_NONDISPLAY |
NS_STATE_SVG_RENDERING_OBSERVER_CONTAINER);
AddStateBits(NS_FRAME_IS_NONDISPLAY);
}
public:

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

@ -49,8 +49,7 @@ class SVGMarkerFrame final : public SVGContainerFrame {
mMarkedFrame(nullptr),
mInUse(false),
mInUse2(false) {
AddStateBits(NS_FRAME_IS_NONDISPLAY |
NS_STATE_SVG_RENDERING_OBSERVER_CONTAINER);
AddStateBits(NS_FRAME_IS_NONDISPLAY);
}
public:

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

@ -36,8 +36,7 @@ class SVGMaskFrame final : public SVGContainerFrame {
protected:
explicit SVGMaskFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
: SVGContainerFrame(aStyle, aPresContext, kClassID), mInUse(false) {
AddStateBits(NS_FRAME_IS_NONDISPLAY |
NS_STATE_SVG_RENDERING_OBSERVER_CONTAINER);
AddStateBits(NS_FRAME_IS_NONDISPLAY);
}
public:

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

@ -1768,7 +1768,7 @@ bool SVGObserverUtils::SelfOrAncestorHasRenderingObservers(
return true;
}
const auto* frame = content->GetPrimaryFrame();
if (frame && frame->IsRenderingObserverContainer()) {
if (frame && frame->IsSVGRenderingObserverContainer()) {
break;
}
content = content->GetFlattenedTreeParent();
@ -1833,7 +1833,7 @@ void SVGObserverUtils::InvalidateRenderingObservers(nsIFrame* aFrame) {
return;
}
if (aFrame->IsRenderingObserverContainer()) {
if (aFrame->IsSVGRenderingObserverContainer()) {
return;
}
@ -1847,7 +1847,7 @@ void SVGObserverUtils::InvalidateRenderingObservers(nsIFrame* aFrame) {
return;
}
}
if (f->IsRenderingObserverContainer()) {
if (f->IsSVGRenderingObserverContainer()) {
return;
}
}

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

@ -48,8 +48,7 @@ class SVGPaintServerFrame : public SVGContainerFrame {
SVGPaintServerFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
ClassID aID)
: SVGContainerFrame(aStyle, aPresContext, aID) {
AddStateBits(NS_FRAME_IS_NONDISPLAY |
NS_STATE_SVG_RENDERING_OBSERVER_CONTAINER);
AddStateBits(NS_FRAME_IS_NONDISPLAY);
}
public:

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

@ -24,9 +24,7 @@ class SVGSymbolFrame final : public SVGViewportFrame {
protected:
explicit SVGSymbolFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
: SVGViewportFrame(aStyle, aPresContext, kClassID) {
AddStateBits(NS_STATE_SVG_RENDERING_OBSERVER_CONTAINER);
}
: SVGViewportFrame(aStyle, aPresContext, kClassID) {}
public:
NS_DECL_QUERYFRAME