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

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

Issue 2821803002: Introduce ScriptLoader::script_type_ (Closed)
Patch Set: 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
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
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 ~ScriptLoader() override; 51 ~ScriptLoader() override;
52 DECLARE_VIRTUAL_TRACE(); 52 DECLARE_VIRTUAL_TRACE();
53 53
54 enum LegacyTypeSupport { 54 enum LegacyTypeSupport {
55 kDisallowLegacyTypeInTypeAttribute, 55 kDisallowLegacyTypeInTypeAttribute,
56 kAllowLegacyTypeInTypeAttribute 56 kAllowLegacyTypeInTypeAttribute
57 }; 57 };
58 static bool IsValidScriptTypeAndLanguage( 58 static bool IsValidScriptTypeAndLanguage(
59 const String& type_attribute_value, 59 const String& type_attribute_value,
60 const String& language_attribute_value, 60 const String& language_attribute_value,
61 LegacyTypeSupport support_legacy_types); 61 LegacyTypeSupport support_legacy_types,
62 ScriptType& out_script_type);
62 63
63 // https://html.spec.whatwg.org/#prepare-a-script 64 // https://html.spec.whatwg.org/#prepare-a-script
64 bool PrepareScript(const TextPosition& script_start_position = 65 bool PrepareScript(const TextPosition& script_start_position =
65 TextPosition::MinimumPosition(), 66 TextPosition::MinimumPosition(),
66 LegacyTypeSupport = kDisallowLegacyTypeInTypeAttribute); 67 LegacyTypeSupport = kDisallowLegacyTypeInTypeAttribute);
67 68
68 String ScriptContent() const; 69 String ScriptContent() const;
69 70
70 // Creates a PendingScript for external script whose fetch is started in 71 // Creates a PendingScript for external script whose fetch is started in
71 // fetchScript(). 72 // fetchScript().
72 PendingScript* CreatePendingScript(); 73 PendingScript* CreatePendingScript();
73 74
74 // Returns false if and only if execution was blocked. 75 // Returns false if and only if execution was blocked.
75 bool ExecuteScript(const Script*); 76 bool ExecuteScript(const Script*);
76 virtual void Execute(); 77 virtual void Execute();
77 78
78 // XML parser calls these 79 // XML parser calls these
79 void DispatchLoadEvent(); 80 void DispatchLoadEvent();
80 void DispatchErrorEvent(); 81 void DispatchErrorEvent();
81 bool IsScriptTypeSupported(LegacyTypeSupport) const; 82 bool IsScriptTypeSupported(LegacyTypeSupport,
83 ScriptType& out_script_type) const;
82 84
83 bool HaveFiredLoadEvent() const { return have_fired_load_; } 85 bool HaveFiredLoadEvent() const { return have_fired_load_; }
84 bool WillBeParserExecuted() const { return will_be_parser_executed_; } 86 bool WillBeParserExecuted() const { return will_be_parser_executed_; }
85 bool ReadyToBeParserExecuted() const { return ready_to_be_parser_executed_; } 87 bool ReadyToBeParserExecuted() const { return ready_to_be_parser_executed_; }
86 bool WillExecuteWhenDocumentFinishedParsing() const { 88 bool WillExecuteWhenDocumentFinishedParsing() const {
87 return will_execute_when_document_finished_parsing_; 89 return will_execute_when_document_finished_parsing_;
88 } 90 }
89 ScriptResource* GetResource() { return resource_.Get(); } 91 ScriptResource* GetResource() { return resource_.Get(); }
90 92
91 void SetHaveFiredLoadEvent(bool have_fired_load) { 93 void SetHaveFiredLoadEvent(bool have_fired_load) {
92 have_fired_load_ = have_fired_load; 94 have_fired_load_ = have_fired_load;
93 } 95 }
94 bool IsParserInserted() const { return parser_inserted_; } 96 bool IsParserInserted() const { return parser_inserted_; }
95 bool AlreadyStarted() const { return already_started_; } 97 bool AlreadyStarted() const { return already_started_; }
96 bool IsNonBlocking() const { return non_blocking_; } 98 bool IsNonBlocking() const { return non_blocking_; }
99 ScriptType GetScriptType() const { return script_type_; }
97 100
98 // Helper functions used by our parent classes. 101 // Helper functions used by our parent classes.
99 void DidNotifySubtreeInsertionsToDocument(); 102 void DidNotifySubtreeInsertionsToDocument();
100 void ChildrenChanged(); 103 void ChildrenChanged();
101 void HandleSourceAttribute(const String& source_url); 104 void HandleSourceAttribute(const String& source_url);
102 void HandleAsyncAttribute(); 105 void HandleAsyncAttribute();
103 106
104 virtual bool IsReady() const { 107 virtual bool IsReady() const {
105 return pending_script_ && pending_script_->IsReady(); 108 return pending_script_ && pending_script_->IsReady();
106 } 109 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 159
157 // https://html.spec.whatwg.org/#non-blocking 160 // https://html.spec.whatwg.org/#non-blocking
158 // "Initially, script elements must have this flag set." 161 // "Initially, script elements must have this flag set."
159 bool non_blocking_ = true; 162 bool non_blocking_ = true;
160 163
161 // https://html.spec.whatwg.org/#ready-to-be-parser-executed 164 // https://html.spec.whatwg.org/#ready-to-be-parser-executed
162 // "Initially, script elements must have this flag unset" 165 // "Initially, script elements must have this flag unset"
163 bool ready_to_be_parser_executed_ = false; 166 bool ready_to_be_parser_executed_ = false;
164 167
165 // https://html.spec.whatwg.org/#concept-script-type 168 // https://html.spec.whatwg.org/#concept-script-type
166 // TODO(hiroshige): Implement "script's type". 169 // "It is determined when the script is prepared"
170 // TODO(hiroshige): Currently |script_type_| is set but ignored, and
171 // thus is handled as if it is a classic script even if type is "module"
172 // and module scripts is enabled.
173 ScriptType script_type_ = ScriptType::kClassic;
kouhei (in TOK) 2017/04/15 01:18:23 Should we have "invalid" ScriptType so that we can
167 174
168 // https://html.spec.whatwg.org/#concept-script-external 175 // https://html.spec.whatwg.org/#concept-script-external
169 // "It is determined when the script is prepared" 176 // "It is determined when the script is prepared"
170 bool is_external_script_ = false; 177 bool is_external_script_ = false;
171 178
172 bool have_fired_load_; 179 bool have_fired_load_;
173 180
174 // Same as "The parser will handle executing the script." 181 // Same as "The parser will handle executing the script."
175 bool will_be_parser_executed_; 182 bool will_be_parser_executed_;
176 183
(...skipping 16 matching lines...) Expand all
193 }; 200 };
194 201
195 DocumentWriteIntervention document_write_intervention_; 202 DocumentWriteIntervention document_write_intervention_;
196 203
197 Member<PendingScript> pending_script_; 204 Member<PendingScript> pending_script_;
198 }; 205 };
199 206
200 } // namespace blink 207 } // namespace blink
201 208
202 #endif // ScriptLoader_h 209 #endif // ScriptLoader_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698