SIGN IN SIGN UP

A block-level aspect-ratio box inside a float grows when its content changes

https://bugs.webkit.org/show_bug.cgi?id=325890
<rdar://problem/188872195>

Reviewed by Antti Koivisto.

  <div style="float: left">
    <div style="aspect-ratio: 1">
      <div style="height: 100%; aspect-ratio: 2">
        <div style="width: 20px; height: 5px"></div>
      </div>
    </div>
  </div>

The aspect-ratio box should stay 20px wide when its content changes. Instead it doubled on every change.

availableLogicalHeightForPercentageComputation() derives the box's height from logicalWidth(), which still holds the previous layout's width while the box measures its own intrinsic widths.
It uses dirty bits to signal intrinsic width computation, and only for grid and shrink-to-fit boxes, so the float's measurement of this block-level box feeds the old width back in.

Let's mark the box while it measures its own intrinsic widths instead, with IntrinsicLogicalWidthComputationScope (the inline-axis counterpart of IntrinsicLogicalHeightComputationScope), and bail out only inside that scope.

* LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-shrink-to-fit-ancestor-relayout-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-shrink-to-fit-ancestor-relayout-ref.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-shrink-to-fit-ancestor-relayout.html: Added.
* Source/WebCore/layout/integration/LayoutIntegrationFormattingContextLayout.cpp:
(WebCore::LayoutIntegration::formattingContextRootLogicalWidthForType):
* Source/WebCore/page/LocalFrameViewLayoutContext.cpp:
(WebCore::LocalFrameViewLayoutContext::addIntrinsicLogicalWidthComputationFor):
(WebCore::LocalFrameViewLayoutContext::removeIntrinsicLogicalWidthComputationFor):
(WebCore::LocalFrameViewLayoutContext::isComputingIntrinsicLogicalWidthFor const):
* Source/WebCore/page/LocalFrameViewLayoutContext.h:
* Source/WebCore/rendering/GridLanesLayout.cpp:
(WebCore::GridLanesLayout::calculateGridLanesIntrinsicLogicalWidth):
* Source/WebCore/rendering/RenderBlock.cpp:
(WebCore::RenderBlock::availableLogicalHeightForPercentageComputation const):
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::minContentLogicalWidthContribution const):
(WebCore::RenderBox::maxContentLogicalWidthContribution const):
(WebCore::RenderBox::computeLogicalWidthUsingGeneric const):
(WebCore::RenderBox::computeOutOfFlowPositionedLogicalWidthUsing const):
* Source/WebCore/rendering/RenderLayoutState.cpp:
(WebCore::IntrinsicLogicalWidthComputationScope::IntrinsicLogicalWidthComputationScope):
(WebCore::IntrinsicLogicalWidthComputationScope::~IntrinsicLogicalWidthComputationScope):
* Source/WebCore/rendering/RenderLayoutState.h:

Canonical link: https://commits.webkit.org/322742@main
A
Alan Baradlay committed
1ba683f0efad28b70cf6ff2d71e8dcf84cc069ea
Parent: 1d5a248