Changeset 73335 in webkit


Ignore:
Timestamp:
Dec 4, 2010 12:40:10 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2010-12-04 Gavin Peters <gavinp@chromium.org>

Reviewed by Adam Barth.

Implement onload events for <link rel=prefetch>
https://bugs.webkit.org/show_bug.cgi?id=50187

  • fast/dom/HTMLLinkElement/link-and-subresource-test-expected.txt: Added.
  • fast/dom/HTMLLinkElement/link-and-subresource-test.html: Added.
  • fast/dom/HTMLLinkElement/prefetch-expected.txt:
  • fast/dom/HTMLLinkElement/prefetch-onload-expected.txt: Added.
  • fast/dom/HTMLLinkElement/prefetch-onload.html: Added.
  • fast/dom/HTMLLinkElement/prefetch.html:
  • http/tests/misc/prefetch-purpose.html:
  • platform/gtk/Skipped:
  • platform/mac/Skipped:
  • platform/qt/Skipped:
  • platform/win/Skipped:

2010-12-04 Gavin Peters <gavinp@chromium.org>

Reviewed by Adam Barth.

Implement onload events for <link rel=prefetch>
https://bugs.webkit.org/show_bug.cgi?id=50187

Tests: fast/dom/HTMLLinkElement/link-and-subresource-test.html

fast/dom/HTMLLinkElement/prefetch-onload.html

  • html/HTMLLinkElement.cpp: (WebCore::HTMLLinkElement::HTMLLinkElement): (WebCore::HTMLLinkElement::~HTMLLinkElement): (WebCore::HTMLLinkElement::parseMappedAttribute): (WebCore::HTMLLinkElement::process): (WebCore::HTMLLinkElement::onloadTimerFired): (WebCore::HTMLLinkElement::notifyFinished):
  • html/HTMLLinkElement.h:
  • loader/cache/CachedResource.cpp: (WebCore::CachedResource::data):
Location:
trunk
Files:
4 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r73331 r73335  
     12010-12-04  Gavin Peters  <gavinp@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Implement onload events for <link rel=prefetch>
     6        https://bugs.webkit.org/show_bug.cgi?id=50187
     7
     8        * fast/dom/HTMLLinkElement/link-and-subresource-test-expected.txt: Added.
     9        * fast/dom/HTMLLinkElement/link-and-subresource-test.html: Added.
     10        * fast/dom/HTMLLinkElement/prefetch-expected.txt:
     11        * fast/dom/HTMLLinkElement/prefetch-onload-expected.txt: Added.
     12        * fast/dom/HTMLLinkElement/prefetch-onload.html: Added.
     13        * fast/dom/HTMLLinkElement/prefetch.html:
     14        * http/tests/misc/prefetch-purpose.html:
     15        * platform/gtk/Skipped:
     16        * platform/mac/Skipped:
     17        * platform/qt/Skipped:
     18        * platform/win/Skipped:
     19
    1202010-12-04  Martin Robinson  <mrobinson@igalia.com>
    221
  • trunk/LayoutTests/fast/dom/HTMLLinkElement/prefetch-expected.txt

    r63032 r73335  
    11prefetch.link has MIME type application/octet-stream
    22This test requires DumpRenderTree to see the log of what resources are loaded.
     3
     4SUCCESS! prefetch onload called.
  • trunk/LayoutTests/fast/dom/HTMLLinkElement/prefetch.html

    r63032 r73335  
    11<body>
    22<script>
     3function log(message) {
     4    var item = document.createElement("li");
     5    item.appendChild(document.createTextNode(message));
     6    document.getElementById("console").appendChild(item);
     7}
     8function prefetch_onload() {
     9    log("SUCCESS!  prefetch onload called.");
     10    layoutTestController.notifyDone();
     11}
    312if (window.layoutTestController) {
    413    layoutTestController.waitUntilDone();
    514    layoutTestController.dumpAsText();
    615    layoutTestController.dumpResourceResponseMIMETypes();
    7     setTimeout("layoutTestController.notifyDone()",50);
    816}
    917</script>
    1018<html>
    1119<p>This test requires DumpRenderTree to see the log of what resources are loaded.
    12 <link href="prefetch.link" rel="prefetch">
     20<link href="prefetch.link" rel="prefetch" onload="prefetch_onload()">
     21<p><ol id="console"></ol>
    1322</html>
    1423
  • trunk/LayoutTests/http/tests/misc/prefetch-purpose.html

    r69420 r73335  
    1313}
    1414</script>
    15 <link href="resources/prefetch-purpose.php" rel="prefetch">
     15<link href="resources/prefetch-purpose.php" rel="prefetch" onload="finishUp()">
    1616</head>
    17 <body onload="setTimeout('finishUp()', 50);">
     17<body>
    1818<p>Nothing to see here, this page should replace itself with resources/prefetch-purpose.php almost instantly.
    1919</body>
  • trunk/LayoutTests/platform/gtk/Skipped

    r73329 r73335  
    51185118
    51195119# Link prefetch is disabled by default
     5120fast/dom/HTMLLinkElement/link-and-subresource-test.html
    51205121fast/dom/HTMLLinkElement/prefetch.html
     5122fast/dom/HTMLLinkElement/prefetch-onload.html
    51215123
    51225124# LayoutTestController::pageProperty is not implemented for GTK yet.
  • trunk/LayoutTests/platform/mac/Skipped

    r73175 r73335  
    185185
    186186# Link prefetch is disabled by default
     187fast/dom/HTMLLinkElement/link-and-subresource-test.html
    187188fast/dom/HTMLLinkElement/prefetch.html
     189fast/dom/HTMLLinkElement/prefetch-onload.html
    188190http/tests/misc/prefetch-purpose.html
    189191
  • trunk/LayoutTests/platform/qt/Skipped

    r73241 r73335  
    51505150
    51515151# Link prefetch is disabled by default
     5152fast/dom/HTMLLinkElement/link-and-subresource-test.html
    51525153fast/dom/HTMLLinkElement/prefetch.html
     5154fast/dom/HTMLLinkElement/prefetch-onload.html
    51535155http/tests/misc/prefetch-purpose.html
    51545156
  • trunk/LayoutTests/platform/win/Skipped

    r73317 r73335  
    947947
    948948# Link prefetch is disabled by default
     949fast/dom/HTMLLinkElement/link-and-subresource-test.html
    949950fast/dom/HTMLLinkElement/prefetch.html
     951fast/dom/HTMLLinkElement/prefetch-onload.html
    950952http/tests/misc/prefetch-purpose.html
    951953
  • trunk/WebCore/ChangeLog

    r73330 r73335  
     12010-12-04  Gavin Peters  <gavinp@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Implement onload events for <link rel=prefetch>
     6        https://bugs.webkit.org/show_bug.cgi?id=50187
     7
     8        Tests: fast/dom/HTMLLinkElement/link-and-subresource-test.html
     9               fast/dom/HTMLLinkElement/prefetch-onload.html
     10
     11        * html/HTMLLinkElement.cpp:
     12        (WebCore::HTMLLinkElement::HTMLLinkElement):
     13        (WebCore::HTMLLinkElement::~HTMLLinkElement):
     14        (WebCore::HTMLLinkElement::parseMappedAttribute):
     15        (WebCore::HTMLLinkElement::process):
     16        (WebCore::HTMLLinkElement::onloadTimerFired):
     17        (WebCore::HTMLLinkElement::notifyFinished):
     18        * html/HTMLLinkElement.h:
     19        * loader/cache/CachedResource.cpp:
     20        (WebCore::CachedResource::data):
     21
    1222010-12-04  Xan Lopez  <xlopez@igalia.com>
    223
  • trunk/WebCore/html/HTMLLinkElement.cpp

    r71767 r73335  
    4949inline HTMLLinkElement::HTMLLinkElement(const QualifiedName& tagName, Document* document, bool createdByParser)
    5050    : HTMLElement(tagName, document)
     51#if ENABLE(LINK_PREFETCH)
     52    , m_onloadTimer(this, &HTMLLinkElement::onloadTimerFired)
     53#endif
    5154    , m_disabledState(Unset)
    5255    , m_loading(false)
     
    7174            document()->removePendingSheet();
    7275    }
     76   
     77#if ENABLE(LINK_PREFETCH)
     78    if (m_cachedLinkPrefetch)
     79        m_cachedLinkPrefetch->removeClient(this);
     80#endif
    7381}
    7482
     
    134142    else if (attr->name() == onbeforeloadAttr)
    135143        setAttributeEventListener(eventNames().beforeloadEvent, createAttributeEventListener(this, attr));
     144#if ENABLE(LINK_PREFETCH)
     145    else if (attr->name() == onloadAttr)
     146        setAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(this, attr));
     147#endif
    136148    else {
    137149        if (attr->name() == titleAttr && m_sheet)
     
    204216
    205217#if ENABLE(LINK_PREFETCH)
    206     if (m_relAttribute.m_isLinkPrefetch && m_url.isValid() && document()->frame())
    207         document()->cachedResourceLoader()->requestLinkPrefetch(m_url);
     218    if (m_relAttribute.m_isLinkPrefetch && m_url.isValid() && document()->frame()) {
     219        m_cachedLinkPrefetch = document()->cachedResourceLoader()->requestLinkPrefetch(m_url);
     220        if (m_cachedLinkPrefetch)
     221            m_cachedLinkPrefetch->addClient(this);
     222    }
    208223#endif
    209224
     
    357372}
    358373
     374#if ENABLE(LINK_PREFETCH)
     375void HTMLLinkElement::onloadTimerFired(Timer<HTMLLinkElement>* timer)
     376{
     377    ASSERT_UNUSED(timer, timer == &m_onloadTimer);
     378    dispatchEvent(Event::create(eventNames().loadEvent, false, false));
     379}
     380
     381void HTMLLinkElement::notifyFinished(CachedResource* resource)
     382{
     383    m_onloadTimer.startOneShot(0);
     384    if (m_cachedLinkPrefetch.get() == resource) {
     385        m_cachedLinkPrefetch->removeClient(this);
     386        m_cachedLinkPrefetch = 0;
     387    }
     388}
     389#endif
     390
    359391bool HTMLLinkElement::sheetLoaded()
    360392{
  • trunk/WebCore/html/HTMLLinkElement.h

    r66057 r73335  
    2828#include "CachedResourceHandle.h"
    2929#include "HTMLElement.h"
     30#include "Timer.h"
    3031
    3132namespace WebCore {
    3233
    3334class CachedCSSStyleSheet;
     35class CachedResource;
    3436class KURL;
    3537
     
    7880    virtual void parseMappedAttribute(Attribute*);
    7981
     82#if ENABLE(LINK_PREFETCH)
     83    void onloadTimerFired(Timer<HTMLLinkElement>*);
     84#endif
    8085    void process();
    8186    static void processCallback(Node*);
     
    8691    // from CachedResourceClient
    8792    virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet* sheet);
     93#if ENABLE(LINK_PREFETCH)
     94    virtual void notifyFinished(CachedResource*);
     95#endif
    8896    virtual bool sheetLoaded();
    8997
     
    113121    CachedResourceHandle<CachedCSSStyleSheet> m_cachedSheet;
    114122    RefPtr<CSSStyleSheet> m_sheet;
     123#if ENABLE(LINK_PREFETCH)
     124    CachedResourceHandle<CachedResource> m_cachedLinkPrefetch;
     125    Timer<HTMLLinkElement> m_onloadTimer;
     126#endif
    115127    KURL m_url;
    116128    String m_type;
  • trunk/WebCore/loader/cache/CachedResource.cpp

    r72303 r73335  
    116116        return;
    117117   
     118    setLoading(false);
    118119    CachedResourceClientWalker w(m_clients);
    119120    while (CachedResourceClient* c = w.next())
Note: See TracChangeset for help on using the changeset viewer.