[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 17:59:54 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 7e9f6dbe974ac13eeff55ba61974537852136ff8
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Dec 4 20:40:10 2010 +0000

    2010-12-04  Gavin Peters  <gavinp at 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 at 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):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73335 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 517b5c3..8db0702 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,22 @@
+2010-12-04  Gavin Peters  <gavinp at 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  Martin Robinson  <mrobinson at igalia.com>
 
         Fix a baseline which differs between my machine and the bots.
diff --git a/LayoutTests/fast/dom/HTMLLinkElement/link-and-subresource-test-expected.txt b/LayoutTests/fast/dom/HTMLLinkElement/link-and-subresource-test-expected.txt
new file mode 100644
index 0000000..ac1b174
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLLinkElement/link-and-subresource-test-expected.txt
@@ -0,0 +1,10 @@
+nick.jpg has MIME type image/jpeg
+nick.jpg has MIME type image/jpeg
+This test verifies that an image which is prefetched, and which is also contained as a subresource of the current document can be loaded correctly as a subresource. See bug 49236 in which this wasn't working.
+
+When this test succeeds, you'll see an image of Nick on a sailboat immediately below this text. When this test fails, you will see no images at all.  
+
+NICK_ONLOAD called
+NICK_ONLOAD called
+SUCCESS. Two loads.
+
diff --git a/LayoutTests/fast/dom/HTMLLinkElement/link-and-subresource-test.html b/LayoutTests/fast/dom/HTMLLinkElement/link-and-subresource-test.html
new file mode 100644
index 0000000..594eafd
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLLinkElement/link-and-subresource-test.html
@@ -0,0 +1,39 @@
+<html>
+<body>
+<script>
+function log(message)
+{
+    var item = document.createElement("li");
+    item.appendChild(document.createTextNode(message));
+    document.getElementById("console").appendChild(item);
+}
+
+nick_load_count = 0
+
+function nick_onload()
+{
+    log("NICK_ONLOAD called");
+    ++nick_load_count;
+    if (nick_load_count == 2) {
+        log("SUCCESS.  Two loads.");
+        layoutTestController.notifyDone();
+    }
+}
+
+if (window.layoutTestController) {
+    layoutTestController.waitUntilDone();
+    layoutTestController.dumpAsText();
+    layoutTestController.dumpResourceResponseMIMETypes();
+}
+</script>
+<p>This test verifies that an image which is prefetched, and which is also contained as a
+subresource of the current document can be loaded correctly as a subresource.  See
+bug 49236 in which this wasn't working.
+<p>When this test succeeds, you'll see an image of Nick on a sailboat immediately below
+this text.  When this test fails, you will see no images at all.
+<link rel="prefetch" href="resources/nick.jpg" onload="nick_onload()" />
+<img src="resources/nick.jpg" onload="nick_onload()" />
+<hr>
+<p><ol id="console"></ol></p>
+</body></html>
+
diff --git a/LayoutTests/fast/dom/HTMLLinkElement/prefetch-expected.txt b/LayoutTests/fast/dom/HTMLLinkElement/prefetch-expected.txt
index 75d77df..9ea65dc 100644
--- a/LayoutTests/fast/dom/HTMLLinkElement/prefetch-expected.txt
+++ b/LayoutTests/fast/dom/HTMLLinkElement/prefetch-expected.txt
@@ -1,2 +1,4 @@
 prefetch.link has MIME type application/octet-stream
 This test requires DumpRenderTree to see the log of what resources are loaded.
