<!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>[168921] 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/168921">168921</a></dd>
<dt>Author</dt> <dd>dbates@webkit.org</dd>
<dt>Date</dt> <dd>2014-05-15 21:30:12 -0700 (Thu, 15 May 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>ASSERT_NOT_REACHED() in DocumentOrderedMap::get() when removing SVG subtree
https://bugs.webkit.org/show_bug.cgi?id=132669
&lt;rdar://problem/14931432&gt;

Reviewed by Brent Fulgham and Ryosuke Niwa.

Source/WebCore:
Fixes an assertion failure when removing an SVG element with a duplicate id.

When removing an SVG element with id A we synchronously instruct each element that references A
to find the first element with id A, call this N, from the document root and register itself to
either receive subsequent notifications from N (say, there is another element with id A) or as
waiting for an element with id A (say, N = nullptr; =&gt; we removed the last element with id A from
the document). Because the elements that reference A perform this operation synchronously when
removing an element they consult an transient state of the DocumentOrderedMap when querying for the
element with id A.

Without loss of generality, let E, E_1, E_2, and E_3 be elements, where E_1, E_2, E_3 are children
of E in that order and E_1.id = E_2.id = A and E_3.href = #A (that is, it references an element
with id A). Suppose we remove E then we remove E_1, update DocumentOrderedMap to decrement its count
for id A, and notify E_3 to look for an element with id A. This leads to an assertion failure since
DocumentOrderedMap expects to find an element with id A, E_2, but cannot find such an element when
traversing from the document root because E was unlinked from the document root (i.e. E_2 is in a
disjoint subtree).

Tests: svg/custom/change-id-of-use-during-removal.html
       svg/custom/remove-subtree-including-path-with-duplicate-id-referenced-by-later-textpath.html
       svg/custom/remove-subtree-including-text-with-duplicate-id-referenced-by-later-tref.html
       svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-earlier-use.html
       svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-animate.html
       svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-feimage.html
       svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-mpath.html
       svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use.html
       svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use2.html
       svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-in-different-subtree.html
       svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-with-duplicate-id-in-different-subtree.html
       svg/custom/remove-use-with-duplicate-id-referenced-by-later-use.html

* dom/ContainerNode.cpp:
(WebCore::ContainerNode::removeChild): Call SVGDocumentExtensions::rebuildElements() after we remove
a DOM subtree so that applicable SVG elements can update their referenced element when the DocumentOrderedMap
is in a stable-state.
(WebCore::ContainerNode::removeChildren): Ditto.
* svg/SVGDocumentExtensions.cpp:
(WebCore::SVGDocumentExtensions::rebuildElements): Added; notifies SVG elements that their href attribute
changed so that they query the DocumentOrderedMap for the element they reference by id in their href attribute.
(WebCore::SVGDocumentExtensions::clearTargetDependencies): Added; Called from removing
an SVG element S from the DOM. Appends all elements that reference the id of S to the end of a Vector of
elements to be rebuilt (when SVGDocumentExtensions::rebuildElements() is called) and notifies these elements
that have been marked to be rebuilt so that they can invalidate their state (e.g. stop animating).
(WebCore::SVGDocumentExtensions::rebuildAllElementReferencesForTarget): Changed to take its argument by reference
(since it's always non-null) and simplified logic to synchronously notify SVG updates that their referenced element
may have changed. Calling SVGElement::svgAttributeChanged() on an element E should at most remove the dependencies
of E.
* svg/SVGDocumentExtensions.h:
* svg/SVGElement.cpp:
(WebCore::SVGElement::~SVGElement): Substitute &quot;*this&quot; for &quot;this&quot; as SVGDocumentExtensions::rebuildAllElementReferencesForTarget()
now takes a reference instead of a pointer.
(WebCore::SVGElement::removedFrom): Modified to call SVGDocumentExtensions::clearTargetDependencies().
(WebCore::SVGElement::attributeChanged): Substitute &quot;*this&quot; for &quot;this&quot; as SVGDocumentExtensions::rebuildAllElementReferencesForTarget()
now takes a reference instead of a pointer.
* svg/SVGElement.h:
(WebCore::SVGElement::callClearTarget): Added; calls through to private virtual SVGElement::clearTarget().
(WebCore::SVGElement::clearTarget): Added.
* svg/SVGTRefElement.cpp:
(WebCore::SVGTRefElement::clearTarget): Added.
* svg/SVGTRefElement.h:
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::clearTarget): Added.
* svg/animation/SVGSMILElement.h:

LayoutTests:
Add tests to ensure that we don't cause an assertion failure when removing an SVG element with a duplicate id.

