diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 9be9d8bec7a2..23eea3bae15b 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -3494,8 +3494,22 @@ nscoord StyleCalcLengthPercentage::Resolve(nscoord aBasis, bool nsStyleDisplay::PrecludesSizeContainmentOrContentVisibilityWithFrame( const nsIFrame& aFrame) const { - // Note: The spec for size containment says it should have no effect on - // non-atomic, inline-level boxes. + // The spec says that in the case of SVG, the contain property only applies + // to elements that have an associated CSS layout box. + // https://drafts.csswg.org/css-contain/#contain-property + // Internal SVG elements do not use the standard CSS box model, and wouldn't + // be affected by size containment. By disabling it we prevent them from + // becoming query containers for size features. + if (aFrame.HasAnyStateBits(NS_FRAME_SVG_LAYOUT)) { + return true; + } + + // Note: The spec for size containment says it should have no effect + // - on non-atomic, inline-level boxes. + // - on internal ruby boxes. + // - if inner display type is table. + // - on internal table boxes. + // https://drafts.csswg.org/css-contain/#containment-size bool isNonReplacedInline = aFrame.IsLineParticipant() && !aFrame.IsReplaced(); return isNonReplacedInline || IsInternalRubyDisplayType() || DisplayInside() == mozilla::StyleDisplayInside::Table || @@ -3513,13 +3527,6 @@ ContainSizeAxes nsStyleDisplay::GetContainSizeAxes( return ContainSizeAxes(false, false); } - // Internal SVG elements do not use the standard CSS box model, and wouldn't - // be affected by size containment. By disabling it we prevent them from - // becoming query containers for size features. - if (aFrame.HasAnyStateBits(NS_FRAME_SVG_LAYOUT)) { - return ContainSizeAxes(false, false); - } - // https://drafts.csswg.org/css-contain-2/#content-visibility // If this content skips its content via content-visibility, it always has // size containment. @@ -3538,6 +3545,8 @@ StyleContentVisibility nsStyleDisplay::ContentVisibility( if (MOZ_LIKELY(mContentVisibility == StyleContentVisibility::Visible)) { return StyleContentVisibility::Visible; } + // content-visibility applies to elements for which size containment applies. + // https://drafts.csswg.org/css-contain/#content-visibility if (PrecludesSizeContainmentOrContentVisibilityWithFrame(aFrame)) { return StyleContentVisibility::Visible; } diff --git a/testing/web-platform/meta/css/css-contain/content-visibility/content-visibility-on-g.html.ini b/testing/web-platform/meta/css/css-contain/content-visibility/content-visibility-on-g.html.ini deleted file mode 100644 index 914135dab649..000000000000 --- a/testing/web-platform/meta/css/css-contain/content-visibility/content-visibility-on-g.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[content-visibility-on-g.html] - expected: FAIL