2011-07-28 Rob Buis <rbuis@rim.com>
authorrwlbuis@webkit.org <rwlbuis@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Jul 2011 14:24:32 +0000 (14:24 +0000)
committerrwlbuis@webkit.org <rwlbuis@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Jul 2011 14:24:32 +0000 (14:24 +0000)
        Use styling test from ietestcenter fails
        https://bugs.webkit.org/show_bug.cgi?id=62147

        Reviewed by Nikolas Zimmermann.

        Make sure CSS selectors are applied to the DOM tree referenced by <use>, not the internal shadow tree. In order to quickly
        find the corresponding DOM tree element store this info in SVGElementRareData.

        Test: svg/W3C-SVG-1.1-SE/struct-use-11-f.svg

        * rendering/svg/SVGShadowTreeElements.cpp:
        (WebCore::SVGShadowTreeContainerElement::styleForRenderer):
        * rendering/svg/SVGShadowTreeElements.h:
        * svg/SVGElement.cpp:
        (WebCore::SVGElement::correspondingElement):
        (WebCore::SVGElement::setCorrespondingElement):
        (WebCore::SVGElement::styleForRenderer):
        * svg/SVGElement.h:
        * svg/SVGElementInstance.cpp:
        (WebCore::SVGElementInstance::invalidateAllInstancesOfElement):
        * svg/SVGElementRareData.h:
        (WebCore::SVGElementRareData::SVGElementRareData):
        (WebCore::SVGElementRareData::correspondingElement):
        (WebCore::SVGElementRareData::setCorrespondingElement):
        * svg/SVGStyledElement.cpp:
        (WebCore::SVGStyledElement::removedFromDocument):
        * svg/SVGUseElement.cpp:
        (WebCore::SVGUseElement::associateInstancesWithShadowTreeElements):
        * svg/SVGUseElement.h:

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

