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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 bool willExecuteWhenDocumentFinishedParsing() const { | 84 bool willExecuteWhenDocumentFinishedParsing() const { |
85 return m_willExecuteWhenDocumentFinishedParsing; | 85 return m_willExecuteWhenDocumentFinishedParsing; |
86 } | 86 } |
87 ScriptResource* resource() { return m_resource.get(); } | 87 ScriptResource* resource() { return m_resource.get(); } |
88 | 88 |
89 void setHaveFiredLoadEvent(bool haveFiredLoad) { | 89 void setHaveFiredLoadEvent(bool haveFiredLoad) { |
90 m_haveFiredLoad = haveFiredLoad; | 90 m_haveFiredLoad = haveFiredLoad; |
91 } | 91 } |
92 bool isParserInserted() const { return m_parserInserted; } | 92 bool isParserInserted() const { return m_parserInserted; } |
93 bool alreadyStarted() const { return m_alreadyStarted; } | 93 bool alreadyStarted() const { return m_alreadyStarted; } |
94 bool forceAsync() const { return m_forceAsync; } | 94 bool isNonBlocking() const { return m_nonBlocking; } |
95 | 95 |
96 // Helper functions used by our parent classes. | 96 // Helper functions used by our parent classes. |
97 void didNotifySubtreeInsertionsToDocument(); | 97 void didNotifySubtreeInsertionsToDocument(); |
98 void childrenChanged(); | 98 void childrenChanged(); |
99 void handleSourceAttribute(const String& sourceUrl); | 99 void handleSourceAttribute(const String& sourceUrl); |
100 void handleAsyncAttribute(); | 100 void handleAsyncAttribute(); |
101 | 101 |
102 virtual bool isReady() const { | 102 virtual bool isReady() const { |
103 return m_pendingScript && m_pendingScript->isReady(); | 103 return m_pendingScript && m_pendingScript->isReady(); |
104 } | 104 } |
(...skipping 30 matching lines...) Expand all Loading... |
135 | 135 |
136 ScriptLoaderClient* client() const; | 136 ScriptLoaderClient* client() const; |
137 | 137 |
138 // PendingScriptClient | 138 // PendingScriptClient |
139 void pendingScriptFinished(PendingScript*) override; | 139 void pendingScriptFinished(PendingScript*) override; |
140 | 140 |
141 Member<Element> m_element; | 141 Member<Element> m_element; |
142 Member<ScriptResource> m_resource; | 142 Member<ScriptResource> m_resource; |
143 WTF::OrdinalNumber m_startLineNumber; | 143 WTF::OrdinalNumber m_startLineNumber; |
144 | 144 |
145 bool m_parserInserted : 1; | 145 // https://html.spec.whatwg.org/#script-processing-model |
146 bool m_isExternalScript : 1; | 146 // "A script element has several associated pieces of state.": |
147 bool m_alreadyStarted : 1; | 147 |
148 bool m_haveFiredLoad : 1; | 148 // https://html.spec.whatwg.org/#already-started |
| 149 // "Initially, script elements must have this flag unset" |
| 150 bool m_alreadyStarted = false; |
| 151 |
| 152 // https://html.spec.whatwg.org/#parser-inserted |
| 153 // "Initially, script elements must have this flag unset." |
| 154 bool m_parserInserted = false; |
| 155 |
| 156 // https://html.spec.whatwg.org/#non-blocking |
| 157 // "Initially, script elements must have this flag set." |
| 158 bool m_nonBlocking = true; |
| 159 |
| 160 // https://html.spec.whatwg.org/#ready-to-be-parser-executed |
| 161 // "Initially, script elements must have this flag unset" |
| 162 bool m_readyToBeParserExecuted = false; |
| 163 |
| 164 // https://html.spec.whatwg.org/#concept-script-type |
| 165 // TODO(hiroshige): Implement "script's type". |
| 166 |
| 167 // https://html.spec.whatwg.org/#concept-script-external |
| 168 // "It is determined when the script is prepared" |
| 169 bool m_isExternalScript = false; |
| 170 |
| 171 bool m_haveFiredLoad; |
| 172 |
149 // Same as "The parser will handle executing the script." | 173 // Same as "The parser will handle executing the script." |
150 bool m_willBeParserExecuted : 1; | 174 bool m_willBeParserExecuted; |
151 bool m_readyToBeParserExecuted : 1; | 175 |
152 bool m_willExecuteWhenDocumentFinishedParsing : 1; | 176 bool m_willExecuteWhenDocumentFinishedParsing; |
153 bool m_forceAsync : 1; | 177 |
154 const bool m_createdDuringDocumentWrite : 1; | 178 const bool m_createdDuringDocumentWrite; |
155 | 179 |
156 ScriptRunner::AsyncExecutionType m_asyncExecType; | 180 ScriptRunner::AsyncExecutionType m_asyncExecType; |
157 enum DocumentWriteIntervention { | 181 enum DocumentWriteIntervention { |
158 DocumentWriteInterventionNone = 0, | 182 DocumentWriteInterventionNone = 0, |
159 // Based on what shouldDisallowFetchForMainFrameScript() returns. | 183 // Based on what shouldDisallowFetchForMainFrameScript() returns. |
160 // This script will be blocked if not present in http cache. | 184 // This script will be blocked if not present in http cache. |
161 DoNotFetchDocWrittenScript, | 185 DoNotFetchDocWrittenScript, |
162 // If a parser blocking doc.written script was not fetched and was not | 186 // If a parser blocking doc.written script was not fetched and was not |
163 // present in the http cache, send a GET for it with an interventions | 187 // present in the http cache, send a GET for it with an interventions |
164 // header to allow the server to know of the intervention. This fetch | 188 // header to allow the server to know of the intervention. This fetch |
165 // will be using DeferOption::IdleLoad to keep it out of the critical | 189 // will be using DeferOption::IdleLoad to keep it out of the critical |
166 // path. | 190 // path. |
167 FetchDocWrittenScriptDeferIdle, | 191 FetchDocWrittenScriptDeferIdle, |
168 }; | 192 }; |
169 | 193 |
170 DocumentWriteIntervention m_documentWriteIntervention; | 194 DocumentWriteIntervention m_documentWriteIntervention; |
171 | 195 |
172 Member<PendingScript> m_pendingScript; | 196 Member<PendingScript> m_pendingScript; |
173 }; | 197 }; |
174 | 198 |
175 ScriptLoader* toScriptLoaderIfPossible(Element*); | 199 ScriptLoader* toScriptLoaderIfPossible(Element*); |
176 | 200 |
177 } // namespace blink | 201 } // namespace blink |
178 | 202 |
179 #endif // ScriptLoader_h | 203 #endif // ScriptLoader_h |
OLD | NEW |