Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e6ef3220723e0ec983018314278e9f2a8291ecc9
      
https://github.com/WebKit/WebKit/commit/e6ef3220723e0ec983018314278e9f2a8291ecc9
  Author: Brent Fulgham <[email protected]>
  Date:   2026-08-26 (Wed, 26 Aug 2026)

  Changed paths:
    A 
LayoutTests/fast/replaced/max-width-on-positioned-replaced-with-intrinsic-ratio-expected.txt
    A 
LayoutTests/fast/replaced/max-width-on-positioned-replaced-with-intrinsic-ratio.html
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-position/position-absolute-replaced-minmax-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-position/position-absolute-replaced-minmax.html
    M Source/WebCore/rendering/RenderReplaced.cpp

  Log Message:
  -----------
  Honor a non-keyword max-width on an out-of-flow replaced box with an 
intrinsic ratio
https://bugs.webkit.org/show_bug.cgi?id=322612
rdar://185831651

Reviewed by Alan Baradlay and Sammy Gill.

An <svg> whose only intrinsic sizing information is an aspect ratio (e.g, a 
viewBox with
no width/height attributes), absolutely positioned with left and right both 
non-auto and
width:auto, was getting stretched to the full width of its containing block, 
ignoring its
`max-width` property.

computeReplacedLogicalWidth()` has a carve-out for an out-of-flow replaced box 
with both
inline insets set, with a comment that implies that it was only intended for 
intrinsic
keywords. It calculated the width from left/right per CSS 2.1 10.3.7 and 
returns early,
skipping `computeReplacedLogicalWidthRespectingMinMaxWidth()`. But the 
condition did not
restrict its behavior, discarding all `max-width` cases. `min-width` did not 
suffer from
this issue because it is applied inside the block.

This patch corrects this issue by applying the `max-width` clamp inside the 
carve-out,
still ignoring it when it is an intrinsic keyword, so lengths and percentages 
constrain
the box while the keywords keep the behavior for which the carve-out was added.

A new WPT is included to protect this from regressing.

Tests: fast/replaced/max-width-on-positioned-replaced-with-intrinsic-ratio.html
       
imported/w3c/web-platform-tests/css/css-position/position-absolute-replaced-minmax.html

* 
LayoutTests/fast/replaced/max-width-on-positioned-replaced-with-intrinsic-ratio-expected.txt:
 Added.
* 
LayoutTests/fast/replaced/max-width-on-positioned-replaced-with-intrinsic-ratio.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-position/position-absolute-replaced-minmax-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-position/position-absolute-replaced-minmax.html:
* Source/WebCore/rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::computeReplacedLogicalWidth const):
Clamp to max-width unless it is an intrinsic keyword or none.

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



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

Reply via email to