| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "public/platform/WebURLRequest.h" | 32 #include "public/platform/WebURLRequest.h" |
| 33 | 33 |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 class ScriptElementBase; | 36 class ScriptElementBase; |
| 37 class Script; | 37 class Script; |
| 38 | 38 |
| 39 class ResourceFetcher; | 39 class ResourceFetcher; |
| 40 class ScriptResource; | 40 class ScriptResource; |
| 41 | 41 |
| 42 class Modulator; |
| 43 class ModulePendingScriptTreeClient; |
| 44 |
| 42 class CORE_EXPORT ScriptLoader : public GarbageCollectedFinalized<ScriptLoader>, | 45 class CORE_EXPORT ScriptLoader : public GarbageCollectedFinalized<ScriptLoader>, |
| 43 public PendingScriptClient { | 46 public PendingScriptClient { |
| 44 USING_GARBAGE_COLLECTED_MIXIN(ScriptLoader); | 47 USING_GARBAGE_COLLECTED_MIXIN(ScriptLoader); |
| 45 | 48 |
| 46 public: | 49 public: |
| 47 static ScriptLoader* Create(ScriptElementBase* element, | 50 static ScriptLoader* Create(ScriptElementBase* element, |
| 48 bool created_by_parser, | 51 bool created_by_parser, |
| 49 bool is_evaluated, | 52 bool is_evaluated, |
| 50 bool created_during_document_write = false) { | 53 bool created_during_document_write = false) { |
| 51 return new ScriptLoader(element, created_by_parser, is_evaluated, | 54 return new ScriptLoader(element, created_by_parser, is_evaluated, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 66 ScriptType& out_script_type); | 69 ScriptType& out_script_type); |
| 67 | 70 |
| 68 // https://html.spec.whatwg.org/#prepare-a-script | 71 // https://html.spec.whatwg.org/#prepare-a-script |
| 69 bool PrepareScript(const TextPosition& script_start_position = | 72 bool PrepareScript(const TextPosition& script_start_position = |
| 70 TextPosition::MinimumPosition(), | 73 TextPosition::MinimumPosition(), |
| 71 LegacyTypeSupport = kDisallowLegacyTypeInTypeAttribute); | 74 LegacyTypeSupport = kDisallowLegacyTypeInTypeAttribute); |
| 72 | 75 |
| 73 String ScriptContent() const; | 76 String ScriptContent() const; |
| 74 | 77 |
| 75 // Creates a PendingScript for external script whose fetch is started in | 78 // Creates a PendingScript for external script whose fetch is started in |
| 76 // FetchClassicScript(). | 79 // FetchClassicScript()/FetchModuleScriptTree(). |
| 77 PendingScript* CreatePendingScript(); | 80 PendingScript* CreatePendingScript(); |
| 78 | 81 |
| 79 // Returns false if and only if execution was blocked. | 82 // Returns false if and only if execution was blocked. |
| 80 bool ExecuteScript(const Script*); | 83 bool ExecuteScript(const Script*); |
| 81 virtual void Execute(); | 84 virtual void Execute(); |
| 82 | 85 |
| 83 // XML parser calls these | 86 // XML parser calls these |
| 84 void DispatchLoadEvent(); | 87 void DispatchLoadEvent(); |
| 85 void DispatchErrorEvent(); | 88 void DispatchErrorEvent(); |
| 86 bool IsScriptTypeSupported(LegacyTypeSupport, | 89 bool IsScriptTypeSupported(LegacyTypeSupport, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // | 144 // |
| 142 // https://html.spec.whatwg.org/#fetch-a-classic-script | 145 // https://html.spec.whatwg.org/#fetch-a-classic-script |
| 143 bool FetchClassicScript(const KURL&, | 146 bool FetchClassicScript(const KURL&, |
| 144 ResourceFetcher*, | 147 ResourceFetcher*, |
| 145 const String& nonce, | 148 const String& nonce, |
| 146 const IntegrityMetadataSet&, | 149 const IntegrityMetadataSet&, |
| 147 ParserDisposition, | 150 ParserDisposition, |
| 148 CrossOriginAttributeValue, | 151 CrossOriginAttributeValue, |
| 149 SecurityOrigin*, | 152 SecurityOrigin*, |
| 150 const String& encoding); | 153 const String& encoding); |
| 154 // https://html.spec.whatwg.org/#fetch-a-module-script-tree |
| 155 void FetchModuleScriptTree(const KURL&, |
| 156 Modulator*, |
| 157 const String& nonce, |
| 158 ParserDisposition, |
| 159 WebURLRequest::FetchCredentialsMode); |
| 151 | 160 |
| 152 bool DoExecuteScript(const Script*); | 161 bool DoExecuteScript(const Script*); |
| 153 | 162 |
| 154 // Clears the connection to the PendingScript. | 163 // Clears the connection to the PendingScript. |
| 155 void DetachPendingScript(); | 164 void DetachPendingScript(); |
| 156 | 165 |
| 157 // PendingScriptClient | 166 // PendingScriptClient |
| 158 void PendingScriptFinished(PendingScript*) override; | 167 void PendingScriptFinished(PendingScript*) override; |
| 159 | 168 |
| 160 Member<ScriptElementBase> element_; | 169 Member<ScriptElementBase> element_; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 175 // https://html.spec.whatwg.org/#non-blocking | 184 // https://html.spec.whatwg.org/#non-blocking |
| 176 // "Initially, script elements must have this flag set." | 185 // "Initially, script elements must have this flag set." |
| 177 bool non_blocking_ = true; | 186 bool non_blocking_ = true; |
| 178 | 187 |
| 179 // https://html.spec.whatwg.org/#ready-to-be-parser-executed | 188 // https://html.spec.whatwg.org/#ready-to-be-parser-executed |
| 180 // "Initially, script elements must have this flag unset" | 189 // "Initially, script elements must have this flag unset" |
| 181 bool ready_to_be_parser_executed_ = false; | 190 bool ready_to_be_parser_executed_ = false; |
| 182 | 191 |
| 183 // https://html.spec.whatwg.org/#concept-script-type | 192 // https://html.spec.whatwg.org/#concept-script-type |
| 184 // "It is determined when the script is prepared" | 193 // "It is determined when the script is prepared" |
| 185 // TODO(hiroshige): Currently |script_type_| is set but ignored, and | |
| 186 // thus is handled as if it is a classic script even if type is "module" | |
| 187 // and module scripts is enabled. | |
| 188 ScriptType script_type_ = ScriptType::kClassic; | 194 ScriptType script_type_ = ScriptType::kClassic; |
| 189 | 195 |
| 190 // https://html.spec.whatwg.org/#concept-script-external | 196 // https://html.spec.whatwg.org/#concept-script-external |
| 191 // "It is determined when the script is prepared" | 197 // "It is determined when the script is prepared" |
| 192 bool is_external_script_ = false; | 198 bool is_external_script_ = false; |
| 193 | 199 |
| 194 bool have_fired_load_; | 200 bool have_fired_load_; |
| 195 | 201 |
| 196 // Same as "The parser will handle executing the script." | 202 // Same as "The parser will handle executing the script." |
| 197 bool will_be_parser_executed_; | 203 bool will_be_parser_executed_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 210 // present in the http cache, send a GET for it with an interventions | 216 // present in the http cache, send a GET for it with an interventions |
| 211 // header to allow the server to know of the intervention. This fetch | 217 // header to allow the server to know of the intervention. This fetch |
| 212 // will be using DeferOption::IdleLoad to keep it out of the critical | 218 // will be using DeferOption::IdleLoad to keep it out of the critical |
| 213 // path. | 219 // path. |
| 214 kFetchDocWrittenScriptDeferIdle, | 220 kFetchDocWrittenScriptDeferIdle, |
| 215 }; | 221 }; |
| 216 | 222 |
| 217 DocumentWriteIntervention document_write_intervention_; | 223 DocumentWriteIntervention document_write_intervention_; |
| 218 | 224 |
| 219 Member<PendingScript> pending_script_; | 225 Member<PendingScript> pending_script_; |
| 226 Member<ModulePendingScriptTreeClient> module_tree_client_; |
| 220 }; | 227 }; |
| 221 | 228 |
| 222 } // namespace blink | 229 } // namespace blink |
| 223 | 230 |
| 224 #endif // ScriptLoader_h | 231 #endif // ScriptLoader_h |
| OLD | NEW |