Skip to content
Browse files
SVG.currentScale should only set page zoom for standalone SVG

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:
  • 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="">
<rect width="100" height="100" fill="green"/>
@@ -0,0 +1,18 @@
<!doctype HTML>
<meta charset="utf-8">
<title>Testcase for changing currentScale on SVG embedded in HTML</title>
<link rel="help" href="">
<link rel="match" href="reference/green-100x100.svg"/>
function go() {
var mySVG = document.getElementById("mySVG");
mySVG.currentScale = 0.5;
<body onload="go()">
<svg id="mySVG">
<rect width="100" height="100" fill="green"></rect>
@@ -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.