OLD | NEW |
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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 136 |
137 WeakPtr<BackgroundHTMLParser> m_backgroundParser; | 137 WeakPtr<BackgroundHTMLParser> m_backgroundParser; |
138 }; | 138 }; |
139 | 139 |
140 HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, bool reportErrors
, ParserSynchronizationPolicy syncPolicy) | 140 HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, bool reportErrors
, ParserSynchronizationPolicy syncPolicy) |
141 : ScriptableDocumentParser(document) | 141 : ScriptableDocumentParser(document) |
142 , m_options(&document) | 142 , m_options(&document) |
143 , m_token(syncPolicy == ForceSynchronousParsing ? adoptPtr(new HTMLToken) :
nullptr) | 143 , m_token(syncPolicy == ForceSynchronousParsing ? adoptPtr(new HTMLToken) :
nullptr) |
144 , m_tokenizer(syncPolicy == ForceSynchronousParsing ? HTMLTokenizer::create(
m_options) : nullptr) | 144 , m_tokenizer(syncPolicy == ForceSynchronousParsing ? HTMLTokenizer::create(
m_options) : nullptr) |
145 , m_scriptRunner(HTMLScriptRunner::create(&document, this)) | 145 , m_scriptRunner(HTMLScriptRunner::create(&document, this)) |
146 , m_treeBuilder(HTMLTreeBuilder::create(this, &document, parserContentPolicy
(), reportErrors, m_options)) | 146 , m_treeBuilder(HTMLTreeBuilder::create(this, &document, getParserContentPol
icy(), reportErrors, m_options)) |
147 , m_loadingTaskRunner(adoptPtr(document.loadingTaskRunner()->clone())) | 147 , m_loadingTaskRunner(adoptPtr(document.loadingTaskRunner()->clone())) |
148 , m_parserScheduler(HTMLParserScheduler::create(this, m_loadingTaskRunner.ge
t())) | 148 , m_parserScheduler(HTMLParserScheduler::create(this, m_loadingTaskRunner.ge
t())) |
149 , m_xssAuditorDelegate(&document) | 149 , m_xssAuditorDelegate(&document) |
150 , m_weakFactory(this) | 150 , m_weakFactory(this) |
151 , m_preloader(HTMLResourcePreloader::create(document)) | 151 , m_preloader(HTMLResourcePreloader::create(document)) |
152 , m_parsedChunkQueue(ParsedChunkQueue::create()) | 152 , m_parsedChunkQueue(ParsedChunkQueue::create()) |
153 , m_shouldUseThreading(syncPolicy == AllowAsynchronousParsing) | 153 , m_shouldUseThreading(syncPolicy == AllowAsynchronousParsing) |
154 , m_endWasDelayed(false) | 154 , m_endWasDelayed(false) |
155 , m_haveBackgroundParser(false) | 155 , m_haveBackgroundParser(false) |
156 , m_tasksWereSuspended(false) | 156 , m_tasksWereSuspended(false) |
157 , m_pumpSessionNestingLevel(0) | 157 , m_pumpSessionNestingLevel(0) |
158 , m_pumpSpeculationsSessionNestingLevel(0) | 158 , m_pumpSpeculationsSessionNestingLevel(0) |
159 , m_isParsingAtLineNumber(false) | 159 , m_isParsingAtLineNumber(false) |
160 { | 160 { |
161 ASSERT(shouldUseThreading() || (m_token && m_tokenizer)); | 161 ASSERT(shouldUseThreading() || (m_token && m_tokenizer)); |
162 } | 162 } |
163 | 163 |
164 // FIXME: Member variables should be grouped into self-initializing structs to | 164 // FIXME: Member variables should be grouped into self-initializing structs to |
165 // minimize code duplication between these constructors. | 165 // minimize code duplication between these constructors. |
166 HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* cont
extElement, ParserContentPolicy parserContentPolicy) | 166 HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* cont
extElement, ParserContentPolicy parserContentPolicy) |
167 : ScriptableDocumentParser(fragment->document(), parserContentPolicy) | 167 : ScriptableDocumentParser(fragment->document(), parserContentPolicy) |
168 , m_options(&fragment->document()) | 168 , m_options(&fragment->document()) |
169 , m_token(adoptPtr(new HTMLToken)) | 169 , m_token(adoptPtr(new HTMLToken)) |
170 , m_tokenizer(HTMLTokenizer::create(m_options)) | 170 , m_tokenizer(HTMLTokenizer::create(m_options)) |
171 , m_treeBuilder(HTMLTreeBuilder::create(this, fragment, contextElement, this
->parserContentPolicy(), m_options)) | 171 , m_treeBuilder(HTMLTreeBuilder::create(this, fragment, contextElement, this
->getParserContentPolicy(), m_options)) |
172 , m_loadingTaskRunner(adoptPtr(fragment->document().loadingTaskRunner()->clo
ne())) | 172 , m_loadingTaskRunner(adoptPtr(fragment->document().loadingTaskRunner()->clo
ne())) |
173 , m_xssAuditorDelegate(&fragment->document()) | 173 , m_xssAuditorDelegate(&fragment->document()) |
174 , m_weakFactory(this) | 174 , m_weakFactory(this) |
175 , m_shouldUseThreading(false) | 175 , m_shouldUseThreading(false) |
176 , m_endWasDelayed(false) | 176 , m_endWasDelayed(false) |
177 , m_haveBackgroundParser(false) | 177 , m_haveBackgroundParser(false) |
178 , m_tasksWereSuspended(false) | 178 , m_tasksWereSuspended(false) |
179 , m_pumpSessionNestingLevel(0) | 179 , m_pumpSessionNestingLevel(0) |
180 , m_pumpSpeculationsSessionNestingLevel(0) | 180 , m_pumpSpeculationsSessionNestingLevel(0) |
181 { | 181 { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 ASSERT(m_haveBackgroundParser); | 314 ASSERT(m_haveBackgroundParser); |
315 | 315 |
316 // pumpPendingSpeculations can cause this parser to be detached from the Doc
ument, | 316 // pumpPendingSpeculations can cause this parser to be detached from the Doc
ument, |
317 // but we need to ensure it isn't deleted yet. | 317 // but we need to ensure it isn't deleted yet. |
318 RefPtrWillBeRawPtr<HTMLDocumentParser> protect(this); | 318 RefPtrWillBeRawPtr<HTMLDocumentParser> protect(this); |
319 pumpPendingSpeculations(); | 319 pumpPendingSpeculations(); |
320 } | 320 } |
321 | 321 |
322 void HTMLDocumentParser::runScriptsForPausedTreeBuilder() | 322 void HTMLDocumentParser::runScriptsForPausedTreeBuilder() |
323 { | 323 { |
324 ASSERT(scriptingContentIsAllowed(parserContentPolicy())); | 324 ASSERT(scriptingContentIsAllowed(getParserContentPolicy())); |
325 | 325 |
326 TextPosition scriptStartPosition = TextPosition::belowRangePosition(); | 326 TextPosition scriptStartPosition = TextPosition::belowRangePosition(); |
327 RefPtrWillBeRawPtr<Element> scriptElement = m_treeBuilder->takeScriptToProce
ss(scriptStartPosition); | 327 RefPtrWillBeRawPtr<Element> scriptElement = m_treeBuilder->takeScriptToProce
ss(scriptStartPosition); |
328 // We will not have a scriptRunner when parsing a DocumentFragment. | 328 // We will not have a scriptRunner when parsing a DocumentFragment. |
329 if (m_scriptRunner) | 329 if (m_scriptRunner) |
330 m_scriptRunner->execute(scriptElement.release(), scriptStartPosition); | 330 m_scriptRunner->execute(scriptElement.release(), scriptStartPosition); |
331 } | 331 } |
332 | 332 |
333 bool HTMLDocumentParser::canTakeNextToken() | 333 bool HTMLDocumentParser::canTakeNextToken() |
334 { | 334 { |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1163 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) | 1163 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) |
1164 { | 1164 { |
1165 ASSERT(decoder); | 1165 ASSERT(decoder); |
1166 DecodedDataDocumentParser::setDecoder(decoder); | 1166 DecodedDataDocumentParser::setDecoder(decoder); |
1167 | 1167 |
1168 if (m_haveBackgroundParser) | 1168 if (m_haveBackgroundParser) |
1169 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParse
r::setDecoder, AllowCrossThreadAccess(m_backgroundParser), takeDecoder())); | 1169 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParse
r::setDecoder, AllowCrossThreadAccess(m_backgroundParser), takeDecoder())); |
1170 } | 1170 } |
1171 | 1171 |
1172 } // namespace blink | 1172 } // namespace blink |
OLD | NEW |