+
+SUCCESS! prefetch onload called.
diff --git a/LayoutTests/fast/dom/HTMLLinkElement/prefetch-onload-expected.txt b/LayoutTests/fast/dom/HTMLLinkElement/prefetch-onload-expected.txt
new file mode 100644
index 0000000..dac6e93
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLLinkElement/prefetch-onload-expected.txt
@@ -0,0 +1,6 @@
+This tests that onload events can be attached to link elements with rel=prefetch. Since prefetch links are just there as a performance optimization, the onload event is their only programatic side-effect.
+
+If it works you should see a message below saying the test has passed.
+
+TEST PASSED.
+
diff --git a/LayoutTests/fast/dom/HTMLLinkElement/prefetch-onload.html b/LayoutTests/fast/dom/HTMLLinkElement/prefetch-onload.html
new file mode 100644
index 0000000..37cfdbf
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLLinkElement/prefetch-onload.html
@@ -0,0 +1,29 @@
+<html>
+<head>
+<script type="text/javascript">
+function log(message)
+{
+    var item = document.createElement("li");
+    item.appendChild(document.createTextNode(message));
+    document.getElementById("console").appendChild(item);
+}
+function done()
+{
+    log("TEST PASSED.");
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+ }
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+</script>
+</head>
+<body>
+<p>This tests that onload events can be attached to link elements with rel=prefetch. Since prefetch links are just there as a performance optimization, the onload event is their only programatic side-effect.</p>
+<p>If it works you should see a message below saying the test has passed.</p>
+<link href="prefetch.link" rel="prefetch" onload="done()" >
+<hr>
+<p><ol id="console"></ol></p>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/HTMLLinkElement/prefetch.html b/LayoutTests/fast/dom/HTMLLinkElement/prefetch.html
index 3b5dd9b..5c223f9 100644
--- a/LayoutTests/fast/dom/HTMLLinkElement/prefetch.html
+++ b/LayoutTests/fast/dom/HTMLLinkElement/prefetch.html
@@ -1,14 +1,23 @@
 <body>
 <script>
+function log(message) {
+    var item = document.createElement("li");
+    item.appendChild(document.createTextNode(message));
+    document.getElementById("console").appendChild(item);
+}
+function prefetch_onload() {
+    log("SUCCESS!  prefetch onload called.");
+    layoutTestController.notifyDone();
+}
 if (window.layoutTestController) {
     layoutTestController.waitUntilDone();
     layoutTestController.dumpAsText();
     layoutTestController.dumpResourceResponseMIMETypes();
-    setTimeout("layoutTestController.notifyDone()",50);
 }
 </script>
 <html>
 <p>This test requires DumpRenderTree to see the log of what resources are loaded.
-<link href="prefetch.link" rel="prefetch">
+<link href="prefetch.link" rel="prefetch" onload="prefetch_onload()">
+<p><ol id="console"></ol>
 </html>
 
diff --git a/LayoutTests/http/tests/misc/prefetch-purpose.html b/LayoutTests/http/tests/misc/prefetch-purpose.html
index 12f17e1..2f9a582 100644
--- a/LayoutTests/http/tests/misc/prefetch-purpose.html
+++ b/LayoutTests/http/tests/misc/prefetch-purpose.html
@@ -12,9 +12,9 @@ if (window.layoutTestController) {
     layoutTestController.dumpResourceResponseMIMETypes();
 }
 </script>
-<link href="resources/prefetch-purpose.php" rel="prefetch">
+<link href="resources/prefetch-purpose.php" rel="prefetch" onload="finishUp()">
 </head>
-<body onload="setTimeout('finishUp()', 50);">
+<body>
 <p>Nothing to see here, this page should replace itself with resources/prefetch-purpose.php almost instantly.
 </body>
 </html>
diff --git a/LayoutTests/platform/gtk/Skipped b/LayoutTests/platform/gtk/Skipped
index f4af8e4..ebc7934 100644
--- a/LayoutTests/platform/gtk/Skipped
+++ b/LayoutTests/platform/gtk/Skipped
@@ -5117,7 +5117,9 @@ fast/forms/slider-mouse-events.html
 fast/forms/slider-zoomed.html
 
 # Link prefetch is disabled by default
+fast/dom/HTMLLinkElement/link-and-subresource-test.html
 fast/dom/HTMLLinkElement/prefetch.html
+fast/dom/HTMLLinkElement/prefetch-onload.html
 
 # LayoutTestController::pageProperty is not implemented for GTK yet.
 printing/page-rule-selection.html
diff --git a/LayoutTests/platform/mac/Skipped b/LayoutTests/platform/mac/Skipped
index 3fe5770..2f8899c 100644
--- a/LayoutTests/platform/mac/Skipped
+++ b/LayoutTests/platform/mac/Skipped
@@ -184,7 +184,9 @@ fast/dom/DeviceOrientation
 fast/dom/Window/window-properties-device-orientation.html
 
 # Link prefetch is disabled by default
+fast/dom/HTMLLinkElement/link-and-subresource-test.html
 fast/dom/HTMLLinkElement/prefetch.html
+fast/dom/HTMLLinkElement/prefetch-onload.html
 http/tests/misc/prefetch-purpose.html
 
 # Filenames aren't filtered out from edit drags yet, see https://bugs.wekit.org/show_bug.cgi?id=38826
diff --git a/LayoutTests/platform/qt/Skipped b/LayoutTests/platform/qt/Skipped
index 34f49a2..c627d25 100644
--- a/LayoutTests/platform/qt/Skipped
+++ b/LayoutTests/platform/qt/Skipped
@@ -5149,7 +5149,9 @@ media/video-delay-load-event.html
 fast/dom/Geolocation/callback-to-remote-context2.html
 
 # Link prefetch is disabled by default
+fast/dom/HTMLLinkElement/link-and-subresource-test.html
 fast/dom/HTMLLinkElement/prefetch.html
+fast/dom/HTMLLinkElement/prefetch-onload.html
 http/tests/misc/prefetch-purpose.html
 
 # [Qt] Regression(r61749): inspector/debugger-pause-on-debugger-statement.html fails
diff --git a/LayoutTests/platform/win/Skipped b/LayoutTests/platform/win/Skipped
index cbdc46a..3116fa3 100644
--- a/LayoutTests/platform/win/Skipped
+++ b/LayoutTests/platform/win/Skipped
@@ -946,7 +946,9 @@ fast/dom/DeviceOrientation
 fast/dom/Window/window-properties-device-orientation.html
 
 # Link prefetch is disabled by default
+fast/dom/HTMLLinkElement/link-and-subresource-test.html
 fast/dom/HTMLLinkElement/prefetch.html
+fast/dom/HTMLLinkElement/prefetch-onload.html
 http/tests/misc/prefetch-purpose.html
 
 # LayoutTestController::pageProperty is not implemented for WIN yet.
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 3ea83cd..8959080 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,24 @@
+2010-12-04  Gavin Peters  <gavinp at 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):
+
 2010-12-04  Xan Lopez  <xlopez at igalia.com>
 
         Reviewed by Martin Robinson.
diff --git a/WebCore/html/HTMLLinkElement.cpp b/WebCore/html/HTMLLinkElement.cpp
index 8dd055c..319e759 100644
--- a/WebCore/html/HTMLLinkElement.cpp
+++ b/WebCore/html/HTMLLinkElement.cpp
@@ -48,6 +48,9 @@ using namespace HTMLNames;
 
 inline HTMLLinkElement::HTMLLinkElement(const QualifiedName& tagName, Document* document, bool createdByParser)
     : HTMLElement(tagName, document)
+#if ENABLE(LINK_PREFETCH)
+    , m_onloadTimer(this, &HTMLLinkElement::onloadTimerFired)
+#endif
     , m_disabledState(Unset)
     , m_loading(false)
     , m_createdByParser(createdByParser)
@@ -70,6 +73,11 @@ HTMLLinkElement::~HTMLLinkElement()
         if (m_loading && !isDisabled() && !isAlternate())
             document()->removePendingSheet();
     }
+    
+#if ENABLE(LINK_PREFETCH)
+    if (m_cachedLinkPrefetch)
+        m_cachedLinkPrefetch->removeClient(this);
+#endif
 }
 
 void HTMLLinkElement::setDisabledState(bool _disabled)
@@ -133,6 +141,10 @@ void HTMLLinkElement::parseMappedAttribute(Attribute* attr)
         setDisabledState(!attr->isNull());
     else if (attr->name() == onbeforeloadAttr)
         setAttributeEventListener(eventNames().beforeloadEvent, createAttributeEventListener(this, attr));
+#if ENABLE(LINK_PREFETCH)
+    else if (attr->name() == onloadAttr)
+        setAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(this, attr));
+#endif
     else {
         if (attr->name() == titleAttr && m_sheet)
             m_sheet->setTitle(attr->value());
@@ -203,8 +215,11 @@ void HTMLLinkElement::process()
     }
 
 #if ENABLE(LINK_PREFETCH)
