Title: [204221] trunk/Source/WebCore
- Revision
- 204221
- Author
- [email protected]
- Date
- 2016-08-05 23:28:24 -0700 (Fri, 05 Aug 2016)
Log Message
[ES6] Add ScriptElement::determineScriptType
https://bugs.webkit.org/show_bug.cgi?id=149576
Reviewed by Ryosuke Niwa.
Change ScriptElement::isScriptTypeSupported to ScriptElement::determineScriptType.
And introduce ScriptType, which is either "classic" or "module".
And support "module" type in ScriptElement[1, 2].
But this patch does not contain any module tag support code.
This will be implemented in the subsequent patch.
[1]: https://html.spec.whatwg.org/multipage/webappapis.html#integration-with-the-_javascript_-module-system
[2]: https://html.spec.whatwg.org/multipage/scripting.html#attr-script-type
* dom/ScriptElement.cpp:
(WebCore::ScriptElement::determineScriptType):
(WebCore::ScriptElement::prepareScript):
(WebCore::ScriptElement::isScriptTypeSupported): Deleted.
* dom/ScriptElement.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (204220 => 204221)
--- trunk/Source/WebCore/ChangeLog 2016-08-06 05:37:28 UTC (rev 204220)
+++ trunk/Source/WebCore/ChangeLog 2016-08-06 06:28:24 UTC (rev 204221)
@@ -1,3 +1,25 @@
+2016-08-05 Yusuke Suzuki <[email protected]>
+
+ [ES6] Add ScriptElement::determineScriptType
+ https://bugs.webkit.org/show_bug.cgi?id=149576
+
+ Reviewed by Ryosuke Niwa.
+
+ Change ScriptElement::isScriptTypeSupported to ScriptElement::determineScriptType.
+ And introduce ScriptType, which is either "classic" or "module".
+ And support "module" type in ScriptElement[1, 2].
+ But this patch does not contain any module tag support code.
+ This will be implemented in the subsequent patch.
+
+ [1]: https://html.spec.whatwg.org/multipage/webappapis.html#integration-with-the-_javascript_-module-system
+ [2]: https://html.spec.whatwg.org/multipage/scripting.html#attr-script-type
+
+ * dom/ScriptElement.cpp:
+ (WebCore::ScriptElement::determineScriptType):
+ (WebCore::ScriptElement::prepareScript):
+ (WebCore::ScriptElement::isScriptTypeSupported): Deleted.
+ * dom/ScriptElement.h:
+
2016-08-05 Jonathan Bedard <[email protected]>
NULL Reference Error in ElementRuleCollector
Modified: trunk/Source/WebCore/dom/ScriptElement.cpp (204220 => 204221)
--- trunk/Source/WebCore/dom/ScriptElement.cpp 2016-08-06 05:37:28 UTC (rev 204220)
+++ trunk/Source/WebCore/dom/ScriptElement.cpp 2016-08-06 06:28:24 UTC (rev 204221)
@@ -145,7 +145,7 @@
m_element.dispatchEvent(Event::create(eventNames().errorEvent, false, false));
}
-bool ScriptElement::isScriptTypeSupported(LegacyTypeSupport supportLegacyTypes) const
+Optional<ScriptElement::ScriptType> ScriptElement::determineScriptType(LegacyTypeSupport supportLegacyTypes) const
{
// FIXME: isLegacySupportedJavaScriptLanguage() is not valid HTML5. It is used here to maintain backwards compatibility with existing layout tests. The specific violations are:
// - Allowing type=_javascript_. type= should only support MIME types, such as text/_javascript_.
@@ -154,18 +154,24 @@
String language = languageAttributeValue();
if (type.isEmpty()) {
if (language.isEmpty())
- return true; // Assume text/_javascript_.
+ return ScriptType::Classic; // Assume text/_javascript_.
if (MIMETypeRegistry::isSupportedJavaScriptMIMEType("text/" + language))
- return true;
+ return ScriptType::Classic;
if (isLegacySupportedJavaScriptLanguage(language))
- return true;
- return false;
+ return ScriptType::Classic;
+ return Nullopt;
}
if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(type.stripWhiteSpace()))
- return true;
+ return ScriptType::Classic;
if (supportLegacyTypes == AllowLegacyTypeInTypeAttribute && isLegacySupportedJavaScriptLanguage(type))
- return true;
- return false;
+ return ScriptType::Classic;
+#if ENABLE(ES6_MODULES)
+ // https://html.spec.whatwg.org/multipage/scripting.html#attr-script-type
+ // Setting the attribute to an ASCII case-insensitive match for the string "module" means that the script is a module script.
+ if (equalLettersIgnoringASCIICase(type, "module"))
+ return ScriptType::Module;
+#endif
+ return Nullopt;
}
// http://dev.w3.org/html5/spec/Overview.html#prepare-a-script
@@ -191,7 +197,7 @@
if (!m_element.inDocument())
return false;
- if (!isScriptTypeSupported(supportLegacyTypes))
+ if (!determineScriptType(supportLegacyTypes))
return false;
if (wasParserInserted) {
Modified: trunk/Source/WebCore/dom/ScriptElement.h (204220 => 204221)
--- trunk/Source/WebCore/dom/ScriptElement.h 2016-08-06 05:37:28 UTC (rev 204220)
+++ trunk/Source/WebCore/dom/ScriptElement.h 2016-08-06 06:28:24 UTC (rev 204221)
@@ -53,7 +53,6 @@
// XML parser calls these
virtual void dispatchLoadEvent() = 0;
void dispatchErrorEvent();
- bool isScriptTypeSupported(LegacyTypeSupport) const;
bool haveFiredLoadEvent() const { return m_haveFiredLoad; }
bool willBeParserExecuted() const { return m_willBeParserExecuted; }
@@ -77,6 +76,9 @@
void handleAsyncAttribute();
private:
+ // https://html.spec.whatwg.org/multipage/scripting.html#concept-script-type
+ enum class ScriptType { Classic, Module };
+ Optional<ScriptType> determineScriptType(LegacyTypeSupport) const;
bool ignoresLoadRequest() const;
bool isScriptForEventSupported() const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes