Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(570)

Unified Diff: sky/engine/core/html/parser/BackgroundHTMLParser.cpp

Issue 678533003: Remove HTMLTreeBuilderSimulator (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sky/engine/core/html/parser/BackgroundHTMLParser.cpp
diff --git a/sky/engine/core/html/parser/BackgroundHTMLParser.cpp b/sky/engine/core/html/parser/BackgroundHTMLParser.cpp
index 923245c89220096bc857eb2ad9afd60f9a492900..e4fda79db2ee3654b4fc724fa8ceae8fe7d06c53 100644
--- a/sky/engine/core/html/parser/BackgroundHTMLParser.cpp
+++ b/sky/engine/core/html/parser/BackgroundHTMLParser.cpp
@@ -27,6 +27,7 @@
#include "core/html/parser/BackgroundHTMLParser.h"
#include "core/html/parser/HTMLDocumentParser.h"
+#include "core/html/parser/HTMLParserIdioms.h"
#include "core/html/parser/TextResourceDecoder.h"
#include "wtf/MainThread.h"
#include "wtf/text/TextPosition.h"
@@ -58,7 +59,6 @@ base::WeakPtr<BackgroundHTMLParser> BackgroundHTMLParser::create(PassOwnPtr<Back
BackgroundHTMLParser::BackgroundHTMLParser(PassOwnPtr<Configuration> config)
: m_token(adoptPtr(new HTMLToken))
, m_tokenizer(HTMLTokenizer::create(config->options))
- , m_treeBuilderSimulator(config->options)
, m_options(config->options)
, m_parser(config->parser)
, m_pendingTokens(adoptPtr(new CompactHTMLTokenStream))
@@ -119,6 +119,28 @@ void BackgroundHTMLParser::markEndOfFile()
m_input.close();
}
+bool BackgroundHTMLParser::updateTokenizerState(const CompactHTMLToken& token)
+{
+ if (token.type() == HTMLToken::StartTag) {
+ const String& tagName = token.data();
+ // FIXME: This is just a copy of Tokenizer::updateStateFor which uses threadSafeMatches.
+ if (threadSafeMatch(tagName, HTMLNames::scriptTag))
+ m_tokenizer->setState(HTMLTokenizer::ScriptDataState);
+ else if (threadSafeMatch(tagName, HTMLNames::styleTag))
+ m_tokenizer->setState(HTMLTokenizer::RAWTEXTState);
+ }
+
+ if (token.type() == HTMLToken::EndTag) {
+ const String& tagName = token.data();
+ if (threadSafeMatch(tagName, HTMLNames::scriptTag)) {
+ m_tokenizer->setState(HTMLTokenizer::DataState);
+ return false;
+ }
+ }
+
+ return true;
+}
+
void BackgroundHTMLParser::pumpTokenizer()
{
while (true) {
@@ -135,7 +157,7 @@ void BackgroundHTMLParser::pumpTokenizer()
m_token->clear();
- if (!m_treeBuilderSimulator.simulate(m_pendingTokens->last(), m_tokenizer.get()) || m_pendingTokens->size() >= pendingTokenLimit)
+ if (!updateTokenizerState(m_pendingTokens->last()) || m_pendingTokens->size() >= pendingTokenLimit)
sendTokensToMainThread();
}
}
« no previous file with comments | « sky/engine/core/html/parser/BackgroundHTMLParser.h ('k') | sky/engine/core/html/parser/HTMLDocumentParser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698