Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3aba094e4036ad70ecb933f17b5e0f03f7b7fdf3
      
https://github.com/WebKit/WebKit/commit/3aba094e4036ad70ecb933f17b5e0f03f7b7fdf3
  Author: Alan Baradlay <[email protected]>
  Date:   2026-04-15 (Wed, 15 Apr 2026)

  Changed paths:
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-aspect-ratio-border-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-aspect-ratio-border.html
    M Source/WebCore/rendering/RenderBox.cpp

  Log Message:
  -----------
  Elements with border, position: absolute and aspect-ratio: 1 are not square
https://bugs.webkit.org/show_bug.cgi?id=272527
<rdar://problem/126292577>

Reviewed by Simon Fraser.

Given:

  div {
      position: absolute;
      height: 100px;
      aspect-ratio: 1 / 1;
      border: 150px solid;
  }

The div should be a 400x400 square (100px content + 150px border on
each side). Instead it is 700x400 - the border was counted twice in the width.

For abspos elements with auto width and aspect-ratio, the width is
computed from the height via computeLogicalWidthFromAspectRatio().
This function returns a border-box value (400px).

But the caller (computeOutOfFlowPositionedLogicalWidth) expects a
content-box value. Every other code path in that function returns
content-box, and the caller adds border + padding at the end.
So the border was added once inside the aspect-ratio function and again by the 
caller: 100 + 300 + 300 = 700.

The fix converts the aspect-ratio result to content-box (by subtracting
border+padding) so the caller can add it back correctly. When
box-sizing is border-box, the result is already in the right
coordinate space for the border-box path at the call site, so no
subtraction is needed.

* 
LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-aspect-ratio-border-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-aspect-ratio-border.html:
 Added.
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::computeOutOfFlowPositionedLogicalWidthUsing const):

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



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

Reply via email to