<!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>[177883] 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/177883">177883</a></dd>
<dt>Author</dt> <dd>darin@apple.com</dd>
<dt>Date</dt> <dd>2015-01-04 18:24:31 -0800 (Sun, 04 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Modernize and tighten up HTMLDocumentParser
https://bugs.webkit.org/show_bug.cgi?id=140041

Reviewed by Sam Weinig.

* dom/DocumentFragment.cpp:
(WebCore::DocumentFragment::parseHTML): Pass a reference instead of
a pointer for the context element.

* html/FTPDirectoryDocument.cpp: Removed unneeded includes, made more
things in FTPDirectoryDocumentParser private. Use Ref instead of RefPtr
in a could places. Initialize in class instead of in constructor.
(WebCore::FTPDirectoryDocumentParser::FTPDirectoryDocumentParser):
Less initialization here.
(WebCore::FTPDirectoryDocumentParser::createTDForFilename): More Ref here.
(WebCore::createTemplateDocumentData): Removed unneeded initialization
of RefPtr, which is initialized without explicitly asking for it.
(WebCore::FTPDirectoryDocumentParser::loadDocumentTemplate): Reworded
comment slightly.

* html/parser/HTMLDocumentParser.cpp: Cut down on includes.
(WebCore::tokenizerStateForContextElement): Fixed URL. Changed argument
to be a reference rather than a pointer.
(WebCore::HTMLDocumentParser::inPumpSession):
(WebCore::HTMLDocumentParser::shouldDelayEnd):
(WebCore::HTMLDocumentParser::HTMLDocumentParser): Marked constructors
inline. Updated for data members that are now objects instead of pointers.
Removed explicit initialization for scalars that are now initialized in
the class definition.
(WebCore::HTMLDocumentParser::create): Moved the private creation
functions in here, out of the header file.
(WebCore::HTMLDocumentParser::~HTMLDocumentParser): Removed unused
m_haveBackgroundParser.
(WebCore::HTMLDocumentParser::prepareToStopParsing): Updated URL and
removed m_haveBackgroundParser reference.
(WebCore::HTMLDocumentParser::processingData): Removed a check of
m_haveBackgroundParser.
(WebCore::HTMLDocumentParser::resumeParsingAfterYield): Tweak comment.
(WebCore::HTMLDocumentParser::runScriptsForPausedTreeBuilder): Added
a null check of the result of takeScriptToProcess, since there really
is no guarantee it's non-null.
(WebCore::HTMLDocumentParser::canTakeNextToken): Removed assertion
that was for m_haveBackgroundParser cases only. Rewrapped comment.
(WebCore::HTMLDocumentParser::contextForParsingSession): Use nullptr.
(WebCore::HTMLDocumentParser::pumpTokenizer): Rework comments,
remove assertions that no longer make sense, use auto instead of
repeating a long type name, update to use m_token and m_tokenizer.
(WebCore::HTMLDocumentParser::hasInsertionPoint): Rewrapped comment.
(WebCore::HTMLDocumentParser::insert): Got rid of braces around a
single-line if body.
(WebCore::HTMLDocumentParser::attemptToRunDeferredScriptsAndEnd):
Removed comment about incorrect m_haveBackgroundParser assertion.
(WebCore::HTMLDocumentParser::isExecutingScript): Use &amp;&amp; style instead
of early exit for a null check.
(WebCore::HTMLDocumentParser::textPosition): Tightened up code a little.
(WebCore::HTMLDocumentParser::resumeParsingAfterScriptExecution): Added
a Ref to protect the parser, as is already done in every other function
that calls pumpTokenizerIfPossible.
(WebCore::HTMLDocumentParser::parseDocumentFragment): Take a reference
instead of a pointer. Also use auto so we get a Ref instead of a RefPtr.

* html/parser/HTMLDocumentParser.h: Removed unneeded includes.
Made private inheritance explicit instead of just omitting public.
Moved function bodies out of the class, and in some cases, out of the
header entirely. Return a reference from tokenizer(). Marked most
virtual functions final. Made DocumentFragment version of the
constructor private rather than protected. Made the functions
suspendScheduledTasks() and resumeScheduledTasks() private, since
they are always called through a base class. Removed the private
token function since it is better to get at m_token directly.
Removed m_haveBackgroundParser, since we don't have that any more
and it's always false. Also removed forcePlaintextForTextDocument
since the tokenizer is exposed and can be used directly to do that.

* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::HTMLTreeBuilder): Made the parser non-const.
It could only be const before because HTMLDocumentParser::tokenizer
took a const parser and returned a non-const tokenizer, but that doesn't
really make sense.
(WebCore::HTMLTreeBuilder::constructTree): Removed null check for
tokenizer, which was never null. Updated since tokenizer is a reference.
(WebCore::HTMLTreeBuilder::processStartTagForInBody): Ditto.
(WebCore::HTMLTreeBuilder::processStartTagForInTable): Ditto.
(WebCore::HTMLTreeBuilder::processEndTag): Ditto. Also fixed and removed
some assertions like the ones I did recently in the rest of this file.
(WebCore::HTMLTreeBuilder::processGenericRCDATAStartTag): Ditto.
(WebCore::HTMLTreeBuilder::processGenericRawTextStartTag): Ditto.
(WebCore::HTMLTreeBuilder::processScriptStartTag): Ditto.

* html/parser/HTMLTreeBuilder.h: Made HTMLDocumentParser&amp; non-const.

* html/parser/TextDocumentParser.cpp: Removed unneeded include and
unneeded explicit destructor.
(WebCore::TextDocumentParser::TextDocumentParser): Updated since
treeBuilder() returns a reference now, and set the tokenizer state
directly since tokenizer() is exposed.

* html/parser/TextDocumentParser.h: Moved initialization of the
data member here instead of the constructor. Also removed unneeded
explicitly defined destructor.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomDocumentFragmentcpp">trunk/Source/WebCore/dom/DocumentFragment.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlFTPDirectoryDocumentcpp">trunk/Source/WebCore/html/FTPDirectoryDocument.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLDocumentParsercpp">trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLDocumentParserh">trunk/Source/WebCore/html/parser/HTMLDocumentParser.h</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLTreeBuildercpp">trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLTreeBuilderh">trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h</a></li>
<li><a href="#trunkSourceWebCorehtmlparserTextDocumentParsercpp">trunk/Source/WebCore/html/parser/TextDocumentParser.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlparserTextDocumentParserh">trunk/Source/WebCore/html/parser/TextDocumentParser.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (177882 => 177883)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-01-05 01:08:01 UTC (rev 177882)
+++ trunk/Source/WebCore/ChangeLog        2015-01-05 02:24:31 UTC (rev 177883)
</span><span class="lines">@@ -1,3 +1,106 @@
</span><ins>+2015-01-04  Darin Adler  &lt;darin@apple.com&gt;
+
+        Modernize and tighten up HTMLDocumentParser
+        https://bugs.webkit.org/show_bug.cgi?id=140041
+
+        Reviewed by Sam Weinig.
+
+        * dom/DocumentFragment.cpp:
+        (WebCore::DocumentFragment::parseHTML): Pass a reference instead of
+        a pointer for the context element.
+
+        * html/FTPDirectoryDocument.cpp: Removed unneeded includes, made more
+        things in FTPDirectoryDocumentParser private. Use Ref instead of RefPtr
+        in a could places. Initialize in class instead of in constructor.
+        (WebCore::FTPDirectoryDocumentParser::FTPDirectoryDocumentParser):
+        Less initialization here.
+        (WebCore::FTPDirectoryDocumentParser::createTDForFilename): More Ref here.
+        (WebCore::createTemplateDocumentData): Removed unneeded initialization
+        of RefPtr, which is initialized without explicitly asking for it.
+        (WebCore::FTPDirectoryDocumentParser::loadDocumentTemplate): Reworded
+        comment slightly.
+
+        * html/parser/HTMLDocumentParser.cpp: Cut down on includes.
+        (WebCore::tokenizerStateForContextElement): Fixed URL. Changed argument
+        to be a reference rather than a pointer.
+        (WebCore::HTMLDocumentParser::inPumpSession):
+        (WebCore::HTMLDocumentParser::shouldDelayEnd):
+        (WebCore::HTMLDocumentParser::HTMLDocumentParser): Marked constructors
+        inline. Updated for data members that are now objects instead of pointers.
+        Removed explicit initialization for scalars that are now initialized in
+        the class definition.
+        (WebCore::HTMLDocumentParser::create): Moved the private creation
+        functions in here, out of the header file.
+        (WebCore::HTMLDocumentParser::~HTMLDocumentParser): Removed unused
+        m_haveBackgroundParser.
+        (WebCore::HTMLDocumentParser::prepareToStopParsing): Updated URL and
+        removed m_haveBackgroundParser reference.
+        (WebCore::HTMLDocumentParser::processingData): Removed a check of
+        m_haveBackgroundParser.
+        (WebCore::HTMLDocumentParser::resumeParsingAfterYield): Tweak comment.
+        (WebCore::HTMLDocumentParser::runScriptsForPausedTreeBuilder): Added
+        a null check of the result of takeScriptToProcess, since there really
+        is no guarantee it's non-null.
+        (WebCore::HTMLDocumentParser::canTakeNextToken): Removed assertion
+        that was for m_haveBackgroundParser cases only. Rewrapped comment.
+        (WebCore::HTMLDocumentParser::contextForParsingSession): Use nullptr.
+        (WebCore::HTMLDocumentParser::pumpTokenizer): Rework comments,
+        remove assertions that no longer make sense, use auto instead of
+        repeating a long type name, update to use m_token and m_tokenizer.
+        (WebCore::HTMLDocumentParser::hasInsertionPoint): Rewrapped comment.
+        (WebCore::HTMLDocumentParser::insert): Got rid of braces around a
+        single-line if body.
+        (WebCore::HTMLDocumentParser::attemptToRunDeferredScriptsAndEnd):
+        Removed comment about incorrect m_haveBackgroundParser assertion.
+        (WebCore::HTMLDocumentParser::isExecutingScript): Use &amp;&amp; style instead
+        of early exit for a null check.
+        (WebCore::HTMLDocumentParser::textPosition): Tightened up code a little.
+        (WebCore::HTMLDocumentParser::resumeParsingAfterScriptExecution): Added
+        a Ref to protect the parser, as is already done in every other function
+        that calls pumpTokenizerIfPossible.
+        (WebCore::HTMLDocumentParser::parseDocumentFragment): Take a reference
+        instead of a pointer. Also use auto so we get a Ref instead of a RefPtr.
+
+        * html/parser/HTMLDocumentParser.h: Removed unneeded includes.
+        Made private inheritance explicit instead of just omitting public.
+        Moved function bodies out of the class, and in some cases, out of the
+        header entirely. Return a reference from tokenizer(). Marked most
+        virtual functions final. Made DocumentFragment version of the
+        constructor private rather than protected. Made the functions
+        suspendScheduledTasks() and resumeScheduledTasks() private, since
+        they are always called through a base class. Removed the private
+        token function since it is better to get at m_token directly.
+        Removed m_haveBackgroundParser, since we don't have that any more
+        and it's always false. Also removed forcePlaintextForTextDocument
+        since the tokenizer is exposed and can be used directly to do that.
+
+        * html/parser/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::HTMLTreeBuilder): Made the parser non-const.
+        It could only be const before because HTMLDocumentParser::tokenizer
+        took a const parser and returned a non-const tokenizer, but that doesn't
+        really make sense.
+        (WebCore::HTMLTreeBuilder::constructTree): Removed null check for
+        tokenizer, which was never null. Updated since tokenizer is a reference.
+        (WebCore::HTMLTreeBuilder::processStartTagForInBody): Ditto.
+        (WebCore::HTMLTreeBuilder::processStartTagForInTable): Ditto.
+        (WebCore::HTMLTreeBuilder::processEndTag): Ditto. Also fixed and removed
+        some assertions like the ones I did recently in the rest of this file.
+        (WebCore::HTMLTreeBuilder::processGenericRCDATAStartTag): Ditto.
+        (WebCore::HTMLTreeBuilder::processGenericRawTextStartTag): Ditto.
+        (WebCore::HTMLTreeBuilder::processScriptStartTag): Ditto.
+
+        * html/parser/HTMLTreeBuilder.h: Made HTMLDocumentParser&amp; non-const.
+
+        * html/parser/TextDocumentParser.cpp: Removed unneeded include and
+        unneeded explicit destructor.
+        (WebCore::TextDocumentParser::TextDocumentParser): Updated since
+        treeBuilder() returns a reference now, and set the tokenizer state
+        directly since tokenizer() is exposed.
+
+        * html/parser/TextDocumentParser.h: Moved initialization of the
+        data member here instead of the constructor. Also removed unneeded
+        explicitly defined destructor.
+
</ins><span class="cx"> 2015-01-04  Antti Koivisto  &lt;antti@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove GlyphPageTree
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentFragmentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DocumentFragment.cpp (177882 => 177883)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DocumentFragment.cpp        2015-01-05 01:08:01 UTC (rev 177882)
+++ trunk/Source/WebCore/dom/DocumentFragment.cpp        2015-01-05 02:24:31 UTC (rev 177883)
</span><span class="lines">@@ -82,11 +82,13 @@
</span><span class="cx"> 
</span><span class="cx"> void DocumentFragment::parseHTML(const String&amp; source, Element* contextElement, ParserContentPolicy parserContentPolicy)
</span><span class="cx"> {
</span><del>-    HTMLDocumentParser::parseDocumentFragment(source, *this, contextElement, parserContentPolicy);
</del><ins>+    ASSERT(contextElement);
+    HTMLDocumentParser::parseDocumentFragment(source, *this, *contextElement, parserContentPolicy);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool DocumentFragment::parseXML(const String&amp; source, Element* contextElement, ParserContentPolicy parserContentPolicy)
</span><span class="cx"> {
</span><ins>+    ASSERT(contextElement);
</ins><span class="cx">     return XMLDocumentParser::parseDocumentFragment(source, *this, contextElement, parserContentPolicy);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlFTPDirectoryDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/FTPDirectoryDocument.cpp (177882 => 177883)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/FTPDirectoryDocument.cpp        2015-01-05 01:08:01 UTC (rev 177882)
+++ trunk/Source/WebCore/html/FTPDirectoryDocument.cpp        2015-01-05 02:24:31 UTC (rev 177883)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2007, 2008, 2014 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2007-2008, 2014-2015 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -26,9 +26,7 @@
</span><span class="cx"> #if ENABLE(FTPDIR)
</span><span class="cx"> #include &quot;FTPDirectoryDocument.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;ExceptionCodePlaceholder.h&quot;
</del><span class="cx"> #include &quot;HTMLDocumentParser.h&quot;
</span><del>-#include &quot;HTMLNames.h&quot;
</del><span class="cx"> #include &quot;HTMLTableElement.h&quot;
</span><span class="cx"> #include &quot;LocalizedStrings.h&quot;
</span><span class="cx"> #include &quot;Logging.h&quot;
</span><span class="lines">@@ -36,10 +34,7 @@
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><span class="cx"> #include &quot;SharedBuffer.h&quot;
</span><span class="cx"> #include &quot;Text.h&quot;
</span><del>-#include &lt;wtf/CurrentTime.h&gt;
-#include &lt;wtf/GregorianDateTime.h&gt;
</del><span class="cx"> #include &lt;wtf/StdLibExtras.h&gt;
</span><del>-#include &lt;wtf/text/CString.h&gt;
</del><span class="cx"> #include &lt;wtf/unicode/CharacterNames.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -53,12 +48,14 @@
</span><span class="cx">         return adoptRef(*new FTPDirectoryDocumentParser(document));
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+private:
</ins><span class="cx">     virtual void append(PassRefPtr&lt;StringImpl&gt;) override;
</span><span class="cx">     virtual void finish() override;
</span><span class="cx"> 
</span><ins>+    // FIXME: Why do we need this?
</ins><span class="cx">     virtual bool isWaitingForScripts() const override { return false; }
</span><span class="cx"> 
</span><del>-    inline void checkBuffer(int len = 10)
</del><ins>+    void checkBuffer(int len = 10)
</ins><span class="cx">     {
</span><span class="cx">         if ((m_dest - m_buffer) &gt; m_size - len) {
</span><span class="cx">             // Enlarge buffer
</span><span class="lines">@@ -69,8 +66,7 @@
</span><span class="cx">             m_size = newSize;
</span><span class="cx">         }
</span><span class="cx">     }
</span><del>-        
-private:
</del><ins>+
</ins><span class="cx">     FTPDirectoryDocumentParser(HTMLDocument&amp;);
</span><span class="cx"> 
</span><span class="cx">     // The parser will attempt to load the document template specified via the preference
</span><span class="lines">@@ -81,13 +77,13 @@
</span><span class="cx"> 
</span><span class="cx">     void parseAndAppendOneLine(const String&amp;);
</span><span class="cx">     void appendEntry(const String&amp; name, const String&amp; size, const String&amp; date, bool isDirectory);    
</span><del>-    RefPtr&lt;Element&gt; createTDForFilename(const String&amp;);
</del><ins>+    Ref&lt;Element&gt; createTDForFilename(const String&amp;);
</ins><span class="cx"> 
</span><span class="cx">     RefPtr&lt;HTMLTableElement&gt; m_tableElement;
</span><span class="cx"> 
</span><del>-    bool m_skipLF;
</del><ins>+    bool m_skipLF { false };
</ins><span class="cx">     
</span><del>-    int m_size;
</del><ins>+    int m_size { 254 };
</ins><span class="cx">     UChar* m_buffer;
</span><span class="cx">     UChar* m_dest;
</span><span class="cx">     String m_carryOver;
</span><span class="lines">@@ -97,8 +93,6 @@
</span><span class="cx"> 
</span><span class="cx"> FTPDirectoryDocumentParser::FTPDirectoryDocumentParser(HTMLDocument&amp; document)
</span><span class="cx">     : HTMLDocumentParser(document)
</span><del>-    , m_skipLF(false)
-    , m_size(254)
</del><span class="cx">     , m_buffer(static_cast&lt;UChar*&gt;(fastMalloc(sizeof(UChar) * m_size)))
</span><span class="cx">     , m_dest(m_buffer)
</span><span class="cx"> {
</span><span class="lines">@@ -132,7 +126,7 @@
</span><span class="cx">     rowElement-&gt;appendChild(element, IGNORE_EXCEPTION);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RefPtr&lt;Element&gt; FTPDirectoryDocumentParser::createTDForFilename(const String&amp; filename)
</del><ins>+Ref&lt;Element&gt; FTPDirectoryDocumentParser::createTDForFilename(const String&amp; filename)
</ins><span class="cx"> {
</span><span class="cx">     String fullURL = document()-&gt;baseURL().string();
</span><span class="cx">     if (fullURL.endsWith('/'))
</span><span class="lines">@@ -144,10 +138,10 @@
</span><span class="cx">     anchorElement-&gt;setAttribute(HTMLNames::hrefAttr, fullURL);
</span><span class="cx">     anchorElement-&gt;appendChild(Text::create(*document(), filename), IGNORE_EXCEPTION);
</span><span class="cx"> 
</span><del>-    RefPtr&lt;Element&gt; tdElement = document()-&gt;createElement(tdTag, false);
</del><ins>+    Ref&lt;Element&gt; tdElement = document()-&gt;createElement(tdTag, false);
</ins><span class="cx">     tdElement-&gt;appendChild(anchorElement, IGNORE_EXCEPTION);
</span><span class="cx"> 
</span><del>-    return tdElement.release();
</del><ins>+    return tdElement;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static String processFilesizeString(const String&amp; size, bool isDirectory)
</span><span class="lines">@@ -275,7 +269,7 @@
</span><span class="cx"> 
</span><span class="cx"> static inline RefPtr&lt;SharedBuffer&gt; createTemplateDocumentData(Settings* settings)
</span><span class="cx"> {
</span><del>-    RefPtr&lt;SharedBuffer&gt; buffer = 0;
</del><ins>+    RefPtr&lt;SharedBuffer&gt; buffer;
</ins><span class="cx">     if (settings)
</span><span class="cx">         buffer = SharedBuffer::createWithContentsOfFile(settings-&gt;ftpDirectoryTemplatePath());
</span><span class="cx">     if (buffer)
</span><span class="lines">@@ -286,9 +280,8 @@
</span><span class="cx"> bool FTPDirectoryDocumentParser::loadDocumentTemplate()
</span><span class="cx"> {
</span><span class="cx">     static SharedBuffer* templateDocumentData = createTemplateDocumentData(document()-&gt;settings()).release().leakRef();
</span><del>-    // FIXME: Instead of storing the data, we'd rather actually parse the template data into the template Document once,
-    // store that document, then &quot;copy&quot; it whenever we get an FTP directory listing.  There are complexities with this 
-    // approach that make it worth putting this off.
</del><ins>+    // FIXME: Instead of storing the data, it would be more efficient if we could parse the template data into the
+    // template Document once, store that document, then &quot;copy&quot; it whenever we get an FTP directory listing.
</ins><span class="cx">     
</span><span class="cx">     if (!templateDocumentData) {
</span><span class="cx">         LOG_ERROR(&quot;Could not load templateData&quot;);
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLDocumentParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp (177882 => 177883)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp        2015-01-05 01:08:01 UTC (rev 177882)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp        2015-01-05 02:24:31 UTC (rev 177883)
</span><span class="lines">@@ -1,5 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2010 Google, Inc. All Rights Reserved.
</span><ins>+ * Copyright (C) 2015 Apple Inc. All Rights Reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -26,31 +27,24 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;HTMLDocumentParser.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;ContentSecurityPolicy.h&quot;
</del><span class="cx"> #include &quot;DocumentFragment.h&quot;
</span><del>-#include &quot;DocumentLoader.h&quot;
-#include &quot;Frame.h&quot;
</del><span class="cx"> #include &quot;HTMLParserScheduler.h&quot;
</span><ins>+#include &quot;HTMLPreloadScanner.h&quot;
</ins><span class="cx"> #include &quot;HTMLScriptRunner.h&quot;
</span><span class="cx"> #include &quot;HTMLTreeBuilder.h&quot;
</span><span class="cx"> #include &quot;HTMLDocument.h&quot;
</span><span class="cx"> #include &quot;InspectorInstrumentation.h&quot;
</span><del>-#include &quot;Settings.h&quot;
-#include &lt;wtf/Ref.h&gt;
</del><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> using namespace HTMLNames;
</span><span class="cx"> 
</span><span class="cx"> // This is a direct transcription of step 4 from:
</span><del>-// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#fragment-case
-static HTMLTokenizer::State tokenizerStateForContextElement(Element* contextElement, bool reportErrors, const HTMLParserOptions&amp; options)
</del><ins>+// https://html.spec.whatwg.org/multipage/syntax.html#parsing-html-fragments
+static HTMLTokenizer::State tokenizerStateForContextElement(Element&amp; contextElement, bool reportErrors, const HTMLParserOptions&amp; options)
</ins><span class="cx"> {
</span><del>-    if (!contextElement)
-        return HTMLTokenizer::DataState;
</del><ins>+    const QualifiedName&amp; contextTag = contextElement.tagQName();
</ins><span class="cx"> 
</span><del>-    const QualifiedName&amp; contextTag = contextElement-&gt;tagQName();
-
</del><span class="cx">     if (contextTag.matches(titleTag) || contextTag.matches(textareaTag))
</span><span class="cx">         return HTMLTokenizer::RCDATAState;
</span><span class="cx">     if (contextTag.matches(styleTag)
</span><span class="lines">@@ -70,46 +64,43 @@
</span><span class="cx"> HTMLDocumentParser::HTMLDocumentParser(HTMLDocument&amp; document)
</span><span class="cx">     : ScriptableDocumentParser(document)
</span><span class="cx">     , m_options(document)
</span><del>-    , m_token(std::make_unique&lt;HTMLToken&gt;())
-    , m_tokenizer(std::make_unique&lt;HTMLTokenizer&gt;(m_options))
</del><ins>+    , m_tokenizer(m_options)
</ins><span class="cx">     , m_scriptRunner(std::make_unique&lt;HTMLScriptRunner&gt;(document, static_cast&lt;HTMLScriptRunnerHost&amp;&gt;(*this)))
</span><span class="cx">     , m_treeBuilder(std::make_unique&lt;HTMLTreeBuilder&gt;(*this, document, parserContentPolicy(), m_options))
</span><span class="cx">     , m_parserScheduler(std::make_unique&lt;HTMLParserScheduler&gt;(*this))
</span><span class="cx">     , m_xssAuditorDelegate(document)
</span><span class="cx">     , m_preloader(std::make_unique&lt;HTMLResourcePreloader&gt;(document))
</span><del>-    , m_endWasDelayed(false)
-    , m_haveBackgroundParser(false)
-    , m_pumpSessionNestingLevel(0)
</del><span class="cx"> {
</span><del>-    ASSERT(m_token);
-    ASSERT(m_tokenizer);
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-// FIXME: Member variables should be grouped into self-initializing structs to
-// minimize code duplication between these constructors.
-HTMLDocumentParser::HTMLDocumentParser(DocumentFragment&amp; fragment, Element* contextElement, ParserContentPolicy parserContentPolicy)
-    : ScriptableDocumentParser(fragment.document(), parserContentPolicy)
</del><ins>+Ref&lt;HTMLDocumentParser&gt; HTMLDocumentParser::create(HTMLDocument&amp; document)
+{
+    return adoptRef(*new HTMLDocumentParser(document));
+}
+
+inline HTMLDocumentParser::HTMLDocumentParser(DocumentFragment&amp; fragment, Element&amp; contextElement, ParserContentPolicy contentPolicy)
+    : ScriptableDocumentParser(fragment.document(), contentPolicy)
</ins><span class="cx">     , m_options(fragment.document())
</span><del>-    , m_token(std::make_unique&lt;HTMLToken&gt;())
-    , m_tokenizer(std::make_unique&lt;HTMLTokenizer&gt;(m_options))
-    , m_treeBuilder(std::make_unique&lt;HTMLTreeBuilder&gt;(*this, fragment, *contextElement, this-&gt;parserContentPolicy(), m_options))
</del><ins>+    , m_tokenizer(m_options)
+    , m_treeBuilder(std::make_unique&lt;HTMLTreeBuilder&gt;(*this, fragment, contextElement, contentPolicy, m_options))
</ins><span class="cx">     , m_xssAuditorDelegate(fragment.document())
</span><del>-    , m_endWasDelayed(false)
-    , m_haveBackgroundParser(false)
-    , m_pumpSessionNestingLevel(0)
</del><span class="cx"> {
</span><span class="cx">     bool reportErrors = false; // For now document fragment parsing never reports errors.
</span><del>-    m_tokenizer-&gt;setState(tokenizerStateForContextElement(contextElement, reportErrors, m_options));
</del><ins>+    m_tokenizer.setState(tokenizerStateForContextElement(contextElement, reportErrors, m_options));
</ins><span class="cx">     m_xssAuditor.initForFragment();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+inline Ref&lt;HTMLDocumentParser&gt; HTMLDocumentParser::create(DocumentFragment&amp; fragment, Element&amp; contextElement, ParserContentPolicy parserContentPolicy)
+{
+    return adoptRef(*new HTMLDocumentParser(fragment, contextElement, parserContentPolicy));
+}
+
</ins><span class="cx"> HTMLDocumentParser::~HTMLDocumentParser()
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!m_parserScheduler);
</span><span class="cx">     ASSERT(!m_pumpSessionNestingLevel);
</span><span class="cx">     ASSERT(!m_preloadScanner);
</span><span class="cx">     ASSERT(!m_insertionPreloadScanner);
</span><del>-    ASSERT(!m_haveBackgroundParser);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLDocumentParser::detach()
</span><span class="lines">@@ -132,12 +123,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // This kicks off &quot;Once the user agent stops parsing&quot; as described by:
</span><del>-// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#the-end
</del><ins>+// https://html.spec.whatwg.org/multipage/syntax.html#the-end
</ins><span class="cx"> void HTMLDocumentParser::prepareToStopParsing()
</span><span class="cx"> {
</span><del>-    // FIXME: It may not be correct to disable this for the background parser.
-    // That means hasInsertionPoint() may not be correct in some cases.
-    ASSERT(!hasInsertionPoint() || m_haveBackgroundParser);
</del><ins>+    ASSERT(!hasInsertionPoint());
</ins><span class="cx"> 
</span><span class="cx">     // pumpTokenizer can cause this parser to be detached from the Document,
</span><span class="cx">     // but we need to ensure it isn't deleted yet.
</span><span class="lines">@@ -164,6 +153,16 @@
</span><span class="cx">     attemptToRunDeferredScriptsAndEnd();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+inline bool HTMLDocumentParser::inPumpSession() const
+{
+    return m_pumpSessionNestingLevel &gt; 0;
+}
+
+inline bool HTMLDocumentParser::shouldDelayEnd() const
+{
+    return inPumpSession() || isWaitingForScripts() || isScheduledForResume() || isExecutingScript();
+}
+
</ins><span class="cx"> bool HTMLDocumentParser::isParsingFragment() const
</span><span class="cx"> {
</span><span class="cx">     return m_treeBuilder-&gt;isParsingFragment();
</span><span class="lines">@@ -171,7 +170,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool HTMLDocumentParser::processingData() const
</span><span class="cx"> {
</span><del>-    return isScheduledForResume() || inPumpSession() || m_haveBackgroundParser;
</del><ins>+    return isScheduledForResume() || inPumpSession();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLDocumentParser::pumpTokenizerIfPossible(SynchronousMode mode)
</span><span class="lines">@@ -200,8 +199,8 @@
</span><span class="cx">     // but we need to ensure it isn't deleted yet.
</span><span class="cx">     Ref&lt;HTMLDocumentParser&gt; protect(*this);
</span><span class="cx"> 
</span><del>-    // We should never be here unless we can pump immediately.  Call pumpTokenizer()
-    // directly so that ASSERTS will fire if we're wrong.
</del><ins>+    // We should never be here unless we can pump immediately.
+    // Call pumpTokenizer() directly so that ASSERTS will fire if we're wrong.
</ins><span class="cx">     pumpTokenizer(AllowYield);
</span><span class="cx">     endIfDelayed();
</span><span class="cx"> }
</span><span class="lines">@@ -211,10 +210,11 @@
</span><span class="cx">     ASSERT(scriptingContentIsAllowed(parserContentPolicy()));
</span><span class="cx"> 
</span><span class="cx">     TextPosition scriptStartPosition = TextPosition::belowRangePosition();
</span><del>-    RefPtr&lt;Element&gt; scriptElement = m_treeBuilder-&gt;takeScriptToProcess(scriptStartPosition);
-    // We will not have a scriptRunner when parsing a DocumentFragment.
-    if (m_scriptRunner)
-        m_scriptRunner-&gt;execute(scriptElement.release(), scriptStartPosition);
</del><ins>+    if (auto scriptElement = m_treeBuilder-&gt;takeScriptToProcess(scriptStartPosition)) {
+        // We will not have a scriptRunner when parsing a DocumentFragment.
+        if (m_scriptRunner)
+            m_scriptRunner-&gt;execute(scriptElement.release(), scriptStartPosition);
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool HTMLDocumentParser::canTakeNextToken(SynchronousMode mode, PumpSession&amp; session)
</span><span class="lines">@@ -222,8 +222,6 @@
</span><span class="cx">     if (isStopped())
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    ASSERT(!m_haveBackgroundParser || mode == ForceSynchronous);
-
</del><span class="cx">     if (isWaitingForScripts()) {
</span><span class="cx">         if (mode == AllowYield)
</span><span class="cx">             m_parserScheduler-&gt;checkForYieldBeforeScript(session);
</span><span class="lines">@@ -238,14 +236,11 @@
</span><span class="cx">             return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // FIXME: It's wrong for the HTMLDocumentParser to reach back to the
-    //        Frame, but this approach is how the old parser handled
-    //        stopping when the page assigns window.location.  What really
-    //        should happen is that assigning window.location causes the
-    //        parser to stop parsing cleanly.  The problem is we're not
-    //        perpared to do that at every point where we run JavaScript.
-    if (!isParsingFragment()
-        &amp;&amp; document()-&gt;frame() &amp;&amp; document()-&gt;frame()-&gt;navigationScheduler().locationChangePending())
</del><ins>+    // FIXME: It's wrong for the HTMLDocumentParser to reach back to the Frame, but this approach is
+    // how the parser has always handled stopping when the page assigns window.location. What should
+    // happen instead  is that assigning window.location causes the parser to stop parsing cleanly.
+    // The problem is we're not prepared to do that at every point where we run JavaScript.
+    if (!isParsingFragment() &amp;&amp; document()-&gt;frame() &amp;&amp; document()-&gt;frame()-&gt;navigationScheduler().locationChangePending())
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     if (mode == AllowYield)
</span><span class="lines">@@ -254,17 +249,12 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLDocumentParser::forcePlaintextForTextDocument()
-{
-    m_tokenizer-&gt;setState(HTMLTokenizer::PLAINTEXTState);
-}
-
</del><span class="cx"> Document* HTMLDocumentParser::contextForParsingSession()
</span><span class="cx"> {
</span><span class="cx">     // The parsing session should interact with the document only when parsing
</span><span class="cx">     // non-fragments. Otherwise, we might delay the load event mistakenly.
</span><span class="cx">     if (isParsingFragment())
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx">     return document();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -272,11 +262,9 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!isStopped());
</span><span class="cx">     ASSERT(!isScheduledForResume());
</span><del>-    // ASSERT that this object is both attached to the Document and protected.
</del><ins>+
+    // This is an attempt to check that this object is both attached to the Document and protected by something.
</ins><span class="cx">     ASSERT(refCount() &gt;= 2);
</span><del>-    ASSERT(m_tokenizer);
-    ASSERT(m_token);
-    ASSERT(!m_haveBackgroundParser || mode == ForceSynchronous);
</del><span class="cx"> 
</span><span class="cx">     PumpSession session(m_pumpSessionNestingLevel, contextForParsingSession());
</span><span class="cx"> 
</span><span class="lines">@@ -285,28 +273,28 @@
</span><span class="cx">     // FIXME: m_input.current().length() is only accurate if we
</span><span class="cx">     // end up parsing the whole buffer in this pump.  We should pass how
</span><span class="cx">     // much we parsed as part of didWriteHTML instead of willWriteHTML.
</span><del>-    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willWriteHTML(document(), m_input.current().currentLine().zeroBasedInt());
</del><ins>+    auto cookie = InspectorInstrumentation::willWriteHTML(document(), m_input.current().currentLine().zeroBasedInt());
</ins><span class="cx"> 
</span><span class="cx">     m_xssAuditor.init(document(), &amp;m_xssAuditorDelegate);
</span><span class="cx"> 
</span><span class="cx">     while (canTakeNextToken(mode, session) &amp;&amp; !session.needsYield) {
</span><span class="cx">         if (!isParsingFragment())
</span><del>-            m_sourceTracker.start(m_input.current(), m_tokenizer.get(), token());
</del><ins>+            m_sourceTracker.start(m_input.current(), &amp;m_tokenizer, m_token);
</ins><span class="cx"> 
</span><del>-        if (!m_tokenizer-&gt;nextToken(m_input.current(), token()))
</del><ins>+        if (!m_tokenizer.nextToken(m_input.current(), m_token))
</ins><span class="cx">             break;
</span><span class="cx"> 
</span><span class="cx">         if (!isParsingFragment()) {
</span><del>-            m_sourceTracker.end(m_input.current(), m_tokenizer.get(), token());
</del><ins>+            m_sourceTracker.end(m_input.current(), &amp;m_tokenizer, m_token);
</ins><span class="cx"> 
</span><span class="cx">             // We do not XSS filter innerHTML, which means we (intentionally) fail
</span><span class="cx">             // http/tests/security/xssAuditor/dom-write-innerHTML.html
</span><del>-            if (auto xssInfo = m_xssAuditor.filterToken(FilterTokenRequest(token(), m_sourceTracker, m_tokenizer-&gt;shouldAllowCDATA())))
</del><ins>+            if (auto xssInfo = m_xssAuditor.filterToken(FilterTokenRequest(m_token, m_sourceTracker, m_tokenizer.shouldAllowCDATA())))
</ins><span class="cx">                 m_xssAuditorDelegate.didBlockScript(*xssInfo);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        constructTreeFromHTMLToken(token());
-        ASSERT(token().isUninitialized());
</del><ins>+        constructTreeFromHTMLToken(m_token);
+        ASSERT(m_token.isUninitialized());
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Ensure we haven't been totally deref'ed after pumping. Any caller of this
</span><span class="lines">@@ -320,7 +308,7 @@
</span><span class="cx">         m_parserScheduler-&gt;scheduleForResume();
</span><span class="cx"> 
</span><span class="cx">     if (isWaitingForScripts()) {
</span><del>-        ASSERT(m_tokenizer-&gt;state() == HTMLTokenizer::DataState);
</del><ins>+        ASSERT(m_tokenizer.state() == HTMLTokenizer::DataState);
</ins><span class="cx">         if (!m_preloadScanner) {
</span><span class="cx">             m_preloadScanner = std::make_unique&lt;HTMLPreloadScanner&gt;(m_options, document()-&gt;url(), document()-&gt;deviceScaleFactor());
</span><span class="cx">             m_preloadScanner-&gt;appendToEnd(m_input.current());
</span><span class="lines">@@ -359,10 +347,9 @@
</span><span class="cx"> bool HTMLDocumentParser::hasInsertionPoint()
</span><span class="cx"> {
</span><span class="cx">     // FIXME: The wasCreatedByScript() branch here might not be fully correct.
</span><del>-    //        Our model of the EOF character differs slightly from the one in
-    //        the spec because our treatment is uniform between network-sourced
-    //        and script-sourced input streams whereas the spec treats them
-    //        differently.
</del><ins>+    // Our model of the EOF character differs slightly from the one in the spec
+    // because our treatment is uniform between network-sourced and script-sourced
+    // input streams whereas the spec treats them differently.
</ins><span class="cx">     return m_input.hasInsertionPoint() || (wasCreatedByScript() &amp;&amp; !m_input.haveSeenEndOfFile());
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -383,9 +370,8 @@
</span><span class="cx">     if (isWaitingForScripts()) {
</span><span class="cx">         // Check the document.write() output with a separate preload scanner as
</span><span class="cx">         // the main scanner can't deal with insertions.
</span><del>-        if (!m_insertionPreloadScanner) {
</del><ins>+        if (!m_insertionPreloadScanner)
</ins><span class="cx">             m_insertionPreloadScanner = std::make_unique&lt;HTMLPreloadScanner&gt;(m_options, document()-&gt;url(), document()-&gt;deviceScaleFactor());
</span><del>-        }
</del><span class="cx">         m_insertionPreloadScanner-&gt;appendToEnd(source);
</span><span class="cx">         m_insertionPreloadScanner-&gt;scan(m_preloader.get(), *document());
</span><span class="cx">     }
</span><span class="lines">@@ -401,6 +387,7 @@
</span><span class="cx">     // pumpTokenizer can cause this parser to be detached from the Document,
</span><span class="cx">     // but we need to ensure it isn't deleted yet.
</span><span class="cx">     Ref&lt;HTMLDocumentParser&gt; protect(*this);
</span><ins>+
</ins><span class="cx">     String source(inputSource);
</span><span class="cx"> 
</span><span class="cx">     if (m_preloadScanner) {
</span><span class="lines">@@ -441,9 +428,7 @@
</span><span class="cx"> void HTMLDocumentParser::attemptToRunDeferredScriptsAndEnd()
</span><span class="cx"> {
</span><span class="cx">     ASSERT(isStopping());
</span><del>-    // FIXME: It may not be correct to disable this for the background parser.
-    // That means hasInsertionPoint() may not be correct in some cases.
-    ASSERT(!hasInsertionPoint() || m_haveBackgroundParser);
</del><ins>+    ASSERT(!hasInsertionPoint());
</ins><span class="cx">     if (m_scriptRunner &amp;&amp; !m_scriptRunner-&gt;executeScriptsWaitingForParsing())
</span><span class="cx">         return;
</span><span class="cx">     end();
</span><span class="lines">@@ -491,18 +476,13 @@
</span><span class="cx"> 
</span><span class="cx"> bool HTMLDocumentParser::isExecutingScript() const
</span><span class="cx"> {
</span><del>-    if (!m_scriptRunner)
-        return false;
-    return m_scriptRunner-&gt;isExecutingScript();
</del><ins>+    return m_scriptRunner &amp;&amp; m_scriptRunner-&gt;isExecutingScript();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TextPosition HTMLDocumentParser::textPosition() const
</span><span class="cx"> {
</span><del>-    const SegmentedString&amp; currentString = m_input.current();
-    OrdinalNumber line = currentString.currentLine();
-    OrdinalNumber column = currentString.currentColumn();
-
-    return TextPosition(line, column);
</del><ins>+    auto&amp; currentString = m_input.current();
+    return TextPosition(currentString.currentLine(), currentString.currentColumn());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool HTMLDocumentParser::isWaitingForScripts() const
</span><span class="lines">@@ -526,6 +506,10 @@
</span><span class="cx">     ASSERT(!isExecutingScript());
</span><span class="cx">     ASSERT(!isWaitingForScripts());
</span><span class="cx"> 
</span><ins>+    // pumpTokenizer can cause this parser to be detached from the Document,
+    // but we need to ensure it isn't deleted yet.
+    Ref&lt;HTMLDocumentParser&gt; protect(*this);
+
</ins><span class="cx">     m_insertionPreloadScanner = nullptr;
</span><span class="cx">     pumpTokenizerIfPossible(AllowYield);
</span><span class="cx">     endIfDelayed();
</span><span class="lines">@@ -589,13 +573,13 @@
</span><span class="cx">         resumeParsingAfterScriptExecution();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLDocumentParser::parseDocumentFragment(const String&amp; source, DocumentFragment&amp; fragment, Element* contextElement, ParserContentPolicy parserContentPolicy)
</del><ins>+void HTMLDocumentParser::parseDocumentFragment(const String&amp; source, DocumentFragment&amp; fragment, Element&amp; contextElement, ParserContentPolicy parserContentPolicy)
</ins><span class="cx"> {
</span><del>-    RefPtr&lt;HTMLDocumentParser&gt; parser = HTMLDocumentParser::create(fragment, contextElement, parserContentPolicy);
</del><ins>+    auto parser = create(fragment, contextElement, parserContentPolicy);
</ins><span class="cx">     parser-&gt;insert(source); // Use insert() so that the parser will not yield.
</span><span class="cx">     parser-&gt;finish();
</span><del>-    ASSERT(!parser-&gt;processingData()); // Make sure we're done. &lt;rdar://problem/3963151&gt;
-    parser-&gt;detach(); // Allows ~DocumentParser to assert it was detached before destruction.
</del><ins>+    ASSERT(!parser-&gt;processingData());
+    parser-&gt;detach();
</ins><span class="cx"> }
</span><span class="cx">     
</span><span class="cx"> void HTMLDocumentParser::suspendScheduledTasks()
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLDocumentParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.h (177882 => 177883)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.h        2015-01-05 01:08:01 UTC (rev 177882)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.h        2015-01-05 02:24:31 UTC (rev 177883)
</span><span class="lines">@@ -1,5 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2010 Google, Inc. All Rights Reserved.
</span><ins>+ * Copyright (C) 2015 Apple Inc. All Rights Reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -27,103 +28,78 @@
</span><span class="cx"> #define HTMLDocumentParser_h
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CachedResourceClient.h&quot;
</span><del>-#include &quot;FragmentScriptingPermission.h&quot;
</del><span class="cx"> #include &quot;HTMLInputStream.h&quot;
</span><del>-#include &quot;HTMLParserOptions.h&quot;
-#include &quot;HTMLPreloadScanner.h&quot;
</del><span class="cx"> #include &quot;HTMLScriptRunnerHost.h&quot;
</span><span class="cx"> #include &quot;HTMLSourceTracker.h&quot;
</span><del>-#include &quot;HTMLToken.h&quot;
</del><span class="cx"> #include &quot;HTMLTokenizer.h&quot;
</span><span class="cx"> #include &quot;ScriptableDocumentParser.h&quot;
</span><del>-#include &quot;SegmentedString.h&quot;
</del><span class="cx"> #include &quot;XSSAuditor.h&quot;
</span><span class="cx"> #include &quot;XSSAuditorDelegate.h&quot;
</span><del>-#include &lt;wtf/Deque.h&gt;
-#include &lt;wtf/WeakPtr.h&gt;
-#include &lt;wtf/text/TextPosition.h&gt;
</del><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class BackgroundHTMLParser;
-class CompactHTMLToken;
-class Document;
</del><span class="cx"> class DocumentFragment;
</span><span class="cx"> class HTMLDocument;
</span><span class="cx"> class HTMLParserScheduler;
</span><ins>+class HTMLPreloadScanner;
</ins><span class="cx"> class HTMLScriptRunner;
</span><span class="cx"> class HTMLTreeBuilder;
</span><span class="cx"> class HTMLResourcePreloader;
</span><del>-class ScriptController;
-class ScriptSourceCode;
-
</del><span class="cx"> class PumpSession;
</span><span class="cx"> 
</span><del>-class HTMLDocumentParser :  public ScriptableDocumentParser, HTMLScriptRunnerHost, CachedResourceClient {
</del><ins>+class HTMLDocumentParser : public ScriptableDocumentParser, private HTMLScriptRunnerHost, private CachedResourceClient {
</ins><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><del>-    static Ref&lt;HTMLDocumentParser&gt; create(HTMLDocument&amp; document)
-    {
-        return adoptRef(*new HTMLDocumentParser(document));
-    }
</del><ins>+    static Ref&lt;HTMLDocumentParser&gt; create(HTMLDocument&amp;);
</ins><span class="cx">     virtual ~HTMLDocumentParser();
</span><span class="cx"> 
</span><del>-    // Exposed for HTMLParserScheduler
</del><ins>+    static void parseDocumentFragment(const String&amp;, DocumentFragment&amp;, Element&amp; contextElement, ParserContentPolicy = AllowScriptingContent);
+
+    // For HTMLParserScheduler.
</ins><span class="cx">     void resumeParsingAfterYield();
</span><span class="cx"> 
</span><del>-    static void parseDocumentFragment(const String&amp;, DocumentFragment&amp;, Element* contextElement, ParserContentPolicy = AllowScriptingContent);
</del><ins>+    // For HTMLTreeBuilder.
+    HTMLTokenizer&amp; tokenizer();
+    virtual TextPosition textPosition() const override final;
</ins><span class="cx"> 
</span><del>-    HTMLTokenizer* tokenizer() const { return m_tokenizer.get(); }
-
-    virtual TextPosition textPosition() const override;
-
-    virtual void suspendScheduledTasks() override;
-    virtual void resumeScheduledTasks() override;
-
</del><span class="cx"> protected:
</span><del>-    virtual void insert(const SegmentedString&amp;) override;
</del><ins>+    explicit HTMLDocumentParser(HTMLDocument&amp;);
+
+    virtual void insert(const SegmentedString&amp;) override final;
</ins><span class="cx">     virtual void append(PassRefPtr&lt;StringImpl&gt;) override;
</span><span class="cx">     virtual void finish() override;
</span><span class="cx"> 
</span><del>-    explicit HTMLDocumentParser(HTMLDocument&amp;);
-    HTMLDocumentParser(DocumentFragment&amp;, Element* contextElement, ParserContentPolicy);
</del><ins>+    HTMLTreeBuilder&amp; treeBuilder();
</ins><span class="cx"> 
</span><del>-    HTMLTreeBuilder* treeBuilder() const { return m_treeBuilder.get(); }
-
-    void forcePlaintextForTextDocument();
-
</del><span class="cx"> private:
</span><del>-    static Ref&lt;HTMLDocumentParser&gt; create(DocumentFragment&amp; fragment, Element* contextElement, ParserContentPolicy parserContentPolicy)
-    {
-        return adoptRef(*new HTMLDocumentParser(fragment, contextElement, parserContentPolicy));
-    }
</del><ins>+    HTMLDocumentParser(DocumentFragment&amp;, Element&amp; contextElement, ParserContentPolicy);
+    static Ref&lt;HTMLDocumentParser&gt; create(DocumentFragment&amp;, Element&amp; contextElement, ParserContentPolicy);
</ins><span class="cx"> 
</span><span class="cx">     // DocumentParser
</span><del>-    virtual void detach() override;
-    virtual bool hasInsertionPoint() override;
-    virtual bool processingData() const override;
-    virtual void prepareToStopParsing() override;
-    virtual void stopParsing() override;
</del><ins>+    virtual void detach() override final;
+    virtual bool hasInsertionPoint() override final;
+    virtual bool processingData() const override final;
+    virtual void prepareToStopParsing() override final;
+    virtual void stopParsing() override final;
</ins><span class="cx">     virtual bool isWaitingForScripts() const override;
</span><del>-    virtual bool isExecutingScript() const override;
-    virtual void executeScriptsWaitingForStylesheets() override;
</del><ins>+    virtual bool isExecutingScript() const override final;
+    virtual void executeScriptsWaitingForStylesheets() override final;
+    virtual void suspendScheduledTasks() override final;
+    virtual void resumeScheduledTasks() override final;
</ins><span class="cx"> 
</span><span class="cx">     // HTMLScriptRunnerHost
</span><del>-    virtual void watchForLoad(CachedResource*) override;
-    virtual void stopWatchingForLoad(CachedResource*) override;
-    virtual HTMLInputStream&amp; inputStream() override { return m_input; }
-    virtual bool hasPreloadScanner() const override { return m_preloadScanner.get(); }
-    virtual void appendCurrentInputStreamToPreloadScannerAndScan() override;
</del><ins>+    virtual void watchForLoad(CachedResource*) override final;
+    virtual void stopWatchingForLoad(CachedResource*) override final;
+    virtual HTMLInputStream&amp; inputStream() override final;
+    virtual bool hasPreloadScanner() const override final;
+    virtual void appendCurrentInputStreamToPreloadScannerAndScan() override final;
</ins><span class="cx"> 
</span><span class="cx">     // CachedResourceClient
</span><del>-    virtual void notifyFinished(CachedResource*) override;
</del><ins>+    virtual void notifyFinished(CachedResource*) override final;
</ins><span class="cx"> 
</span><span class="cx">     Document* contextForParsingSession();
</span><span class="cx"> 
</span><del>-    enum SynchronousMode {
-        AllowYield,
-        ForceSynchronous,
-    };
</del><ins>+    enum SynchronousMode { AllowYield, ForceSynchronous };
</ins><span class="cx">     bool canTakeNextToken(SynchronousMode, PumpSession&amp;);
</span><span class="cx">     void pumpTokenizer(SynchronousMode);
</span><span class="cx">     void pumpTokenizerIfPossible(SynchronousMode);
</span><span class="lines">@@ -139,16 +115,14 @@
</span><span class="cx"> 
</span><span class="cx">     bool isParsingFragment() const;
</span><span class="cx">     bool isScheduledForResume() const;
</span><del>-    bool inPumpSession() const { return m_pumpSessionNestingLevel &gt; 0; }
-    bool shouldDelayEnd() const { return inPumpSession() || isWaitingForScripts() || isScheduledForResume() || isExecutingScript(); }
</del><ins>+    bool inPumpSession() const;
+    bool shouldDelayEnd() const;
</ins><span class="cx"> 
</span><del>-    HTMLToken&amp; token() { return *m_token.get(); }
-
</del><span class="cx">     HTMLParserOptions m_options;
</span><span class="cx">     HTMLInputStream m_input;
</span><span class="cx"> 
</span><del>-    std::unique_ptr&lt;HTMLToken&gt; m_token;
-    std::unique_ptr&lt;HTMLTokenizer&gt; m_tokenizer;
</del><ins>+    HTMLToken m_token;
+    HTMLTokenizer m_tokenizer;
</ins><span class="cx">     std::unique_ptr&lt;HTMLScriptRunner&gt; m_scriptRunner;
</span><span class="cx">     std::unique_ptr&lt;HTMLTreeBuilder&gt; m_treeBuilder;
</span><span class="cx">     std::unique_ptr&lt;HTMLPreloadScanner&gt; m_preloadScanner;
</span><span class="lines">@@ -161,11 +135,31 @@
</span><span class="cx"> 
</span><span class="cx">     std::unique_ptr&lt;HTMLResourcePreloader&gt; m_preloader;
</span><span class="cx"> 
</span><del>-    bool m_endWasDelayed;
-    bool m_haveBackgroundParser;
-    unsigned m_pumpSessionNestingLevel;
</del><ins>+    bool m_endWasDelayed { false };
+    unsigned m_pumpSessionNestingLevel { 0 };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><ins>+inline HTMLTokenizer&amp; HTMLDocumentParser::tokenizer()
+{
+    return m_tokenizer;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+inline HTMLInputStream&amp; HTMLDocumentParser::inputStream()
+{
+    return m_input;
+}
+
+inline bool HTMLDocumentParser::hasPreloadScanner() const
+{
+    return m_preloadScanner.get();
+}
+
+inline HTMLTreeBuilder&amp; HTMLDocumentParser::treeBuilder()
+{
+    ASSERT(m_treeBuilder);
+    return *m_treeBuilder;
+}
+
+}
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLTreeBuildercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp (177882 => 177883)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp        2015-01-05 01:08:01 UTC (rev 177882)
+++ trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp        2015-01-05 02:24:31 UTC (rev 177883)
</span><span class="lines">@@ -252,7 +252,7 @@
</span><span class="cx">     return isParsingFragment() || isParsingTemplateContents();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-HTMLTreeBuilder::HTMLTreeBuilder(const HTMLDocumentParser&amp; parser, HTMLDocument&amp; document, ParserContentPolicy parserContentPolicy, const HTMLParserOptions&amp; options)
</del><ins>+HTMLTreeBuilder::HTMLTreeBuilder(HTMLDocumentParser&amp; parser, HTMLDocument&amp; document, ParserContentPolicy parserContentPolicy, const HTMLParserOptions&amp; options)
</ins><span class="cx">     : m_parser(parser)
</span><span class="cx">     , m_options(options)
</span><span class="cx">     , m_tree(document, parserContentPolicy, options.maximumDOMTreeDepth)
</span><span class="lines">@@ -263,7 +263,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-HTMLTreeBuilder::HTMLTreeBuilder(const HTMLDocumentParser&amp; parser, DocumentFragment&amp; fragment, Element&amp; contextElement, ParserContentPolicy parserContentPolicy, const HTMLParserOptions&amp; options)
</del><ins>+HTMLTreeBuilder::HTMLTreeBuilder(HTMLDocumentParser&amp; parser, DocumentFragment&amp; fragment, Element&amp; contextElement, ParserContentPolicy parserContentPolicy, const HTMLParserOptions&amp; options)
</ins><span class="cx">     : m_parser(parser)
</span><span class="cx">     , m_options(options)
</span><span class="cx">     , m_fragmentContext(fragment, contextElement)
</span><span class="lines">@@ -340,15 +340,13 @@
</span><span class="cx">     else
</span><span class="cx">         processToken(token);
</span><span class="cx"> 
</span><del>-    if (m_parser.tokenizer()) {
-        bool inForeignContent = !m_tree.isEmpty()
-            &amp;&amp; !adjustedCurrentStackItem().isInHTMLNamespace()
-            &amp;&amp; !HTMLElementStack::isHTMLIntegrationPoint(m_tree.currentStackItem())
-            &amp;&amp; !HTMLElementStack::isMathMLTextIntegrationPoint(m_tree.currentStackItem());
</del><ins>+    bool inForeignContent = !m_tree.isEmpty()
+        &amp;&amp; !adjustedCurrentStackItem().isInHTMLNamespace()
+        &amp;&amp; !HTMLElementStack::isHTMLIntegrationPoint(m_tree.currentStackItem())
+        &amp;&amp; !HTMLElementStack::isMathMLTextIntegrationPoint(m_tree.currentStackItem());
</ins><span class="cx"> 
</span><del>-        m_parser.tokenizer()-&gt;setForceNullCharacterReplacement(m_insertionMode == InsertionMode::Text || inForeignContent);
-        m_parser.tokenizer()-&gt;setShouldAllowCDATA(inForeignContent);
-    }
</del><ins>+    m_parser.tokenizer().setForceNullCharacterReplacement(m_insertionMode == InsertionMode::Text || inForeignContent);
+    m_parser.tokenizer().setShouldAllowCDATA(inForeignContent);
</ins><span class="cx"> 
</span><span class="cx"> #if !ASSERT_DISABLED
</span><span class="cx">     m_destructionProhibited = false;
</span><span class="lines">@@ -699,8 +697,7 @@
</span><span class="cx">     if (token.name() == plaintextTag) {
</span><span class="cx">         processFakePEndTagIfPInButtonScope();
</span><span class="cx">         m_tree.insertHTMLElement(&amp;token);
</span><del>-        if (m_parser.tokenizer())
-            m_parser.tokenizer()-&gt;setState(HTMLTokenizer::PLAINTEXTState);
</del><ins>+        m_parser.tokenizer().setState(HTMLTokenizer::PLAINTEXTState);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (token.name() == buttonTag) {
</span><span class="lines">@@ -806,8 +803,7 @@
</span><span class="cx">     if (token.name() == textareaTag) {
</span><span class="cx">         m_tree.insertHTMLElement(&amp;token);
</span><span class="cx">         m_shouldSkipLeadingNewline = true;
</span><del>-        if (m_parser.tokenizer())
-            m_parser.tokenizer()-&gt;setState(HTMLTokenizer::RCDATAState);
</del><ins>+        m_parser.tokenizer().setState(HTMLTokenizer::RCDATAState);
</ins><span class="cx">         m_originalInsertionMode = m_insertionMode;
</span><span class="cx">         m_framesetOk = false;
</span><span class="cx">         m_insertionMode = InsertionMode::Text;
</span><span class="lines">@@ -1991,11 +1987,10 @@
</span><span class="cx">     ASSERT(token.type() == HTMLToken::EndTag);
</span><span class="cx">     switch (m_insertionMode) {
</span><span class="cx">     case InsertionMode::Initial:
</span><del>-        ASSERT(m_insertionMode == InsertionMode::Initial);
</del><span class="cx">         defaultForInitial();
</span><ins>+        ASSERT(m_insertionMode == InsertionMode::BeforeHTML);
</ins><span class="cx">         FALLTHROUGH;
</span><span class="cx">     case InsertionMode::BeforeHTML:
</span><del>-        ASSERT(m_insertionMode == InsertionMode::BeforeHTML);
</del><span class="cx">         if (token.name() != headTag &amp;&amp; token.name() != bodyTag &amp;&amp; token.name() != htmlTag &amp;&amp; token.name() != brTag) {
</span><span class="cx">             parseError(token);
</span><span class="cx">             return;
</span><span class="lines">@@ -2143,14 +2138,12 @@
</span><span class="cx">             m_tree.openElements()-&gt;pop();
</span><span class="cx">             m_insertionMode = m_originalInsertionMode;
</span><span class="cx"> 
</span><del>-            if (m_parser.tokenizer()) {
-                // This token will not have been created by the tokenizer if a
-                // self-closing script tag was encountered and pre-HTML5 parser
-                // quirks are enabled. We must set the tokenizer's state to
-                // DataState explicitly if the tokenizer didn't have a chance to.
-                ASSERT(m_parser.tokenizer()-&gt;state() == HTMLTokenizer::DataState || m_options.usePreHTML5ParserQuirks);
-                m_parser.tokenizer()-&gt;setState(HTMLTokenizer::DataState);
-            }
</del><ins>+            // This token will not have been created by the tokenizer if a
+            // self-closing script tag was encountered and pre-HTML5 parser
+            // quirks are enabled. We must set the tokenizer's state to
+            // DataState explicitly if the tokenizer didn't have a chance to.
+            ASSERT(m_parser.tokenizer().state() == HTMLTokenizer::DataState || m_options.usePreHTML5ParserQuirks);
+            m_parser.tokenizer().setState(HTMLTokenizer::DataState);
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">         m_tree.openElements()-&gt;pop();
</span><span class="lines">@@ -2752,8 +2745,7 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(token.type() == HTMLToken::StartTag);
</span><span class="cx">     m_tree.insertHTMLElement(&amp;token);
</span><del>-    if (m_parser.tokenizer())
-        m_parser.tokenizer()-&gt;setState(HTMLTokenizer::RCDATAState);
</del><ins>+    m_parser.tokenizer().setState(HTMLTokenizer::RCDATAState);
</ins><span class="cx">     m_originalInsertionMode = m_insertionMode;
</span><span class="cx">     m_insertionMode = InsertionMode::Text;
</span><span class="cx"> }
</span><span class="lines">@@ -2762,8 +2754,7 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(token.type() == HTMLToken::StartTag);
</span><span class="cx">     m_tree.insertHTMLElement(&amp;token);
</span><del>-    if (m_parser.tokenizer())
-        m_parser.tokenizer()-&gt;setState(HTMLTokenizer::RAWTEXTState);
</del><ins>+    m_parser.tokenizer().setState(HTMLTokenizer::RAWTEXTState);
</ins><span class="cx">     m_originalInsertionMode = m_insertionMode;
</span><span class="cx">     m_insertionMode = InsertionMode::Text;
</span><span class="cx"> }
</span><span class="lines">@@ -2772,8 +2763,7 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(token.type() == HTMLToken::StartTag);
</span><span class="cx">     m_tree.insertScriptElement(&amp;token);
</span><del>-    if (m_parser.tokenizer())
-        m_parser.tokenizer()-&gt;setState(HTMLTokenizer::ScriptDataState);
</del><ins>+    m_parser.tokenizer().setState(HTMLTokenizer::ScriptDataState);
</ins><span class="cx">     m_originalInsertionMode = m_insertionMode;
</span><span class="cx"> 
</span><span class="cx">     TextPosition position = m_parser.textPosition();
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLTreeBuilderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h (177882 => 177883)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h        2015-01-05 01:08:01 UTC (rev 177882)
+++ trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h        2015-01-05 02:24:31 UTC (rev 177883)
</span><span class="lines">@@ -37,8 +37,8 @@
</span><span class="cx"> class HTMLTreeBuilder {
</span><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><del>-    HTMLTreeBuilder(const HTMLDocumentParser&amp;, HTMLDocument&amp;, ParserContentPolicy, const HTMLParserOptions&amp;);
-    HTMLTreeBuilder(const HTMLDocumentParser&amp;, DocumentFragment&amp;, Element&amp; contextElement, ParserContentPolicy, const HTMLParserOptions&amp;);
</del><ins>+    HTMLTreeBuilder(HTMLDocumentParser&amp;, HTMLDocument&amp;, ParserContentPolicy, const HTMLParserOptions&amp;);
+    HTMLTreeBuilder(HTMLDocumentParser&amp;, DocumentFragment&amp;, Element&amp; contextElement, ParserContentPolicy, const HTMLParserOptions&amp;);
</ins><span class="cx">     void setShouldSkipLeadingNewline(bool);
</span><span class="cx"> 
</span><span class="cx">     ~HTMLTreeBuilder();
</span><span class="lines">@@ -183,7 +183,7 @@
</span><span class="cx">         RefPtr&lt;HTMLStackItem&gt; m_contextElementStackItem;
</span><span class="cx">     };
</span><span class="cx"> 
</span><del>-    const HTMLDocumentParser&amp; m_parser;
</del><ins>+    HTMLDocumentParser&amp; m_parser;
</ins><span class="cx">     const HTMLParserOptions m_options;
</span><span class="cx">     const FragmentParsingContext m_fragmentContext;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserTextDocumentParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/TextDocumentParser.cpp (177882 => 177883)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/TextDocumentParser.cpp        2015-01-05 01:08:01 UTC (rev 177882)
+++ trunk/Source/WebCore/html/parser/TextDocumentParser.cpp        2015-01-05 02:24:31 UTC (rev 177883)
</span><span class="lines">@@ -25,7 +25,6 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;TextDocumentParser.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;HTMLDocument.h&quot;
</del><span class="cx"> #include &quot;HTMLTreeBuilder.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -34,14 +33,9 @@
</span><span class="cx"> 
</span><span class="cx"> TextDocumentParser::TextDocumentParser(HTMLDocument&amp; document)
</span><span class="cx">     : HTMLDocumentParser(document)
</span><del>-    , m_haveInsertedFakePreElement(false)
</del><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-TextDocumentParser::~TextDocumentParser()
-{
-}
-
</del><span class="cx"> void TextDocumentParser::append(PassRefPtr&lt;StringImpl&gt; text)
</span><span class="cx"> {
</span><span class="cx">     if (!m_haveInsertedFakePreElement)
</span><span class="lines">@@ -59,15 +53,15 @@
</span><span class="cx">     Vector&lt;Attribute&gt; attributes;
</span><span class="cx">     attributes.append(Attribute(styleAttr, &quot;word-wrap: break-word; white-space: pre-wrap;&quot;));
</span><span class="cx">     AtomicHTMLToken fakePre(HTMLToken::StartTag, preTag.localName(), attributes);
</span><del>-    treeBuilder()-&gt;constructTree(fakePre);
</del><ins>+    treeBuilder().constructTree(fakePre);
</ins><span class="cx"> 
</span><span class="cx">     // Normally we would skip the first \n after a &lt;pre&gt; element, but we don't
</span><span class="cx">     // want to skip the first \n for text documents!
</span><del>-    treeBuilder()-&gt;setShouldSkipLeadingNewline(false);
</del><ins>+    treeBuilder().setShouldSkipLeadingNewline(false);
</ins><span class="cx"> 
</span><span class="cx">     // Although Text Documents expose a &quot;pre&quot; element in their DOM, they
</span><span class="cx">     // act like a &lt;plaintext&gt; tag, so we have to force plaintext mode.
</span><del>-    forcePlaintextForTextDocument();
</del><ins>+    tokenizer().setState(HTMLTokenizer::PLAINTEXTState);
</ins><span class="cx"> 
</span><span class="cx">     m_haveInsertedFakePreElement = true;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserTextDocumentParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/TextDocumentParser.h (177882 => 177883)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/TextDocumentParser.h        2015-01-05 01:08:01 UTC (rev 177882)
+++ trunk/Source/WebCore/html/parser/TextDocumentParser.h        2015-01-05 02:24:31 UTC (rev 177883)
</span><span class="lines">@@ -22,7 +22,6 @@
</span><span class="cx">  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> #ifndef TextDocumentParser_h
</span><span class="cx"> #define TextDocumentParser_h
</span><span class="cx"> 
</span><span class="lines">@@ -36,15 +35,15 @@
</span><span class="cx">     {
</span><span class="cx">         return adoptRef(*new TextDocumentParser(document));
</span><span class="cx">     }
</span><del>-    virtual ~TextDocumentParser();
</del><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     explicit TextDocumentParser(HTMLDocument&amp;);
</span><span class="cx"> 
</span><span class="cx">     virtual void append(PassRefPtr&lt;StringImpl&gt;) override;
</span><ins>+
</ins><span class="cx">     void insertFakePreElement();
</span><span class="cx"> 
</span><del>-    bool m_haveInsertedFakePreElement;
</del><ins>+    bool m_haveInsertedFakePreElement { false };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>