Changeset 61518 in webkit


Ignore:
Timestamp:
Jun 20, 2010 6:05:16 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-06-20 Tony Gentilcore <tonyg@chromium.org>

Reviewed by Eric Seidel.

Test to make sure parsing of async attribute works for HTML script tags
and test to make sure that async is not parsed for SVG script tags.
https://bugs.webkit.org/show_bug.cgi?id=39026

  • fast/dom/HTMLScriptElement/script-async-attr-expected.txt: Added.
  • fast/dom/HTMLScriptElement/script-async-attr.html: Added.
  • svg/dom/SVGScriptElement/script-async-attr-expected.txt: Added.
  • svg/dom/SVGScriptElement/script-async-attr.svg: Added.

2010-06-20 Tony Gentilcore <tonyg@chromium.org>

Reviewed by Eric Seidel.

Recognize async attribute on HTML script tags.
https://bugs.webkit.org/show_bug.cgi?id=39026

This does not implement async behavior, it only parses the async
attribute for HTML script tags. SVG script tags continue to not
support the async attribute.

Tests: fast/dom/HTMLScriptElement/script-async-attr.html

svg/dom/SVGScriptElement/script-async-attr.svg

  • dom/ScriptElement.cpp: (WebCore::ScriptElementData::isAsynchronous): (WebCore::ScriptElementData::isDeferred):
  • dom/ScriptElement.h:
  • html/HTMLAttributeNames.in:
  • html/HTMLScriptElement.cpp: (WebCore::HTMLScriptElement::async): (WebCore::HTMLScriptElement::setAsync): (WebCore::HTMLScriptElement::defer): (WebCore::HTMLScriptElement::asyncAttributeValue): (WebCore::HTMLScriptElement::deferAttributeValue):
  • html/HTMLScriptElement.h:
  • html/HTMLScriptElement.idl:
  • svg/SVGScriptElement.cpp: (WebCore::SVGScriptElement::asyncAttributeValue): (WebCore::SVGScriptElement::deferAttributeValue):
  • svg/SVGScriptElement.h:
Location:
trunk
Files:
4 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r61517 r61518  
     12010-06-20  Tony Gentilcore  <tonyg@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Test to make sure parsing of async attribute works for HTML script tags
     6        and test to make sure that async is not parsed for SVG script tags.
     7        https://bugs.webkit.org/show_bug.cgi?id=39026
     8
     9        * fast/dom/HTMLScriptElement/script-async-attr-expected.txt: Added.
     10        * fast/dom/HTMLScriptElement/script-async-attr.html: Added.
     11        * svg/dom/SVGScriptElement/script-async-attr-expected.txt: Added.
     12        * svg/dom/SVGScriptElement/script-async-attr.svg: Added.
     13
    1142010-06-20  Tony Chang  <tony@chromium.org>
    215
  • trunk/WebCore/ChangeLog

    r61514 r61518  
     12010-06-20  Tony Gentilcore  <tonyg@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Recognize async attribute on HTML script tags.
     6        https://bugs.webkit.org/show_bug.cgi?id=39026
     7
     8        This does not implement async behavior, it only parses the async
     9        attribute for HTML script tags. SVG script tags continue to not
     10        support the async attribute.
     11
     12        Tests: fast/dom/HTMLScriptElement/script-async-attr.html
     13               svg/dom/SVGScriptElement/script-async-attr.svg
     14
     15        * dom/ScriptElement.cpp:
     16        (WebCore::ScriptElementData::isAsynchronous):
     17        (WebCore::ScriptElementData::isDeferred):
     18        * dom/ScriptElement.h:
     19        * html/HTMLAttributeNames.in:
     20        * html/HTMLScriptElement.cpp:
     21        (WebCore::HTMLScriptElement::async):
     22        (WebCore::HTMLScriptElement::setAsync):
     23        (WebCore::HTMLScriptElement::defer):
     24        (WebCore::HTMLScriptElement::asyncAttributeValue):
     25        (WebCore::HTMLScriptElement::deferAttributeValue):
     26        * html/HTMLScriptElement.h:
     27        * html/HTMLScriptElement.idl:
     28        * svg/SVGScriptElement.cpp:
     29        (WebCore::SVGScriptElement::asyncAttributeValue):
     30        (WebCore::SVGScriptElement::deferAttributeValue):
     31        * svg/SVGScriptElement.h:
     32
    1332010-06-20  Nikita Vasilyev  <me@elv1s.ru>
    234
  • trunk/WebCore/dom/ScriptElement.cpp

    r60275 r61518  
    306306}
    307307
     308bool ScriptElementData::isAsynchronous() const
     309{
     310    // Only external scripts may be asynchronous.
     311    // See: http://dev.w3.org/html5/spec/Overview.html#attr-script-async
     312    return !m_scriptElement->sourceAttributeValue().isEmpty() && m_scriptElement->asyncAttributeValue();
     313}
     314
     315bool ScriptElementData::isDeferred() const
     316{
     317    // Only external scripts may be deferred and async trumps defer to allow for backward compatibility.
     318    // See: http://dev.w3.org/html5/spec/Overview.html#attr-script-defer
     319    return !m_scriptElement->sourceAttributeValue().isEmpty() && !m_scriptElement->asyncAttributeValue() && m_scriptElement->deferAttributeValue();
     320}
     321
    308322ScriptElement* toScriptElement(Element* element)
    309323{
  • trunk/WebCore/dom/ScriptElement.h

    r60275 r61518  
    4545    virtual String forAttributeValue() const = 0;
    4646    virtual String eventAttributeValue() const = 0;
     47    virtual bool asyncAttributeValue() const = 0;
     48    virtual bool deferAttributeValue() const = 0;
    4749
    4850    virtual void dispatchLoadEvent() = 0;
     
    7577    String scriptContent() const;
    7678    String scriptCharset() const;
     79    bool isAsynchronous() const;
     80    bool isDeferred() const;
    7781
    7882    Element* element() const { return m_element; }
  • trunk/WebCore/html/HTMLAttributeNames.in

    r60727 r61518  
    4444aria-valuenow
    4545aria-valuetext
     46async
    4647autocomplete
    4748autofocus
  • trunk/WebCore/html/HTMLScriptElement.cpp

    r61410 r61518  
    150150}
    151151
     152bool HTMLScriptElement::async() const
     153{
     154    return asyncAttributeValue();
     155}
     156
     157void HTMLScriptElement::setAsync(bool async)
     158{
     159    setAttribute(asyncAttr, async ? "" : 0);
     160}
     161
    152162bool HTMLScriptElement::defer() const
    153163{
     164    return deferAttributeValue();
     165}
     166
     167void HTMLScriptElement::setDefer(bool defer)
     168{
     169    setAttribute(deferAttr, defer ? "" : 0);
     170}
     171
     172KURL HTMLScriptElement::src() const
     173{
     174    return document()->completeURL(sourceAttributeValue());
     175}
     176
     177void HTMLScriptElement::setSrc(const String &value)
     178{
     179    setAttribute(srcAttr, value);
     180}
     181
     182String HTMLScriptElement::type() const
     183{
     184    return typeAttributeValue();
     185}
     186
     187void HTMLScriptElement::setType(const String &value)
     188{
     189    setAttribute(typeAttr, value);
     190}
     191
     192String HTMLScriptElement::scriptCharset() const
     193{
     194    return m_data.scriptCharset();
     195}
     196
     197String HTMLScriptElement::scriptContent() const
     198{
     199    return m_data.scriptContent();
     200}
     201
     202void HTMLScriptElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
     203{
     204    HTMLElement::addSubresourceAttributeURLs(urls);
     205
     206    addSubresourceURL(urls, src());
     207}
     208
     209String HTMLScriptElement::sourceAttributeValue() const
     210{
     211    return getAttribute(srcAttr).string();
     212}
     213
     214String HTMLScriptElement::charsetAttributeValue() const
     215{
     216    return getAttribute(charsetAttr).string();
     217}
     218
     219String HTMLScriptElement::typeAttributeValue() const
     220{
     221    return getAttribute(typeAttr).string();
     222}
     223
     224String HTMLScriptElement::languageAttributeValue() const
     225{
     226    return getAttribute(languageAttr).string();
     227}
     228
     229String HTMLScriptElement::forAttributeValue() const
     230{
     231    return getAttribute(forAttr).string();
     232}
     233
     234String HTMLScriptElement::eventAttributeValue() const
     235{
     236    return getAttribute(eventAttr).string();
     237}
     238
     239bool HTMLScriptElement::asyncAttributeValue() const
     240{
     241    return !getAttribute(asyncAttr).isNull();
     242}
     243
     244bool HTMLScriptElement::deferAttributeValue() const
     245{
    154246    return !getAttribute(deferAttr).isNull();
    155 }
    156 
    157 void HTMLScriptElement::setDefer(bool defer)
    158 {
    159     setAttribute(deferAttr, defer ? "" : 0);
    160 }
    161 
    162 KURL HTMLScriptElement::src() const
    163 {
    164     return document()->completeURL(sourceAttributeValue());
    165 }
    166 
    167 void HTMLScriptElement::setSrc(const String &value)
    168 {
    169     setAttribute(srcAttr, value);
    170 }
    171 
    172 String HTMLScriptElement::type() const
    173 {
    174     return typeAttributeValue();
    175 }
    176 
    177 void HTMLScriptElement::setType(const String &value)
    178 {
    179     setAttribute(typeAttr, value);
    180 }
    181 
    182 String HTMLScriptElement::scriptCharset() const
    183 {
    184     return m_data.scriptCharset();
    185 }
    186 
    187 String HTMLScriptElement::scriptContent() const
    188 {
    189     return m_data.scriptContent();
    190 }
    191 
    192 void HTMLScriptElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
    193 {
    194     HTMLElement::addSubresourceAttributeURLs(urls);
    195 
    196     addSubresourceURL(urls, src());
    197 }
    198 
    199 String HTMLScriptElement::sourceAttributeValue() const
    200 {
    201     return getAttribute(srcAttr).string();
    202 }
    203 
    204 String HTMLScriptElement::charsetAttributeValue() const
    205 {
    206     return getAttribute(charsetAttr).string();
    207 }
    208 
    209 String HTMLScriptElement::typeAttributeValue() const
    210 {
    211     return getAttribute(typeAttr).string();
    212 }
    213 
    214 String HTMLScriptElement::languageAttributeValue() const
    215 {
    216     return getAttribute(languageAttr).string();
    217 }
    218 
    219 String HTMLScriptElement::forAttributeValue() const
    220 {
    221     return getAttribute(forAttr).string();
    222 }
    223 
    224 String HTMLScriptElement::eventAttributeValue() const
    225 {
    226     return getAttribute(eventAttr).string();
    227247}
    228248
  • trunk/WebCore/html/HTMLScriptElement.h

    r60361 r61518  
    4848    void setCharset(const String&);
    4949
     50    bool async() const;
     51    void setAsync(bool);
     52
    5053    bool defer() const;
    5154    void setDefer(bool);
     
    8689    virtual String forAttributeValue() const;
    8790    virtual String eventAttributeValue() const;
     91    virtual bool asyncAttributeValue() const;
     92    virtual bool deferAttributeValue() const;
    8893
    8994    virtual void dispatchLoadEvent();
  • trunk/WebCore/html/HTMLScriptElement.idl

    r61413 r61518  
    2525        attribute [Reflect] DOMString event;
    2626        attribute [Reflect] DOMString charset;
     27        attribute [Reflect] boolean async;
    2728        attribute [Reflect] boolean defer;
    2829        attribute [ReflectURL] DOMString src;
  • trunk/WebCore/svg/SVGScriptElement.cpp

    r59773 r61518  
    200200}
    201201
     202bool SVGScriptElement::asyncAttributeValue() const
     203{
     204    return false;
     205}
     206
     207bool SVGScriptElement::deferAttributeValue() const
     208{
     209    return false;
     210}
     211
    202212void SVGScriptElement::dispatchLoadEvent()
    203213{
  • trunk/WebCore/svg/SVGScriptElement.h

    r59773 r61518  
    6868        virtual String forAttributeValue() const;
    6969        virtual String eventAttributeValue() const;
     70        virtual bool asyncAttributeValue() const;
     71        virtual bool deferAttributeValue() const;
    7072
    7173        virtual void dispatchLoadEvent();
Note: See TracChangeset for help on using the changeset viewer.