| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 || contextTag.matches(noframesTag)) | 82 || contextTag.matches(noframesTag)) |
| 83 return reportErrors ? HTMLTokenizer::RAWTEXTState : HTMLTokenizer::PLAIN
TEXTState; | 83 return reportErrors ? HTMLTokenizer::RAWTEXTState : HTMLTokenizer::PLAIN
TEXTState; |
| 84 if (contextTag.matches(scriptTag)) | 84 if (contextTag.matches(scriptTag)) |
| 85 return reportErrors ? HTMLTokenizer::ScriptDataState : HTMLTokenizer::PL
AINTEXTState; | 85 return reportErrors ? HTMLTokenizer::ScriptDataState : HTMLTokenizer::PL
AINTEXTState; |
| 86 if (contextTag.matches(plaintextTag)) | 86 if (contextTag.matches(plaintextTag)) |
| 87 return HTMLTokenizer::PLAINTEXTState; | 87 return HTMLTokenizer::PLAINTEXTState; |
| 88 return HTMLTokenizer::DataState; | 88 return HTMLTokenizer::DataState; |
| 89 } | 89 } |
| 90 | 90 |
| 91 HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, ParserSynchroniza
tionPolicy syncPolicy) | 91 HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, ParserSynchroniza
tionPolicy syncPolicy) |
| 92 : ScriptableDocumentParser(document) | 92 : HTMLDocumentParser(document, AllowScriptingContent, syncPolicy) |
| 93 { |
| 94 m_scriptRunner = HTMLScriptRunner::create(&document, this); |
| 95 m_treeBuilder = HTMLTreeBuilder::create(this, &document, AllowScriptingConte
nt, m_options); |
| 96 } |
| 97 |
| 98 HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* cont
extElement, ParserContentPolicy parserContentPolicy) |
| 99 : HTMLDocumentParser(fragment->document(), parserContentPolicy, ForceSynchro
nousParsing) |
| 100 { |
| 101 // No m_scriptRunner in fragment parser. |
| 102 m_treeBuilder = HTMLTreeBuilder::create(this, fragment, contextElement, pars
erContentPolicy, m_options); |
| 103 |
| 104 bool reportErrors = false; // For now document fragment parsing never report
s errors. |
| 105 m_tokenizer->setState(tokenizerStateForContextElement(contextElement, report
Errors, m_options)); |
| 106 m_xssAuditor.initForFragment(); |
| 107 } |
| 108 |
| 109 HTMLDocumentParser::HTMLDocumentParser(Document& document, ParserContentPolicy c
ontentPolicy, ParserSynchronizationPolicy syncPolicy) |
| 110 : ScriptableDocumentParser(document, contentPolicy) |
| 93 , m_options(&document) | 111 , m_options(&document) |
| 94 , m_token(syncPolicy == ForceSynchronousParsing ? wrapUnique(new HTMLToken)
: nullptr) | 112 , m_token(syncPolicy == ForceSynchronousParsing ? wrapUnique(new HTMLToken)
: nullptr) |
| 95 , m_tokenizer(syncPolicy == ForceSynchronousParsing ? HTMLTokenizer::create(
m_options) : nullptr) | 113 , m_tokenizer(syncPolicy == ForceSynchronousParsing ? HTMLTokenizer::create(
m_options) : nullptr) |
| 96 , m_scriptRunner(HTMLScriptRunner::create(&document, this)) | |
| 97 , m_treeBuilder(HTMLTreeBuilder::create(this, &document, getParserContentPol
icy(), m_options)) | |
| 98 , m_loadingTaskRunner(wrapUnique(document.loadingTaskRunner()->clone())) | 114 , m_loadingTaskRunner(wrapUnique(document.loadingTaskRunner()->clone())) |
| 99 , m_parserScheduler(HTMLParserScheduler::create(this, m_loadingTaskRunner.ge
t())) | 115 , m_parserScheduler(syncPolicy == AllowAsynchronousParsing ? HTMLParserSched
uler::create(this, m_loadingTaskRunner.get()) : nullptr) |
| 100 , m_xssAuditorDelegate(&document) | 116 , m_xssAuditorDelegate(&document) |
| 101 , m_weakFactory(this) | 117 , m_weakFactory(this) |
| 102 , m_preloader(HTMLResourcePreloader::create(document)) | 118 , m_preloader(HTMLResourcePreloader::create(document)) |
| 103 , m_parsedChunkQueue(ParsedChunkQueue::create()) | 119 , m_parsedChunkQueue(ParsedChunkQueue::create()) |
| 104 , m_evaluator(DocumentWriteEvaluator::create(document)) | 120 , m_evaluator(DocumentWriteEvaluator::create(document)) |
| 105 , m_shouldUseThreading(syncPolicy == AllowAsynchronousParsing) | 121 , m_shouldUseThreading(syncPolicy == AllowAsynchronousParsing) |
| 106 , m_endWasDelayed(false) | 122 , m_endWasDelayed(false) |
| 107 , m_haveBackgroundParser(false) | 123 , m_haveBackgroundParser(false) |
| 108 , m_tasksWereSuspended(false) | 124 , m_tasksWereSuspended(false) |
| 109 , m_pumpSessionNestingLevel(0) | 125 , m_pumpSessionNestingLevel(0) |
| 110 , m_pumpSpeculationsSessionNestingLevel(0) | 126 , m_pumpSpeculationsSessionNestingLevel(0) |
| 111 , m_isParsingAtLineNumber(false) | 127 , m_isParsingAtLineNumber(false) |
| 112 , m_triedLoadingLinkHeaders(false) | 128 , m_triedLoadingLinkHeaders(false) |
| 113 { | 129 { |
| 114 ASSERT(shouldUseThreading() || (m_token && m_tokenizer)); | 130 ASSERT(shouldUseThreading() || (m_token && m_tokenizer)); |
| 115 } | 131 } |
| 116 | 132 |
| 117 // FIXME: Member variables should be grouped into self-initializing structs to | |
| 118 // minimize code duplication between these constructors. | |
| 119 HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* cont
extElement, ParserContentPolicy parserContentPolicy) | |
| 120 : ScriptableDocumentParser(fragment->document(), parserContentPolicy) | |
| 121 , m_options(&fragment->document()) | |
| 122 , m_token(wrapUnique(new HTMLToken)) | |
| 123 , m_tokenizer(HTMLTokenizer::create(m_options)) | |
| 124 , m_treeBuilder(HTMLTreeBuilder::create(this, fragment, contextElement, this
->getParserContentPolicy(), m_options)) | |
| 125 , m_loadingTaskRunner(wrapUnique(fragment->document().loadingTaskRunner()->c
lone())) | |
| 126 , m_xssAuditorDelegate(&fragment->document()) | |
| 127 , m_weakFactory(this) | |
| 128 , m_shouldUseThreading(false) | |
| 129 , m_endWasDelayed(false) | |
| 130 , m_haveBackgroundParser(false) | |
| 131 , m_tasksWereSuspended(false) | |
| 132 , m_pumpSessionNestingLevel(0) | |
| 133 , m_pumpSpeculationsSessionNestingLevel(0) | |
| 134 { | |
| 135 bool reportErrors = false; // For now document fragment parsing never report
s errors. | |
| 136 m_tokenizer->setState(tokenizerStateForContextElement(contextElement, report
Errors, m_options)); | |
| 137 m_xssAuditor.initForFragment(); | |
| 138 } | |
| 139 | |
| 140 HTMLDocumentParser::~HTMLDocumentParser() | 133 HTMLDocumentParser::~HTMLDocumentParser() |
| 141 { | 134 { |
| 142 // In Oilpan, HTMLDocumentParser can die together with Document, and | 135 // In Oilpan, HTMLDocumentParser can die together with Document, and |
| 143 // detach() is not called in this case. | 136 // detach() is not called in this case. |
| 144 if (m_haveBackgroundParser) | 137 if (m_haveBackgroundParser) |
| 145 stopBackgroundParser(); | 138 stopBackgroundParser(); |
| 146 } | 139 } |
| 147 | 140 |
| 148 DEFINE_TRACE(HTMLDocumentParser) | 141 DEFINE_TRACE(HTMLDocumentParser) |
| 149 { | 142 { |
| (...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1146 (*closure)(); | 1139 (*closure)(); |
| 1147 return; | 1140 return; |
| 1148 case Asynchronous: | 1141 case Asynchronous: |
| 1149 m_loadingTaskRunner->postTask(BLINK_FROM_HERE, std::move(closure)); | 1142 m_loadingTaskRunner->postTask(BLINK_FROM_HERE, std::move(closure)); |
| 1150 return; | 1143 return; |
| 1151 } | 1144 } |
| 1152 NOTREACHED(); | 1145 NOTREACHED(); |
| 1153 } | 1146 } |
| 1154 | 1147 |
| 1155 } // namespace blink | 1148 } // namespace blink |
| OLD | NEW |