Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: afe06d98359dd88adf413d5b6be54dfd33c8196e
https://github.com/WebKit/WebKit/commit/afe06d98359dd88adf413d5b6be54dfd33c8196e
Author: Ahmad Saleem <[email protected]>
Date: 2026-06-15 (Mon, 15 Jun 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/cssom-getBoundingClientRect-003-expected.txt
R
LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/cssom-view/cssom-getBoundingClientRect-003-expected.txt
M Source/WebCore/dom/Element.cpp
Log Message:
-----------
Element.getBoundingClientRect() on SVG <tspan> returns the whole <text>
bounds instead of the tspan's own area
https://bugs.webkit.org/show_bug.cgi?id=317088
rdar://179626476
Reviewed by Simon Fraser.
This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.
Per the SVG 2 spec [1], "The 'tspan', 'textPath', and 'a' elements that are
descended from text content elements act as inline elements", so their CSSOM
box geometry should be each element's own rendered area. The same section
states that "the object bounding box units are computed relative to the entire
'text' element in all cases, even when different effects are applied to
different 'tspan' or 'textPath' elements within the same 'text' element" -- that
whole-<text> box is correct for objectBoundingBox-unit effects (gradient/
pattern/clip/mask/filter), but not for CSSOM.
Element::getBoundingClientRect() conflated the two: it routes every element with
an SVG layout box through SVGElement::getBoundingBox() ->
RenderSVGInline::objectBoundingBox(), which returns the <text> ancestor's box.
So `<text>X<tspan>XX</tspan></text>` reported the tspan at the text origin
instead of past the preceding "X". Range.getBoundingClientRect() was already
correct via RenderSVGInline::absoluteQuads().
Exclude SVG inline elements from elementWithSVGLayoutBox() so they fall through
to the box-model path (absoluteQuads()), matching Range.
[1] https://w3c.github.io/svgwg/svg2-draft/text.html#TextElement
*
LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/cssom-getBoundingClientRect-003-expected.txt:
Progression
*
LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/cssom-view/cssom-getBoundingClientRect-003-expected.txt:
Removed.
* Source/WebCore/dom/Element.cpp:
(WebCore::elementWithSVGLayoutBox):
Canonical link: https://commits.webkit.org/315234@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications