[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
zimmermann at webkit.org
zimmermann at webkit.org
Wed Dec 22 11:10:17 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 886791b23fea262479fb88d78bbb9f8c090005e3
Author: zimmermann at webkit.org <zimmermann at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Jul 14 09:39:25 2010 +0000
2010-07-14 Nikolas Zimmermann <nzimmermann at rim.com>
Reviewed by Eric Seidel.
SVG patterns and masks should not be able to reference themselves
https://bugs.webkit.org/show_bug.cgi?id=32171
Don't apply pattern/mask resources, if they contain cyclic references. Gradients/Filters are not affected.
Clippers are already correcly handling this on their own, as well as markers (all which require subtle quirks, covered by existing tests).
Tests: svg/custom/recursive-filter.svg
svg/custom/recursive-gradient.svg
svg/custom/recursive-mask.svg
svg/custom/recursive-pattern.svg
* rendering/RenderSVGResourceContainer.h:
(WebCore::RenderSVGResourceContainer::RenderSVGResourceContainer): Stop using idForStyleResolution(), but use getIdAttribute(), no functional change though.
(WebCore::RenderSVGResourceContainer::idChanged): Ditto.
(WebCore::RenderSVGResourceContainer::childElementReferencesResource): To be implemented by classes inheriting from us. Defaults to false.
(WebCore::RenderSVGResourceContainer::containsCyclicReference): Check whether this resource contains contains a child which references ourselves.
* rendering/RenderSVGResourceMasker.cpp:
(WebCore::RenderSVGResourceMasker::childElementReferencesResource): Check whether the masker child specifies mask=".." with the same URI than ourselves.
(WebCore::RenderSVGResourceMasker::applyResource): Early exit if we contain a cylic reference.
* rendering/RenderSVGResourceMasker.h:
* rendering/RenderSVGResourcePattern.cpp:
(WebCore::RenderSVGResourcePattern::childElementReferencesResource): Check whether the masker child specifies fill=".." with the same URI than ourselves.
(WebCore::RenderSVGResourcePattern::applyResource): Early exit if we contain a cylic reference.
* rendering/RenderSVGResourcePattern.h:
* svg/SVGPaint.cpp:
(WebCore::SVGPaint::matchesTargetURI): Add new helper function comparing a SVGPaint URI with a given reference id.
* svg/SVGPaint.h:
2010-07-14 Nikolas Zimmermann <nzimmermann at rim.com>
Reviewed by Eric Seidel.
SVG patterns and masks should not be able to reference themselves
https://bugs.webkit.org/show_bug.cgi?id=32171
Add new layout tests covering recursion in pattern/mask/gradient/filter. Nothing crashing anymore.
* platform/mac/svg/custom/recursive-filter-expected.checksum: Added.
* platform/mac/svg/custom/recursive-filter-expected.png: Added.
* platform/mac/svg/custom/recursive-filter-expected.txt: Added.
* platform/mac/svg/custom/recursive-gradient-expected.checksum: Added.
* platform/mac/svg/custom/recursive-gradient-expected.png: Added.
* platform/mac/svg/custom/recursive-gradient-expected.txt: Added.
* platform/mac/svg/custom/recursive-mask-expected.checksum: Added.
* platform/mac/svg/custom/recursive-mask-expected.png: Added.
* platform/mac/svg/custom/recursive-mask-expected.txt: Added.
* platform/mac/svg/custom/recursive-pattern-expected.checksum: Added.
* platform/mac/svg/custom/recursive-pattern-expected.png: Added.
* platform/mac/svg/custom/recursive-pattern-expected.txt: Added.
* svg/custom/recursive-filter.svg: Added.
* svg/custom/recursive-gradient.svg: Added.
* svg/custom/recursive-mask.svg: Added.
* svg/custom/recursive-pattern.svg: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63300 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 87502db..c5ee8a7 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,29 @@
+2010-07-14 Nikolas Zimmermann <nzimmermann at rim.com>
+
+ Reviewed by Eric Seidel.
+
+ SVG patterns and masks should not be able to reference themselves
+ https://bugs.webkit.org/show_bug.cgi?id=32171
+
+ Add new layout tests covering recursion in pattern/mask/gradient/filter. Nothing crashing anymore.
+
+ * platform/mac/svg/custom/recursive-filter-expected.checksum: Added.
+ * platform/mac/svg/custom/recursive-filter-expected.png: Added.
+ * platform/mac/svg/custom/recursive-filter-expected.txt: Added.
+ * platform/mac/svg/custom/recursive-gradient-expected.checksum: Added.
+ * platform/mac/svg/custom/recursive-gradient-expected.png: Added.
+ * platform/mac/svg/custom/recursive-gradient-expected.txt: Added.
+ * platform/mac/svg/custom/recursive-mask-expected.checksum: Added.
+ * platform/mac/svg/custom/recursive-mask-expected.png: Added.
+ * platform/mac/svg/custom/recursive-mask-expected.txt: Added.
+ * platform/mac/svg/custom/recursive-pattern-expected.checksum: Added.
+ * platform/mac/svg/custom/recursive-pattern-expected.png: Added.
+ * platform/mac/svg/custom/recursive-pattern-expected.txt: Added.
+ * svg/custom/recursive-filter.svg: Added.
+ * svg/custom/recursive-gradient.svg: Added.
+ * svg/custom/recursive-mask.svg: Added.
+ * svg/custom/recursive-pattern.svg: Added.
+
2010-07-14 Yuta Kitamura <yutak at chromium.org>
Reviewed by Alexey Proskuryakov.
diff --git a/LayoutTests/platform/mac/svg/custom/recursive-filter-expected.checksum b/LayoutTests/platform/mac/svg/custom/recursive-filter-expected.checksum
new file mode 100644
index 0000000..8c9fcbd
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/custom/recursive-filter-expected.checksum
@@ -0,0 +1 @@
+dda4f1b67cf9fb2058815ce9466326fc
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/custom/recursive-filter-expected.png b/LayoutTests/platform/mac/svg/custom/recursive-filter-expected.png
new file mode 100644
index 0000000..2634333
Binary files /dev/null and b/LayoutTests/platform/mac/svg/custom/recursive-filter-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/custom/recursive-filter-expected.txt b/LayoutTests/platform/mac/svg/custom/recursive-filter-expected.txt
new file mode 100644
index 0000000..c3d7c3f
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/custom/recursive-filter-expected.txt
@@ -0,0 +1,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 111x210
+ RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+ RenderSVGResourceFilter {filter} [id="filter1"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
+ [feGaussianBlur stdDeviation="4.00, 4.00"]
+ [SourceGraphic]
+ RenderSVGResourceFilter {filter} [id="filter2"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
+ RenderPath {rect} at (0,0) size 111x111 [stroke={[type=SOLID] [color=#008000]}] [fill={[type=SOLID] [color=#0000FF]}] [data="M0.00,0.00 L100.00,0.00 L100.00,100.00 L0.00,100.00 Z"]
+ [filter="filter1"] RenderSVGResourceFilter {filter} at (-10,-10) size 120x120
+ RenderPath {rect} at (0,90) size 111x120 [stroke={[type=SOLID] [color=#008000]}] [fill={[type=SOLID] [color=#0000FF]}] [data="M0.00,100.00 L100.00,100.00 L100.00,200.00 L0.00,200.00 Z"]
+ [filter="filter2"] RenderSVGResourceFilter {filter} at (-10,90) size 120x120
diff --git a/LayoutTests/platform/mac/svg/custom/recursive-gradient-expected.checksum b/LayoutTests/platform/mac/svg/custom/recursive-gradient-expected.checksum
new file mode 100644
index 0000000..15263c7
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/custom/recursive-gradient-expected.checksum
@@ -0,0 +1 @@
+57e9077e7ffd8d9acdc6ef9a92e6d3d6
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/custom/recursive-gradient-expected.png b/LayoutTests/platform/mac/svg/custom/recursive-gradient-expected.png
new file mode 100644
index 0000000..0fbe75b
Binary files /dev/null and b/LayoutTests/platform/mac/svg/custom/recursive-gradient-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/custom/recursive-gradient-expected.txt b/LayoutTests/platform/mac/svg/custom/recursive-gradient-expected.txt
new file mode 100644
index 0000000..d2ce098
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/custom/recursive-gradient-expected.txt
@@ -0,0 +1,9 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderSVGRoot {svg} at (0,0) size 101x101
+ RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+ RenderSVGResourceRadialGradient {radialGradient} [id="gradient1"] [gradientUnits=objectBoundingBox] [center=(0.50,0.50)] [focal=(0.15,0.15)] [radius=0.50]
+ RenderSVGGradientStop {stop} [offset=0.00] [color=#0000FF]
+ RenderSVGGradientStop {stop} [offset=1.00] [color=#FF0000]
+ RenderPath {rect} at (0,0) size 101x101 [stroke={[type=SOLID] [color=#008000]}] [fill={[type=RADIAL-GRADIENT] [id="gradient1"]}] [data="M0.00,0.00 L100.00,0.00 L100.00,100.00 L0.00,100.00 Z"]
diff --git a/LayoutTests/platform/mac/svg/custom/recursive-mask-expected.checksum b/LayoutTests/platform/mac/svg/custom/recursive-mask-expected.checksum
new file mode 100644
index 0000000..724c7ee
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/custom/recursive-mask-expected.checksum
@@ -0,0 +1 @@
+7f078b4f3971b046bbab30231bfb350c
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/custom/recursive-mask-expected.png b/LayoutTests/platform/mac/svg/custom/recursive-mask-expected.png
new file mode 100644
index 0000000..12349fa
Binary files /dev/null and b/LayoutTests/platform/mac/svg/custom/recursive-mask-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/custom/recursive-mask-expected.txt b/LayoutTests/platform/mac/svg/custom/recursive-mask-expected.txt
new file mode 100644
index 0000000..1dc7839
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/custom/recursive-mask-expected.txt
@@ -0,0 +1,21 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderSVGRoot {svg} at (0,0) size 150x50
+ RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+ RenderSVGResourceMasker {mask} [id="mask1"] [maskUnits=objectBoundingBox] [maskContentUnits=userSpaceOnUse]
+ RenderPath {rect} at (0,0) size 50x50 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M0.00,0.00 L50.00,0.00 L50.00,50.00 L0.00,50.00 Z"]
+ RenderSVGResourceMasker {mask} [id="mask2"] [maskUnits=objectBoundingBox] [maskContentUnits=userSpaceOnUse]
+ RenderPath {rect} at (100,0) size 50x50 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M100.00,0.00 L150.00,0.00 L150.00,50.00 L100.00,50.00 Z"]
+ [masker="mask2"] RenderSVGResourceMasker {mask} at (100,0) size 50x50
+ RenderSVGResourceMasker {mask} [id="mask3"] [maskUnits=objectBoundingBox] [maskContentUnits=userSpaceOnUse]
+ RenderPath {rect} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M0.00,100.00 L50.00,100.00 L50.00,150.00 L0.00,150.00 Z"]
+ [masker="mask1"] RenderSVGResourceMasker {mask} at (0,0) size 0x0
+ RenderPath {rect} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M100.00,100.00 L150.00,100.00 L150.00,150.00 L100.00,150.00 Z"]
+ [masker="mask2"] RenderSVGResourceMasker {mask} at (0,0) size 0x0
+ RenderPath {rect} at (0,0) size 50x50 [stroke={[type=SOLID] [color=#008000]}] [fill={[type=SOLID] [color=#0000FF]}] [data="M0.00,0.00 L100.00,0.00 L100.00,100.00 L0.00,100.00 Z"]
+ [masker="mask1"] RenderSVGResourceMasker {mask} at (0,0) size 50x50
+ RenderPath {rect} at (100,0) size 50x50 [stroke={[type=SOLID] [color=#008000]}] [fill={[type=SOLID] [color=#0000FF]}] [data="M100.00,0.00 L200.00,0.00 L200.00,100.00 L100.00,100.00 Z"]
+ [masker="mask2"] RenderSVGResourceMasker {mask} at (100,0) size 50x50
+ RenderPath {rect} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#008000]}] [fill={[type=SOLID] [color=#0000FF]}] [data="M100.00,100.00 L200.00,100.00 L200.00,200.00 L100.00,200.00 Z"]
+ [masker="mask3"] RenderSVGResourceMasker {mask} at (0,0) size 0x0
diff --git a/LayoutTests/platform/mac/svg/custom/recursive-pattern-expected.checksum b/LayoutTests/platform/mac/svg/custom/recursive-pattern-expected.checksum
new file mode 100644
index 0000000..78df2b3
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/custom/recursive-pattern-expected.checksum
@@ -0,0 +1 @@
+4de93deb4103eaf64c73e4c897f42cf5
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/custom/recursive-pattern-expected.png b/LayoutTests/platform/mac/svg/custom/recursive-pattern-expected.png
new file mode 100644
index 0000000..cec57e5
Binary files /dev/null and b/LayoutTests/platform/mac/svg/custom/recursive-pattern-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/custom/recursive-pattern-expected.txt b/LayoutTests/platform/mac/svg/custom/recursive-pattern-expected.txt
new file mode 100644
index 0000000..981b956
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/custom/recursive-pattern-expected.txt
@@ -0,0 +1,15 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderSVGRoot {svg} at (0,0) size 201x201
+ RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+ RenderSVGResourcePattern {pattern} [id="pattern1"] [patternUnits=objectBoundingBox] [patternContentUnits=userSpaceOnUse]
+ RenderPath {rect} at (0,0) size 100x100 [fill={[type=PATTERN] [id="pattern1"]}] [data="M0.00,0.00 L100.00,0.00 L100.00,100.00 L0.00,100.00 Z"]
+ RenderSVGResourcePattern {pattern} [id="pattern2"] [patternUnits=objectBoundingBox] [patternContentUnits=userSpaceOnUse]
+ RenderPath {rect} at (0,0) size 100x100 [fill={[type=PATTERN] [id="pattern1"]}] [data="M0.00,0.00 L100.00,0.00 L100.00,100.00 L0.00,100.00 Z"]
+ RenderSVGResourcePattern {pattern} [id="pattern3"] [patternUnits=objectBoundingBox] [patternContentUnits=userSpaceOnUse]
+ RenderSVGResourcePattern {pattern} [id="pattern4"] [patternUnits=objectBoundingBox] [patternContentUnits=userSpaceOnUse]
+ RenderPath {rect} at (0,0) size 101x101 [stroke={[type=SOLID] [color=#008000]}] [fill={[type=PATTERN] [id="pattern1"]}] [data="M0.00,0.00 L100.00,0.00 L100.00,100.00 L0.00,100.00 Z"]
+ RenderPath {rect} at (0,99) size 101x102 [stroke={[type=SOLID] [color=#008000]}] [fill={[type=PATTERN] [id="pattern2"]}] [data="M0.00,100.00 L100.00,100.00 L100.00,200.00 L0.00,200.00 Z"]
+ RenderPath {rect} at (99,0) size 102x101 [stroke={[type=SOLID] [color=#008000]}] [fill={[type=PATTERN] [id="pattern3"]}] [data="M100.00,0.00 L200.00,0.00 L200.00,100.00 L100.00,100.00 Z"]
+ RenderPath {rect} at (99,99) size 102x102 [stroke={[type=SOLID] [color=#008000]}] [fill={[type=PATTERN] [id="pattern4"]}] [data="M100.00,100.00 L200.00,100.00 L200.00,200.00 L100.00,200.00 Z"]
diff --git a/LayoutTests/svg/custom/recursive-filter.svg b/LayoutTests/svg/custom/recursive-filter.svg
new file mode 100644
index 0000000..7b4e617
--- /dev/null
+++ b/LayoutTests/svg/custom/recursive-filter.svg
@@ -0,0 +1,15 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<defs>
+ <filter id="filter1" filter="url(#filter1)">
+ <feGaussianBlur stdDeviation="4"/>
+ </filter>
+
+ <filter id="filter2" xlink:href="#filter2"/>
+</defs>
+
+<!-- This should be blurred -->
+<rect x="0" y="0" width="100" height="100" filter="url(#filter1)" fill="blue" stroke="green"/>
+
+<!-- This should not crash and not render anything -->
+<rect x="0" y="100" width="100" height="100" filter="url(#filter2)" fill="blue" stroke="green"/>
+</svg>
diff --git a/LayoutTests/svg/custom/recursive-gradient.svg b/LayoutTests/svg/custom/recursive-gradient.svg
new file mode 100644
index 0000000..40b3b5b
--- /dev/null
+++ b/LayoutTests/svg/custom/recursive-gradient.svg
@@ -0,0 +1,11 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<defs>
+ <radialGradient xlink:href="#gradient1" id="gradient1" gradientUnits="objectBoundingBox" cx=".5" cy=".5" fx=".5" fy=".5" r=".5">
+ <stop stop-color="blue" offset="0"/>
+ <stop stop-color="red" offset="1"/>
+ </radialGradient>
+</defs>
+
+<!-- This should not crash -->
+<rect x="0" y="0" width="100" height="100" fill="url(#gradient1)" stroke="green"/>
+</svg>
diff --git a/LayoutTests/svg/custom/recursive-mask.svg b/LayoutTests/svg/custom/recursive-mask.svg
new file mode 100644
index 0000000..89387f8
--- /dev/null
+++ b/LayoutTests/svg/custom/recursive-mask.svg
@@ -0,0 +1,26 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<defs>
+ <mask id="mask1" mask="url(#mask1)">
+ <rect width="50" height="50" fill="white"/>
+ </mask>
+
+ <mask id="mask2">
+ <rect x="100" width="50" height="50" fill="white" mask="url(#mask2)"/>
+ </mask>
+
+ <mask id="mask3">
+ <rect x="0" y="100" width="50" height="50" fill="white" mask="url(#mask1)"/>
+ <rect x="100" y="100" width="50" height="50" fill="white" mask="url(#mask2)"/>
+ </mask>
+</defs>
+
+<!-- This should be masked, resulting in a 50x50 rect -->
+<rect x="0" y="0" width="100" height="100" fill="blue" mask="url(#mask1)" stroke="green"/>
+
+<!-- This should not render anything -->
+<rect x="100" y="0" width="100" height="100" fill="blue" mask="url(#mask2)" stroke="green"/>
+
+<!-- This should not render anything -->
+<rect x="100" y="100" width="100" height="100" fill="blue" mask="url(#mask3)" stroke="green"/>
+
+</svg>
diff --git a/LayoutTests/svg/custom/recursive-pattern.svg b/LayoutTests/svg/custom/recursive-pattern.svg
new file mode 100644
index 0000000..95caaaa
--- /dev/null
+++ b/LayoutTests/svg/custom/recursive-pattern.svg
@@ -0,0 +1,20 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<defs>
+ <pattern id="pattern1" x="0" y="0" width="100" height="100">
+ <rect x="0" y="0" width="100" height="100" fill="url(#pattern1)"/>
+ </pattern>
+
+ <pattern id="pattern2" x="0" y="0" width="100" height="100">
+ <rect x="0" y="0" width="100" height="100" fill="url(#pattern1)"/>
+ </pattern>
+
+ <pattern id="pattern3" x="0" y="0" width="100" height="100" xlink:href="#pattern1"/>
+ <pattern id="pattern4" x="0" y="0" width="100" height="100" xlink:href="#pattern2"/>
+</defs>
+
+<!-- This should not crash -->
+<rect x="0" y="0" width="100" height="100" fill="url(#pattern1)" stroke="green"/>
+<rect x="0" y="100" width="100" height="100" fill="url(#pattern2)" stroke="green"/>
+<rect x="100" y="0" width="100" height="100" fill="url(#pattern3)" stroke="green"/>
+<rect x="100" y="100" width="100" height="100" fill="url(#pattern4)" stroke="green"/>
+</svg>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ee79516..888c402 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,35 @@
+2010-07-14 Nikolas Zimmermann <nzimmermann at rim.com>
+
+ Reviewed by Eric Seidel.
+
+ SVG patterns and masks should not be able to reference themselves
+ https://bugs.webkit.org/show_bug.cgi?id=32171
+
+ Don't apply pattern/mask resources, if they contain cyclic references. Gradients/Filters are not affected.
+ Clippers are already correcly handling this on their own, as well as markers (all which require subtle quirks, covered by existing tests).
+
+ Tests: svg/custom/recursive-filter.svg
+ svg/custom/recursive-gradient.svg
+ svg/custom/recursive-mask.svg
+ svg/custom/recursive-pattern.svg
+
+ * rendering/RenderSVGResourceContainer.h:
+ (WebCore::RenderSVGResourceContainer::RenderSVGResourceContainer): Stop using idForStyleResolution(), but use getIdAttribute(), no functional change though.
+ (WebCore::RenderSVGResourceContainer::idChanged): Ditto.
+ (WebCore::RenderSVGResourceContainer::childElementReferencesResource): To be implemented by classes inheriting from us. Defaults to false.
+ (WebCore::RenderSVGResourceContainer::containsCyclicReference): Check whether this resource contains contains a child which references ourselves.
+ * rendering/RenderSVGResourceMasker.cpp:
+ (WebCore::RenderSVGResourceMasker::childElementReferencesResource): Check whether the masker child specifies mask=".." with the same URI than ourselves.
+ (WebCore::RenderSVGResourceMasker::applyResource): Early exit if we contain a cylic reference.
+ * rendering/RenderSVGResourceMasker.h:
+ * rendering/RenderSVGResourcePattern.cpp:
+ (WebCore::RenderSVGResourcePattern::childElementReferencesResource): Check whether the masker child specifies fill=".." with the same URI than ourselves.
+ (WebCore::RenderSVGResourcePattern::applyResource): Early exit if we contain a cylic reference.
+ * rendering/RenderSVGResourcePattern.h:
+ * svg/SVGPaint.cpp:
+ (WebCore::SVGPaint::matchesTargetURI): Add new helper function comparing a SVGPaint URI with a given reference id.
+ * svg/SVGPaint.h:
+
2010-07-14 Eric Seidel <eric at webkit.org>
Reviewed by Nikolas Zimmermann.
diff --git a/WebCore/rendering/RenderSVGResourceContainer.h b/WebCore/rendering/RenderSVGResourceContainer.h
index 54617bb..06c5280 100644
--- a/WebCore/rendering/RenderSVGResourceContainer.h
+++ b/WebCore/rendering/RenderSVGResourceContainer.h
@@ -35,8 +35,7 @@ public:
RenderSVGResourceContainer(SVGStyledElement* node)
: RenderSVGHiddenContainer(node)
, RenderSVGResource()
- // FIXME: Should probably be using getIdAttribute rather than idForStyleResolution.
- , m_id(node->hasID() ? node->idForStyleResolution() : nullAtom)
+ , m_id(node->hasID() ? node->getIdAttribute() : nullAtom)
{
ASSERT(node->document());
node->document()->accessSVGExtensions()->addResource(m_id, this);
@@ -57,9 +56,7 @@ public:
// Remove old id, that is guaranteed to be present in cache
extensions->removeResource(m_id);
-
- // FIXME: Should probably be using getIdAttribute rather than idForStyleResolution.
- m_id = node()->hasID() ? static_cast<Element*>(node())->idForStyleResolution() : nullAtom;
+ m_id = static_cast<Element*>(node())->getIdAttribute();
// It's possible that an element is referencing us with the new id, and has to be notified that we're existing now
if (extensions->isPendingResource(m_id)) {
@@ -84,7 +81,8 @@ public:
virtual bool drawsContents() { return false; }
virtual RenderSVGResourceContainer* toRenderSVGResourceContainer() { return this; }
-
+ virtual bool childElementReferencesResource(const SVGRenderStyle*, const String&) const { return false; }
+
static AffineTransform transformOnNonScalingStroke(RenderObject* object, const AffineTransform resourceTransform)
{
if (!object->isRenderPath())
@@ -96,6 +94,39 @@ public:
return transform;
}
+ bool containsCyclicReference(const Node* startNode) const
+ {
+ Document* document = startNode->document();
+ ASSERT(document);
+
+ for (Node* node = startNode->firstChild(); node; node = node->nextSibling()) {
+ if (!node->isSVGElement())
+ continue;
+
+ RenderObject* renderer = node->renderer();
+ if (!renderer)
+ continue;
+
+ RenderStyle* style = renderer->style();
+ if (!style)
+ continue;
+
+ const SVGRenderStyle* svgStyle = style->svgStyle();
+ ASSERT(svgStyle);
+
+ // Let the class inheriting from us decide whether the child element references ourselves.
+ if (childElementReferencesResource(svgStyle, m_id))
+ return true;
+
+ if (node->hasChildNodes()) {
+ if (containsCyclicReference(node))
+ return true;
+ }
+ }
+
+ return false;
+ }
+
private:
AtomicString m_id;
};
diff --git a/WebCore/rendering/RenderSVGResourceMasker.cpp b/WebCore/rendering/RenderSVGResourceMasker.cpp
index 74d3fe6..352ea56 100644
--- a/WebCore/rendering/RenderSVGResourceMasker.cpp
+++ b/WebCore/rendering/RenderSVGResourceMasker.cpp
@@ -84,6 +84,14 @@ void RenderSVGResourceMasker::invalidateClient(RenderObject* object)
markForLayoutAndResourceInvalidation(object);
}
+bool RenderSVGResourceMasker::childElementReferencesResource(const SVGRenderStyle* style, const String& referenceId) const
+{
+ if (!style->hasMasker())
+ return false;
+
+ return style->maskerResource() == referenceId;
+}
+
bool RenderSVGResourceMasker::applyResource(RenderObject* object, RenderStyle*, GraphicsContext*& context, unsigned short resourceMode)
{
ASSERT(object);
@@ -103,6 +111,10 @@ bool RenderSVGResourceMasker::applyResource(RenderObject* object, RenderStyle*,
if (!maskElement)
return false;
+ // Early exit, if this resource contains a child which references ourselves.
+ if (containsCyclicReference(node()))
+ return false;
+
createMaskImage(maskerData, maskElement, object);
}
diff --git a/WebCore/rendering/RenderSVGResourceMasker.h b/WebCore/rendering/RenderSVGResourceMasker.h
index f6301cb..56f657b 100644
--- a/WebCore/rendering/RenderSVGResourceMasker.h
+++ b/WebCore/rendering/RenderSVGResourceMasker.h
@@ -69,6 +69,8 @@ private:
void createMaskImage(MaskerData*, const SVGMaskElement*, RenderObject*);
void calculateMaskContentRepaintRect();
+ virtual bool childElementReferencesResource(const SVGRenderStyle*, const String&) const;
+
FloatRect m_maskBoundaries;
HashMap<RenderObject*, MaskerData*> m_masker;
};
diff --git a/WebCore/rendering/RenderSVGResourcePattern.cpp b/WebCore/rendering/RenderSVGResourcePattern.cpp
index ba24fcf..b783705 100644
--- a/WebCore/rendering/RenderSVGResourcePattern.cpp
+++ b/WebCore/rendering/RenderSVGResourcePattern.cpp
@@ -69,6 +69,21 @@ void RenderSVGResourcePattern::invalidateClient(RenderObject* object)
markForLayoutAndResourceInvalidation(object);
}
+bool RenderSVGResourcePattern::childElementReferencesResource(const SVGRenderStyle* style, const String& referenceId) const
+{
+ if (style->hasFill()) {
+ if (style->fillPaint()->matchesTargetURI(referenceId))
+ return true;
+ }
+
+ if (style->hasStroke()) {
+ if (style->strokePaint()->matchesTargetURI(referenceId))
+ return true;
+ }
+
+ return false;
+}
+
bool RenderSVGResourcePattern::applyResource(RenderObject* object, RenderStyle* style, GraphicsContext*& context, unsigned short resourceMode)
{
ASSERT(object);
@@ -91,6 +106,9 @@ bool RenderSVGResourcePattern::applyResource(RenderObject* object, RenderStyle*
PatternData* patternData = m_pattern.get(object);
if (!patternData->pattern) {
+ // Early exit, if this resource contains a child which references ourselves.
+ if (containsCyclicReference(node()))
+ return false;
// Create tile image
OwnPtr<ImageBuffer> tileImage = createTileImage(patternData, patternElement, object);
diff --git a/WebCore/rendering/RenderSVGResourcePattern.h b/WebCore/rendering/RenderSVGResourcePattern.h
index 690b0de..ec89777 100644
--- a/WebCore/rendering/RenderSVGResourcePattern.h
+++ b/WebCore/rendering/RenderSVGResourcePattern.h
@@ -67,6 +67,8 @@ private:
FloatRect calculatePatternBoundariesIncludingOverflow(PatternAttributes&, const FloatRect& objectBoundingBox,
const AffineTransform& viewBoxCTM, const FloatRect& patternBoundaries) const;
+ virtual bool childElementReferencesResource(const SVGRenderStyle*, const String&) const;
+
HashMap<RenderObject*, PatternData*> m_pattern;
};
diff --git a/WebCore/svg/SVGPaint.cpp b/WebCore/svg/SVGPaint.cpp
index 82a5fe4..6d60979 100644
--- a/WebCore/svg/SVGPaint.cpp
+++ b/WebCore/svg/SVGPaint.cpp
@@ -1,6 +1,7 @@
/*
- Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox at kde.org>
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann at kde.org>
2004, 2005, 2006, 2007 Rob Buis <buis at kde.org>
+ Copyright (C) Research In Motion Limited 2010. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -19,8 +20,10 @@
*/
#include "config.h"
+
#if ENABLE(SVG)
#include "SVGPaint.h"
+#include "SVGURIReference.h"
namespace WebCore {
@@ -108,8 +111,14 @@ String SVGPaint::cssText() const
return SVGColor::cssText();
}
+bool SVGPaint::matchesTargetURI(const String& referenceId)
+{
+ if (m_paintType != SVG_PAINTTYPE_URI && m_paintType != SVG_PAINTTYPE_URI_RGBCOLOR)
+ return false;
+
+ return referenceId == SVGURIReference::getTarget(m_uri);
+}
+
}
-// vim:ts=4:noet
#endif // ENABLE(SVG)
-
diff --git a/WebCore/svg/SVGPaint.h b/WebCore/svg/SVGPaint.h
index 032f715..aa696d1 100644
--- a/WebCore/svg/SVGPaint.h
+++ b/WebCore/svg/SVGPaint.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox at kde.org>
+ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann at kde.org>
2004, 2005, 2006, 2007 Rob Buis <buis at kde.org>
Copyright (C) 2006 Samuel Weinig (sam.weinig at gmial.com)
@@ -78,6 +78,8 @@ namespace WebCore {
static SVGPaint* defaultFill();
static SVGPaint* defaultStroke();
+ bool matchesTargetURI(const String& referenceId);
+
private:
SVGPaint();
SVGPaint(const String& uri);
@@ -96,5 +98,3 @@ namespace WebCore {
#endif // ENABLE(SVG)
#endif // SVGPaint_h
-
-// vim:ts=4:noet
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list