 Chromium Code Reviews
 Chromium Code Reviews Issue 779393002:
  Turn DocumentParser::pinToMainThread into a cleaner api  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master
    
  
    Issue 779393002:
  Turn DocumentParser::pinToMainThread into a cleaner api  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master| Index: Source/core/dom/Document.cpp | 
| diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp | 
| index 63cb1e518c441db49e3ef02308e29485cf4d1bf2..449dab76957d721cd8d514cdc75ea4f188da85fa 100644 | 
| --- a/Source/core/dom/Document.cpp | 
| +++ b/Source/core/dom/Document.cpp | 
| @@ -508,6 +508,7 @@ Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC | 
| , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsTimerFired) | 
| , m_hasViewportUnits(false) | 
| , m_styleRecalcElementCounter(0) | 
| + , m_backgroundParsingPolicy(AllowAsynchronousParsing) | 
| { | 
| if (m_frame) { | 
| ASSERT(m_frame->page()); | 
| @@ -1233,11 +1234,6 @@ KURL Document::baseURI() const | 
| void Document::setContent(const String& content) | 
| { | 
| open(); | 
| - // FIXME: This should probably use insert(), but that's (intentionally) | 
| - // 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(); | 
| 
kbalazs
2014/12/05 23:37:57
Note that this called XMLDocumentParser::pinToMain
 | 
| m_parser->append(content.impl()); | 
| close(); | 
| } | 
| @@ -2288,7 +2284,7 @@ PassRefPtrWillBeRawPtr<DocumentParser> Document::createParser() | 
| { | 
| if (isHTMLDocument()) { | 
| bool reportErrors = InspectorInstrumentation::collectingHTMLParseErrors(page()); | 
| - return HTMLDocumentParser::create(toHTMLDocument(*this), reportErrors); | 
| + return HTMLDocumentParser::create(toHTMLDocument(*this), reportErrors, m_backgroundParsingPolicy); | 
| } | 
| // FIXME: this should probably pass the frame instead | 
| return XMLDocumentParser::create(*this, view()); | 
| @@ -2335,6 +2331,8 @@ void Document::open(Document* ownerDocument, ExceptionState& exceptionState) | 
| m_frame->loader().stopAllLoaders(); | 
| } | 
| + forceSynchronousParsing(); | 
| 
kbalazs
2014/12/05 23:37:57
This is in open() (not obvious from the context).
 | 
| + | 
| removeAllEventListenersRecursively(); | 
| implicitOpen(); | 
| if (ScriptableDocumentParser* parser = scriptableDocumentParser()) | 
| @@ -2346,6 +2344,12 @@ void Document::open(Document* ownerDocument, ExceptionState& exceptionState) | 
| m_loadEventProgress = LoadEventNotRun; | 
| } | 
| +void Document::forceSynchronousParsing() | 
| +{ | 
| + ASSERT(!m_parser); | 
| + m_backgroundParsingPolicy = ForceSynchronousParsing; | 
| +} | 
| + | 
| void Document::detachParser() | 
| { | 
| if (!m_parser) |