REGRESSION(r234620): SVGLangSpace::svgAttributeChanged() should invalidate the render...
authorsaid@apple.com <said@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Oct 2018 23:59:52 +0000 (23:59 +0000)
committersaid@apple.com <said@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Oct 2018 23:59:52 +0000 (23:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190411

Reviewed by Simon Fraser.

Source/WebCore:

Test: svg/dynamic-updates/SVGStopElement-dom-xml-lang-attrr.html

When changing the attributes of the SVGLangSpace, we should invalidate
the renderer of the SVGGeometryElement descendant only. Renderer of other
elements, like SVGStopElement, should not be invalidated because they do
not have geometry and they can be used as resources for drawing another
SVGGeometryElement.

* svg/SVGElement.h:
(WebCore::SVGElement::isSVGGeometryElement const):
* svg/SVGGeometryElement.h:
(isType):
* svg/SVGLangSpace.cpp:
(WebCore::SVGLangSpace::svgAttributeChanged):

LayoutTests:

* svg/dynamic-updates/SVGStopElement-dom-xml-lang-attrr-expected.txt: Added.
* svg/dynamic-updates/SVGStopElement-dom-xml-lang-attrr.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/svg/dynamic-updates/SVGStopElement-dom-xml-lang-attrr-expected.txt [new file with mode: 0644]
LayoutTests/svg/dynamic-updates/SVGStopElement-dom-xml-lang-attrr.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/svg/SVGElement.h
Source/WebCore/svg/SVGGeometryElement.h
Source/WebCore/svg/SVGLangSpace.cpp

index 103368c..d7397f1 100644 (file)
@@ -1,3 +1,13 @@
+2018-10-09  Said Abou-Hallawa  <sabouhallawa@apple.com>
+
+        REGRESSION(r234620): SVGLangSpace::svgAttributeChanged() should invalidate the renderer of the SVGGeometryElement descendant only
+        https://bugs.webkit.org/show_bug.cgi?id=190411
+
+        Reviewed by Simon Fraser.
+
+        * svg/dynamic-updates/SVGStopElement-dom-xml-lang-attrr-expected.txt: Added.
+        * svg/dynamic-updates/SVGStopElement-dom-xml-lang-attrr.html: Added.
+
 2018-10-09  Chris Dumez  <cdumez@apple.com>
 
         Anchor target should be ignored on activation when the download attribute is set
diff --git a/LayoutTests/svg/dynamic-updates/SVGStopElement-dom-xml-lang-attrr-expected.txt b/LayoutTests/svg/dynamic-updates/SVGStopElement-dom-xml-lang-attrr-expected.txt
new file mode 100644 (file)
index 0000000..7cc52a0
--- /dev/null
@@ -0,0 +1,3 @@
+Passes if no crash happens.
+
+
diff --git a/LayoutTests/svg/dynamic-updates/SVGStopElement-dom-xml-lang-attrr.html b/LayoutTests/svg/dynamic-updates/SVGStopElement-dom-xml-lang-attrr.html
new file mode 100644 (file)
index 0000000..62d4d31
--- /dev/null
@@ -0,0 +1,21 @@
+<body>
+    <p>Passes if no crash happens.</p>
+    <svg>
+        <linearGradient id="gradient">
+            <stop id="stop1" offset="0%" stop-color="green" />
+            <stop id="stop2" offset="50%" stop-color="green" />
+        </linearGradient>
+        <rect fill="url(#gradient)" x="10" y="10" width="200" height="100"/>
+    </svg>
+    <script>
+        if (window.testRunner) {
+            testRunner.dumpAsText();
+            testRunner.waitUntilDone();
+        }
+        setTimeout(function(){ 
+            stop1.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:lang", "jw");
+            if (window.testRunner)
+                testRunner.notifyDone();
+        }, 0);
+    </script>
+</body>
index e7667d5..633fb50 100644 (file)
@@ -1,3 +1,25 @@
+2018-10-09  Said Abou-Hallawa  <sabouhallawa@apple.com>
+
+        REGRESSION(r234620): SVGLangSpace::svgAttributeChanged() should invalidate the renderer of the SVGGeometryElement descendant only
+        https://bugs.webkit.org/show_bug.cgi?id=190411
+
+        Reviewed by Simon Fraser.
+
+        Test: svg/dynamic-updates/SVGStopElement-dom-xml-lang-attrr.html
+
+        When changing the attributes of the SVGLangSpace, we should invalidate
+        the renderer of the SVGGeometryElement descendant only. Renderer of other
+        elements, like SVGStopElement, should not be invalidated because they do
+        not have geometry and they can be used as resources for drawing another
+        SVGGeometryElement.
+
+        * svg/SVGElement.h:
+        (WebCore::SVGElement::isSVGGeometryElement const):
+        * svg/SVGGeometryElement.h:
+        (isType):
+        * svg/SVGLangSpace.cpp:
+        (WebCore::SVGLangSpace::svgAttributeChanged):
+
 2018-10-09  Chris Dumez  <cdumez@apple.com>
 
         Anchor target should be ignored on activation when the download attribute is set
index cf60b8d..34bd9e0 100644 (file)
@@ -65,6 +65,7 @@ public:
     virtual AffineTransform localCoordinateSpaceTransform(SVGLocatable::CTMScope) const;
 
     virtual bool isSVGGraphicsElement() const { return false; }
+    virtual bool isSVGGeometryElement() const { return false; }
     virtual bool isFilterEffect() const { return false; }
     virtual bool isGradientStop() const { return false; }
     virtual bool isTextContent() const { return false; }
index 8ad251e..824fefc 100644 (file)
@@ -54,6 +54,7 @@ protected:
     void svgAttributeChanged(const QualifiedName&) override;
 
 private:
+    bool isSVGGeometryElement() const override { return true; }
     const SVGAttributeOwnerProxy& attributeOwnerProxy() const override { return m_attributeOwnerProxy; }
 
     static void registerAttributes();
@@ -64,3 +65,8 @@ private:
 };
 
 } // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::SVGGeometryElement)
+    static bool isType(const WebCore::SVGElement& element) { return element.isSVGGeometryElement(); }
+    static bool isType(const WebCore::Node& node) { return is<WebCore::SVGElement>(node) && isType(downcast<WebCore::SVGElement>(node)); }
+SPECIALIZE_TYPE_TRAITS_END()
index 258a1af..8b9d80d 100644 (file)
@@ -24,7 +24,7 @@
 
 #include "RenderSVGResource.h"
 #include "RenderSVGShape.h"
-#include "SVGElement.h"
+#include "SVGGeometryElement.h"
 #include "XMLNames.h"
 #include <wtf/NeverDestroyed.h>
 
@@ -67,10 +67,13 @@ void SVGLangSpace::svgAttributeChanged(const QualifiedName& attrName)
     if (!isKnownAttribute(attrName))
         return;
 
-    if (auto* renderer = downcast<RenderSVGShape>(m_contextElement.renderer())) {
-        SVGElement::InstanceInvalidationGuard guard(m_contextElement);
-        RenderSVGResource::markForLayoutAndParentResourceInvalidation(*renderer);
-    }
+    auto* renderer = m_contextElement.renderer();
+    if (!is<RenderSVGShape>(renderer))
+        return;
+
+    ASSERT(is<SVGGeometryElement>(m_contextElement));
+    SVGElement::InstanceInvalidationGuard guard(m_contextElement);
+    RenderSVGResource::markForLayoutAndParentResourceInvalidation(*renderer);
 }
 
 }