Skip to content

Truly independent web browser

Tests/LibWeb: Test filter animations inside an SVG on the compositor

Andreas Klingcf5144039615
diff --git a/Tests/LibWeb/Ref/expected/compositor-svg-internal-transform-ref.html b/Tests/LibWeb/Ref/expected/compositor-svg-internal-transform-ref.html
index cc081d9a9e7..599d0476065 100644
--- a/Tests/LibWeb/Ref/expected/compositor-svg-internal-transform-ref.html
+++ b/Tests/LibWeb/Ref/expected/compositor-svg-internal-transform-ref.html
@@ -19,3 +19,8 @@
<rect opacity="0.5" x="10" y="12" width="2" height="2"></rect>
<g opacity="0.5"><rect x="13" y="12" width="2" height="2"></rect><rect x="14" y="13" width="2" height="2"></rect></g>
</svg>
+<svg viewBox="0 0 24 24">
+ <rect style="filter: brightness(0.5)" x="2" y="2" width="4" height="4"></rect>
+ <g style="filter: brightness(0.5)"><rect x="8" y="2" width="4" height="4"></rect></g>
+ <rect style="filter: drop-shadow(4px 4px 0 red)" x="14" y="2" width="4" height="4"></rect>
+</svg>
diff --git a/Tests/LibWeb/Ref/input/compositor-svg-internal-transform.html b/Tests/LibWeb/Ref/input/compositor-svg-internal-transform.html
index 9d0378730ca..58abfc5c489 100644
--- a/Tests/LibWeb/Ref/input/compositor-svg-internal-transform.html
+++ b/Tests/LibWeb/Ref/input/compositor-svg-internal-transform.html
@@ -11,6 +11,8 @@
@keyframes turn { from, to { transform: rotate(90deg); } }
@keyframes grow { from, to { transform: scale(2); } }
@keyframes half { from, to { opacity: 0.5; } }
+ @keyframes dim { from, to { filter: brightness(0.5); } }
+ @keyframes shadow { from, to { filter: drop-shadow(4px 4px 0 red); } }
</style>
<svg viewBox="0 0 24 24">
<rect class="box" style="animation: squash 1s linear infinite" x="2" y="2" width="4" height="4"></rect>
@@ -30,6 +32,11 @@
<rect style="animation: half 1s linear infinite" x="10" y="12" width="2" height="2"></rect>
<g style="animation: half 1s linear infinite"><rect x="13" y="12" width="2" height="2"></rect><rect x="14" y="13" width="2" height="2"></rect></g>
</svg>
+<svg viewBox="0 0 24 24">
+ <rect style="animation: dim 1s linear infinite" x="2" y="2" width="4" height="4"></rect>
+ <g style="animation: dim 1s linear infinite"><rect x="8" y="2" width="4" height="4"></rect></g>
+ <rect style="animation: shadow 1s linear infinite" x="14" y="2" width="4" height="4"></rect>
+</svg>
<script>
// These animations stay on one value, so whichever side samples them draws what a box at that value draws. The
// reference spells out where each box ends up without a transform, under the same scale from the viewBox.
diff --git a/Tests/LibWeb/Text/expected/css/compositor-svg-internal-transform.txt b/Tests/LibWeb/Text/expected/css/compositor-svg-internal-transform.txt
index ff9d647471c..cb6ded45c2c 100644
--- a/Tests/LibWeb/Text/expected/css/compositor-svg-internal-transform.txt
+++ b/Tests/LibWeb/Text/expected/css/compositor-svg-internal-transform.txt
@@ -14,6 +14,10 @@ runs on the compositor:
a fading group: true
a fading use element: true
a fading rect in a group with a filter element: true
+ a dimming rect: false
+ a dimming group: false
+ a dimming use element: false
+ a dimming rect in a group with a filter element: false
runs on the compositor, though it must not:
a rect in a group with a filter element: false
a rect in a group with a clip path in its bounding box: false
@@ -27,6 +31,8 @@ runs on the compositor, though it must not:
a group around a non-scaling stroke: false
a rect in a mask: false
a fading rect in a mask: false
+ a dimming rect in a mask: false
+ a rect animating a filter element: false
the main thread leaves the animated style alone: true
the main thread asks for no frames: true
the main thread runs no rendering updates: true
diff --git a/Tests/LibWeb/Text/input/css/compositor-svg-internal-transform.html b/Tests/LibWeb/Text/input/css/compositor-svg-internal-transform.html
index c2ef55487f7..8f758be28e0 100644
--- a/Tests/LibWeb/Text/input/css/compositor-svg-internal-transform.html
+++ b/Tests/LibWeb/Text/input/css/compositor-svg-internal-transform.html
@@ -3,8 +3,12 @@
<style>
@keyframes pulse { from { transform: scaleY(0.5); } to { transform: scaleY(1); } }
@keyframes fade { from { opacity: 0.5; } to { opacity: 1; } }
+ @keyframes dim { from { filter: brightness(0.5); } to { filter: brightness(1); } }
+ @keyframes dim-through-a-filter-element { from { filter: url(#f); } to { filter: url(#f); } }
.bar { animation: pulse 1s infinite; }
.fading { animation: fade 1s infinite; }
+ .dimming { animation: dim 1s infinite; }
+ .dimming-through-a-filter-element { animation: dim-through-a-filter-element 1s infinite; }
#cases { width: 100px; height: 100px; }
</style>
<svg id="cases" viewBox="0 0 24 24"></svg>
@@ -19,6 +23,7 @@
const rect = `<rect class="bar" width="5" height="5"/>`;
const fadingRect = `<rect class="fading" width="5" height="5"/>`;
+ const dimmingRect = `<rect class="dimming" width="5" height="5"/>`;
const urlFilter = `<filter id="f"><feOffset dx="1"/></filter>`;
const onTheCompositor = {
"a rect": rect,
@@ -36,10 +41,15 @@
"a fading group": `<g class="fading"><rect width="5" height="5"/></g>`,
"a fading use element": `<defs><rect id="u" width="5" height="5"/></defs><use class="fading" href="#u" x="1"/>`,
"a fading rect in a group with a filter element": `${urlFilter}<g filter="url(#f)">${fadingRect}</g>`,
+ "a dimming rect": dimmingRect,
+ "a dimming group": `<g class="dimming"><rect width="5" height="5"/></g>`,
+ "a dimming use element": `<defs><rect id="u" width="5" height="5"/></defs><use class="dimming" href="#u" x="1"/>`,
+ "a dimming rect in a group with a filter element": `${urlFilter}<g filter="url(#f)">${dimmingRect}</g>`,
};
// The compositor knows no bounding boxes. That of a group includes the transforms of the boxes inside it, so what
- // reads that box needs the main thread to keep those transforms current. Opacity leaves bounding boxes alone. The
- // content of a resource is painted by the main thread each time it is used, so has no nodes for the compositor.
+ // reads that box needs the main thread to keep those transforms current. Opacity and filter functions leave bounding
+ // boxes alone. The content of a resource is painted by the main thread each time it is used, so has no nodes for the
+ // compositor, and the compositor has no filter elements.
const onTheMainThread = {
"a rect in a group with a filter element": `${urlFilter}<g filter="url(#f)">${rect}</g>`,
"a rect in a group with a clip path in its bounding box": `<clipPath id="c" clipPathUnits="objectBoundingBox"><rect width="1" height="1"/></clipPath><g clip-path="url(#c)">${rect}</g>`,
@@ -53,6 +63,8 @@
"a group around a non-scaling stroke": `<g class="bar"><rect width="5" height="5" stroke="red" vector-effect="non-scaling-stroke"/></g>`,
"a rect in a mask": `<mask id="n">${rect}</mask><rect mask="url(#n)" width="9" height="9"/>`,
"a fading rect in a mask": `<mask id="n">${fadingRect}</mask><rect mask="url(#n)" width="9" height="9"/>`,
+ "a dimming rect in a mask": `<mask id="n">${dimmingRect}</mask><rect mask="url(#n)" width="9" height="9"/>`,
+ "a rect animating a filter element": `${urlFilter}<rect class="dimming-through-a-filter-element" width="5" height="5"/>`,
};
asyncTest(async done => {