Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3bf36f28537ef706402eba6e7ebfb6effd7fd58d
      
https://github.com/WebKit/WebKit/commit/3bf36f28537ef706402eba6e7ebfb6effd7fd58d
  Author: Alan Baradlay <[email protected]>
  Date:   2026-10-02 (Fri, 02 Oct 2026)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/calc-size-replaced-element-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/calc-size-replaced-element.html
    M Source/WebCore/rendering/RenderReplaced.cpp

  Log Message:
  -----------
  [css-values-5 calc-size()] Add support for an auto basis on replaced elements
https://bugs.webkit.org/show_bug.cgi?id=324772
<rdar://problem/188041259>

Reviewed by Antti Koivisto.

    <!-- a 60x20 image -->
    <img style="width: calc-size(auto, size * 2)">

`auto` on a replaced element is its intrinsic width, 60px, so the image is 
120px wide, and the aspect ratio then makes it 40px tall.

* Source/WebCore/rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::hasReplacedLogicalHeight const): An auto basis 
decides the used height, unlike the bare keyword.

(WebCore::behavesAsAutoSize): Says whether a size leaves the other axis to the 
aspect ratio, which a calc-size() does not, except
when both axes have an auto basis and each would otherwise stand for the other.

(WebCore::RenderReplaced::computeReplacedLogicalWidth const):
The CSS 2.1 10.3.2 auto path moved into a lambda, unchanged apart from its 
computedHeightIsAuto test,
so that its result can serve as `size`; the rest of the diff there is 
indentation:

    auto autoLogicalWidth = [&] {
        ...the existing auto width code...
    };

    if (style.logicalWidth().isCalcSize()) {
        ASSERT(style.logicalWidth().isAuto());
        auto calcSizeLogicalWidth = 
style.logicalWidth().get<Style::UnevaluatedCalcSize>();
        auto logicalWidth = resolveCalcSizeLogicalWidth(calcSizeLogicalWidth, 
autoLogicalWidth(), containingBlockLogicalWidthForContent());
        return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalWidth, 
isComputingIntrinsicSize);
    }

    return autoLogicalWidth();

(WebCore::RenderReplaced::computeReplacedLogicalHeight const):
(WebCore::RenderReplaced::computeReplacedLogicalHeightUsingGeneric const): An 
auto basis resolves through the intrinsic height, as the intrinsic keywords 
already do.

* 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/calc-size-replaced-element.html:
 Covers an auto basis in both axes and the height the aspect ratio transfers 
from it.

* 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/calc-size-replaced-element-expected.txt:

Canonical link: https://commits.webkit.org/322486@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to