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

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

Issue 2824583002: Implement <script nomodule> (Closed)
Patch Set: Move script_type declaration 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights
6 * reserved. 6 * reserved.
7 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> 7 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org>
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // for the string "module", the script's type is "module"." 208 // for the string "module", the script's type is "module"."
209 out_script_type = ScriptType::kModule; 209 out_script_type = ScriptType::kModule;
210 return true; 210 return true;
211 } 211 }
212 212
213 // - "If neither of the above conditions are true, then abort these steps 213 // - "If neither of the above conditions are true, then abort these steps
214 // at this point. No script is executed." 214 // at this point. No script is executed."
215 return false; 215 return false;
216 } 216 }
217 217
218 bool ScriptLoader::BlockForNoModule(ScriptType script_type, bool nomodule) {
219 return nomodule && script_type == ScriptType::kClassic &&
220 RuntimeEnabledFeatures::moduleScriptsEnabled();
221 }
222
218 bool ScriptLoader::IsScriptTypeSupported(LegacyTypeSupport support_legacy_types, 223 bool ScriptLoader::IsScriptTypeSupported(LegacyTypeSupport support_legacy_types,
219 ScriptType& out_script_type) const { 224 ScriptType& out_script_type) const {
220 return IsValidScriptTypeAndLanguage(element_->TypeAttributeValue(), 225 return IsValidScriptTypeAndLanguage(element_->TypeAttributeValue(),
221 element_->LanguageAttributeValue(), 226 element_->LanguageAttributeValue(),
222 support_legacy_types, out_script_type); 227 support_legacy_types, out_script_type);
223 } 228 }
224 229
225 // https://html.spec.whatwg.org/#prepare-a-script 230 // https://html.spec.whatwg.org/#prepare-a-script
226 bool ScriptLoader::PrepareScript(const TextPosition& script_start_position, 231 bool ScriptLoader::PrepareScript(const TextPosition& script_start_position,
227 LegacyTypeSupport support_legacy_types) { 232 LegacyTypeSupport support_legacy_types) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 return false; 294 return false;
290 295
291 // 10. "If scripting is disabled for the script element, then abort these 296 // 10. "If scripting is disabled for the script element, then abort these
292 // steps at this point. The script is not executed." 297 // steps at this point. The script is not executed."
293 if (!context_document->CanExecuteScripts(kAboutToExecuteScript)) 298 if (!context_document->CanExecuteScripts(kAboutToExecuteScript))
294 return false; 299 return false;
295 300
296 // 11. "If the script element has a nomodule content attribute 301 // 11. "If the script element has a nomodule content attribute
297 // and the script's type is "classic", then abort these steps. 302 // and the script's type is "classic", then abort these steps.
298 // The script is not executed." 303 // The script is not executed."
299 // TODO(japhet): Implement this step. 304 if (BlockForNoModule(script_type_, element_->NomoduleAttributeValue()))
305 return false;
300 306
301 // 13. 307 // 13.
302 if (!IsScriptForEventSupported()) 308 if (!IsScriptForEventSupported())
303 return false; 309 return false;
304 310
305 // 14. is handled below. 311 // 14. is handled below.
306 312
307 // 15. "Let CORS setting be the current state of the element's 313 // 15. "Let CORS setting be the current state of the element's
308 // crossorigin content attribute." 314 // crossorigin content attribute."
309 CrossOriginAttributeValue cross_origin = 315 CrossOriginAttributeValue cross_origin =
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 // then abort these steps at this point. The script is not executed. 858 // then abort these steps at this point. The script is not executed.
853 return DeprecatedEqualIgnoringCase(event_attribute, "onload") || 859 return DeprecatedEqualIgnoringCase(event_attribute, "onload") ||
854 DeprecatedEqualIgnoringCase(event_attribute, "onload()"); 860 DeprecatedEqualIgnoringCase(event_attribute, "onload()");
855 } 861 }
856 862
857 String ScriptLoader::ScriptContent() const { 863 String ScriptLoader::ScriptContent() const {
858 return element_->TextFromChildren(); 864 return element_->TextFromChildren();
859 } 865 }
860 866
861 } // namespace blink 867 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/ScriptLoader.h ('k') | third_party/WebKit/Source/core/html/HTMLAttributeNames.json5 » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698