14 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/svg/W3C-SVG-1.1-SE/struct-use-11-f-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/W3C-SVG-1.1-SE/struct-use-11-f-expected.txt [new file with mode: 0644]
LayoutTests/svg/W3C-SVG-1.1-SE/struct-use-11-f.svg [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/svg/SVGShadowTreeElements.cpp
Source/WebCore/rendering/svg/SVGShadowTreeElements.h
Source/WebCore/svg/SVGElement.cpp
Source/WebCore/svg/SVGElement.h
Source/WebCore/svg/SVGElementInstance.cpp
Source/WebCore/svg/SVGElementRareData.h
Source/WebCore/svg/SVGStyledElement.cpp
Source/WebCore/svg/SVGUseElement.cpp
Source/WebCore/svg/SVGUseElement.h

index 7c3d00b..e04cc47 100644 (file)
@@ -1,3 +1,14 @@
+2011-07-28  Rob Buis  <rbuis@rim.com>
+
+        Use styling test from ietestcenter fails
+        https://bugs.webkit.org/show_bug.cgi?id=62147 
+
+        Reviewed by Nikolas Zimmermann.
+
+        * platform/mac/svg/W3C-SVG-1.1-SE/struct-use-11-f-expected.png: Added.
+        * platform/mac/svg/W3C-SVG-1.1-SE/struct-use-11-f-expected.txt: Added.
+        * svg/W3C-SVG-1.1-SE/struct-use-11-f.svg: Added.
+
 2011-07-28  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         [Qt] Unreviewed gardening.
diff --git a/LayoutTests/platform/mac/svg/W3C-SVG-1.1-SE/struct-use-11-f-expected.png b/LayoutTests/platform/mac/svg/W3C-SVG-1.1-SE/struct-use-11-f-expected.png
new file mode 100644 (file)
index 0000000..4815b57
Binary files /dev/null and b/LayoutTests/platform/mac/svg/W3C-SVG-1.1-SE/struct-use-11-f-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/W3C-SVG-1.1-SE/struct-use-11-f-expected.txt b/LayoutTests/platform/mac/svg/W3C-SVG-1.1-SE/struct-use-11-f-expected.txt
new file mode 100644 (file)
index 0000000..1f10c68
--- /dev/null
@@ -0,0 +1,65 @@
+layer at (0,0) size 480x360
+  RenderView at (0,0) size 480x360
+layer at (0,0) size 480x360
+  RenderSVGRoot {svg} at (0,0) size 480x360
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+    RenderSVGContainer {g} at (2,2) size 384x296
+      RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+        RenderSVGPath {circle} at (2,2) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+        RenderSVGPath {circle} at (2,2) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+        RenderSVGPath {circle} at (2,2) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+        RenderSVGContainer {g} at (2,2) size 96x96
+          RenderSVGPath {circle} at (2,2) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+        RenderSVGContainer {g} at (2,2) size 96x96
+          RenderSVGPath {circle} at (2,2) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+        RenderSVGContainer {g} at (2,2) size 96x96
+          RenderSVGPath {circle} at (2,2) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+        RenderSVGContainer {g} at (0,0) size 0x0
+        RenderSVGPath {circle} at (2,2) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+        RenderSVGPath {circle} at (2,2) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+        RenderSVGPath {circle} at (2,2) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+        RenderSVGPath {circle} at (2,2) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+        RenderSVGPath {circle} at (2,2) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+        RenderSVGContainer {g} at (2,2) size 96x96
+          RenderSVGPath {circle} at (2,2) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+      RenderSVGContainer {use} at (2,2) size 96x96
+        RenderSVGContainer {g} at (2,2) size 96x96
+          RenderSVGPath {circle} at (2,2) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+      RenderSVGContainer {use} at (98,2) size 96x96
+        RenderSVGContainer {g} at (98,2) size 96x96 [transform={m=((1.00,0.00)(0.00,1.00)) t=(96.00,0.00)}]
+          RenderSVGPath {circle} at (98,2) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+      RenderSVGContainer {use} at (194,2) size 96x96
+        RenderSVGContainer {g} at (194,2) size 96x96 [transform={m=((1.00,0.00)(0.00,1.00)) t=(192.00,0.00)}]
+          RenderSVGPath {circle} at (194,2) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+      RenderSVGContainer {use} at (290,2) size 96x96
+        RenderSVGContainer {g} at (290,2) size 96x96 [transform={m=((1.00,0.00)(0.00,1.00)) t=(288.00,0.00)}]
+          RenderSVGPath {circle} at (290,2) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+      RenderSVGContainer {use} at (2,102) size 96x96
+        RenderSVGContainer {g} at (2,102) size 96x96 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,100.00)}]
+          RenderSVGPath {circle} at (2,102) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+      RenderSVGContainer {use} at (98,102) size 96x96
+        RenderSVGContainer {g} at (98,102) size 96x96 [transform={m=((1.00,0.00)(0.00,1.00)) t=(96.00,100.00)}]
+          RenderSVGPath {circle} at (98,102) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+      RenderSVGContainer {use} at (194,102) size 96x96
+        RenderSVGContainer {g} at (194,102) size 96x96 [transform={m=((1.00,0.00)(0.00,1.00)) t=(192.00,100.00)}]
+          RenderSVGPath {circle} at (194,102) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+      RenderSVGContainer {use} at (290,102) size 96x96
+        RenderSVGContainer {g} at (290,102) size 96x96 [transform={m=((1.00,0.00)(0.00,1.00)) t=(288.00,100.00)}]
+          RenderSVGPath {circle} at (290,102) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+      RenderSVGContainer {use} at (2,202) size 96x96
+        RenderSVGContainer {g} at (2,202) size 96x96 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,200.00)}]
+          RenderSVGPath {circle} at (2,202) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+      RenderSVGContainer {use} at (98,202) size 96x96
+        RenderSVGContainer {g} at (98,202) size 96x96 [transform={m=((1.00,0.00)(0.00,1.00)) t=(96.00,200.00)}]
+          RenderSVGPath {circle} at (98,202) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+      RenderSVGContainer {use} at (194,202) size 96x96
+        RenderSVGContainer {g} at (194,202) size 96x96 [transform={m=((1.00,0.00)(0.00,1.00)) t=(192.00,200.00)}]
+          RenderSVGPath {circle} at (194,202) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+      RenderSVGContainer {use} at (290,202) size 96x96
+        RenderSVGContainer {g} at (290,202) size 96x96 [transform={m=((1.00,0.00)(0.00,1.00)) t=(288.00,200.00)}]
+          RenderSVGPath {circle} at (290,202) size 96x96 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=48.00]
+    RenderSVGContainer {g} at (10,310) size 231x38
+      RenderSVGText {text} at (10,310) size 231x38 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,0) size 231x38
+          chunk 1 text run 1 at (10.00,340.00) startOffset 0 endOffset 16 width 231.00: "$Revision: 1.2 $"
+    RenderSVGPath {rect} at (0,0) size 480x360 [stroke={[type=SOLID] [color=#000000]}] [x=1.00] [y=1.00] [width=478.00] [height=358.00]
diff --git a/LayoutTests/svg/W3C-SVG-1.1-SE/struct-use-11-f.svg b/LayoutTests/svg/W3C-SVG-1.1-SE/struct-use-11-f.svg
new file mode 100644 (file)
index 0000000..4c90310
--- /dev/null
@@ -0,0 +1,151 @@
+<svg id="svg-root" width="100%" height="100%"
+  viewBox="0 0 480 360" xmlns="http://www.w3.org/2000/svg"
+  xmlns:xlink="http://www.w3.org/1999/xlink">
+  <!--======================================================================-->
+  <!--=  Copyright 2008 World Wide Web Consortium, (Massachusetts          =-->
+  <!--=  Institute of Technology, European Research Consortium for         =-->
+  <!--=  Informatics and Mathematics (ERCIM), Keio University).            =-->
+  <!--=  All Rights Reserved.                                              =-->
+  <!--=  See http://www.w3.org/Consortium/Legal/.                          =-->
+  <!--======================================================================-->
+  <d:SVGTestCase xmlns:d="http://www.w3.org/2000/02/svg/testsuite/description/"
+    template-version="1.4" reviewer="CL" author="Microsoft" status="accepted"
+    version="$Revision: 1.2 $" testname="$RCSfile: struct-use-11-f.svg,v $">
+    <d:testDescription xmlns="http://www.w3.org/1999/xhtml" href="http://www.w3.org/TR/SVG11/struct.html#UseElement">
+      <p>
+        CSS selectors that apply to an element referenced via 'use' also apply to the 'use' instance.
+      </p>
+      <p>
+        A 'style' block contains all CSS rules. Various CSS selectors are applied to 'circle' elements. A unique 'class' selector is
+        used for all cases to ensure that the selectors don't interfere with each other. For each 'circle', there is a corresponding
+        'use' instance. For structure-related rules, a 'g' tag is used.
+      </p>
+    </d:testDescription>
+    <d:operatorScript xmlns="http://www.w3.org/1999/xhtml">
+      <p>
+        Run the test. No interaction required.
+      </p>
+    </d:operatorScript>
+    <d:passCriteria xmlns="http://www.w3.org/1999/xhtml">
+      <p>
+        Test passes if twelve blue circles and no black circles are visible on the page.
+      </p>
+    </d:passCriteria>
+  </d:SVGTestCase>
+  <title id="test-title">$RCSfile: struct-use-11-f.svg,v $</title>
+  <defs>
+    <font-face
+      font-family="SVGFreeSansASCII"
+      unicode-range="U+0-7F">
+      <font-face-src>
+        <font-face-uri xlink:href="../resources/SVGFreeSans.svg#ascii"/>
+      </font-face-src>
+    </font-face>
+  </defs>
+  <g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18">
+
+    <style type="text/css"><![CDATA[
+        #testId.test1
+        {
+            fill: blue;
+        }
+        *.test2
+        {
+            fill: blue;
+        }
+        circle.test3
+        {
+            fill: blue;
+        }
+        .descendant circle.test4
+        {
+            fill: blue;
+        }
+        .child > circle.test5
+        {
+            fill: blue;
+        }
+        .test6:first-child
+        {
+            fill: blue;
+        }
+        .sibling + circle.test7
+        {
+            fill: blue;
+        }
+        circle[cx].test8
+        {
+            fill: blue;
+        }
+        circle[cx="50"].test9
+        {
+            fill: blue;
+        }
+        circle[foo~="warning1"].test10
+        {
+            fill: blue;
+        }
+        circle[lang|="en"].test11
+        {
+            fill: blue;
+        }
+       .test12 {
+            fill: blue
+         }
+        .twochildren:first-child
+        {
+            fill: black;
+        }]]>
+    </style>
+    <defs>
+        <circle cx="50" cy="50" r="48" id="testId" class="test1" />
+        <circle cx="50" cy="50" r="48" id="testClass" class="test2" />
+        <circle cx="50" cy="50" r="48" id="testType" class="test3" />
+        <g class="descendant">
+            <circle cx="50" cy="50" r="48" id="testDescendant" class="test4" />
+        </g>
+        <g class="child">
+            <circle cx="50" cy="50" r="48" id="testChild" class="test5" />
+        </g>
+        <g>
+            <circle cx="50" cy="50" r="48" id="testFirstChild" class="test6" />
+        </g>
+        <g class="sibling"></g>
+        <circle cx="50" cy="50" r="48" id="testSibling" class="test7" />
+        <circle cx="50" cy="50" r="48" id="testAttribute" class="test8" />
+        <circle cx="50" cy="50" r="48" id="testAttributeWithValue" class="test9" />
+        <circle cx="50" cy="50" r="48" id="testAttributeWithSpaceSeparatedValueList" class="test10" foo="warning1 warning2" />
+        <circle cx="50" cy="50" r="48" id="testAttributeWithHyphenSeparatedValueList" class="test11" lang="en-us" />
+        <g class="twochildren">
+           <circle cx="50" cy="50" r="48" id="notFirstChild" display="none" />
+            <circle cx="50" cy="50" r="48" id="testFirstChild2" class="test12" />
+        </g>
+    </defs>
+    <use xlink:href="#testId" x="0" y="0" />
+    <use xlink:href="#testClass" x="96" y="0" />
+    <use xlink:href="#testType" x="192" y="0" />
+    <use xlink:href="#testDescendant" x="288" y="0" />
+    <use xlink:href="#testChild" x="0" y="100" />
+    <use xlink:href="#testFirstChild" x="96" y="100" />
+    <use xlink:href="#testSibling" x="192" y="100" />
+    <use xlink:href="#testAttribute" x="288" y="100" />
+    <use xlink:href="#testAttributeWithValue" x="0" y="200" />
+    <use xlink:href="#testAttributeWithSpaceSeparatedValueList" x="96" y="200" />
+    <use xlink:href="#testAttributeWithHyphenSeparatedValueList" x="192" y="200" />
+    <use xlink:href="#testFirstChild2" x="288" y="200" />
+
+  </g>
+  <g font-family="SVGFreeSansASCII,sans-serif" font-size="32">
+    <text id="revision" x="10" y="340" stroke="none"
+      fill="black">$Revision: 1.2 $</text>
+  </g>
+  <rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/>
+  <!-- comment out this watermark once the test is approved -->
+  <!--
+  <g id="draft-watermark">
+    <rect x="1" y="1" width="478" height="20" fill="red" stroke="black" stroke-width="1"/>
+    <text font-family="SVGFreeSansASCII,sans-serif" font-weight="bold" font-size="20" x="240"
+      text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text>
+  </g>
+  -->
+</svg>
index 1852f34..5375e51 100644 (file)
@@ -1,3 +1,35 @@
+2011-07-28  Rob Buis  <rbuis@rim.com>
+
+        Use styling test from ietestcenter fails
+        https://bugs.webkit.org/show_bug.cgi?id=62147 
+
+        Reviewed by Nikolas Zimmermann.
+
+        Make sure CSS selectors are applied to the DOM tree referenced by <use>, not the internal shadow tree. In order to quickly
+        find the corresponding DOM tree element store this info in SVGElementRareData. 
+
+        Test: svg/W3C-SVG-1.1-SE/struct-use-11-f.svg
+
+        * rendering/svg/SVGShadowTreeElements.cpp:
+        (WebCore::SVGShadowTreeContainerElement::styleForRenderer):
+        * rendering/svg/SVGShadowTreeElements.h:
+        * svg/SVGElement.cpp:
+        (WebCore::SVGElement::correspondingElement):
+        (WebCore::SVGElement::setCorrespondingElement):
+        (WebCore::SVGElement::styleForRenderer):
+        * svg/SVGElement.h:
+        * svg/SVGElementInstance.cpp:
+        (WebCore::SVGElementInstance::invalidateAllInstancesOfElement):
+        * svg/SVGElementRareData.h:
+        (WebCore::SVGElementRareData::SVGElementRareData):
+        (WebCore::SVGElementRareData::correspondingElement):
+        (WebCore::SVGElementRareData::setCorrespondingElement):
+        * svg/SVGStyledElement.cpp:
+        (WebCore::SVGStyledElement::removedFromDocument):
+        * svg/SVGUseElement.cpp:
+        (WebCore::SVGUseElement::associateInstancesWithShadowTreeElements):
+        * svg/SVGUseElement.h:
+
 2011-07-28  Denis Oliver Kropp  <dok@directfb.org>
 
         This fixes build without video enabled.
index 3887bba..13a4de0 100644 (file)
@@ -22,6 +22,7 @@
 #if ENABLE(SVG)
 #include "SVGShadowTreeElements.h"
 
+#include "CSSStyleSelector.h"
 #include "Document.h"
 #include "FloatSize.h"
 #include "RenderObject.h"
@@ -97,6 +98,11 @@ void SVGShadowTreeRootElement::clearSVGShadowHost()
     setParent(0);
 }
 
+PassRefPtr<RenderStyle> SVGShadowTreeContainerElement::styleForRenderer(const NodeRenderingContext&)
+{
+    return document()->styleSelector()->styleForElement(this, 0, true/*allowSharing*/);
+}
+
 }
 
 #endif
index b37d721..72b4b72 100644 (file)
@@ -39,6 +39,8 @@ public:
     bool containerOffsetChanged() const { return m_containerOffsetChanged; }
     void setContainerOffsetChanged(bool containerOffsetChanged) { m_containerOffsetChanged = containerOffsetChanged; }
 
+    virtual PassRefPtr<RenderStyle> styleForRenderer(const NodeRenderingContext&);
+
 protected:
     SVGShadowTreeContainerElement(Document*);
 
index 07ac31c..d8912bd 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "Attribute.h"
 #include "CSSCursorImageValue.h"
+#include "CSSStyleSelector.h"
 #include "DOMImplementation.h"
 #include "Document.h"
 #include "Event.h"
@@ -258,6 +259,17 @@ void SVGElement::cursorImageValueRemoved()
     rareSVGData()->setCursorImageValue(0);
 }
 
