SMIL animations of SVG <view> element have no effect
https://bugs.webkit.org/show_bug.cgi?id=94469
Patch by Nikolas Zimmermann <zimmermann@kde.org> on 2019-09-13
Reviewed by Said Abou-Hallawa.
Source/WebCore:
SMIL animations of the attributes associated with SVGViewElement work fine, but without any
visual effect. When loading an SVG document with a given fragment identifier
(e.g. test.svg#customView) where 'customView' references to an embedded SVGViewElement, the
viewBox/preserveAspectRatio settings should be taken from the SVGViewElement. Currently
there is no link between the SVGViewElement and the SVGSVGElement. The settings from the
SVGViewElement are only pasrsed onco in SVGSVGElement::scrollToFragment(). Dynamic updates
of the 'viewBox' and 'preserveAspectRatio' attributes of the SVGViewElement thus have no
visual effect, since the SVGSVGElement does not re-evaluates its viewBox.
Store a RefPtr to the currently used SVGViewElement in SVGSVGElement, and a WeakPtr back
to the SVGSVGElement that currently references the SVGViewElement. This allows us to
propagate SVGViewElement attribute changes to SVGSVGElement and re-evaluate the viewBox
stored in SVGSVGElement and trigger visual updates.
Tests: svg/custom/animation-on-view-element.html
svg/custom/multiple-view-elements.html
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::scrollToFragment):
* svg/SVGSVGElement.h:
* svg/SVGViewElement.cpp:
(WebCore::SVGViewElement::svgAttributeChanged): Add missing implementation, tracked by
webkit.org/b/196554. Correctly handle SVGFitToViewBox property changes. Update the viewBox
stored in the SVGSVGElement, that references the SVGViewElement. Afterwards invalidate the
renderer associated with the SVGSVGElement, which properly triggers visual updates.
* svg/SVGViewElement.h:
LayoutTests:
Add new layout tests to verify that dynamic modifications of the <view> element cause
visual updates. Previously SVGSVGElement was never notified about changes of the
SVGViewElement and thus did not update the stored viewBox.
* svg/custom/animation-on-view-element-expected.html: Added.
* svg/custom/animation-on-view-element.html: Added. This is a new reftest
demonstrating that animations of SVG <view> elements now behave as expected.
* svg/custom/multiple-view-elements-expected.html: Added.
* svg/custom/multiple-view-elements.html: Added.
* svg/dom/SVGViewSpec-multiple-views-expected.txt:
* svg/dom/SVGViewSpec-multiple-views.html: Extend to cover dynamic modifications.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@249843 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/svg/custom/multiple-view-elements-expected.html b/LayoutTests/svg/custom/multiple-view-elements-expected.html
new file mode 100644
index 0000000..2cb394a
--- /dev/null
+++ b/LayoutTests/svg/custom/multiple-view-elements-expected.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script>
+ if (window.testRunner)
+ testRunner.waitUntilDone();
+
+ function loaded() {
+ if (window.testRunner)
+ testRunner.notifyDone();
+ }
+ </script>
+</head>
+<body onload="loaded()">
+ <div style="display: inline">
+ <svg xmlns="http://www.w3.org/2000/svg" width="200" height="200">
+ <rect x="0" y="0" width="200" height="200" fill="green"/>
+ </svg>
+ </div>
+ <div style="display: inline">
+ <svg xmlns="http://www.w3.org/2000/svg" width="200" height="200">
+ <rect x="0" y="0" width="200" height="200" fill="green"/>
+ </svg>
+ </div>
+ <br/>
+ <div style="display: inline">
+ <svg xmlns="http://www.w3.org/2000/svg" width="200" height="200">
+ <rect x="0" y="0" width="200" height="200" fill="green"/>
+ </svg>
+ </div>
+ <div style="display: inline">
+ <svg xmlns="http://www.w3.org/2000/svg" width="200" height="200">
+ <rect x="0" y="0" width="200" height="200" fill="green"/>
+ </svg>
+ </div>
+</body>
+</html>