Reviewed by David.
authorzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Dec 2007 18:57:23 +0000 (18:57 +0000)
committerzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Dec 2007 18:57:23 +0000 (18:57 +0000)
Fixes: http://bugs.webkit.org/show_bug.cgi?id=15645
Don't allow selectors to interfere with the SVG shadow tree (<use> internal non-exposed tree).

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

LayoutTests/ChangeLog
LayoutTests/platform/mac/svg/custom/use-css-no-effect-on-shadow-tree-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/svg/custom/use-css-no-effect-on-shadow-tree-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/custom/use-css-no-effect-on-shadow-tree-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/use-css-no-effect-on-shadow-tree.svg [new file with mode: 0644]
WebCore/ChangeLog
WebCore/css/CSSStyleSelector.cpp

index c90653a..c51f496 100644 (file)
@@ -1,5 +1,16 @@
 2007-12-03  Nikolas Zimmermann  <zimmermann@kde.org>
 
+        Reviewed by David.
+
+        Add new testcase verifying that CSS selectors don't affect the non-exposed SVG shadow tree.
+
+        * platform/mac/svg/custom/use-css-no-effect-on-shadow-tree-expected.checksum: Added.
+        * platform/mac/svg/custom/use-css-no-effect-on-shadow-tree-expected.png: Added.
+        * platform/mac/svg/custom/use-css-no-effect-on-shadow-tree-expected.txt: Added.
+        * svg/custom/use-css-no-effect-on-shadow-tree.svg: Added.
+
+2007-12-03  Nikolas Zimmermann  <zimmermann@kde.org>
+
         Rubber stamped by Mark.
 
         Commit missing layout test results from my last commit (fix for bug 15403)
