Changeset 204221 in webkit


Ignore:
Timestamp:
Aug 5, 2016 11:28:24 PM (8 years ago)
Author:
Yusuke Suzuki
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:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r204220 r204221  
     12016-08-05  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        [ES6] Add ScriptElement::determineScriptType
     4        https://bugs.webkit.org/show_bug.cgi?id=149576
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Change ScriptElement::isScriptTypeSupported to ScriptElement::determineScriptType.
     9        And introduce ScriptType, which is either "classic" or "module".
     10        And support "module" type in ScriptElement[1, 2].
     11        But this patch does not contain any module tag support code.
     12        This will be implemented in the subsequent patch.
     13
     14        [1]: https://html.spec.whatwg.org/multipage/webappapis.html#integration-with-the-javascript-module-system
     15        [2]: https://html.spec.whatwg.org/multipage/scripting.html#attr-script-type
     16
     17        * dom/ScriptElement.cpp:
     18        (WebCore::ScriptElement::determineScriptType):
     19        (WebCore::ScriptElement::prepareScript):
     20        (WebCore::ScriptElement::isScriptTypeSupported): Deleted.
     21        * dom/ScriptElement.h:
     22
    1232016-08-05  Jonathan Bedard  <jbedard@apple.com>
    224
  • trunk/Source/WebCore/dom/ScriptElement.cpp

    r204014 r204221  
    146146}
    147147
    148 bool ScriptElement::isScriptTypeSupported(LegacyTypeSupport supportLegacyTypes) const
     148Optional<ScriptElement::ScriptType> ScriptElement::determineScriptType(LegacyTypeSupport supportLegacyTypes) const
    149149{
    150150    // FIXME: isLegacySupportedJavaScriptLanguage() is not valid HTML5. It is used here to maintain backwards compatibility with existing layout tests. The specific violations are:
     
    155155    if (type.isEmpty()) {
    156156        if (language.isEmpty())
    157             return true; // Assume text/javascript.
     157            return ScriptType::Classic; // Assume text/javascript.
    158158        if (MIMETypeRegistry::isSupportedJavaScriptMIMEType("text/" + language))
    159             return true;
     159            return ScriptType::Classic;
    160160        if (isLegacySupportedJavaScriptLanguage(language))
    161             return true;
    162         return false;
     161            return ScriptType::Classic;
     162        return Nullopt;
    163163    }
    164164    if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(type.stripWhiteSpace()))
    165         return true;
     165        return ScriptType::Classic;
    166166    if (supportLegacyTypes == AllowLegacyTypeInTypeAttribute && isLegacySupportedJavaScriptLanguage(type))
    167         return true;
    168     return false;
     167        return ScriptType::Classic;
     168#if ENABLE(ES6_MODULES)
     169    // https://html.spec.whatwg.org/multipage/scripting.html#attr-script-type
     170    // Setting the attribute to an ASCII case-insensitive match for the string "module" means that the script is a module script.
     171    if (equalLettersIgnoringASCIICase(type, "module"))
     172        return ScriptType::Module;
     173#endif
     174    return Nullopt;
    169175}
    170176
     
    192198        return false;
    193199
    194     if (!isScriptTypeSupported(supportLegacyTypes))
     200    if (!determineScriptType(supportLegacyTypes))
    195201        return false;
    196202
  • trunk/Source/WebCore/dom/ScriptElement.h

    r200340 r204221  
    5454    virtual void dispatchLoadEvent() = 0;
    5555    void dispatchErrorEvent();
    56     bool isScriptTypeSupported(LegacyTypeSupport) const;
    5756
    5857    bool haveFiredLoadEvent() const { return m_haveFiredLoad; }
     
    7877
    7978private:
     79    // https://html.spec.whatwg.org/multipage/scripting.html#concept-script-type
     80    enum class ScriptType { Classic, Module };
     81    Optional<ScriptType> determineScriptType(LegacyTypeSupport) const;
    8082    bool ignoresLoadRequest() const;
    8183    bool isScriptForEventSupported() const;
Note: See TracChangeset for help on using the changeset viewer.