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/Script.h" | 26 #include "core/dom/Script.h" |
27 #include "core/dom/ScriptRunner.h" | 27 #include "core/dom/ScriptRunner.h" |
28 #include "core/loader/resource/ScriptResource.h" | 28 #include "core/html/CrossOriginAttribute.h" |
29 #include "platform/loader/fetch/FetchParameters.h" | 29 #include "platform/loader/fetch/ResourceLoaderOptions.h" |
30 #include "platform/loader/fetch/ResourceClient.h" | |
31 #include "platform/wtf/text/TextPosition.h" | 30 #include "platform/wtf/text/TextPosition.h" |
32 #include "platform/wtf/text/WTFString.h" | 31 #include "platform/wtf/text/WTFString.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; |
| 40 class ScriptResource; |
| 41 |
39 class CORE_EXPORT ScriptLoader : public GarbageCollectedFinalized<ScriptLoader>, | 42 class CORE_EXPORT ScriptLoader : public GarbageCollectedFinalized<ScriptLoader>, |
40 public PendingScriptClient { | 43 public PendingScriptClient { |
41 USING_GARBAGE_COLLECTED_MIXIN(ScriptLoader); | 44 USING_GARBAGE_COLLECTED_MIXIN(ScriptLoader); |
42 | 45 |
43 public: | 46 public: |
44 static ScriptLoader* Create(ScriptElementBase* element, | 47 static ScriptLoader* Create(ScriptElementBase* element, |
45 bool created_by_parser, | 48 bool created_by_parser, |
46 bool is_evaluated, | 49 bool is_evaluated, |
47 bool created_during_document_write = false) { | 50 bool created_during_document_write = false) { |
48 return new ScriptLoader(element, created_by_parser, is_evaluated, | 51 return new ScriptLoader(element, created_by_parser, is_evaluated, |
(...skipping 14 matching lines...) Expand all Loading... |
63 ScriptType& out_script_type); | 66 ScriptType& out_script_type); |
64 | 67 |
65 // https://html.spec.whatwg.org/#prepare-a-script | 68 // https://html.spec.whatwg.org/#prepare-a-script |
66 bool PrepareScript(const TextPosition& script_start_position = | 69 bool PrepareScript(const TextPosition& script_start_position = |
67 TextPosition::MinimumPosition(), | 70 TextPosition::MinimumPosition(), |
68 LegacyTypeSupport = kDisallowLegacyTypeInTypeAttribute); | 71 LegacyTypeSupport = kDisallowLegacyTypeInTypeAttribute); |
69 | 72 |
70 String ScriptContent() const; | 73 String ScriptContent() const; |
71 | 74 |
72 // Creates a PendingScript for external script whose fetch is started in | 75 // Creates a PendingScript for external script whose fetch is started in |
73 // fetchScript(). | 76 // FetchClassicScript(). |
74 PendingScript* CreatePendingScript(); | 77 PendingScript* CreatePendingScript(); |
75 | 78 |
76 // Returns false if and only if execution was blocked. | 79 // Returns false if and only if execution was blocked. |
77 bool ExecuteScript(const Script*); | 80 bool ExecuteScript(const Script*); |
78 virtual void Execute(); | 81 virtual void Execute(); |
79 | 82 |
80 // XML parser calls these | 83 // XML parser calls these |
81 void DispatchLoadEvent(); | 84 void DispatchLoadEvent(); |
82 void DispatchErrorEvent(); | 85 void DispatchErrorEvent(); |
83 bool IsScriptTypeSupported(LegacyTypeSupport, | 86 bool IsScriptTypeSupported(LegacyTypeSupport, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 protected: | 128 protected: |
126 ScriptLoader(ScriptElementBase*, | 129 ScriptLoader(ScriptElementBase*, |
127 bool created_by_parser, | 130 bool created_by_parser, |
128 bool is_evaluated, | 131 bool is_evaluated, |
129 bool created_during_document_write); | 132 bool created_during_document_write); |
130 | 133 |
131 private: | 134 private: |
132 bool IgnoresLoadRequest() const; | 135 bool IgnoresLoadRequest() const; |
133 bool IsScriptForEventSupported() const; | 136 bool IsScriptForEventSupported() const; |
134 | 137 |
135 bool FetchScript(const String& source_url, | 138 // FetchClassicScript corresponds to Step 21.6 of |
136 const String& encoding, | 139 // https://html.spec.whatwg.org/#prepare-a-script |
137 FetchParameters::DeferOption); | 140 // and must NOT be called from outside of PendingScript(). |
| 141 // |
| 142 // https://html.spec.whatwg.org/#fetch-a-classic-script |
| 143 bool FetchClassicScript(const KURL&, |
| 144 ResourceFetcher*, |
| 145 const String& nonce, |
| 146 const IntegrityMetadataSet&, |
| 147 ParserDisposition, |
| 148 CrossOriginAttributeValue, |
| 149 SecurityOrigin*, |
| 150 const String& encoding); |
| 151 |
138 bool DoExecuteScript(const Script*); | 152 bool DoExecuteScript(const Script*); |
139 | 153 |
140 // Clears the connection to the PendingScript. | 154 // Clears the connection to the PendingScript. |
141 void DetachPendingScript(); | 155 void DetachPendingScript(); |
142 | 156 |
143 // PendingScriptClient | 157 // PendingScriptClient |
144 void PendingScriptFinished(PendingScript*) override; | 158 void PendingScriptFinished(PendingScript*) override; |
145 | 159 |
146 Member<ScriptElementBase> element_; | 160 Member<ScriptElementBase> element_; |
147 Member<ScriptResource> resource_; | 161 Member<ScriptResource> resource_; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 }; | 215 }; |
202 | 216 |
203 DocumentWriteIntervention document_write_intervention_; | 217 DocumentWriteIntervention document_write_intervention_; |
204 | 218 |
205 Member<PendingScript> pending_script_; | 219 Member<PendingScript> pending_script_; |
206 }; | 220 }; |
207 | 221 |
208 } // namespace blink | 222 } // namespace blink |
209 | 223 |
210 #endif // ScriptLoader_h | 224 #endif // ScriptLoader_h |
OLD | NEW |