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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 || (contextTag.matches(noscriptTag) && options.scriptEnabled) 78 || (contextTag.matches(noscriptTag) && options.scriptEnabled)
79 || contextTag.matches(noframesTag)) 79 || contextTag.matches(noframesTag))
80 return reportErrors ? HTMLTokenizer::RAWTEXTState : HTMLTokenizer::PLAIN TEXTState; 80 return reportErrors ? HTMLTokenizer::RAWTEXTState : HTMLTokenizer::PLAIN TEXTState;
81 if (contextTag.matches(scriptTag)) 81 if (contextTag.matches(scriptTag))
82 return reportErrors ? HTMLTokenizer::ScriptDataState : HTMLTokenizer::PL AINTEXTState; 82 return reportErrors ? HTMLTokenizer::ScriptDataState : HTMLTokenizer::PL AINTEXTState;
83 if (contextTag.matches(plaintextTag)) 83 if (contextTag.matches(plaintextTag))
84 return HTMLTokenizer::PLAINTEXTState; 84 return HTMLTokenizer::PLAINTEXTState;
85 return HTMLTokenizer::DataState; 85 return HTMLTokenizer::DataState;
86 } 86 }
87 87
88 class ParserDataReceiver final : public RefCountedWillBeGarbageCollectedFinalize d<ParserDataReceiver>, public DocumentLifecycleObserver { 88 class ParserDataReceiver final : public GarbageCollectedFinalized<ParserDataRece iver>, public DocumentLifecycleObserver {
89 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ParserDataReceiver); 89 USING_GARBAGE_COLLECTED_MIXIN(ParserDataReceiver);
90 public: 90 public:
91 static PassRefPtrWillBeRawPtr<ParserDataReceiver> create(WeakPtr<BackgroundH TMLParser> backgroundParser, Document* document) 91 static RawPtr<ParserDataReceiver> create(WeakPtr<BackgroundHTMLParser> backg roundParser, Document* document)
92 { 92 {
93 return adoptRefWillBeNoop(new ParserDataReceiver(backgroundParser, docum ent)); 93 return new ParserDataReceiver(backgroundParser, document);
94 } 94 }
95 95
96 DEFINE_INLINE_VIRTUAL_TRACE() 96 DEFINE_INLINE_VIRTUAL_TRACE()
97 { 97 {
98 DocumentLifecycleObserver::trace(visitor); 98 DocumentLifecycleObserver::trace(visitor);
99 } 99 }
100 100
101 private: 101 private:
102 ParserDataReceiver(WeakPtr<BackgroundHTMLParser> backgroundParser, Document* document) 102 ParserDataReceiver(WeakPtr<BackgroundHTMLParser> backgroundParser, Document* document)
103 : DocumentLifecycleObserver(document) 103 : DocumentLifecycleObserver(document)
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // This kicks off "Once the user agent stops parsing" as described by: 224 // This kicks off "Once the user agent stops parsing" as described by:
225 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#the- end 225 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#the- end
226 void HTMLDocumentParser::prepareToStopParsing() 226 void HTMLDocumentParser::prepareToStopParsing()
227 { 227 {
228 // FIXME: It may not be correct to disable this for the background parser. 228 // FIXME: It may not be correct to disable this for the background parser.
229 // That means hasInsertionPoint() may not be correct in some cases. 229 // That means hasInsertionPoint() may not be correct in some cases.
230 ASSERT(!hasInsertionPoint() || m_haveBackgroundParser); 230 ASSERT(!hasInsertionPoint() || m_haveBackgroundParser);
231 231
232 // pumpTokenizer can cause this parser to be detached from the Document, 232 // pumpTokenizer can cause this parser to be detached from the Document,
233 // but we need to ensure it isn't deleted yet. 233 // but we need to ensure it isn't deleted yet.
234 RefPtrWillBeRawPtr<HTMLDocumentParser> protect(this); 234 RawPtr<HTMLDocumentParser> protect(this);
235 235
236 // NOTE: This pump should only ever emit buffered character tokens. 236 // NOTE: This pump should only ever emit buffered character tokens.
237 if (m_tokenizer) { 237 if (m_tokenizer) {
238 ASSERT(!m_haveBackgroundParser); 238 ASSERT(!m_haveBackgroundParser);
239 pumpTokenizerIfPossible(); 239 pumpTokenizerIfPossible();
240 } 240 }
241 241
242 if (isStopped()) 242 if (isStopped())
243 return; 243 return;
244 244
(...skipping 30 matching lines...) Expand all
275 } 275 }
276 276
277 // Used by HTMLParserScheduler 277 // Used by HTMLParserScheduler
278 void HTMLDocumentParser::resumeParsingAfterYield() 278 void HTMLDocumentParser::resumeParsingAfterYield()
279 { 279 {
280 ASSERT(shouldUseThreading()); 280 ASSERT(shouldUseThreading());
281 ASSERT(m_haveBackgroundParser); 281 ASSERT(m_haveBackgroundParser);
282 282
283 // pumpPendingSpeculations can cause this parser to be detached from the Doc ument, 283 // pumpPendingSpeculations can cause this parser to be detached from the Doc ument,
284 // but we need to ensure it isn't deleted yet. 284 // but we need to ensure it isn't deleted yet.
285 RefPtrWillBeRawPtr<HTMLDocumentParser> protect(this); 285 RawPtr<HTMLDocumentParser> protect(this);
286 pumpPendingSpeculations(); 286 pumpPendingSpeculations();
287 } 287 }
288 288
289 void HTMLDocumentParser::runScriptsForPausedTreeBuilder() 289 void HTMLDocumentParser::runScriptsForPausedTreeBuilder()
290 { 290 {
291 ASSERT(scriptingContentIsAllowed(getParserContentPolicy())); 291 ASSERT(scriptingContentIsAllowed(getParserContentPolicy()));
292 292
293 TextPosition scriptStartPosition = TextPosition::belowRangePosition(); 293 TextPosition scriptStartPosition = TextPosition::belowRangePosition();
294 RefPtrWillBeRawPtr<Element> scriptElement = m_treeBuilder->takeScriptToProce ss(scriptStartPosition); 294 RawPtr<Element> scriptElement = m_treeBuilder->takeScriptToProcess(scriptSta rtPosition);
295 // We will not have a scriptRunner when parsing a DocumentFragment. 295 // We will not have a scriptRunner when parsing a DocumentFragment.
296 if (m_scriptRunner) 296 if (m_scriptRunner)
297 m_scriptRunner->execute(scriptElement.release(), scriptStartPosition); 297 m_scriptRunner->execute(scriptElement.release(), scriptStartPosition);
298 } 298 }
299 299
300 bool HTMLDocumentParser::canTakeNextToken() 300 bool HTMLDocumentParser::canTakeNextToken()
301 { 301 {
302 if (isStopped()) 302 if (isStopped())
303 return false; 303 return false;
304 304
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 717
718 void HTMLDocumentParser::insert(const SegmentedString& source) 718 void HTMLDocumentParser::insert(const SegmentedString& source)
719 { 719 {
720 if (isStopped()) 720 if (isStopped())
721 return; 721 return;
722 722
723 TRACE_EVENT1("blink", "HTMLDocumentParser::insert", "source_length", source. length()); 723 TRACE_EVENT1("blink", "HTMLDocumentParser::insert", "source_length", source. length());
724 724
725 // pumpTokenizer can cause this parser to be detached from the Document, 725 // pumpTokenizer can cause this parser to be detached from the Document,
726 // but we need to ensure it isn't deleted yet. 726 // but we need to ensure it isn't deleted yet.
727 RefPtrWillBeRawPtr<HTMLDocumentParser> protect(this); 727 RawPtr<HTMLDocumentParser> protect(this);
728 728
729 if (!m_tokenizer) { 729 if (!m_tokenizer) {
730 ASSERT(!inPumpSession()); 730 ASSERT(!inPumpSession());
731 ASSERT(m_haveBackgroundParser || wasCreatedByScript()); 731 ASSERT(m_haveBackgroundParser || wasCreatedByScript());
732 m_token = adoptPtr(new HTMLToken); 732 m_token = adoptPtr(new HTMLToken);
733 m_tokenizer = HTMLTokenizer::create(m_options); 733 m_tokenizer = HTMLTokenizer::create(m_options);
734 } 734 }
735 735
736 SegmentedString excludedLineNumberSource(source); 736 SegmentedString excludedLineNumberSource(source);
737 excludedLineNumberSource.setExcludeLineNumbers(); 737 excludedLineNumberSource.setExcludeLineNumbers();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 { 811 {
812 if (isStopped()) 812 if (isStopped())
813 return; 813 return;
814 814
815 // We should never reach this point if we're using a parser thread, 815 // We should never reach this point if we're using a parser thread,
816 // as appendBytes() will directly ship the data to the thread. 816 // as appendBytes() will directly ship the data to the thread.
817 ASSERT(!shouldUseThreading()); 817 ASSERT(!shouldUseThreading());
818 818
819 // pumpTokenizer can cause this parser to be detached from the Document, 819 // pumpTokenizer can cause this parser to be detached from the Document,
820 // but we need to ensure it isn't deleted yet. 820 // but we need to ensure it isn't deleted yet.
821 RefPtrWillBeRawPtr<HTMLDocumentParser> protect(this); 821 RawPtr<HTMLDocumentParser> protect(this);
822 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "HTMLDocumentParser:: append", "size", inputSource.length()); 822 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "HTMLDocumentParser:: append", "size", inputSource.length());
823 const SegmentedString source(inputSource); 823 const SegmentedString source(inputSource);
824 824
825 if (m_preloadScanner) { 825 if (m_preloadScanner) {
826 if (m_input.current().isEmpty() && !isWaitingForScripts()) { 826 if (m_input.current().isEmpty() && !isWaitingForScripts()) {
827 // We have parsed until the end of the current input and so are now moving ahead of the preload scanner. 827 // We have parsed until the end of the current input and so are now moving ahead of the preload scanner.
828 // Clear the scanner so we know to scan starting from the current in put point if we block again. 828 // Clear the scanner so we know to scan starting from the current in put point if we block again.
829 m_preloadScanner.clear(); 829 m_preloadScanner.clear();
830 } else { 830 } else {
831 m_preloadScanner->appendToEnd(source); 831 m_preloadScanner->appendToEnd(source);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 prepareToStopParsing(); 898 prepareToStopParsing();
899 } 899 }
900 900
901 void HTMLDocumentParser::finish() 901 void HTMLDocumentParser::finish()
902 { 902 {
903 // FIXME: We should ASSERT(!m_parserStopped) here, since it does not 903 // FIXME: We should ASSERT(!m_parserStopped) here, since it does not
904 // makes sense to call any methods on DocumentParser once it's been stopped. 904 // makes sense to call any methods on DocumentParser once it's been stopped.
905 // However, FrameLoader::stop calls DocumentParser::finish unconditionally. 905 // However, FrameLoader::stop calls DocumentParser::finish unconditionally.
906 906
907 // flush may ending up executing arbitrary script, and possibly detach the p arser. 907 // flush may ending up executing arbitrary script, and possibly detach the p arser.
908 RefPtrWillBeRawPtr<HTMLDocumentParser> protect(this); 908 RawPtr<HTMLDocumentParser> protect(this);
909 flush(); 909 flush();
910 if (isDetached()) 910 if (isDetached())
911 return; 911 return;
912 912
913 // Empty documents never got an append() call, and thus have never started 913 // Empty documents never got an append() call, and thus have never started
914 // a background parser. In those cases, we ignore shouldUseThreading() 914 // a background parser. In those cases, we ignore shouldUseThreading()
915 // and fall through to the non-threading case. 915 // and fall through to the non-threading case.
916 if (m_haveBackgroundParser) { 916 if (m_haveBackgroundParser) {
917 if (!m_input.haveSeenEndOfFile()) 917 if (!m_input.haveSeenEndOfFile())
918 m_input.closeWithoutMarkingEndOfFile(); 918 m_input.closeWithoutMarkingEndOfFile();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 void HTMLDocumentParser::resumeParsingAfterScriptExecution() 989 void HTMLDocumentParser::resumeParsingAfterScriptExecution()
990 { 990 {
991 ASSERT(!isExecutingScript()); 991 ASSERT(!isExecutingScript());
992 ASSERT(!isWaitingForScripts()); 992 ASSERT(!isWaitingForScripts());
993 993
994 if (m_haveBackgroundParser) { 994 if (m_haveBackgroundParser) {
995 validateSpeculations(m_lastChunkBeforeScript.release()); 995 validateSpeculations(m_lastChunkBeforeScript.release());
996 ASSERT(!m_lastChunkBeforeScript); 996 ASSERT(!m_lastChunkBeforeScript);
997 // processParsedChunkFromBackgroundParser can cause this parser to be de tached from the Document, 997 // processParsedChunkFromBackgroundParser can cause this parser to be de tached from the Document,
998 // but we need to ensure it isn't deleted yet. 998 // but we need to ensure it isn't deleted yet.
999 RefPtrWillBeRawPtr<HTMLDocumentParser> protect(this); 999 RawPtr<HTMLDocumentParser> protect(this);
1000 pumpPendingSpeculations(); 1000 pumpPendingSpeculations();
1001 return; 1001 return;
1002 } 1002 }
1003 1003
1004 m_insertionPreloadScanner.clear(); 1004 m_insertionPreloadScanner.clear();
1005 pumpTokenizerIfPossible(); 1005 pumpTokenizerIfPossible();
1006 endIfDelayed(); 1006 endIfDelayed();
1007 } 1007 }
1008 1008
1009 void HTMLDocumentParser::appendCurrentInputStreamToPreloadScannerAndScan() 1009 void HTMLDocumentParser::appendCurrentInputStreamToPreloadScannerAndScan()
1010 { 1010 {
1011 ASSERT(m_preloadScanner); 1011 ASSERT(m_preloadScanner);
1012 m_preloadScanner->appendToEnd(m_input.current()); 1012 m_preloadScanner->appendToEnd(m_input.current());
1013 m_preloadScanner->scan(m_preloader.get(), document()->baseElementURL(), null ptr); 1013 m_preloadScanner->scan(m_preloader.get(), document()->baseElementURL(), null ptr);
1014 } 1014 }
1015 1015
1016 void HTMLDocumentParser::notifyScriptLoaded(Resource* cachedResource) 1016 void HTMLDocumentParser::notifyScriptLoaded(Resource* cachedResource)
1017 { 1017 {
1018 // pumpTokenizer can cause this parser to be detached from the Document, 1018 // pumpTokenizer can cause this parser to be detached from the Document,
1019 // but we need to ensure it isn't deleted yet. 1019 // but we need to ensure it isn't deleted yet.
1020 RefPtrWillBeRawPtr<HTMLDocumentParser> protect(this); 1020 RawPtr<HTMLDocumentParser> protect(this);
1021 1021
1022 ASSERT(m_scriptRunner); 1022 ASSERT(m_scriptRunner);
1023 ASSERT(!isExecutingScript()); 1023 ASSERT(!isExecutingScript());
1024 1024
1025 if (isStopped()) { 1025 if (isStopped()) {
1026 return; 1026 return;
1027 } 1027 }
1028 1028
1029 if (isStopping()) { 1029 if (isStopping()) {
1030 attemptToRunDeferredScriptsAndEnd(); 1030 attemptToRunDeferredScriptsAndEnd();
(...skipping 11 matching lines...) Expand all
1042 // so this will not be called in the DocumentFragment case. 1042 // so this will not be called in the DocumentFragment case.
1043 ASSERT(m_scriptRunner); 1043 ASSERT(m_scriptRunner);
1044 // Ignore calls unless we have a script blocking the parser waiting on a 1044 // Ignore calls unless we have a script blocking the parser waiting on a
1045 // stylesheet load. Otherwise we are currently parsing and this 1045 // stylesheet load. Otherwise we are currently parsing and this
1046 // is a re-entrant call from encountering a </ style> tag. 1046 // is a re-entrant call from encountering a </ style> tag.
1047 if (!m_scriptRunner->hasScriptsWaitingForResources()) 1047 if (!m_scriptRunner->hasScriptsWaitingForResources())
1048 return; 1048 return;
1049 1049
1050 // pumpTokenizer can cause this parser to be detached from the Document, 1050 // pumpTokenizer can cause this parser to be detached from the Document,
1051 // but we need to ensure it isn't deleted yet. 1051 // but we need to ensure it isn't deleted yet.
1052 RefPtrWillBeRawPtr<HTMLDocumentParser> protect(this); 1052 RawPtr<HTMLDocumentParser> protect(this);
1053 m_scriptRunner->executeScriptsWaitingForResources(); 1053 m_scriptRunner->executeScriptsWaitingForResources();
1054 if (!isWaitingForScripts()) 1054 if (!isWaitingForScripts())
1055 resumeParsingAfterScriptExecution(); 1055 resumeParsingAfterScriptExecution();
1056 } 1056 }
1057 1057
1058 void HTMLDocumentParser::parseDocumentFragment(const String& source, DocumentFra gment* fragment, Element* contextElement, ParserContentPolicy parserContentPolic y) 1058 void HTMLDocumentParser::parseDocumentFragment(const String& source, DocumentFra gment* fragment, Element* contextElement, ParserContentPolicy parserContentPolic y)
1059 { 1059 {
1060 RefPtrWillBeRawPtr<HTMLDocumentParser> parser = HTMLDocumentParser::create(f ragment, contextElement, parserContentPolicy); 1060 RawPtr<HTMLDocumentParser> parser = HTMLDocumentParser::create(fragment, con textElement, parserContentPolicy);
1061 parser->append(source); 1061 parser->append(source);
1062 parser->finish(); 1062 parser->finish();
1063 parser->detach(); // Allows ~DocumentParser to assert it was detached before destruction. 1063 parser->detach(); // Allows ~DocumentParser to assert it was detached before destruction.
1064 } 1064 }
1065 1065
1066 void HTMLDocumentParser::suspendScheduledTasks() 1066 void HTMLDocumentParser::suspendScheduledTasks()
1067 { 1067 {
1068 ASSERT(!m_tasksWereSuspended); 1068 ASSERT(!m_tasksWereSuspended);
1069 m_tasksWereSuspended = true; 1069 m_tasksWereSuspended = true;
1070 if (m_parserScheduler) 1070 if (m_parserScheduler)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) 1125 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder)
1126 { 1126 {
1127 ASSERT(decoder); 1127 ASSERT(decoder);
1128 DecodedDataDocumentParser::setDecoder(decoder); 1128 DecodedDataDocumentParser::setDecoder(decoder);
1129 1129
1130 if (m_haveBackgroundParser) 1130 if (m_haveBackgroundParser)
1131 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParse r::setDecoder, AllowCrossThreadAccess(m_backgroundParser), takeDecoder())); 1131 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParse r::setDecoder, AllowCrossThreadAccess(m_backgroundParser), takeDecoder()));
1132 } 1132 }
1133 1133
1134 } // namespace blink 1134 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698