[SVG] Use element disappears after scripted change
authorleviw@chromium.org <leviw@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Feb 2012 00:14:42 +0000 (00:14 +0000)
committerleviw@chromium.org <leviw@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Feb 2012 00:14:42 +0000 (00:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=74392

Reviewed by Eric Seidel.

Source/WebCore:

Solution uncovered by Nikolas Zimmermann. Removing an early return that caused
SVGUseElements to not update the shadow root's style, and therefor not render
correctly.

Test: svg/custom/use-disappears-after-style-update.svg

* svg/SVGUseElement.cpp:
(WebCore::SVGUseElement::didRecalcStyle):

LayoutTests:

* platform/mac-snowleopard/svg/custom/use-disappears-after-style-update-expected.png: Added.
* platform/mac-snowleopard/svg/custom/use-disappears-after-style-update-expected.txt: Added.
* svg/custom/use-disappears-after-style-update.svg: Added.

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

LayoutTests/ChangeLog
LayoutTests/platform/mac-snowleopard/svg/custom/use-disappears-after-style-update-expected.png [new file with mode: 0644]
LayoutTests/platform/mac-snowleopard/svg/custom/use-disappears-after-style-update-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/use-disappears-after-style-update.svg [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/svg/SVGUseElement.cpp

index feabf27..a5ac1df 100644 (file)
@@ -1,5 +1,16 @@
 2012-02-07  Levi Weintraub  <leviw@chromium.org>
 
+        [SVG] Use element disappears after scripted change
+        https://bugs.webkit.org/show_bug.cgi?id=74392
+
+        Reviewed by Eric Seidel.
+
+        * platform/mac-snowleopard/svg/custom/use-disappears-after-style-update-expected.png: Added.
+        * platform/mac-snowleopard/svg/custom/use-disappears-after-style-update-expected.txt: Added.
+        * svg/custom/use-disappears-after-style-update.svg: Added.
+
+2012-02-07  Levi Weintraub  <leviw@chromium.org>
+
         unicode-bidi:plaintext is supposed to be effective on display:inline elements too
         https://bugs.webkit.org/show_bug.cgi?id=73310
 
diff --git a/LayoutTests/platform/mac-snowleopard/svg/custom/use-disappears-after-style-update-expected.png b/LayoutTests/platform/mac-snowleopard/svg/custom/use-disappears-after-style-update-expected.png
new file mode 100644 (file)
index 0000000..738b2e3
Binary files /dev/null and b/LayoutTests/platform/mac-snowleopard/svg/custom/use-disappears-after-style-update-expected.png differ
diff --git a/LayoutTests/platform/mac-snowleopard/svg/custom/use-disappears-after-style-update-expected.txt b/LayoutTests/platform/mac-snowleopard/svg/custom/use-disappears-after-style-update-expected.txt
new file mode 100644 (file)
index 0000000..601f5b6
--- /dev/null
@@ -0,0 +1,17 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 300x400
+  RenderSVGRoot {svg} at (10,10) size 76x36
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+      RenderSVGResourceFilter {filter} [id="simple"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
+        [feOffset dx="0.00" dy="0.00"]
+          [SourceGraphic]
+      RenderSVGRect {rect} at (0,10) size 30x30 [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=10.00] [width=30.00] [height=30.00]
+    RenderSVGContainer {g} at (10,10) size 76x36
+      RenderSVGContainer {use} at (10,10) size 30x30
+        RenderSVGContainer {g} at (10,10) size 30x30 [transform={m=((1.00,0.00)(0.00,1.00)) t=(10.00,0.00)}]
+          RenderSVGRect {rect} at (10,10) size 30x30 [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=10.00] [width=30.00] [height=30.00]
+      RenderSVGContainer {use} at (50,10) size 36x36
+        [filter="simple"] RenderSVGResourceFilter {filter} at (50,10) size 36x36
+        RenderSVGContainer {g} at (50,10) size 30x30 [transform={m=((1.00,0.00)(0.00,1.00)) t=(50.00,0.00)}]
+          RenderSVGRect {rect} at (50,10) size 30x30 [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=10.00] [width=30.00] [height=30.00]
diff --git a/LayoutTests/svg/custom/use-disappears-after-style-update.svg b/LayoutTests/svg/custom/use-disappears-after-style-update.svg
new file mode 100644 (file)
index 0000000..b02e10c
--- /dev/null
@@ -0,0 +1,53 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
+  style="width:300px;height:400px">
+
+<!-- This tests filters failing to refresh after the initial rendering
+(https://bugs.webkit.org/show_bug.cgi?id=53088).
+There should be two green squares in the output. -->
+
+<defs>
+<filter id="simple" x="0" y="0">
+  <feOffset in="SourceGraphic" dx="0" dy="0" />
+</filter>
+
+<rect id="rect" width="30" y="10" height="30" fill="red" />
+
+</defs>
+
+<g>
+
+<use xlink:href="#rect" x="10" />
+
+<use filter="url(#simple)" xlink:href="#rect" x="50" />
+
+</g>
+
+<script><![CDATA[
+    var elements = ['rect'];
+    for (var i=0; i<elements.length; ++i) {
+      elements[i] = document.getElementById(elements[i]);
+    }
+    setTimeout(wait, 0);
+    
+    function wait() {
+      // Single timeout doesn't seem to wait for the initial painting, wait again.
+      setTimeout(change, 0);
+    }
+
+    function change() {
+      for (var i=0; i<elements.length; ++i) {
+        elements[i].setAttribute('fill', 'green');
+      }
+
+      if (window.layoutTestController) {
+          // Let it repaint and get screenshot.
+          setTimeout("layoutTestController.notifyDone()", 0);
+      }
+    }
+
+    if (window.layoutTestController) {
+        layoutTestController.waitUntilDone();
+    }
+]]></script>
+
+</svg>
index 771a248..45d53f3 100644 (file)
@@ -1,3 +1,19 @@
+2012-02-07  Levi Weintraub  <leviw@chromium.org>
+
+        [SVG] Use element disappears after scripted change
+        https://bugs.webkit.org/show_bug.cgi?id=74392
+
+        Reviewed by Eric Seidel.
+
+        Solution uncovered by Nikolas Zimmermann. Removing an early return that caused
+        SVGUseElements to not update the shadow root's style, and therefor not render
+        correctly.
+
+        Test: svg/custom/use-disappears-after-style-update.svg
+
+        * svg/SVGUseElement.cpp:
+        (WebCore::SVGUseElement::didRecalcStyle):
+
 2012-02-07  Kentaro Hara  <haraken@chromium.org>
 
         Rename [v8OnProto] IDL attribute to [V8OnProto] IDL attribute
index 60d0e3c..fd7f2d2 100644 (file)
@@ -358,17 +358,12 @@ void SVGUseElement::didRecalcStyle(StyleChange change)
     if (!shadowRoot)
         return;
     
-    bool needsStyleUpdate = !m_needsShadowTreeRecreation;
     if (m_needsShadowTreeRecreation) {
         shadowRoot->markShadowTreeForRecreation();
         m_needsShadowTreeRecreation = false;
     }
 
     shadowRoot->updateFromElement();
-
-    if (!needsStyleUpdate)
-        return;
-
     shadowRoot->updateStyle(change);
 }