2011-03-29 Leo Yang <leo.yang@torchmobile.com.cn>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Mar 2011 13:28:09 +0000 (13:28 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Mar 2011 13:28:09 +0000 (13:28 +0000)
        Reviewed by Nikolas Zimmermann.

        Incorrect offset of svg <use> element which is in <symbol> element
        https://bugs.webkit.org/show_bug.cgi?id=57318

        Test case to verify offset of svg <use> element in <symbol> element
        is set correctly.

        * platform/qt/svg/custom/use-in-symbol-with-offset-expected.checksum: Added.
        * platform/qt/svg/custom/use-in-symbol-with-offset-expected.png: Added.
        * svg/custom/use-in-symbol-with-offset-expected.txt: Added.
        * svg/custom/use-in-symbol-with-offset.svg: Added.
2011-03-29  Leo Yang  <leo.yang@torchmobile.com.cn>

        Reviewed by Nikolas Zimmermann.

        Incorrect offset of svg <use> element which is in <symbol> element
        https://bugs.webkit.org/show_bug.cgi?id=57318

        When webkit expanded a svg <symbol> element in the shadow tree it
        would clone the children of the <symbol>. The children may contain
        SVGShadowTreeContainerElement which was expanded from svg <use>
        element. But the clone operation would clone a
        SVGShadowTreeContainerElement as a svg <g> element. This resulted
        that updateContainerOffset wouldn't update offset for those elements
        which were expand from <use> elements.

        This patch implements cloneElementWithoutAttributesAndChildren for
        SVGShadowTreeContainerElement to make the container clone itself
        correctly.

        Test: svg/custom/use-in-symbol-with-offset.svg

        * rendering/svg/SVGShadowTreeElements.cpp:
        (WebCore::SVGShadowTreeContainerElement::cloneElementWithoutAttributesAndChildren):
        * rendering/svg/SVGShadowTreeElements.h:

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

LayoutTests/ChangeLog
LayoutTests/platform/qt/svg/custom/use-in-symbol-with-offset-expected.checksum [new file with mode: 0644]
LayoutTests/platform/qt/svg/custom/use-in-symbol-with-offset-expected.png [new file with mode: 0644]
LayoutTests/svg/custom/use-in-symbol-with-offset-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/use-in-symbol-with-offset.svg [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/svg/SVGShadowTreeElements.cpp
Source/WebCore/rendering/svg/SVGShadowTreeElements.h

index 2b9a79f2e6b9a32d6068ed41d8cb9763dc9143f1..195b9a147cc53d45307fd00dd0e72a9efbddb1b5 100644 (file)
@@ -1,3 +1,18 @@
+2011-03-29  Leo Yang  <leo.yang@torchmobile.com.cn>
+
+        Reviewed by Nikolas Zimmermann.
+
+        Incorrect offset of svg <use> element which is in <symbol> element
+        https://bugs.webkit.org/show_bug.cgi?id=57318
+
+        Test case to verify offset of svg <use> element in <symbol> element
+        is set correctly.
+
+        * platform/qt/svg/custom/use-in-symbol-with-offset-expected.checksum: Added.
+        * platform/qt/svg/custom/use-in-symbol-with-offset-expected.png: Added.
+        * svg/custom/use-in-symbol-with-offset-expected.txt: Added.
+        * svg/custom/use-in-symbol-with-offset.svg: Added.
+
 2011-03-29  Pavel Feldman  <pfeldman@chromium.org>
 
         Reviewed by Yury Semikhatsky.
 2011-03-29  Pavel Feldman  <pfeldman@chromium.org>
 
         Reviewed by Yury Semikhatsky.
diff --git a/LayoutTests/platform/qt/svg/custom/use-in-symbol-with-offset-expected.checksum b/LayoutTests/platform/qt/svg/custom/use-in-symbol-with-offset-expected.checksum
new file mode 100644 (file)
index 0000000..7363841
--- /dev/null
@@ -0,0 +1 @@
+778803df0a824ed8f2c7dfa07c56832e
\ No newline at end of file
diff --git a/LayoutTests/platform/qt/svg/custom/use-in-symbol-with-offset-expected.png b/LayoutTests/platform/qt/svg/custom/use-in-symbol-with-offset-expected.png
new file mode 100644 (file)
index 0000000..5120d7c
Binary files /dev/null and b/LayoutTests/platform/qt/svg/custom/use-in-symbol-with-offset-expected.png differ
diff --git a/LayoutTests/svg/custom/use-in-symbol-with-offset-expected.txt b/LayoutTests/svg/custom/use-in-symbol-with-offset-expected.txt
new file mode 100644 (file)
index 0000000..093e3e6
--- /dev/null
@@ -0,0 +1,14 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 100x100
+  RenderSVGRoot {svg} at (0,0) size 100x100
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+    RenderSVGContainer {use} at (0,0) size 100x100
+      RenderSVGContainer {g} at (0,0) size 100x100
+        RenderSVGViewportContainer {svg} at (0,0) size 100x100
+          RenderSVGContainer {g} at (0,0) size 50x100
+            RenderSVGViewportContainer {svg} at (0,0) size 50x100
+              RenderSVGPath {rect} at (0,0) size 50x100 [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=1.00] [height=2.00]
+          RenderSVGContainer {g} at (50,0) size 50x100 [transform={m=((1.00,0.00)(0.00,1.00)) t=(1.00,0.00)}]
+            RenderSVGViewportContainer {svg} at (50,0) size 50x100
+              RenderSVGPath {rect} at (50,0) size 50x100 [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=1.00] [height=2.00]
diff --git a/LayoutTests/svg/custom/use-in-symbol-with-offset.svg b/LayoutTests/svg/custom/use-in-symbol-with-offset.svg
new file mode 100644 (file)
index 0000000..1682a22
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" standalone="no"?>
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0" width="100" height="100">
+    <defs>
+        <symbol id="s" viewBox="0 0 1 2">
+            <rect fill="green" width="1" height="2" />
+        </symbol>
+        <symbol id="s1" viewBox="0 0 2 2">
+            <use xlink:href="#s" x="0" y="0" width="1" height="2" />
+            <use xlink:href="#s" x="1" y="0" width="1" height="2" />
+        </symbol>
+    </defs>
+    <use xlink:href="#s1" x="0" y="0" width="100" height="100" />
+</svg>
index 416bdacc825163a876d823fa4a83899c85533630..fc42f6c681e725543a8ddc584eb12db40b411b25 100644 (file)
@@ -1,3 +1,28 @@
+2011-03-29  Leo Yang  <leo.yang@torchmobile.com.cn>
+
+        Reviewed by Nikolas Zimmermann.
+
+        Incorrect offset of svg <use> element which is in <symbol> element
+        https://bugs.webkit.org/show_bug.cgi?id=57318
+
+        When webkit expanded a svg <symbol> element in the shadow tree it
+        would clone the children of the <symbol>. The children may contain
+        SVGShadowTreeContainerElement which was expanded from svg <use>
+        element. But the clone operation would clone a
+        SVGShadowTreeContainerElement as a svg <g> element. This resulted
+        that updateContainerOffset wouldn't update offset for those elements
+        which were expand from <use> elements.
+
+        This patch implements cloneElementWithoutAttributesAndChildren for
+        SVGShadowTreeContainerElement to make the container clone itself
+        correctly.
+
+        Test: svg/custom/use-in-symbol-with-offset.svg
+
+        * rendering/svg/SVGShadowTreeElements.cpp:
+        (WebCore::SVGShadowTreeContainerElement::cloneElementWithoutAttributesAndChildren):
+        * rendering/svg/SVGShadowTreeElements.h:
+
 2011-03-29  Eric Seidel  <eric@webkit.org>
 
         Reviewed by Ryosuke Niwa.
 2011-03-29  Eric Seidel  <eric@webkit.org>
 
         Reviewed by Ryosuke Niwa.
index 2d84c48a368d1b0eb8be9772f977eafcfde464c1..9ccdef0e3a3e17ab5d99ee7192497f336a95b785 100644 (file)
@@ -47,6 +47,10 @@ FloatSize SVGShadowTreeContainerElement::containerTranslation() const
     return FloatSize(m_xOffset.value(this), m_yOffset.value(this));
 }
 
     return FloatSize(m_xOffset.value(this), m_yOffset.value(this));
 }
 
+PassRefPtr<Element> SVGShadowTreeContainerElement::cloneElementWithoutAttributesAndChildren() const
+{
+    return adoptRef(new SVGShadowTreeContainerElement(document()));
+}
 // SVGShadowTreeRootElement
 
 inline SVGShadowTreeRootElement::SVGShadowTreeRootElement(Document* document, SVGUseElement* shadowParent)
 // SVGShadowTreeRootElement
 
 inline SVGShadowTreeRootElement::SVGShadowTreeRootElement(Document* document, SVGUseElement* shadowParent)
index 3406f956f9be4ec83709d749fede755b512fa4fe..2952e3589e26f6132133f8b6c3231870c881a106 100644 (file)
@@ -44,6 +44,7 @@ protected:
     SVGShadowTreeContainerElement(Document*);
 
 private:
     SVGShadowTreeContainerElement(Document*);
 
 private:
+    virtual PassRefPtr<Element> cloneElementWithoutAttributesAndChildren() const;
     virtual bool isShadowTreeContainerElement() const { return true; }
 
     SVGLength m_xOffset;
     virtual bool isShadowTreeContainerElement() const { return true; }
 
     SVGLength m_xOffset;