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

Unified Diff: Source/core/loader/DocumentWriter.cpp

Issue 779393002: Turn DocumentParser::pinToMainThread into a cleaner api (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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: Source/core/loader/DocumentWriter.cpp
diff --git a/Source/core/loader/DocumentWriter.cpp b/Source/core/loader/DocumentWriter.cpp
index 41c48c18407230dac318b8d2cc9d4b603bdfbfce..97f88b5bd33ffd259ce0195f960479f489a4fcc2 100644
--- a/Source/core/loader/DocumentWriter.cpp
+++ b/Source/core/loader/DocumentWriter.cpp
@@ -44,20 +44,24 @@
namespace blink {
-PassRefPtrWillBeRawPtr<DocumentWriter> DocumentWriter::create(Document* document, const AtomicString& mimeType, const AtomicString& encoding)
+PassRefPtrWillBeRawPtr<DocumentWriter> DocumentWriter::create(Document* document, ParserSynchronizationPolicy parsingPolicy, const AtomicString& mimeType, const AtomicString& encoding)
{
- return adoptRefWillBeNoop(new DocumentWriter(document, mimeType, encoding));
+ return adoptRefWillBeNoop(new DocumentWriter(document, parsingPolicy, mimeType, encoding));
}
-DocumentWriter::DocumentWriter(Document* document, const AtomicString& mimeType, const AtomicString& encoding)
+DocumentWriter::DocumentWriter(Document* document, ParserSynchronizationPolicy parsingPolicy, const AtomicString& mimeType, const AtomicString& encoding)
: m_document(document)
, m_decoderBuilder(mimeType, encoding)
+ , m_forcedSynchronousParse(parsingPolicy == ForceSynchronousParsing)
+{
+ if (m_forcedSynchronousParse)
+ m_document->forceSynchronousParsing();
+
// We grab a reference to the parser so that we'll always send data to the
// original parser, even if the document acquires a new parser (e.g., via
// document.open).
- , m_parser(m_document->implicitOpen())
- , m_forcedSynchronousParse(false)
-{
+ m_parser = m_document->implicitOpen();
kbalazs 2014/12/05 23:37:57 moved out from initializer list because forceSyncP
+
if (m_document->frame()) {
if (FrameView* view = m_document->frame()->view())
view->setContentsSize(IntSize());
@@ -74,15 +78,6 @@ void DocumentWriter::trace(Visitor* visitor)
visitor->trace(m_parser);
}
-void DocumentWriter::forceSynchronousParse()
-{
- ASSERT(!m_forcedSynchronousParse);
-
- ASSERT(m_parser);
- m_parser->pinToMainThread();
- m_forcedSynchronousParse = true;
-}
-
void DocumentWriter::appendReplacingData(const String& source)
{
m_document->setCompatibilityMode(Document::NoQuirksMode);
@@ -90,10 +85,9 @@ void DocumentWriter::appendReplacingData(const String& source)
// FIXME: This should call DocumentParser::appendBytes instead of append
// to support RawDataDocumentParsers.
if (DocumentParser* parser = m_document->parser()) {
- if (!m_forcedSynchronousParse)
- forceSynchronousParse();
- // Because we're pinned to the main thread we don't need to worry about
+ // Because the parser is pinned to the main thread we don't need to worry about
// passing ownership of the source string.
+ ASSERT(m_forcedSynchronousParse);
parser->append(source.impl());
}
}
« Source/core/html/parser/HTMLDocumentParser.cpp ('K') | « Source/core/loader/DocumentWriter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698