<!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>[186749] branches/safari-600.1.4.17-branch</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/186749">186749</a></dd>
<dt>Author</dt> <dd>ddkilzer@apple.com</dd>
<dt>Date</dt> <dd>2015-07-12 23:11:46 -0700 (Sun, 12 Jul 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/185769">r185769</a>. rdar://problem/21727217</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6001417branchLayoutTestsChangeLog">branches/safari-600.1.4.17-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari6001417branchSourceWebCoreChangeLog">branches/safari-600.1.4.17-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari6001417branchSourceWebCoredomScriptElementcpp">branches/safari-600.1.4.17-branch/Source/WebCore/dom/ScriptElement.cpp</a></li>
<li><a href="#branchessafari6001417branchSourceWebCoredomScriptElementh">branches/safari-600.1.4.17-branch/Source/WebCore/dom/ScriptElement.h</a></li>
<li><a href="#branchessafari6001417branchSourceWebCorehtmlHTMLScriptElementcpp">branches/safari-600.1.4.17-branch/Source/WebCore/html/HTMLScriptElement.cpp</a></li>
<li><a href="#branchessafari6001417branchSourceWebCorehtmlHTMLScriptElementh">branches/safari-600.1.4.17-branch/Source/WebCore/html/HTMLScriptElement.h</a></li>
<li><a href="#branchessafari6001417branchSourceWebCoresvgSVGScriptElementcpp">branches/safari-600.1.4.17-branch/Source/WebCore/svg/SVGScriptElement.cpp</a></li>
<li><a href="#branchessafari6001417branchSourceWebCoresvgSVGScriptElementh">branches/safari-600.1.4.17-branch/Source/WebCore/svg/SVGScriptElement.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari6001417branchLayoutTestsfastdomelementremovedwhileinsertingparentcrashexpectedtxt">branches/safari-600.1.4.17-branch/LayoutTests/fast/dom/element-removed-while-inserting-parent-crash-expected.txt</a></li>
<li><a href="#branchessafari6001417branchLayoutTestsfastdomelementremovedwhileinsertingparentcrashhtml">branches/safari-600.1.4.17-branch/LayoutTests/fast/dom/element-removed-while-inserting-parent-crash.html</a></li>
<li><a href="#branchessafari6001417branchLayoutTestsfastdomnamedmapremovedwhileinsertingparentcrashexpectedtxt">branches/safari-600.1.4.17-branch/LayoutTests/fast/dom/named-map-removed-while-inserting-parent-crash-expected.txt</a></li>
<li><a href="#branchessafari6001417branchLayoutTestsfastdomnamedmapremovedwhileinsertingparentcrashhtml">branches/safari-600.1.4.17-branch/LayoutTests/fast/dom/named-map-removed-while-inserting-parent-crash.html</a></li>
<li><a href="#branchessafari6001417branchLayoutTestsfastformsformcontrolremovedwhileinsertingparentcrashexpectedtxt">branches/safari-600.1.4.17-branch/LayoutTests/fast/forms/form-control-removed-while-inserting-parent-crash-expected.txt</a></li>
<li><a href="#branchessafari6001417branchLayoutTestsfastformsformcontrolremovedwhileinsertingparentcrashhtml">branches/safari-600.1.4.17-branch/LayoutTests/fast/forms/form-control-removed-while-inserting-parent-crash.html</a></li>
<li><a href="#branchessafari6001417branchLayoutTestssvgdomelementremovedwhileinsertingparentcrashexpectedtxt">branches/safari-600.1.4.17-branch/LayoutTests/svg/dom/element-removed-while-inserting-parent-crash-expected.txt</a></li>
<li><a href="#branchessafari6001417branchLayoutTestssvgdomelementremovedwhileinsertingparentcrashhtml">branches/safari-600.1.4.17-branch/LayoutTests/svg/dom/element-removed-while-inserting-parent-crash.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari6001417branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.17-branch/LayoutTests/ChangeLog (186748 => 186749)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.17-branch/LayoutTests/ChangeLog        2015-07-13 05:24:09 UTC (rev 186748)
+++ branches/safari-600.1.4.17-branch/LayoutTests/ChangeLog        2015-07-13 06:11:46 UTC (rev 186749)
</span><span class="lines">@@ -1,5 +1,28 @@
</span><span class="cx"> 2015-07-12  David Kilzer  &lt;ddkilzer@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r185769. rdar://problem/21727217
+
+    2015-06-19  Andy Estes  &lt;aestes@apple.com&gt;
+
+        Various assertion failures occur when executing script in the midst of DOM insertion
+        https://bugs.webkit.org/show_bug.cgi?id=132482
+
+        Reviewed by Darin Adler.
+
+        Wrote named-map-removed-while-inserting-parent-crash.html by reducing the test case attached to bug 132482.
+        The remaining tests were taken from blink r132482.
+
+        * fast/dom/element-removed-while-inserting-parent-crash-expected.txt: Added.
+        * fast/dom/element-removed-while-inserting-parent-crash.html: Added.
+        * fast/dom/named-map-removed-while-inserting-parent-crash-expected.txt: Added.
+        * fast/dom/named-map-removed-while-inserting-parent-crash.html: Added.
+        * fast/forms/form-control-removed-while-inserting-parent-crash-expected.txt: Added.
+        * fast/forms/form-control-removed-while-inserting-parent-crash.html: Added.
+        * svg/dom/element-removed-while-inserting-parent-crash-expected.txt: Added.
+        * svg/dom/element-removed-while-inserting-parent-crash.html: Added.
+
+2015-07-12  David Kilzer  &lt;ddkilzer@apple.com&gt;
+
</ins><span class="cx">         Merge r186474. rdar://problem/21716537
</span><span class="cx"> 
</span><span class="cx">     2015-07-07  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari6001417branchLayoutTestsfastdomelementremovedwhileinsertingparentcrashexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-600.1.4.17-branch/LayoutTests/fast/dom/element-removed-while-inserting-parent-crash-expected.txt (0 => 186749)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.17-branch/LayoutTests/fast/dom/element-removed-while-inserting-parent-crash-expected.txt                                (rev 0)
+++ branches/safari-600.1.4.17-branch/LayoutTests/fast/dom/element-removed-while-inserting-parent-crash-expected.txt        2015-07-13 06:11:46 UTC (rev 186749)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+PASS
</ins></span></pre></div>
<a id="branchessafari6001417branchLayoutTestsfastdomelementremovedwhileinsertingparentcrashhtml"></a>
<div class="addfile"><h4>Added: branches/safari-600.1.4.17-branch/LayoutTests/fast/dom/element-removed-while-inserting-parent-crash.html (0 => 186749)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.17-branch/LayoutTests/fast/dom/element-removed-while-inserting-parent-crash.html                                (rev 0)
+++ branches/safari-600.1.4.17-branch/LayoutTests/fast/dom/element-removed-while-inserting-parent-crash.html        2015-07-13 06:11:46 UTC (rev 186749)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;body&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+var element = document.createElement();
+
+var script = document.createElement('script');
+script.textContent = 'document.currentScript.nextSibling.remove()';
+
+var container = document.createElement('div');
+container.appendChild(script);
+container.appendChild(element);
+
+document.body.appendChild(container);
+document.body.innerHTML = 'PASS';
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="branchessafari6001417branchLayoutTestsfastdomnamedmapremovedwhileinsertingparentcrashexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-600.1.4.17-branch/LayoutTests/fast/dom/named-map-removed-while-inserting-parent-crash-expected.txt (0 => 186749)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.17-branch/LayoutTests/fast/dom/named-map-removed-while-inserting-parent-crash-expected.txt                                (rev 0)
+++ branches/safari-600.1.4.17-branch/LayoutTests/fast/dom/named-map-removed-while-inserting-parent-crash-expected.txt        2015-07-13 06:11:46 UTC (rev 186749)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+PASS
</ins></span></pre></div>
<a id="branchessafari6001417branchLayoutTestsfastdomnamedmapremovedwhileinsertingparentcrashhtml"></a>
<div class="addfile"><h4>Added: branches/safari-600.1.4.17-branch/LayoutTests/fast/dom/named-map-removed-while-inserting-parent-crash.html (0 => 186749)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.17-branch/LayoutTests/fast/dom/named-map-removed-while-inserting-parent-crash.html                                (rev 0)
+++ branches/safari-600.1.4.17-branch/LayoutTests/fast/dom/named-map-removed-while-inserting-parent-crash.html        2015-07-13 06:11:46 UTC (rev 186749)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;body&gt;
+
+&lt;!-- Ensures that TreeScope::m_imageMapsByName is created --&gt;
+&lt;map name&gt;&lt;/map&gt;
+
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+var map = document.createElement('map');
+map.name = 'map';
+
+var script = document.createElement('script');
+script.textContent = 'document.currentScript.parentNode.remove()';
+
+var container = document.createElement('div');
+container.appendChild(script);
+container.appendChild(map);
+
+document.body.appendChild(container);
+document.body.innerHTML = 'PASS';
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="branchessafari6001417branchLayoutTestsfastformsformcontrolremovedwhileinsertingparentcrashexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-600.1.4.17-branch/LayoutTests/fast/forms/form-control-removed-while-inserting-parent-crash-expected.txt (0 => 186749)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.17-branch/LayoutTests/fast/forms/form-control-removed-while-inserting-parent-crash-expected.txt                                (rev 0)
+++ branches/safari-600.1.4.17-branch/LayoutTests/fast/forms/form-control-removed-while-inserting-parent-crash-expected.txt        2015-07-13 06:11:46 UTC (rev 186749)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+PASS
</ins></span></pre></div>
<a id="branchessafari6001417branchLayoutTestsfastformsformcontrolremovedwhileinsertingparentcrashhtml"></a>
<div class="addfile"><h4>Added: branches/safari-600.1.4.17-branch/LayoutTests/fast/forms/form-control-removed-while-inserting-parent-crash.html (0 => 186749)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.17-branch/LayoutTests/fast/forms/form-control-removed-while-inserting-parent-crash.html                                (rev 0)
+++ branches/safari-600.1.4.17-branch/LayoutTests/fast/forms/form-control-removed-while-inserting-parent-crash.html        2015-07-13 06:11:46 UTC (rev 186749)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;body&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+var input = document.createElement('input');
+
+var script = document.createElement('script');
+script.textContent = 'document.currentScript.parentNode.remove()';
+
+var container = document.createElement('div');
+container.appendChild(script);
+container.appendChild(input);
+
+document.body.appendChild(container);
+document.body.innerHTML = 'PASS';
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="branchessafari6001417branchLayoutTestssvgdomelementremovedwhileinsertingparentcrashexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-600.1.4.17-branch/LayoutTests/svg/dom/element-removed-while-inserting-parent-crash-expected.txt (0 => 186749)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.17-branch/LayoutTests/svg/dom/element-removed-while-inserting-parent-crash-expected.txt                                (rev 0)
+++ branches/safari-600.1.4.17-branch/LayoutTests/svg/dom/element-removed-while-inserting-parent-crash-expected.txt        2015-07-13 06:11:46 UTC (rev 186749)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+PASS
</ins></span></pre></div>
<a id="branchessafari6001417branchLayoutTestssvgdomelementremovedwhileinsertingparentcrashhtml"></a>
<div class="addfile"><h4>Added: branches/safari-600.1.4.17-branch/LayoutTests/svg/dom/element-removed-while-inserting-parent-crash.html (0 => 186749)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.17-branch/LayoutTests/svg/dom/element-removed-while-inserting-parent-crash.html                                (rev 0)
+++ branches/safari-600.1.4.17-branch/LayoutTests/svg/dom/element-removed-while-inserting-parent-crash.html        2015-07-13 06:11:46 UTC (rev 186749)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;body&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+var element = document.createElementNS('http://www.w3.org/2000/svg');
+
+var script = document.createElementNS('http://www.w3.org/2000/svg', 'script');
+script.id = 'script';
+script.textContent = 'document.getElementById(\'script\').nextSibling.remove()'; // document.currentScript doesn't work for SVGScriptElement.
+
+var container = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
+container.appendChild(script);
+container.appendChild(element);
+
+document.body.appendChild(container);
+document.body.innerHTML = 'PASS';
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="branchessafari6001417branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.17-branch/Source/WebCore/ChangeLog (186748 => 186749)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.17-branch/Source/WebCore/ChangeLog        2015-07-13 05:24:09 UTC (rev 186748)
+++ branches/safari-600.1.4.17-branch/Source/WebCore/ChangeLog        2015-07-13 06:11:46 UTC (rev 186749)
</span><span class="lines">@@ -1,5 +1,48 @@
</span><span class="cx"> 2015-07-12  David Kilzer  &lt;ddkilzer@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r185769. rdar://problem/21727217
+
+    2015-06-19  Andy Estes  &lt;aestes@apple.com&gt;
+
+        Various assertion failures occur when executing script in the midst of DOM insertion
+        https://bugs.webkit.org/show_bug.cgi?id=132482
+
+        Reviewed by Darin Adler.
+
+        Prior to this change, when an element containing a &lt;script&gt; child was inserted into a document, the script was
+        executed in ScriptElement::insertedInto(). That script can access nodes that follow it in the newly-inserted
+        hierarchy but are not yet fully inserted, leading to at least the following problems:
+
+            - The script could remove a node that is not yet marked as in the document.
+            - The script could remove a named &lt;map&gt; that has yet to be added to TreeScope::m_imageMapsByName.
+            - The script could remove a form control that has yet to be added to FormController::m_formElementsWithState.
+
+        These scenarios all result in assertion failures. This change ensures that each node in the newly-inserted
+        hierarchy is fully inserted before executing any scripts.
+
+        Tests: fast/dom/element-removed-while-inserting-parent-crash.html
+               fast/dom/named-map-removed-while-inserting-parent-crash.html
+               fast/forms/form-control-removed-while-inserting-parent-crash.html
+               svg/dom/element-removed-while-inserting-parent-crash.html
+
+        * dom/ScriptElement.cpp:
+        (WebCore::ScriptElement::shouldNotifySubtreeInsertions): Renamed from insertedInto().
+        Returned true in the case where insertedInto() would've called prepareScript().
+        (WebCore::ScriptElement::didNotifySubtreeInsertions): Called prepareScript().
+        (WebCore::ScriptElement::insertedInto): Renamed to shouldNotifySubtreeInsertions().
+        * dom/ScriptElement.h:
+        * html/HTMLScriptElement.cpp:
+        (WebCore::HTMLScriptElement::insertedInto): If shouldNotifySubtreeInsertions() is true, returned InsertionShouldCallDidNotifySubtreeInsertions.
+        Otherwise, returned InsertionDone.
+        (WebCore::HTMLScriptElement::didNotifySubtreeInsertions): Called ScriptElement::didNotifySubtreeInsertions().
+        * html/HTMLScriptElement.h:
+        * svg/SVGScriptElement.cpp:
+        (WebCore::SVGScriptElement::insertedInto): Did the same as HTMLScriptElement::insertedInto().
+        (WebCore::SVGScriptElement::didNotifySubtreeInsertions): Called ScriptElement::didNotifySubtreeInsertions().
+        * svg/SVGScriptElement.h:
+
+2015-07-12  David Kilzer  &lt;ddkilzer@apple.com&gt;
+
</ins><span class="cx">         Merge r186474. rdar://problem/21716537
</span><span class="cx"> 
</span><span class="cx">     2015-07-07  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari6001417branchSourceWebCoredomScriptElementcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.17-branch/Source/WebCore/dom/ScriptElement.cpp (186748 => 186749)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.17-branch/Source/WebCore/dom/ScriptElement.cpp        2015-07-13 05:24:09 UTC (rev 186748)
+++ branches/safari-600.1.4.17-branch/Source/WebCore/dom/ScriptElement.cpp        2015-07-13 06:11:46 UTC (rev 186749)
</span><span class="lines">@@ -79,12 +79,17 @@
</span><span class="cx">     stopLoadRequest();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ScriptElement::insertedInto(ContainerNode&amp; insertionPoint)
</del><ins>+bool ScriptElement::shouldNotifySubtreeInsertions(ContainerNode&amp; insertionPoint)
</ins><span class="cx"> {
</span><del>-    if (insertionPoint.inDocument() &amp;&amp; !m_parserInserted)
-        prepareScript(); // FIXME: Provide a real starting line number here.
</del><ins>+    return insertionPoint.inDocument() &amp;&amp; !m_parserInserted;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void ScriptElement::didNotifySubtreeInsertions(ContainerNode*)
+{
+    ASSERT(!m_parserInserted);
+    prepareScript(); // FIXME: Provide a real starting line number here.
+}
+
</ins><span class="cx"> void ScriptElement::childrenChanged()
</span><span class="cx"> {
</span><span class="cx">     if (!m_parserInserted &amp;&amp; m_element.inDocument())
</span></span></pre></div>
<a id="branchessafari6001417branchSourceWebCoredomScriptElementh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.17-branch/Source/WebCore/dom/ScriptElement.h (186748 => 186749)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.17-branch/Source/WebCore/dom/ScriptElement.h        2015-07-13 05:24:09 UTC (rev 186748)
+++ branches/safari-600.1.4.17-branch/Source/WebCore/dom/ScriptElement.h        2015-07-13 06:11:46 UTC (rev 186749)
</span><span class="lines">@@ -69,7 +69,8 @@
</span><span class="cx">     bool forceAsync() const { return m_forceAsync; }
</span><span class="cx"> 
</span><span class="cx">     // Helper functions used by our parent classes.
</span><del>-    void insertedInto(ContainerNode&amp;);
</del><ins>+    bool shouldNotifySubtreeInsertions(ContainerNode&amp;);
+    void didNotifySubtreeInsertions(ContainerNode*);
</ins><span class="cx">     void childrenChanged();
</span><span class="cx">     void handleSourceAttribute(const String&amp; sourceUrl);
</span><span class="cx">     void handleAsyncAttribute();
</span></span></pre></div>
<a id="branchessafari6001417branchSourceWebCorehtmlHTMLScriptElementcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.17-branch/Source/WebCore/html/HTMLScriptElement.cpp (186748 => 186749)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.17-branch/Source/WebCore/html/HTMLScriptElement.cpp        2015-07-13 05:24:09 UTC (rev 186748)
+++ branches/safari-600.1.4.17-branch/Source/WebCore/html/HTMLScriptElement.cpp        2015-07-13 06:11:46 UTC (rev 186749)
</span><span class="lines">@@ -73,10 +73,14 @@
</span><span class="cx"> Node::InsertionNotificationRequest HTMLScriptElement::insertedInto(ContainerNode&amp; insertionPoint)
</span><span class="cx"> {
</span><span class="cx">     HTMLElement::insertedInto(insertionPoint);
</span><del>-    ScriptElement::insertedInto(insertionPoint);
-    return InsertionDone;
</del><ins>+    return shouldNotifySubtreeInsertions(insertionPoint) ? InsertionShouldCallDidNotifySubtreeInsertions : InsertionDone;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void HTMLScriptElement::didNotifySubtreeInsertions(ContainerNode* node)
+{
+    ScriptElement::didNotifySubtreeInsertions(node);
+}
+
</ins><span class="cx"> void HTMLScriptElement::setText(const String &amp;value)
</span><span class="cx"> {
</span><span class="cx">     Ref&lt;HTMLScriptElement&gt; protectFromMutationEvents(*this);
</span></span></pre></div>
<a id="branchessafari6001417branchSourceWebCorehtmlHTMLScriptElementh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.17-branch/Source/WebCore/html/HTMLScriptElement.h (186748 => 186749)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.17-branch/Source/WebCore/html/HTMLScriptElement.h        2015-07-13 05:24:09 UTC (rev 186748)
+++ branches/safari-600.1.4.17-branch/Source/WebCore/html/HTMLScriptElement.h        2015-07-13 06:11:46 UTC (rev 186749)
</span><span class="lines">@@ -46,6 +46,7 @@
</span><span class="cx"> 
</span><span class="cx">     virtual void parseAttribute(const QualifiedName&amp;, const AtomicString&amp;) override;
</span><span class="cx">     virtual InsertionNotificationRequest insertedInto(ContainerNode&amp;) override;
</span><ins>+    virtual void didNotifySubtreeInsertions(ContainerNode*) override;
</ins><span class="cx">     virtual void childrenChanged(const ChildChange&amp;) override;
</span><span class="cx"> 
</span><span class="cx">     virtual bool isURLAttribute(const Attribute&amp;) const override;
</span></span></pre></div>
<a id="branchessafari6001417branchSourceWebCoresvgSVGScriptElementcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.17-branch/Source/WebCore/svg/SVGScriptElement.cpp (186748 => 186749)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.17-branch/Source/WebCore/svg/SVGScriptElement.cpp        2015-07-13 05:24:09 UTC (rev 186748)
+++ branches/safari-600.1.4.17-branch/Source/WebCore/svg/SVGScriptElement.cpp        2015-07-13 06:11:46 UTC (rev 186749)
</span><span class="lines">@@ -117,12 +117,16 @@
</span><span class="cx"> Node::InsertionNotificationRequest SVGScriptElement::insertedInto(ContainerNode&amp; rootParent)
</span><span class="cx"> {
</span><span class="cx">     SVGElement::insertedInto(rootParent);
</span><del>-    ScriptElement::insertedInto(rootParent);
</del><span class="cx">     if (rootParent.inDocument())
</span><span class="cx">         SVGExternalResourcesRequired::insertedIntoDocument(this);
</span><del>-    return InsertionDone;
</del><ins>+    return shouldNotifySubtreeInsertions(rootParent) ? InsertionShouldCallDidNotifySubtreeInsertions : InsertionDone;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void SVGScriptElement::didNotifySubtreeInsertions(ContainerNode* node)
+{
+    ScriptElement::didNotifySubtreeInsertions(node);
+}
+
</ins><span class="cx"> void SVGScriptElement::childrenChanged(const ChildChange&amp; change)
</span><span class="cx"> {
</span><span class="cx">     SVGElement::childrenChanged(change);
</span></span></pre></div>
<a id="branchessafari6001417branchSourceWebCoresvgSVGScriptElementh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.17-branch/Source/WebCore/svg/SVGScriptElement.h (186748 => 186749)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.17-branch/Source/WebCore/svg/SVGScriptElement.h        2015-07-13 05:24:09 UTC (rev 186748)
+++ branches/safari-600.1.4.17-branch/Source/WebCore/svg/SVGScriptElement.h        2015-07-13 06:11:46 UTC (rev 186749)
</span><span class="lines">@@ -43,6 +43,7 @@
</span><span class="cx">     bool isSupportedAttribute(const QualifiedName&amp;);
</span><span class="cx">     virtual void parseAttribute(const QualifiedName&amp;, const AtomicString&amp;) override;
</span><span class="cx">     virtual InsertionNotificationRequest insertedInto(ContainerNode&amp;) override;
</span><ins>+    virtual void didNotifySubtreeInsertions(ContainerNode*) override;
</ins><span class="cx">     virtual void childrenChanged(const ChildChange&amp;) override;
</span><span class="cx"> 
</span><span class="cx">     virtual void svgAttributeChanged(const QualifiedName&amp;) override;
</span></span></pre>
</div>
</div>

</body>
</html>