Dynamic changes in the style attributes of an SVGElement do no affect the <use> instances
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Jan 2019 00:13:41 +0000 (00:13 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Jan 2019 00:13:41 +0000 (00:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193647

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2019-01-22
Reviewed by Simon Fraser.

Source/WebCore:

Changing a style attribute of an SVGELement needs to call invalidateInstances().

Tests: svg/custom/svg-use-style-dynamic-change-invalidate.svg

* svg/SVGElement.cpp:
(WebCore::SVGElement::attributeChanged):

LayoutTests:

* svg/custom/svg-use-style-dynamic-change-invalidate-expected.svg: Added.
* svg/custom/svg-use-style-dynamic-change-invalidate.svg: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240305 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/svg/custom/svg-use-style-dynamic-change-invalidate-expected.svg [new file with mode: 0644]
LayoutTests/svg/custom/svg-use-style-dynamic-change-invalidate.svg [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/svg/SVGElement.cpp

index c90ff25..1910b09 100644 (file)
@@ -1,3 +1,13 @@
+2019-01-22  Said Abou-Hallawa  <sabouhallawa@apple.com>
+
+        Dynamic changes in the style attributes of an SVGElement do no affect the <use> instances
+        https://bugs.webkit.org/show_bug.cgi?id=193647
+
+        Reviewed by Simon Fraser.
+
+        * svg/custom/svg-use-style-dynamic-change-invalidate-expected.svg: Added.
+        * svg/custom/svg-use-style-dynamic-change-invalidate.svg: Added.
+
 2019-01-22  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         Unreviewed, skip all resource load statistics tests on GTK
diff --git a/LayoutTests/svg/custom/svg-use-style-dynamic-change-invalidate-expected.svg b/LayoutTests/svg/custom/svg-use-style-dynamic-change-invalidate-expected.svg
new file mode 100644 (file)
index 0000000..8088c39
--- /dev/null
@@ -0,0 +1,6 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+       <rect width="100" height="100" fill="green"/>
+       <rect x="110" width="100" height="100" fill="green"/>
+       <rect x="220" width="100" height="100" fill="green"/>
+       <rect x="330" width="100" height="100" fill="green"/>
+</svg>
diff --git a/LayoutTests/svg/custom/svg-use-style-dynamic-change-invalidate.svg b/LayoutTests/svg/custom/svg-use-style-dynamic-change-invalidate.svg
new file mode 100644 (file)
index 0000000..473730d
--- /dev/null
@@ -0,0 +1,25 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+    <symbol id="symbol">
+        <rect id="symbol-rect" width="100%" height="100%" fill="red"/>
+    </symbol>
+    <defs>
+        <rect id="defs-rect" width="100" height="100" fill="red"/>
+    </defs>
+    <rect id="rect" width="100" height="100" fill="red"/>
+    <use x="110" width="100" height="100" xlink:href="#symbol"/>
+    <use x="220" width="100" height="100" xlink:href="#defs-rect"/>
+    <use x="330" width="100" height="100" xlink:href="#rect"/>
+    <script>
+        if (window.testRunner)
+            testRunner.waitUntilDone();
+
+        setTimeout(function(){
+            document.getElementById("symbol-rect").setAttribute("style", "fill: green");
+            document.getElementById("defs-rect").setAttribute("style", "fill: green");
+            document.getElementById("rect").setAttribute("style", "fill: green");
+
+            if (window.testRunner)
+                testRunner.notifyDone();
+      }, 0);
+    </script>
+</svg>
index d9ef453..9aa9f3b 100644 (file)
@@ -1,3 +1,17 @@
+2019-01-22  Said Abou-Hallawa  <sabouhallawa@apple.com>
+
+        Dynamic changes in the style attributes of an SVGElement do no affect the <use> instances
+        https://bugs.webkit.org/show_bug.cgi?id=193647
+
+        Reviewed by Simon Fraser.
+
+        Changing a style attribute of an SVGELement needs to call invalidateInstances().
+
+        Tests: svg/custom/svg-use-style-dynamic-change-invalidate.svg
+
+        * svg/SVGElement.cpp:
+        (WebCore::SVGElement::attributeChanged):
+
 2019-01-22  Alex Christensen  <achristensen@webkit.org>
 
         Fix more builds.
index 12ee77c..fdcc8fb 100644 (file)
@@ -686,8 +686,10 @@ void SVGElement::attributeChanged(const QualifiedName& name, const AtomicString&
         document().accessSVGExtensions().rebuildAllElementReferencesForTarget(*this);
 
     // Changes to the style attribute are processed lazily (see Element::getAttribute() and related methods),
-    // so we don't want changes to the style attribute to result in extra work here.
-    if (name != HTMLNames::styleAttr)
+    // so we don't want changes to the style attribute to result in extra work here except invalidateInstances().
+    if (name == HTMLNames::styleAttr)
+        invalidateInstances();
+    else
         svgAttributeChanged(name);
 }