Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 58f3b64ab9920550ef12bd9a5145645463a77201
      
https://github.com/WebKit/WebKit/commit/58f3b64ab9920550ef12bd9a5145645463a77201
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-05-25 (Mon, 25 May 2026)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-viewport/zoom/svg-computed-style-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-viewport/zoom/svg-computed-style.html
    M 
LayoutTests/imported/w3c/web-platform-tests/svg/extensibility/foreignObject/properties-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/svg/geometry/parsing/height-computed-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/svg/geometry/parsing/sizing-properties-computed-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/svg/geometry/parsing/width-computed-expected.txt
    R 
LayoutTests/platform/glib/imported/w3c/web-platform-tests/svg/geometry/parsing/height-computed-expected.txt
    R 
LayoutTests/platform/glib/imported/w3c/web-platform-tests/svg/geometry/parsing/width-computed-expected.txt
    M LayoutTests/svg/css/parse-calc-length-expected.txt
    M LayoutTests/svg/css/parse-calc-length.html
    M LayoutTests/svg/css/parse-height-expected.txt
    M LayoutTests/svg/css/parse-height.html
    M LayoutTests/svg/css/parse-length-expected.txt
    M LayoutTests/svg/css/parse-length.html
    M Source/WebCore/rendering/RenderObject.h
    M Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp
    M Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp
    M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGForeignObject.cpp
    M Source/WebCore/style/StyleContainmentCheckerInlines.h
    M Source/WebCore/style/StyleExtractor.cpp
    M Source/WebCore/style/StyleExtractorCustom.h

  Log Message:
  -----------
  Resolved value for 'width' and 'height' on SVG geometry elements should be 
the used value
https://bugs.webkit.org/show_bug.cgi?id=192665
rdar://96320059

Reviewed by Sam Weinig.

Per CSSOM [1], getComputedStyle() should return the used value (resolved pixels)
for width/height when the property applies to the element and display is not
none/contents. Previously, SVG elements like <rect>, <image>, and
<foreignObject> returned the computed value instead.

For SVG geometry elements that are not RenderBox subclasses (rect, image),
resolve the CSS value directly via SVGLengthContext rather than reading from
the renderer's bounding box, which can be empty when only one dimension is
set. SVGLengthContext's non-numeric fallback returns 0, which matches the
SVG2 sizing spec for rect/image/foreignObject where 'auto' resolves to 0.
The resulting value is wrapped in Length<>, whose ToCSS conversion divides
by usedZoom on serialization; the resolved value is therefore pre-multiplied
by usedZoom so the round-trip yields the original CSS pixel value.

Also fix isLayoutDependent() to force layout for SVG geometry elements
before extracting used values, and ensure foreignObject is excluded from
size containment per the CSS Conditional spec.

Note: inner <svg> (SVGViewportContainer) is intentionally excluded from the
used-value resolution path because its resolved value should remain the
computed value (auto, percentages), and because <use> element width/height
overrides modify SVG animated properties rather than CSS style.

[1] https://drafts.csswg.org/cssom/#resolved-values

* Source/WebCore/rendering/RenderObject.h:
Added isRenderSVGRect() and isRenderOrLegacyRenderSVGRect() helpers.
* Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp:
(WebCore::RenderSVGForeignObject::layout):
Use CSS computed style for dimensions instead of SVG animated properties.
* Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp:
Drop unused include.
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGForeignObject.cpp:
(WebCore::LegacyRenderSVGForeignObject::layout):
Use CSS computed style for dimensions instead of SVG animated properties.
* Source/WebCore/style/StyleContainmentCheckerInlines.h:
(WebCore::Style::ContainmentChecker::shouldApplySizeContainment const):
(WebCore::Style::ContainmentChecker::shouldApplyInlineSizeContainment const):
Exclude foreignObject from size/inline-size containment per spec.
* Source/WebCore/style/StyleExtractor.cpp:
(WebCore::Style::isLayoutDependent):
Force layout for SVG geometry elements before extracting used values.
* Source/WebCore/style/StyleExtractorCustom.h:
Resolve SVG geometry element width/height directly via SVGLengthContext
instead of using bounding boxes; pre-multiply by usedZoom to compensate
for Length<>'s ToCSS divide-by-zoom on serialization.

> Progressions:
* 
LayoutTests/imported/w3c/web-platform-tests/svg/extensibility/foreignObject/properties-expected.txt
* 
LayoutTests/imported/w3c/web-platform-tests/svg/geometry/parsing/height-computed-expected.txt
* 
LayoutTests/imported/w3c/web-platform-tests/svg/geometry/parsing/sizing-properties-computed-expected.txt
* 
LayoutTests/imported/w3c/web-platform-tests/svg/geometry/parsing/width-computed-expected.txt:

> Test updates (legacy SVG tests adjusted for spec-correct used-value 
> reporting):
* LayoutTests/svg/css/parse-calc-length-expected.txt:
* LayoutTests/svg/css/parse-calc-length.html:
* LayoutTests/svg/css/parse-height-expected.txt:
* LayoutTests/svg/css/parse-height.html:
* LayoutTests/svg/css/parse-length-expected.txt:
* LayoutTests/svg/css/parse-length.html:

> Removed platform-specific expectations (now match cross-platform results):
* 
LayoutTests/platform/glib/imported/w3c/web-platform-tests/svg/geometry/parsing/height-computed-expected.txt:
 Removed.
* 
LayoutTests/platform/glib/imported/w3c/web-platform-tests/svg/geometry/parsing/width-computed-expected.txt:
 Removed.

> Drive-by test fix (already fixed on WPT Upstream) leading to progression (not 
> related to patch):
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-viewport/zoom/svg-computed-style-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-viewport/zoom/svg-computed-style.html:

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



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

Reply via email to