[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9
zimmermann at webkit.org
zimmermann at webkit.org
Thu Feb 4 21:23:58 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 2c76ec15affc9ff919626ca868f33a5ce931aa73
Author: zimmermann at webkit.org <zimmermann at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Jan 21 23:22:56 2010 +0000
2010-01-21 Nikolas Zimmermann <nzimmermann at rim.com>
Reviewed by Dirk Schulze.
<use> with % lengths does not update on window resize
https://bugs.webkit.org/show_bug.cgi?id=14639
appendChild broken for symbol-use
https://bugs.webkit.org/show_bug.cgi?id=24802
Test: svg/custom/relative-sized-shadow-tree-content-with-symbol.xhtml
svg/custom/svg/custom/relative-sized-use-on-symbol.xhtml
Fix reaction on window size changes for relative sized elements within <symbol> elements.
Don't evaluate SVGUseElement width/height attributes in order to propagate them to the shadow tree,
instead just propagate the attribute values itself so "100%" remains "100%" instead of being evaluated
to an absolute pixel value in the parent <svg> user-space.
Needs another fix in SVGStyledElement::childrenChanged(), which is a regression from my last <use>
patch, that hasn't been detected, as the use-dynamic-append.svg testcase was broken.
The combination of all the last <use> patches finally fixes the peepo.co.uk website, which was broken by several bugs for years.
* svg/SVGStyledElement.cpp:
(WebCore::SVGStyledElement::childrenChanged): Need to mark shadow trees needing recalcs, even when parsing.
* svg/SVGUseElement.cpp:
(WebCore::SVGUseElement::svgAttributeChanged): Don't reclone for width/height attribute changes, just propagate them down the render tree
(WebCore::updateContainerSize): Added helper function, updating the width/height attributes in the shadow tree.
(WebCore::SVGUseElement::updateContainerSizes):
(WebCore::SVGUseElement::buildShadowAndInstanceTree): Update container width/height after shadow tree creation, instead of doing it inbetween.
(WebCore::SVGUseElement::buildShadowTree): Don't alter width/height attributes here anymore.
(WebCore::SVGUseElement::expandUseElementsInShadowTree): Ditto.
(WebCore::SVGUseElement::expandSymbolElementsInShadowTree): Ditto.
* svg/SVGUseElement.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53656 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 9e97b82..f91a5ff 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,25 @@
+2010-01-21 Nikolas Zimmermann <nzimmermann at rim.com>
+
+ Reviewed by Dirk Schulze.
+
+ <use> with % lengths does not update on window resize
+ https://bugs.webkit.org/show_bug.cgi?id=14639
+
+ Fix reaction on window size changes for relative sized elements within <symbol> elements.
+
+ * platform/mac/svg/custom/relative-sized-shadow-tree-content-with-symbol-expected.checksum: Added.
+ * platform/mac/svg/custom/relative-sized-shadow-tree-content-with-symbol-expected.png: Added.
+ * platform/mac/svg/custom/relative-sized-shadow-tree-content-with-symbol-expected.txt: Added.
+ * platform/mac/svg/custom/relative-sized-use-on-symbol-expected.checksum: Added.
+ * platform/mac/svg/custom/relative-sized-use-on-symbol-expected.png: Added.
+ * platform/mac/svg/custom/relative-sized-use-on-symbol-expected.txt: Added.
+ * platform/mac/svg/custom/use-dynamic-append-expected.txt:
+ * platform/mac/svg/custom/use-recursion-4-expected.txt:
+ * platform/mac/svg/hixie/error/017-expected.txt:
+ * svg/custom/relative-sized-shadow-tree-content-with-symbol.xhtml: Added.
+ * svg/custom/relative-sized-use-on-symbol.xhtml: Added.
+ * svg/custom/use-dynamic-append.svg: Fix bug in testcase, which prevents pixel tests to detect regressions.
+
2010-01-21 Brian Weinstein <bweinstein at apple.com>
Rubber-stamped by Adam Roben.
diff --git a/LayoutTests/platform/mac/svg/custom/relative-sized-shadow-tree-content-with-symbol-expected.checksum b/LayoutTests/platform/mac/svg/custom/relative-sized-shadow-tree-content-with-symbol-expected.checksum
new file mode 100644
index 0000000..984dd7b
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/custom/relative-sized-shadow-tree-content-with-symbol-expected.checksum
@@ -0,0 +1 @@
+f8527513598f34e770168e7dc52522bc
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/custom/relative-sized-shadow-tree-content-with-symbol-expected.png b/LayoutTests/platform/mac/svg/custom/relative-sized-shadow-tree-content-with-symbol-expected.png
new file mode 100644
index 0000000..572012a
Binary files /dev/null and b/LayoutTests/platform/mac/svg/custom/relative-sized-shadow-tree-content-with-symbol-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/custom/relative-sized-shadow-tree-content-with-symbol-expected.txt b/LayoutTests/platform/mac/svg/custom/relative-sized-shadow-tree-content-with-symbol-expected.txt
new file mode 100644
index 0000000..4e432b3
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/custom/relative-sized-shadow-tree-content-with-symbol-expected.txt
@@ -0,0 +1,18 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x478
+ RenderBlock {html} at (0,0) size 800x478
+ RenderBody {body} at (8,16) size 784x454
+ RenderBlock {p} at (0,0) size 784x36
+ RenderText {#text} at (0,0) size 721x36
+ text run at (0,0) width 721: "The svg area contained in the div element (red box), should fill out the whole area (two blue rectangles, first: (0,0)-"
+ text run at (0,18) width 670: "(50%,50%), second: (50%,50%)-(100%,100%)), especially after resizing the content box to a different size"
+ RenderBlock {div} at (0,52) size 402x402 [border: (1px solid #FF0000)]
+ RenderSVGRoot {svg} at (9,69) size 400x400
+ RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+ RenderSVGContainer {use} at (9,69) size 400x400
+ RenderSVGContainer {g} at (9,69) size 400x400
+ RenderSVGViewportContainer {svg} at (9,69) size 400x400
+ RenderPath {rect} at (209,269) size 200x200 [fill={[type=SOLID] [color=#008000]}] [data="M100.00,100.00 L200.00,100.00 L200.00,200.00 L100.00,200.00 Z"]
+ RenderPath {rect} at (9,69) size 200x200 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00 L100.00,0.00 L100.00,100.00 L0.00,100.00 Z"]
+ RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/platform/mac/svg/custom/relative-sized-use-on-symbol-expected.checksum b/LayoutTests/platform/mac/svg/custom/relative-sized-use-on-symbol-expected.checksum
new file mode 100644
index 0000000..193a09b
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/custom/relative-sized-use-on-symbol-expected.checksum
@@ -0,0 +1 @@
+800daee7baaae6d7f6d0fe50fddede3e
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/custom/relative-sized-use-on-symbol-expected.png b/LayoutTests/platform/mac/svg/custom/relative-sized-use-on-symbol-expected.png
new file mode 100644
index 0000000..8b34ccd
Binary files /dev/null and b/LayoutTests/platform/mac/svg/custom/relative-sized-use-on-symbol-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/custom/relative-sized-use-on-symbol-expected.txt b/LayoutTests/platform/mac/svg/custom/relative-sized-use-on-symbol-expected.txt
new file mode 100644
index 0000000..112317f
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/custom/relative-sized-use-on-symbol-expected.txt
@@ -0,0 +1,16 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x460
+ RenderBlock {html} at (0,0) size 800x460
+ RenderBody {body} at (8,16) size 784x436
+ RenderBlock {p} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 676x18
+ text run at (0,0) width 676: "The svg area contained in the div element (red box), should fill out the whole area with a green shaped path"
+ RenderBlock {div} at (0,34) size 402x402 [border: (1px solid #FF0000)]
+ RenderSVGRoot {svg} at (45.80,85.63) size 326.40x326.62
+ RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+ RenderSVGContainer {use} at (45.80,85.63) size 326.40x326.62
+ RenderSVGContainer {g} at (45.80,85.63) size 326.40x326.62 [transform={m=((1.00,0.00)(0.00,1.00)) t=(20.00,20.00)}]
+ RenderSVGViewportContainer {svg} at (45.80,85.63) size 326.40x326.62
+ RenderPath {path} at (45.80,85.63) size 326.40x326.62 [fill={[type=SOLID] [color=#008000]}] [data="M143.00,103.00 L143.00,117.00 C143.00,130.91,112.56,142.19,75.00,142.19 C37.44,142.19,7.00,130.91,7.00,117.00 L7.00,117.00 L7.00,103.00 C7.00,89.09,37.44,77.81,75.00,77.81 C112.56,77.81,143.00,89.09,143.00,103.00 L52.00,72.00 C34.31,70.66,20.85,55.57,21.52,37.84 C22.20,20.12,36.76,6.09,54.50,6.09 C72.24,6.09,86.80,20.12,87.48,37.84 C88.15,55.57,74.69,70.66,57.00,72.00"]
+ RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/platform/mac/svg/custom/use-dynamic-append-expected.txt b/LayoutTests/platform/mac/svg/custom/use-dynamic-append-expected.txt
index ca6f906..3b0ad2c 100644
--- a/LayoutTests/platform/mac/svg/custom/use-dynamic-append-expected.txt
+++ b/LayoutTests/platform/mac/svg/custom/use-dynamic-append-expected.txt
@@ -2,11 +2,13 @@ layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderSVGRoot {svg} at (0,0) size 419x144
- RenderSVGContainer {g} at (0,0) size 100x100
- RenderPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00 L100.00,0.00 L100.00,100.00 L0.00,100.00 Z"]
- RenderSVGContainer {use} at (0,0) size 0x0
- RenderSVGContainer {g} at (0,0) size 0x0
- RenderSVGContainer {g} at (0,0) size 0x0
+ RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+ RenderSVGContainer {g} at (0,0) size 100x100
+ RenderPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00 L100.00,0.00 L100.00,100.00 L0.00,100.00 Z"]
+ RenderSVGContainer {use} at (0,0) size 100x100
+ RenderSVGContainer {g} at (0,0) size 100x100
+ RenderSVGContainer {g} at (0,0) size 100x100
+ RenderPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00 L100.00,0.00 L100.00,100.00 L0.00,100.00 Z"]
RenderSVGText {text} at (10,120) size 366x17 contains 1 chunk(s)
RenderSVGInlineText {#text} at (0,-13) size 366x17
chunk 1 text run 1 at (10.00,120.00) startOffset 0 endOffset 60 width 366.00: "This test tries to change a container referenced by a <use>."
diff --git a/LayoutTests/platform/mac/svg/custom/use-recursion-4-expected.txt b/LayoutTests/platform/mac/svg/custom/use-recursion-4-expected.txt
index a0afd78..d695e69 100644
--- a/LayoutTests/platform/mac/svg/custom/use-recursion-4-expected.txt
+++ b/LayoutTests/platform/mac/svg/custom/use-recursion-4-expected.txt
@@ -6,7 +6,6 @@ layer at (0,0) size 800x600
RenderSVGContainer {g} at (0,0) size 0x0
RenderSVGContainer {use} at (0,0) size 0x0
RenderSVGContainer {g} at (0,0) size 0x0
- RenderSVGContainer {g} at (0,0) size 0x0
RenderSVGContainer {g} at (-2.50,-2.50) size 65x15
RenderPath {rect} at (-2.50,-2.50) size 65x15 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [data="M0.00,0.00 L60.00,0.00 L60.00,10.00 L0.00,10.00 Z"]
RenderSVGContainer {use} at (0,0) size 0x0
diff --git a/LayoutTests/platform/mac/svg/hixie/error/017-expected.txt b/LayoutTests/platform/mac/svg/hixie/error/017-expected.txt
index 81d0a05..e54ebb2 100644
--- a/LayoutTests/platform/mac/svg/hixie/error/017-expected.txt
+++ b/LayoutTests/platform/mac/svg/hixie/error/017-expected.txt
@@ -6,15 +6,12 @@ layer at (0,0) size 800x600
RenderSVGContainer {g} at (0,0) size 0x0
RenderSVGContainer {use} at (0,0) size 0x0
RenderSVGContainer {g} at (0,0) size 0x0
- RenderSVGContainer {g} at (0,0) size 0x0
RenderSVGContainer {g} at (0,0) size 0x0
RenderSVGContainer {use} at (0,0) size 0x0
RenderSVGContainer {g} at (0,0) size 0x0
- RenderSVGContainer {g} at (0,0) size 0x0
RenderSVGContainer {g} at (0,0) size 0x0
RenderSVGContainer {use} at (0,0) size 0x0
RenderSVGContainer {g} at (0,0) size 0x0
- RenderSVGContainer {g} at (0,0) size 0x0
RenderSVGContainer {g} at (0,0) size 0x0
RenderSVGContainer {use} at (0,0) size 0x0
RenderSVGContainer {g} at (0,0) size 0x0
diff --git a/LayoutTests/svg/custom/relative-sized-shadow-tree-content-with-symbol.xhtml b/LayoutTests/svg/custom/relative-sized-shadow-tree-content-with-symbol.xhtml
new file mode 100644
index 0000000..663b15a
--- /dev/null
+++ b/LayoutTests/svg/custom/relative-sized-shadow-tree-content-with-symbol.xhtml
@@ -0,0 +1,26 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<body onload="window.setTimeout(resizeBox,0)">
+ <p>The svg area contained in the div element (red box), should fill out the whole area (two blue rectangles, first: (0,0)-(50%,50%), second: (50%,50%)-(100%,100%)), especially after resizing the content box to a different size</p>
+ <div id="contentBox" style="width: 100px; height: 400px; border: 1px solid red;">
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <defs>
+ <symbol id="targetSymbol" viewBox="0 0 200 200" width="50%" height="50%">
+ <rect x="50%" y="50%" width="50%" height="50%" fill="green"/>
+ <rect width="100" height="100" fill="green"/>
+ </symbol>
+ </defs>
+ <use xlink:href="#targetSymbol"/>
+ </svg>
+ </div>
+ <script>
+ if (window.layoutTestController)
+ layoutTestController.waitUntilDone();
+
+ function resizeBox() {
+ document.getElementById("contentBox").style.setProperty("width", "400px");
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
+ </script>
+</body>
+</html>
diff --git a/LayoutTests/svg/custom/relative-sized-use-on-symbol.xhtml b/LayoutTests/svg/custom/relative-sized-use-on-symbol.xhtml
new file mode 100644
index 0000000..f58be25
--- /dev/null
+++ b/LayoutTests/svg/custom/relative-sized-use-on-symbol.xhtml
@@ -0,0 +1,25 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<body onload="window.setTimeout(resizeBox,0)">
+ <p>The svg area contained in the div element (red box), should fill out the whole area with a green shaped path</p>
+ <div id="contentBox" style="width: 100px; height: 400px; border: 1px solid red;">
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <defs>
+ <symbol id="gamesBorder" viewBox="0 0 150 150" >
+ <path fill="green" d="M143 103 143 117 a27,10 0 1 1 -136 0 L 7 117 7 103 a27,10 0 0 1 136 0 L52 72 a33,33 0 1 1 5 0" />
+ </symbol>
+ </defs>
+ <use xlink:href="#gamesBorder" x="5%" y="5%" width="90%" height="90%"/>
+ </svg>
+ </div>
+ <script>
+ if (window.layoutTestController)
+ layoutTestController.waitUntilDone();
+
+ function resizeBox() {
+ document.getElementById("contentBox").style.setProperty("width", "400px");
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
+ </script>
+</body>
+</html>
diff --git a/LayoutTests/svg/custom/use-dynamic-append.svg b/LayoutTests/svg/custom/use-dynamic-append.svg
index b8d7650..c32a0dc 100644
--- a/LayoutTests/svg/custom/use-dynamic-append.svg
+++ b/LayoutTests/svg/custom/use-dynamic-append.svg
@@ -11,8 +11,10 @@ function runTest()
document.getElementById("groupA").appendChild(node)
}
]]></script>
+<defs>
<g id="groupA">
</g>
+</defs>
<use xlink:href="#groupA"/>
<text x="10" y="120" font-size="15">This test tries to change a container referenced by a <use>.</text>
<text x="10" y="140" font-size="15">If it is successful, there should be a green rect above. Bug 15080.</text>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 91c0bfa..2e26092 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,38 @@
+2010-01-21 Nikolas Zimmermann <nzimmermann at rim.com>
+
+ Reviewed by Dirk Schulze.
+
+ <use> with % lengths does not update on window resize
+ https://bugs.webkit.org/show_bug.cgi?id=14639
+
+ appendChild broken for symbol-use
+ https://bugs.webkit.org/show_bug.cgi?id=24802
+
+ Test: svg/custom/relative-sized-shadow-tree-content-with-symbol.xhtml
+ svg/custom/svg/custom/relative-sized-use-on-symbol.xhtml
+
+ Fix reaction on window size changes for relative sized elements within <symbol> elements.
+ Don't evaluate SVGUseElement width/height attributes in order to propagate them to the shadow tree,
+ instead just propagate the attribute values itself so "100%" remains "100%" instead of being evaluated
+ to an absolute pixel value in the parent <svg> user-space.
+
+ Needs another fix in SVGStyledElement::childrenChanged(), which is a regression from my last <use>
+ patch, that hasn't been detected, as the use-dynamic-append.svg testcase was broken.
+
+ The combination of all the last <use> patches finally fixes the peepo.co.uk website, which was broken by several bugs for years.
+
+ * svg/SVGStyledElement.cpp:
+ (WebCore::SVGStyledElement::childrenChanged): Need to mark shadow trees needing recalcs, even when parsing.
+ * svg/SVGUseElement.cpp:
+ (WebCore::SVGUseElement::svgAttributeChanged): Don't reclone for width/height attribute changes, just propagate them down the render tree
+ (WebCore::updateContainerSize): Added helper function, updating the width/height attributes in the shadow tree.
+ (WebCore::SVGUseElement::updateContainerSizes):
+ (WebCore::SVGUseElement::buildShadowAndInstanceTree): Update container width/height after shadow tree creation, instead of doing it inbetween.
+ (WebCore::SVGUseElement::buildShadowTree): Don't alter width/height attributes here anymore.
+ (WebCore::SVGUseElement::expandUseElementsInShadowTree): Ditto.
+ (WebCore::SVGUseElement::expandSymbolElementsInShadowTree): Ditto.
+ * svg/SVGUseElement.h:
+
2010-01-21 Alexey Proskuryakov <ap at apple.com>
Reviewed by Darin Adler.
diff --git a/WebCore/svg/SVGStyledElement.cpp b/WebCore/svg/SVGStyledElement.cpp
index a4a84ef..59b4c9b 100644
--- a/WebCore/svg/SVGStyledElement.cpp
+++ b/WebCore/svg/SVGStyledElement.cpp
@@ -258,8 +258,6 @@ void SVGStyledElement::invalidateResourcesInAncestorChain() const
void SVGStyledElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
{
SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
- if (document()->parsing())
- return;
// Invalidate all SVGElementInstances associated with us
SVGElementInstance::invalidateAllInstancesOfElement(this);
diff --git a/WebCore/svg/SVGUseElement.cpp b/WebCore/svg/SVGUseElement.cpp
index f8f459b..9590091 100644
--- a/WebCore/svg/SVGUseElement.cpp
+++ b/WebCore/svg/SVGUseElement.cpp
@@ -157,16 +157,18 @@ void SVGUseElement::svgAttributeChanged(const QualifiedName& attrName)
return;
}
+ if (attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr) {
+ updateContainerSizes();
+ return;
+ }
+
// Be very careful here, if svgAttributeChanged() has been called because a SVG CSS property changed, we do NOT want to reclone the tree!
if (SVGStyledElement::isKnownAttribute(attrName)) {
setNeedsStyleRecalc();
return;
}
- // TODO: We should be able to remove the need for width/height to require a reclone, similar to the x/y logic.
- if (attrName == SVGNames::widthAttr
- || attrName == SVGNames::heightAttr
- || SVGTests::isKnownAttribute(attrName)
+ if (SVGTests::isKnownAttribute(attrName)
|| SVGLangSpace::isKnownAttribute(attrName)
|| SVGExternalResourcesRequired::isKnownAttribute(attrName)
|| SVGStyledTransformableElement::isKnownAttribute(attrName)) {
@@ -174,6 +176,54 @@ void SVGUseElement::svgAttributeChanged(const QualifiedName& attrName)
}
}
+static void updateContainerSize(SVGUseElement* useElement, SVGElementInstance* targetInstance)
+{
+ // Depth-first used to write the method in early exit style, no particular other reason.
+ for (SVGElementInstance* instance = targetInstance->firstChild(); instance; instance = instance->nextSibling())
+ updateContainerSize(useElement, instance);
+
+ SVGElement* correspondingElement = targetInstance->correspondingElement();
+ ASSERT(correspondingElement);
+
+ bool isSymbolTag = correspondingElement->hasTagName(SVGNames::symbolTag);
+ if (!correspondingElement->hasTagName(SVGNames::svgTag) && !isSymbolTag)
+ return;
+
+ SVGElement* shadowTreeElement = targetInstance->shadowTreeElement();
+ ASSERT(shadowTreeElement);
+ ASSERT(shadowTreeElement->hasTagName(SVGNames::svgTag));
+
+ // Spec (<use> on <symbol>): This generated 'svg' will always have explicit values for attributes width and height.
+ // If attributes width and/or height are provided on the 'use' element, then these attributes
+ // will be transferred to the generated 'svg'. If attributes width and/or height are not specified,
+ // the generated 'svg' element will use values of 100% for these attributes.
+
+ // Spec (<use> on <svg>): If attributes width and/or height are provided on the 'use' element, then these
+ // values will override the corresponding attributes on the 'svg' in the generated tree.
+
+ if (useElement->hasAttribute(SVGNames::widthAttr))
+ shadowTreeElement->setAttribute(SVGNames::widthAttr, useElement->getAttribute(SVGNames::widthAttr));
+ else if (isSymbolTag && shadowTreeElement->hasAttribute(SVGNames::widthAttr))
+ shadowTreeElement->setAttribute(SVGNames::widthAttr, "100%");
+
+ if (useElement->hasAttribute(SVGNames::heightAttr))
+ shadowTreeElement->setAttribute(SVGNames::heightAttr, useElement->getAttribute(SVGNames::heightAttr));
+ else if (isSymbolTag && shadowTreeElement->hasAttribute(SVGNames::heightAttr))
+ shadowTreeElement->setAttribute(SVGNames::heightAttr, "100%");
+}
+
+void SVGUseElement::updateContainerSizes()
+{
+ if (!m_targetElementInstance)
+ return;
+
+ // Update whole subtree, scanning for shadow container elements, that correspond to <svg>/<symbol> tags
+ updateContainerSize(this, m_targetElementInstance.get());
+
+ if (renderer())
+ renderer()->setNeedsLayout(true);
+}
+
static void updateContainerOffset(SVGElementInstance* targetInstance)
{
// Depth-first used to write the method in early exit style, no particular other reason.
@@ -465,8 +515,9 @@ void SVGUseElement::buildShadowAndInstanceTree(SVGShadowTreeRootElement* shadowR
// Transfer event listeners assigned to the referenced element to our shadow tree elements.
transferEventListenersToShadowTree(m_targetElementInstance.get());
- // Update container translation offsets
+ // Update container offset/size
updateContainerOffsets();
+ updateContainerSizes();
}
RenderObject* SVGUseElement::createRenderer(RenderArena* arena, RenderStyle*)
@@ -597,18 +648,6 @@ void SVGUseElement::handleDeepUseReferencing(SVGUseElement* use, SVGElementInsta
buildInstanceTree(target, newInstancePtr, foundProblem);
}
-void SVGUseElement::alterShadowTreeForSVGTag(SVGElement* target)
-{
- String widthString = String::number(width().value(this));
- String heightString = String::number(height().value(this));
-
- if (hasAttribute(SVGNames::widthAttr))
- target->setAttribute(SVGNames::widthAttr, widthString);
-
- if (hasAttribute(SVGNames::heightAttr))
- target->setAttribute(SVGNames::heightAttr, heightString);
-}
-
void SVGUseElement::removeDisallowedElementsFromSubtree(Node* subtree)
{
ASSERT(!subtree->inDocument());
@@ -649,10 +688,6 @@ void SVGUseElement::buildShadowTree(SVGShadowTreeRootElement* shadowRoot, SVGEle
ExceptionCode ec = 0;
shadowRoot->appendChild(newChild.release(), ec);
ASSERT(!ec);
-
- // Handle use referencing <svg> special case
- if (target->hasTagName(SVGNames::svgTag))
- alterShadowTreeForSVGTag(newChildPtr);
}
#if ENABLE(SVG) && ENABLE(SVG_USE)
@@ -719,10 +754,6 @@ void SVGUseElement::expandUseElementsInShadowTree(SVGShadowTreeRootElement* shad
use->parentNode()->replaceChild(cloneParent.release(), use, ec);
ASSERT(!ec);
- // Handle use referencing <svg> special case
- if (target->hasTagName(SVGNames::svgTag))
- alterShadowTreeForSVGTag(newChildPtr);
-
// Immediately stop here, and restart expanding.
expandUseElementsInShadowTree(shadowRoot, shadowRoot);
return;
@@ -747,16 +778,8 @@ void SVGUseElement::expandSymbolElementsInShadowTree(SVGShadowTreeRootElement* s
// Transfer all attributes from <symbol> to the new <svg> element
svgElement->attributes()->setAttributes(*element->attributes());
- // Explicitly re-set width/height values
- String widthString = String::number(width().value(this));
- String heightString = String::number(height().value(this));
-
- svgElement->setAttribute(SVGNames::widthAttr, hasAttribute(SVGNames::widthAttr) ? widthString : "100%");
- svgElement->setAttribute(SVGNames::heightAttr, hasAttribute(SVGNames::heightAttr) ? heightString : "100%");
-
- ExceptionCode ec = 0;
-
// Only clone symbol children, and add them to the new <svg> element
+ ExceptionCode ec = 0;
for (Node* child = element->firstChild(); child; child = child->nextSibling()) {
RefPtr<Node> newChild = child->cloneNode(true);
svgElement->appendChild(newChild.release(), ec);
diff --git a/WebCore/svg/SVGUseElement.h b/WebCore/svg/SVGUseElement.h
index a24bcdd..8f8a51b 100644
--- a/WebCore/svg/SVGUseElement.h
+++ b/WebCore/svg/SVGUseElement.h
@@ -93,7 +93,6 @@ namespace WebCore {
void handleDeepUseReferencing(SVGUseElement* use, SVGElementInstance* targetInstance, bool& foundCycle);
// Shadow tree handling
- void alterShadowTreeForSVGTag(SVGElement*);
void buildShadowTree(SVGShadowTreeRootElement*, SVGElement* target, SVGElementInstance* targetInstance);
#if ENABLE(SVG) && ENABLE(SVG_USE)
@@ -107,7 +106,9 @@ namespace WebCore {
void transferUseAttributesToReplacedElement(SVGElement* from, SVGElement* to) const;
void transferEventListenersToShadowTree(SVGElementInstance* target);
+
void updateContainerOffsets();
+ void updateContainerSizes();
bool m_isPendingResource;
bool m_needsShadowTreeRecreation;
@@ -115,7 +116,7 @@ namespace WebCore {
RefPtr<SVGElementInstance> m_targetElementInstance;
};
-} // namespace WebCore
+}
-#endif // ENABLE(SVG)
+#endif
#endif
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list