<!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>[164005] branches/safari-537.75-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/164005">164005</a></dd>
<dt>Author</dt> <dd>matthew_hanson@apple.com</dd>
<dt>Date</dt> <dd>2014-02-12 18:03:49 -0800 (Wed, 12 Feb 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/163579">r163579</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari53775branchLayoutTestsChangeLog">branches/safari-537.75-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari53775branchLayoutTestsTestExpectations">branches/safari-537.75-branch/LayoutTests/TestExpectations</a></li>
<li><a href="#branchessafari53775branchSourceWebCoreChangeLog">branches/safari-537.75-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari53775branchSourceWebCorehtmlparserHTMLConstructionSitecpp">branches/safari-537.75-branch/Source/WebCore/html/parser/HTMLConstructionSite.cpp</a></li>
<li><a href="#branchessafari53775branchSourceWebCorehtmlparserHTMLConstructionSiteh">branches/safari-537.75-branch/Source/WebCore/html/parser/HTMLConstructionSite.h</a></li>
<li><a href="#branchessafari53775branchSourceWebCorehtmlparserHTMLTreeBuildercpp">branches/safari-537.75-branch/Source/WebCore/html/parser/HTMLTreeBuilder.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari53775branchLayoutTestsfastparseradoptionagencycrash01expectedtxt">branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-01-expected.txt</a></li>
<li><a href="#branchessafari53775branchLayoutTestsfastparseradoptionagencycrash01html">branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-01.html</a></li>
<li><a href="#branchessafari53775branchLayoutTestsfastparseradoptionagencycrash02expectedtxt">branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-02-expected.txt</a></li>
<li><a href="#branchessafari53775branchLayoutTestsfastparseradoptionagencycrash02html">branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-02.html</a></li>
<li><a href="#branchessafari53775branchLayoutTestsfastparseradoptionagencycrash03expectedtxt">branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-03-expected.txt</a></li>
<li><a href="#branchessafari53775branchLayoutTestsfastparseradoptionagencycrash03html">branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-03.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari53775branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-537.75-branch/LayoutTests/ChangeLog (164004 => 164005)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-537.75-branch/LayoutTests/ChangeLog        2014-02-13 01:54:27 UTC (rev 164004)
+++ branches/safari-537.75-branch/LayoutTests/ChangeLog        2014-02-13 02:03:49 UTC (rev 164005)
</span><span class="lines">@@ -1,5 +1,24 @@
</span><span class="cx"> 2014-02-12 Matthew Hanson <matthew_hanson@apple.com>
</span><span class="cx">
</span><ins>+ Merge r163579.
+
+ 2014-02-04 Jeffrey Pfau <jpfau@apple.com>
+
+ Make adoption agency use the task queue
+ https://bugs.webkit.org/show_bug.cgi?id=109445
+
+ Reviewed by Ryosuke Niwa.
+
+ * TestExpectations:
+ * fast/parser/adoption-agency-crash-01-expected.txt: Added.
+ * fast/parser/adoption-agency-crash-01.html: Added.
+ * fast/parser/adoption-agency-crash-02-expected.txt: Added.
+ * fast/parser/adoption-agency-crash-02.html: Added.
+ * fast/parser/adoption-agency-crash-03-expected.txt: Added.
+ * fast/parser/adoption-agency-crash-03.html: Added.
+
+2014-02-12 Matthew Hanson <matthew_hanson@apple.com>
+
</ins><span class="cx"> Merge r162679.
</span><span class="cx">
</span><span class="cx"> 2014-01-23 Jon Honeycutt <jhoneycutt@apple.com>
</span></span></pre></div>
<a id="branchessafari53775branchLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: branches/safari-537.75-branch/LayoutTests/TestExpectations (164004 => 164005)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-537.75-branch/LayoutTests/TestExpectations        2014-02-13 01:54:27 UTC (rev 164004)
+++ branches/safari-537.75-branch/LayoutTests/TestExpectations        2014-02-13 02:03:49 UTC (rev 164005)
</span><span class="lines">@@ -19,4 +19,8 @@
</span><span class="cx"> webkit.org/b/118301 fast/dom/timer-throttling-hidden-page.html [ Skip ]
</span><span class="cx">
</span><span class="cx"> webkit.org/b/57700 mathml/presentation/row.xhtml [ Failure ]
</span><del>-webkit.org/b/57700 mathml/presentation/mo.xhtml [ Failure ]
</del><span class="cx">\ No newline at end of file
</span><ins>+webkit.org/b/57700 mathml/presentation/mo.xhtml [ Failure ]
+
+# These will be fixed soon
+[ Debug ] fast/parser/adoption-agency-crash-01.html [ Crash ]
+[ Debug ] fast/parser/adoption-agency-crash-03.html [ Crash ]
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="branchessafari53775branchLayoutTestsfastparseradoptionagencycrash01expectedtxtfromrev163579trunkLayoutTestsfastparseradoptionagencycrash01expectedtxt"></a>
<div class="copfile"><h4>Copied: branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-01-expected.txt (from rev 163579, trunk/LayoutTests/fast/parser/adoption-agency-crash-01-expected.txt) (0 => 164005)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-01-expected.txt         (rev 0)
+++ branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-01-expected.txt        2014-02-13 02:03:49 UTC (rev 164005)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+PASS
+
</ins></span></pre></div>
<a id="branchessafari53775branchLayoutTestsfastparseradoptionagencycrash01htmlfromrev163579trunkLayoutTestsfastparseradoptionagencycrash01html"></a>
<div class="copfile"><h4>Copied: branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-01.html (from rev 163579, trunk/LayoutTests/fast/parser/adoption-agency-crash-01.html) (0 => 164005)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-01.html         (rev 0)
+++ branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-01.html        2014-02-13 02:03:49 UTC (rev 164005)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+
+document.write('<a><p><iframe onload="document.write(\'<script>void(0)<\/script></a>\');"></iframe><script>document.body.innerHTML = \'PASS\';<\/script>');
+</script>
</ins></span></pre></div>
<a id="branchessafari53775branchLayoutTestsfastparseradoptionagencycrash02expectedtxtfromrev163579trunkLayoutTestsfastparseradoptionagencycrash02expectedtxt"></a>
<div class="copfile"><h4>Copied: branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-02-expected.txt (from rev 163579, trunk/LayoutTests/fast/parser/adoption-agency-crash-02-expected.txt) (0 => 164005)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-02-expected.txt         (rev 0)
+++ branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-02-expected.txt        2014-02-13 02:03:49 UTC (rev 164005)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+PASS
</ins></span></pre></div>
<a id="branchessafari53775branchLayoutTestsfastparseradoptionagencycrash02htmlfromrev163579trunkLayoutTestsfastparseradoptionagencycrash02html"></a>
<div class="copfile"><h4>Copied: branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-02.html (from rev 163579, trunk/LayoutTests/fast/parser/adoption-agency-crash-02.html) (0 => 164005)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-02.html         (rev 0)
+++ branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-02.html        2014-02-13 02:03:49 UTC (rev 164005)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+
+document.write('<a><p><iframe onload="document.write(\'<script>document.body.innerHTML = &quot;PASS&quot;;<\/script></a>\');"></iframe>');
+</script>
</ins></span></pre></div>
<a id="branchessafari53775branchLayoutTestsfastparseradoptionagencycrash03expectedtxtfromrev163579trunkLayoutTestsfastparseradoptionagencycrash03expectedtxt"></a>
<div class="copfile"><h4>Copied: branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-03-expected.txt (from rev 163579, trunk/LayoutTests/fast/parser/adoption-agency-crash-03-expected.txt) (0 => 164005)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-03-expected.txt         (rev 0)
+++ branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-03-expected.txt        2014-02-13 02:03:49 UTC (rev 164005)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+PASS 1 of 2
+PASS 2 of 2
</ins></span></pre></div>
<a id="branchessafari53775branchLayoutTestsfastparseradoptionagencycrash03htmlfromrev163579trunkLayoutTestsfastparseradoptionagencycrash03html"></a>
<div class="copfile"><h4>Copied: branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-03.html (from rev 163579, trunk/LayoutTests/fast/parser/adoption-agency-crash-03.html) (0 => 164005)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-03.html         (rev 0)
+++ branches/safari-537.75-branch/LayoutTests/fast/parser/adoption-agency-crash-03.html        2014-02-13 02:03:49 UTC (rev 164005)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+</script>
+<iframe onload="document.write('<a><blockquote>PASS 2 of 2<iframe onload=&quot;document.write(\'<a>\')&quot;></iframe><script>document.body.innerHTML = \'PASS 1 of 2\';</script>');">
</ins></span></pre></div>
<a id="branchessafari53775branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-537.75-branch/Source/WebCore/ChangeLog (164004 => 164005)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-537.75-branch/Source/WebCore/ChangeLog        2014-02-13 01:54:27 UTC (rev 164004)
+++ branches/safari-537.75-branch/Source/WebCore/ChangeLog        2014-02-13 02:03:49 UTC (rev 164005)
</span><span class="lines">@@ -1,5 +1,40 @@
</span><span class="cx"> 2014-02-12 Matthew Hanson <matthew_hanson@apple.com>
</span><span class="cx">
</span><ins>+ Merge r163579.
+
+ 2014-02-04 Jeffrey Pfau <jpfau@apple.com>
+
+ Make adoption agency use the task queue
+ https://bugs.webkit.org/show_bug.cgi?id=109445
+
+ Reviewed by Ryosuke Niwa.
+
+ Tests: fast/parser/adoption-agency-crash-01.html
+ fast/parser/adoption-agency-crash-02.html
+ fast/parser/adoption-agency-crash-03.html
+
+ * html/parser/HTMLConstructionSite.cpp:
+ (WebCore::insert):
+ (WebCore::executeInsertTask):
+ (WebCore::executeReparentTask):
+ (WebCore::executeInsertAlreadyParsedChildTask):
+ (WebCore::executeTakeAllChildrenTask):
+ (WebCore::executeTask):
+ (WebCore::HTMLConstructionSite::attachLater):
+ (WebCore::HTMLConstructionSite::executeQueuedTasks):
+ (WebCore::HTMLConstructionSite::insertTextNode):
+ (WebCore::HTMLConstructionSite::reparent):
+ (WebCore::HTMLConstructionSite::insertAlreadyParsedChild):
+ (WebCore::HTMLConstructionSite::takeAllChildren):
+ (WebCore::HTMLConstructionSite::fosterParent):
+ * html/parser/HTMLConstructionSite.h:
+ (WebCore::HTMLConstructionSiteTask::HTMLConstructionSiteTask):
+ (WebCore::HTMLConstructionSiteTask::oldParent):
+ * html/parser/HTMLTreeBuilder.cpp:
+ (WebCore::HTMLTreeBuilder::callTheAdoptionAgency):
+
+2014-02-12 Matthew Hanson <matthew_hanson@apple.com>
+
</ins><span class="cx"> Merge r162820.
</span><span class="cx">
</span><span class="cx"> 2014-01-26 David Kilzer <ddkilzer@apple.com>
</span></span></pre></div>
<a id="branchessafari53775branchSourceWebCorehtmlparserHTMLConstructionSitecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-537.75-branch/Source/WebCore/html/parser/HTMLConstructionSite.cpp (164004 => 164005)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-537.75-branch/Source/WebCore/html/parser/HTMLConstructionSite.cpp        2014-02-13 01:54:27 UTC (rev 164004)
+++ branches/safari-537.75-branch/Source/WebCore/html/parser/HTMLConstructionSite.cpp        2014-02-13 02:03:49 UTC (rev 164005)
</span><span class="lines">@@ -87,13 +87,16 @@
</span><span class="cx"> return string.isAllSpecialCharacters<isHTMLSpace>();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static inline void executeTask(HTMLConstructionSiteTask& task)
</del><ins>+static inline void insert(HTMLConstructionSiteTask& task)
</ins><span class="cx"> {
</span><span class="cx"> #if ENABLE(TEMPLATE_ELEMENT)
</span><span class="cx"> if (task.parent->hasTagName(templateTag))
</span><span class="cx"> task.parent = toHTMLTemplateElement(task.parent.get())->content();
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+ if (ContainerNode* parent = task.child->parentNode())
+ parent->parserRemoveChild(task.child.get());
+
</ins><span class="cx"> if (task.nextChild)
</span><span class="cx"> task.parent->parserInsertBefore(task.child.get(), task.nextChild.get());
</span><span class="cx"> else
</span><span class="lines">@@ -104,19 +107,72 @@
</span><span class="cx">
</span><span class="cx"> if (task.child->parentNode() && task.parent->attached() && !task.child->attached())
</span><span class="cx"> task.child->attach();
</span><ins>+}
</ins><span class="cx">
</span><ins>+static inline void executeInsertTask(HTMLConstructionSiteTask& task)
+{
+ ASSERT(task.operation == HTMLConstructionSiteTask::Insert);
+
+ insert(task);
+
</ins><span class="cx"> task.child->beginParsingChildren();
</span><span class="cx">
</span><span class="cx"> if (task.selfClosing)
</span><span class="cx"> task.child->finishParsingChildren();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static inline void executeReparentTask(HTMLConstructionSiteTask& task)
+{
+ ASSERT(task.operation == HTMLConstructionSiteTask::Reparent);
+
+ if (ContainerNode* parent = task.child->parentNode())
+ parent->parserRemoveChild(task.child.get());
+
+ task.parent->parserAppendChild(task.child);
+}
+
+static inline void executeInsertAlreadyParsedChildTask(HTMLConstructionSiteTask& task)
+{
+ ASSERT(task.operation == HTMLConstructionSiteTask::InsertAlreadyParsedChild);
+
+ insert(task);
+}
+
+static inline void executeTakeAllChildrenTask(HTMLConstructionSiteTask& task)
+{
+ ASSERT(task.operation == HTMLConstructionSiteTask::TakeAllChildren);
+
+ task.parent->takeAllChildrenFrom(task.oldParent());
+ // Notice that we don't need to manually attach the moved children
+ // because takeAllChildrenFrom does that work for us.
+}
+
+static inline void executeTask(HTMLConstructionSiteTask& task)
+{
+ switch (task.operation) {
+ case HTMLConstructionSiteTask::Insert:
+ executeInsertTask(task);
+ return;
+ // All the cases below this point are only used by the adoption agency.
+ case HTMLConstructionSiteTask::InsertAlreadyParsedChild:
+ executeInsertAlreadyParsedChildTask(task);
+ return;
+ case HTMLConstructionSiteTask::Reparent:
+ executeReparentTask(task);
+ return;
+ case HTMLConstructionSiteTask::TakeAllChildren:
+ executeTakeAllChildrenTask(task);
+ return;
+ }
+ ASSERT_NOT_REACHED();
+}
+
</ins><span class="cx"> void HTMLConstructionSite::attachLater(ContainerNode* parent, PassRefPtr<Node> prpChild, bool selfClosing)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(scriptingContentIsAllowed(m_parserContentPolicy) || !prpChild.get()->isElementNode() || !toScriptElementIfPossible(toElement(prpChild.get())));
</span><span class="cx"> ASSERT(pluginContentIsAllowed(m_parserContentPolicy) || !prpChild->isPluginElement());
</span><span class="cx">
</span><del>- HTMLConstructionSiteTask task;
</del><ins>+ HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Insert);
</ins><span class="cx"> task.parent = parent;
</span><span class="cx"> task.child = prpChild;
</span><span class="cx"> task.selfClosing = selfClosing;
</span><span class="lines">@@ -131,19 +187,18 @@
</span><span class="cx"> task.parent = task.parent->parentNode();
</span><span class="cx">
</span><span class="cx"> ASSERT(task.parent);
</span><del>- m_attachmentQueue.append(task);
</del><ins>+ m_taskQueue.append(task);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void HTMLConstructionSite::executeQueuedTasks()
</span><span class="cx"> {
</span><del>- const size_t size = m_attachmentQueue.size();
</del><ins>+ const size_t size = m_taskQueue.size();
</ins><span class="cx"> if (!size)
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> // Copy the task queue into a local variable in case executeTask
</span><span class="cx"> // re-enters the parser.
</span><del>- AttachmentQueue queue;
- queue.swap(m_attachmentQueue);
</del><ins>+ TaskQueue queue = std::move(m_taskQueue);
</ins><span class="cx">
</span><span class="cx"> for (size_t i = 0; i < size; ++i)
</span><span class="cx"> executeTask(queue[i]);
</span><span class="lines">@@ -480,7 +535,7 @@
</span><span class="cx">
</span><span class="cx"> void HTMLConstructionSite::insertTextNode(const String& characters, WhitespaceMode whitespaceMode)
</span><span class="cx"> {
</span><del>- HTMLConstructionSiteTask task;
</del><ins>+ HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Insert);
</ins><span class="cx"> task.parent = currentNode();
</span><span class="cx">
</span><span class="cx"> if (shouldFosterParent())
</span><span class="lines">@@ -526,6 +581,43 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void HTMLConstructionSite::reparent(HTMLElementStack::ElementRecord& newParent, HTMLElementStack::ElementRecord& child)
+{
+ HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Reparent);
+ task.parent = newParent.node();
+ task.child = child.element();
+ m_taskQueue.append(task);
+}
+
+void HTMLConstructionSite::reparent(HTMLElementStack::ElementRecord& newParent, HTMLStackItem& child)
+{
+ HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Reparent);
+ task.parent = newParent.node();
+ task.child = child.element();
+ m_taskQueue.append(task);
+}
+
+void HTMLConstructionSite::insertAlreadyParsedChild(HTMLStackItem& newParent, HTMLElementStack::ElementRecord& child)
+{
+ if (newParent.causesFosterParenting()) {
+ fosterParent(child.element());
+ return;
+ }
+
+ HTMLConstructionSiteTask task(HTMLConstructionSiteTask::InsertAlreadyParsedChild);
+ task.parent = newParent.node();
+ task.child = child.element();
+ m_taskQueue.append(task);
+}
+
+void HTMLConstructionSite::takeAllChildren(HTMLStackItem& newParent, HTMLElementStack::ElementRecord& oldParent)
+{
+ HTMLConstructionSiteTask task(HTMLConstructionSiteTask::TakeAllChildren);
+ task.parent = newParent.node();
+ task.child = oldParent.node();
+ m_taskQueue.append(task);
+}
+
</ins><span class="cx"> PassRefPtr<Element> HTMLConstructionSite::createElement(AtomicHTMLToken* token, const AtomicString& namespaceURI)
</span><span class="cx"> {
</span><span class="cx"> QualifiedName tagName(nullAtom, token->name(), namespaceURI);
</span><span class="lines">@@ -661,12 +753,12 @@
</span><span class="cx">
</span><span class="cx"> void HTMLConstructionSite::fosterParent(PassRefPtr<Node> node)
</span><span class="cx"> {
</span><del>- HTMLConstructionSiteTask task;
</del><ins>+ HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Insert);
</ins><span class="cx"> findFosterSite(task);
</span><span class="cx"> task.child = node;
</span><span class="cx"> ASSERT(task.parent);
</span><span class="cx">
</span><del>- m_attachmentQueue.append(task);
</del><ins>+ m_taskQueue.append(task);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari53775branchSourceWebCorehtmlparserHTMLConstructionSiteh"></a>
<div class="modfile"><h4>Modified: branches/safari-537.75-branch/Source/WebCore/html/parser/HTMLConstructionSite.h (164004 => 164005)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-537.75-branch/Source/WebCore/html/parser/HTMLConstructionSite.h        2014-02-13 01:54:27 UTC (rev 164004)
+++ branches/safari-537.75-branch/Source/WebCore/html/parser/HTMLConstructionSite.h        2014-02-13 02:03:49 UTC (rev 164005)
</span><span class="lines">@@ -39,11 +39,28 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> struct HTMLConstructionSiteTask {
</span><del>- HTMLConstructionSiteTask()
- : selfClosing(false)
</del><ins>+ enum Operation {
+ Insert,
+ InsertAlreadyParsedChild,
+ Reparent,
+ TakeAllChildren,
+ };
+
+ explicit HTMLConstructionSiteTask(Operation op)
+ : operation(op)
+ , selfClosing(false)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ ContainerNode* oldParent()
+ {
+ // It's sort of ugly, but we store the |oldParent| in the |child| field
+ // of the task so that we don't bloat the HTMLConstructionSiteTask
+ // object in the common case of the Insert operation.
+ return toContainerNode(child.get());
+ }
+
+ Operation operation;
</ins><span class="cx"> RefPtr<ContainerNode> parent;
</span><span class="cx"> RefPtr<Node> nextChild;
</span><span class="cx"> RefPtr<Node> child;
</span><span class="lines">@@ -100,6 +117,14 @@
</span><span class="cx"> void insertHTMLHtmlStartTagInBody(AtomicHTMLToken*);
</span><span class="cx"> void insertHTMLBodyStartTagInBody(AtomicHTMLToken*);
</span><span class="cx">
</span><ins>+ void reparent(HTMLElementStack::ElementRecord& newParent, HTMLElementStack::ElementRecord& child);
+ void reparent(HTMLElementStack::ElementRecord& newParent, HTMLStackItem& child);
+ // insertAlreadyParsedChild assumes that |child| has already been parsed (i.e., we're just
+ // moving it around in the tree rather than parsing it for the first time). That means
+ // this function doesn't call beginParsingChildren / finishParsingChildren.
+ void insertAlreadyParsedChild(HTMLStackItem& newParent, HTMLElementStack::ElementRecord& child);
+ void takeAllChildren(HTMLStackItem& newParent, HTMLElementStack::ElementRecord& oldParent);
+
</ins><span class="cx"> PassRefPtr<HTMLStackItem> createElementFromSavedToken(HTMLStackItem*);
</span><span class="cx">
</span><span class="cx"> bool shouldFosterParent() const;
</span><span class="lines">@@ -156,7 +181,7 @@
</span><span class="cx"> private:
</span><span class="cx"> // In the common case, this queue will have only one task because most
</span><span class="cx"> // tokens produce only one DOM mutation.
</span><del>- typedef Vector<HTMLConstructionSiteTask, 1> AttachmentQueue;
</del><ins>+ typedef Vector<HTMLConstructionSiteTask, 1> TaskQueue;
</ins><span class="cx">
</span><span class="cx"> void setCompatibilityMode(Document::CompatibilityMode);
</span><span class="cx"> void setCompatibilityModeFromDoctype(const String& name, const String& publicId, const String& systemId);
</span><span class="lines">@@ -183,7 +208,7 @@
</span><span class="cx"> mutable HTMLElementStack m_openElements;
</span><span class="cx"> mutable HTMLFormattingElementList m_activeFormattingElements;
</span><span class="cx">
</span><del>- AttachmentQueue m_attachmentQueue;
</del><ins>+ TaskQueue m_taskQueue;
</ins><span class="cx">
</span><span class="cx"> ParserContentPolicy m_parserContentPolicy;
</span><span class="cx"> bool m_isParsingFragment;
</span></span></pre></div>
<a id="branchessafari53775branchSourceWebCorehtmlparserHTMLTreeBuildercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-537.75-branch/Source/WebCore/html/parser/HTMLTreeBuilder.cpp (164004 => 164005)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-537.75-branch/Source/WebCore/html/parser/HTMLTreeBuilder.cpp        2014-02-13 01:54:27 UTC (rev 164004)
+++ branches/safari-537.75-branch/Source/WebCore/html/parser/HTMLTreeBuilder.cpp        2014-02-13 02:03:49 UTC (rev 164005)
</span><span class="lines">@@ -1595,49 +1595,18 @@
</span><span class="cx"> if (lastNode == furthestBlock)
</span><span class="cx"> bookmark.moveToAfter(nodeEntry);
</span><span class="cx"> // 9.9
</span><del>- if (ContainerNode* parent = lastNode->element()->parentNode())
- parent->parserRemoveChild(lastNode->element());
- node->element()->parserAppendChild(lastNode->element());
- if (lastNode->element()->parentElement()->attached() && !lastNode->element()->attached())
- lastNode->element()->lazyAttach();
</del><ins>+ m_tree.reparent(*node, *lastNode);
</ins><span class="cx"> // 9.10
</span><span class="cx"> lastNode = node;
</span><span class="cx"> }
</span><span class="cx"> // 10.
</span><del>- if (ContainerNode* parent = lastNode->element()->parentNode())
- parent->parserRemoveChild(lastNode->element());
- if (commonAncestor->causesFosterParenting())
- m_tree.fosterParent(lastNode->element());
- else {
-#if ENABLE(TEMPLATE_ELEMENT)
- if (commonAncestor->hasTagName(templateTag))
- toHTMLTemplateElement(commonAncestor->node())->content()->parserAppendChild(lastNode->element());
- else
- commonAncestor->node()->parserAppendChild(lastNode->element());
-#else
- commonAncestor->node()->parserAppendChild(lastNode->element());
-#endif
- ASSERT(lastNode->stackItem()->isElementNode());
- ASSERT(lastNode->element()->parentNode());
- if (lastNode->element()->parentNode()->attached() && !lastNode->element()->attached())
- lastNode->element()->lazyAttach();
- }
</del><ins>+ m_tree.insertAlreadyParsedChild(*commonAncestor, *lastNode);
</ins><span class="cx"> // 11.
</span><span class="cx"> RefPtr<HTMLStackItem> newItem = m_tree.createElementFromSavedToken(formattingElementRecord->stackItem().get());
</span><span class="cx"> // 12.
</span><del>- newItem->element()->takeAllChildrenFrom(furthestBlock->element());
</del><ins>+ m_tree.takeAllChildren(*newItem, *furthestBlock);
</ins><span class="cx"> // 13.
</span><del>- Element* furthestBlockElement = furthestBlock->element();
- // FIXME: All this creation / parserAppendChild / attach business should
- // be in HTMLConstructionSite. My guess is that steps 11--15
- // should all be in some HTMLConstructionSite function.
- furthestBlockElement->parserAppendChild(newItem->element());
- // FIXME: Why is this attach logic necessary? Style resolve should attach us if needed.
- if (furthestBlockElement->attached() && !newItem->element()->attached()) {
- // Notice that newItem->element() might already be attached if, for example, one of the reparented
- // children is a style element, which attaches itself automatically.
- newItem->element()->attach();
- }
</del><ins>+ m_tree.reparent(*furthestBlock, *newItem);
</ins><span class="cx"> // 14.
</span><span class="cx"> m_tree.activeFormattingElements()->swapTo(formattingElement, newItem, bookmark);
</span><span class="cx"> // 15.
</span></span></pre>
</div>
</div>
</body>
</html>