diff --git a/LayoutTests/platform/mac/svg/custom/use-css-no-effect-on-shadow-tree-expected.checksum b/LayoutTests/platform/mac/svg/custom/use-css-no-effect-on-shadow-tree-expected.checksum
new file mode 100644 (file)
index 0000000..0ab60f0
--- /dev/null
@@ -0,0 +1 @@
+bc0f6d15f6cc84da243f2e6c41b44ccb
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/custom/use-css-no-effect-on-shadow-tree-expected.png b/LayoutTests/platform/mac/svg/custom/use-css-no-effect-on-shadow-tree-expected.png
new file mode 100644 (file)
index 0000000..d168162
Binary files /dev/null and b/LayoutTests/platform/mac/svg/custom/use-css-no-effect-on-shadow-tree-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/custom/use-css-no-effect-on-shadow-tree-expected.txt b/LayoutTests/platform/mac/svg/custom/use-css-no-effect-on-shadow-tree-expected.txt
new file mode 100644 (file)
index 0000000..058a451
--- /dev/null
@@ -0,0 +1,11 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 453x113
+  RenderSVGRoot {svg} at (-0.06,-0.56) size 453.13x114.13
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+      RenderPath {path} at (300,49.50) size 600.50x201 [stroke={[type=SOLID] [color=#FF0000] [opacity=0.50] [miter limit=10.00] [line join=BEVEL] [dash array={300.00, 100.00}]}] [fill={[type=SOLID] [color=#000000]}] [data="M300.00,50.00L900.00,50.00L900.00,250.00L300.00,250.00"]
+    RenderPath {rect} at (-0.06,-0.56) size 453.13x114.13 [stroke={[type=SOLID] [color=#0000FF] [stroke width=3.00]}] [data="M0.00,0.00L1200.00,0.00L1200.00,300.00L0.00,300.00"]
+    RenderSVGContainer {g} at (105.97,11.30) size 241.07x90.40
+      RenderSVGContainer {use} at (105.97,11.30) size 241.07x90.40
+        RenderSVGContainer {g} at (105.97,11.30) size 241.07x90.40
+          RenderPath {path} at (105.97,11.30) size 241.07x90.40 [stroke={[type=SOLID] [color=#FF0000] [opacity=0.50] [stroke width=40.00] [line cap=ROUND] [line join=BEVEL] [dash offset=50.00] [dash array={300.00, 100.00}]}] [fill={[type=SOLID] [color=#0000FF] [opacity=0.50]}] [data="M300.00,50.00L900.00,50.00L900.00,250.00L300.00,250.00"]
diff --git a/LayoutTests/svg/custom/use-css-no-effect-on-shadow-tree.svg b/LayoutTests/svg/custom/use-css-no-effect-on-shadow-tree.svg
new file mode 100644 (file)
index 0000000..380ee2a
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
+  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg width="12cm" height="3cm" viewBox="0 0 1200 300" version="1.1"
+     xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+  <desc>Example Use04 - 'use' with CSS styling</desc>
+  <defs style=" /* rule 9 */ stroke-miterlimit: 10" >
+    <path id="MyPath" d="M300 50 L900 50 L900 250 L300 250"
+                     class="MyPathClass"
+                     style=" /* rule 10 */ stroke-dasharray:300,100" />
+  </defs>
+  <style type="text/css">
+    <![CDATA[
+      /* rule 1 */ #MyUse { fill: blue }
+      /* rule 2 */ #MyPath { stroke: red }
+      /* rule 3 */ use { fill-opacity: .5 }
+      /* rule 4 */ path { stroke-opacity: .5 }
+      /* rule 5 */ .MyUseClass { stroke-linecap: round }
+      /* rule 6 */ .MyPathClass { stroke-linejoin: bevel }
+      /* rule 7 */ use > path { shape-rendering: optimizeQuality }
+      /* rule 8 */ g > path { visibility: hidden }
+    ]]>
+  </style>
+
+  <rect x="0" y="0" width="1200" height="300"
+         style="fill:none; stroke:blue; stroke-width:3"/>
+  <g style=" /* rule 11 */ stroke-width:40">
+    <use id="MyUse" xlink:href="#MyPath" 
+         class="MyUseClass"
+         style="/* rule 12 */ stroke-dashoffset:50" />
+  </g>
+</svg>
index b0f1252..9a0eb9f 100644 (file)
@@ -1,3 +1,13 @@
+2007-12-03  Nikolas Zimmermann  <zimmermann@kde.org>
+
+        Reviewed by David.
+
+        Fixes: http://bugs.webkit.org/show_bug.cgi?id=15645
+        Don't allow selectors to interfere with the SVG shadow tree (<use> internal non-exposed tree).
+
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::checkSelector):
+
 2007-12-03  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Adam Roben.
index 72742ac..6ffe4e8 100644 (file)
@@ -1252,7 +1252,8 @@ bool CSSStyleSelector::checkSelector(CSSSelector* sel)
 
     // Check the selector
     SelectorMatch match = checkSelector(sel, element, true, false);
-    if (match != SelectorMatches) return false;
+    if (match != SelectorMatches)
+        return false;
 
     if (pseudoStyle != RenderStyle::NOPSEUDO && pseudoStyle != dynamicPseudo)
         return false;
@@ -1265,8 +1266,15 @@ bool CSSStyleSelector::checkSelector(CSSSelector* sel)
 // * SelectorMatches         - the selector matches the element e
 // * SelectorFailsLocally    - the selector fails for the element e
 // * SelectorFailsCompletely - the selector fails for e and any sibling or ancestor of e
-CSSStyleSelector::SelectorMatch CSSStyleSelector::checkSelector(CSSSelector* sel, Element *e, bool isAncestor, bool isSubSelector)
+CSSStyleSelector::SelectorMatch CSSStyleSelector::checkSelector(CSSSelector* sel, Elemente, bool isAncestor, bool isSubSelector)
 {
+#if ENABLE(SVG)
+    // Spec: CSS2 selectors cannot be applied to the (conceptually) cloned DOM tree
+    // because its contents are not part of the formal document structure.
+    if (e->isSVGElement() && e->isShadowNode())
+        return SelectorFailsCompletely;
+#endif
+
     // first selector has to match
     if (!checkOneSelector(sel, e, isAncestor, isSubSelector))
         return SelectorFailsLocally;
@@ -1276,7 +1284,8 @@ CSSStyleSelector::SelectorMatch CSSStyleSelector::checkSelector(CSSSelector* sel
 
     // Prepare next sel
     sel = sel->m_tagHistory;
-    if (!sel) return SelectorMatches;
+    if (!sel)
+        return SelectorMatches;
 
     if (relation != CSSSelector::SubSelector)
         // Bail-out if this selector is irrelevant for the pseudoStyle