-    if (m_relAttribute.m_isLinkPrefetch && m_url.isValid() && document()->frame())
-        document()->cachedResourceLoader()->requestLinkPrefetch(m_url);
+    if (m_relAttribute.m_isLinkPrefetch && m_url.isValid() && document()->frame()) {
+        m_cachedLinkPrefetch = document()->cachedResourceLoader()->requestLinkPrefetch(m_url);
+        if (m_cachedLinkPrefetch)
+            m_cachedLinkPrefetch->addClient(this);
+    }
 #endif
 
     bool acceptIfTypeContainsTextCSS = document()->page() && document()->page()->settings() && document()->page()->settings()->treatsAnyTextCSSLinkAsStylesheet();
@@ -356,6 +371,23 @@ bool HTMLLinkElement::isLoading() const
     return static_cast<CSSStyleSheet *>(m_sheet.get())->isLoading();
 }
 
+#if ENABLE(LINK_PREFETCH)
+void HTMLLinkElement::onloadTimerFired(Timer<HTMLLinkElement>* timer)
+{
+    ASSERT_UNUSED(timer, timer == &m_onloadTimer);
+    dispatchEvent(Event::create(eventNames().loadEvent, false, false));
+}
+
+void HTMLLinkElement::notifyFinished(CachedResource* resource)
+{
+    m_onloadTimer.startOneShot(0);
+    if (m_cachedLinkPrefetch.get() == resource) {
+        m_cachedLinkPrefetch->removeClient(this);
+        m_cachedLinkPrefetch = 0;
+    }
+}
+#endif
+
 bool HTMLLinkElement::sheetLoaded()
 {
     if (!isLoading() && !isDisabled() && !isAlternate()) {
diff --git a/WebCore/html/HTMLLinkElement.h b/WebCore/html/HTMLLinkElement.h
index 2fb7525..f359b8a 100644
--- a/WebCore/html/HTMLLinkElement.h
+++ b/WebCore/html/HTMLLinkElement.h
@@ -27,10 +27,12 @@
 #include "CachedResourceClient.h"
 #include "CachedResourceHandle.h"
 #include "HTMLElement.h"
+#include "Timer.h"
 
 namespace WebCore {
 
 class CachedCSSStyleSheet;
+class CachedResource;
 class KURL;
 
 class HTMLLinkElement : public HTMLElement, public CachedResourceClient {
@@ -77,6 +79,9 @@ public:
 private:
     virtual void parseMappedAttribute(Attribute*);
 
+#if ENABLE(LINK_PREFETCH)
+    void onloadTimerFired(Timer<HTMLLinkElement>*);
+#endif
     void process();
     static void processCallback(Node*);
 
@@ -85,6 +90,9 @@ private:
 
     // from CachedResourceClient
     virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet* sheet);
+#if ENABLE(LINK_PREFETCH)
+    virtual void notifyFinished(CachedResource*);
+#endif
     virtual bool sheetLoaded();
 
     bool isAlternate() const { return m_disabledState == Unset && m_relAttribute.m_isAlternate; }
@@ -112,6 +120,10 @@ private:
 
     CachedResourceHandle<CachedCSSStyleSheet> m_cachedSheet;
     RefPtr<CSSStyleSheet> m_sheet;
+#if ENABLE(LINK_PREFETCH)
+    CachedResourceHandle<CachedResource> m_cachedLinkPrefetch;
+    Timer<HTMLLinkElement> m_onloadTimer;
+#endif
     KURL m_url;
     String m_type;
     String m_media;
diff --git a/WebCore/loader/cache/CachedResource.cpp b/WebCore/loader/cache/CachedResource.cpp
index 844065d..e952a54 100644
--- a/WebCore/loader/cache/CachedResource.cpp
+++ b/WebCore/loader/cache/CachedResource.cpp
@@ -115,6 +115,7 @@ void CachedResource::data(PassRefPtr<SharedBuffer>, bool allDataReceived)
     if (!allDataReceived)
         return;
     
+    setLoading(false);
     CachedResourceClientWalker w(m_clients);
     while (CachedResourceClient* c = w.next())
         c->notifyFinished(this);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list