Remove DocumentParser::pinToMainThread() and related code
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 18 Jan 2014 17:11:46 +0000 (17:11 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 18 Jan 2014 17:11:46 +0000 (17:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=127221

Reviewed by Andreas Kling.

* dom/Document.cpp:
(WebCore::Document::setContent):
* dom/DocumentParser.h:
* html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::HTMLDocumentParser):
* html/parser/HTMLDocumentParser.h:
* html/parser/HTMLParserOptions.cpp:
(WebCore::HTMLParserOptions::HTMLParserOptions):
* html/parser/HTMLParserOptions.h:
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::processEndTag):
* loader/DocumentWriter.cpp:
(WebCore::DocumentWriter::replaceDocument):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@162254 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/DocumentParser.h
Source/WebCore/html/parser/HTMLDocumentParser.cpp
Source/WebCore/html/parser/HTMLDocumentParser.h
Source/WebCore/html/parser/HTMLParserOptions.cpp
Source/WebCore/html/parser/HTMLParserOptions.h
Source/WebCore/html/parser/HTMLTreeBuilder.cpp
Source/WebCore/loader/DocumentWriter.cpp

index 10507f2..0d240b4 100644 (file)
@@ -1,5 +1,26 @@
 2014-01-18  Anders Carlsson  <andersca@apple.com>
 
+        Remove DocumentParser::pinToMainThread() and related code
+        https://bugs.webkit.org/show_bug.cgi?id=127221
+
+        Reviewed by Andreas Kling.
+
+        * dom/Document.cpp:
+        (WebCore::Document::setContent):
+        * dom/DocumentParser.h:
+        * html/parser/HTMLDocumentParser.cpp:
+        (WebCore::HTMLDocumentParser::HTMLDocumentParser):
+        * html/parser/HTMLDocumentParser.h:
+        * html/parser/HTMLParserOptions.cpp:
+        (WebCore::HTMLParserOptions::HTMLParserOptions):
+        * html/parser/HTMLParserOptions.h:
+        * html/parser/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::processEndTag):
+        * loader/DocumentWriter.cpp:
+        (WebCore::DocumentWriter::replaceDocument):
+
+2014-01-18  Anders Carlsson  <andersca@apple.com>
+
         Remove HTMLParserThread
         https://bugs.webkit.org/show_bug.cgi?id=127220
 
index 335080a..2517e04 100644 (file)
@@ -1350,7 +1350,6 @@ void Document::setContent(const String& content)
     // not implemented for the XML parser as it's normally synonymous with
     // document.write(). append() will end up yielding, but close() will
     // pump the tokenizer syncrhonously and finish the parse.
-    m_parser->pinToMainThread();
     m_parser->append(content.impl());
     close();
 }
index 0b064a5..7b2f017 100644 (file)
@@ -50,8 +50,6 @@ public:
     virtual void appendBytes(DocumentWriter&, const char* bytes, size_t length) = 0;
     virtual void flush(DocumentWriter&) = 0;
 
-    virtual void pinToMainThread() { }
-
     // FIXME: append() should be private, but DocumentWriter::replaceDocument uses it for now.
     // FIXME: This really should take a PassOwnPtr to signify that it expects to take
     // ownership of the buffer. The parser expects the PassRefPtr to hold the only ref of the StringImpl.
index e594ae7..b652552 100644 (file)
@@ -70,8 +70,8 @@ static HTMLTokenizer::State tokenizerStateForContextElement(Element* contextElem
 HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document)
     : ScriptableDocumentParser(document)
     , m_options(document)
-    , m_token(m_options.useThreading ? nullptr : adoptPtr(new HTMLToken))
-    , m_tokenizer(m_options.useThreading ? nullptr : HTMLTokenizer::create(m_options))
+    , m_token(adoptPtr(new HTMLToken))
+    , m_tokenizer(HTMLTokenizer::create(m_options))
     , m_scriptRunner(HTMLScriptRunner::create(document, *this))
     , m_treeBuilder(HTMLTreeBuilder::create(*this, document, parserContentPolicy(), m_options))
     , m_parserScheduler(HTMLParserScheduler::create(*this))
@@ -80,12 +80,12 @@ HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document)
     , m_weakFactory(this)
 #endif
     , m_preloader(adoptPtr(new HTMLResourcePreloader(document)))
-    , m_isPinnedToMainThread(false)
     , m_endWasDelayed(false)
     , m_haveBackgroundParser(false)
     , m_pumpSessionNestingLevel(0)
 {
-    ASSERT(shouldUseThreading() || (m_token && m_tokenizer));
+    ASSERT(m_token);
+    ASSERT(m_tokenizer);
 }
 
 // FIXME: Member variables should be grouped into self-initializing structs to
@@ -100,12 +100,10 @@ HTMLDocumentParser::HTMLDocumentParser(DocumentFragment& fragment, Element* cont
 #if ENABLE(THREADED_HTML_PARSER)
     , m_weakFactory(this)
 #endif
-    , m_isPinnedToMainThread(true)
     , m_endWasDelayed(false)
     , m_haveBackgroundParser(false)
     , m_pumpSessionNestingLevel(0)
 {
-    ASSERT(!shouldUseThreading());
     bool reportErrors = false; // For now document fragment parsing never reports errors.
     m_tokenizer->setState(tokenizerStateForContextElement(contextElement, reportErrors, m_options));
     m_xssAuditor.initForFragment();
@@ -120,20 +118,6 @@ HTMLDocumentParser::~HTMLDocumentParser()
     ASSERT(!m_haveBackgroundParser);
 }
 
-#if ENABLE(THREADED_HTML_PARSER)
-void HTMLDocumentParser::pinToMainThread()
-{
-    ASSERT(!m_haveBackgroundParser);
-    ASSERT(!m_isPinnedToMainThread);
-    m_isPinnedToMainThread = true;
-    if (!m_tokenizer) {
-        ASSERT(!m_token);
-        m_token = adoptPtr(new HTMLToken);
-        m_tokenizer = HTMLTokenizer::create(m_options);
-    }
-}
-#endif
-
 void HTMLDocumentParser::detach()
 {
 #if ENABLE(THREADED_HTML_PARSER)
index a65e0c8..27e9461 100644 (file)
@@ -113,9 +113,6 @@ private:
     }
 
     // DocumentParser
-#if ENABLE(THREADED_HTML_PARSER)
-    virtual void pinToMainThread() override;
-#endif
     virtual void detach() override;
     virtual bool hasInsertionPoint() override;
     virtual bool processingData() const override;
@@ -129,7 +126,7 @@ private:
     virtual void watchForLoad(CachedResource*) override;
     virtual void stopWatchingForLoad(CachedResource*) override;
     virtual HTMLInputStream& inputStream() override { return m_input; }
-    virtual bool hasPreloadScanner() const override { return m_preloadScanner.get() && !shouldUseThreading(); }
+    virtual bool hasPreloadScanner() const override { return m_preloadScanner.get(); }
     virtual void appendCurrentInputStreamToPreloadScannerAndScan() override;
 
     // CachedResourceClient
@@ -166,8 +163,6 @@ private:
     void attemptToRunDeferredScriptsAndEnd();
     void end();
 
-    bool shouldUseThreading() const { return m_options.useThreading && !m_isPinnedToMainThread; }
-
     bool isParsingFragment() const;
     bool isScheduledForResume() const;
     bool inPumpSession() const { return m_pumpSessionNestingLevel > 0; }
@@ -200,7 +195,6 @@ private:
 #endif
     OwnPtr<HTMLResourcePreloader> m_preloader;
 
-    bool m_isPinnedToMainThread;
     bool m_endWasDelayed;
     bool m_haveBackgroundParser;
     unsigned m_pumpSessionNestingLevel;
index b8cf54b..000d4b0 100644 (file)
@@ -39,7 +39,6 @@ HTMLParserOptions::HTMLParserOptions()
     : scriptEnabled(false)
     , pluginsEnabled(false)
     , usePreHTML5ParserQuirks(false)
-    , useThreading(false)
     , maximumDOMTreeDepth(Settings::defaultMaximumHTMLParserDOMTreeDepth)
 {
 }
@@ -52,14 +51,6 @@ HTMLParserOptions::HTMLParserOptions(Document& document)
 
     Settings* settings = document.settings();
     usePreHTML5ParserQuirks = settings && settings->usePreHTML5ParserQuirks();
-#if ENABLE(THREADED_HTML_PARSER)
-    // We force the main-thread parser for about:blank, javascript: and data: urls for compatibility
-    // with historical synchronous loading/parsing behavior of those schemes.
-    useThreading = settings && settings->threadedHTMLParser() && !document->url().isBlankURL()
-        && (settings->useThreadedHTMLParserForDataURLs() || !document->url().protocolIsData());
-#else
-    useThreading = false;
-#endif
     maximumDOMTreeDepth = settings ? settings->maximumHTMLParserDOMTreeDepth() : Settings::defaultMaximumHTMLParserDOMTreeDepth;
 }
 
index 8898c2d..1d79c2b 100644 (file)
@@ -38,7 +38,6 @@ public:
     bool scriptEnabled;
     bool pluginsEnabled;
     bool usePreHTML5ParserQuirks;
-    bool useThreading;
     unsigned maximumDOMTreeDepth;
 };
 
index 1a1a0aa..34653e7 100644 (file)
@@ -2212,7 +2212,7 @@ void HTMLTreeBuilder::processEndTag(AtomicHTMLToken* token)
                 // 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_options.useThreading);
+                ASSERT(m_parser.tokenizer()->state() == HTMLTokenizer::DataState || m_options.usePreHTML5ParserQuirks);
                 m_parser.tokenizer()->setState(HTMLTokenizer::DataState);
             }
             return;
index 30bfe05..742eb99 100644 (file)
@@ -82,12 +82,8 @@ void DocumentWriter::replaceDocument(const String& source, Document* ownerDocume
 
         // FIXME: This should call DocumentParser::appendBytes instead of append
         // to support RawDataDocumentParsers.
-        if (DocumentParser* parser = m_frame->document()->parser()) {
-            parser->pinToMainThread();
-            // Because we're pinned to the main thread we don't need to worry about
-            // passing ownership of the source string.
+        if (DocumentParser* parser = m_frame->document()->parser())
             parser->append(source.impl());
-        }
     }
 
     end();