+SVGElement* SVGElement::correspondingElement()
+{
+    ASSERT(!hasRareSVGData() || !rareSVGData()->correspondingElement() || shadowTreeRootNode());
+    return hasRareSVGData() ? rareSVGData()->correspondingElement() : 0;
+}
+
+void SVGElement::setCorrespondingElement(SVGElement* correspondingElement)
+{
+    ensureRareSVGData()->setCorrespondingElement(correspondingElement);
+}
+
 void SVGElement::parseMappedAttribute(Attribute* attr)
 {
     // standard events
@@ -414,6 +426,14 @@ void SVGElement::synchronizeSystemLanguage(void* contextElement)
     static_cast<SVGElement*>(contextElement)->synchronizeSystemLanguage();
 }
 
+PassRefPtr<RenderStyle> SVGElement::styleForRenderer(const NodeRenderingContext& context)
+{
+    if (correspondingElement())
+        return document()->styleSelector()->styleForElement(correspondingElement(), parentNode() ? parentNode()->renderer()->style() : 0, false/*allowSharing*/);
+
+    return StyledElement::styleForRenderer(context);
+}
+
 }
 
 #endif // ENABLE(SVG)
index 703a9ae..128ecab 100644 (file)
@@ -84,7 +84,12 @@ public:
     void setCursorImageValue(CSSCursorImageValue*);
     void cursorImageValueRemoved();
 
+    SVGElement* correspondingElement();
+    void setCorrespondingElement(SVGElement*);
+
     virtual void updateAnimatedSVGAttribute(const QualifiedName&) const;
+    virtual PassRefPtr<RenderStyle> styleForRenderer(const NodeRenderingContext&);
 
     static void synchronizeRequiredFeatures(void* contextElement);
     static void synchronizeRequiredExtensions(void* contextElement);
index 0fba66b..a93a48a 100644 (file)
@@ -109,7 +109,10 @@ void SVGElementInstance::invalidateAllInstancesOfElement(SVGElement* element)
     // Mark all use elements referencing 'element' for rebuilding
     const HashSet<SVGElementInstance*>::const_iterator end = set.end();
     for (HashSet<SVGElementInstance*>::const_iterator it = set.begin(); it != end; ++it) {
+        ASSERT((*it)->shadowTreeElement());
+        ASSERT((*it)->shadowTreeElement()->correspondingElement());
         ASSERT((*it)->correspondingElement() == element);
+        (*it)->shadowTreeElement()->setCorrespondingElement(0);
         if (SVGUseElement* element = (*it)->correspondingUseElement()) {
             ASSERT(element->inDocument());
             element->invalidateShadowTree();
index 50bf235..5019662 100644 (file)
@@ -37,6 +37,7 @@ public:
     SVGElementRareData()
         : m_cursorElement(0)
         , m_cursorImageValue(0)
+        , m_correspondingElement(0)
         , m_instancesUpdatesBlocked(false)
         , m_hasPendingResources(false)
     {
@@ -67,6 +68,9 @@ public:
     SVGCursorElement* cursorElement() const { return m_cursorElement; }
     void setCursorElement(SVGCursorElement* cursorElement) { m_cursorElement = cursorElement; }
 
+    SVGElement* correspondingElement() { return m_correspondingElement; }
+    void setCorrespondingElement(SVGElement* correspondingElement) { m_correspondingElement = correspondingElement; }
+
     CSSCursorImageValue* cursorImageValue() const { return m_cursorImageValue; }
     void setCursorImageValue(CSSCursorImageValue* cursorImageValue) { m_cursorImageValue = cursorImageValue; }
 
@@ -74,6 +78,7 @@ private:
     HashSet<SVGElementInstance*> m_elementInstances;
     SVGCursorElement* m_cursorElement;
     CSSCursorImageValue* m_cursorImageValue;
+    SVGElement* m_correspondingElement;
     bool m_instancesUpdatesBlocked : 1;
     bool m_hasPendingResources : 1;
 };
index 88de72e..d80dbe0 100644 (file)
@@ -397,6 +397,7 @@ void SVGStyledElement::removedFromDocument()
 {
     updateRelativeLengthsInformation(false, this);
     SVGElement::removedFromDocument();
+    SVGElementInstance::invalidateAllInstancesOfElement(this);
 
     Document* document = this->document();
     if (!needsPendingResourceHandling() || !document)
index 7aeaa00..38db682 100644 (file)
@@ -36,6 +36,7 @@
 #include "RenderSVGResource.h"
 #include "RenderSVGShadowTreeRootContainer.h"
 #include "SVGElementInstance.h"
+#include "SVGElementRareData.h"
 #include "SVGElementInstanceList.h"
 #include "SVGGElement.h"
 #include "SVGNames.h"
@@ -1013,6 +1014,7 @@ void SVGUseElement::associateInstancesWithShadowTreeElements(Node* target, SVGEl
 
     ASSERT(!targetInstance->shadowTreeElement());
     targetInstance->setShadowTreeElement(element);
+    element->setCorrespondingElement(originalElement);
 
     Node* node = target->firstChild();
     for (SVGElementInstance* instance = targetInstance->firstChild(); node && instance; instance = instance->nextSibling()) {
index 89a79a6..b65ca4e 100644 (file)
@@ -76,6 +76,7 @@ private:
     void setUpdatesBlocked(bool blocked) { m_updatesBlocked = blocked; }
 
     friend class RenderSVGShadowTreeRootContainer;
+    friend class SVGElement;
     void buildShadowAndInstanceTree(SVGShadowTreeRootElement*);
     void detachInstance();