Bug 318096
| Summary: | SVGSVGElement.currentScale is a no-op on non-document-root outermost <svg> | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Karl Dubost <karlcow> |
| Component: | SVG | Assignee: | Karl Dubost <karlcow> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | sabouhallawa, webkit-bug-importer, zimmermann |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari 26 | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Karl Dubost
SVGSVGElement.currentScale only works when the <svg> is the document root.
On an inline HTML-hosted <svg>, which the SVG 2 spec defines as an outermost svg element, the setter is silently discarded and the getter returns 1.
Chrome and Firefox both return the assigned value.
WebKit is the outlier.
<svg id="s"><rect width="100" height="100" fill="green"/></svg>
<script>
const s = document.getElementById("s");
s.currentScale = 2;
console.log(s.currentScale); // Chrome: 2, Firefox: 2, Safari: 1
</script>
currentScale/currentTranslate
"only have an effect on the outermost svg element of an SVG document fragment."
An SVG document fragment
"starts with an 'svg' element which is either the root element of the document
or whose parent element is not in the SVG namespace."
So an HTML-body-child <svg> and a foreignObject→div→<svg> are outermost svg elements:
1. on setting, the assigned value must be stored,
2. and on getting it must be returned
(the spec only mandates return 1 / no-op for non-outermost svg elements).
https://w3c.github.io/svgwg/svg2-draft/struct.html#__svg__SVGSVGElement__currentScale
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/180889449>
Karl Dubost
This is because of
if (!isConnected() || !isOutermostSVGSVGElement() || document().documentElement() != this)
return nullptr;
in Source/WebCore/svg/SVGSVGElement.cpp, frameForCurrentScale()
There is another but that should be addressed separately:
Visual magnification of inline SVG: Chrome-only;
Firefox and the existing WPT reftest svg/struct/reftests/currentScale-change-repaint.html (reference unchanged 100×100) both reject it.
Need more discussions in the SVG WG.
Karl Dubost
Pull request: https://github.com/WebKit/WebKit/pull/68077
EWS
Committed 318762@main (c6bd8acdac1f): <https://commits.webkit.org/318762@main>
Reviewed commits have been landed. Closing PR #68077 and removing active labels.