Skip to content
Permalink
Browse files
Do not assume that an absolute positioned block box's height is alway…
…s resolvable

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

Reviewed by Simon Fraser.

1. While the ICB (RenderView) always has fixed height/width, the RenderStyle values are set to auto.
2. It's incorrect to assume that we can always resolve the height for an absolute positioned box (e.g. it may have a "height: auto" relative positioned containing block)

* LayoutTests/fast/block/fill-available-with-absolute-position-expected.html: Added.
* LayoutTests/fast/block/fill-available-with-absolute-position.html: Added.
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::computeIntrinsicLogicalContentHeightUsing const):
(WebCore::RenderBox::computePositionedLogicalHeightUsing const):

Canonical link: https://commits.webkit.org/251215@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295124 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alanbujtas committed Jun 2, 2022
1 parent 6852fe3 commit 7dbea27e7b965b3ac7b38776777dda974314971f
Showing 3 changed files with 27 additions and 1 deletion.
@@ -0,0 +1,9 @@
<style>
div {
width: 10px;
height: 100%;
background-color: green;
position: absolute;
}
</style>
<div></div>
@@ -0,0 +1,15 @@
<style>
.fill {
width: 10px;
background-color: green;
height: -webkit-fill-available;
position: absolute;
}
.relative-containing-block {
position: relative;
}
</style>
<div class=fill></div>
<div class=relative-containing-block>
<div class=fill style="background-color: red"></div>
</div>
@@ -3281,6 +3281,8 @@ std::optional<LayoutUnit> RenderBox::computeIntrinsicLogicalContentHeightUsing(L
// Until then, this is mostly just guesswork.
if (!containingBlock)
return false;
if (is<RenderView>(containingBlock))
return true;
auto containingBlockHasSpecifiedSpace = [&] {
auto isOrthogonal = WebCore::isOrthogonal(*this, *containingBlock);
auto& style = containingBlock->style();
@@ -4478,7 +4480,7 @@ void RenderBox::computePositionedLogicalHeightUsing(SizeType heightType, Length
logicalHeightIsAuto = false;
} else {
if (logicalHeightLength.isIntrinsic())
resolvedLogicalHeight = adjustContentBoxLogicalHeightForBoxSizing(computeIntrinsicLogicalContentHeightUsing(logicalHeightLength, contentLogicalHeight, bordersPlusPadding).value());
resolvedLogicalHeight = adjustContentBoxLogicalHeightForBoxSizing(computeIntrinsicLogicalContentHeightUsing(logicalHeightLength, contentLogicalHeight, bordersPlusPadding).value_or(0_lu));
else if (fromAspectRatio) {
resolvedLogicalHeight = blockSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), style().logicalAspectRatio(), style().boxSizingForAspectRatio(), logicalWidth());
resolvedLogicalHeight = std::max(LayoutUnit(), resolvedLogicalHeight - bordersPlusPadding);

0 comments on commit 7dbea27

Please sign in to comment.