Skip to content

Commit

Permalink
Replace incorrect ASSERTs in RenderBox::containingBlockLogicalWidthFo…
Browse files Browse the repository at this point in the history
…rPositioned/containingBlockLogicalHeightForPositioned

https://bugs.webkit.org/show_bug.cgi?id=268714

Reviewed by Antti Koivisto.

ASSERT(containingBlock.isInFlowPositioned()) is stale now that backdrop-filter can make an inline box form containing block for out-of-flow boxes.
Instead let's just check that the incoming RenderBoxModelObject renderer can actually be a containing block for out-of-flow descendants.

* LayoutTests/platform/ios/TestExpectations:
* LayoutTests/platform/mac/TestExpectations:
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::containingBlockLogicalWidthForPositioned const):
(WebCore::RenderBox::containingBlockLogicalHeightForPositioned const):

Canonical link: https://commits.webkit.org/274092@main
  • Loading branch information
alanbaradlay committed Feb 5, 2024
1 parent 99ca4b7 commit 8e1707f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
2 changes: 0 additions & 2 deletions LayoutTests/platform/ios/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -2394,8 +2394,6 @@ webkit.org/b/76121 imported/blink/fast/events/event-trusted.html [ Skip ]
webkit.org/b/184608 [ Debug ] animations/added-while-suspended.html [ Skip ]
webkit.org/b/184608 [ Debug ] transitions/created-while-suspended.html [ Skip ]

webkit.org/b/268580 [ Debug ] imported/w3c/web-platform-tests/html/dom/elements/global-attributes/the-anchor-attribute-003-crash.tentative.html [ Skip ]

webkit.org/b/155095 fast/table/border-collapsing/table-rtl-row-mixed-direction.html [ ImageOnlyFailure Pass ]
webkit.org/b/155095 fast/table/border-collapsing/table-ltr-rows-mixed-direction.html [ ImageOnlyFailure Pass ]

Expand Down
3 changes: 0 additions & 3 deletions LayoutTests/platform/mac/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -2579,6 +2579,3 @@ fast/gradients/conic-stop-with-offset-zero-in-middle.html [ ImageOnlyFailure ]
webkit.org/b/267352 [ Monterey ] imported/w3c/web-platform-tests/mathml/relations/css-styling/padding-border-margin/margin-003.html [ Failure ]

webkit.org/b/267612 [ Ventura+ Release x86_64 ] fast/canvas/image-buffer-backend-variants.html [ Pass Failure ]

# Asserts in debug 'global-attributes'.
webkit.org/b/267993 [ Debug ] imported/w3c/web-platform-tests/html/dom/elements/global-attributes/the-anchor-attribute-003-crash.tentative.html [ Skip ]
27 changes: 18 additions & 9 deletions Source/WebCore/rendering/RenderBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3859,6 +3859,8 @@ LayoutUnit RenderBox::constrainBlockMarginInAvailableSpaceOrTrim(const RenderBox

LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxModelObject& containingBlock, RenderFragmentContainer* fragment, bool checkForPerpendicularWritingMode) const
{
ASSERT(containingBlock.canContainAbsolutelyPositionedObjects() || containingBlock.canContainFixedPositionObjects());

if (checkForPerpendicularWritingMode && containingBlock.isHorizontalWritingMode() != isHorizontalWritingMode())
return containingBlockLogicalHeightForPositioned(containingBlock, false);

Expand Down Expand Up @@ -3900,13 +3902,17 @@ LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxMo
return (boxInfo) ? std::max<LayoutUnit>(0, cb->clientLogicalWidth() - (cb->logicalWidth() - boxInfo->logicalWidth())) : cb->clientLogicalWidth();
}

ASSERT(containingBlock.isInFlowPositioned());
if (auto* inlineBox = dynamicDowncast<RenderInline>(containingBlock))
return inlineBox->innerPaddingBoxWidth();

return downcast<RenderInline>(containingBlock).innerPaddingBoxWidth();
ASSERT_NOT_REACHED();
return { };
}

LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxModelObject& containingBlock, bool checkForPerpendicularWritingMode) const
{
ASSERT(containingBlock.canContainAbsolutelyPositionedObjects() || containingBlock.canContainFixedPositionObjects());

if (checkForPerpendicularWritingMode && containingBlock.isHorizontalWritingMode() != isHorizontalWritingMode())
return containingBlockLogicalWidthForPositioned(containingBlock, nullptr, false);

Expand All @@ -3915,16 +3921,16 @@ LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxM
return height.value();
}

if (containingBlock.isRenderBox()) {
if (auto* box = dynamicDowncast<RenderBox>(containingBlock)) {
bool isFixedPosition = isFixedPositioned();

if (isFixedPosition) {
if (auto* renderView = dynamicDowncast<RenderView>(containingBlock))
if (auto* renderView = dynamicDowncast<RenderView>(*box))
return renderView->clientLogicalHeightForFixedPosition();
}

auto* containingBlockAsRenderBlock = dynamicDowncast<RenderBlock>(containingBlock);
const RenderBlock& cb = containingBlockAsRenderBlock ? *containingBlockAsRenderBlock : *containingBlock.containingBlock();
auto* containingBlockAsRenderBlock = dynamicDowncast<RenderBlock>(*box);
const RenderBlock& cb = containingBlockAsRenderBlock ? *containingBlockAsRenderBlock : *box->containingBlock();
LayoutUnit result = cb.clientLogicalHeight();
RenderFragmentedFlow* fragmentedFlow = enclosingFragmentedFlow();
if (fragmentedFlow && fragmentedFlow->isHorizontalWritingMode() == containingBlock.isHorizontalWritingMode()) {
Expand All @@ -3933,9 +3939,12 @@ LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxM
}
return result;
}

ASSERT(containingBlock.isInFlowPositioned());
return downcast<RenderInline>(containingBlock).innerPaddingBoxHeight();

if (auto* inlineBox = dynamicDowncast<RenderInline>(containingBlock))
return inlineBox->innerPaddingBoxHeight();

ASSERT_NOT_REACHED();
return { };
}

static void computeInlineStaticDistance(Length& logicalLeft, Length& logicalRight, const RenderBox* child, const RenderBoxModelObject& containerBlock, LayoutUnit containerLogicalWidth, RenderFragmentContainer* fragment)
Expand Down

0 comments on commit 8e1707f

Please sign in to comment.