<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[197194] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/197194">197194</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-02-26 12:58:32 -0800 (Fri, 26 Feb 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>&lt;g&gt; wrapping &lt;symbol&gt; causes display of hidden &lt;symbol&gt;
https://bugs.webkit.org/show_bug.cgi?id=154576

Patch by Said Abou-Hallawa &lt;sabouhallawa@apple.com&gt; on 2016-02-26
Reviewed by Darin Adler.
Source/WebCore:

The SVGSymbolElement is allowed in the shadow tree of an SVGUseElement
only if it subtree root element. Any descendant SVGSymbolElement should
be removed from the subtree because it is a hidden container. If the cloned
subtree includes an SVGUseElement which references an SVGSymbolElement,
the same rule will be applied to the descendant SVGUseElement. The goal
is to remove all the descendant SVGSymbolElements from the cloned target
because these SVGSymbolElements will be expanded to SVGSVGElements and
hence become visible.

* svg/SVGUseElement.cpp:
(WebCore::disassociateAndRemoveClones): A helper function which removes
cloned SVGElements and their subtrees from their parents and disassociate
them from their originals.

(WebCore::removeDisallowedElementsFromSubtree): Use disassociateAndRemoveClones().

(WebCore::removeSymbolElementsFromSubtree): Removes all the descendant
SVGSymbolElements from the cloned subtree. It does not remove the root
element itself if it is an SVGSymbolElement because this one will be
expanded to an SVGSVGElement which is exactly what we need.

(WebCore::SVGUseElement::cloneTarget): Call removeSymbolElementsFromSubtree()
to remove the descendant SVGSymbolElements from the cloned subtree before
appending it to the container shadow root.

LayoutTests:

Ensure the &lt;symbol&gt; element is not displayed when it's wrapped in a &lt;g&gt;
element and this &lt;g&gt; element is referenced by a &lt;use&gt; element.

* platform/gtk/svg/custom/use-on-g-containing-symbol-expected.png: Removed.
* platform/gtk/svg/custom/use-on-g-containing-symbol-expected.txt: Removed.
* platform/ios-simulator/svg/custom/use-on-g-containing-symbol-expected.txt: Removed.
* platform/mac/svg/custom/use-on-g-containing-symbol-expected.png: Removed.
* platform/mac/svg/custom/use-on-g-containing-symbol-expected.txt: Removed.
* platform/win/svg/custom/use-on-g-containing-symbol-expected.txt: Removed.
* svg/custom/use-on-g-containing-symbol-expected.svg: Added.
* svg/custom/use-on-g-containing-symbol.svg:
The original test was wrong. It had the following definition:
    &quot;&lt;g id='symbol'&gt;&lt;symbol&gt;...&lt;/symbol&gt;&lt;/g&gt;&quot;
And it was expecting to have the symbol drawn if the &lt;g&gt; element was
referenced like that
    &quot;&lt;use xlink:href='#symbol'/&gt;&quot;
FireFox does not render anything for this &lt;use&gt; element which is correct.
With this patch, this test failed so it had to be modified to test the right
behavior. Also it is now converted to a ref test.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestssvgcustomuseongcontainingsymbolsvg">trunk/LayoutTests/svg/custom/use-on-g-containing-symbol.svg</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoresvgSVGUseElementcpp">trunk/Source/WebCore/svg/SVGUseElement.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestssvgcustomuseongcontainingsymbolexpectedsvg">trunk/LayoutTests/svg/custom/use-on-g-containing-symbol-expected.svg</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsplatformgtksvgcustomuseongcontainingsymbolexpectedpng">trunk/LayoutTests/platform/gtk/svg/custom/use-on-g-containing-symbol-expected.png</a></li>
<li><a href="#trunkLayoutTestsplatformgtksvgcustomuseongcontainingsymbolexpectedtxt">trunk/LayoutTests/platform/gtk/svg/custom/use-on-g-containing-symbol-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorsvgcustomuseongcontainingsymbolexpectedtxt">trunk/LayoutTests/platform/ios-simulator/svg/custom/use-on-g-containing-symbol-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacsvgcustomuseongcontainingsymbolexpectedpng">trunk/LayoutTests/platform/mac/svg/custom/use-on-g-containing-symbol-expected.png</a></li>
<li><a href="#trunkLayoutTestsplatformmacsvgcustomuseongcontainingsymbolexpectedtxt">trunk/LayoutTests/platform/mac/svg/custom/use-on-g-containing-symbol-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformwinsvgcustomuseongcontainingsymbolexpectedtxt">trunk/LayoutTests/platform/win/svg/custom/use-on-g-containing-symbol-expected.txt</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (197193 => 197194)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-02-26 20:47:24 UTC (rev 197193)
+++ trunk/LayoutTests/ChangeLog        2016-02-26 20:58:32 UTC (rev 197194)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2016-02-26  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
+
+        &lt;g&gt; wrapping &lt;symbol&gt; causes display of hidden &lt;symbol&gt;
+        https://bugs.webkit.org/show_bug.cgi?id=154576
+
+        Reviewed by Darin Adler.
+
+        Ensure the &lt;symbol&gt; element is not displayed when it's wrapped in a &lt;g&gt;
+        element and this &lt;g&gt; element is referenced by a &lt;use&gt; element.
+
+        * platform/gtk/svg/custom/use-on-g-containing-symbol-expected.png: Removed.
+        * platform/gtk/svg/custom/use-on-g-containing-symbol-expected.txt: Removed.
+        * platform/ios-simulator/svg/custom/use-on-g-containing-symbol-expected.txt: Removed.
+        * platform/mac/svg/custom/use-on-g-containing-symbol-expected.png: Removed.
+        * platform/mac/svg/custom/use-on-g-containing-symbol-expected.txt: Removed.
+        * platform/win/svg/custom/use-on-g-containing-symbol-expected.txt: Removed.
+        * svg/custom/use-on-g-containing-symbol-expected.svg: Added.
+        * svg/custom/use-on-g-containing-symbol.svg:
+        The original test was wrong. It had the following definition:
+            &quot;&lt;g id='symbol'&gt;&lt;symbol&gt;...&lt;/symbol&gt;&lt;/g&gt;&quot;
+        And it was expecting to have the symbol drawn if the &lt;g&gt; element was
+        referenced like that
+            &quot;&lt;use xlink:href='#symbol'/&gt;&quot;
+        FireFox does not render anything for this &lt;use&gt; element which is correct.
+        With this patch, this test failed so it had to be modified to test the right
+        behavior. Also it is now converted to a ref test.
+
</ins><span class="cx"> 2016-02-26  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r197167.
</span></span></pre></div>
<a id="trunkLayoutTestsplatformgtksvgcustomuseongcontainingsymbolexpectedpng"></a>
<div class="binary"><h4>Deleted: trunk/LayoutTests/platform/gtk/svg/custom/use-on-g-containing-symbol-expected.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="trunkLayoutTestsplatformgtksvgcustomuseongcontainingsymbolexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/platform/gtk/svg/custom/use-on-g-containing-symbol-expected.txt (197193 => 197194)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/gtk/svg/custom/use-on-g-containing-symbol-expected.txt        2016-02-26 20:47:24 UTC (rev 197193)
+++ trunk/LayoutTests/platform/gtk/svg/custom/use-on-g-containing-symbol-expected.txt        2016-02-26 20:58:32 UTC (rev 197194)
</span><span class="lines">@@ -1,17 +0,0 @@
</span><del>-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderSVGRoot {svg} at (20,45) size 488x82
-    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
-      RenderSVGContainer {g} at (0,0) size 0x0
-        RenderSVGHiddenContainer {symbol} at (0,0) size 0x0
-          RenderSVGRect {rect} at (0,0) size 125x25 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
-    RenderSVGContainer {g} at (245,45) size 130x30 [transform={m=((1.00,0.00)(0.00,1.00)) t=(125.00,25.00)}]
-      RenderSVGRect {rect} at (245,45) size 130x30 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
-    RenderSVGText {text} at (10,45) size 244x19 contains 1 chunk(s)
-      RenderSVGInlineText {#text} at (0,0) size 244x18
-        chunk 1 text run 1 at (10.00,60.00) startOffset 0 endOffset 38 width 244.00: &quot;The two objects should look identical.&quot;
-    RenderSVGContainer {use} at (45,45) size 130x30 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
-      RenderSVGContainer {g} at (45,45) size 130x30
-        RenderSVGViewportContainer {svg} at (45,45) size 130x30
-          RenderSVGRect {rect} at (45,45) size 130x30 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
</del></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorsvgcustomuseongcontainingsymbolexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/platform/ios-simulator/svg/custom/use-on-g-containing-symbol-expected.txt (197193 => 197194)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator/svg/custom/use-on-g-containing-symbol-expected.txt        2016-02-26 20:47:24 UTC (rev 197193)
+++ trunk/LayoutTests/platform/ios-simulator/svg/custom/use-on-g-containing-symbol-expected.txt        2016-02-26 20:58:32 UTC (rev 197194)
</span><span class="lines">@@ -1,17 +0,0 @@
</span><del>-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderSVGRoot {svg} at (20,45) size 489x82
-    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
-      RenderSVGContainer {g} at (0,0) size 0x0
-        RenderSVGHiddenContainer {symbol} at (0,0) size 0x0
-          RenderSVGRect {rect} at (0,0) size 125x25 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
-    RenderSVGContainer {g} at (245,45) size 130x30 [transform={m=((1.00,0.00)(0.00,1.00)) t=(125.00,25.00)}]
-      RenderSVGRect {rect} at (245,45) size 130x30 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
-    RenderSVGText {text} at (10,45) size 245x19 contains 1 chunk(s)
-      RenderSVGInlineText {#text} at (0,0) size 245x18
-        chunk 1 text run 1 at (10.00,60.00) startOffset 0 endOffset 38 width 244.40: &quot;The two objects should look identical.&quot;
-    RenderSVGContainer {use} at (45,45) size 130x30 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
-      RenderSVGContainer {g} at (45,45) size 130x30
-        RenderSVGViewportContainer {svg} at (45,45) size 130x30
-          RenderSVGRect {rect} at (45,45) size 130x30 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
</del></span></pre></div>
<a id="trunkLayoutTestsplatformmacsvgcustomuseongcontainingsymbolexpectedpng"></a>
<div class="binary"><h4>Deleted: trunk/LayoutTests/platform/mac/svg/custom/use-on-g-containing-symbol-expected.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacsvgcustomuseongcontainingsymbolexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/platform/mac/svg/custom/use-on-g-containing-symbol-expected.txt (197193 => 197194)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/svg/custom/use-on-g-containing-symbol-expected.txt        2016-02-26 20:47:24 UTC (rev 197193)
+++ trunk/LayoutTests/platform/mac/svg/custom/use-on-g-containing-symbol-expected.txt        2016-02-26 20:58:32 UTC (rev 197194)
</span><span class="lines">@@ -1,17 +0,0 @@
</span><del>-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderSVGRoot {svg} at (20,45) size 489x83
-    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
-      RenderSVGContainer {g} at (0,0) size 0x0
-        RenderSVGHiddenContainer {symbol} at (0,0) size 0x0
-          RenderSVGRect {rect} at (0,0) size 125x25 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
-    RenderSVGContainer {g} at (245,45) size 130x30 [transform={m=((1.00,0.00)(0.00,1.00)) t=(125.00,25.00)}]
-      RenderSVGRect {rect} at (245,45) size 130x30 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
-    RenderSVGText {text} at (10,45) size 245x19 contains 1 chunk(s)
-      RenderSVGInlineText {#text} at (0,0) size 245x19
-        chunk 1 text run 1 at (10.00,60.00) startOffset 0 endOffset 38 width 244.40: &quot;The two objects should look identical.&quot;
-    RenderSVGContainer {use} at (45,45) size 130x30 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
-      RenderSVGContainer {g} at (45,45) size 130x30
-        RenderSVGViewportContainer {svg} at (45,45) size 130x30
-          RenderSVGRect {rect} at (45,45) size 130x30 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
</del></span></pre></div>
<a id="trunkLayoutTestsplatformwinsvgcustomuseongcontainingsymbolexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/platform/win/svg/custom/use-on-g-containing-symbol-expected.txt (197193 => 197194)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/win/svg/custom/use-on-g-containing-symbol-expected.txt        2016-02-26 20:47:24 UTC (rev 197193)
+++ trunk/LayoutTests/platform/win/svg/custom/use-on-g-containing-symbol-expected.txt        2016-02-26 20:58:32 UTC (rev 197194)
</span><span class="lines">@@ -1,17 +0,0 @@
</span><del>-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderSVGRoot {svg} at (20,45) size 488x83
-    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
-      RenderSVGContainer {g} at (0,0) size 0x0
-        RenderSVGHiddenContainer {symbol} at (0,0) size 0x0
-          RenderSVGRect {rect} at (0,0) size 125x25 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
-    RenderSVGContainer {g} at (245,45) size 130x30 [transform={m=((1.00,0.00)(0.00,1.00)) t=(125.00,25.00)}]
-      RenderSVGRect {rect} at (245,45) size 130x30 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
-    RenderSVGText {text} at (10,45) size 244x19 contains 1 chunk(s)
-      RenderSVGInlineText {#text} at (0,0) size 244x19
-        chunk 1 text run 1 at (10.00,60.00) startOffset 0 endOffset 38 width 244.00: &quot;The two objects should look identical.&quot;
-    RenderSVGContainer {use} at (45,45) size 130x30 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
-      RenderSVGContainer {g} at (45,45) size 130x30
-        RenderSVGViewportContainer {svg} at (45,45) size 130x30
-          RenderSVGRect {rect} at (45,45) size 130x30 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
</del></span></pre></div>
<a id="trunkLayoutTestssvgcustomuseongcontainingsymbolexpectedsvg"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/use-on-g-containing-symbol-expected.svg (0 => 197194)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/use-on-g-containing-symbol-expected.svg                                (rev 0)
+++ trunk/LayoutTests/svg/custom/use-on-g-containing-symbol-expected.svg        2016-02-26 20:58:32 UTC (rev 197194)
</span><span class="lines">@@ -0,0 +1,8 @@
</span><ins>+&lt;svg version=&quot;1.2&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
+    &lt;symbol id=&quot;rect-symbol&quot;&gt; 
+        &lt;rect x=&quot;0&quot; y=&quot;0&quot; width=&quot;100&quot; height=&quot;100&quot; fill=&quot;green&quot;/&gt;
+    &lt;/symbol&gt; 
+    &lt;use xlink:href=&quot;#rect-symbol&quot; transform=&quot;translate(10,10)&quot;/&gt;
+    &lt;use xlink:href=&quot;#rect-symbol&quot; transform=&quot;translate(120,10)&quot;/&gt;
+    &lt;use xlink:href=&quot;#rect-symbol&quot; transform=&quot;translate(230,10)&quot;/&gt;
+&lt;/svg&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestssvgcustomuseongcontainingsymbolsvg"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/svg/custom/use-on-g-containing-symbol.svg (197193 => 197194)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/use-on-g-containing-symbol.svg        2016-02-26 20:47:24 UTC (rev 197193)
+++ trunk/LayoutTests/svg/custom/use-on-g-containing-symbol.svg        2016-02-26 20:58:32 UTC (rev 197194)
</span><span class="lines">@@ -1,19 +1,10 @@
</span><del>-&lt;?xml version=&quot;1.0&quot; standalone=&quot;no&quot;?&gt;
-&lt;!DOCTYPE svg PUBLIC &quot;-//W3C//DTD SVG 1.1//EN&quot; &quot;http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd&quot;&gt;
-&lt;svg width=&quot;800&quot; height=&quot;600&quot; viewBox=&quot;0 0 400 300&quot; version=&quot;1.1&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
-&lt;defs&gt;
-    &lt;g id=&quot;symbol&quot;&gt;
-        &lt;symbol overflow=&quot;visible&quot;&gt;
-            &lt;rect stroke-width=&quot;5px&quot; fill=&quot;red&quot; stroke=&quot;navy&quot; width=&quot;60&quot; height=&quot;10&quot;/&gt;
</del><ins>+&lt;svg version=&quot;1.2&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
+    &lt;use xlink:href=&quot;#rect-group&quot; transform=&quot;translate(110, 0)&quot;&gt;&lt;/use&gt;
+    &lt;g id=&quot;rect-group&quot;&gt;
+        &lt;symbol id=&quot;rect-symbol&quot;&gt; 
+            &lt;rect x=&quot;0&quot; y=&quot;0&quot; width=&quot;100&quot; height=&quot;100&quot; fill=&quot;currentColor&quot;/&gt;
</ins><span class="cx">         &lt;/symbol&gt;
</span><ins>+        &lt;use xlink:href=&quot;#rect-symbol&quot; color=&quot;green&quot; transform=&quot;translate(10,10)&quot;/&gt;
</ins><span class="cx">     &lt;/g&gt;
</span><del>-&lt;/defs&gt;
-
-&lt;g transform=&quot;translate(125 25)&quot;&gt;
-    &lt;rect stroke-width=&quot;5px&quot; fill=&quot;red&quot; stroke=&quot;navy&quot; width=&quot;60&quot; height=&quot;10&quot;/&gt;
-&lt;/g&gt;
-
-&lt;text x=&quot;10&quot; y=&quot;60&quot;&gt;The two objects should look identical.&lt;/text&gt;
-&lt;use x=&quot;25&quot; y=&quot;25&quot; xlink:href=&quot;#symbol&quot;/&gt;
</del><ins>+    &lt;use xlink:href=&quot;#rect-group&quot; transform=&quot;translate(220, 0)&quot;/&gt;
</ins><span class="cx"> &lt;/svg&gt;
</span><del>-
</del></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (197193 => 197194)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-02-26 20:47:24 UTC (rev 197193)
+++ trunk/Source/WebCore/ChangeLog        2016-02-26 20:58:32 UTC (rev 197194)
</span><span class="lines">@@ -1,3 +1,35 @@
</span><ins>+2016-02-26  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
+
+        &lt;g&gt; wrapping &lt;symbol&gt; causes display of hidden &lt;symbol&gt;
+        https://bugs.webkit.org/show_bug.cgi?id=154576
+
+        Reviewed by Darin Adler.
+        
+        The SVGSymbolElement is allowed in the shadow tree of an SVGUseElement
+        only if it subtree root element. Any descendant SVGSymbolElement should
+        be removed from the subtree because it is a hidden container. If the cloned
+        subtree includes an SVGUseElement which references an SVGSymbolElement,
+        the same rule will be applied to the descendant SVGUseElement. The goal
+        is to remove all the descendant SVGSymbolElements from the cloned target
+        because these SVGSymbolElements will be expanded to SVGSVGElements and
+        hence become visible.
+
+        * svg/SVGUseElement.cpp:
+        (WebCore::disassociateAndRemoveClones): A helper function which removes
+        cloned SVGElements and their subtrees from their parents and disassociate
+        them from their originals.
+        
+        (WebCore::removeDisallowedElementsFromSubtree): Use disassociateAndRemoveClones().
+        
+        (WebCore::removeSymbolElementsFromSubtree): Removes all the descendant
+        SVGSymbolElements from the cloned subtree. It does not remove the root
+        element itself if it is an SVGSymbolElement because this one will be
+        expanded to an SVGSVGElement which is exactly what we need.
+        
+        (WebCore::SVGUseElement::cloneTarget): Call removeSymbolElementsFromSubtree()
+        to remove the descendant SVGSymbolElements from the cloned subtree before
+        appending it to the container shadow root.
+
</ins><span class="cx"> 2016-02-26  Olivier Blin  &lt;olivier.blin@softathome.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Initialize LocaleICU data members in header
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGUseElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGUseElement.cpp (197193 => 197194)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGUseElement.cpp        2016-02-26 20:47:24 UTC (rev 197193)
+++ trunk/Source/WebCore/svg/SVGUseElement.cpp        2016-02-26 20:58:32 UTC (rev 197194)
</span><span class="lines">@@ -310,6 +310,15 @@
</span><span class="cx">     return targetClone-&gt;renderer();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static inline void disassociateAndRemoveClones(const Vector&lt;Element*&gt;&amp; clones)
+{
+    for (auto&amp; clone : clones) {
+        for (auto&amp; descendant : descendantsOfType&lt;SVGElement&gt;(*clone))
+            descendant.setCorrespondingElement(nullptr);
+        clone-&gt;parentNode()-&gt;removeChild(*clone);
+    }
+}
+
</ins><span class="cx"> static void removeDisallowedElementsFromSubtree(SVGElement&amp; subtree)
</span><span class="cx"> {
</span><span class="cx">     // Remove disallowed elements after the fact rather than not cloning them in the first place.
</span><span class="lines">@@ -330,13 +339,22 @@
</span><span class="cx">         }
</span><span class="cx">         ++it;
</span><span class="cx">     }
</span><del>-    for (auto* element : disallowedElements) {
-        for (auto&amp; descendant : descendantsOfType&lt;SVGElement&gt;(*element))
-            descendant.setCorrespondingElement(nullptr);
-        element-&gt;parentNode()-&gt;removeChild(*element);
-    }
</del><ins>+
+    disassociateAndRemoveClones(disallowedElements);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void removeSymbolElementsFromSubtree(SVGElement&amp; subtree)
+{
+    // Symbol elements inside the subtree should not be cloned for two reasons: 1) They are invisible and
+    // don't need to be cloned to get correct rendering. 2) expandSymbolElementsInShadowTree will turn them
+    // into &lt;svg&gt; elements, which is correct for symbol elements directly referenced by use elements,
+    // but incorrect for ones that just happen to be in a subtree.
+    Vector&lt;Element*&gt; symbolElements;
+    for (auto&amp; descendant : descendantsOfType&lt;SVGSymbolElement&gt;(subtree))
+        symbolElements.append(&amp;descendant);
+    disassociateAndRemoveClones(symbolElements);
+}
+
</ins><span class="cx"> static void associateClonesWithOriginals(SVGElement&amp; clone, SVGElement&amp; original)
</span><span class="cx"> {
</span><span class="cx">     // This assertion checks that we don't call this with the arguments backwards.
</span><span class="lines">@@ -409,6 +427,7 @@
</span><span class="cx">     Ref&lt;SVGElement&gt; targetClone = static_cast&lt;SVGElement&amp;&gt;(target.cloneElementWithChildren(document()).get());
</span><span class="cx">     associateClonesWithOriginals(targetClone.get(), target);
</span><span class="cx">     removeDisallowedElementsFromSubtree(targetClone.get());
</span><ins>+    removeSymbolElementsFromSubtree(targetClone.get());
</ins><span class="cx">     transferSizeAttributesToTargetClone(targetClone.get());
</span><span class="cx">     container.appendChild(WTFMove(targetClone));
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>