Diff
Modified: trunk/Source/WebCore/ChangeLog (141069 => 141070)
--- trunk/Source/WebCore/ChangeLog 2013-01-29 08:01:03 UTC (rev 141069)
+++ trunk/Source/WebCore/ChangeLog 2013-01-29 08:01:37 UTC (rev 141070)
@@ -1,3 +1,29 @@
+2013-01-28 Adam Barth <[email protected]>
+
+ HTMLDocumentParser should hold the HTMLToken using an OwnPtr
+ https://bugs.webkit.org/show_bug.cgi?id=107762
+
+ Reviewed by Eric Seidel.
+
+ Using an OwnPtr will let us detach the HTMLToken from the
+ HTMLDocumentParser and send it to the BackgroundHTMLParser for further
+ processing.
+
+ * html/parser/BackgroundHTMLParser.cpp:
+ (WebCore::BackgroundHTMLParser::BackgroundHTMLParser):
+ (WebCore::BackgroundHTMLParser::pumpTokenizer):
+ * html/parser/BackgroundHTMLParser.h:
+ (BackgroundHTMLParser):
+ * html/parser/CompactHTMLToken.cpp:
+ (WebCore::CompactHTMLToken::CompactHTMLToken):
+ * html/parser/CompactHTMLToken.h:
+ (CompactHTMLToken):
+ * html/parser/HTMLDocumentParser.cpp:
+ (WebCore::HTMLDocumentParser::HTMLDocumentParser):
+ (WebCore::HTMLDocumentParser::pumpTokenizer):
+ * html/parser/HTMLDocumentParser.h:
+ (HTMLDocumentParser):
+
2013-01-28 Huang Dongsung <[email protected]>
[Texmap] Refactor code related to debug border and repaint count.
Modified: trunk/Source/WebCore/html/parser/BackgroundHTMLParser.cpp (141069 => 141070)
--- trunk/Source/WebCore/html/parser/BackgroundHTMLParser.cpp 2013-01-29 08:01:03 UTC (rev 141069)
+++ trunk/Source/WebCore/html/parser/BackgroundHTMLParser.cpp 2013-01-29 08:01:37 UTC (rev 141070)
@@ -84,6 +84,7 @@
BackgroundHTMLParser::BackgroundHTMLParser(const HTMLParserOptions& options, const WeakPtr<HTMLDocumentParser>& parser)
: m_inForeignContent(false)
+ , m_token(adoptPtr(new HTMLToken))
, m_tokenizer(HTMLTokenizer::create(options))
, m_options(options)
, m_parser(parser)
@@ -153,9 +154,9 @@
void BackgroundHTMLParser::pumpTokenizer()
{
- while (m_tokenizer->nextToken(m_input, m_token)) {
- m_pendingTokens->append(CompactHTMLToken(m_token, TextPosition(m_input.currentLine(), m_input.currentColumn())));
- m_token.clear();
+ while (m_tokenizer->nextToken(m_input, *m_token.get())) {
+ m_pendingTokens->append(CompactHTMLToken(m_token.get(), TextPosition(m_input.currentLine(), m_input.currentColumn())));
+ m_token->clear();
if (!simulateTreeBuilder(m_pendingTokens->last()) || m_pendingTokens->size() >= pendingTokenLimit)
sendTokensToMainThread();
Modified: trunk/Source/WebCore/html/parser/BackgroundHTMLParser.h (141069 => 141070)
--- trunk/Source/WebCore/html/parser/BackgroundHTMLParser.h 2013-01-29 08:01:03 UTC (rev 141069)
+++ trunk/Source/WebCore/html/parser/BackgroundHTMLParser.h 2013-01-29 08:01:37 UTC (rev 141070)
@@ -64,9 +64,9 @@
void sendTokensToMainThread();
+ bool m_inForeignContent; // FIXME: We need a stack of foreign content markers.
SegmentedString m_input;
- HTMLToken m_token;
- bool m_inForeignContent; // FIXME: We need a stack of foreign content markers.
+ OwnPtr<HTMLToken> m_token;
OwnPtr<HTMLTokenizer> m_tokenizer;
HTMLParserOptions m_options;
WeakPtr<HTMLDocumentParser> m_parser;
Modified: trunk/Source/WebCore/html/parser/CompactHTMLToken.cpp (141069 => 141070)
--- trunk/Source/WebCore/html/parser/CompactHTMLToken.cpp 2013-01-29 08:01:03 UTC (rev 141069)
+++ trunk/Source/WebCore/html/parser/CompactHTMLToken.cpp 2013-01-29 08:01:37 UTC (rev 141070)
@@ -42,8 +42,8 @@
COMPILE_ASSERT(sizeof(CompactHTMLToken) == sizeof(SameSizeAsCompactHTMLToken), CompactHTMLToken_should_stay_small);
-CompactHTMLToken::CompactHTMLToken(const HTMLToken& token, const TextPosition& textPosition)
- : m_type(token.type())
+CompactHTMLToken::CompactHTMLToken(const HTMLToken* token, const TextPosition& textPosition)
+ : m_type(token->type())
, m_isAll8BitData(false)
, m_doctypeForcesQuirks(false)
, m_textPosition(textPosition)
@@ -53,32 +53,32 @@
ASSERT_NOT_REACHED();
break;
case HTMLTokenTypes::DOCTYPE: {
- m_data = String(token.name().data(), token.name().size());
+ m_data = String(token->name().data(), token->name().size());
// There is only 1 DOCTYPE token per document, so to avoid increasing the
// size of CompactHTMLToken, we just use the m_attributes vector.
- String publicIdentifier(token.publicIdentifier().data(), token.publicIdentifier().size());
- String systemIdentifier(token.systemIdentifier().data(), token.systemIdentifier().size());
+ String publicIdentifier(token->publicIdentifier().data(), token->publicIdentifier().size());
+ String systemIdentifier(token->systemIdentifier().data(), token->systemIdentifier().size());
m_attributes.append(CompactAttribute(publicIdentifier, systemIdentifier));
- m_doctypeForcesQuirks = token.forceQuirks();
+ m_doctypeForcesQuirks = token->forceQuirks();
break;
}
case HTMLTokenTypes::EndOfFile:
break;
case HTMLTokenTypes::StartTag:
- m_attributes.reserveInitialCapacity(token.attributes().size());
- for (Vector<AttributeBase>::const_iterator it = token.attributes().begin(); it != token.attributes().end(); ++it)
+ m_attributes.reserveInitialCapacity(token->attributes().size());
+ for (Vector<AttributeBase>::const_iterator it = token->attributes().begin(); it != token->attributes().end(); ++it)
m_attributes.append(CompactAttribute(String(it->m_name.data(), it->m_name.size()), String(it->m_value.data(), it->m_value.size())));
// Fall through!
case HTMLTokenTypes::EndTag:
- m_selfClosing = token.selfClosing();
+ m_selfClosing = token->selfClosing();
// Fall through!
case HTMLTokenTypes::Comment:
case HTMLTokenTypes::Character:
- if (token.isAll8BitData()) {
- m_data = String::make8BitFrom16BitSource(token.data().data(), token.data().size());
+ if (token->isAll8BitData()) {
+ m_data = String::make8BitFrom16BitSource(token->data().data(), token->data().size());
m_isAll8BitData = true;
} else
- m_data = String(token.data().data(), token.data().size());
+ m_data = String(token->data().data(), token->data().size());
break;
default:
ASSERT_NOT_REACHED();
Modified: trunk/Source/WebCore/html/parser/CompactHTMLToken.h (141069 => 141070)
--- trunk/Source/WebCore/html/parser/CompactHTMLToken.h 2013-01-29 08:01:03 UTC (rev 141069)
+++ trunk/Source/WebCore/html/parser/CompactHTMLToken.h 2013-01-29 08:01:37 UTC (rev 141070)
@@ -57,7 +57,7 @@
class CompactHTMLToken {
public:
- explicit CompactHTMLToken(const HTMLToken&, const TextPosition&);
+ CompactHTMLToken(const HTMLToken*, const TextPosition&);
bool isSafeToSendToAnotherThread() const;
Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp (141069 => 141070)
--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp 2013-01-29 08:01:03 UTC (rev 141069)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp 2013-01-29 08:01:37 UTC (rev 141070)
@@ -77,6 +77,7 @@
HTMLDocumentParser::HTMLDocumentParser(HTMLDocument* document, bool reportErrors)
: ScriptableDocumentParser(document)
, m_options(document)
+ , m_token(adoptPtr(new HTMLToken))
, m_tokenizer(HTMLTokenizer::create(m_options))
, m_scriptRunner(HTMLScriptRunner::create(document, this))
, m_treeBuilder(HTMLTreeBuilder::create(this, document, reportErrors, m_options))
@@ -96,6 +97,7 @@
HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* contextElement, FragmentScriptingPermission scriptingPermission)
: ScriptableDocumentParser(fragment->document())
, m_options(fragment->document())
+ , m_token(adoptPtr(new HTMLToken))
, m_tokenizer(HTMLTokenizer::create(m_options))
, m_treeBuilder(HTMLTreeBuilder::create(this, fragment, contextElement, scriptingPermission, m_options))
, m_xssAuditor(this)
@@ -345,20 +347,20 @@
while (canTakeNextToken(mode, session) && !session.needsYield) {
if (!isParsingFragment())
- m_sourceTracker.start(m_input, m_tokenizer.get(), m_token);
+ m_sourceTracker.start(m_input, m_tokenizer.get(), token());
- if (!m_tokenizer->nextToken(m_input.current(), m_token))
+ if (!m_tokenizer->nextToken(m_input.current(), token()))
break;
if (!isParsingFragment()) {
- m_sourceTracker.end(m_input, m_tokenizer.get(), m_token);
+ m_sourceTracker.end(m_input, m_tokenizer.get(), token());
// We do not XSS filter innerHTML, which means we (intentionally) fail
// http/tests/security/xssAuditor/dom-write-innerHTML.html
- m_xssAuditor.filterToken(m_token);
+ m_xssAuditor.filterToken(token());
}
- constructTreeFromHTMLToken(m_token);
+ constructTreeFromHTMLToken(token());
ASSERT(m_token.isUninitialized());
}
Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.h (141069 => 141070)
--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.h 2013-01-29 08:01:03 UTC (rev 141069)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.h 2013-01-29 08:01:37 UTC (rev 141070)
@@ -154,12 +154,12 @@
bool inPumpSession() const { return m_pumpSessionNestingLevel > 0; }
bool shouldDelayEnd() const { return inPumpSession() || isWaitingForScripts() || isScheduledForResume() || isExecutingScript(); }
+ HTMLToken& token() { return *m_token.get(); }
+
HTMLParserOptions m_options;
HTMLInputStream m_input;
- // We hold m_token here because it might be partially complete.
- HTMLToken m_token;
-
+ OwnPtr<HTMLToken> m_token;
OwnPtr<HTMLTokenizer> m_tokenizer;
OwnPtr<HTMLScriptRunner> m_scriptRunner;
OwnPtr<HTMLTreeBuilder> m_treeBuilder;