Skip to content

[SVG intrinsic sizing] height: max-content uses default width instead of the used width when only a viewBox is present#66441

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
Ahmad-S792:eng/SVG-intrinsic-sizing-height-max-content-uses-default-width-instead-of-the-used-width-when-only-a-viewBox-is-present
Jun 4, 2026
Merged

[SVG intrinsic sizing] height: max-content uses default width instead of the used width when only a viewBox is present#66441
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
Ahmad-S792:eng/SVG-intrinsic-sizing-height-max-content-uses-default-width-instead-of-the-used-width-when-only-a-viewBox-is-present

Conversation

@Ahmad-S792
Copy link
Copy Markdown
Contributor

@Ahmad-S792 Ahmad-S792 commented Jun 4, 2026

96eae58

[SVG intrinsic sizing] height: max-content uses default width instead of the used width when only a viewBox is present
https://bugs.webkit.org/show_bug.cgi?id=316299
rdar://178712792

Reviewed by Alan Baradlay.

Follow-up to 313864@main. When an SVG has only a viewBox and resolves an
intrinsic height keyword (e.g. height: max-content), we derived the height
from the 300px default width via the aspect ratio, ignoring the used width.
The upstream svg-intrinsic-size-008.html synced in 314370@main expects the
"Just viewBox" case (height:max-content in a 400x400 block) to be 400x100,
but we produced 300x75 and this is also expected [1] & [2]:

Use the estimated used width when provided, otherwise contentBoxLogicalWidth(),
mirroring RenderReplaced::computeReplacedLogicalHeight.

[1] w3c/csswg-drafts#13149 (comment)
[2] w3c/csswg-drafts#13149 (comment)

* LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/svg-intrinsic-size-008-expected.txt: Progression
* Source/WebCore/rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::computeReplacedLogicalHeight const):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGRoot.cpp:
(WebCore::LegacyRenderSVGRoot::computeReplacedLogicalHeight const):

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

8d78009

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows Apple Internal
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win ⏳ 🛠 ios-apple
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 🧪 win-tests ⏳ 🛠 mac-apple
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe ⏳ 🛠 vision-apple
✅ 🧪 ios-wk2-wpt ✅ 🧪 api-mac-debug ✅ 🛠 gtk3-libwebrtc
✅ 🧪 api-ios ✅ 🧪 mac-wk1 ✅ 🛠 gtk
✅ 🛠 ios-safer-cpp ✅ 🧪 mac-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🛠 playstation
✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
✅ 🛠 tv-sim ✅ 🧪 mac-site-isolation
✅ 🛠 watch
✅ 🛠 watch-sim

@Ahmad-S792 Ahmad-S792 self-assigned this Jun 4, 2026
@Ahmad-S792 Ahmad-S792 added the CSS Cascading Style Sheets implementation label Jun 4, 2026
@Ahmad-S792 Ahmad-S792 requested a review from alanbaradlay June 4, 2026 16:49
@Ahmad-S792 Ahmad-S792 added the merge-queue Applied to send a pull request to merge-queue label Jun 4, 2026
… of the used width when only a viewBox is present

https://bugs.webkit.org/show_bug.cgi?id=316299
rdar://178712792

Reviewed by Alan Baradlay.

Follow-up to 313864@main. When an SVG has only a viewBox and resolves an
intrinsic height keyword (e.g. height: max-content), we derived the height
from the 300px default width via the aspect ratio, ignoring the used width.
The upstream svg-intrinsic-size-008.html synced in 314370@main expects the
"Just viewBox" case (height:max-content in a 400x400 block) to be 400x100,
but we produced 300x75 and this is also expected [1] & [2]:

Use the estimated used width when provided, otherwise contentBoxLogicalWidth(),
mirroring RenderReplaced::computeReplacedLogicalHeight.

[1] w3c/csswg-drafts#13149 (comment)
[2] w3c/csswg-drafts#13149 (comment)

* LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/svg-intrinsic-size-008-expected.txt: Progression
* Source/WebCore/rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::computeReplacedLogicalHeight const):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGRoot.cpp:
(WebCore::LegacyRenderSVGRoot::computeReplacedLogicalHeight const):

Canonical link: https://commits.webkit.org/314556@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/SVG-intrinsic-sizing-height-max-content-uses-default-width-instead-of-the-used-width-when-only-a-viewBox-is-present branch from 8d78009 to 96eae58 Compare June 4, 2026 18:01
@webkit-commit-queue
Copy link
Copy Markdown
Collaborator

Committed 314556@main (96eae58): https://commits.webkit.org/314556@main

Reviewed commits have been landed. Closing PR #66441 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 96eae58 into WebKit:main Jun 4, 2026
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CSS Cascading Style Sheets implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants