Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<html class="reftest-wait">
<meta charset="utf-8">
<title>SVG coordinate systems: transform attribute on the outermost svg element, dynamic changes with compositing</title>
<link rel="author" title="Nikolas Zimmermann" href="mailto:nzimmermann@igalia.com">
<link rel="match" href="outer-svg-transform-attribute-dynamic-002-ref.html">
<meta name="assert" content="Changing the transform attribute of a composited outermost svg element, or of one with composited descendants, updates the rendering.">
<style>
.container { display: flex; width: 600px; height: 200px; background-color: gold; }
.composited { will-change: transform; }
</style>
<div class="container">
<svg id="changed" class="composited" width="200" height="200" viewBox="0 0 20 20" transform="rotate(45)">
<rect x="2" y="2" width="16" height="16" fill="green"/>
</svg>
<svg id="added" class="composited" width="200" height="200" viewBox="0 0 20 20">
<rect x="2" y="2" width="16" height="16" fill="green"/>
</svg>
<svg id="descendant" width="200" height="200" style="position: relative; z-index: 1">
<rect width="100" height="100" fill="blue"/>
<foreignObject width="100" height="100">
<div class="composited" style="margin-left: 50px; width: 50px; height: 50px; background-color: green"></div>
</foreignObject>
</svg>
</div>
<script>
window.addEventListener("load", () => {
requestAnimationFrame(() => requestAnimationFrame(() => {
document.getElementById("changed").setAttribute("transform", "scale(0.5) translate(-100, -50)");
document.getElementById("added").setAttribute("transform", "translate(10, 15)");
document.getElementById("descendant").setAttribute("transform", "translate(20, 30)");
document.documentElement.classList.remove("reftest-wait");
}));
});
</script>
</html>