* svg/custom/change-id-of-use-during-removal-expected.txt: Added.
* svg/custom/change-id-of-use-during-removal.html: Added.
* svg/custom/remove-subtree-including-path-with-duplicate-id-referenced-by-later-textpath-expected.txt: Added.
* svg/custom/remove-subtree-including-path-with-duplicate-id-referenced-by-later-textpath.html: Added.
* svg/custom/remove-subtree-including-text-with-duplicate-id-referenced-by-later-tref-expected.txt: Added.
* svg/custom/remove-subtree-including-text-with-duplicate-id-referenced-by-later-tref.html: Added.
* svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-earlier-use-expected.txt: Added.
* svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-earlier-use.html: Added.
* svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-animate-expected.txt: Added.
* svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-animate.html: Added.
* svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-feimage-expected.txt: Added.
* svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-feimage.html: Added.
* svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-mpath-expected.txt: Added.
* svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-mpath.html: Added.
* svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use-expected.txt: Added.
* svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use.html: Added.
* svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use2-expected.txt: Added.
* svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use2.html: Added.
* svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-in-different-subtree-expected.txt: Added.
* svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-in-different-subtree.html: Added.
* svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-with-duplicate-id-in-different-subtree-expected.html: Added.
* svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-with-duplicate-id-in-different-subtree.html: Added.
* svg/custom/remove-use-with-duplicate-id-referenced-by-later-use-expected.html: Added.
* svg/custom/remove-use-with-duplicate-id-referenced-by-later-use.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomContainerNodecpp">trunk/Source/WebCore/dom/ContainerNode.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGDocumentExtensionscpp">trunk/Source/WebCore/svg/SVGDocumentExtensions.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGDocumentExtensionsh">trunk/Source/WebCore/svg/SVGDocumentExtensions.h</a></li>
<li><a href="#trunkSourceWebCoresvgSVGElementcpp">trunk/Source/WebCore/svg/SVGElement.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGElementh">trunk/Source/WebCore/svg/SVGElement.h</a></li>
<li><a href="#trunkSourceWebCoresvgSVGTRefElementcpp">trunk/Source/WebCore/svg/SVGTRefElement.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGTRefElementh">trunk/Source/WebCore/svg/SVGTRefElement.h</a></li>
<li><a href="#trunkSourceWebCoresvganimationSVGSMILElementcpp">trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp</a></li>
<li><a href="#trunkSourceWebCoresvganimationSVGSMILElementh">trunk/Source/WebCore/svg/animation/SVGSMILElement.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestssvgcustomchangeidofuseduringremovalexpectedtxt">trunk/LayoutTests/svg/custom/change-id-of-use-during-removal-expected.txt</a></li>
<li><a href="#trunkLayoutTestssvgcustomchangeidofuseduringremovalhtml">trunk/LayoutTests/svg/custom/change-id-of-use-during-removal.html</a></li>
<li><a href="#trunkLayoutTestssvgcustomremovesubtreeincludingpathwithduplicateidreferencedbylatertextpathexpectedtxt">trunk/LayoutTests/svg/custom/remove-subtree-including-path-with-duplicate-id-referenced-by-later-textpath-expected.txt</a></li>
<li><a href="#trunkLayoutTestssvgcustomremovesubtreeincludingpathwithduplicateidreferencedbylatertextpathhtml">trunk/LayoutTests/svg/custom/remove-subtree-including-path-with-duplicate-id-referenced-by-later-textpath.html</a></li>
<li><a href="#trunkLayoutTestssvgcustomremovesubtreeincludingtextwithduplicateidreferencedbylatertrefexpectedtxt">trunk/LayoutTests/svg/custom/remove-subtree-including-text-with-duplicate-id-referenced-by-later-tref-expected.txt</a></li>
<li><a href="#trunkLayoutTestssvgcustomremovesubtreeincludingtextwithduplicateidreferencedbylatertrefhtml">trunk/LayoutTests/svg/custom/remove-subtree-including-text-with-duplicate-id-referenced-by-later-tref.html</a></li>
<li><a href="#trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbyearlieruseexpectedtxt">trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-earlier-use-expected.txt</a></li>
<li><a href="#trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbyearlierusehtml">trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-earlier-use.html</a></li>
<li><a href="#trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbylateranimateexpectedtxt">trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-animate-expected.txt</a></li>
<li><a href="#trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbylateranimatehtml">trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-animate.html</a></li>
<li><a href="#trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbylaterfeimageexpectedtxt">trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-feimage-expected.txt</a></li>
<li><a href="#trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbylaterfeimagehtml">trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-feimage.html</a></li>
<li><a href="#trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbylatermpathexpectedtxt">trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-mpath-expected.txt</a></li>
<li><a href="#trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbylatermpathhtml">trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-mpath.html</a></li>
<li><a href="#trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbylateruseexpectedtxt">trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use-expected.txt</a></li>
<li><a href="#trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbylaterusehtml">trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use.html</a></li>
<li><a href="#trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbylateruse2expectedtxt">trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use2-expected.txt</a></li>
<li><a href="#trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbylateruse2html">trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use2.html</a></li>
<li><a href="#trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbyuseindifferentsubtreeexpectedtxt">trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-in-different-subtree-expected.txt</a></li>
<li><a href="#trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbyuseindifferentsubtreehtml">trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-in-different-subtree.html</a></li>
<li><a href="#trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbyusewithduplicateidindifferentsubtreeexpectedhtml">trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-with-duplicate-id-in-different-subtree-expected.html</a></li>
<li><a href="#trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbyusewithduplicateidindifferentsubtreehtml">trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-with-duplicate-id-in-different-subtree.html</a></li>
<li><a href="#trunkLayoutTestssvgcustomremoveusewithduplicateidreferencedbylateruseexpectedhtml">trunk/LayoutTests/svg/custom/remove-use-with-duplicate-id-referenced-by-later-use-expected.html</a></li>
<li><a href="#trunkLayoutTestssvgcustomremoveusewithduplicateidreferencedbylaterusehtml">trunk/LayoutTests/svg/custom/remove-use-with-duplicate-id-referenced-by-later-use.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (168920 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-05-16 03:56:10 UTC (rev 168920)
+++ trunk/LayoutTests/ChangeLog        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -1,5 +1,40 @@
</span><span class="cx"> 2014-05-15  Daniel Bates  &lt;dabates@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        ASSERT_NOT_REACHED() in DocumentOrderedMap::get() when removing SVG subtree
+        https://bugs.webkit.org/show_bug.cgi?id=132669
+        &lt;rdar://problem/14931432&gt;
+
+        Reviewed by Brent Fulgham and Ryosuke Niwa.
+
+        Add tests to ensure that we don't cause an assertion failure when removing an SVG element with a duplicate id.
+
+        * svg/custom/change-id-of-use-during-removal-expected.txt: Added.
+        * svg/custom/change-id-of-use-during-removal.html: Added.
+        * svg/custom/remove-subtree-including-path-with-duplicate-id-referenced-by-later-textpath-expected.txt: Added.
+        * svg/custom/remove-subtree-including-path-with-duplicate-id-referenced-by-later-textpath.html: Added.
+        * svg/custom/remove-subtree-including-text-with-duplicate-id-referenced-by-later-tref-expected.txt: Added.
+        * svg/custom/remove-subtree-including-text-with-duplicate-id-referenced-by-later-tref.html: Added.
+        * svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-earlier-use-expected.txt: Added.
+        * svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-earlier-use.html: Added.
+        * svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-animate-expected.txt: Added.
+        * svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-animate.html: Added.
+        * svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-feimage-expected.txt: Added.
+        * svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-feimage.html: Added.
+        * svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-mpath-expected.txt: Added.
+        * svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-mpath.html: Added.
+        * svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use-expected.txt: Added.
+        * svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use.html: Added.
+        * svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use2-expected.txt: Added.
+        * svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use2.html: Added.
+        * svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-in-different-subtree-expected.txt: Added.
+        * svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-in-different-subtree.html: Added.
+        * svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-with-duplicate-id-in-different-subtree-expected.html: Added.
+        * svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-with-duplicate-id-in-different-subtree.html: Added.
+        * svg/custom/remove-use-with-duplicate-id-referenced-by-later-use-expected.html: Added.
+        * svg/custom/remove-use-with-duplicate-id-referenced-by-later-use.html: Added.
+
+2014-05-15  Daniel Bates  &lt;dabates@apple.com&gt;
+
</ins><span class="cx">         SVG element may reference arbitrary DOM element before running its insertion logic
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=132757
</span><span class="cx">         &lt;rdar://problem/15703817&gt;
</span></span></pre></div>
<a id="trunkLayoutTestssvgcustomchangeidofuseduringremovalexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/change-id-of-use-during-removal-expected.txt (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/change-id-of-use-during-removal-expected.txt                                (rev 0)
+++ trunk/LayoutTests/svg/custom/change-id-of-use-during-removal-expected.txt        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+This tests that we don't cause an assertion failure when changing the id of a &lt;use&gt; on removal from the document despite a later &lt;use&gt; referencing its former id.
+
+PASS
</ins></span></pre></div>
<a id="trunkLayoutTestssvgcustomchangeidofuseduringremovalhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/change-id-of-use-during-removal.html (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/change-id-of-use-during-removal.html                                (rev 0)
+++ trunk/LayoutTests/svg/custom/change-id-of-use-during-removal.html        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+function handleNodeRemoved(event)
+{
+    document.removeEventListener(&quot;DOMNodeRemoved&quot;, handleNodeRemoved, false);
+    firstUseElement.id = &quot;B&quot;;
+}
+
+document.addEventListener(&quot;DOMNodeRemoved&quot;, handleNodeRemoved, false);
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p&gt;This tests that we don't cause an assertion failure when changing the id of a &amp;lt;use&amp;gt; on removal from the document despite a later &amp;lt;use&amp;gt; referencing its former id.&lt;/p&gt;
+&lt;svg&gt;
+    &lt;use id=&quot;A&quot;&gt;&lt;/use&gt;
+    &lt;use id=&quot;A&quot;&gt;&lt;/use&gt;
+    &lt;use xlink:href=&quot;#A&quot;&gt;&lt;/use&gt;
+&lt;/svg&gt;
+&lt;script&gt;
+var firstUseElement = document.querySelector(&quot;use&quot;);
+var svg = document.querySelector(&quot;svg&quot;);
+document.body.removeChild(svg);
+&lt;/script&gt;
+&lt;p&gt;PASS&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestssvgcustomremovesubtreeincludingpathwithduplicateidreferencedbylatertextpathexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/remove-subtree-including-path-with-duplicate-id-referenced-by-later-textpath-expected.txt (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/remove-subtree-including-path-with-duplicate-id-referenced-by-later-textpath-expected.txt                                (rev 0)
+++ trunk/LayoutTests/svg/custom/remove-subtree-including-path-with-duplicate-id-referenced-by-later-textpath-expected.txt        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+This tests that we don't cause an assertion failure when implicitly removing a &lt;path&gt; (by removing its parent), with the same id as another element, that is referenced by a later &lt;textpath&gt;.
+
+PASS
</ins></span></pre></div>
<a id="trunkLayoutTestssvgcustomremovesubtreeincludingpathwithduplicateidreferencedbylatertextpathhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/remove-subtree-including-path-with-duplicate-id-referenced-by-later-textpath.html (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/remove-subtree-including-path-with-duplicate-id-referenced-by-later-textpath.html                                (rev 0)
+++ trunk/LayoutTests/svg/custom/remove-subtree-including-path-with-duplicate-id-referenced-by-later-textpath.html        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p&gt;This tests that we don't cause an assertion failure when implicitly removing a &amp;lt;path&amp;gt; (by removing its parent), with the same id as another element, that is referenced by a later &amp;lt;textpath&amp;gt;.&lt;/p&gt;
+&lt;svg style=&quot;width: 200px; height: 200px&quot;&gt;
+    &lt;path id=&quot;A&quot; d=&quot;M 0 20 L 100 20 L 100 120 L 0 120&quot; fill=&quot;red&quot; /&gt;
+    &lt;path id=&quot;A&quot; d=&quot;M 0 20 L 100 20 L 100 120 L 0 120&quot; fill=&quot;red&quot; /&gt;
+    &lt;text&gt;
+        &lt;textPath xlink:href=&quot;#A&quot;&gt;FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL&lt;/textPath&gt;
+    &lt;/text&gt;
+&lt;/svg&gt;
+&lt;script&gt;
+var svg = document.querySelector(&quot;svg&quot;);
+document.body.removeChild(svg);
+&lt;/script&gt;
+&lt;p&gt;PASS&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestssvgcustomremovesubtreeincludingtextwithduplicateidreferencedbylatertrefexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/remove-subtree-including-text-with-duplicate-id-referenced-by-later-tref-expected.txt (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/remove-subtree-including-text-with-duplicate-id-referenced-by-later-tref-expected.txt                                (rev 0)
+++ trunk/LayoutTests/svg/custom/remove-subtree-including-text-with-duplicate-id-referenced-by-later-tref-expected.txt        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+This tests that we don't cause an assertion failure when implicitly removing a &lt;text&gt; (by removing its parent), with the same id as another element, that is referenced by a later &lt;tref&gt;.
+
+PASS
</ins></span></pre></div>
<a id="trunkLayoutTestssvgcustomremovesubtreeincludingtextwithduplicateidreferencedbylatertrefhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/remove-subtree-including-text-with-duplicate-id-referenced-by-later-tref.html (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/remove-subtree-including-text-with-duplicate-id-referenced-by-later-tref.html                                (rev 0)
+++ trunk/LayoutTests/svg/custom/remove-subtree-including-text-with-duplicate-id-referenced-by-later-tref.html        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p&gt;This tests that we don't cause an assertion failure when implicitly removing a &amp;lt;text&amp;gt; (by removing its parent), with the same id as another element, that is referenced by a later &amp;lt;tref&amp;gt;.&lt;/p&gt;
+&lt;svg version=&quot;1.1&quot;&gt;
+    &lt;defs&gt;
+        &lt;text id=&quot;A&quot;&gt;FAIL&lt;/text&gt;
+        &lt;text id=&quot;A&quot;&gt;FAIL&lt;/text&gt;
+    &lt;/defs&gt;
+    &lt;text x=&quot;0&quot; y=&quot;20&quot;&gt;
+        &lt;tref xlink:href=&quot;#A&quot;&gt;&lt;/tref&gt;
+    &lt;/text&gt;
+&lt;/svg&gt;
+&lt;script&gt;
+var svg = document.querySelector(&quot;svg&quot;);
+document.body.removeChild(svg);
+&lt;/script&gt;
+&lt;p&gt;PASS&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbyearlieruseexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-earlier-use-expected.txt (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-earlier-use-expected.txt                                (rev 0)
+++ trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-earlier-use-expected.txt        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+This tests that we don't cause an assertion failure when implicitly removing a &lt;use&gt; (by removing its parent), with the same id as another element, that is referenced by an earlier &lt;use&gt;.
+
+PASS
</ins></span></pre></div>
<a id="trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbyearlierusehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-earlier-use.html (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-earlier-use.html                                (rev 0)
+++ trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-earlier-use.html        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p&gt;This tests that we don't cause an assertion failure when implicitly removing a &amp;lt;use&amp;gt; (by removing its parent), with the same id as another element, that is referenced by an earlier &amp;lt;use&amp;gt;.&lt;/p&gt;
+&lt;svg&gt;
+    &lt;use xlink:href=&quot;#A&quot;&gt;&lt;/use&gt;
+    &lt;use id=&quot;A&quot;&gt;&lt;/use&gt;
+    &lt;use id=&quot;A&quot;&gt;&lt;/use&gt;
+&lt;/svg&gt;
+&lt;script&gt;
+var svg = document.querySelector(&quot;svg&quot;);
+document.body.removeChild(svg);
+&lt;/script&gt;
+&lt;p&gt;PASS&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbylateranimateexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-animate-expected.txt (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-animate-expected.txt                                (rev 0)
+++ trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-animate-expected.txt        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+This tests that we don't cause an assertion failure when implicitly removing a &lt;use&gt; (by removing its parent), with the same id as another element, that is referenced by a later &lt;animate&gt;.
+
+PASS
</ins></span></pre></div>
<a id="trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbylateranimatehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-animate.html (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-animate.html                                (rev 0)
+++ trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-animate.html        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p&gt;This tests that we don't cause an assertion failure when implicitly removing a &amp;lt;use&amp;gt; (by removing its parent), with the same id as another element, that is referenced by a later &amp;lt;animate&amp;gt;.&lt;/p&gt;
+&lt;svg&gt;
+    &lt;use id=&quot;A&quot;&gt;&lt;/use&gt;
+    &lt;use id=&quot;A&quot;&gt;&lt;/use&gt;
+    &lt;animate xlink:href=&quot;#A&quot;&gt;&lt;/animate&gt;
+&lt;/svg&gt;
+&lt;script&gt;
+var svg = document.querySelector(&quot;svg&quot;);
+document.body.removeChild(svg);
+&lt;/script&gt;
+&lt;p&gt;PASS&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbylaterfeimageexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-feimage-expected.txt (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-feimage-expected.txt                                (rev 0)
+++ trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-feimage-expected.txt        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+This tests that we don't cause an assertion failure when implicitly removing a &lt;use&gt; (by removing its parent), with the same id as another element, that is referenced by a later &lt;feimage&gt;.
+
+PASS
</ins></span></pre></div>
<a id="trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbylaterfeimagehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-feimage.html (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-feimage.html                                (rev 0)
+++ trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-feimage.html        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p&gt;This tests that we don't cause an assertion failure when implicitly removing a &amp;lt;use&amp;gt; (by removing its parent), with the same id as another element, that is referenced by a later &amp;lt;feimage&amp;gt;.&lt;/p&gt;
+&lt;svg&gt;
+    &lt;use id=&quot;A&quot;&gt;&lt;/use&gt;
+    &lt;use id=&quot;A&quot;&gt;&lt;/use&gt;
+    &lt;feimage xlink:href=&quot;#A&quot;&gt;&lt;/feimage&gt;
+&lt;/svg&gt;
+&lt;script&gt;
+var svg = document.querySelector(&quot;svg&quot;);
+document.body.removeChild(svg);
+&lt;/script&gt;
+&lt;p&gt;PASS&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbylatermpathexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-mpath-expected.txt (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-mpath-expected.txt                                (rev 0)
+++ trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-mpath-expected.txt        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+This tests that we don't cause an assertion failure when implicitly removing a &lt;use&gt; (by removing its parent), with the same id as another element, that is referenced by a later &lt;mpath&gt;.
+
+PASS
</ins></span></pre></div>
<a id="trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbylatermpathhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-mpath.html (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-mpath.html                                (rev 0)
+++ trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-mpath.html        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p&gt;This tests that we don't cause an assertion failure when implicitly removing a &amp;lt;use&amp;gt; (by removing its parent), with the same id as another element, that is referenced by a later &amp;lt;mpath&amp;gt;.&lt;/p&gt;
+&lt;svg&gt;
+    &lt;use id=&quot;A&quot;&gt;&lt;/use&gt;
+    &lt;use id=&quot;A&quot;&gt;&lt;/use&gt;
+    &lt;mpath xlink:href=&quot;#A&quot;&gt;&lt;/mpath&gt;
+&lt;/svg&gt;
+&lt;script&gt;
+var svg = document.querySelector(&quot;svg&quot;);
+document.body.removeChild(svg);
+&lt;/script&gt;
+&lt;p&gt;PASS&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbylateruseexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use-expected.txt (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use-expected.txt                                (rev 0)
+++ trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use-expected.txt        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+This tests that we don't cause an assertion failure when implicitly removing a &lt;use&gt; (by removing its parent), with the same id as another element, that is referenced by a later &lt;use&gt;.
+
+PASS
</ins></span></pre></div>
<a id="trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbylaterusehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use.html (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use.html                                (rev 0)
+++ trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use.html        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p&gt;This tests that we don't cause an assertion failure when implicitly removing a &amp;lt;use&amp;gt; (by removing its parent), with the same id as another element, that is referenced by a later &amp;lt;use&amp;gt;.&lt;/p&gt;
+&lt;svg&gt;
+    &lt;use id=&quot;A&quot;&gt;&lt;/use&gt;
+    &lt;use id=&quot;A&quot;&gt;&lt;/use&gt;
+    &lt;use xlink:href=&quot;#A&quot;&gt;&lt;/use&gt;
+&lt;/svg&gt;
+&lt;script&gt;
+var svg = document.querySelector(&quot;svg&quot;);
+document.body.removeChild(svg);
+&lt;/script&gt;
+&lt;p&gt;PASS&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbylateruse2expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use2-expected.txt (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use2-expected.txt                                (rev 0)
+++ trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use2-expected.txt        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+This tests that we don't cause an assertion failure when implicitly removing a &lt;use&gt; (by removing its parent), with the same id as another element, that is referenced by a later &lt;use&gt;.
+
+PASS
</ins></span></pre></div>
<a id="trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbylateruse2html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use2.html (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use2.html                                (rev 0)
+++ trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use2.html        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p&gt;This tests that we don't cause an assertion failure when implicitly removing a &amp;lt;use&amp;gt; (by removing its parent), with the same id as another element, that is referenced by a later &amp;lt;use&amp;gt;.&lt;/p&gt;
+&lt;svg&gt;
+    &lt;use id=&quot;A&quot;&gt;&lt;/use&gt;
+    &lt;g id=&quot;A&quot;&gt;&lt;/g&gt;
+    &lt;use xlink:href=&quot;#A&quot;&gt;&lt;/use&gt;
+&lt;/svg&gt;
+&lt;script&gt;
+var svg = document.querySelector(&quot;svg&quot;);
+document.body.removeChild(svg);
+&lt;/script&gt;
+&lt;p&gt;PASS&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbyuseindifferentsubtreeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-in-different-subtree-expected.txt (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-in-different-subtree-expected.txt                                (rev 0)
+++ trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-in-different-subtree-expected.txt        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+This tests that we don't cause an assertion failure when implicitly removing a &lt;use&gt; (by removing its parent), with the same id as another element, that is referenced by a later &lt;use&gt; in a different SVG subtree.
+
+PASS
</ins></span></pre></div>
<a id="trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbyuseindifferentsubtreehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-in-different-subtree.html (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-in-different-subtree.html                                (rev 0)
+++ trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-in-different-subtree.html        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+&lt;/script&gt;
+&lt;style&gt;
+svg {
+    height: 128px;
+    width: 128px;
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p&gt;This tests that we don't cause an assertion failure when implicitly removing a &amp;lt;use&amp;gt; (by removing its parent), with the same id as another element, that is referenced by a later &amp;lt;use&amp;gt; in a different SVG subtree.&lt;/p&gt;
+&lt;svg id=&quot;svg1&quot;&gt;
+    &lt;defs&gt;
+        &lt;text id=&quot;fail&quot; x=&quot;0&quot; y=&quot;20&quot;&gt;FAIL&lt;/text&gt;
+    &lt;/defs&gt;
+    &lt;use id=&quot;A&quot; xlink:href=&quot;#fail&quot;&gt;&lt;/use&gt;
+    &lt;use id=&quot;A&quot; xlink:href=&quot;#fail&quot;&gt;&lt;/use&gt;
+&lt;/svg&gt;
+&lt;svg&gt;
+    &lt;use xlink:href=&quot;#A&quot;&gt;&lt;/use&gt;
+&lt;/svg&gt;
+&lt;script&gt;
+var svg = document.getElementById(&quot;svg1&quot;);
+document.body.removeChild(svg);
+&lt;/script&gt;
+&lt;p&gt;PASS&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbyusewithduplicateidindifferentsubtreeexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-with-duplicate-id-in-different-subtree-expected.html (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-with-duplicate-id-in-different-subtree-expected.html                                (rev 0)
+++ trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-with-duplicate-id-in-different-subtree-expected.html        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;body&gt;
+&lt;div style=&quot;width: 128px; height: 128px; background-color: green&quot;&gt;&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestssvgcustomremovesubtreeincludingusewithduplicateidreferencedbyusewithduplicateidindifferentsubtreehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-with-duplicate-id-in-different-subtree.html (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-with-duplicate-id-in-different-subtree.html                                (rev 0)
+++ trunk/LayoutTests/svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-with-duplicate-id-in-different-subtree.html        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;style&gt;
+svg {
+    height: 128px;
+    width: 128px;
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;!-- This tests that we don't cause an assertion failure when implicitly removing a &lt;use&gt; (by removing its parent), with the same id as other elements, that is referenced by a later &lt;use&gt; in a different SVG subtree. --&gt;
+&lt;svg id=&quot;svg1&quot;&gt;
+    &lt;defs&gt;
+        &lt;rect id=&quot;bad&quot; x=&quot;0&quot; y=&quot;0&quot; width=&quot;128&quot; height=&quot;128&quot; fill=&quot;red&quot;&gt;&lt;/rect&gt;
+    &lt;/defs&gt;
+    &lt;use id=&quot;A&quot; xlink:href=&quot;#bad&quot;&gt;&lt;/use&gt;
+    &lt;use id=&quot;A&quot; xlink:href=&quot;#bad&quot;&gt;&lt;/use&gt;
+&lt;/svg&gt;
+&lt;svg&gt;
+    &lt;defs&gt;
+        &lt;rect id=&quot;good&quot; x=&quot;0&quot; y=&quot;0&quot; width=&quot;128&quot; height=&quot;128&quot; fill=&quot;green&quot;&gt;&lt;/rect&gt;
+        &lt;use id=&quot;A&quot; xlink:href=&quot;#good&quot;&gt;&lt;/use&gt; &lt;!-- [1] --&gt;
+    &lt;/defs&gt;
+    &lt;use xlink:href=&quot;#A&quot;&gt;&lt;/use&gt; &lt;!-- [2] --&gt;
+&lt;/svg&gt;
+&lt;script&gt;
+var svg = document.getElementById(&quot;svg1&quot;);
+document.body.removeChild(svg); // [2] will depend on [1]
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestssvgcustomremoveusewithduplicateidreferencedbylateruseexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/remove-use-with-duplicate-id-referenced-by-later-use-expected.html (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/remove-use-with-duplicate-id-referenced-by-later-use-expected.html                                (rev 0)
+++ trunk/LayoutTests/svg/custom/remove-use-with-duplicate-id-referenced-by-later-use-expected.html        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;body&gt;
+&lt;div style=&quot;width: 128px; height: 128px; background-color: green&quot;&gt;&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestssvgcustomremoveusewithduplicateidreferencedbylaterusehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/custom/remove-use-with-duplicate-id-referenced-by-later-use.html (0 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/custom/remove-use-with-duplicate-id-referenced-by-later-use.html                                (rev 0)
+++ trunk/LayoutTests/svg/custom/remove-use-with-duplicate-id-referenced-by-later-use.html        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;style&gt;
+svg {
+    height: 128px;
+    width: 128px;
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;!-- This tests that we don't cause an assertion failure when removing a &lt;use&gt;, with the same id another element, that is referenced by a later &lt;use&gt;. --&gt;
+&lt;svg&gt;
+    &lt;defs&gt;
+        &lt;rect id=&quot;pass&quot; x=&quot;0&quot; y=&quot;0&quot; width=&quot;128&quot; height=&quot;128&quot; fill=&quot;green&quot;&gt;&lt;/rect&gt;
+        &lt;rect id=&quot;fail&quot; x=&quot;0&quot; y=&quot;0&quot; width=&quot;128&quot; height=&quot;128&quot; fill=&quot;red&quot;&gt;&lt;/rect&gt;
+        &lt;use id=&quot;A&quot; xlink:href=&quot;#fail&quot;&gt;&lt;/use&gt;
+        &lt;use id=&quot;A&quot; xlink:href=&quot;#pass&quot;&gt;&lt;/use&gt;
+    &lt;/defs&gt;
+    &lt;use xlink:href=&quot;#A&quot;&gt;&lt;/use&gt;
+&lt;/svg&gt;
+&lt;script&gt;
+var firstUseElement = document.querySelector(&quot;use&quot;);
+firstUseElement.parentNode.removeChild(firstUseElement);
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (168920 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-05-16 03:56:10 UTC (rev 168920)
+++ trunk/Source/WebCore/ChangeLog        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -1,3 +1,75 @@
</span><ins>+2014-05-15  Daniel Bates  &lt;dabates@apple.com&gt;
+
+        ASSERT_NOT_REACHED() in DocumentOrderedMap::get() when removing SVG subtree
+        https://bugs.webkit.org/show_bug.cgi?id=132669
+        &lt;rdar://problem/14931432&gt;
+
+        Reviewed by Brent Fulgham and Ryosuke Niwa.
+
+        Fixes an assertion failure when removing an SVG element with a duplicate id.
+
+        When removing an SVG element with id A we synchronously instruct each element that references A
+        to find the first element with id A, call this N, from the document root and register itself to
+        either receive subsequent notifications from N (say, there is another element with id A) or as
+        waiting for an element with id A (say, N = nullptr; =&gt; we removed the last element with id A from
+        the document). Because the elements that reference A perform this operation synchronously when
+        removing an element they consult an transient state of the DocumentOrderedMap when querying for the
+        element with id A.
+    
+        Without loss of generality, let E, E_1, E_2, and E_3 be elements, where E_1, E_2, E_3 are children
+        of E in that order and E_1.id = E_2.id = A and E_3.href = #A (that is, it references an element
+        with id A). Suppose we remove E then we remove E_1, update DocumentOrderedMap to decrement its count
+        for id A, and notify E_3 to look for an element with id A. This leads to an assertion failure since
+        DocumentOrderedMap expects to find an element with id A, E_2, but cannot find such an element when
+        traversing from the document root because E was unlinked from the document root (i.e. E_2 is in a
+        disjoint subtree).
+
+        Tests: svg/custom/change-id-of-use-during-removal.html
+               svg/custom/remove-subtree-including-path-with-duplicate-id-referenced-by-later-textpath.html
+               svg/custom/remove-subtree-including-text-with-duplicate-id-referenced-by-later-tref.html
+               svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-earlier-use.html
+               svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-animate.html
+               svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-feimage.html
+               svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-mpath.html
+               svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use.html
+               svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-later-use2.html
+               svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-in-different-subtree.html
+               svg/custom/remove-subtree-including-use-with-duplicate-id-referenced-by-use-with-duplicate-id-in-different-subtree.html
+               svg/custom/remove-use-with-duplicate-id-referenced-by-later-use.html
+
+        * dom/ContainerNode.cpp:
+        (WebCore::ContainerNode::removeChild): Call SVGDocumentExtensions::rebuildElements() after we remove
+        a DOM subtree so that applicable SVG elements can update their referenced element when the DocumentOrderedMap
+        is in a stable-state.
+        (WebCore::ContainerNode::removeChildren): Ditto.
+        * svg/SVGDocumentExtensions.cpp:
+        (WebCore::SVGDocumentExtensions::rebuildElements): Added; notifies SVG elements that their href attribute
+        changed so that they query the DocumentOrderedMap for the element they reference by id in their href attribute.
+        (WebCore::SVGDocumentExtensions::clearTargetDependencies): Added; Called from removing
+        an SVG element S from the DOM. Appends all elements that reference the id of S to the end of a Vector of
+        elements to be rebuilt (when SVGDocumentExtensions::rebuildElements() is called) and notifies these elements
+        that have been marked to be rebuilt so that they can invalidate their state (e.g. stop animating).
+        (WebCore::SVGDocumentExtensions::rebuildAllElementReferencesForTarget): Changed to take its argument by reference
+        (since it's always non-null) and simplified logic to synchronously notify SVG updates that their referenced element
+        may have changed. Calling SVGElement::svgAttributeChanged() on an element E should at most remove the dependencies
+        of E.
+        * svg/SVGDocumentExtensions.h:
+        * svg/SVGElement.cpp:
+        (WebCore::SVGElement::~SVGElement): Substitute &quot;*this&quot; for &quot;this&quot; as SVGDocumentExtensions::rebuildAllElementReferencesForTarget()
+        now takes a reference instead of a pointer.
+        (WebCore::SVGElement::removedFrom): Modified to call SVGDocumentExtensions::clearTargetDependencies().
+        (WebCore::SVGElement::attributeChanged): Substitute &quot;*this&quot; for &quot;this&quot; as SVGDocumentExtensions::rebuildAllElementReferencesForTarget()
+        now takes a reference instead of a pointer.
+        * svg/SVGElement.h:
+        (WebCore::SVGElement::callClearTarget): Added; calls through to private virtual SVGElement::clearTarget().
+        (WebCore::SVGElement::clearTarget): Added.
+        * svg/SVGTRefElement.cpp:
+        (WebCore::SVGTRefElement::clearTarget): Added.
+        * svg/SVGTRefElement.h:
+        * svg/animation/SVGSMILElement.cpp:
+        (WebCore::SVGSMILElement::clearTarget): Added.
+        * svg/animation/SVGSMILElement.h:
+
</ins><span class="cx"> 2014-05-15  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [iOS WK2] When zoomed, fixed elements jump at the start of a scroll, and jump back at the end.
</span></span></pre></div>
<a id="trunkSourceWebCoredomContainerNodecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (168920 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ContainerNode.cpp        2014-05-16 03:56:10 UTC (rev 168920)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -47,6 +47,8 @@
</span><span class="cx"> #include &quot;RenderWidget.h&quot;
</span><span class="cx"> #include &quot;ResourceLoadScheduler.h&quot;
</span><span class="cx"> #include &quot;RootInlineBox.h&quot;
</span><ins>+#include &quot;SVGDocumentExtensions.h&quot;
+#include &quot;SVGNames.h&quot;
</ins><span class="cx"> #include &quot;SelectorQuery.h&quot;
</span><span class="cx"> #include &quot;TemplateContentDocumentFragment.h&quot;
</span><span class="cx"> #include &lt;wtf/CurrentTime.h&gt;
</span><span class="lines">@@ -565,6 +567,14 @@
</span><span class="cx"> 
</span><span class="cx">         ChildNodeRemovalNotifier(*this).notify(child.get());
</span><span class="cx">     }
</span><ins>+
+
+    if (document().svgExtensions()) {
+        Element* shadowHost = this-&gt;shadowHost();
+        if (!shadowHost || !shadowHost-&gt;hasTagName(SVGNames::useTag))
+            document().accessSVGExtensions()-&gt;rebuildElements();
+    }
+
</ins><span class="cx">     dispatchSubtreeModifiedEvent();
</span><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="lines">@@ -656,6 +666,12 @@
</span><span class="cx">             ChildNodeRemovalNotifier(*this).notify(removedChildren[i].get());
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    if (document().svgExtensions()) {
+        Element* shadowHost = this-&gt;shadowHost();
+        if (!shadowHost || !shadowHost-&gt;hasTagName(SVGNames::useTag))
+            document().accessSVGExtensions()-&gt;rebuildElements();
+    }
+
</ins><span class="cx">     dispatchSubtreeModifiedEvent();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGDocumentExtensionscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGDocumentExtensions.cpp (168920 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGDocumentExtensions.cpp        2014-05-16 03:56:10 UTC (rev 168920)
+++ trunk/Source/WebCore/svg/SVGDocumentExtensions.cpp        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #include &quot;SVGSMILElement.h&quot;
</span><span class="cx"> #include &quot;SVGSVGElement.h&quot;
</span><span class="cx"> #include &quot;ScriptableDocumentParser.h&quot;
</span><ins>+#include &quot;ShadowRoot.h&quot;
</ins><span class="cx"> #include &quot;XLinkNames.h&quot;
</span><span class="cx"> #include &lt;wtf/text/AtomicString.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -331,29 +332,48 @@
</span><span class="cx">         m_elementDependencies.remove(*it);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void SVGDocumentExtensions::rebuildAllElementReferencesForTarget(SVGElement* referencedElement)
</del><ins>+void SVGDocumentExtensions::rebuildElements()
</ins><span class="cx"> {
</span><del>-    ASSERT(referencedElement);
-    auto it = m_elementDependencies.find(referencedElement);
</del><ins>+    Vector&lt;SVGElement*&gt; shadowRebuildElements = std::move(m_rebuildElements);
+    for (auto* element : shadowRebuildElements)
+        element-&gt;svgAttributeChanged(XLinkNames::hrefAttr);
+}
+
+void SVGDocumentExtensions::clearTargetDependencies(SVGElement&amp; referencedElement)
+{
+    if (referencedElement.isInShadowTree()) {
+        // The host element (e.g. &lt;use&gt;) of the shadow root will rebuild the shadow tree
+        // and all its references.
+        ASSERT(referencedElement.shadowRoot());
+        ASSERT(m_rebuildElements.contains(referencedElement.shadowRoot()-&gt;hostElement()));
+        return;
+    }
+    auto it = m_elementDependencies.find(&amp;referencedElement);
</ins><span class="cx">     if (it == m_elementDependencies.end())
</span><span class="cx">         return;
</span><del>-    ASSERT(it-&gt;key == referencedElement);
-    Vector&lt;SVGElement*&gt; toBeNotified;
</del><ins>+    ASSERT(it-&gt;key == &amp;referencedElement);
+    HashSet&lt;SVGElement*&gt;* referencingElements = it-&gt;value.get();
+    for (auto* element : *referencingElements) {
+        m_rebuildElements.append(element);
+        element-&gt;callClearTarget();
+    }
+}
</ins><span class="cx"> 
</span><ins>+void SVGDocumentExtensions::rebuildAllElementReferencesForTarget(SVGElement&amp; referencedElement)
+{
+    auto it = m_elementDependencies.find(&amp;referencedElement);
+    if (it == m_elementDependencies.end())
+        return;
+    ASSERT(it-&gt;key == &amp;referencedElement);
+
</ins><span class="cx">     HashSet&lt;SVGElement*&gt;* referencingElements = it-&gt;value.get();
</span><del>-    auto setEnd = referencingElements-&gt;end();
-    for (auto setIt = referencingElements-&gt;begin(); setIt != setEnd; ++setIt)
-        toBeNotified.append(*setIt);
</del><ins>+    Vector&lt;SVGElement*&gt; elementsToRebuild;
+    elementsToRebuild.reserveInitialCapacity(referencingElements-&gt;size());
+    for (auto* element : *referencingElements)
+        elementsToRebuild.uncheckedAppend(element);
</ins><span class="cx"> 
</span><del>-    // Force rebuilding the referencingElement so it knows about this change.
-    auto vectorEnd = toBeNotified.end();
-    for (auto vectorIt = toBeNotified.begin(); vectorIt != vectorEnd; ++vectorIt) {
-        // Before rebuilding referencingElement ensure it was not removed from under us.
-        if (HashSet&lt;SVGElement*&gt;* referencingElements = setOfElementsReferencingTarget(referencedElement)) {
-            if (referencingElements-&gt;contains(*vectorIt))
-                (*vectorIt)-&gt;svgAttributeChanged(XLinkNames::hrefAttr);
-        }
-    }
</del><ins>+    for (auto* element : elementsToRebuild)
+        element-&gt;svgAttributeChanged(XLinkNames::hrefAttr);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SVGDocumentExtensions::removeAllElementReferencesForTarget(SVGElement* referencedElement)
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGDocumentExtensionsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGDocumentExtensions.h (168920 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGDocumentExtensions.h        2014-05-16 03:56:10 UTC (rev 168920)
+++ trunk/Source/WebCore/svg/SVGDocumentExtensions.h        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -66,9 +66,12 @@
</span><span class="cx">     HashSet&lt;SVGElement*&gt;* setOfElementsReferencingTarget(SVGElement* referencedElement) const;
</span><span class="cx">     void addElementReferencingTarget(SVGElement* referencingElement, SVGElement* referencedElement);
</span><span class="cx">     void removeAllTargetReferencesForElement(SVGElement*);
</span><del>-    void rebuildAllElementReferencesForTarget(SVGElement*);
</del><ins>+    void rebuildAllElementReferencesForTarget(SVGElement&amp;);
</ins><span class="cx">     void removeAllElementReferencesForTarget(SVGElement*);
</span><span class="cx"> 
</span><ins>+    void clearTargetDependencies(SVGElement&amp;);
+    void rebuildElements();
+
</ins><span class="cx"> #if ENABLE(SVG_FONTS)
</span><span class="cx">     const HashSet&lt;SVGFontFaceElement*&gt;&amp; svgFontFaceElements() const { return m_svgFontFaceElements; }
</span><span class="cx">     void registerSVGFontFaceElement(SVGFontFaceElement*);
</span><span class="lines">@@ -87,6 +90,7 @@
</span><span class="cx">     HashMap&lt;SVGElement*, std::unique_ptr&lt;HashSet&lt;SVGElement*&gt;&gt;&gt; m_elementDependencies;
</span><span class="cx">     std::unique_ptr&lt;SVGResourcesCache&gt; m_resourcesCache;
</span><span class="cx"> 
</span><ins>+    Vector&lt;SVGElement*&gt; m_rebuildElements;
</ins><span class="cx"> public:
</span><span class="cx">     // This HashMap contains a list of pending resources. Pending resources, are such
</span><span class="cx">     // which are referenced by any object in the SVG document, but do NOT exist yet.
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGElement.cpp (168920 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGElement.cpp        2014-05-16 03:56:10 UTC (rev 168920)
+++ trunk/Source/WebCore/svg/SVGElement.cpp        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -249,7 +249,7 @@
</span><span class="cx"> 
</span><span class="cx">         m_svgRareData = nullptr;
</span><span class="cx">     }
</span><del>-    document().accessSVGExtensions()-&gt;rebuildAllElementReferencesForTarget(this);
</del><ins>+    document().accessSVGExtensions()-&gt;rebuildAllElementReferencesForTarget(*this);
</ins><span class="cx">     document().accessSVGExtensions()-&gt;removeAllElementReferencesForTarget(this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -346,7 +346,7 @@
</span><span class="cx">     StyledElement::removedFrom(rootParent);
</span><span class="cx"> 
</span><span class="cx">     if (wasInDocument) {
</span><del>-        document().accessSVGExtensions()-&gt;rebuildAllElementReferencesForTarget(this);
</del><ins>+        document().accessSVGExtensions()-&gt;clearTargetDependencies(*this);
</ins><span class="cx">         document().accessSVGExtensions()-&gt;removeAllElementReferencesForTarget(this);
</span><span class="cx">     }
</span><span class="cx">     SVGElementInstance::invalidateAllInstancesOfElement(this);
</span><span class="lines">@@ -697,7 +697,7 @@
</span><span class="cx">     StyledElement::attributeChanged(name, oldValue, newValue);
</span><span class="cx"> 
</span><span class="cx">     if (name == HTMLNames::idAttr)
</span><del>-        document().accessSVGExtensions()-&gt;rebuildAllElementReferencesForTarget(this);
</del><ins>+        document().accessSVGExtensions()-&gt;rebuildAllElementReferencesForTarget(*this);
</ins><span class="cx"> 
</span><span class="cx">     // Changes to the style attribute are processed lazily (see Element::getAttribute() and related methods),
</span><span class="cx">     // so we don't want changes to the style attribute to result in extra work here.
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGElement.h (168920 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGElement.h        2014-05-16 03:56:10 UTC (rev 168920)
+++ trunk/Source/WebCore/svg/SVGElement.h        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -145,6 +145,8 @@
</span><span class="cx">     bool hasTagName(const SVGQualifiedName&amp; name) const { return hasLocalName(name.localName()); }
</span><span class="cx">     virtual short tabIndex() const override;
</span><span class="cx"> 
</span><ins>+    void callClearTarget() { clearTarget(); }
+
</ins><span class="cx"> protected:
</span><span class="cx">     SVGElement(const QualifiedName&amp;, Document&amp;);
</span><span class="cx">     virtual ~SVGElement();
</span><span class="lines">@@ -181,6 +183,8 @@
</span><span class="cx"> 
</span><span class="cx">     virtual bool isSupported(StringImpl* feature, StringImpl* version) const;
</span><span class="cx"> 
</span><ins>+    virtual void clearTarget() { }
+
</ins><span class="cx">     void mapInstanceToElement(SVGElementInstance*);
</span><span class="cx">     void removeInstanceMapping(SVGElementInstance*);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGTRefElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGTRefElement.cpp (168920 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGTRefElement.cpp        2014-05-16 03:56:10 UTC (rev 168920)
+++ trunk/Source/WebCore/svg/SVGTRefElement.cpp        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -243,6 +243,11 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void SVGTRefElement::clearTarget()
+{
+    m_targetListener-&gt;detach();
+}
+
</ins><span class="cx"> void SVGTRefElement::buildPendingResource()
</span><span class="cx"> {
</span><span class="cx">     // Remove any existing event listener.
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGTRefElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGTRefElement.h (168920 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGTRefElement.h        2014-05-16 03:56:10 UTC (rev 168920)
+++ trunk/Source/WebCore/svg/SVGTRefElement.h        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -53,6 +53,8 @@
</span><span class="cx">     virtual InsertionNotificationRequest insertedInto(ContainerNode&amp;) override;
</span><span class="cx">     virtual void removedFrom(ContainerNode&amp;) override;
</span><span class="cx"> 
</span><ins>+    virtual void clearTarget() override;
+
</ins><span class="cx">     void updateReferencedText(Element*);
</span><span class="cx"> 
</span><span class="cx">     void detachTarget();
</span></span></pre></div>
<a id="trunkSourceWebCoresvganimationSVGSMILElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp (168920 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp        2014-05-16 03:56:10 UTC (rev 168920)
+++ trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -146,6 +146,11 @@
</span><span class="cx">     document().accessSVGExtensions()-&gt;removeAllTargetReferencesForElement(this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void SVGSMILElement::clearTarget()
+{
+    setTargetElement(nullptr);
+}
+
</ins><span class="cx"> void SVGSMILElement::buildPendingResource()
</span><span class="cx"> {
</span><span class="cx">     clearResourceReferences();
</span></span></pre></div>
<a id="trunkSourceWebCoresvganimationSVGSMILElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/animation/SVGSMILElement.h (168920 => 168921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/animation/SVGSMILElement.h        2014-05-16 03:56:10 UTC (rev 168920)
+++ trunk/Source/WebCore/svg/animation/SVGSMILElement.h        2014-05-16 04:30:12 UTC (rev 168921)
</span><span class="lines">@@ -126,6 +126,8 @@
</span><span class="cx">     void buildPendingResource() override;
</span><span class="cx">     void clearResourceReferences();
</span><span class="cx"> 
</span><ins>+    virtual void clearTarget() override;
+
</ins><span class="cx">     virtual void startedActiveInterval() = 0;
</span><span class="cx">     void endedActiveInterval();
</span><span class="cx">     virtual void updateAnimation(float percent, unsigned repeat, SVGSMILElement* resultElement) = 0;
</span></span></pre>
</div>
</div>

</body>
</html>