WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
107394
[SVG2] Support SVGSVGElement's transform attribute
https://bugs.webkit.org/show_bug.cgi?id=107394
Summary
[SVG2] Support SVGSVGElement's transform attribute
Philip Rogers
Reported
2013-01-19 21:14:18 PST
wkbug.com/107393 refactors SVGSVGElement to inherit from SVGStyledTransformableElement but we need to implement the transform attribute in SVGSVGElement.cpp.
Attachments
probe-scale.html
(1.23 KB, text/html)
2026-09-08 21:02 PDT
,
Karl Dubost
no flags
Details
probe.html
(4.17 KB, text/html)
2026-09-08 21:03 PDT
,
Karl Dubost
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Simon Fraser (smfr)
Comment 1
2017-05-09 22:07:37 PDT
Needed to fix LayoutTests/svg/transforms/svgsvgelement-transform.svg
Brent Fulgham
Comment 2
2022-07-15 16:36:45 PDT
Safari and Chrome fail, Firefox works.
Radar WebKit Bug Importer
Comment 3
2022-07-15 16:36:56 PDT
<
rdar://problem/97100492
>
Ahmad Saleem
Comment 4
2024-01-27 11:32:27 PST
Test Case -
https://jsfiddle.net/teg5fh8v/
Fixed in Layer Based SVG Engine, so this is a good sign. :-)
Karl Dubost
Comment 5
2026-09-08 21:02:56 PDT
Created
attachment 481336
[details]
probe-scale.html
Karl Dubost
Comment 6
2026-09-08 21:03:28 PDT
Created
attachment 481337
[details]
probe.html
Karl Dubost
Comment 7
2026-09-08 21:21:02 PDT
Still broken in shipping Safari. The WebKit team received a new report
rdar://184540709
for
https://www.councillpsychiatric.com/
, whose icons render at full size because the `transform` on the outermost `<svg>` is dropped. Measured in three engines on the same machine, 2026-09-09, with the two attached probes. `scale(.5)` on an outermost `<svg width="400" height="100">` holding a 100x100 rect, inline in an HTML document. svg box inner rect transform="scale(.5)" Safari 27.0 400x100 100x100 Firefox 157 200x50 50x50 Chrome 155 200x50 50x50 style="transform:scale(.5)" Safari 27.0 200x50 50x50 Firefox 157 200x50 50x50 Chrome 155 200x50 50x50 no transform all three 400x100 100x100 In Safari the attribute changes nothing. The box stays 400x100 and the rect stays 100x100, which is what both measure with no transform at all. Firefox and Chrome return the same numbers as each other, and in both of them the attribute gives the same box and the same rect as the CSS property does. Matching the CSS control is the requirement. SVG 2 makes `transform` a presentation attribute on any element in the SVG namespace except `pattern`, `linearGradient` and `radialGradient`, so `svg` is included:
https://w3c.github.io/svgwg/svg2-draft/styling.html#PresentationAttributes
and a presentation attribute participates in the cascade as an ordinary author declaration, so the attribute and the style property are the same declaration arriving by two routes:
https://drafts.csswg.org/css-transforms-1/#transform-attribute-specificity
> The participation in the CSS cascade is determined by the specificity of presentation attributes in the SVG specification. According to SVG, user agents conceptually insert a new author style sheet for presentation attributes, which is the first in the author style sheet collection.
That is the same passage graouts reached for in
comment #5
of
bug 217286
, which is the other half of this bug. The working group also wrote it out, as an annotation under the `viewBox` attribute rather than as normative prose:
https://w3c.github.io/svgwg/svg2-draft/coords.html#ViewBoxAttribute
> Transform on the 'svg' element is a bit special due to the 'viewBox' attribute. The transform should be applied as if the 'svg' had a parent element with that transform set. RESOLUTION: transform property applies conceptually to the outside of the 'svg' element and there is no difference between presentation attribute and style property (in terms of the visual result).
`getComputedStyle(svg).transform` with the attribute present: Safari 27.0 none Firefox 157 matrix(0.5, 0, 0, 0.5, 0, 0) Chrome 155 matrix(0.5, 0, 0, 0.5, 0, 0) Same for an inner `<svg transform="scale(2)">`, where the other two report `matrix(2, 0, 0, 2, 0, 0)` and Safari reports `none`. The attribute never reaches computed style, so nothing downstream of style resolution can see it and each renderer has to fetch it from a side channel instead. That is the same cause as
bug 217286
, seen on `svg` rather than on `circle`. On
comment 4
. LBSE applies the attribute on an inner `<svg>`, on a standalone SVG document root, and on the content of an outermost `<svg>` in HTML. It still does not resize the outermost `<svg>`'s own box, so this cannot be closed on the LBSE work alone. Same probes, `LayerBasedSVGEngineEnabled` toggled in Safari 26.4: off on inner <svg> no yes standalone SVG document root no yes outermost <svg> in HTML, content scales no yes outermost <svg> in HTML, box scales no no With the flag on, `scale(.5)` shrinks the content to 50x50 and leaves the svg's HTML layout box at 400x100. Both other engines shrink the box. So a fix here has to move the box, not only what is drawn inside it. Where it is dropped: - Source/WebCore/rendering/svg/legacy/LegacyRenderSVGRoot.cpp:416, `localToParentTransform()` builds its matrix from `m_localToBorderBoxTransform` plus the box offset and never consults `animatedLocalTransform()`. Nothing else in that file does either. - Source/WebCore/rendering/svg/RenderSVGRoot.cpp:483, `needsHasSVGTransformFlags()` does consult it, through `SVGSVGElement::hasTransformRelatedAttributes()`. That is why the attribute has an effect with the flag on and none with it off. Coverage already exists and is already marked failing. Five imported WPT reftests at LayoutTests/TestExpectations:7866-7870, all `[ ImageOnlyFailure ]`, and none of the five carries a bug number: outer-svg-transform.svg inner-svg-transform.svg inner-svg-transform-and-viewbox.svg inner-svg-rotate-transform.svg inner-svg-css-transform.svg Four of them are `[ Pass ]` under platform/mac-tahoe-wk2-lbse-text/TestExpectations; `inner-svg-transform-and-viewbox.svg` fails under LBSE too. Separately, LayoutTests/svg/transforms/svgsvgelement-transform-expected.svg still bakes in the wrong result: it draws the red rectangle, with a comment saying it will need updating after this bug lands. None of the five covers the shape the site hit, which is an outermost `<svg transform>` inline in HTML next to a CSS control. probe-scale.html is that case. Environment: macOS, dpr 1. Safari Technology Preview 27.0 (Release 251) and Safari 26.4, Firefox Nightly 157, Chrome Canary 155.
Karl Dubost
Comment 8
2026-09-08 22:20:00 PDT
This would be partially fixed by
https://github.com/WebKit/WebKit/pull/63207
but there were concerns about performances
Bug 217286
Karl Dubost
Comment 9
2026-09-09 21:59:20 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/73645
Karl Dubost
Comment 10
2026-11-12 02:31:00 PST
Submitted web-platform-tests pull request:
https://github.com/web-platform-tests/wpt/pull/65090
EWS
Comment 11
2026-11-12 17:20:15 PST
Committed
326593@main
(687dc0272124): <
https://commits.webkit.org/326593@main
> Reviewed commits have been landed. Closing PR #73645 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug