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

Side by Side Diff: Source/core/html/parser/HTMLDocumentParser.cpp

Issue 20140002: Remove minimumLayoutDelay() and associated machinery (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: another fix Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 220 }
221 221
222 bool HTMLDocumentParser::isScheduledForResume() const 222 bool HTMLDocumentParser::isScheduledForResume() const
223 { 223 {
224 return m_parserScheduler && m_parserScheduler->isScheduledForResume(); 224 return m_parserScheduler && m_parserScheduler->isScheduledForResume();
225 } 225 }
226 226
227 // Used by HTMLParserScheduler 227 // Used by HTMLParserScheduler
228 void HTMLDocumentParser::resumeParsingAfterYield() 228 void HTMLDocumentParser::resumeParsingAfterYield()
229 { 229 {
230 ASSERT(!m_isPinnedToMainThread);
230 // pumpTokenizer can cause this parser to be detached from the Document, 231 // pumpTokenizer can cause this parser to be detached from the Document,
231 // but we need to ensure it isn't deleted yet. 232 // but we need to ensure it isn't deleted yet.
232 RefPtr<HTMLDocumentParser> protect(this); 233 RefPtr<HTMLDocumentParser> protect(this);
233 234
234 if (m_haveBackgroundParser) { 235 if (m_haveBackgroundParser) {
235 pumpPendingSpeculations(); 236 pumpPendingSpeculations();
236 return; 237 return;
237 } 238 }
238 239
239 // We should never be here unless we can pump immediately. Call pumpTokeniz er() 240 // We should never be here unless we can pump immediately. Call pumpTokeniz er()
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 385
385 ActiveParserSession session(contextForParsingSession()); 386 ActiveParserSession session(contextForParsingSession());
386 387
387 OwnPtr<ParsedChunk> chunk(popChunk); 388 OwnPtr<ParsedChunk> chunk(popChunk);
388 OwnPtr<CompactHTMLTokenStream> tokens = chunk->tokens.release(); 389 OwnPtr<CompactHTMLTokenStream> tokens = chunk->tokens.release();
389 390
390 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::startedChun kWithCheckpoint, m_backgroundParser, chunk->inputCheckpoint)); 391 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::startedChun kWithCheckpoint, m_backgroundParser, chunk->inputCheckpoint));
391 392
392 for (XSSInfoStream::const_iterator it = chunk->xssInfos.begin(); it != chunk ->xssInfos.end(); ++it) { 393 for (XSSInfoStream::const_iterator it = chunk->xssInfos.begin(); it != chunk ->xssInfos.end(); ++it) {
393 m_textPosition = (*it)->m_textPosition; 394 m_textPosition = (*it)->m_textPosition;
394 m_xssAuditorDelegate.didBlockScript(**it); 395 m_xssAuditorDelegate.didBlockScript(**it);
395 if (isStopped()) 396 if (isStopped())
396 break; 397 break;
397 } 398 }
398 399
399 for (Vector<CompactHTMLToken>::const_iterator it = tokens->begin(); it != to kens->end(); ++it) { 400 for (Vector<CompactHTMLToken>::const_iterator it = tokens->begin(); it != to kens->end(); ++it) {
400 ASSERT(!isWaitingForScripts()); 401 ASSERT(!isWaitingForScripts());
401 402
402 if (!isParsingFragment() 403 if (!isParsingFragment()
403 && document()->frame() && document()->frame()->navigationScheduler() ->locationChangePending()) { 404 && document()->frame() && document()->frame()->navigationScheduler() ->locationChangePending()) {
404 405
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 702
702 m_input.appendToEnd(source); 703 m_input.appendToEnd(source);
703 704
704 if (inPumpSession()) { 705 if (inPumpSession()) {
705 // We've gotten data off the network in a nested write. 706 // We've gotten data off the network in a nested write.
706 // We don't want to consume any more of the input stream now. Do 707 // We don't want to consume any more of the input stream now. Do
707 // not worry. We'll consume this data in a less-nested write(). 708 // not worry. We'll consume this data in a less-nested write().
708 return; 709 return;
709 } 710 }
710 711
711 pumpTokenizerIfPossible(AllowYield); 712 // A couple pinToMainThread() callers require synchronous parsing, but can't
713 // easily use the insert() method, so we hack append() for them to be synchr onous.
714 // javascript: url handling is one such caller.
715 // FIXME: This is gross, and we should separate the concept of synchronous p arsing
716 // from insert() so that only document.write() uses insert.
717 if (m_isPinnedToMainThread)
718 pumpTokenizerIfPossible(ForceSynchronous);
719 else
720 pumpTokenizerIfPossible(AllowYield);
712 721
713 endIfDelayed(); 722 endIfDelayed();
714 } 723 }
715 724
716 void HTMLDocumentParser::end() 725 void HTMLDocumentParser::end()
717 { 726 {
718 ASSERT(!isDetached()); 727 ASSERT(!isDetached());
719 ASSERT(!isScheduledForResume()); 728 ASSERT(!isScheduledForResume());
720 729
721 if (m_haveBackgroundParser) 730 if (m_haveBackgroundParser)
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 // addClient would call notifyFinished if the load were complete. 873 // addClient would call notifyFinished if the load were complete.
865 // Callers do not expect to be re-entered from this call, so they should 874 // Callers do not expect to be re-entered from this call, so they should
866 // not an already-loaded CachedResource. 875 // not an already-loaded CachedResource.
867 cachedScript->addClient(this); 876 cachedScript->addClient(this);
868 } 877 }
869 878
870 void HTMLDocumentParser::stopWatchingForLoad(CachedResource* cachedScript) 879 void HTMLDocumentParser::stopWatchingForLoad(CachedResource* cachedScript)
871 { 880 {
872 cachedScript->removeClient(this); 881 cachedScript->removeClient(this);
873 } 882 }
874 883
875 void HTMLDocumentParser::appendCurrentInputStreamToPreloadScannerAndScan() 884 void HTMLDocumentParser::appendCurrentInputStreamToPreloadScannerAndScan()
876 { 885 {
877 ASSERT(m_preloadScanner); 886 ASSERT(m_preloadScanner);
878 m_preloadScanner->appendToEnd(m_input.current()); 887 m_preloadScanner->appendToEnd(m_input.current());
879 m_preloadScanner->scan(m_preloader.get(), document()->baseElementURL()); 888 m_preloadScanner->scan(m_preloader.get(), document()->baseElementURL());
880 } 889 }
881 890
882 void HTMLDocumentParser::notifyFinished(CachedResource* cachedResource) 891 void HTMLDocumentParser::notifyFinished(CachedResource* cachedResource)
883 { 892 {
884 // pumpTokenizer can cause this parser to be detached from the Document, 893 // pumpTokenizer can cause this parser to be detached from the Document,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 } 926 }
918 927
919 void HTMLDocumentParser::parseDocumentFragment(const String& source, DocumentFra gment* fragment, Element* contextElement, ParserContentPolicy parserContentPolic y) 928 void HTMLDocumentParser::parseDocumentFragment(const String& source, DocumentFra gment* fragment, Element* contextElement, ParserContentPolicy parserContentPolic y)
920 { 929 {
921 RefPtr<HTMLDocumentParser> parser = HTMLDocumentParser::create(fragment, con textElement, parserContentPolicy); 930 RefPtr<HTMLDocumentParser> parser = HTMLDocumentParser::create(fragment, con textElement, parserContentPolicy);
922 parser->insert(source); // Use insert() so that the parser will not yield. 931 parser->insert(source); // Use insert() so that the parser will not yield.
923 parser->finish(); 932 parser->finish();
924 ASSERT(!parser->processingData()); // Make sure we're done. <rdar://problem/ 3963151> 933 ASSERT(!parser->processingData()); // Make sure we're done. <rdar://problem/ 3963151>
925 parser->detach(); // Allows ~DocumentParser to assert it was detached before destruction. 934 parser->detach(); // Allows ~DocumentParser to assert it was detached before destruction.
926 } 935 }
927 936
928 void HTMLDocumentParser::suspendScheduledTasks() 937 void HTMLDocumentParser::suspendScheduledTasks()
929 { 938 {
930 if (m_parserScheduler) 939 if (m_parserScheduler)
931 m_parserScheduler->suspend(); 940 m_parserScheduler->suspend();
932 } 941 }
933 942
934 void HTMLDocumentParser::resumeScheduledTasks() 943 void HTMLDocumentParser::resumeScheduledTasks()
935 { 944 {
936 if (m_parserScheduler) 945 if (m_parserScheduler)
937 m_parserScheduler->resume(); 946 m_parserScheduler->resume();
938 } 947 }
939 948
940 } 949 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698