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

Side by Side Diff: Source/core/dom/Document.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 unified diff | Download patch
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/DocumentParser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 , m_writeRecursionIsTooDeep(false) 501 , m_writeRecursionIsTooDeep(false)
502 , m_writeRecursionDepth(0) 502 , m_writeRecursionDepth(0)
503 , m_taskRunner(MainThreadTaskRunner::create(this)) 503 , m_taskRunner(MainThreadTaskRunner::create(this))
504 , m_registrationContext(initializer.registrationContext(this)) 504 , m_registrationContext(initializer.registrationContext(this))
505 , m_elementDataCacheClearTimer(this, &Document::elementDataCacheClearTimerFi red) 505 , m_elementDataCacheClearTimer(this, &Document::elementDataCacheClearTimerFi red)
506 , m_timeline(AnimationTimeline::create(this)) 506 , m_timeline(AnimationTimeline::create(this))
507 , m_templateDocumentHost(nullptr) 507 , m_templateDocumentHost(nullptr)
508 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT imerFired) 508 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT imerFired)
509 , m_hasViewportUnits(false) 509 , m_hasViewportUnits(false)
510 , m_styleRecalcElementCounter(0) 510 , m_styleRecalcElementCounter(0)
511 , m_parserSyncPolicy(AllowAsynchronousParsing)
511 { 512 {
512 if (m_frame) { 513 if (m_frame) {
513 ASSERT(m_frame->page()); 514 ASSERT(m_frame->page());
514 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); 515 provideContextFeaturesToDocumentFrom(*this, *m_frame->page());
515 516
516 m_fetcher = m_frame->loader().documentLoader()->fetcher(); 517 m_fetcher = m_frame->loader().documentLoader()->fetcher();
517 } 518 }
518 519
519 if (!m_fetcher) 520 if (!m_fetcher)
520 m_fetcher = ResourceFetcher::create(0); 521 m_fetcher = ResourceFetcher::create(0);
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 } 1227 }
1227 1228
1228 KURL Document::baseURI() const 1229 KURL Document::baseURI() const
1229 { 1230 {
1230 return m_baseURL; 1231 return m_baseURL;
1231 } 1232 }
1232 1233
1233 void Document::setContent(const String& content) 1234 void Document::setContent(const String& content)
1234 { 1235 {
1235 open(); 1236 open();
1236 // FIXME: This should probably use insert(), but that's (intentionally)
1237 // not implemented for the XML parser as it's normally synonymous with
1238 // document.write(). append() will end up yielding, but close() will
1239 // pump the tokenizer syncrhonously and finish the parse.
1240 m_parser->pinToMainThread();
1241 m_parser->append(content.impl()); 1237 m_parser->append(content.impl());
1242 close(); 1238 close();
1243 } 1239 }
1244 1240
1245 String Document::suggestedMIMEType() const 1241 String Document::suggestedMIMEType() const
1246 { 1242 {
1247 if (isXMLDocument()) { 1243 if (isXMLDocument()) {
1248 if (isXHTMLDocument()) 1244 if (isXHTMLDocument())
1249 return "application/xhtml+xml"; 1245 return "application/xhtml+xml";
1250 if (isSVGDocument()) 1246 if (isSVGDocument())
(...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after
2287 ASSERT(&cacheOwner == this || !m_axObjectCache); 2283 ASSERT(&cacheOwner == this || !m_axObjectCache);
2288 if (!cacheOwner.m_axObjectCache) 2284 if (!cacheOwner.m_axObjectCache)
2289 cacheOwner.m_axObjectCache = adoptPtr(AXObjectCache::create(cacheOwner)) ; 2285 cacheOwner.m_axObjectCache = adoptPtr(AXObjectCache::create(cacheOwner)) ;
2290 return cacheOwner.m_axObjectCache.get(); 2286 return cacheOwner.m_axObjectCache.get();
2291 } 2287 }
2292 2288
2293 PassRefPtrWillBeRawPtr<DocumentParser> Document::createParser() 2289 PassRefPtrWillBeRawPtr<DocumentParser> Document::createParser()
2294 { 2290 {
2295 if (isHTMLDocument()) { 2291 if (isHTMLDocument()) {
2296 bool reportErrors = InspectorInstrumentation::collectingHTMLParseErrors( page()); 2292 bool reportErrors = InspectorInstrumentation::collectingHTMLParseErrors( page());
2297 return HTMLDocumentParser::create(toHTMLDocument(*this), reportErrors); 2293 return HTMLDocumentParser::create(toHTMLDocument(*this), reportErrors, m _parserSyncPolicy);
2298 } 2294 }
2299 // FIXME: this should probably pass the frame instead 2295 // FIXME: this should probably pass the frame instead
2300 return XMLDocumentParser::create(*this, view()); 2296 return XMLDocumentParser::create(*this, view());
2301 } 2297 }
2302 2298
2303 bool Document::isFrameSet() const 2299 bool Document::isFrameSet() const
2304 { 2300 {
2305 if (!isHTMLDocument()) 2301 if (!isHTMLDocument())
2306 return false; 2302 return false;
2307 return isHTMLFrameSetElement(body()); 2303 return isHTMLFrameSetElement(body());
(...skipping 27 matching lines...) Expand all
2335 if (!parser->wasCreatedByScript() && parser->hasInsertionPoint() ) 2331 if (!parser->wasCreatedByScript() && parser->hasInsertionPoint() )
2336 return; 2332 return;
2337 } 2333 }
2338 } 2334 }
2339 2335
2340 if (m_frame->loader().state() == FrameStateProvisional) 2336 if (m_frame->loader().state() == FrameStateProvisional)
2341 m_frame->loader().stopAllLoaders(); 2337 m_frame->loader().stopAllLoaders();
2342 } 2338 }
2343 2339
2344 removeAllEventListenersRecursively(); 2340 removeAllEventListenersRecursively();
2345 implicitOpen(); 2341 implicitOpen(ForceSynchronousParsing);
2346 if (ScriptableDocumentParser* parser = scriptableDocumentParser()) 2342 if (ScriptableDocumentParser* parser = scriptableDocumentParser())
2347 parser->setWasCreatedByScript(true); 2343 parser->setWasCreatedByScript(true);
2348 2344
2349 if (m_frame) 2345 if (m_frame)
2350 m_frame->loader().didExplicitOpen(); 2346 m_frame->loader().didExplicitOpen();
2351 if (m_loadEventProgress != LoadEventInProgress && m_loadEventProgress != Unl oadEventInProgress) 2347 if (m_loadEventProgress != LoadEventInProgress && m_loadEventProgress != Unl oadEventInProgress)
2352 m_loadEventProgress = LoadEventNotRun; 2348 m_loadEventProgress = LoadEventNotRun;
2353 } 2349 }
2354 2350
2355 void Document::detachParser() 2351 void Document::detachParser()
(...skipping 10 matching lines...) Expand all
2366 return; 2362 return;
2367 2363
2368 // We have to clear the parser to avoid possibly triggering 2364 // We have to clear the parser to avoid possibly triggering
2369 // the onload handler when closing as a side effect of a cancel-style 2365 // the onload handler when closing as a side effect of a cancel-style
2370 // change, such as opening a new document or closing the window while 2366 // change, such as opening a new document or closing the window while
2371 // still parsing. 2367 // still parsing.
2372 detachParser(); 2368 detachParser();
2373 explicitClose(); 2369 explicitClose();
2374 } 2370 }
2375 2371
2376 PassRefPtrWillBeRawPtr<DocumentParser> Document::implicitOpen() 2372 PassRefPtrWillBeRawPtr<DocumentParser> Document::implicitOpen(ParserSynchronizat ionPolicy parserSyncPolicy)
2377 { 2373 {
2378 cancelParsing(); 2374 cancelParsing();
2379 2375
2380 removeChildren(); 2376 removeChildren();
2381 ASSERT(!m_focusedElement); 2377 ASSERT(!m_focusedElement);
2382 2378
2383 setCompatibilityMode(NoQuirksMode); 2379 setCompatibilityMode(NoQuirksMode);
2384 2380
2381 m_parserSyncPolicy = parserSyncPolicy;
2385 m_parser = createParser(); 2382 m_parser = createParser();
2386 setParsingState(Parsing); 2383 setParsingState(Parsing);
2387 setReadyState(Loading); 2384 setReadyState(Loading);
2388 2385
2389 return m_parser; 2386 return m_parser;
2390 } 2387 }
2391 2388
2392 HTMLElement* Document::body() const 2389 HTMLElement* Document::body() const
2393 { 2390 {
2394 if (!documentElement()) 2391 if (!documentElement())
(...skipping 3452 matching lines...) Expand 10 before | Expand all | Expand 10 after
5847 #ifndef NDEBUG 5844 #ifndef NDEBUG
5848 using namespace blink; 5845 using namespace blink;
5849 void showLiveDocumentInstances() 5846 void showLiveDocumentInstances()
5850 { 5847 {
5851 WeakDocumentSet& set = liveDocumentSet(); 5848 WeakDocumentSet& set = liveDocumentSet();
5852 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5849 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5853 for (Document* document : set) 5850 for (Document* document : set)
5854 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); 5851 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data());
5855 } 5852 }
5856 #endif 5853 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/DocumentParser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698