<!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>[200340] trunk/Source/WebCore</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/200340">200340</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-05-02 15:18:05 -0700 (Mon, 02 May 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Modernize HTMLConstructionSite
https://bugs.webkit.org/show_bug.cgi?id=157279

Reviewed by Alex Christensen.

Modernize HTMLConstructionSite: Use less raw pointers, more auto, more
range loops and more nullptr.

* dom/ScriptElement.h:
* html/parser/HTMLConstructionSite.cpp:
(WebCore::setAttributes):
(WebCore::shouldUseLengthLimit):
(WebCore::executeReparentTask):
(WebCore::HTMLConstructionSite::attachLater):
(WebCore::HTMLConstructionSite::executeQueuedTasks):
(WebCore::HTMLConstructionSite::HTMLConstructionSite):
(WebCore::HTMLConstructionSite::takeForm):
(WebCore::HTMLConstructionSite::dispatchDocumentElementAvailableIfNeeded):
(WebCore::HTMLConstructionSite::insertHTMLHtmlStartTagBeforeHTML):
(WebCore::HTMLConstructionSite::mergeAttributesFromTokenIntoElement):
(WebCore::HTMLConstructionSite::insertHTMLHtmlStartTagInBody):
(WebCore::HTMLConstructionSite::insertHTMLBodyStartTagInBody):
(WebCore::HTMLConstructionSite::setDefaultCompatibilityMode):
(WebCore::HTMLConstructionSite::setCompatibilityMode):
(WebCore::HTMLConstructionSite::finishedParsing):
(WebCore::HTMLConstructionSite::insertDoctype):
(WebCore::HTMLConstructionSite::insertComment):
(WebCore::HTMLConstructionSite::insertCommentOnDocument):
(WebCore::HTMLConstructionSite::insertCommentOnHTMLHtmlElement):
(WebCore::HTMLConstructionSite::insertHTMLHeadElement):
(WebCore::HTMLConstructionSite::insertHTMLBodyElement):
(WebCore::HTMLConstructionSite::insertHTMLFormElement):
(WebCore::HTMLConstructionSite::insertHTMLElement):
(WebCore::HTMLConstructionSite::insertHTMLElementOrFindCustomElementInterface):
(WebCore::HTMLConstructionSite::insertCustomElement):
(WebCore::HTMLConstructionSite::insertSelfClosingHTMLElement):
(WebCore::HTMLConstructionSite::insertFormattingElement):
(WebCore::HTMLConstructionSite::insertScriptElement):
(WebCore::HTMLConstructionSite::insertForeignElement):
(WebCore::HTMLConstructionSite::insertTextNode):
(WebCore::HTMLConstructionSite::reparent):
(WebCore::HTMLConstructionSite::insertAlreadyParsedChild):
(WebCore::HTMLConstructionSite::takeAllChildren):
(WebCore::HTMLConstructionSite::createElement):
(WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface):
(WebCore::HTMLConstructionSite::createHTMLElement):
(WebCore::HTMLConstructionSite::createElementFromSavedToken):
(WebCore::HTMLConstructionSite::indexOfFirstUnopenFormattingElement):
(WebCore::HTMLConstructionSite::reconstructTheActiveFormattingElements):
(WebCore::HTMLConstructionSite::findFosterSite):
(WebCore::HTMLConstructionSite::shouldFosterParent):
(WebCore::HTMLConstructionSite::fosterParent):
(WebCore::HTMLConstructionSite::~HTMLConstructionSite): Deleted.
(WebCore::HTMLConstructionSite::setForm): Deleted.
(WebCore::HTMLConstructionSite::setCompatibilityModeFromDoctype): Deleted.
(WebCore::HTMLConstructionSite::ownerDocumentForCurrentNode): Deleted.
(WebCore::HTMLConstructionSite::generateImpliedEndTagsWithExclusion): Deleted.
* html/parser/HTMLConstructionSite.h:
(WebCore::HTMLConstructionSite::inQuirksMode):
(WebCore::HTMLConstructionSite::isTelephoneNumberParsingEnabled):
(WebCore::HTMLConstructionSite::RedirectToFosterParentGuard::RedirectToFosterParentGuard):
* html/parser/HTMLElementStack.cpp:
(WebCore::HTMLNames::isRootNode):
(WebCore::HTMLElementStack::ElementRecord::ElementRecord):
(WebCore::HTMLElementStack::ElementRecord::replaceElement):
(WebCore::HTMLElementStack::ElementRecord::isAbove):
(WebCore::HTMLElementStack::popAll):
(WebCore::HTMLElementStack::popUntil):
(WebCore::HTMLElementStack::popUntilPopped):
(WebCore::HTMLElementStack::pushRootNode):
(WebCore::HTMLElementStack::pushHTMLHtmlElement):
(WebCore::HTMLElementStack::pushRootNodeCommon):
(WebCore::HTMLElementStack::pushHTMLHeadElement):
(WebCore::HTMLElementStack::pushHTMLBodyElement):
(WebCore::HTMLElementStack::push):
(WebCore::HTMLElementStack::insertAbove):
(WebCore::HTMLElementStack::removeHTMLHeadElement):
(WebCore::HTMLElementStack::remove):
(WebCore::HTMLElementStack::contains):
(WebCore::inScopeCommon):
(WebCore::HTMLElementStack::hasNumberedHeaderElementInScope):
(WebCore::HTMLElementStack::inScope):
(WebCore::HTMLElementStack::pushCommon):
(WebCore::HTMLElementStack::popCommon):
(WebCore::HTMLElementStack::removeNonTopCommon):
(WebCore::HTMLElementStack::show):
(WebCore::HTMLElementStack::hasOnlyOneElement): Deleted.
(WebCore::HTMLElementStack::secondElementIsHTMLBodyElement): Deleted.
(WebCore::HTMLElementStack::pop): Deleted.
(WebCore::HTMLElementStack::popUntilTableScopeMarker): Deleted.
(WebCore::HTMLElementStack::oneBelowTop): Deleted.
* html/parser/HTMLElementStack.h:
(WebCore::HTMLElementStack::ElementRecord::stackItem):
(WebCore::HTMLElementStack::ElementRecord::setNext): Deleted.
(WebCore::HTMLElementStack::popUntilPopped): Deleted.
* html/parser/HTMLFormattingElementList.cpp:
(WebCore::HTMLFormattingElementList::contains):
(WebCore::HTMLFormattingElementList::swapTo):
(WebCore::HTMLFormattingElementList::append):
(WebCore::HTMLFormattingElementList::remove):
(WebCore::HTMLFormattingElementList::tryToEnsureNoahsArkConditionQuickly):
(WebCore::HTMLFormattingElementList::ensureNoahsArkCondition):
* html/parser/HTMLFormattingElementList.h:
(WebCore::HTMLFormattingElementList::Entry::Entry):
(WebCore::HTMLFormattingElementList::Entry::replaceElement):
(WebCore::HTMLFormattingElementList::Bookmark::Bookmark):
(WebCore::HTMLFormattingElementList::Bookmark::moveToAfter):
(WebCore::HTMLFormattingElementList::Bookmark::mark):
(WebCore::HTMLFormattingElementList::first):
(WebCore::HTMLFormattingElementList::Entry::isMarker): Deleted.
(WebCore::HTMLFormattingElementList::Entry::stackItem): Deleted.
(WebCore::HTMLFormattingElementList::Entry::operator!=): Deleted.
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::processDoctypeToken):
(WebCore::HTMLTreeBuilder::processCloseWhenNestedTag):
(WebCore::HTMLTreeBuilder::processStartTagForInBody):
(WebCore::HTMLTreeBuilder::insertGenericHTMLElement):
(WebCore::HTMLTreeBuilder::processTemplateStartTag):
(WebCore::HTMLTreeBuilder::processStartTagForInTable):
(WebCore::HTMLTreeBuilder::processStartTag):
(WebCore::HTMLTreeBuilder::processHtmlStartTagForInBody):
(WebCore::HTMLTreeBuilder::processAnyOtherEndTagForInBody):
(WebCore::HTMLTreeBuilder::callTheAdoptionAgency):
(WebCore::HTMLTreeBuilder::processEndTagForInBody):
(WebCore::HTMLTreeBuilder::processComment):
(WebCore::HTMLTreeBuilder::defaultForBeforeHTML):
(WebCore::HTMLTreeBuilder::processStartTagForInHead):
(WebCore::HTMLTreeBuilder::processGenericRCDATAStartTag):
(WebCore::HTMLTreeBuilder::processGenericRawTextStartTag):
(WebCore::HTMLTreeBuilder::processScriptStartTag):
(WebCore::HTMLTreeBuilder::processTokenInForeignContent):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomScriptElementh">trunk/Source/WebCore/dom/ScriptElement.h</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLConstructionSitecpp">trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLConstructionSiteh">trunk/Source/WebCore/html/parser/HTMLConstructionSite.h</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLElementStackcpp">trunk/Source/WebCore/html/parser/HTMLElementStack.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLElementStackh">trunk/Source/WebCore/html/parser/HTMLElementStack.h</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLFormattingElementListcpp">trunk/Source/WebCore/html/parser/HTMLFormattingElementList.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLFormattingElementListh">trunk/Source/WebCore/html/parser/HTMLFormattingElementList.h</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLTreeBuildercpp">trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (200339 => 200340)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-05-02 21:42:07 UTC (rev 200339)
+++ trunk/Source/WebCore/ChangeLog        2016-05-02 22:18:05 UTC (rev 200340)
</span><span class="lines">@@ -1,3 +1,137 @@
</span><ins>+2016-05-02  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Modernize HTMLConstructionSite
+        https://bugs.webkit.org/show_bug.cgi?id=157279
+
+        Reviewed by Alex Christensen.
+
+        Modernize HTMLConstructionSite: Use less raw pointers, more auto, more
+        range loops and more nullptr.
+
+        * dom/ScriptElement.h:
+        * html/parser/HTMLConstructionSite.cpp:
+        (WebCore::setAttributes):
+        (WebCore::shouldUseLengthLimit):
+        (WebCore::executeReparentTask):
+        (WebCore::HTMLConstructionSite::attachLater):
+        (WebCore::HTMLConstructionSite::executeQueuedTasks):
+        (WebCore::HTMLConstructionSite::HTMLConstructionSite):
+        (WebCore::HTMLConstructionSite::takeForm):
+        (WebCore::HTMLConstructionSite::dispatchDocumentElementAvailableIfNeeded):
+        (WebCore::HTMLConstructionSite::insertHTMLHtmlStartTagBeforeHTML):
+        (WebCore::HTMLConstructionSite::mergeAttributesFromTokenIntoElement):
+        (WebCore::HTMLConstructionSite::insertHTMLHtmlStartTagInBody):
+        (WebCore::HTMLConstructionSite::insertHTMLBodyStartTagInBody):
+        (WebCore::HTMLConstructionSite::setDefaultCompatibilityMode):
+        (WebCore::HTMLConstructionSite::setCompatibilityMode):
+        (WebCore::HTMLConstructionSite::finishedParsing):
+        (WebCore::HTMLConstructionSite::insertDoctype):
+        (WebCore::HTMLConstructionSite::insertComment):
+        (WebCore::HTMLConstructionSite::insertCommentOnDocument):
+        (WebCore::HTMLConstructionSite::insertCommentOnHTMLHtmlElement):
+        (WebCore::HTMLConstructionSite::insertHTMLHeadElement):
+        (WebCore::HTMLConstructionSite::insertHTMLBodyElement):
+        (WebCore::HTMLConstructionSite::insertHTMLFormElement):
+        (WebCore::HTMLConstructionSite::insertHTMLElement):
+        (WebCore::HTMLConstructionSite::insertHTMLElementOrFindCustomElementInterface):
+        (WebCore::HTMLConstructionSite::insertCustomElement):
+        (WebCore::HTMLConstructionSite::insertSelfClosingHTMLElement):
+        (WebCore::HTMLConstructionSite::insertFormattingElement):
+        (WebCore::HTMLConstructionSite::insertScriptElement):
+        (WebCore::HTMLConstructionSite::insertForeignElement):
+        (WebCore::HTMLConstructionSite::insertTextNode):
+        (WebCore::HTMLConstructionSite::reparent):
+        (WebCore::HTMLConstructionSite::insertAlreadyParsedChild):
+        (WebCore::HTMLConstructionSite::takeAllChildren):
+        (WebCore::HTMLConstructionSite::createElement):
+        (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface):
+        (WebCore::HTMLConstructionSite::createHTMLElement):
+        (WebCore::HTMLConstructionSite::createElementFromSavedToken):
+        (WebCore::HTMLConstructionSite::indexOfFirstUnopenFormattingElement):
+        (WebCore::HTMLConstructionSite::reconstructTheActiveFormattingElements):
+        (WebCore::HTMLConstructionSite::findFosterSite):
+        (WebCore::HTMLConstructionSite::shouldFosterParent):
+        (WebCore::HTMLConstructionSite::fosterParent):
+        (WebCore::HTMLConstructionSite::~HTMLConstructionSite): Deleted.
+        (WebCore::HTMLConstructionSite::setForm): Deleted.
+        (WebCore::HTMLConstructionSite::setCompatibilityModeFromDoctype): Deleted.
+        (WebCore::HTMLConstructionSite::ownerDocumentForCurrentNode): Deleted.
+        (WebCore::HTMLConstructionSite::generateImpliedEndTagsWithExclusion): Deleted.
+        * html/parser/HTMLConstructionSite.h:
+        (WebCore::HTMLConstructionSite::inQuirksMode):
+        (WebCore::HTMLConstructionSite::isTelephoneNumberParsingEnabled):
+        (WebCore::HTMLConstructionSite::RedirectToFosterParentGuard::RedirectToFosterParentGuard):
+        * html/parser/HTMLElementStack.cpp:
+        (WebCore::HTMLNames::isRootNode):
+        (WebCore::HTMLElementStack::ElementRecord::ElementRecord):
+        (WebCore::HTMLElementStack::ElementRecord::replaceElement):
+        (WebCore::HTMLElementStack::ElementRecord::isAbove):
+        (WebCore::HTMLElementStack::popAll):
+        (WebCore::HTMLElementStack::popUntil):
+        (WebCore::HTMLElementStack::popUntilPopped):
+        (WebCore::HTMLElementStack::pushRootNode):
+        (WebCore::HTMLElementStack::pushHTMLHtmlElement):
+        (WebCore::HTMLElementStack::pushRootNodeCommon):
+        (WebCore::HTMLElementStack::pushHTMLHeadElement):
+        (WebCore::HTMLElementStack::pushHTMLBodyElement):
+        (WebCore::HTMLElementStack::push):
+        (WebCore::HTMLElementStack::insertAbove):
+        (WebCore::HTMLElementStack::removeHTMLHeadElement):
+        (WebCore::HTMLElementStack::remove):
+        (WebCore::HTMLElementStack::contains):
+        (WebCore::inScopeCommon):
+        (WebCore::HTMLElementStack::hasNumberedHeaderElementInScope):
+        (WebCore::HTMLElementStack::inScope):
+        (WebCore::HTMLElementStack::pushCommon):
+        (WebCore::HTMLElementStack::popCommon):
+        (WebCore::HTMLElementStack::removeNonTopCommon):
+        (WebCore::HTMLElementStack::show):
+        (WebCore::HTMLElementStack::hasOnlyOneElement): Deleted.
+        (WebCore::HTMLElementStack::secondElementIsHTMLBodyElement): Deleted.
+        (WebCore::HTMLElementStack::pop): Deleted.
+        (WebCore::HTMLElementStack::popUntilTableScopeMarker): Deleted.
+        (WebCore::HTMLElementStack::oneBelowTop): Deleted.
+        * html/parser/HTMLElementStack.h:
+        (WebCore::HTMLElementStack::ElementRecord::stackItem):
+        (WebCore::HTMLElementStack::ElementRecord::setNext): Deleted.
+        (WebCore::HTMLElementStack::popUntilPopped): Deleted.
+        * html/parser/HTMLFormattingElementList.cpp:
+        (WebCore::HTMLFormattingElementList::contains):
+        (WebCore::HTMLFormattingElementList::swapTo):
+        (WebCore::HTMLFormattingElementList::append):
+        (WebCore::HTMLFormattingElementList::remove):
+        (WebCore::HTMLFormattingElementList::tryToEnsureNoahsArkConditionQuickly):
+        (WebCore::HTMLFormattingElementList::ensureNoahsArkCondition):
+        * html/parser/HTMLFormattingElementList.h:
+        (WebCore::HTMLFormattingElementList::Entry::Entry):
+        (WebCore::HTMLFormattingElementList::Entry::replaceElement):
+        (WebCore::HTMLFormattingElementList::Bookmark::Bookmark):
+        (WebCore::HTMLFormattingElementList::Bookmark::moveToAfter):
+        (WebCore::HTMLFormattingElementList::Bookmark::mark):
+        (WebCore::HTMLFormattingElementList::first):
+        (WebCore::HTMLFormattingElementList::Entry::isMarker): Deleted.
+        (WebCore::HTMLFormattingElementList::Entry::stackItem): Deleted.
+        (WebCore::HTMLFormattingElementList::Entry::operator!=): Deleted.
+        * html/parser/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::processDoctypeToken):
+        (WebCore::HTMLTreeBuilder::processCloseWhenNestedTag):
+        (WebCore::HTMLTreeBuilder::processStartTagForInBody):
+        (WebCore::HTMLTreeBuilder::insertGenericHTMLElement):
+        (WebCore::HTMLTreeBuilder::processTemplateStartTag):
+        (WebCore::HTMLTreeBuilder::processStartTagForInTable):
+        (WebCore::HTMLTreeBuilder::processStartTag):
+        (WebCore::HTMLTreeBuilder::processHtmlStartTagForInBody):
+        (WebCore::HTMLTreeBuilder::processAnyOtherEndTagForInBody):
+        (WebCore::HTMLTreeBuilder::callTheAdoptionAgency):
+        (WebCore::HTMLTreeBuilder::processEndTagForInBody):
+        (WebCore::HTMLTreeBuilder::processComment):
+        (WebCore::HTMLTreeBuilder::defaultForBeforeHTML):
+        (WebCore::HTMLTreeBuilder::processStartTagForInHead):
+        (WebCore::HTMLTreeBuilder::processGenericRCDATAStartTag):
+        (WebCore::HTMLTreeBuilder::processGenericRawTextStartTag):
+        (WebCore::HTMLTreeBuilder::processScriptStartTag):
+        (WebCore::HTMLTreeBuilder::processTokenInForeignContent):
+
</ins><span class="cx"> 2016-05-02  Per Arne Vollan  &lt;peavo@outlook.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove unneeded casts once we upgrade to a version of Visual Studio that is not broken
</span></span></pre></div>
<a id="trunkSourceWebCoredomScriptElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ScriptElement.h (200339 => 200340)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ScriptElement.h        2016-05-02 21:42:07 UTC (rev 200339)
+++ trunk/Source/WebCore/dom/ScriptElement.h        2016-05-02 22:18:05 UTC (rev 200340)
</span><span class="lines">@@ -112,6 +112,7 @@
</span><span class="cx">     String m_fallbackCharacterEncoding;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+// FIXME: replace with downcast&lt;ScriptElement&gt;.
</ins><span class="cx"> ScriptElement* toScriptElementIfPossible(Element*);
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLConstructionSitecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp (200339 => 200340)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp        2016-05-02 21:42:07 UTC (rev 200339)
+++ trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp        2016-05-02 22:18:05 UTC (rev 200340)
</span><span class="lines">@@ -60,9 +60,9 @@
</span><span class="cx">     element.parserSetAttributes(attributes);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline void setAttributes(Element&amp; element, AtomicHTMLToken* token, ParserContentPolicy parserContentPolicy)
</del><ins>+static inline void setAttributes(Element&amp; element, AtomicHTMLToken&amp; token, ParserContentPolicy parserContentPolicy)
</ins><span class="cx"> {
</span><del>-    setAttributes(element, token-&gt;attributes(), parserContentPolicy);
</del><ins>+    setAttributes(element, token.attributes(), parserContentPolicy);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static bool hasImpliedEndTag(const HTMLStackItem&amp; item)
</span><span class="lines">@@ -79,11 +79,9 @@
</span><span class="cx">         || item.hasTagName(rtcTag);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static bool shouldUseLengthLimit(const ContainerNode* node)
</del><ins>+static bool shouldUseLengthLimit(const ContainerNode&amp; node)
</ins><span class="cx"> {
</span><del>-    return !node-&gt;hasTagName(scriptTag)
-        &amp;&amp; !node-&gt;hasTagName(styleTag)
-        &amp;&amp; !node-&gt;hasTagName(SVGNames::scriptTag);
</del><ins>+    return !node.hasTagName(scriptTag) &amp;&amp; !node.hasTagName(styleTag) &amp;&amp; !node.hasTagName(SVGNames::scriptTag);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static inline bool causesFosterParenting(const HTMLStackItem&amp; item)
</span><span class="lines">@@ -130,7 +128,7 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(task.operation == HTMLConstructionSiteTask::Reparent);
</span><span class="cx"> 
</span><del>-    if (ContainerNode* parent = task.child-&gt;parentNode())
</del><ins>+    if (auto* parent = task.child-&gt;parentNode())
</ins><span class="cx">         parent-&gt;parserRemoveChild(*task.child);
</span><span class="cx"> 
</span><span class="cx">     task.parent-&gt;parserAppendChild(*task.child);
</span><span class="lines">@@ -172,79 +170,72 @@
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLConstructionSite::attachLater(ContainerNode* parent, PassRefPtr&lt;Node&gt; prpChild, bool selfClosing)
</del><ins>+void HTMLConstructionSite::attachLater(ContainerNode&amp; parent, Ref&lt;Node&gt;&amp;&amp; child, bool selfClosing)
</ins><span class="cx"> {
</span><del>-    ASSERT(scriptingContentIsAllowed(m_parserContentPolicy) || !is&lt;Element&gt;(*prpChild) || !toScriptElementIfPossible(downcast&lt;Element&gt;(prpChild.get())));
-    ASSERT(pluginContentIsAllowed(m_parserContentPolicy) || !prpChild-&gt;isPluginElement());
</del><ins>+    ASSERT(scriptingContentIsAllowed(m_parserContentPolicy) || !is&lt;Element&gt;(child.get()) || !toScriptElementIfPossible(downcast&lt;Element&gt;(child.ptr())));
+    ASSERT(pluginContentIsAllowed(m_parserContentPolicy) || !child-&gt;isPluginElement());
</ins><span class="cx"> 
</span><del>-    HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Insert);
-    task.parent = parent;
-    task.child = prpChild;
-    task.selfClosing = selfClosing;
-
</del><span class="cx">     if (shouldFosterParent()) {
</span><del>-        fosterParent(task.child);
</del><ins>+        fosterParent(WTFMove(child));
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Insert);
+    task.parent = &amp;parent;
+    task.child = WTFMove(child);
+    task.selfClosing = selfClosing;
+
</ins><span class="cx">     // Add as a sibling of the parent if we have reached the maximum depth allowed.
</span><span class="cx">     if (m_openElements.stackDepth() &gt; m_maximumDOMTreeDepth &amp;&amp; task.parent-&gt;parentNode())
</span><span class="cx">         task.parent = task.parent-&gt;parentNode();
</span><span class="cx"> 
</span><span class="cx">     ASSERT(task.parent);
</span><del>-    m_taskQueue.append(task);
</del><ins>+    m_taskQueue.append(WTFMove(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_taskQueue.size();
-    if (!size)
</del><ins>+    if (m_taskQueue.isEmpty())
</ins><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><span class="cx">     TaskQueue queue = WTFMove(m_taskQueue);
</span><span class="cx"> 
</span><del>-    for (size_t i = 0; i &lt; size; ++i)
-        executeTask(queue[i]);
</del><ins>+    for (auto&amp; task : queue)
+        executeTask(task);
</ins><span class="cx"> 
</span><span class="cx">     // We might be detached now.
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> HTMLConstructionSite::HTMLConstructionSite(Document&amp; document, ParserContentPolicy parserContentPolicy, unsigned maximumDOMTreeDepth)
</span><del>-    : m_document(&amp;document)
-    , m_attachmentRoot(&amp;document)
</del><ins>+    : m_document(document)
+    , m_attachmentRoot(document)
</ins><span class="cx">     , m_parserContentPolicy(parserContentPolicy)
</span><span class="cx">     , m_isParsingFragment(false)
</span><span class="cx">     , m_redirectAttachToFosterParent(false)
</span><span class="cx">     , m_maximumDOMTreeDepth(maximumDOMTreeDepth)
</span><span class="cx">     , m_inQuirksMode(document.inQuirksMode())
</span><span class="cx"> {
</span><del>-    ASSERT(m_document-&gt;isHTMLDocument() || m_document-&gt;isXHTMLDocument());
</del><ins>+    ASSERT(m_document.isHTMLDocument() || m_document.isXHTMLDocument());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> HTMLConstructionSite::HTMLConstructionSite(DocumentFragment&amp; fragment, ParserContentPolicy parserContentPolicy, unsigned maximumDOMTreeDepth)
</span><del>-    : m_document(&amp;fragment.document())
-    , m_attachmentRoot(&amp;fragment)
</del><ins>+    : m_document(fragment.document())
+    , m_attachmentRoot(fragment)
</ins><span class="cx">     , m_parserContentPolicy(parserContentPolicy)
</span><span class="cx">     , m_isParsingFragment(true)
</span><span class="cx">     , m_redirectAttachToFosterParent(false)
</span><span class="cx">     , m_maximumDOMTreeDepth(maximumDOMTreeDepth)
</span><span class="cx">     , m_inQuirksMode(fragment.document().inQuirksMode())
</span><span class="cx"> {
</span><del>-    ASSERT(m_document-&gt;isHTMLDocument() || m_document-&gt;isXHTMLDocument());
</del><ins>+    ASSERT(m_document.isHTMLDocument() || m_document.isXHTMLDocument());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> HTMLConstructionSite::~HTMLConstructionSite()
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLConstructionSite::detach()
-{
-    m_document = 0;
-    m_attachmentRoot = 0;
-}
-
</del><span class="cx"> void HTMLConstructionSite::setForm(HTMLFormElement* form)
</span><span class="cx"> {
</span><span class="cx">     // This method should only be needed for HTMLTreeBuilder in the fragment case.
</span><span class="lines">@@ -252,61 +243,63 @@
</span><span class="cx">     m_form = form;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-PassRefPtr&lt;HTMLFormElement&gt; HTMLConstructionSite::takeForm()
</del><ins>+RefPtr&lt;HTMLFormElement&gt; HTMLConstructionSite::takeForm()
</ins><span class="cx"> {
</span><del>-    return m_form.release();
</del><ins>+    return WTFMove(m_form);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLConstructionSite::dispatchDocumentElementAvailableIfNeeded()
</span><span class="cx"> {
</span><del>-    ASSERT(m_document);
-    if (m_document-&gt;frame() &amp;&amp; !m_isParsingFragment)
-        m_document-&gt;frame()-&gt;injectUserScripts(InjectAtDocumentStart);
</del><ins>+    if (m_isParsingFragment)
+        return;
+
+    if (auto* frame = m_document.frame())
+        frame-&gt;injectUserScripts(InjectAtDocumentStart);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLConstructionSite::insertHTMLHtmlStartTagBeforeHTML(AtomicHTMLToken* token)
</del><ins>+void HTMLConstructionSite::insertHTMLHtmlStartTagBeforeHTML(AtomicHTMLToken&amp; token)
</ins><span class="cx"> {
</span><del>-    Ref&lt;HTMLHtmlElement&gt; element = HTMLHtmlElement::create(*m_document);
-    setAttributes(element.get(), token, m_parserContentPolicy);
-    attachLater(m_attachmentRoot, element.ptr());
-    m_openElements.pushHTMLHtmlElement(HTMLStackItem::create(element.copyRef(), *token));
</del><ins>+    auto element = HTMLHtmlElement::create(m_document);
+    setAttributes(element, token, m_parserContentPolicy);
+    attachLater(m_attachmentRoot, element.copyRef());
+    m_openElements.pushHTMLHtmlElement(HTMLStackItem::create(element.copyRef(), token));
</ins><span class="cx"> 
</span><span class="cx">     executeQueuedTasks();
</span><span class="cx">     element-&gt;insertedByParser();
</span><span class="cx">     dispatchDocumentElementAvailableIfNeeded();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLConstructionSite::mergeAttributesFromTokenIntoElement(AtomicHTMLToken* token, Element* element)
</del><ins>+void HTMLConstructionSite::mergeAttributesFromTokenIntoElement(AtomicHTMLToken&amp; token, Element&amp; element)
</ins><span class="cx"> {
</span><del>-    if (token-&gt;attributes().isEmpty())
</del><ins>+    if (token.attributes().isEmpty())
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    for (auto&amp; tokenAttribute : token-&gt;attributes()) {
-        if (!element-&gt;elementData() || !element-&gt;findAttributeByName(tokenAttribute.name()))
-            element-&gt;setAttribute(tokenAttribute.name(), tokenAttribute.value());
</del><ins>+    for (auto&amp; tokenAttribute : token.attributes()) {
+        if (!element.elementData() || !element.findAttributeByName(tokenAttribute.name()))
+            element.setAttribute(tokenAttribute.name(), tokenAttribute.value());
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLConstructionSite::insertHTMLHtmlStartTagInBody(AtomicHTMLToken* token)
</del><ins>+void HTMLConstructionSite::insertHTMLHtmlStartTagInBody(AtomicHTMLToken&amp; token)
</ins><span class="cx"> {
</span><span class="cx">     // Fragments do not have a root HTML element, so any additional HTML elements
</span><span class="cx">     // encountered during fragment parsing should be ignored.
</span><span class="cx">     if (m_isParsingFragment)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    mergeAttributesFromTokenIntoElement(token, &amp;m_openElements.htmlElement());
</del><ins>+    mergeAttributesFromTokenIntoElement(token, m_openElements.htmlElement());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLConstructionSite::insertHTMLBodyStartTagInBody(AtomicHTMLToken* token)
</del><ins>+void HTMLConstructionSite::insertHTMLBodyStartTagInBody(AtomicHTMLToken&amp; token)
</ins><span class="cx"> {
</span><del>-    mergeAttributesFromTokenIntoElement(token, &amp;m_openElements.bodyElement());
</del><ins>+    mergeAttributesFromTokenIntoElement(token, m_openElements.bodyElement());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLConstructionSite::setDefaultCompatibilityMode()
</span><span class="cx"> {
</span><span class="cx">     if (m_isParsingFragment)
</span><span class="cx">         return;
</span><del>-    if (m_document-&gt;isSrcdocDocument())
</del><ins>+    if (m_document.isSrcdocDocument())
</ins><span class="cx">         return;
</span><span class="cx">     setCompatibilityMode(DocumentCompatibilityMode::QuirksMode);
</span><span class="cx"> }
</span><span class="lines">@@ -314,7 +307,7 @@
</span><span class="cx"> void HTMLConstructionSite::setCompatibilityMode(DocumentCompatibilityMode mode)
</span><span class="cx"> {
</span><span class="cx">     m_inQuirksMode = (mode == DocumentCompatibilityMode::QuirksMode);
</span><del>-    m_document-&gt;setCompatibilityMode(mode);
</del><ins>+    m_document.setCompatibilityMode(mode);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLConstructionSite::setCompatibilityModeFromDoctype(const String&amp; name, const String&amp; publicId, const String&amp; systemId)
</span><span class="lines">@@ -407,18 +400,17 @@
</span><span class="cx"> 
</span><span class="cx"> void HTMLConstructionSite::finishedParsing()
</span><span class="cx"> {
</span><del>-    m_document-&gt;finishedParsing();
</del><ins>+    m_document.finishedParsing();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLConstructionSite::insertDoctype(AtomicHTMLToken* token)
</del><ins>+void HTMLConstructionSite::insertDoctype(AtomicHTMLToken&amp; token)
</ins><span class="cx"> {
</span><del>-    ASSERT(token-&gt;type() == HTMLToken::DOCTYPE);
</del><ins>+    ASSERT(token.type() == HTMLToken::DOCTYPE);
</ins><span class="cx"> 
</span><del>-    String publicId = token-&gt;publicIdentifier();
-    String systemId = token-&gt;systemIdentifier();
</del><ins>+    String publicId = token.publicIdentifier();
+    String systemId = token.systemIdentifier();
</ins><span class="cx"> 
</span><del>-    RefPtr&lt;DocumentType&gt; doctype = DocumentType::create(*m_document, token-&gt;name(), publicId, systemId);
-    attachLater(m_attachmentRoot, doctype.release());
</del><ins>+    attachLater(m_attachmentRoot, DocumentType::create(m_document, token.name(), publicId, systemId));
</ins><span class="cx"> 
</span><span class="cx">     // DOCTYPE nodes are only processed when parsing fragments w/o contextElements, which
</span><span class="cx">     // never occurs.  However, if we ever chose to support such, this code is subtly wrong,
</span><span class="lines">@@ -429,106 +421,107 @@
</span><span class="cx">     if (m_isParsingFragment)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (token-&gt;forceQuirks())
</del><ins>+    if (token.forceQuirks())
</ins><span class="cx">         setCompatibilityMode(DocumentCompatibilityMode::QuirksMode);
</span><span class="cx">     else
</span><del>-        setCompatibilityModeFromDoctype(token-&gt;name(), publicId, systemId);
</del><ins>+        setCompatibilityModeFromDoctype(token.name(), publicId, systemId);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLConstructionSite::insertComment(AtomicHTMLToken* token)
</del><ins>+void HTMLConstructionSite::insertComment(AtomicHTMLToken&amp; token)
</ins><span class="cx"> {
</span><del>-    ASSERT(token-&gt;type() == HTMLToken::Comment);
-    attachLater(&amp;currentNode(), Comment::create(ownerDocumentForCurrentNode(), token-&gt;comment()));
</del><ins>+    ASSERT(token.type() == HTMLToken::Comment);
+    attachLater(currentNode(), Comment::create(ownerDocumentForCurrentNode(), token.comment()));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLConstructionSite::insertCommentOnDocument(AtomicHTMLToken* token)
</del><ins>+void HTMLConstructionSite::insertCommentOnDocument(AtomicHTMLToken&amp; token)
</ins><span class="cx"> {
</span><del>-    ASSERT(token-&gt;type() == HTMLToken::Comment);
-    attachLater(m_attachmentRoot, Comment::create(*m_document, token-&gt;comment()));
</del><ins>+    ASSERT(token.type() == HTMLToken::Comment);
+    attachLater(m_attachmentRoot, Comment::create(m_document, token.comment()));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLConstructionSite::insertCommentOnHTMLHtmlElement(AtomicHTMLToken* token)
</del><ins>+void HTMLConstructionSite::insertCommentOnHTMLHtmlElement(AtomicHTMLToken&amp; token)
</ins><span class="cx"> {
</span><del>-    ASSERT(token-&gt;type() == HTMLToken::Comment);
</del><ins>+    ASSERT(token.type() == HTMLToken::Comment);
</ins><span class="cx">     ContainerNode&amp; parent = m_openElements.rootNode();
</span><del>-    attachLater(&amp;parent, Comment::create(parent.document(), token-&gt;comment()));
</del><ins>+    attachLater(parent, Comment::create(parent.document(), token.comment()));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLConstructionSite::insertHTMLHeadElement(AtomicHTMLToken* token)
</del><ins>+void HTMLConstructionSite::insertHTMLHeadElement(AtomicHTMLToken&amp; token)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!shouldFosterParent());
</span><del>-    m_head = HTMLStackItem::create(createHTMLElement(token), *token);
-    attachLater(&amp;currentNode(), &amp;m_head-&gt;element());
-    m_openElements.pushHTMLHeadElement(m_head);
</del><ins>+    m_head = HTMLStackItem::create(createHTMLElement(token), token);
+    attachLater(currentNode(), m_head-&gt;element());
+    m_openElements.pushHTMLHeadElement(*m_head);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLConstructionSite::insertHTMLBodyElement(AtomicHTMLToken* token)
</del><ins>+void HTMLConstructionSite::insertHTMLBodyElement(AtomicHTMLToken&amp; token)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!shouldFosterParent());
</span><del>-    RefPtr&lt;Element&gt; body = createHTMLElement(token);
-    attachLater(&amp;currentNode(), body.get());
-    m_openElements.pushHTMLBodyElement(HTMLStackItem::create(body.releaseNonNull(), *token));
</del><ins>+    auto body = createHTMLElement(token);
+    attachLater(currentNode(), body.copyRef());
+    m_openElements.pushHTMLBodyElement(HTMLStackItem::create(WTFMove(body), token));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLConstructionSite::insertHTMLFormElement(AtomicHTMLToken* token, bool isDemoted)
</del><ins>+void HTMLConstructionSite::insertHTMLFormElement(AtomicHTMLToken&amp; token, bool isDemoted)
</ins><span class="cx"> {
</span><del>-    RefPtr&lt;Element&gt; element = createHTMLElement(token);
-    ASSERT(is&lt;HTMLFormElement&gt;(*element));
-    m_form = static_pointer_cast&lt;HTMLFormElement&gt;(element.release());
</del><ins>+    auto element = createHTMLElement(token);
+    m_form = &amp;downcast&lt;HTMLFormElement&gt;(element.get());
</ins><span class="cx">     m_form-&gt;setDemoted(isDemoted);
</span><del>-    attachLater(&amp;currentNode(), m_form);
-    m_openElements.push(HTMLStackItem::create(*m_form, *token));
</del><ins>+    attachLater(currentNode(), *m_form);
+    m_openElements.push(HTMLStackItem::create(*m_form, token));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLConstructionSite::insertHTMLElement(AtomicHTMLToken* token)
</del><ins>+void HTMLConstructionSite::insertHTMLElement(AtomicHTMLToken&amp; token)
</ins><span class="cx"> {
</span><del>-    RefPtr&lt;Element&gt; element = createHTMLElement(token);
-    attachLater(&amp;currentNode(), element);
-    m_openElements.push(HTMLStackItem::create(element.releaseNonNull(), *token));
</del><ins>+    auto element = createHTMLElement(token);
+    attachLater(currentNode(), element.copyRef());
+    m_openElements.push(HTMLStackItem::create(WTFMove(element), token));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(CUSTOM_ELEMENTS)
</span><del>-JSCustomElementInterface* HTMLConstructionSite::insertHTMLElementOrFindCustomElementInterface(AtomicHTMLToken* token)
</del><ins>+
+JSCustomElementInterface* HTMLConstructionSite::insertHTMLElementOrFindCustomElementInterface(AtomicHTMLToken&amp; token)
</ins><span class="cx"> {
</span><span class="cx">     JSCustomElementInterface* interface = nullptr;
</span><span class="cx">     RefPtr&lt;Element&gt; element = createHTMLElementOrFindCustomElementInterface(token, &amp;interface);
</span><span class="cx">     if (UNLIKELY(interface))
</span><span class="cx">         return interface;
</span><del>-    attachLater(&amp;currentNode(), element);
-    m_openElements.push(HTMLStackItem::create(element.releaseNonNull(), *token));
</del><ins>+    attachLater(currentNode(), *element);
+    m_openElements.push(HTMLStackItem::create(element.releaseNonNull(), token));
</ins><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLConstructionSite::insertCustomElement(Ref&lt;Element&gt;&amp;&amp; element, const AtomicString&amp; localName, Vector&lt;Attribute&gt;&amp; attributes)
</span><span class="cx"> {
</span><del>-    setAttributes(element.get(), attributes, m_parserContentPolicy);
-    attachLater(&amp;currentNode(), element.ptr());
</del><ins>+    setAttributes(element, attributes, m_parserContentPolicy);
+    attachLater(currentNode(), element.copyRef());
</ins><span class="cx">     m_openElements.push(HTMLStackItem::create(WTFMove(element), localName, attributes));
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-void HTMLConstructionSite::insertSelfClosingHTMLElement(AtomicHTMLToken* token)
</del><ins>+void HTMLConstructionSite::insertSelfClosingHTMLElement(AtomicHTMLToken&amp; token)
</ins><span class="cx"> {
</span><del>-    ASSERT(token-&gt;type() == HTMLToken::StartTag);
</del><ins>+    ASSERT(token.type() == HTMLToken::StartTag);
</ins><span class="cx">     // Normally HTMLElementStack is responsible for calling finishParsingChildren,
</span><span class="cx">     // but self-closing elements are never in the element stack so the stack
</span><span class="cx">     // doesn't get a chance to tell them that we're done parsing their children.
</span><del>-    attachLater(&amp;currentNode(), createHTMLElement(token), true);
</del><ins>+    attachLater(currentNode(), createHTMLElement(token), true);
</ins><span class="cx">     // FIXME: Do we want to acknowledge the token's self-closing flag?
</span><span class="cx">     // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#acknowledge-self-closing-flag
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLConstructionSite::insertFormattingElement(AtomicHTMLToken* token)
</del><ins>+void HTMLConstructionSite::insertFormattingElement(AtomicHTMLToken&amp; token)
</ins><span class="cx"> {
</span><span class="cx">     // http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#the-stack-of-open-elements
</span><span class="cx">     // Possible active formatting elements include:
</span><span class="cx">     // a, b, big, code, em, font, i, nobr, s, small, strike, strong, tt, and u.
</span><del>-    ASSERT(isFormattingTag(token-&gt;name()));
</del><ins>+    ASSERT(isFormattingTag(token.name()));
</ins><span class="cx">     insertHTMLElement(token);
</span><del>-    m_activeFormattingElements.append(&amp;currentStackItem());
</del><ins>+    m_activeFormattingElements.append(currentStackItem());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLConstructionSite::insertScriptElement(AtomicHTMLToken* token)
</del><ins>+void HTMLConstructionSite::insertScriptElement(AtomicHTMLToken&amp; token)
</ins><span class="cx"> {
</span><span class="cx">     // http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#already-started
</span><span class="cx">     // http://html5.org/specs/dom-parsing.html#dom-range-createcontextualfragment
</span><span class="lines">@@ -537,23 +530,23 @@
</span><span class="cx">     // those flags or effects thereof.
</span><span class="cx">     const bool parserInserted = m_parserContentPolicy != AllowScriptingContentAndDoNotMarkAlreadyStarted;
</span><span class="cx">     const bool alreadyStarted = m_isParsingFragment &amp;&amp; parserInserted;
</span><del>-    Ref&lt;HTMLScriptElement&gt; element = HTMLScriptElement::create(scriptTag, ownerDocumentForCurrentNode(), parserInserted, alreadyStarted);
-    setAttributes(element.get(), token, m_parserContentPolicy);
</del><ins>+    auto element = HTMLScriptElement::create(scriptTag, ownerDocumentForCurrentNode(), parserInserted, alreadyStarted);
+    setAttributes(element, token, m_parserContentPolicy);
</ins><span class="cx">     if (scriptingContentIsAllowed(m_parserContentPolicy))
</span><del>-        attachLater(&amp;currentNode(), element.ptr());
-    m_openElements.push(HTMLStackItem::create(WTFMove(element), *token));
</del><ins>+        attachLater(currentNode(), element.copyRef());
+    m_openElements.push(HTMLStackItem::create(WTFMove(element), token));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLConstructionSite::insertForeignElement(AtomicHTMLToken* token, const AtomicString&amp; namespaceURI)
</del><ins>+void HTMLConstructionSite::insertForeignElement(AtomicHTMLToken&amp; token, const AtomicString&amp; namespaceURI)
</ins><span class="cx"> {
</span><del>-    ASSERT(token-&gt;type() == HTMLToken::StartTag);
</del><ins>+    ASSERT(token.type() == HTMLToken::StartTag);
</ins><span class="cx">     notImplemented(); // parseError when xmlns or xmlns:xlink are wrong.
</span><span class="cx"> 
</span><del>-    RefPtr&lt;Element&gt; element = createElement(token, namespaceURI);
-    if (scriptingContentIsAllowed(m_parserContentPolicy) || !toScriptElementIfPossible(element.get()))
-        attachLater(&amp;currentNode(), element, token-&gt;selfClosing());
-    if (!token-&gt;selfClosing())
-        m_openElements.push(HTMLStackItem::create(element.releaseNonNull(), *token, namespaceURI));
</del><ins>+    auto element = createElement(token, namespaceURI);
+    if (scriptingContentIsAllowed(m_parserContentPolicy) || !toScriptElementIfPossible(element.ptr()))
+        attachLater(currentNode(), element.copyRef(), token.selfClosing());
+    if (!token.selfClosing())
+        m_openElements.push(HTMLStackItem::create(WTFMove(element), token, namespaceURI));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLConstructionSite::insertTextNode(const String&amp; characters, WhitespaceMode whitespaceMode)
</span><span class="lines">@@ -569,11 +562,10 @@
</span><span class="cx"> 
</span><span class="cx">     // Strings composed entirely of whitespace are likely to be repeated.
</span><span class="cx">     // Turn them into AtomicString so we share a single string for each.
</span><del>-    bool shouldUseAtomicString = whitespaceMode == AllWhitespace
-        || (whitespaceMode == WhitespaceUnknown &amp;&amp; isAllWhitespace(characters));
</del><ins>+    bool shouldUseAtomicString = whitespaceMode == AllWhitespace || (whitespaceMode == WhitespaceUnknown &amp;&amp; isAllWhitespace(characters));
</ins><span class="cx"> 
</span><span class="cx">     unsigned currentPosition = 0;
</span><del>-    unsigned lengthLimit = shouldUseLengthLimit(task.parent.get()) ? Text::defaultLengthLimit : std::numeric_limits&lt;unsigned&gt;::max();
</del><ins>+    unsigned lengthLimit = shouldUseLengthLimit(*task.parent) ? Text::defaultLengthLimit : std::numeric_limits&lt;unsigned&gt;::max();
</ins><span class="cx"> 
</span><span class="cx">     // FIXME: Splitting text nodes into smaller chunks contradicts HTML5 spec, but is currently necessary
</span><span class="cx">     // for performance, see &lt;https://bugs.webkit.org/show_bug.cgi?id=55898&gt;.
</span><span class="lines">@@ -582,12 +574,11 @@
</span><span class="cx">     if (is&lt;Text&gt;(previousChild)) {
</span><span class="cx">         // FIXME: We're only supposed to append to this text node if it
</span><span class="cx">         // was the last text node inserted by the parser.
</span><del>-        Text&amp; textNode = downcast&lt;Text&gt;(*previousChild);
-        currentPosition = textNode.parserAppendData(characters, 0, lengthLimit);
</del><ins>+        currentPosition = downcast&lt;Text&gt;(*previousChild).parserAppendData(characters, 0, lengthLimit);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     while (currentPosition &lt; characters.length()) {
</span><del>-        Ref&lt;Text&gt; textNode = Text::createWithLengthLimit(task.parent-&gt;document(), shouldUseAtomicString ? AtomicString(characters).string() : characters, currentPosition, lengthLimit);
</del><ins>+        auto textNode = Text::createWithLengthLimit(task.parent-&gt;document(), shouldUseAtomicString ? AtomicString(characters).string() : characters, currentPosition, lengthLimit);
</ins><span class="cx">         // If we have a whole string of unbreakable characters the above could lead to an infinite loop. Exceeding the length limit is the lesser evil.
</span><span class="cx">         if (!textNode-&gt;length()) {
</span><span class="cx">             String substring = characters.substring(currentPosition);
</span><span class="lines">@@ -607,7 +598,7 @@
</span><span class="cx">     HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Reparent);
</span><span class="cx">     task.parent = &amp;newParent.node();
</span><span class="cx">     task.child = &amp;child.element();
</span><del>-    m_taskQueue.append(task);
</del><ins>+    m_taskQueue.append(WTFMove(task));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLConstructionSite::reparent(HTMLElementStack::ElementRecord&amp; newParent, HTMLStackItem&amp; child)
</span><span class="lines">@@ -615,20 +606,20 @@
</span><span class="cx">     HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Reparent);
</span><span class="cx">     task.parent = &amp;newParent.node();
</span><span class="cx">     task.child = &amp;child.element();
</span><del>-    m_taskQueue.append(task);
</del><ins>+    m_taskQueue.append(WTFMove(task));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLConstructionSite::insertAlreadyParsedChild(HTMLStackItem&amp; newParent, HTMLElementStack::ElementRecord&amp; child)
</span><span class="cx"> {
</span><span class="cx">     if (causesFosterParenting(newParent)) {
</span><del>-        fosterParent(&amp;child.element());
</del><ins>+        fosterParent(child.element());
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     HTMLConstructionSiteTask task(HTMLConstructionSiteTask::InsertAlreadyParsedChild);
</span><span class="cx">     task.parent = &amp;newParent.node();
</span><span class="cx">     task.child = &amp;child.element();
</span><del>-    m_taskQueue.append(task);
</del><ins>+    m_taskQueue.append(WTFMove(task));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLConstructionSite::takeAllChildren(HTMLStackItem&amp; newParent, HTMLElementStack::ElementRecord&amp; oldParent)
</span><span class="lines">@@ -636,14 +627,14 @@
</span><span class="cx">     HTMLConstructionSiteTask task(HTMLConstructionSiteTask::TakeAllChildren);
</span><span class="cx">     task.parent = &amp;newParent.node();
</span><span class="cx">     task.child = &amp;oldParent.node();
</span><del>-    m_taskQueue.append(task);
</del><ins>+    m_taskQueue.append(WTFMove(task));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-Ref&lt;Element&gt; HTMLConstructionSite::createElement(AtomicHTMLToken* token, const AtomicString&amp; namespaceURI)
</del><ins>+Ref&lt;Element&gt; HTMLConstructionSite::createElement(AtomicHTMLToken&amp; token, const AtomicString&amp; namespaceURI)
</ins><span class="cx"> {
</span><del>-    QualifiedName tagName(nullAtom, token-&gt;name(), namespaceURI);
-    Ref&lt;Element&gt; element = ownerDocumentForCurrentNode().createElement(tagName, true);
-    setAttributes(element.get(), token, m_parserContentPolicy);
</del><ins>+    QualifiedName tagName(nullAtom, token.name(), namespaceURI);
+    auto element = ownerDocumentForCurrentNode().createElement(tagName, true);
+    setAttributes(element, token, m_parserContentPolicy);
</ins><span class="cx">     return element;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -655,9 +646,9 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> RefPtr&lt;Element&gt; HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface(
</span><del>-    AtomicHTMLToken* token, JSCustomElementInterface** customElementInterface)
</del><ins>+    AtomicHTMLToken&amp; token, JSCustomElementInterface** customElementInterface)
</ins><span class="cx"> {
</span><del>-    auto&amp; localName = token-&gt;name();
</del><ins>+    auto&amp; localName = token.name();
</ins><span class="cx">     // FIXME: This can't use HTMLConstructionSite::createElement because we
</span><span class="cx">     // have to pass the current form element.  We should rework form association
</span><span class="cx">     // to occur after construction to allow better code sharing here.
</span><span class="lines">@@ -703,53 +694,53 @@
</span><span class="cx">     return element;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Ref&lt;Element&gt; HTMLConstructionSite::createHTMLElement(AtomicHTMLToken* token)
</del><ins>+Ref&lt;Element&gt; HTMLConstructionSite::createHTMLElement(AtomicHTMLToken&amp; token)
</ins><span class="cx"> {
</span><span class="cx">     RefPtr&lt;Element&gt; element = createHTMLElementOrFindCustomElementInterface(token, nullptr);
</span><span class="cx">     ASSERT(element);
</span><span class="cx">     return element.releaseNonNull();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Ref&lt;HTMLStackItem&gt; HTMLConstructionSite::createElementFromSavedToken(HTMLStackItem* item)
</del><ins>+Ref&lt;HTMLStackItem&gt; HTMLConstructionSite::createElementFromSavedToken(HTMLStackItem&amp; item)
</ins><span class="cx"> {
</span><span class="cx">     // NOTE: Moving from item -&gt; token -&gt; item copies the Attribute vector twice!
</span><del>-    AtomicHTMLToken fakeToken(HTMLToken::StartTag, item-&gt;localName(), Vector&lt;Attribute&gt;(item-&gt;attributes()));
-    ASSERT(item-&gt;namespaceURI() == HTMLNames::xhtmlNamespaceURI);
-    ASSERT(isFormattingTag(item-&gt;localName()));
-    return HTMLStackItem::create(createHTMLElement(&amp;fakeToken), fakeToken, item-&gt;namespaceURI());
</del><ins>+    AtomicHTMLToken fakeToken(HTMLToken::StartTag, item.localName(), Vector&lt;Attribute&gt;(item.attributes()));
+    ASSERT(item.namespaceURI() == HTMLNames::xhtmlNamespaceURI);
+    ASSERT(isFormattingTag(item.localName()));
+    return HTMLStackItem::create(createHTMLElement(fakeToken), fakeToken, item.namespaceURI());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool HTMLConstructionSite::indexOfFirstUnopenFormattingElement(unsigned&amp; firstUnopenElementIndex) const
</del><ins>+Optional&lt;unsigned&gt; HTMLConstructionSite::indexOfFirstUnopenFormattingElement() const
</ins><span class="cx"> {
</span><span class="cx">     if (m_activeFormattingElements.isEmpty())
</span><del>-        return false;
</del><ins>+        return Nullopt;
</ins><span class="cx">     unsigned index = m_activeFormattingElements.size();
</span><span class="cx">     do {
</span><span class="cx">         --index;
</span><del>-        const HTMLFormattingElementList::Entry&amp; entry = m_activeFormattingElements.at(index);
-        if (entry.isMarker() || m_openElements.contains(&amp;entry.element())) {
-            firstUnopenElementIndex = index + 1;
-            return firstUnopenElementIndex &lt; m_activeFormattingElements.size();
</del><ins>+        const auto&amp; entry = m_activeFormattingElements.at(index);
+        if (entry.isMarker() || m_openElements.contains(entry.element())) {
+            unsigned firstUnopenElementIndex = index + 1;
+            return firstUnopenElementIndex &lt; m_activeFormattingElements.size() ? firstUnopenElementIndex : Optional&lt;unsigned&gt;(Nullopt);
</ins><span class="cx">         }
</span><span class="cx">     } while (index);
</span><del>-    firstUnopenElementIndex = index;
-    return true;
</del><ins>+
+    return index;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLConstructionSite::reconstructTheActiveFormattingElements()
</span><span class="cx"> {
</span><del>-    unsigned firstUnopenElementIndex;
-    if (!indexOfFirstUnopenFormattingElement(firstUnopenElementIndex))
</del><ins>+    Optional&lt;unsigned&gt; firstUnopenElementIndex = indexOfFirstUnopenFormattingElement();
+    if (!firstUnopenElementIndex)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    unsigned unopenEntryIndex = firstUnopenElementIndex;
-    ASSERT(unopenEntryIndex &lt; m_activeFormattingElements.size());
-    for (; unopenEntryIndex &lt; m_activeFormattingElements.size(); ++unopenEntryIndex) {
-        HTMLFormattingElementList::Entry&amp; unopenedEntry = m_activeFormattingElements.at(unopenEntryIndex);
-        RefPtr&lt;HTMLStackItem&gt; reconstructed = createElementFromSavedToken(unopenedEntry.stackItem());
-        attachLater(&amp;currentNode(), &amp;reconstructed-&gt;node());
-        m_openElements.push(reconstructed);
-        unopenedEntry.replaceElement(reconstructed.release());
</del><ins>+    ASSERT(firstUnopenElementIndex.value() &lt; m_activeFormattingElements.size());
+    for (unsigned unopenEntryIndex = firstUnopenElementIndex.value(); unopenEntryIndex &lt; m_activeFormattingElements.size(); ++unopenEntryIndex) {
+        auto&amp; unopenedEntry = m_activeFormattingElements.at(unopenEntryIndex);
+        ASSERT(unopenedEntry.stackItem());
+        auto reconstructed = createElementFromSavedToken(*unopenedEntry.stackItem());
+        attachLater(currentNode(), reconstructed-&gt;node());
+        m_openElements.push(reconstructed.copyRef());
+        unopenedEntry.replaceElement(WTFMove(reconstructed));
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -765,24 +756,18 @@
</span><span class="cx">         m_openElements.pop();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool HTMLConstructionSite::inQuirksMode()
-{
-    return m_inQuirksMode;
-}
-
</del><span class="cx"> void HTMLConstructionSite::findFosterSite(HTMLConstructionSiteTask&amp; task)
</span><span class="cx"> {
</span><span class="cx">     // When a node is to be foster parented, the last template element with no table element is below it in the stack of open elements is the foster parent element (NOT the template's parent!)
</span><del>-    HTMLElementStack::ElementRecord* lastTemplateElement = m_openElements.topmost(templateTag.localName());
</del><ins>+    auto* lastTemplateElement = m_openElements.topmost(templateTag.localName());
</ins><span class="cx">     if (lastTemplateElement &amp;&amp; !m_openElements.inTableScope(tableTag)) {
</span><span class="cx">         task.parent = &amp;lastTemplateElement-&gt;element();
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    HTMLElementStack::ElementRecord* lastTableElementRecord = m_openElements.topmost(tableTag.localName());
-    if (lastTableElementRecord) {
-        Element&amp; lastTableElement = lastTableElementRecord-&gt;element();
-        ContainerNode* parent = lastTableElement.parentNode();
</del><ins>+    if (auto* lastTableElementRecord = m_openElements.topmost(tableTag.localName())) {
+        auto&amp; lastTableElement = lastTableElementRecord-&gt;element();
+        auto* parent = lastTableElement.parentNode();
</ins><span class="cx">         // When parsing HTML fragments, we skip step 4.2 (&quot;Let root be a new html element with no attributes&quot;) for efficiency,
</span><span class="cx">         // and instead use the DocumentFragment as a root node. So we must treat the root node (DocumentFragment) as if it is a html element here.
</span><span class="cx">         bool parentCanBeFosterParent = parent &amp;&amp; (parent-&gt;isElementNode() || (m_isParsingFragment &amp;&amp; parent == &amp;m_openElements.rootNode()));
</span><span class="lines">@@ -801,18 +786,17 @@
</span><span class="cx"> 
</span><span class="cx"> bool HTMLConstructionSite::shouldFosterParent() const
</span><span class="cx"> {
</span><del>-    return m_redirectAttachToFosterParent
-        &amp;&amp; causesFosterParenting(currentStackItem());
</del><ins>+    return m_redirectAttachToFosterParent &amp;&amp; causesFosterParenting(currentStackItem());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLConstructionSite::fosterParent(PassRefPtr&lt;Node&gt; node)
</del><ins>+void HTMLConstructionSite::fosterParent(Ref&lt;Node&gt;&amp;&amp; node)
</ins><span class="cx"> {
</span><span class="cx">     HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Insert);
</span><span class="cx">     findFosterSite(task);
</span><del>-    task.child = node;
</del><ins>+    task.child = WTFMove(node);
</ins><span class="cx">     ASSERT(task.parent);
</span><span class="cx"> 
</span><del>-    m_taskQueue.append(task);
</del><ins>+    m_taskQueue.append(WTFMove(task));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLConstructionSiteh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLConstructionSite.h (200339 => 200340)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLConstructionSite.h        2016-05-02 21:42:07 UTC (rev 200339)
+++ trunk/Source/WebCore/html/parser/HTMLConstructionSite.h        2016-05-02 22:18:05 UTC (rev 200340)
</span><span class="lines">@@ -31,8 +31,8 @@
</span><span class="cx"> #include &quot;HTMLElementStack.h&quot;
</span><span class="cx"> #include &quot;HTMLFormattingElementList.h&quot;
</span><span class="cx"> #include &lt;wtf/Noncopyable.h&gt;
</span><del>-#include &lt;wtf/PassRefPtr.h&gt;
</del><span class="cx"> #include &lt;wtf/RefPtr.h&gt;
</span><ins>+#include &lt;wtf/TemporaryChange.h&gt;
</ins><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -93,33 +93,32 @@
</span><span class="cx">     HTMLConstructionSite(DocumentFragment&amp;, ParserContentPolicy, unsigned maximumDOMTreeDepth);
</span><span class="cx">     ~HTMLConstructionSite();
</span><span class="cx"> 
</span><del>-    void detach();
</del><span class="cx">     void executeQueuedTasks();
</span><span class="cx"> 
</span><span class="cx">     void setDefaultCompatibilityMode();
</span><span class="cx">     void finishedParsing();
</span><span class="cx"> 
</span><del>-    void insertDoctype(AtomicHTMLToken*);
-    void insertComment(AtomicHTMLToken*);
-    void insertCommentOnDocument(AtomicHTMLToken*);
-    void insertCommentOnHTMLHtmlElement(AtomicHTMLToken*);
-    void insertHTMLElement(AtomicHTMLToken*);
</del><ins>+    void insertDoctype(AtomicHTMLToken&amp;);
+    void insertComment(AtomicHTMLToken&amp;);
+    void insertCommentOnDocument(AtomicHTMLToken&amp;);
+    void insertCommentOnHTMLHtmlElement(AtomicHTMLToken&amp;);
+    void insertHTMLElement(AtomicHTMLToken&amp;);
</ins><span class="cx"> #if ENABLE(CUSTOM_ELEMENTS)
</span><del>-    JSCustomElementInterface* insertHTMLElementOrFindCustomElementInterface(AtomicHTMLToken*);
</del><ins>+    JSCustomElementInterface* insertHTMLElementOrFindCustomElementInterface(AtomicHTMLToken&amp;);
</ins><span class="cx">     void insertCustomElement(Ref&lt;Element&gt;&amp;&amp;, const AtomicString&amp; localName, Vector&lt;Attribute&gt;&amp;);
</span><span class="cx"> #endif
</span><del>-    void insertSelfClosingHTMLElement(AtomicHTMLToken*);
-    void insertFormattingElement(AtomicHTMLToken*);
-    void insertHTMLHeadElement(AtomicHTMLToken*);
-    void insertHTMLBodyElement(AtomicHTMLToken*);
-    void insertHTMLFormElement(AtomicHTMLToken*, bool isDemoted = false);
-    void insertScriptElement(AtomicHTMLToken*);
</del><ins>+    void insertSelfClosingHTMLElement(AtomicHTMLToken&amp;);
+    void insertFormattingElement(AtomicHTMLToken&amp;);
+    void insertHTMLHeadElement(AtomicHTMLToken&amp;);
+    void insertHTMLBodyElement(AtomicHTMLToken&amp;);
+    void insertHTMLFormElement(AtomicHTMLToken&amp;, bool isDemoted = false);
+    void insertScriptElement(AtomicHTMLToken&amp;);
</ins><span class="cx">     void insertTextNode(const String&amp;, WhitespaceMode = WhitespaceUnknown);
</span><del>-    void insertForeignElement(AtomicHTMLToken*, const AtomicString&amp; namespaceURI);
</del><ins>+    void insertForeignElement(AtomicHTMLToken&amp;, const AtomicString&amp; namespaceURI);
</ins><span class="cx"> 
</span><del>-    void insertHTMLHtmlStartTagBeforeHTML(AtomicHTMLToken*);
-    void insertHTMLHtmlStartTagInBody(AtomicHTMLToken*);
-    void insertHTMLBodyStartTagInBody(AtomicHTMLToken*);
</del><ins>+    void insertHTMLHtmlStartTagBeforeHTML(AtomicHTMLToken&amp;);
+    void insertHTMLHtmlStartTagInBody(AtomicHTMLToken&amp;);
+    void insertHTMLBodyStartTagInBody(AtomicHTMLToken&amp;);
</ins><span class="cx"> 
</span><span class="cx">     void reparent(HTMLElementStack::ElementRecord&amp; newParent, HTMLElementStack::ElementRecord&amp; child);
</span><span class="cx">     void reparent(HTMLElementStack::ElementRecord&amp; newParent, HTMLStackItem&amp; child);
</span><span class="lines">@@ -129,18 +128,18 @@
</span><span class="cx">     void insertAlreadyParsedChild(HTMLStackItem&amp; newParent, HTMLElementStack::ElementRecord&amp; child);
</span><span class="cx">     void takeAllChildren(HTMLStackItem&amp; newParent, HTMLElementStack::ElementRecord&amp; oldParent);
</span><span class="cx"> 
</span><del>-    Ref&lt;HTMLStackItem&gt; createElementFromSavedToken(HTMLStackItem*);
</del><ins>+    Ref&lt;HTMLStackItem&gt; createElementFromSavedToken(HTMLStackItem&amp;);
</ins><span class="cx"> 
</span><span class="cx">     bool shouldFosterParent() const;
</span><del>-    void fosterParent(PassRefPtr&lt;Node&gt;);
</del><ins>+    void fosterParent(Ref&lt;Node&gt;&amp;&amp;);
</ins><span class="cx"> 
</span><del>-    bool indexOfFirstUnopenFormattingElement(unsigned&amp; firstUnopenElementIndex) const;
</del><ins>+    Optional&lt;unsigned&gt; indexOfFirstUnopenFormattingElement() const;
</ins><span class="cx">     void reconstructTheActiveFormattingElements();
</span><span class="cx"> 
</span><span class="cx">     void generateImpliedEndTags();
</span><span class="cx">     void generateImpliedEndTagsWithExclusion(const AtomicString&amp; tagName);
</span><span class="cx"> 
</span><del>-    bool inQuirksMode();
</del><ins>+    bool inQuirksMode() { return m_inQuirksMode; }
</ins><span class="cx"> 
</span><span class="cx">     bool isEmpty() const { return !m_openElements.stackDepth(); }
</span><span class="cx">     Element&amp; currentElement() const { return m_openElements.top(); }
</span><span class="lines">@@ -157,32 +156,23 @@
</span><span class="cx"> 
</span><span class="cx">     void setForm(HTMLFormElement*);
</span><span class="cx">     HTMLFormElement* form() const { return m_form.get(); }
</span><del>-    PassRefPtr&lt;HTMLFormElement&gt; takeForm();
</del><ins>+    RefPtr&lt;HTMLFormElement&gt; takeForm();
</ins><span class="cx"> 
</span><span class="cx">     ParserContentPolicy parserContentPolicy() { return m_parserContentPolicy; }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(TELEPHONE_NUMBER_DETECTION)
</span><del>-    bool isTelephoneNumberParsingEnabled() { return m_document-&gt;isTelephoneNumberParsingEnabled(); }
</del><ins>+    bool isTelephoneNumberParsingEnabled() { return m_document.isTelephoneNumberParsingEnabled(); }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     class RedirectToFosterParentGuard {
</span><span class="cx">         WTF_MAKE_NONCOPYABLE(RedirectToFosterParentGuard);
</span><span class="cx">     public:
</span><del>-        RedirectToFosterParentGuard(HTMLConstructionSite&amp; tree)
-            : m_tree(tree)
-            , m_wasRedirectingBefore(tree.m_redirectAttachToFosterParent)
-        {
-            m_tree.m_redirectAttachToFosterParent = true;
-        }
</del><ins>+        explicit RedirectToFosterParentGuard(HTMLConstructionSite&amp; tree)
+            : m_redirectAttachToFosterParentChange(tree.m_redirectAttachToFosterParent, true)
+        { }
</ins><span class="cx"> 
</span><del>-        ~RedirectToFosterParentGuard()
-        {
-            m_tree.m_redirectAttachToFosterParent = m_wasRedirectingBefore;
-        }
-
</del><span class="cx">     private:
</span><del>-        HTMLConstructionSite&amp; m_tree;
-        bool m_wasRedirectingBefore;
</del><ins>+        TemporaryChange&lt;bool&gt; m_redirectAttachToFosterParentChange;
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     static bool isFormattingTag(const AtomicString&amp;);
</span><span class="lines">@@ -195,23 +185,23 @@
</span><span class="cx">     void setCompatibilityMode(DocumentCompatibilityMode);
</span><span class="cx">     void setCompatibilityModeFromDoctype(const String&amp; name, const String&amp; publicId, const String&amp; systemId);
</span><span class="cx"> 
</span><del>-    void attachLater(ContainerNode* parent, PassRefPtr&lt;Node&gt; child, bool selfClosing = false);
</del><ins>+    void attachLater(ContainerNode&amp; parent, Ref&lt;Node&gt;&amp;&amp; child, bool selfClosing = false);
</ins><span class="cx"> 
</span><span class="cx">     void findFosterSite(HTMLConstructionSiteTask&amp;);
</span><span class="cx"> 
</span><del>-    RefPtr&lt;Element&gt; createHTMLElementOrFindCustomElementInterface(AtomicHTMLToken*, JSCustomElementInterface**);
-    Ref&lt;Element&gt; createHTMLElement(AtomicHTMLToken*);
-    Ref&lt;Element&gt; createElement(AtomicHTMLToken*, const AtomicString&amp; namespaceURI);
</del><ins>+    RefPtr&lt;Element&gt; createHTMLElementOrFindCustomElementInterface(AtomicHTMLToken&amp;, JSCustomElementInterface**);
+    Ref&lt;Element&gt; createHTMLElement(AtomicHTMLToken&amp;);
+    Ref&lt;Element&gt; createElement(AtomicHTMLToken&amp;, const AtomicString&amp; namespaceURI);
</ins><span class="cx"> 
</span><del>-    void mergeAttributesFromTokenIntoElement(AtomicHTMLToken*, Element*);
</del><ins>+    void mergeAttributesFromTokenIntoElement(AtomicHTMLToken&amp;, Element&amp;);
</ins><span class="cx">     void dispatchDocumentElementAvailableIfNeeded();
</span><span class="cx"> 
</span><del>-    Document* m_document;
</del><ins>+    Document&amp; m_document;
</ins><span class="cx">     
</span><span class="cx">     // This is the root ContainerNode to which the parser attaches all newly
</span><span class="cx">     // constructed nodes. It points to a DocumentFragment when parsing fragments
</span><span class="cx">     // and a Document in all other cases.
</span><del>-    ContainerNode* m_attachmentRoot;
</del><ins>+    ContainerNode&amp; m_attachmentRoot;
</ins><span class="cx">     
</span><span class="cx">     RefPtr&lt;HTMLStackItem&gt; m_head;
</span><span class="cx">     RefPtr&lt;HTMLFormElement&gt; m_form;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLElementStackcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLElementStack.cpp (200339 => 200340)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLElementStack.cpp        2016-05-02 21:42:07 UTC (rev 200339)
+++ trunk/Source/WebCore/html/parser/HTMLElementStack.cpp        2016-05-02 22:18:05 UTC (rev 200340)
</span><span class="lines">@@ -40,8 +40,7 @@
</span><span class="cx"> 
</span><span class="cx"> inline bool isRootNode(HTMLStackItem&amp; item)
</span><span class="cx"> {
</span><del>-    return item.isDocumentFragment()
-        || item.hasTagName(htmlTag);
</del><ins>+    return item.isDocumentFragment() || item.hasTagName(htmlTag);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> inline bool isScopeMarker(HTMLStackItem&amp; item)
</span><span class="lines">@@ -116,42 +115,32 @@
</span><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-HTMLElementStack::ElementRecord::ElementRecord(PassRefPtr&lt;HTMLStackItem&gt; item, std::unique_ptr&lt;ElementRecord&gt; next)
-    : m_item(item)
</del><ins>+HTMLElementStack::ElementRecord::ElementRecord(Ref&lt;HTMLStackItem&gt;&amp;&amp; item, std::unique_ptr&lt;ElementRecord&gt; next)
+    : m_item(WTFMove(item))
</ins><span class="cx">     , m_next(WTFMove(next))
</span><span class="cx"> {
</span><del>-    ASSERT(m_item);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> HTMLElementStack::ElementRecord::~ElementRecord()
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLElementStack::ElementRecord::replaceElement(PassRefPtr&lt;HTMLStackItem&gt; item)
</del><ins>+void HTMLElementStack::ElementRecord::replaceElement(Ref&lt;HTMLStackItem&gt;&amp;&amp; item)
</ins><span class="cx"> {
</span><del>-    ASSERT(item);
-    ASSERT(!m_item || m_item-&gt;isElement());
</del><ins>+    ASSERT(m_item-&gt;isElement());
</ins><span class="cx">     // FIXME: Should this call finishParsingChildren?
</span><del>-    m_item = item;
</del><ins>+    m_item = WTFMove(item);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool HTMLElementStack::ElementRecord::isAbove(ElementRecord* other) const
</del><ins>+bool HTMLElementStack::ElementRecord::isAbove(ElementRecord&amp; other) const
</ins><span class="cx"> {
</span><del>-    for (ElementRecord* below = next(); below; below = below-&gt;next()) {
-        if (below == other)
</del><ins>+    for (auto* below = next(); below; below = below-&gt;next()) {
+        if (below == &amp;other)
</ins><span class="cx">             return true;
</span><span class="cx">     }
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-HTMLElementStack::HTMLElementStack()
-    : m_rootNode(0)
-    , m_headElement(0)
-    , m_bodyElement(0)
-    , m_stackDepth(0)
-{
-}
-
</del><span class="cx"> HTMLElementStack::~HTMLElementStack()
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="lines">@@ -189,9 +178,9 @@
</span><span class="cx"> 
</span><span class="cx"> void HTMLElementStack::popAll()
</span><span class="cx"> {
</span><del>-    m_rootNode = 0;
-    m_headElement = 0;
-    m_bodyElement = 0;
</del><ins>+    m_rootNode = nullptr;
+    m_headElement = nullptr;
+    m_bodyElement = nullptr;
</ins><span class="cx">     m_stackDepth = 0;
</span><span class="cx">     while (m_top) {
</span><span class="cx">         topNode().finishParsingChildren();
</span><span class="lines">@@ -226,13 +215,13 @@
</span><span class="cx">     pop();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLElementStack::popUntil(Element* element)
</del><ins>+void HTMLElementStack::popUntil(Element&amp; element)
</ins><span class="cx"> {
</span><del>-    while (&amp;top() != element)
</del><ins>+    while (&amp;top() != &amp;element)
</ins><span class="cx">         pop();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLElementStack::popUntilPopped(Element* element)
</del><ins>+void HTMLElementStack::popUntilPopped(Element&amp; element)
</ins><span class="cx"> {
</span><span class="cx">     popUntil(element);
</span><span class="cx">     pop();
</span><span class="lines">@@ -292,78 +281,76 @@
</span><span class="cx">         pop();
</span><span class="cx"> }
</span><span class="cx">     
</span><del>-void HTMLElementStack::pushRootNode(PassRefPtr&lt;HTMLStackItem&gt; rootItem)
</del><ins>+void HTMLElementStack::pushRootNode(Ref&lt;HTMLStackItem&gt;&amp;&amp; rootItem)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(rootItem-&gt;isDocumentFragment());
</span><del>-    pushRootNodeCommon(rootItem);
</del><ins>+    pushRootNodeCommon(WTFMove(rootItem));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLElementStack::pushHTMLHtmlElement(PassRefPtr&lt;HTMLStackItem&gt; item)
</del><ins>+void HTMLElementStack::pushHTMLHtmlElement(Ref&lt;HTMLStackItem&gt;&amp;&amp; item)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(item-&gt;hasTagName(HTMLNames::htmlTag));
</span><del>-    pushRootNodeCommon(item);
</del><ins>+    pushRootNodeCommon(WTFMove(item));
</ins><span class="cx"> }
</span><span class="cx">     
</span><del>-void HTMLElementStack::pushRootNodeCommon(PassRefPtr&lt;HTMLStackItem&gt; rootItem)
</del><ins>+void HTMLElementStack::pushRootNodeCommon(Ref&lt;HTMLStackItem&gt;&amp;&amp; rootItem)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!m_top);
</span><span class="cx">     ASSERT(!m_rootNode);
</span><span class="cx">     m_rootNode = &amp;rootItem-&gt;node();
</span><del>-    pushCommon(rootItem);
</del><ins>+    pushCommon(WTFMove(rootItem));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLElementStack::pushHTMLHeadElement(PassRefPtr&lt;HTMLStackItem&gt; item)
</del><ins>+void HTMLElementStack::pushHTMLHeadElement(Ref&lt;HTMLStackItem&gt;&amp;&amp; item)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(item-&gt;hasTagName(HTMLNames::headTag));
</span><span class="cx">     ASSERT(!m_headElement);
</span><span class="cx">     m_headElement = &amp;item-&gt;element();
</span><del>-    pushCommon(item);
</del><ins>+    pushCommon(WTFMove(item));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLElementStack::pushHTMLBodyElement(PassRefPtr&lt;HTMLStackItem&gt; item)
</del><ins>+void HTMLElementStack::pushHTMLBodyElement(Ref&lt;HTMLStackItem&gt;&amp;&amp; item)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(item-&gt;hasTagName(HTMLNames::bodyTag));
</span><span class="cx">     ASSERT(!m_bodyElement);
</span><span class="cx">     m_bodyElement = &amp;item-&gt;element();
</span><del>-    pushCommon(item);
</del><ins>+    pushCommon(WTFMove(item));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLElementStack::push(PassRefPtr&lt;HTMLStackItem&gt; item)
</del><ins>+void HTMLElementStack::push(Ref&lt;HTMLStackItem&gt;&amp;&amp; item)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!item-&gt;hasTagName(HTMLNames::htmlTag));
</span><span class="cx">     ASSERT(!item-&gt;hasTagName(HTMLNames::headTag));
</span><span class="cx">     ASSERT(!item-&gt;hasTagName(HTMLNames::bodyTag));
</span><span class="cx">     ASSERT(m_rootNode);
</span><del>-    pushCommon(item);
</del><ins>+    pushCommon(WTFMove(item));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLElementStack::insertAbove(PassRefPtr&lt;HTMLStackItem&gt; item, ElementRecord* recordBelow)
</del><ins>+void HTMLElementStack::insertAbove(Ref&lt;HTMLStackItem&gt;&amp;&amp; item, ElementRecord&amp; recordBelow)
</ins><span class="cx"> {
</span><del>-    ASSERT(item);
-    ASSERT(recordBelow);
</del><span class="cx">     ASSERT(m_top);
</span><span class="cx">     ASSERT(!item-&gt;hasTagName(HTMLNames::htmlTag));
</span><span class="cx">     ASSERT(!item-&gt;hasTagName(HTMLNames::headTag));
</span><span class="cx">     ASSERT(!item-&gt;hasTagName(HTMLNames::bodyTag));
</span><span class="cx">     ASSERT(m_rootNode);
</span><del>-    if (recordBelow == m_top.get()) {
-        push(item);
</del><ins>+    if (&amp;recordBelow == m_top.get()) {
+        push(item.copyRef());
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    for (ElementRecord* recordAbove = m_top.get(); recordAbove; recordAbove = recordAbove-&gt;next()) {
-        if (recordAbove-&gt;next() != recordBelow)
</del><ins>+    for (auto* recordAbove = m_top.get(); recordAbove; recordAbove = recordAbove-&gt;next()) {
+        if (recordAbove-&gt;next() != &amp;recordBelow)
</ins><span class="cx">             continue;
</span><span class="cx"> 
</span><del>-        m_stackDepth++;
-        recordAbove-&gt;setNext(std::make_unique&lt;ElementRecord&gt;(item, recordAbove-&gt;releaseNext()));
</del><ins>+        ++m_stackDepth;
+        recordAbove-&gt;setNext(std::make_unique&lt;ElementRecord&gt;(WTFMove(item), recordAbove-&gt;releaseNext()));
</ins><span class="cx">         recordAbove-&gt;next()-&gt;element().beginParsingChildren();
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-HTMLElementStack::ElementRecord&amp; HTMLElementStack::topRecord() const
</del><ins>+auto HTMLElementStack::topRecord() const -&gt; ElementRecord&amp;
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(m_top);
</span><span class="cx">     return *m_top;
</span><span class="lines">@@ -379,10 +366,10 @@
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLElementStack::removeHTMLHeadElement(Element* element)
</del><ins>+void HTMLElementStack::removeHTMLHeadElement(Element&amp; element)
</ins><span class="cx"> {
</span><del>-    ASSERT(m_headElement == element);
-    if (&amp;m_top-&gt;element() == element) {
</del><ins>+    ASSERT(m_headElement == &amp;element);
+    if (&amp;m_top-&gt;element() == &amp;element) {
</ins><span class="cx">         popHTMLHeadElement();
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -390,35 +377,35 @@
</span><span class="cx">     removeNonTopCommon(element);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLElementStack::remove(Element* element)
</del><ins>+void HTMLElementStack::remove(Element&amp; element)
</ins><span class="cx"> {
</span><del>-    ASSERT(!element-&gt;hasTagName(HTMLNames::headTag));
-    if (&amp;m_top-&gt;element() == element) {
</del><ins>+    ASSERT(!element.hasTagName(HTMLNames::headTag));
+    if (&amp;m_top-&gt;element() == &amp;element) {
</ins><span class="cx">         pop();
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     removeNonTopCommon(element);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-HTMLElementStack::ElementRecord* HTMLElementStack::find(Element* element) const
</del><ins>+auto HTMLElementStack::find(Element&amp; element) const -&gt; ElementRecord*
</ins><span class="cx"> {
</span><del>-    for (ElementRecord* record = m_top.get(); record; record = record-&gt;next()) {
-        if (&amp;record-&gt;node() == element)
</del><ins>+    for (auto* record = m_top.get(); record; record = record-&gt;next()) {
+        if (&amp;record-&gt;node() == &amp;element)
</ins><span class="cx">             return record;
</span><span class="cx">     }
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-HTMLElementStack::ElementRecord* HTMLElementStack::topmost(const AtomicString&amp; tagName) const
</del><ins>+auto HTMLElementStack::topmost(const AtomicString&amp; tagName) const -&gt; ElementRecord*
</ins><span class="cx"> {
</span><del>-    for (ElementRecord* record = m_top.get(); record; record = record-&gt;next()) {
</del><ins>+    for (auto* record = m_top.get(); record; record = record-&gt;next()) {
</ins><span class="cx">         if (record-&gt;stackItem().matchesHTMLTag(tagName))
</span><span class="cx">             return record;
</span><span class="cx">     }
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool HTMLElementStack::contains(Element* element) const
</del><ins>+bool HTMLElementStack::contains(Element&amp; element) const
</ins><span class="cx"> {
</span><span class="cx">     return !!find(element);
</span><span class="cx"> }
</span><span class="lines">@@ -431,7 +418,7 @@
</span><span class="cx"> template &lt;bool isMarker(HTMLStackItem&amp;)&gt; bool inScopeCommon(HTMLElementStack::ElementRecord* top, const AtomicString&amp; targetTag)
</span><span class="cx"> {
</span><span class="cx">     for (auto* record = top; record; record = record-&gt;next()) {
</span><del>-        HTMLStackItem&amp; item = record-&gt;stackItem();
</del><ins>+        auto&amp; item = record-&gt;stackItem();
</ins><span class="cx">         if (item.matchesHTMLTag(targetTag))
</span><span class="cx">             return true;
</span><span class="cx">         if (isMarker(item))
</span><span class="lines">@@ -443,8 +430,8 @@
</span><span class="cx"> 
</span><span class="cx"> bool HTMLElementStack::hasNumberedHeaderElementInScope() const
</span><span class="cx"> {
</span><del>-    for (ElementRecord* record = m_top.get(); record; record = record-&gt;next()) {
-        HTMLStackItem&amp; item = record-&gt;stackItem();
</del><ins>+    for (auto* record = m_top.get(); record; record = record-&gt;next()) {
+        auto&amp; item = record-&gt;stackItem();
</ins><span class="cx">         if (isNumberedHeaderElement(item))
</span><span class="cx">             return true;
</span><span class="cx">         if (isScopeMarker(item))
</span><span class="lines">@@ -454,11 +441,11 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool HTMLElementStack::inScope(Element* targetElement) const
</del><ins>+bool HTMLElementStack::inScope(Element&amp; targetElement) const
</ins><span class="cx"> {
</span><del>-    for (ElementRecord* record = m_top.get(); record; record = record-&gt;next()) {
-        HTMLStackItem&amp; item = record-&gt;stackItem();
-        if (&amp;item.node() == targetElement)
</del><ins>+    for (auto* record = m_top.get(); record; record = record-&gt;next()) {
+        auto&amp; item = record-&gt;stackItem();
+        if (&amp;item.node() == &amp;targetElement)
</ins><span class="cx">             return true;
</span><span class="cx">         if (isScopeMarker(item))
</span><span class="cx">             return false;
</span><span class="lines">@@ -545,12 +532,12 @@
</span><span class="cx">     return *m_rootNode;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLElementStack::pushCommon(PassRefPtr&lt;HTMLStackItem&gt; item)
</del><ins>+void HTMLElementStack::pushCommon(Ref&lt;HTMLStackItem&gt;&amp;&amp; item)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(m_rootNode);
</span><span class="cx"> 
</span><del>-    m_stackDepth++;
-    m_top = std::make_unique&lt;ElementRecord&gt;(item, WTFMove(m_top));
</del><ins>+    ++m_stackDepth;
+    m_top = std::make_unique&lt;ElementRecord&gt;(WTFMove(item), WTFMove(m_top));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLElementStack::popCommon()
</span><span class="lines">@@ -562,32 +549,32 @@
</span><span class="cx">     top().finishParsingChildren();
</span><span class="cx">     m_top = m_top-&gt;releaseNext();
</span><span class="cx"> 
</span><del>-    m_stackDepth--;
</del><ins>+    --m_stackDepth;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLElementStack::removeNonTopCommon(Element* element)
</del><ins>+void HTMLElementStack::removeNonTopCommon(Element&amp; element)
</ins><span class="cx"> {
</span><del>-    ASSERT(!element-&gt;hasTagName(HTMLNames::htmlTag));
-    ASSERT(!element-&gt;hasTagName(HTMLNames::bodyTag));
-    ASSERT(&amp;top() != element);
-    for (ElementRecord* record = m_top.get(); record; record = record-&gt;next()) {
-        if (&amp;record-&gt;next()-&gt;element() == element) {
</del><ins>+    ASSERT(!element.hasTagName(HTMLNames::htmlTag));
+    ASSERT(!element.hasTagName(HTMLNames::bodyTag));
+    ASSERT(&amp;top() != &amp;element);
+    for (auto* record = m_top.get(); record; record = record-&gt;next()) {
+        if (&amp;record-&gt;next()-&gt;element() == &amp;element) {
</ins><span class="cx">             // FIXME: Is it OK to call finishParsingChildren()
</span><span class="cx">             // when the children aren't actually finished?
</span><del>-            element-&gt;finishParsingChildren();
</del><ins>+            element.finishParsingChildren();
</ins><span class="cx">             record-&gt;setNext(record-&gt;next()-&gt;releaseNext());
</span><del>-            m_stackDepth--;
</del><ins>+            --m_stackDepth;
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-HTMLElementStack::ElementRecord* HTMLElementStack::furthestBlockForFormattingElement(Element* formattingElement) const
</del><ins>+auto HTMLElementStack::furthestBlockForFormattingElement(Element&amp; formattingElement) const -&gt; ElementRecord*
</ins><span class="cx"> {
</span><span class="cx">     ElementRecord* furthestBlock = nullptr;
</span><del>-    for (ElementRecord* record = m_top.get(); record; record = record-&gt;next()) {
-        if (&amp;record-&gt;element() == formattingElement)
</del><ins>+    for (auto* record = m_top.get(); record; record = record-&gt;next()) {
+        if (&amp;record-&gt;element() == &amp;formattingElement)
</ins><span class="cx">             return furthestBlock;
</span><span class="cx">         if (isSpecialNode(record-&gt;stackItem()))
</span><span class="cx">             furthestBlock = record;
</span><span class="lines">@@ -600,7 +587,7 @@
</span><span class="cx"> 
</span><span class="cx"> void HTMLElementStack::show()
</span><span class="cx"> {
</span><del>-    for (ElementRecord* record = m_top.get(); record; record = record-&gt;next())
</del><ins>+    for (auto* record = m_top.get(); record; record = record-&gt;next())
</ins><span class="cx">         record-&gt;element().showNode();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLElementStackh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLElementStack.h (200339 => 200340)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLElementStack.h        2016-05-02 21:42:07 UTC (rev 200339)
+++ trunk/Source/WebCore/html/parser/HTMLElementStack.h        2016-05-02 22:18:05 UTC (rev 200340)
</span><span class="lines">@@ -44,23 +44,25 @@
</span><span class="cx"> class HTMLElementStack {
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(HTMLElementStack); WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><del>-    HTMLElementStack();
</del><ins>+    HTMLElementStack() = default;
</ins><span class="cx">     ~HTMLElementStack();
</span><span class="cx"> 
</span><span class="cx">     class ElementRecord {
</span><span class="cx">         WTF_MAKE_NONCOPYABLE(ElementRecord); WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx">     public:
</span><del>-        ElementRecord(PassRefPtr&lt;HTMLStackItem&gt;, std::unique_ptr&lt;ElementRecord&gt;);
</del><ins>+        ElementRecord(Ref&lt;HTMLStackItem&gt;&amp;&amp;, std::unique_ptr&lt;ElementRecord&gt;);
</ins><span class="cx">         ~ElementRecord();
</span><span class="cx">     
</span><span class="cx">         Element&amp; element() const { return m_item-&gt;element(); }
</span><span class="cx">         ContainerNode&amp; node() const { return m_item-&gt;node(); }
</span><span class="cx">         const AtomicString&amp; namespaceURI() const { return m_item-&gt;namespaceURI(); }
</span><del>-        HTMLStackItem&amp; stackItem() const { return *m_item; }
-        void replaceElement(PassRefPtr&lt;HTMLStackItem&gt;);
</del><ins>+        HTMLStackItem&amp; stackItem() { return m_item.get(); }
+        const HTMLStackItem&amp; stackItem() const { return m_item.get(); }
</ins><span class="cx"> 
</span><del>-        bool isAbove(ElementRecord*) const;
</del><ins>+        void replaceElement(Ref&lt;HTMLStackItem&gt;&amp;&amp;);
</ins><span class="cx"> 
</span><ins>+        bool isAbove(ElementRecord&amp;) const;
+
</ins><span class="cx">         ElementRecord* next() const { return m_next.get(); }
</span><span class="cx"> 
</span><span class="cx">     private:
</span><span class="lines">@@ -69,7 +71,7 @@
</span><span class="cx">         std::unique_ptr&lt;ElementRecord&gt; releaseNext() { return WTFMove(m_next); }
</span><span class="cx">         void setNext(std::unique_ptr&lt;ElementRecord&gt; next) { m_next = WTFMove(next); }
</span><span class="cx"> 
</span><del>-        RefPtr&lt;HTMLStackItem&gt; m_item;
</del><ins>+        Ref&lt;HTMLStackItem&gt; m_item;
</ins><span class="cx">         std::unique_ptr&lt;ElementRecord&gt; m_next;
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="lines">@@ -94,25 +96,25 @@
</span><span class="cx"> 
</span><span class="cx">     HTMLStackItem* oneBelowTop() const;
</span><span class="cx">     ElementRecord&amp; topRecord() const;
</span><del>-    ElementRecord* find(Element*) const;
-    ElementRecord* furthestBlockForFormattingElement(Element*) const;
</del><ins>+    ElementRecord* find(Element&amp;) const;
+    ElementRecord* furthestBlockForFormattingElement(Element&amp;) const;
</ins><span class="cx">     ElementRecord* topmost(const AtomicString&amp; tagName) const;
</span><span class="cx"> 
</span><del>-    void insertAbove(PassRefPtr&lt;HTMLStackItem&gt;, ElementRecord*);
</del><ins>+    void insertAbove(Ref&lt;HTMLStackItem&gt;&amp;&amp;, ElementRecord&amp;);
</ins><span class="cx"> 
</span><del>-    void push(PassRefPtr&lt;HTMLStackItem&gt;);
-    void pushRootNode(PassRefPtr&lt;HTMLStackItem&gt;);
-    void pushHTMLHtmlElement(PassRefPtr&lt;HTMLStackItem&gt;);
-    void pushHTMLHeadElement(PassRefPtr&lt;HTMLStackItem&gt;);
-    void pushHTMLBodyElement(PassRefPtr&lt;HTMLStackItem&gt;);
</del><ins>+    void push(Ref&lt;HTMLStackItem&gt;&amp;&amp;);
+    void pushRootNode(Ref&lt;HTMLStackItem&gt;&amp;&amp;);
+    void pushHTMLHtmlElement(Ref&lt;HTMLStackItem&gt;&amp;&amp;);
+    void pushHTMLHeadElement(Ref&lt;HTMLStackItem&gt;&amp;&amp;);
+    void pushHTMLBodyElement(Ref&lt;HTMLStackItem&gt;&amp;&amp;);
</ins><span class="cx"> 
</span><span class="cx">     void pop();
</span><span class="cx">     void popUntil(const AtomicString&amp; tagName);
</span><del>-    void popUntil(Element*);
</del><ins>+    void popUntil(Element&amp;);
</ins><span class="cx">     void popUntilPopped(const AtomicString&amp; tagName);
</span><span class="cx">     void popUntilPopped(const QualifiedName&amp; tagName) { popUntilPopped(tagName.localName()); }
</span><span class="cx"> 
</span><del>-    void popUntilPopped(Element*);
</del><ins>+    void popUntilPopped(Element&amp;);
</ins><span class="cx">     void popUntilNumberedHeaderElementPopped();
</span><span class="cx">     void popUntilTableScopeMarker(); // &quot;clear the stack back to a table context&quot; in the spec.
</span><span class="cx">     void popUntilTableBodyScopeMarker(); // &quot;clear the stack back to a table body context&quot; in the spec.
</span><span class="lines">@@ -125,13 +127,13 @@
</span><span class="cx">     static bool isMathMLTextIntegrationPoint(HTMLStackItem&amp;);
</span><span class="cx">     static bool isHTMLIntegrationPoint(HTMLStackItem&amp;);
</span><span class="cx"> 
</span><del>-    void remove(Element*);
-    void removeHTMLHeadElement(Element*);
</del><ins>+    void remove(Element&amp;);
+    void removeHTMLHeadElement(Element&amp;);
</ins><span class="cx"> 
</span><del>-    bool contains(Element*) const;
</del><ins>+    bool contains(Element&amp;) const;
</ins><span class="cx">     bool contains(const AtomicString&amp; tagName) const;
</span><span class="cx"> 
</span><del>-    bool inScope(Element*) const;
</del><ins>+    bool inScope(Element&amp;) const;
</ins><span class="cx">     bool inScope(const AtomicString&amp; tagName) const;
</span><span class="cx">     bool inScope(const QualifiedName&amp;) const;
</span><span class="cx">     bool inListItemScope(const AtomicString&amp; tagName) const;
</span><span class="lines">@@ -159,10 +161,10 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    void pushCommon(PassRefPtr&lt;HTMLStackItem&gt;);
-    void pushRootNodeCommon(PassRefPtr&lt;HTMLStackItem&gt;);
</del><ins>+    void pushCommon(Ref&lt;HTMLStackItem&gt;&amp;&amp;);
+    void pushRootNodeCommon(Ref&lt;HTMLStackItem&gt;&amp;&amp;);
</ins><span class="cx">     void popCommon();
</span><del>-    void removeNonTopCommon(Element*);
</del><ins>+    void removeNonTopCommon(Element&amp;);
</ins><span class="cx"> 
</span><span class="cx">     std::unique_ptr&lt;ElementRecord&gt; m_top;
</span><span class="cx"> 
</span><span class="lines">@@ -171,10 +173,10 @@
</span><span class="cx">     // FIXME: We don't currently require type-specific information about
</span><span class="cx">     // these elements so we haven't yet bothered to plumb the types all the
</span><span class="cx">     // way down through createElement, etc.
</span><del>-    ContainerNode* m_rootNode;
-    Element* m_headElement;
-    Element* m_bodyElement;
-    unsigned m_stackDepth;
</del><ins>+    ContainerNode* m_rootNode { nullptr };
+    Element* m_headElement { nullptr };
+    Element* m_bodyElement { nullptr };
+    unsigned m_stackDepth { 0 };
</ins><span class="cx"> };
</span><span class="cx">     
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLFormattingElementListcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLFormattingElementList.cpp (200339 => 200340)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLFormattingElementList.cpp        2016-05-02 21:42:07 UTC (rev 200339)
+++ trunk/Source/WebCore/html/parser/HTMLFormattingElementList.cpp        2016-05-02 22:18:05 UTC (rev 200340)
</span><span class="lines">@@ -57,52 +57,52 @@
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool HTMLFormattingElementList::contains(Element* element)
</del><ins>+bool HTMLFormattingElementList::contains(Element&amp; element)
</ins><span class="cx"> {
</span><span class="cx">     return !!find(element);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-HTMLFormattingElementList::Entry* HTMLFormattingElementList::find(Element* element)
</del><ins>+auto HTMLFormattingElementList::find(Element&amp; element) -&gt; Entry*
</ins><span class="cx"> {
</span><del>-    size_t index = m_entries.reverseFind(element);
</del><ins>+    size_t index = m_entries.reverseFind(&amp;element);
</ins><span class="cx">     if (index != notFound) {
</span><span class="cx">         // This is somewhat of a hack, and is why this method can't be const.
</span><span class="cx">         return &amp;m_entries[index];
</span><span class="cx">     }
</span><del>-    return 0;
</del><ins>+    return nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-HTMLFormattingElementList::Bookmark HTMLFormattingElementList::bookmarkFor(Element* element)
</del><ins>+auto HTMLFormattingElementList::bookmarkFor(Element&amp; element) -&gt; Bookmark
</ins><span class="cx"> {
</span><del>-    size_t index = m_entries.reverseFind(element);
</del><ins>+    size_t index = m_entries.reverseFind(&amp;element);
</ins><span class="cx">     ASSERT(index != notFound);
</span><del>-    return Bookmark(&amp;at(index));
</del><ins>+    return Bookmark(at(index));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLFormattingElementList::swapTo(Element* oldElement, PassRefPtr&lt;HTMLStackItem&gt; newItem, const Bookmark&amp; bookmark)
</del><ins>+void HTMLFormattingElementList::swapTo(Element&amp; oldElement, Ref&lt;HTMLStackItem&gt;&amp;&amp; newItem, const Bookmark&amp; bookmark)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(contains(oldElement));
</span><del>-    ASSERT(!contains(&amp;newItem-&gt;element()));
</del><ins>+    ASSERT(!contains(newItem-&gt;element()));
</ins><span class="cx">     if (!bookmark.hasBeenMoved()) {
</span><del>-        ASSERT(&amp;bookmark.mark()-&gt;element() == oldElement);
-        bookmark.mark()-&gt;replaceElement(newItem);
</del><ins>+        ASSERT(&amp;bookmark.mark().element() == &amp;oldElement);
+        bookmark.mark().replaceElement(newItem.copyRef());
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    size_t index = bookmark.mark() - first();
</del><ins>+    size_t index = &amp;bookmark.mark() - &amp;first();
</ins><span class="cx">     ASSERT_WITH_SECURITY_IMPLICATION(index &lt; size());
</span><del>-    m_entries.insert(index + 1, newItem);
</del><ins>+    m_entries.insert(index + 1, WTFMove(newItem));
</ins><span class="cx">     remove(oldElement);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLFormattingElementList::append(PassRefPtr&lt;HTMLStackItem&gt; item)
</del><ins>+void HTMLFormattingElementList::append(Ref&lt;HTMLStackItem&gt;&amp;&amp; item)
</ins><span class="cx"> {
</span><del>-    ensureNoahsArkCondition(item.get());
-    m_entries.append(item);
</del><ins>+    ensureNoahsArkCondition(item);
+    m_entries.append(WTFMove(item));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLFormattingElementList::remove(Element* element)
</del><ins>+void HTMLFormattingElementList::remove(Element&amp; element)
</ins><span class="cx"> {
</span><del>-    size_t index = m_entries.reverseFind(element);
</del><ins>+    size_t index = m_entries.reverseFind(&amp;element);
</ins><span class="cx">     if (index != notFound)
</span><span class="cx">         m_entries.remove(index);
</span><span class="cx"> }
</span><span class="lines">@@ -123,7 +123,7 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLFormattingElementList::tryToEnsureNoahsArkConditionQuickly(HTMLStackItem* newItem, Vector&lt;HTMLStackItem*&gt;&amp; remainingCandidates)
</del><ins>+void HTMLFormattingElementList::tryToEnsureNoahsArkConditionQuickly(HTMLStackItem&amp; newItem, Vector&lt;HTMLStackItem*&gt;&amp; remainingCandidates)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(remainingCandidates.isEmpty());
</span><span class="cx"> 
</span><span class="lines">@@ -134,7 +134,7 @@
</span><span class="cx">     // of a quickly ensuring the condition.
</span><span class="cx">     Vector&lt;HTMLStackItem*, 10&gt; candidates;
</span><span class="cx"> 
</span><del>-    size_t newItemAttributeCount = newItem-&gt;attributes().size();
</del><ins>+    size_t newItemAttributeCount = newItem.attributes().size();
</ins><span class="cx"> 
</span><span class="cx">     for (size_t i = m_entries.size(); i; ) {
</span><span class="cx">         --i;
</span><span class="lines">@@ -144,7 +144,7 @@
</span><span class="cx"> 
</span><span class="cx">         // Quickly reject obviously non-matching candidates.
</span><span class="cx">         HTMLStackItem* candidate = entry.stackItem();
</span><del>-        if (newItem-&gt;localName() != candidate-&gt;localName() || newItem-&gt;namespaceURI() != candidate-&gt;namespaceURI())
</del><ins>+        if (newItem.localName() != candidate-&gt;localName() || newItem.namespaceURI() != candidate-&gt;namespaceURI())
</ins><span class="cx">             continue;
</span><span class="cx">         if (candidate-&gt;attributes().size() != newItemAttributeCount)
</span><span class="cx">             continue;
</span><span class="lines">@@ -158,7 +158,7 @@
</span><span class="cx">     remainingCandidates.appendVector(candidates);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLFormattingElementList::ensureNoahsArkCondition(HTMLStackItem* newItem)
</del><ins>+void HTMLFormattingElementList::ensureNoahsArkCondition(HTMLStackItem&amp; newItem)
</ins><span class="cx"> {
</span><span class="cx">     Vector&lt;HTMLStackItem*&gt; candidates;
</span><span class="cx">     tryToEnsureNoahsArkConditionQuickly(newItem, candidates);
</span><span class="lines">@@ -170,15 +170,15 @@
</span><span class="cx">     Vector&lt;HTMLStackItem*&gt; remainingCandidates;
</span><span class="cx">     remainingCandidates.reserveInitialCapacity(candidates.size());
</span><span class="cx"> 
</span><del>-    for (auto&amp; attribute : newItem-&gt;attributes()) {
</del><ins>+    for (auto&amp; attribute : newItem.attributes()) {
</ins><span class="cx">         for (auto&amp; candidate : candidates) {
</span><span class="cx">             // These properties should already have been checked by tryToEnsureNoahsArkConditionQuickly.
</span><del>-            ASSERT(newItem-&gt;attributes().size() == candidate-&gt;attributes().size());
-            ASSERT(newItem-&gt;localName() == candidate-&gt;localName() &amp;&amp; newItem-&gt;namespaceURI() == candidate-&gt;namespaceURI());
</del><ins>+            ASSERT(newItem.attributes().size() == candidate-&gt;attributes().size());
+            ASSERT(newItem.localName() == candidate-&gt;localName() &amp;&amp; newItem.namespaceURI() == candidate-&gt;namespaceURI());
</ins><span class="cx"> 
</span><del>-            const Attribute* candidateAttribute = candidate-&gt;findAttribute(attribute.name());
</del><ins>+            auto* candidateAttribute = candidate-&gt;findAttribute(attribute.name());
</ins><span class="cx">             if (candidateAttribute &amp;&amp; candidateAttribute-&gt;value() == attribute.value())
</span><del>-                remainingCandidates.append(candidate);
</del><ins>+                remainingCandidates.uncheckedAppend(candidate);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (remainingCandidates.size() &lt; kNoahsArkCapacity)
</span><span class="lines">@@ -192,7 +192,7 @@
</span><span class="cx">     // however, that we wil spin the loop more than once because of how the
</span><span class="cx">     // formatting element list gets permuted.
</span><span class="cx">     for (size_t i = kNoahsArkCapacity - 1; i &lt; candidates.size(); ++i)
</span><del>-        remove(&amp;candidates[i]-&gt;element());
</del><ins>+        remove(candidates[i]-&gt;element());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(TREE_DEBUGGING)
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLFormattingElementListh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLFormattingElementList.h (200339 => 200340)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLFormattingElementList.h        2016-05-02 21:42:07 UTC (rev 200339)
+++ trunk/Source/WebCore/html/parser/HTMLFormattingElementList.h        2016-05-02 22:18:05 UTC (rev 200340)
</span><span class="lines">@@ -48,16 +48,14 @@
</span><span class="cx">     class Entry {
</span><span class="cx">     public:
</span><span class="cx">         // Inline because they're hot and Vector&lt;T&gt; uses them.
</span><del>-        explicit Entry(PassRefPtr&lt;HTMLStackItem&gt; item)
-            : m_item(item)
</del><ins>+        explicit Entry(Ref&lt;HTMLStackItem&gt;&amp;&amp; item)
+            : m_item(WTFMove(item))
</ins><span class="cx">         {
</span><span class="cx">         }
</span><span class="cx">         enum MarkerEntryType { MarkerEntry };
</span><span class="cx">         Entry(MarkerEntryType)
</span><del>-            : m_item(0)
</del><span class="cx">         {
</span><span class="cx">         }
</span><del>-        ~Entry() {}
</del><span class="cx"> 
</span><span class="cx">         bool isMarker() const { return !m_item; }
</span><span class="cx"> 
</span><span class="lines">@@ -69,7 +67,7 @@
</span><span class="cx">             ASSERT(m_item);
</span><span class="cx">             return m_item-&gt;element();
</span><span class="cx">         }
</span><del>-        void replaceElement(PassRefPtr&lt;HTMLStackItem&gt; item) { m_item = item; }
</del><ins>+        void replaceElement(Ref&lt;HTMLStackItem&gt;&amp;&amp; item) { m_item = WTFMove(item); }
</ins><span class="cx"> 
</span><span class="cx">         // Needed for use with Vector.  These are super-hot and must be inline.
</span><span class="cx">         bool operator==(Element* element) const { return !m_item ? !element : &amp;m_item-&gt;element() == element; }
</span><span class="lines">@@ -81,20 +79,20 @@
</span><span class="cx"> 
</span><span class="cx">     class Bookmark {
</span><span class="cx">     public:
</span><del>-        Bookmark(Entry* entry)
</del><ins>+        explicit Bookmark(Entry&amp; entry)
</ins><span class="cx">             : m_hasBeenMoved(false)
</span><del>-            , m_mark(entry)
</del><ins>+            , m_mark(&amp;entry)
</ins><span class="cx">         {
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        void moveToAfter(Entry* before)
</del><ins>+        void moveToAfter(Entry&amp; before)
</ins><span class="cx">         {
</span><span class="cx">             m_hasBeenMoved = true;
</span><del>-            m_mark = before;
</del><ins>+            m_mark = &amp;before;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         bool hasBeenMoved() const { return m_hasBeenMoved; }
</span><del>-        Entry* mark() const { return m_mark; }
</del><ins>+        Entry&amp; mark() const { ASSERT(m_mark); return *m_mark; }
</ins><span class="cx"> 
</span><span class="cx">     private:
</span><span class="cx">         bool m_hasBeenMoved;
</span><span class="lines">@@ -106,13 +104,13 @@
</span><span class="cx"> 
</span><span class="cx">     Element* closestElementInScopeWithName(const AtomicString&amp;);
</span><span class="cx"> 
</span><del>-    Entry* find(Element*);
-    bool contains(Element*);
-    void append(PassRefPtr&lt;HTMLStackItem&gt;);
-    void remove(Element*);
</del><ins>+    Entry* find(Element&amp;);
+    bool contains(Element&amp;);
+    void append(Ref&lt;HTMLStackItem&gt;&amp;&amp;);
+    void remove(Element&amp;);
</ins><span class="cx"> 
</span><del>-    Bookmark bookmarkFor(Element*);
-    void swapTo(Element* oldElement, PassRefPtr&lt;HTMLStackItem&gt; newItem, const Bookmark&amp;);
</del><ins>+    Bookmark bookmarkFor(Element&amp;);
+    void swapTo(Element&amp; oldElement, Ref&lt;HTMLStackItem&gt;&amp;&amp; newItem, const Bookmark&amp;);
</ins><span class="cx"> 
</span><span class="cx">     void appendMarker();
</span><span class="cx">     // clearToLastMarker also clears the marker (per the HTML5 spec).
</span><span class="lines">@@ -126,12 +124,12 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    Entry* first() { return &amp;at(0); }
</del><ins>+    Entry&amp; first() { return at(0); }
</ins><span class="cx"> 
</span><span class="cx">     // http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#list-of-active-formatting-elements
</span><span class="cx">     // These functions enforce the &quot;Noah's Ark&quot; condition, which removes redundant mis-nested elements.
</span><del>-    void tryToEnsureNoahsArkConditionQuickly(HTMLStackItem*, Vector&lt;HTMLStackItem*&gt;&amp; remainingCandiates);
-    void ensureNoahsArkCondition(HTMLStackItem*);
</del><ins>+    void tryToEnsureNoahsArkConditionQuickly(HTMLStackItem&amp;, Vector&lt;HTMLStackItem*&gt;&amp; remainingCandidates);
+    void ensureNoahsArkCondition(HTMLStackItem&amp;);
</ins><span class="cx"> 
</span><span class="cx">     Vector&lt;Entry&gt; m_entries;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLTreeBuildercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp (200339 => 200340)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp        2016-05-02 21:42:07 UTC (rev 200339)
+++ trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp        2016-05-02 22:18:05 UTC (rev 200340)
</span><span class="lines">@@ -400,7 +400,7 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(token.type() == HTMLToken::DOCTYPE);
</span><span class="cx">     if (m_insertionMode == InsertionMode::Initial) {
</span><del>-        m_tree.insertDoctype(&amp;token);
</del><ins>+        m_tree.insertDoctype(token);
</ins><span class="cx">         m_insertionMode = InsertionMode::BeforeHTML;
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -510,7 +510,7 @@
</span><span class="cx">             break;
</span><span class="cx">     }
</span><span class="cx">     processFakePEndTagIfPInButtonScope();
</span><del>-    m_tree.insertHTMLElement(&amp;token);
</del><ins>+    m_tree.insertHTMLElement(token);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template &lt;typename TableQualifiedName&gt; static HashMap&lt;AtomicString, QualifiedName&gt; createCaseMap(const TableQualifiedName* const names[], unsigned length)
</span><span class="lines">@@ -618,7 +618,7 @@
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">         m_framesetOk = false;
</span><del>-        m_tree.insertHTMLBodyStartTagInBody(&amp;token);
</del><ins>+        m_tree.insertHTMLBodyStartTagInBody(token);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (token.name() == framesetTag) {
</span><span class="lines">@@ -630,10 +630,10 @@
</span><span class="cx">         if (!m_framesetOk)
</span><span class="cx">             return;
</span><span class="cx">         m_tree.openElements().bodyElement().remove(ASSERT_NO_EXCEPTION);
</span><del>-        m_tree.openElements().popUntil(&amp;m_tree.openElements().bodyElement());
</del><ins>+        m_tree.openElements().popUntil(m_tree.openElements().bodyElement());
</ins><span class="cx">         m_tree.openElements().popHTMLBodyElement();
</span><span class="cx">         ASSERT(&amp;m_tree.openElements().top() == &amp;m_tree.openElements().htmlElement());
</span><del>-        m_tree.insertHTMLElement(&amp;token);
</del><ins>+        m_tree.insertHTMLElement(token);
</ins><span class="cx">         m_insertionMode = InsertionMode::InFrameset;
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -661,7 +661,7 @@
</span><span class="cx">         || token.name() == summaryTag
</span><span class="cx">         || token.name() == ulTag) {
</span><span class="cx">         processFakePEndTagIfPInButtonScope();
</span><del>-        m_tree.insertHTMLElement(&amp;token);
</del><ins>+        m_tree.insertHTMLElement(token);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (isNumberedHeaderTag(token.name())) {
</span><span class="lines">@@ -670,12 +670,12 @@
</span><span class="cx">             parseError(token);
</span><span class="cx">             m_tree.openElements().pop();
</span><span class="cx">         }
</span><del>-        m_tree.insertHTMLElement(&amp;token);
</del><ins>+        m_tree.insertHTMLElement(token);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (token.name() == preTag || token.name() == listingTag) {
</span><span class="cx">         processFakePEndTagIfPInButtonScope();
</span><del>-        m_tree.insertHTMLElement(&amp;token);
</del><ins>+        m_tree.insertHTMLElement(token);
</ins><span class="cx">         m_shouldSkipLeadingNewline = true;
</span><span class="cx">         m_framesetOk = false;
</span><span class="cx">         return;
</span><span class="lines">@@ -686,7 +686,7 @@
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">         processFakePEndTagIfPInButtonScope();
</span><del>-        m_tree.insertHTMLFormElement(&amp;token);
</del><ins>+        m_tree.insertHTMLFormElement(token);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (token.name() == liTag) {
</span><span class="lines">@@ -699,7 +699,7 @@
</span><span class="cx">     }
</span><span class="cx">     if (token.name() == plaintextTag) {
</span><span class="cx">         processFakePEndTagIfPInButtonScope();
</span><del>-        m_tree.insertHTMLElement(&amp;token);
</del><ins>+        m_tree.insertHTMLElement(token);
</ins><span class="cx">         m_parser.tokenizer().setPLAINTEXTState();
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -711,7 +711,7 @@
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">         m_tree.reconstructTheActiveFormattingElements();
</span><del>-        m_tree.insertHTMLElement(&amp;token);
</del><ins>+        m_tree.insertHTMLElement(token);
</ins><span class="cx">         m_framesetOk = false;
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -720,17 +720,17 @@
</span><span class="cx">         if (activeATag) {
</span><span class="cx">             parseError(token);
</span><span class="cx">             processFakeEndTag(aTag);
</span><del>-            m_tree.activeFormattingElements().remove(activeATag);
-            if (m_tree.openElements().contains(activeATag))
-                m_tree.openElements().remove(activeATag);
</del><ins>+            m_tree.activeFormattingElements().remove(*activeATag);
+            if (m_tree.openElements().contains(*activeATag))
+                m_tree.openElements().remove(*activeATag);
</ins><span class="cx">         }
</span><span class="cx">         m_tree.reconstructTheActiveFormattingElements();
</span><del>-        m_tree.insertFormattingElement(&amp;token);
</del><ins>+        m_tree.insertFormattingElement(token);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (isNonAnchorNonNobrFormattingTag(token.name())) {
</span><span class="cx">         m_tree.reconstructTheActiveFormattingElements();
</span><del>-        m_tree.insertFormattingElement(&amp;token);
</del><ins>+        m_tree.insertFormattingElement(token);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (token.name() == nobrTag) {
</span><span class="lines">@@ -740,7 +740,7 @@
</span><span class="cx">             processFakeEndTag(nobrTag);
</span><span class="cx">             m_tree.reconstructTheActiveFormattingElements();
</span><span class="cx">         }
</span><del>-        m_tree.insertFormattingElement(&amp;token);
</del><ins>+        m_tree.insertFormattingElement(token);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (token.name() == appletTag || token.name() == embedTag || token.name() == objectTag) {
</span><span class="lines">@@ -749,7 +749,7 @@
</span><span class="cx">     }
</span><span class="cx">     if (token.name() == appletTag || token.name() == marqueeTag || token.name() == objectTag) {
</span><span class="cx">         m_tree.reconstructTheActiveFormattingElements();
</span><del>-        m_tree.insertHTMLElement(&amp;token);
</del><ins>+        m_tree.insertHTMLElement(token);
</ins><span class="cx">         m_tree.activeFormattingElements().appendMarker();
</span><span class="cx">         m_framesetOk = false;
</span><span class="cx">         return;
</span><span class="lines">@@ -757,7 +757,7 @@
</span><span class="cx">     if (token.name() == tableTag) {
</span><span class="cx">         if (!m_tree.inQuirksMode() &amp;&amp; m_tree.openElements().inButtonScope(pTag))
</span><span class="cx">             processFakeEndTag(pTag);
</span><del>-        m_tree.insertHTMLElement(&amp;token);
</del><ins>+        m_tree.insertHTMLElement(token);
</ins><span class="cx">         m_framesetOk = false;
</span><span class="cx">         m_insertionMode = InsertionMode::InTable;
</span><span class="cx">         return;
</span><span class="lines">@@ -775,25 +775,25 @@
</span><span class="cx">         || token.name() == keygenTag
</span><span class="cx">         || token.name() == wbrTag) {
</span><span class="cx">         m_tree.reconstructTheActiveFormattingElements();
</span><del>-        m_tree.insertSelfClosingHTMLElement(&amp;token);
</del><ins>+        m_tree.insertSelfClosingHTMLElement(token);
</ins><span class="cx">         m_framesetOk = false;
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (token.name() == inputTag) {
</span><span class="cx">         m_tree.reconstructTheActiveFormattingElements();
</span><del>-        m_tree.insertSelfClosingHTMLElement(&amp;token);
</del><ins>+        m_tree.insertSelfClosingHTMLElement(token);
</ins><span class="cx">         Attribute* typeAttribute = findAttribute(token.attributes(), typeAttr);
</span><span class="cx">         if (!typeAttribute || !equalLettersIgnoringASCIICase(typeAttribute-&gt;value(), &quot;hidden&quot;))
</span><span class="cx">             m_framesetOk = false;
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (token.name() == paramTag || token.name() == sourceTag || token.name() == trackTag) {
</span><del>-        m_tree.insertSelfClosingHTMLElement(&amp;token);
</del><ins>+        m_tree.insertSelfClosingHTMLElement(token);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (token.name() == hrTag) {
</span><span class="cx">         processFakePEndTagIfPInButtonScope();
</span><del>-        m_tree.insertSelfClosingHTMLElement(&amp;token);
</del><ins>+        m_tree.insertSelfClosingHTMLElement(token);
</ins><span class="cx">         m_framesetOk = false;
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -802,7 +802,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (token.name() == textareaTag) {
</span><del>-        m_tree.insertHTMLElement(&amp;token);
</del><ins>+        m_tree.insertHTMLElement(token);
</ins><span class="cx">         m_shouldSkipLeadingNewline = true;
</span><span class="cx">         m_parser.tokenizer().setRCDATAState();
</span><span class="cx">         m_originalInsertionMode = m_insertionMode;
</span><span class="lines">@@ -832,7 +832,7 @@
</span><span class="cx">     }
</span><span class="cx">     if (token.name() == selectTag) {
</span><span class="cx">         m_tree.reconstructTheActiveFormattingElements();
</span><del>-        m_tree.insertHTMLElement(&amp;token);
</del><ins>+        m_tree.insertHTMLElement(token);
</ins><span class="cx">         m_framesetOk = false;
</span><span class="cx">         if (m_insertionMode == InsertionMode::InTable
</span><span class="cx">             || m_insertionMode == InsertionMode::InCaption
</span><span class="lines">@@ -851,7 +851,7 @@
</span><span class="cx">             processEndTag(endOption);
</span><span class="cx">         }
</span><span class="cx">         m_tree.reconstructTheActiveFormattingElements();
</span><del>-        m_tree.insertHTMLElement(&amp;token);
</del><ins>+        m_tree.insertHTMLElement(token);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (token.name() == rbTag || token.name() == rtcTag) {
</span><span class="lines">@@ -860,7 +860,7 @@
</span><span class="cx">             if (!m_tree.currentStackItem().hasTagName(rubyTag))
</span><span class="cx">                 parseError(token);
</span><span class="cx">         }
</span><del>-        m_tree.insertHTMLElement(&amp;token);
</del><ins>+        m_tree.insertHTMLElement(token);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (token.name() == rtTag || token.name() == rpTag) {
</span><span class="lines">@@ -869,21 +869,21 @@
</span><span class="cx">             if (!m_tree.currentStackItem().hasTagName(rubyTag) &amp;&amp; !m_tree.currentStackItem().hasTagName(rtcTag))
</span><span class="cx">                 parseError(token);
</span><span class="cx">         }
</span><del>-        m_tree.insertHTMLElement(&amp;token);
</del><ins>+        m_tree.insertHTMLElement(token);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (token.name() == MathMLNames::mathTag.localName()) {
</span><span class="cx">         m_tree.reconstructTheActiveFormattingElements();
</span><span class="cx">         adjustMathMLAttributes(token);
</span><span class="cx">         adjustForeignAttributes(token);
</span><del>-        m_tree.insertForeignElement(&amp;token, MathMLNames::mathmlNamespaceURI);
</del><ins>+        m_tree.insertForeignElement(token, MathMLNames::mathmlNamespaceURI);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (token.name() == SVGNames::svgTag.localName()) {
</span><span class="cx">         m_tree.reconstructTheActiveFormattingElements();
</span><span class="cx">         adjustSVGAttributes(token);
</span><span class="cx">         adjustForeignAttributes(token);
</span><del>-        m_tree.insertForeignElement(&amp;token, SVGNames::svgNamespaceURI);
</del><ins>+        m_tree.insertForeignElement(token, SVGNames::svgNamespaceURI);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (isCaptionColOrColgroupTag(token.name())
</span><span class="lines">@@ -907,11 +907,11 @@
</span><span class="cx"> inline void HTMLTreeBuilder::insertGenericHTMLElement(AtomicHTMLToken&amp; token)
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(CUSTOM_ELEMENTS)
</span><del>-    auto* interface = m_tree.insertHTMLElementOrFindCustomElementInterface(&amp;token);
</del><ins>+    auto* interface = m_tree.insertHTMLElementOrFindCustomElementInterface(token);
</ins><span class="cx">     if (UNLIKELY(interface))
</span><span class="cx">         m_customElementToConstruct = std::make_unique&lt;CustomElementConstructionData&gt;(*interface, token.name(), token.attributes());
</span><span class="cx"> #else
</span><del>-    m_tree.insertHTMLElement(&amp;token);
</del><ins>+    m_tree.insertHTMLElement(token);
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -925,7 +925,7 @@
</span><span class="cx"> void HTMLTreeBuilder::processTemplateStartTag(AtomicHTMLToken&amp; token)
</span><span class="cx"> {
</span><span class="cx">     m_tree.activeFormattingElements().appendMarker();
</span><del>-    m_tree.insertHTMLElement(&amp;token);
</del><ins>+    m_tree.insertHTMLElement(token);
</ins><span class="cx">     m_templateInsertionModes.append(InsertionMode::TemplateContents);
</span><span class="cx">     m_insertionMode = InsertionMode::TemplateContents;
</span><span class="cx"> }
</span><span class="lines">@@ -992,13 +992,13 @@
</span><span class="cx">     if (token.name() == captionTag) {
</span><span class="cx">         m_tree.openElements().popUntilTableScopeMarker();
</span><span class="cx">         m_tree.activeFormattingElements().appendMarker();
</span><del>-        m_tree.insertHTMLElement(&amp;token);
</del><ins>+        m_tree.insertHTMLElement(token);
</ins><span class="cx">         m_insertionMode = InsertionMode::InCaption;
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (token.name() == colgroupTag) {
</span><span class="cx">         m_tree.openElements().popUntilTableScopeMarker();
</span><del>-        m_tree.insertHTMLElement(&amp;token);
</del><ins>+        m_tree.insertHTMLElement(token);
</ins><span class="cx">         m_insertionMode = InsertionMode::InColumnGroup;
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -1010,7 +1010,7 @@
</span><span class="cx">     }
</span><span class="cx">     if (isTableBodyContextTag(token.name())) {
</span><span class="cx">         m_tree.openElements().popUntilTableScopeMarker();
</span><del>-        m_tree.insertHTMLElement(&amp;token);
</del><ins>+        m_tree.insertHTMLElement(token);
</ins><span class="cx">         m_insertionMode = InsertionMode::InTableBody;
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -1037,7 +1037,7 @@
</span><span class="cx">         Attribute* typeAttribute = findAttribute(token.attributes(), typeAttr);
</span><span class="cx">         if (typeAttribute &amp;&amp; equalLettersIgnoringASCIICase(typeAttribute-&gt;value(), &quot;hidden&quot;)) {
</span><span class="cx">             parseError(token);
</span><del>-            m_tree.insertSelfClosingHTMLElement(&amp;token);
</del><ins>+            m_tree.insertSelfClosingHTMLElement(token);
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">         // Fall through to &quot;anything else&quot; case.
</span><span class="lines">@@ -1046,7 +1046,7 @@
</span><span class="cx">         parseError(token);
</span><span class="cx">         if (m_tree.form() &amp;&amp; !isParsingTemplateContents())
</span><span class="cx">             return;
</span><del>-        m_tree.insertHTMLFormElement(&amp;token, true);
</del><ins>+        m_tree.insertHTMLFormElement(token, true);
</ins><span class="cx">         m_tree.openElements().pop();
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -1069,7 +1069,7 @@
</span><span class="cx">         FALLTHROUGH;
</span><span class="cx">     case InsertionMode::BeforeHTML:
</span><span class="cx">         if (token.name() == htmlTag) {
</span><del>-            m_tree.insertHTMLHtmlStartTagBeforeHTML(&amp;token);
</del><ins>+            m_tree.insertHTMLHtmlStartTagBeforeHTML(token);
</ins><span class="cx">             m_insertionMode = InsertionMode::BeforeHead;
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="lines">@@ -1082,7 +1082,7 @@
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">         if (token.name() == headTag) {
</span><del>-            m_tree.insertHTMLHeadElement(&amp;token);
</del><ins>+            m_tree.insertHTMLHeadElement(token);
</ins><span class="cx">             m_insertionMode = InsertionMode::InHead;
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="lines">@@ -1102,12 +1102,12 @@
</span><span class="cx">         }
</span><span class="cx">         if (token.name() == bodyTag) {
</span><span class="cx">             m_framesetOk = false;
</span><del>-            m_tree.insertHTMLBodyElement(&amp;token);
</del><ins>+            m_tree.insertHTMLBodyElement(token);
</ins><span class="cx">             m_insertionMode = InsertionMode::InBody;
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">         if (token.name() == framesetTag) {
</span><del>-            m_tree.insertHTMLElement(&amp;token);
</del><ins>+            m_tree.insertHTMLElement(token);
</ins><span class="cx">             m_insertionMode = InsertionMode::InFrameset;
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="lines">@@ -1122,9 +1122,10 @@
</span><span class="cx">             || token.name() == templateTag
</span><span class="cx">             || token.name() == titleTag) {
</span><span class="cx">             parseError(token);
</span><del>-            m_tree.openElements().pushHTMLHeadElement(m_tree.headStackItem());
</del><ins>+            ASSERT(m_tree.headStackItem());
+            m_tree.openElements().pushHTMLHeadElement(*m_tree.headStackItem());
</ins><span class="cx">             processStartTagForInHead(token);
</span><del>-            m_tree.openElements().removeHTMLHeadElement(&amp;m_tree.head());
</del><ins>+            m_tree.openElements().removeHTMLHeadElement(m_tree.head());
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">         if (token.name() == headTag) {
</span><span class="lines">@@ -1161,7 +1162,7 @@
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">         if (token.name() == colTag) {
</span><del>-            m_tree.insertSelfClosingHTMLElement(&amp;token);
</del><ins>+            m_tree.insertSelfClosingHTMLElement(token);
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">         if (token.name() == templateTag) {
</span><span class="lines">@@ -1177,7 +1178,7 @@
</span><span class="cx">     case InsertionMode::InTableBody:
</span><span class="cx">         if (token.name() == trTag) {
</span><span class="cx">             m_tree.openElements().popUntilTableBodyScopeMarker(); // How is there ever anything to pop?
</span><del>-            m_tree.insertHTMLElement(&amp;token);
</del><ins>+            m_tree.insertHTMLElement(token);
</ins><span class="cx">             m_insertionMode = InsertionMode::InRow;
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="lines">@@ -1206,7 +1207,7 @@
</span><span class="cx">     case InsertionMode::InRow:
</span><span class="cx">         if (isTableCellContextTag(token.name())) {
</span><span class="cx">             m_tree.openElements().popUntilTableRowScopeMarker();
</span><del>-            m_tree.insertHTMLElement(&amp;token);
</del><ins>+            m_tree.insertHTMLElement(token);
</ins><span class="cx">             m_insertionMode = InsertionMode::InCell;
</span><span class="cx">             m_tree.activeFormattingElements().appendMarker();
</span><span class="cx">             return;
</span><span class="lines">@@ -1278,11 +1279,11 @@
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">         if (token.name() == framesetTag) {
</span><del>-            m_tree.insertHTMLElement(&amp;token);
</del><ins>+            m_tree.insertHTMLElement(token);
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">         if (token.name() == frameTag) {
</span><del>-            m_tree.insertSelfClosingHTMLElement(&amp;token);
</del><ins>+            m_tree.insertSelfClosingHTMLElement(token);
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">         if (token.name() == noframesTag) {
</span><span class="lines">@@ -1326,7 +1327,7 @@
</span><span class="cx">                 AtomicHTMLToken endOption(HTMLToken::EndTag, optionTag.localName());
</span><span class="cx">                 processEndTag(endOption);
</span><span class="cx">             }
</span><del>-            m_tree.insertHTMLElement(&amp;token);
</del><ins>+            m_tree.insertHTMLElement(token);
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">         if (token.name() == optgroupTag) {
</span><span class="lines">@@ -1338,7 +1339,7 @@
</span><span class="cx">                 AtomicHTMLToken endOptgroup(HTMLToken::EndTag, optgroupTag.localName());
</span><span class="cx">                 processEndTag(endOptgroup);
</span><span class="cx">             }
</span><del>-            m_tree.insertHTMLElement(&amp;token);
</del><ins>+            m_tree.insertHTMLElement(token);
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">         if (token.name() == selectTag) {
</span><span class="lines">@@ -1418,7 +1419,7 @@
</span><span class="cx">         ASSERT(isParsingTemplateContents());
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    m_tree.insertHTMLHtmlStartTagInBody(&amp;token);
</del><ins>+    m_tree.insertHTMLHtmlStartTagInBody(token);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool HTMLTreeBuilder::processBodyEndTagForInBody(AtomicHTMLToken&amp; token)
</span><span class="lines">@@ -1443,7 +1444,7 @@
</span><span class="cx">             m_tree.generateImpliedEndTagsWithExclusion(token.name());
</span><span class="cx">             if (!m_tree.currentStackItem().matchesHTMLTag(token.name()))
</span><span class="cx">                 parseError(token);
</span><del>-            m_tree.openElements().popUntilPopped(&amp;item.element());
</del><ins>+            m_tree.openElements().popUntilPopped(item.element());
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">         if (isSpecialNode(item)) {
</span><span class="lines">@@ -1471,34 +1472,34 @@
</span><span class="cx">         if (!formattingElement)
</span><span class="cx">             return processAnyOtherEndTagForInBody(token);
</span><span class="cx">         // 4.c
</span><del>-        if ((m_tree.openElements().contains(formattingElement)) &amp;&amp; !m_tree.openElements().inScope(formattingElement)) {
</del><ins>+        if ((m_tree.openElements().contains(*formattingElement)) &amp;&amp; !m_tree.openElements().inScope(*formattingElement)) {
</ins><span class="cx">             parseError(token);
</span><span class="cx">             notImplemented(); // Check the stack of open elements for a more specific parse error.
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">         // 4.b
</span><del>-        auto* formattingElementRecord = m_tree.openElements().find(formattingElement);
</del><ins>+        auto* formattingElementRecord = m_tree.openElements().find(*formattingElement);
</ins><span class="cx">         if (!formattingElementRecord) {
</span><span class="cx">             parseError(token);
</span><del>-            m_tree.activeFormattingElements().remove(formattingElement);
</del><ins>+            m_tree.activeFormattingElements().remove(*formattingElement);
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">         // 4.d
</span><span class="cx">         if (formattingElement != &amp;m_tree.currentElement())
</span><span class="cx">             parseError(token);
</span><span class="cx">         // 5.
</span><del>-        auto* furthestBlock = m_tree.openElements().furthestBlockForFormattingElement(formattingElement);
</del><ins>+        auto* furthestBlock = m_tree.openElements().furthestBlockForFormattingElement(*formattingElement);
</ins><span class="cx">         // 6.
</span><span class="cx">         if (!furthestBlock) {
</span><del>-            m_tree.openElements().popUntilPopped(formattingElement);
-            m_tree.activeFormattingElements().remove(formattingElement);
</del><ins>+            m_tree.openElements().popUntilPopped(*formattingElement);
+            m_tree.activeFormattingElements().remove(*formattingElement);
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">         // 7.
</span><del>-        ASSERT(furthestBlock-&gt;isAbove(formattingElementRecord));
</del><ins>+        ASSERT(furthestBlock-&gt;isAbove(*formattingElementRecord));
</ins><span class="cx">         Ref&lt;HTMLStackItem&gt; commonAncestor = formattingElementRecord-&gt;next()-&gt;stackItem();
</span><span class="cx">         // 8.
</span><del>-        HTMLFormattingElementList::Bookmark bookmark = m_tree.activeFormattingElements().bookmarkFor(formattingElement);
</del><ins>+        HTMLFormattingElementList::Bookmark bookmark = m_tree.activeFormattingElements().bookmarkFor(*formattingElement);
</ins><span class="cx">         // 9.
</span><span class="cx">         auto* node = furthestBlock;
</span><span class="cx">         auto* nextNode = node-&gt;next();
</span><span class="lines">@@ -1510,8 +1511,8 @@
</span><span class="cx">             ASSERT(node);
</span><span class="cx">             nextNode = node-&gt;next(); // Save node-&gt;next() for the next iteration in case node is deleted in 9.5.
</span><span class="cx">             // 9.5
</span><del>-            if (!m_tree.activeFormattingElements().contains(&amp;node-&gt;element())) {
-                m_tree.openElements().remove(&amp;node-&gt;element());
</del><ins>+            if (!m_tree.activeFormattingElements().contains(node-&gt;element())) {
+                m_tree.openElements().remove(node-&gt;element());
</ins><span class="cx">                 node = 0;
</span><span class="cx">                 continue;
</span><span class="cx">             }
</span><span class="lines">@@ -1519,15 +1520,15 @@
</span><span class="cx">             if (node == formattingElementRecord)
</span><span class="cx">                 break;
</span><span class="cx">             // 9.7
</span><del>-            RefPtr&lt;HTMLStackItem&gt; newItem = m_tree.createElementFromSavedToken(&amp;node-&gt;stackItem());
</del><ins>+            auto newItem = m_tree.createElementFromSavedToken(node-&gt;stackItem());
</ins><span class="cx"> 
</span><del>-            HTMLFormattingElementList::Entry* nodeEntry = m_tree.activeFormattingElements().find(&amp;node-&gt;element());
</del><ins>+            HTMLFormattingElementList::Entry* nodeEntry = m_tree.activeFormattingElements().find(node-&gt;element());
</ins><span class="cx">             nodeEntry-&gt;replaceElement(newItem.copyRef());
</span><del>-            node-&gt;replaceElement(newItem.release());
</del><ins>+            node-&gt;replaceElement(WTFMove(newItem));
</ins><span class="cx"> 
</span><span class="cx">             // 9.8
</span><span class="cx">             if (lastNode == furthestBlock)
</span><del>-                bookmark.moveToAfter(nodeEntry);
</del><ins>+                bookmark.moveToAfter(*nodeEntry);
</ins><span class="cx">             // 9.9
</span><span class="cx">             m_tree.reparent(*node, *lastNode);
</span><span class="cx">             // 9.10
</span><span class="lines">@@ -1536,16 +1537,16 @@
</span><span class="cx">         // 10.
</span><span class="cx">         m_tree.insertAlreadyParsedChild(commonAncestor.get(), *lastNode);
</span><span class="cx">         // 11.
</span><del>-        RefPtr&lt;HTMLStackItem&gt; newItem = m_tree.createElementFromSavedToken(&amp;formattingElementRecord-&gt;stackItem());
</del><ins>+        auto newItem = m_tree.createElementFromSavedToken(formattingElementRecord-&gt;stackItem());
</ins><span class="cx">         // 12.
</span><del>-        m_tree.takeAllChildren(*newItem, *furthestBlock);
</del><ins>+        m_tree.takeAllChildren(newItem, *furthestBlock);
</ins><span class="cx">         // 13.
</span><del>-        m_tree.reparent(*furthestBlock, *newItem);
</del><ins>+        m_tree.reparent(*furthestBlock, newItem);
</ins><span class="cx">         // 14.
</span><del>-        m_tree.activeFormattingElements().swapTo(formattingElement, newItem, bookmark);
</del><ins>+        m_tree.activeFormattingElements().swapTo(*formattingElement, newItem.copyRef(), bookmark);
</ins><span class="cx">         // 15.
</span><del>-        m_tree.openElements().remove(formattingElement);
-        m_tree.openElements().insertAbove(newItem, furthestBlock);
</del><ins>+        m_tree.openElements().remove(*formattingElement);
+        m_tree.openElements().insertAbove(WTFMove(newItem), *furthestBlock);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1798,15 +1799,15 @@
</span><span class="cx">     }
</span><span class="cx">     if (token.name() == formTag) {
</span><span class="cx">         if (!isParsingTemplateContents()) {
</span><del>-            RefPtr&lt;Element&gt; node = m_tree.takeForm();
-            if (!node || !m_tree.openElements().inScope(node.get())) {
</del><ins>+            RefPtr&lt;Element&gt; formElement = m_tree.takeForm();
+            if (!formElement || !m_tree.openElements().inScope(*formElement)) {
</ins><span class="cx">                 parseError(token);
</span><span class="cx">                 return;
</span><span class="cx">             }
</span><span class="cx">             m_tree.generateImpliedEndTags();
</span><del>-            if (&amp;m_tree.currentNode() != node.get())
</del><ins>+            if (&amp;m_tree.currentNode() != formElement.get())
</ins><span class="cx">                 parseError(token);
</span><del>-            m_tree.openElements().remove(node.get());
</del><ins>+            m_tree.openElements().remove(*formElement);
</ins><span class="cx">         } else {
</span><span class="cx">             if (!m_tree.openElements().inScope(token.name())) {
</span><span class="cx">                 parseError(token);
</span><span class="lines">@@ -2213,11 +2214,11 @@
</span><span class="cx">         || m_insertionMode == InsertionMode::BeforeHTML
</span><span class="cx">         || m_insertionMode == InsertionMode::AfterAfterBody
</span><span class="cx">         || m_insertionMode == InsertionMode::AfterAfterFrameset) {
</span><del>-        m_tree.insertCommentOnDocument(&amp;token);
</del><ins>+        m_tree.insertCommentOnDocument(token);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (m_insertionMode == InsertionMode::AfterBody) {
</span><del>-        m_tree.insertCommentOnHTMLHtmlElement(&amp;token);
</del><ins>+        m_tree.insertCommentOnHTMLHtmlElement(token);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (m_insertionMode == InsertionMode::InTableText) {
</span><span class="lines">@@ -2225,7 +2226,7 @@
</span><span class="cx">         processComment(token);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    m_tree.insertComment(&amp;token);
</del><ins>+    m_tree.insertComment(token);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLTreeBuilder::processCharacter(AtomicHTMLToken&amp; token)
</span><span class="lines">@@ -2583,7 +2584,7 @@
</span><span class="cx"> void HTMLTreeBuilder::defaultForBeforeHTML()
</span><span class="cx"> {
</span><span class="cx">     AtomicHTMLToken startHTML(HTMLToken::StartTag, htmlTag.localName());
</span><del>-    m_tree.insertHTMLHtmlStartTagBeforeHTML(&amp;startHTML);
</del><ins>+    m_tree.insertHTMLHtmlStartTagBeforeHTML(startHTML);
</ins><span class="cx">     m_insertionMode = InsertionMode::BeforeHead;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2642,7 +2643,7 @@
</span><span class="cx">         || token.name() == commandTag
</span><span class="cx">         || token.name() == linkTag
</span><span class="cx">         || token.name() == metaTag) {
</span><del>-        m_tree.insertSelfClosingHTMLElement(&amp;token);
</del><ins>+        m_tree.insertSelfClosingHTMLElement(token);
</ins><span class="cx">         // Note: The custom processing for the &lt;meta&gt; tag is done in HTMLMetaElement::process().
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="lines">@@ -2655,7 +2656,7 @@
</span><span class="cx">             processGenericRawTextStartTag(token);
</span><span class="cx">             return true;
</span><span class="cx">         }
</span><del>-        m_tree.insertHTMLElement(&amp;token);
</del><ins>+        m_tree.insertHTMLElement(token);
</ins><span class="cx">         m_insertionMode = InsertionMode::InHeadNoscript;
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="lines">@@ -2684,7 +2685,7 @@
</span><span class="cx"> void HTMLTreeBuilder::processGenericRCDATAStartTag(AtomicHTMLToken&amp; token)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(token.type() == HTMLToken::StartTag);
</span><del>-    m_tree.insertHTMLElement(&amp;token);
</del><ins>+    m_tree.insertHTMLElement(token);
</ins><span class="cx">     m_parser.tokenizer().setRCDATAState();
</span><span class="cx">     m_originalInsertionMode = m_insertionMode;
</span><span class="cx">     m_insertionMode = InsertionMode::Text;
</span><span class="lines">@@ -2693,7 +2694,7 @@
</span><span class="cx"> void HTMLTreeBuilder::processGenericRawTextStartTag(AtomicHTMLToken&amp; token)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(token.type() == HTMLToken::StartTag);
</span><del>-    m_tree.insertHTMLElement(&amp;token);
</del><ins>+    m_tree.insertHTMLElement(token);
</ins><span class="cx">     m_parser.tokenizer().setRAWTEXTState();
</span><span class="cx">     m_originalInsertionMode = m_insertionMode;
</span><span class="cx">     m_insertionMode = InsertionMode::Text;
</span><span class="lines">@@ -2702,7 +2703,7 @@
</span><span class="cx"> void HTMLTreeBuilder::processScriptStartTag(AtomicHTMLToken&amp; token)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(token.type() == HTMLToken::StartTag);
</span><del>-    m_tree.insertScriptElement(&amp;token);
</del><ins>+    m_tree.insertScriptElement(token);
</ins><span class="cx">     m_parser.tokenizer().setScriptDataState();
</span><span class="cx">     m_originalInsertionMode = m_insertionMode;
</span><span class="cx"> 
</span><span class="lines">@@ -2824,7 +2825,7 @@
</span><span class="cx">             adjustSVGAttributes(token);
</span><span class="cx">         }
</span><span class="cx">         adjustForeignAttributes(token);
</span><del>-        m_tree.insertForeignElement(&amp;token, currentNamespace);
</del><ins>+        m_tree.insertForeignElement(token, currentNamespace);
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     case HTMLToken::EndTag: {
</span><span class="lines">@@ -2844,7 +2845,7 @@
</span><span class="cx">                 parseError(token);
</span><span class="cx">             while (1) {
</span><span class="cx">                 if (nodeRecord-&gt;stackItem().localName() == token.name()) {
</span><del>-                    m_tree.openElements().popUntilPopped(&amp;nodeRecord-&gt;element());
</del><ins>+                    m_tree.openElements().popUntilPopped(nodeRecord-&gt;element());
</ins><span class="cx">                     return;
</span><span class="cx">                 }
</span><span class="cx">                 nodeRecord = nodeRecord-&gt;next();
</span><span class="lines">@@ -2858,7 +2859,7 @@
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     case HTMLToken::Comment:
</span><del>-        m_tree.insertComment(&amp;token);
</del><ins>+        m_tree.insertComment(token);
</ins><span class="cx">         return;
</span><span class="cx">     case HTMLToken::Character: {
</span><span class="cx">         String characters = String(token.characters(), token.charactersLength());
</span></span></pre>
</div>
</div>

</body>
</html>