Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 3639421f492995a9e9559c99145fbee3649c3104
https://github.com/WebKit/WebKit/commit/3639421f492995a9e9559c99145fbee3649c3104
Author: Ahmad Saleem <[email protected]>
Date: 2026-10-02 (Fri, 02 Oct 2026)
Changed paths:
A
LayoutTests/svg/custom/embed-sizing-zero-intrinsic-width-height-expected.txt
A LayoutTests/svg/custom/embed-sizing-zero-intrinsic-width-height.html
A
LayoutTests/svg/custom/object-sizing-zero-intrinsic-width-height-expected.txt
A LayoutTests/svg/custom/object-sizing-zero-intrinsic-width-height.html
M Source/WebCore/rendering/RenderEmbeddedObject.cpp
M Source/WebCore/rendering/RenderEmbeddedObject.h
Log Message:
-----------
Respect zero intrinsic size for SVG in object/embed elements
https://bugs.webkit.org/show_bug.cgi?id=276569
rdar://132152736
Reviewed by Alan Baradlay.
This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.
When an <object> or <embed> element loads an SVG with an explicit zero
dimension (e.g. width="0" or height="0"), WebKit incorrectly rendered the
element at 300x150px. Other browsers correctly collapse the affected axis
to zero.
RenderReplaced already distinguishes an explicit zero natural size from an
absent one via shouldRespectZeroIntrinsicWidth/Height() (added for images
in 299085@main and 323310), but RenderEmbeddedObject did not override them,
so an embedded SVG root with a zero dimension fell back to the 300x150
default. This patch adds those overrides:
- shouldRespectZeroIntrinsicWidth() respects an explicit zero width.
- shouldRespectZeroIntrinsicHeight() respects an explicit zero height,
except when the SVG also has a natural width and an aspect ratio to
derive the height from: the natural height of 0 is then superseded by a
height derived from the natural width and that ratio. The ratio may come
from the SVG's viewBox (e.g. width="50" height="0" viewBox="0 0 100 100"
resolves to 50x50) or from the CSS aspect-ratio property (e.g.
width="50" height="0" with aspect-ratio: 2 / 1 resolves to 50x25),
matching RenderImage and the CSSWG resolutions in
https://github.com/w3c/csswg-drafts/issues/6286#issuecomment-866986544
and https://github.com/w3c/csswg-drafts/issues/11236#issuecomment-2718502765.
Tests: svg/custom/object-sizing-zero-intrinsic-width-height.html
svg/custom/embed-sizing-zero-intrinsic-width-height.html
Merge (Test):
https://chromium.googlesource.com/chromium/src.git/+/da94afcf81b0564c60b759895245011b42662d7b
* LayoutTests/svg/custom/embed-sizing-zero-intrinsic-width-height-expected.txt:
Added.
* LayoutTests/svg/custom/embed-sizing-zero-intrinsic-width-height.html: Added.
*
LayoutTests/svg/custom/object-sizing-zero-intrinsic-width-height-expected.txt:
Added.
* LayoutTests/svg/custom/object-sizing-zero-intrinsic-width-height.html: Added.
* Source/WebCore/rendering/RenderEmbeddedObject.cpp:
(WebCore::embeddedSVGElement):
(WebCore::RenderEmbeddedObject::shouldRespectZeroIntrinsicWidth const):
(WebCore::RenderEmbeddedObject::shouldRespectZeroIntrinsicHeight const):
* Source/WebCore/rendering/RenderEmbeddedObject.h:
Canonical link: https://commits.webkit.org/322529@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications