Skip to content
Permalink
Browse files
SVG.currentScale should only set page zoom for standalone SVG
https://bugs.webkit.org/show_bug.cgi?id=245520

Reviewed by Nikolas Zimmermann.

SVG.currentScale should only set page zoom for standalone SVG.

* Source/WebCore/svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::frameForCurrentScale const):

Canonical link: https://commits.webkit.org/254787@main
  • Loading branch information
rwlbuis committed Sep 23, 2022
1 parent 0c76565 commit 0f17225c6ed32b87357f5e115829678064ebb824
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg">
<rect width="100" height="100" fill="green"/>
</svg>
@@ -0,0 +1,18 @@
<!doctype HTML>
<head>
<meta charset="utf-8">
<title>Testcase for changing currentScale on SVG embedded in HTML</title>
<link rel="help" href="https://www.w3.org/TR/SVG/struct.html#__svg__SVGSVGElement__currentScale">
<link rel="match" href="reference/green-100x100.svg"/>
<script>
function go() {
var mySVG = document.getElementById("mySVG");
mySVG.currentScale = 0.5;
}
</script>
</head>
<body onload="go()">
<svg id="mySVG">
<rect width="100" height="100" fill="green"></rect>
</svg>
</body>
@@ -109,7 +109,7 @@ RefPtr<Frame> SVGSVGElement::frameForCurrentScale() const
{
// The behavior of currentScale() is undefined when we're dealing with non-standalone SVG documents.
// If the document is embedded, the scaling is handled by the host renderer.
if (!isConnected() || !isOutermostSVGSVGElement())
if (!isConnected() || !isOutermostSVGSVGElement() || parentNode())
return nullptr;
RefPtr frame = document().frame();
return frame && frame->isMainFrame() ? frame : nullptr;

0 comments on commit 0f17225

Please sign in to comment.