| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
| 15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
| 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
| 18 * | 18 * |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 #ifndef ScriptLoader_h | 21 #ifndef ScriptLoader_h |
| 22 #define ScriptLoader_h | 22 #define ScriptLoader_h |
| 23 | 23 |
| 24 #include "core/CoreExport.h" | 24 #include "core/CoreExport.h" |
| 25 #include "core/dom/PendingScript.h" | 25 #include "core/dom/PendingScript.h" |
| 26 #include "core/dom/ScriptRunner.h" | 26 #include "core/dom/ScriptRunner.h" |
| 27 #include "core/loader/resource/ScriptResource.h" | 27 #include "core/loader/resource/ScriptResource.h" |
| 28 #include "platform/loader/fetch/FetchParameters.h" | 28 #include "platform/loader/fetch/FetchParameters.h" |
| 29 #include "platform/loader/fetch/ResourceClient.h" | |
| 30 #include "platform/wtf/text/TextPosition.h" | 29 #include "platform/wtf/text/TextPosition.h" |
| 31 #include "platform/wtf/text/WTFString.h" | 30 #include "platform/wtf/text/WTFString.h" |
| 32 | 31 |
| 33 namespace blink { | 32 namespace blink { |
| 34 | 33 |
| 34 class Script; |
| 35 class ScriptElementBase; | 35 class ScriptElementBase; |
| 36 class Script; | 36 class ScriptResource; |
| 37 class ModulePendingScriptTreeClient; |
| 37 | 38 |
| 38 class CORE_EXPORT ScriptLoader : public GarbageCollectedFinalized<ScriptLoader>, | 39 class CORE_EXPORT ScriptLoader : public GarbageCollectedFinalized<ScriptLoader>, |
| 39 public PendingScriptClient { | 40 public PendingScriptClient { |
| 40 USING_GARBAGE_COLLECTED_MIXIN(ScriptLoader); | 41 USING_GARBAGE_COLLECTED_MIXIN(ScriptLoader); |
| 41 | 42 |
| 42 public: | 43 public: |
| 43 static ScriptLoader* Create(ScriptElementBase* element, | 44 static ScriptLoader* Create(ScriptElementBase* element, |
| 44 bool created_by_parser, | 45 bool created_by_parser, |
| 45 bool is_evaluated, | 46 bool is_evaluated, |
| 46 bool created_during_document_write = false) { | 47 bool created_during_document_write = false) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 return will_execute_when_document_finished_parsing_; | 88 return will_execute_when_document_finished_parsing_; |
| 88 } | 89 } |
| 89 ScriptResource* GetResource() { return resource_.Get(); } | 90 ScriptResource* GetResource() { return resource_.Get(); } |
| 90 | 91 |
| 91 void SetHaveFiredLoadEvent(bool have_fired_load) { | 92 void SetHaveFiredLoadEvent(bool have_fired_load) { |
| 92 have_fired_load_ = have_fired_load; | 93 have_fired_load_ = have_fired_load; |
| 93 } | 94 } |
| 94 bool IsParserInserted() const { return parser_inserted_; } | 95 bool IsParserInserted() const { return parser_inserted_; } |
| 95 bool AlreadyStarted() const { return already_started_; } | 96 bool AlreadyStarted() const { return already_started_; } |
| 96 bool IsNonBlocking() const { return non_blocking_; } | 97 bool IsNonBlocking() const { return non_blocking_; } |
| 98 ScriptType GetScriptType() const { return script_type_; } |
| 97 | 99 |
| 98 // Helper functions used by our parent classes. | 100 // Helper functions used by our parent classes. |
| 99 void DidNotifySubtreeInsertionsToDocument(); | 101 void DidNotifySubtreeInsertionsToDocument(); |
| 100 void ChildrenChanged(); | 102 void ChildrenChanged(); |
| 101 void HandleSourceAttribute(const String& source_url); | 103 void HandleSourceAttribute(const String& source_url); |
| 102 void HandleAsyncAttribute(); | 104 void HandleAsyncAttribute(); |
| 103 | 105 |
| 104 virtual bool IsReady() const { | 106 virtual bool IsReady() const { |
| 105 return pending_script_ && pending_script_->IsReady(); | 107 return pending_script_ && pending_script_->IsReady(); |
| 106 } | 108 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 158 |
| 157 // https://html.spec.whatwg.org/#non-blocking | 159 // https://html.spec.whatwg.org/#non-blocking |
| 158 // "Initially, script elements must have this flag set." | 160 // "Initially, script elements must have this flag set." |
| 159 bool non_blocking_ = true; | 161 bool non_blocking_ = true; |
| 160 | 162 |
| 161 // https://html.spec.whatwg.org/#ready-to-be-parser-executed | 163 // https://html.spec.whatwg.org/#ready-to-be-parser-executed |
| 162 // "Initially, script elements must have this flag unset" | 164 // "Initially, script elements must have this flag unset" |
| 163 bool ready_to_be_parser_executed_ = false; | 165 bool ready_to_be_parser_executed_ = false; |
| 164 | 166 |
| 165 // https://html.spec.whatwg.org/#concept-script-type | 167 // https://html.spec.whatwg.org/#concept-script-type |
| 166 // TODO(hiroshige): Implement "script's type". | 168 // "It is determined when the script is prepared" |
| 169 ScriptType script_type_ = ScriptType::kClassic; |
| 167 | 170 |
| 168 // https://html.spec.whatwg.org/#concept-script-external | 171 // https://html.spec.whatwg.org/#concept-script-external |
| 169 // "It is determined when the script is prepared" | 172 // "It is determined when the script is prepared" |
| 170 bool is_external_script_ = false; | 173 bool is_external_script_ = false; |
| 171 | 174 |
| 172 bool have_fired_load_; | 175 bool have_fired_load_; |
| 173 | 176 |
| 174 // Same as "The parser will handle executing the script." | 177 // Same as "The parser will handle executing the script." |
| 175 bool will_be_parser_executed_; | 178 bool will_be_parser_executed_; |
| 176 | 179 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 188 // present in the http cache, send a GET for it with an interventions | 191 // present in the http cache, send a GET for it with an interventions |
| 189 // header to allow the server to know of the intervention. This fetch | 192 // header to allow the server to know of the intervention. This fetch |
| 190 // will be using DeferOption::IdleLoad to keep it out of the critical | 193 // will be using DeferOption::IdleLoad to keep it out of the critical |
| 191 // path. | 194 // path. |
| 192 kFetchDocWrittenScriptDeferIdle, | 195 kFetchDocWrittenScriptDeferIdle, |
| 193 }; | 196 }; |
| 194 | 197 |
| 195 DocumentWriteIntervention document_write_intervention_; | 198 DocumentWriteIntervention document_write_intervention_; |
| 196 | 199 |
| 197 Member<PendingScript> pending_script_; | 200 Member<PendingScript> pending_script_; |
| 201 Member<ModulePendingScriptTreeClient> module_tree_client_; |
| 198 }; | 202 }; |
| 199 | 203 |
| 200 } // namespace blink | 204 } // namespace blink |
| 201 | 205 |
| 202 #endif // ScriptLoader_h | 206 #endif // ScriptLoader_h |
| OLD | NEW |