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 14 matching lines...) Expand all Loading... |
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/FetchRequest.h" | 28 #include "platform/loader/fetch/FetchRequest.h" |
29 #include "platform/loader/fetch/ResourceClient.h" | 29 #include "platform/loader/fetch/ResourceClient.h" |
30 #include "wtf/text/TextPosition.h" | 30 #include "wtf/text/TextPosition.h" |
31 #include "wtf/text/WTFString.h" | 31 #include "wtf/text/WTFString.h" |
32 | 32 |
33 namespace blink { | 33 namespace blink { |
34 | 34 |
35 class LocalFrame; | |
36 class ScriptElementBase; | 35 class ScriptElementBase; |
37 class ScriptSourceCode; | 36 class Script; |
38 | 37 |
39 class CORE_EXPORT ScriptLoader : public GarbageCollectedFinalized<ScriptLoader>, | 38 class CORE_EXPORT ScriptLoader : public GarbageCollectedFinalized<ScriptLoader>, |
40 public PendingScriptClient { | 39 public PendingScriptClient { |
41 USING_GARBAGE_COLLECTED_MIXIN(ScriptLoader); | 40 USING_GARBAGE_COLLECTED_MIXIN(ScriptLoader); |
42 | 41 |
43 public: | 42 public: |
44 static ScriptLoader* create(ScriptElementBase* element, | 43 static ScriptLoader* create(ScriptElementBase* element, |
45 bool createdByParser, | 44 bool createdByParser, |
46 bool isEvaluated, | 45 bool isEvaluated, |
47 bool createdDuringDocumentWrite = false) { | 46 bool createdDuringDocumentWrite = false) { |
(...skipping 13 matching lines...) Expand all Loading... |
61 const String& languageAttributeValue, | 60 const String& languageAttributeValue, |
62 LegacyTypeSupport supportLegacyTypes); | 61 LegacyTypeSupport supportLegacyTypes); |
63 | 62 |
64 // https://html.spec.whatwg.org/#prepare-a-script | 63 // https://html.spec.whatwg.org/#prepare-a-script |
65 bool prepareScript( | 64 bool prepareScript( |
66 const TextPosition& scriptStartPosition = TextPosition::minimumPosition(), | 65 const TextPosition& scriptStartPosition = TextPosition::minimumPosition(), |
67 LegacyTypeSupport = DisallowLegacyTypeInTypeAttribute); | 66 LegacyTypeSupport = DisallowLegacyTypeInTypeAttribute); |
68 | 67 |
69 String scriptContent() const; | 68 String scriptContent() const; |
70 // Returns false if and only if execution was blocked. | 69 // Returns false if and only if execution was blocked. |
71 bool executeScript(const ScriptSourceCode&); | 70 bool executeScript(const Script*); |
72 virtual void execute(); | 71 virtual void execute(); |
73 | 72 |
74 // XML parser calls these | 73 // XML parser calls these |
75 void dispatchLoadEvent(); | 74 void dispatchLoadEvent(); |
76 void dispatchErrorEvent(); | 75 void dispatchErrorEvent(); |
77 bool isScriptTypeSupported(LegacyTypeSupport) const; | 76 bool isScriptTypeSupported(LegacyTypeSupport) const; |
78 | 77 |
79 bool haveFiredLoadEvent() const { return m_haveFiredLoad; } | 78 bool haveFiredLoadEvent() const { return m_haveFiredLoad; } |
80 bool willBeParserExecuted() const { return m_willBeParserExecuted; } | 79 bool willBeParserExecuted() const { return m_willBeParserExecuted; } |
81 bool readyToBeParserExecuted() const { return m_readyToBeParserExecuted; } | 80 bool readyToBeParserExecuted() const { return m_readyToBeParserExecuted; } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 113 |
115 protected: | 114 protected: |
116 ScriptLoader(ScriptElementBase*, | 115 ScriptLoader(ScriptElementBase*, |
117 bool createdByParser, | 116 bool createdByParser, |
118 bool isEvaluated, | 117 bool isEvaluated, |
119 bool createdDuringDocumentWrite); | 118 bool createdDuringDocumentWrite); |
120 | 119 |
121 private: | 120 private: |
122 bool ignoresLoadRequest() const; | 121 bool ignoresLoadRequest() const; |
123 bool isScriptForEventSupported() const; | 122 bool isScriptForEventSupported() const; |
124 void logScriptMIMEType(LocalFrame*, ScriptResource*, const String&); | |
125 | 123 |
126 bool fetchScript(const String& sourceUrl, | 124 bool fetchScript(const String& sourceUrl, |
127 const String& encoding, | 125 const String& encoding, |
128 FetchRequest::DeferOption); | 126 FetchRequest::DeferOption); |
129 bool doExecuteScript(const ScriptSourceCode&); | 127 bool doExecuteScript(const Script*); |
130 | 128 |
131 // Clears the connection to the PendingScript. | 129 // Clears the connection to the PendingScript. |
132 void detachPendingScript(); | 130 void detachPendingScript(); |
133 | 131 |
134 // PendingScriptClient | 132 // PendingScriptClient |
135 void pendingScriptFinished(PendingScript*) override; | 133 void pendingScriptFinished(PendingScript*) override; |
136 | 134 |
137 Member<ScriptElementBase> m_element; | 135 Member<ScriptElementBase> m_element; |
138 Member<ScriptResource> m_resource; | 136 Member<ScriptResource> m_resource; |
139 WTF::OrdinalNumber m_startLineNumber; | 137 WTF::OrdinalNumber m_startLineNumber; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 }; | 186 }; |
189 | 187 |
190 DocumentWriteIntervention m_documentWriteIntervention; | 188 DocumentWriteIntervention m_documentWriteIntervention; |
191 | 189 |
192 Member<PendingScript> m_pendingScript; | 190 Member<PendingScript> m_pendingScript; |
193 }; | 191 }; |
194 | 192 |
195 } // namespace blink | 193 } // namespace blink |
196 | 194 |
197 #endif // ScriptLoader_h | 195 #endif // ScriptLoader_h |
OLD | NEW |