Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: third_party/WebKit/Source/core/dom/ScriptLoader.h

Issue 2821803002: Introduce ScriptLoader::script_type_ (Closed)
Patch Set: Add missing include Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/ScriptLoader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ScriptRunner.h" 27 #include "core/dom/ScriptRunner.h"
27 #include "core/loader/resource/ScriptResource.h" 28 #include "core/loader/resource/ScriptResource.h"
28 #include "platform/loader/fetch/FetchParameters.h" 29 #include "platform/loader/fetch/FetchParameters.h"
29 #include "platform/loader/fetch/ResourceClient.h" 30 #include "platform/loader/fetch/ResourceClient.h"
30 #include "platform/wtf/text/TextPosition.h" 31 #include "platform/wtf/text/TextPosition.h"
31 #include "platform/wtf/text/WTFString.h" 32 #include "platform/wtf/text/WTFString.h"
32 33
33 namespace blink { 34 namespace blink {
34 35
35 class ScriptElementBase; 36 class ScriptElementBase;
(...skipping 15 matching lines...) Expand all
51 ~ScriptLoader() override; 52 ~ScriptLoader() override;
52 DECLARE_VIRTUAL_TRACE(); 53 DECLARE_VIRTUAL_TRACE();
53 54
54 enum LegacyTypeSupport { 55 enum LegacyTypeSupport {
55 kDisallowLegacyTypeInTypeAttribute, 56 kDisallowLegacyTypeInTypeAttribute,
56 kAllowLegacyTypeInTypeAttribute 57 kAllowLegacyTypeInTypeAttribute
57 }; 58 };
58 static bool IsValidScriptTypeAndLanguage( 59 static bool IsValidScriptTypeAndLanguage(
59 const String& type_attribute_value, 60 const String& type_attribute_value,
60 const String& language_attribute_value, 61 const String& language_attribute_value,
61 LegacyTypeSupport support_legacy_types); 62 LegacyTypeSupport support_legacy_types,
63 ScriptType& out_script_type);
62 64
63 // https://html.spec.whatwg.org/#prepare-a-script 65 // https://html.spec.whatwg.org/#prepare-a-script
64 bool PrepareScript(const TextPosition& script_start_position = 66 bool PrepareScript(const TextPosition& script_start_position =
65 TextPosition::MinimumPosition(), 67 TextPosition::MinimumPosition(),
66 LegacyTypeSupport = kDisallowLegacyTypeInTypeAttribute); 68 LegacyTypeSupport = kDisallowLegacyTypeInTypeAttribute);
67 69
68 String ScriptContent() const; 70 String ScriptContent() const;
69 71
70 // Creates a PendingScript for external script whose fetch is started in 72 // Creates a PendingScript for external script whose fetch is started in
71 // fetchScript(). 73 // fetchScript().
72 PendingScript* CreatePendingScript(); 74 PendingScript* CreatePendingScript();
73 75
74 // Returns false if and only if execution was blocked. 76 // Returns false if and only if execution was blocked.
75 bool ExecuteScript(const Script*); 77 bool ExecuteScript(const Script*);
76 virtual void Execute(); 78 virtual void Execute();
77 79
78 // XML parser calls these 80 // XML parser calls these
79 void DispatchLoadEvent(); 81 void DispatchLoadEvent();
80 void DispatchErrorEvent(); 82 void DispatchErrorEvent();
81 bool IsScriptTypeSupported(LegacyTypeSupport) const; 83 bool IsScriptTypeSupported(LegacyTypeSupport,
84 ScriptType& out_script_type) const;
82 85
83 bool HaveFiredLoadEvent() const { return have_fired_load_; } 86 bool HaveFiredLoadEvent() const { return have_fired_load_; }
84 bool WillBeParserExecuted() const { return will_be_parser_executed_; } 87 bool WillBeParserExecuted() const { return will_be_parser_executed_; }
85 bool ReadyToBeParserExecuted() const { return ready_to_be_parser_executed_; } 88 bool ReadyToBeParserExecuted() const { return ready_to_be_parser_executed_; }
86 bool WillExecuteWhenDocumentFinishedParsing() const { 89 bool WillExecuteWhenDocumentFinishedParsing() const {
87 return will_execute_when_document_finished_parsing_; 90 return will_execute_when_document_finished_parsing_;
88 } 91 }
89 ScriptResource* GetResource() { return resource_.Get(); } 92 ScriptResource* GetResource() { return resource_.Get(); }
90 93
91 void SetHaveFiredLoadEvent(bool have_fired_load) { 94 void SetHaveFiredLoadEvent(bool have_fired_load) {
92 have_fired_load_ = have_fired_load; 95 have_fired_load_ = have_fired_load;
93 } 96 }
94 bool IsParserInserted() const { return parser_inserted_; } 97 bool IsParserInserted() const { return parser_inserted_; }
95 bool AlreadyStarted() const { return already_started_; } 98 bool AlreadyStarted() const { return already_started_; }
96 bool IsNonBlocking() const { return non_blocking_; } 99 bool IsNonBlocking() const { return non_blocking_; }
100 ScriptType GetScriptType() const { return script_type_; }
97 101
98 // Helper functions used by our parent classes. 102 // Helper functions used by our parent classes.
99 void DidNotifySubtreeInsertionsToDocument(); 103 void DidNotifySubtreeInsertionsToDocument();
100 void ChildrenChanged(); 104 void ChildrenChanged();
101 void HandleSourceAttribute(const String& source_url); 105 void HandleSourceAttribute(const String& source_url);
102 void HandleAsyncAttribute(); 106 void HandleAsyncAttribute();
103 107
104 virtual bool IsReady() const { 108 virtual bool IsReady() const {
105 return pending_script_ && pending_script_->IsReady(); 109 return pending_script_ && pending_script_->IsReady();
106 } 110 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 160
157 // https://html.spec.whatwg.org/#non-blocking 161 // https://html.spec.whatwg.org/#non-blocking
158 // "Initially, script elements must have this flag set." 162 // "Initially, script elements must have this flag set."
159 bool non_blocking_ = true; 163 bool non_blocking_ = true;
160 164
161 // https://html.spec.whatwg.org/#ready-to-be-parser-executed 165 // https://html.spec.whatwg.org/#ready-to-be-parser-executed
162 // "Initially, script elements must have this flag unset" 166 // "Initially, script elements must have this flag unset"
163 bool ready_to_be_parser_executed_ = false; 167 bool ready_to_be_parser_executed_ = false;
164 168
165 // https://html.spec.whatwg.org/#concept-script-type 169 // https://html.spec.whatwg.org/#concept-script-type
166 // TODO(hiroshige): Implement "script's type". 170 // "It is determined when the script is prepared"
171 // TODO(hiroshige): Currently |script_type_| is set but ignored, and
172 // thus is handled as if it is a classic script even if type is "module"
173 // and module scripts is enabled.
174 ScriptType script_type_ = ScriptType::kClassic;
167 175
168 // https://html.spec.whatwg.org/#concept-script-external 176 // https://html.spec.whatwg.org/#concept-script-external
169 // "It is determined when the script is prepared" 177 // "It is determined when the script is prepared"
170 bool is_external_script_ = false; 178 bool is_external_script_ = false;
171 179
172 bool have_fired_load_; 180 bool have_fired_load_;
173 181
174 // Same as "The parser will handle executing the script." 182 // Same as "The parser will handle executing the script."
175 bool will_be_parser_executed_; 183 bool will_be_parser_executed_;
176 184
(...skipping 16 matching lines...) Expand all
193 }; 201 };
194 202
195 DocumentWriteIntervention document_write_intervention_; 203 DocumentWriteIntervention document_write_intervention_;
196 204
197 Member<PendingScript> pending_script_; 205 Member<PendingScript> pending_script_;
198 }; 206 };
199 207
200 } // namespace blink 208 } // namespace blink
201 209
202 #endif // ScriptLoader_h 210 #endif // ScriptLoader_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/ScriptLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698