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_treeBuilder = HTMLTreeBuilder::create(this, &document, AllowScriptingConte nt, m_options); | |
Yoav Weiss
2016/07/05 08:20:14
Doesn't this mean that we're creating m_treeBuilde
kouhei (in TOK)
2016/07/06 00:49:54
Yes. This does mean that m_treeBuilder Member smar
| |
95 } | |
96 | |
97 HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* cont extElement, ParserContentPolicy parserContentPolicy) | |
Yoav Weiss
2016/07/05 08:20:14
Not critical, but It would've been easier to revie
kouhei (in TOK)
2016/07/06 00:49:54
I think we should have delegated ctor def either a
| |
98 : HTMLDocumentParser(fragment->document(), parserContentPolicy, ForceSynchro nousParsing) | |
99 { | |
100 m_treeBuilder = HTMLTreeBuilder::create(this, fragment, contextElement, pars erContentPolicy, m_options); | |
101 | |
102 bool reportErrors = false; // For now document fragment parsing never report s errors. | |
103 m_tokenizer->setState(tokenizerStateForContextElement(contextElement, report Errors, m_options)); | |
104 m_xssAuditor.initForFragment(); | |
105 } | |
106 | |
107 HTMLDocumentParser::HTMLDocumentParser(Document& document, ParserContentPolicy c ontentPolicy, ParserSynchronizationPolicy syncPolicy) | |
108 : ScriptableDocumentParser(document, contentPolicy) | |
93 , m_options(&document) | 109 , m_options(&document) |
94 , m_token(syncPolicy == ForceSynchronousParsing ? wrapUnique(new HTMLToken) : nullptr) | 110 , m_token(syncPolicy == ForceSynchronousParsing ? wrapUnique(new HTMLToken) : nullptr) |
95 , m_tokenizer(syncPolicy == ForceSynchronousParsing ? HTMLTokenizer::create( m_options) : nullptr) | 111 , m_tokenizer(syncPolicy == ForceSynchronousParsing ? HTMLTokenizer::create( m_options) : nullptr) |
96 , m_scriptRunner(HTMLScriptRunner::create(&document, this)) | 112 , m_scriptRunner(scriptingContentIsAllowed(contentPolicy) ? HTMLScriptRunner ::create(&document, this) : nullptr) |
tzik
2016/07/05 07:59:09
# As we chatted offline.
On old code, m_scriptRunn
| |
97 , m_treeBuilder(HTMLTreeBuilder::create(this, &document, getParserContentPol icy(), m_options)) | |
98 , m_loadingTaskRunner(wrapUnique(document.loadingTaskRunner()->clone())) | 113 , m_loadingTaskRunner(wrapUnique(document.loadingTaskRunner()->clone())) |
99 , m_parserScheduler(HTMLParserScheduler::create(this, m_loadingTaskRunner.ge t())) | 114 , m_parserScheduler(syncPolicy == AllowAsynchronousParsing ? HTMLParserSched uler::create(this, m_loadingTaskRunner.get()) : nullptr) |
100 , m_xssAuditorDelegate(&document) | 115 , m_xssAuditorDelegate(&document) |
101 , m_weakFactory(this) | 116 , m_weakFactory(this) |
102 , m_preloader(HTMLResourcePreloader::create(document)) | 117 , m_preloader(HTMLResourcePreloader::create(document)) |
103 , m_parsedChunkQueue(ParsedChunkQueue::create()) | 118 , m_parsedChunkQueue(ParsedChunkQueue::create()) |
104 , m_evaluator(DocumentWriteEvaluator::create(document)) | 119 , m_evaluator(DocumentWriteEvaluator::create(document)) |
105 , m_shouldUseThreading(syncPolicy == AllowAsynchronousParsing) | 120 , m_shouldUseThreading(syncPolicy == AllowAsynchronousParsing) |
106 , m_endWasDelayed(false) | 121 , m_endWasDelayed(false) |
107 , m_haveBackgroundParser(false) | 122 , m_haveBackgroundParser(false) |
108 , m_tasksWereSuspended(false) | 123 , m_tasksWereSuspended(false) |
109 , m_pumpSessionNestingLevel(0) | 124 , m_pumpSessionNestingLevel(0) |
110 , m_pumpSpeculationsSessionNestingLevel(0) | 125 , m_pumpSpeculationsSessionNestingLevel(0) |
111 , m_isParsingAtLineNumber(false) | 126 , m_isParsingAtLineNumber(false) |
112 , m_triedLoadingLinkHeaders(false) | 127 , m_triedLoadingLinkHeaders(false) |
113 { | 128 { |
114 ASSERT(shouldUseThreading() || (m_token && m_tokenizer)); | 129 ASSERT(shouldUseThreading() || (m_token && m_tokenizer)); |
115 } | 130 } |
116 | 131 |
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() | 132 HTMLDocumentParser::~HTMLDocumentParser() |
141 { | 133 { |
142 // In Oilpan, HTMLDocumentParser can die together with Document, and | 134 // In Oilpan, HTMLDocumentParser can die together with Document, and |
143 // detach() is not called in this case. | 135 // detach() is not called in this case. |
144 if (m_haveBackgroundParser) | 136 if (m_haveBackgroundParser) |
145 stopBackgroundParser(); | 137 stopBackgroundParser(); |
146 } | 138 } |
147 | 139 |
148 DEFINE_TRACE(HTMLDocumentParser) | 140 DEFINE_TRACE(HTMLDocumentParser) |
149 { | 141 { |
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1146 (*closure)(); | 1138 (*closure)(); |
1147 return; | 1139 return; |
1148 case Asynchronous: | 1140 case Asynchronous: |
1149 m_loadingTaskRunner->postTask(BLINK_FROM_HERE, std::move(closure)); | 1141 m_loadingTaskRunner->postTask(BLINK_FROM_HERE, std::move(closure)); |
1150 return; | 1142 return; |
1151 } | 1143 } |
1152 NOTREACHED(); | 1144 NOTREACHED(); |
1153 } | 1145 } |
1154 | 1146 |
1155 } // namespace blink | 1147 } // namespace blink |
OLD | NEW |