Title: [87020] trunk
Revision
87020
Author
[email protected]
Date
2011-05-21 12:24:56 -0700 (Sat, 21 May 2011)

Log Message

2011-05-21  Gavin Peters  <[email protected]>

        Reviewed by Adam Barth.

        Add rel type prerender to distinguish prerender from prefetch
        https://bugs.webkit.org/show_bug.cgi?id=61079

        Chrome right now uses <link rel=prefetch ...> for one of two things,
        to warm the cache in the same way as firefox, or to launch a speculative
        rendering of a web page, for faster "loading" when the user navigates to it.

        This new rel type will let us distinguish the two cases; the rel type prerender
        isn't used on the web today, but the Google Web Search example prerendering application
        is ready to experiment with it.

        * fast/dom/HTMLLinkElement/prerender-expected.txt: Added.
        * fast/dom/HTMLLinkElement/prerender.html: Added.
        * platform/gtk/Skipped:
        * platform/mac/Skipped:
        * platform/qt/Skipped:
        * platform/win/Skipped:
2011-05-21  Gavin Peters  <[email protected]>

        Reviewed by Adam Barth.

        Add rel type prerender to distinguish prerender from prefetch
        https://bugs.webkit.org/show_bug.cgi?id=61079

        Chrome right now uses <link rel=prefetch ...> for one of two things,
        to warm the cache in the same way as firefox, or to launch a speculative
        rendering of a web page, for faster "loading" when the user navigates to it.

        This new rel type will let us distinguish the two cases; the rel type prerender
        isn't used on the web today, but the Google Web Search example prerendering application
        is ready to experiment with it.

        Test: fast/dom/HTMLLinkElement/prerender.html

        * html/HTMLLinkElement.cpp:
        (WebCore::HTMLLinkElement::tokenizeRelAttribute):
        (WebCore::HTMLLinkElement::process):
        * html/HTMLLinkElement.h:
        (WebCore::HTMLLinkElement::RelAttribute::RelAttribute):
        * loader/cache/CachedResource.cpp:
        (WebCore::defaultPriorityForResourceType):
        * loader/cache/CachedResource.h:
        (WebCore::CachedResource::isLinkResource):
        * loader/cache/CachedResourceLoader.cpp:
        (WebCore::createResource):
        (WebCore::CachedResourceLoader::requestLinkResource):
        (WebCore::CachedResourceLoader::canRequest):
        * loader/cache/CachedResourceLoader.h:
        * loader/cache/CachedResourceRequest.cpp:
        (WebCore::cachedResourceTypeToTargetType):
        (WebCore::CachedResourceRequest::load):
        * platform/network/ResourceRequestBase.h:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (87019 => 87020)


--- trunk/LayoutTests/ChangeLog	2011-05-21 15:30:02 UTC (rev 87019)
+++ trunk/LayoutTests/ChangeLog	2011-05-21 19:24:56 UTC (rev 87020)
@@ -1,3 +1,25 @@
+2011-05-21  Gavin Peters  <[email protected]>
+
+        Reviewed by Adam Barth.
+
+        Add rel type prerender to distinguish prerender from prefetch
+        https://bugs.webkit.org/show_bug.cgi?id=61079
+
+        Chrome right now uses <link rel=prefetch ...> for one of two things,
+        to warm the cache in the same way as firefox, or to launch a speculative
+        rendering of a web page, for faster "loading" when the user navigates to it.
+
+        This new rel type will let us distinguish the two cases; the rel type prerender
+        isn't used on the web today, but the Google Web Search example prerendering application
+        is ready to experiment with it.
+
+        * fast/dom/HTMLLinkElement/prerender-expected.txt: Added.
+        * fast/dom/HTMLLinkElement/prerender.html: Added.
+        * platform/gtk/Skipped:
+        * platform/mac/Skipped:
+        * platform/qt/Skipped:
+        * platform/win/Skipped:
+
 2011-05-21  Kent Tamura  <[email protected]>
 
         [GTK] [Chromium] Update test results for r87014.

Added: trunk/LayoutTests/fast/dom/HTMLLinkElement/prerender-expected.txt (0 => 87020)


--- trunk/LayoutTests/fast/dom/HTMLLinkElement/prerender-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLLinkElement/prerender-expected.txt	2011-05-21 19:24:56 UTC (rev 87020)
@@ -0,0 +1,3 @@
+prefetch.link has MIME type application/octet-stream
+PASS onload called!
+This test will only print "PASS" or "FAIL" if link prefetches are enabled, otherwise it will show nothing below.

Added: trunk/LayoutTests/fast/dom/HTMLLinkElement/prerender.html (0 => 87020)


--- trunk/LayoutTests/fast/dom/HTMLLinkElement/prerender.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLLinkElement/prerender.html	2011-05-21 19:24:56 UTC (rev 87020)
@@ -0,0 +1,20 @@
+<body>
+<div id="console"></div>
+<script src=""
+<script>
+function prefetch_onload() {
+    testPassed('onload called!');
+    layoutTestController.notifyDone();
+}
+if (window.layoutTestController) {
+    layoutTestController.waitUntilDone();
+    layoutTestController.dumpAsText();
+    layoutTestController.dumpResourceResponseMIMETypes();
+}
+</script>
+<html>
+<p>This test will only print "PASS" or "FAIL" if link prefetches are
+enabled, otherwise it will show nothing below.</p>
+<link href="" rel="prerender" _onload_="prefetch_onload()" _onerror_="testFailed('onerror')" />
+</html>
+

Modified: trunk/LayoutTests/platform/gtk/Skipped (87019 => 87020)


--- trunk/LayoutTests/platform/gtk/Skipped	2011-05-21 15:30:02 UTC (rev 87019)
+++ trunk/LayoutTests/platform/gtk/Skipped	2011-05-21 19:24:56 UTC (rev 87020)
@@ -943,6 +943,7 @@
 fast/dom/HTMLLinkElement/prefetch-onerror.html
 fast/dom/HTMLLinkElement/prefetch-onload.html
 fast/dom/HTMLLinkElement/prefetch-beforeload.html
+fast/dom/HTMLLinkElement/prerender.html
 fast/dom/HTMLLinkElement/subresource.html
 
 # Tests failing because the context menu is grabbing mouse events.

Modified: trunk/LayoutTests/platform/mac/Skipped (87019 => 87020)


--- trunk/LayoutTests/platform/mac/Skipped	2011-05-21 15:30:02 UTC (rev 87019)
+++ trunk/LayoutTests/platform/mac/Skipped	2011-05-21 19:24:56 UTC (rev 87020)
@@ -186,6 +186,7 @@
 fast/dom/HTMLLinkElement/prefetch-beforeload.html
 fast/dom/HTMLLinkElement/prefetch-onerror.html
 fast/dom/HTMLLinkElement/prefetch-onload.html
+fast/dom/HTMLLinkElement/prerender.html
 fast/dom/HTMLLinkElement/subresource.html
 http/tests/misc/link-rel-prefetch-and-subresource.html
 http/tests/misc/prefetch-purpose.html

Modified: trunk/LayoutTests/platform/qt/Skipped (87019 => 87020)


--- trunk/LayoutTests/platform/qt/Skipped	2011-05-21 15:30:02 UTC (rev 87019)
+++ trunk/LayoutTests/platform/qt/Skipped	2011-05-21 19:24:56 UTC (rev 87020)
@@ -1970,6 +1970,7 @@
 fast/dom/HTMLLinkElement/prefetch-beforeload.html
 fast/dom/HTMLLinkElement/prefetch-onerror.html
 fast/dom/HTMLLinkElement/prefetch-onload.html
+fast/dom/HTMLLinkElement/prerender.html
 fast/dom/HTMLLinkElement/subresource.html
 http/tests/misc/link-rel-prefetch-and-subresource.html
 http/tests/misc/prefetch-purpose.html

Modified: trunk/LayoutTests/platform/win/Skipped (87019 => 87020)


--- trunk/LayoutTests/platform/win/Skipped	2011-05-21 15:30:02 UTC (rev 87019)
+++ trunk/LayoutTests/platform/win/Skipped	2011-05-21 19:24:56 UTC (rev 87020)
@@ -1006,8 +1006,9 @@
 fast/dom/HTMLLinkElement/prefetch-beforeload.html
 fast/dom/HTMLLinkElement/prefetch-onerror.html
 fast/dom/HTMLLinkElement/prefetch-onload.html
+http/tests/misc/link-rel-prefetch-and-subresource.html
+fast/dom/HTMLLinkElement/prerender.html
 fast/dom/HTMLLinkElement/subresource.html
-http/tests/misc/link-rel-prefetch-and-subresource.html
 http/tests/misc/prefetch-purpose.html
 
 # LayoutTestController::pageProperty is not implemented for WIN yet.

Modified: trunk/Source/WebCore/ChangeLog (87019 => 87020)


--- trunk/Source/WebCore/ChangeLog	2011-05-21 15:30:02 UTC (rev 87019)
+++ trunk/Source/WebCore/ChangeLog	2011-05-21 19:24:56 UTC (rev 87020)
@@ -1,3 +1,39 @@
+2011-05-21  Gavin Peters  <[email protected]>
+
+        Reviewed by Adam Barth.
+
+        Add rel type prerender to distinguish prerender from prefetch
+        https://bugs.webkit.org/show_bug.cgi?id=61079
+
+        Chrome right now uses <link rel=prefetch ...> for one of two things,
+        to warm the cache in the same way as firefox, or to launch a speculative
+        rendering of a web page, for faster "loading" when the user navigates to it.
+
+        This new rel type will let us distinguish the two cases; the rel type prerender
+        isn't used on the web today, but the Google Web Search example prerendering application
+        is ready to experiment with it.
+
+        Test: fast/dom/HTMLLinkElement/prerender.html
+
+        * html/HTMLLinkElement.cpp:
+        (WebCore::HTMLLinkElement::tokenizeRelAttribute):
+        (WebCore::HTMLLinkElement::process):
+        * html/HTMLLinkElement.h:
+        (WebCore::HTMLLinkElement::RelAttribute::RelAttribute):
+        * loader/cache/CachedResource.cpp:
+        (WebCore::defaultPriorityForResourceType):
+        * loader/cache/CachedResource.h:
+        (WebCore::CachedResource::isLinkResource):
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::createResource):
+        (WebCore::CachedResourceLoader::requestLinkResource):
+        (WebCore::CachedResourceLoader::canRequest):
+        * loader/cache/CachedResourceLoader.h:
+        * loader/cache/CachedResourceRequest.cpp:
+        (WebCore::cachedResourceTypeToTargetType):
+        (WebCore::CachedResourceRequest::load):
+        * platform/network/ResourceRequestBase.h:
+
 2011-05-21  Emil A Eklund  <[email protected]>
 
         Reviewed by Eric Seidel.

Modified: trunk/Source/WebCore/html/HTMLLinkElement.cpp (87019 => 87020)


--- trunk/Source/WebCore/html/HTMLLinkElement.cpp	2011-05-21 15:30:02 UTC (rev 87019)
+++ trunk/Source/WebCore/html/HTMLLinkElement.cpp	2011-05-21 19:24:56 UTC (rev 87020)
@@ -165,6 +165,7 @@
     relAttribute.m_isDNSPrefetch = false;
 #if ENABLE(LINK_PREFETCH)
     relAttribute.m_isLinkPrefetch = false;
+    relAttribute.m_isLinkPrerender = false;
     relAttribute.m_isLinkSubresource = false;
 #endif
     if (equalIgnoringCase(rel, "stylesheet"))
@@ -205,6 +206,8 @@
 #if ENABLE(LINK_PREFETCH)
             else if (equalIgnoringCase(*it, "prefetch"))
               relAttribute.m_isLinkPrefetch = true;
+            else if (equalIgnoringCase(*it, "prerender"))
+              relAttribute.m_isLinkPrerender = true;
             else if (equalIgnoringCase(*it, "subresource"))
               relAttribute.m_isLinkSubresource = true;
 #endif
@@ -249,14 +252,20 @@
     }
 
 #if ENABLE(LINK_PREFETCH)
-    if ((m_relAttribute.m_isLinkPrefetch || m_relAttribute.m_isLinkSubresource) && m_url.isValid() && document()->frame()) {
+    if ((m_relAttribute.m_isLinkPrefetch || m_relAttribute.m_isLinkPrerender || m_relAttribute.m_isLinkSubresource) && m_url.isValid() && document()->frame()) {
         if (!checkBeforeLoadEvent())
             return;
         ResourceLoadPriority priority = ResourceLoadPriorityUnresolved;
-        if (m_relAttribute.m_isLinkSubresource)
+        CachedResource::Type type = CachedResource::LinkPrefetch;
+        // We only make one request to the cachedresourcelodaer if multiple rel types are
+        // specified, 
+        if (m_relAttribute.m_isLinkSubresource) {
             priority = ResourceLoadPriorityLow;
+            type = CachedResource::LinkSubresource;
+        } else if (m_relAttribute.m_isLinkPrerender)
+            type = CachedResource::LinkPrerender;
 
-        m_cachedLinkResource = document()->cachedResourceLoader()->requestLinkResource(m_url, priority);
+        m_cachedLinkResource = document()->cachedResourceLoader()->requestLinkResource(type, m_url, priority);
         if (m_cachedLinkResource)
             m_cachedLinkResource->addClient(this);
     }

Modified: trunk/Source/WebCore/html/HTMLLinkElement.h (87019 => 87020)


--- trunk/Source/WebCore/html/HTMLLinkElement.h	2011-05-21 15:30:02 UTC (rev 87019)
+++ trunk/Source/WebCore/html/HTMLLinkElement.h	2011-05-21 19:24:56 UTC (rev 87020)
@@ -45,6 +45,7 @@
         bool m_isDNSPrefetch;
 #if ENABLE(LINK_PREFETCH)
         bool m_isLinkPrefetch;
+        bool m_isLinkPrerender;
         bool m_isLinkSubresource;
 #endif
 
@@ -55,6 +56,7 @@
             , m_isDNSPrefetch(false)
 #if ENABLE(LINK_PREFETCH)
             , m_isLinkPrefetch(false)
+            , m_isLinkPrerender(false)
             , m_isLinkSubresource(false)
 #endif
             { 

Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (87019 => 87020)


--- trunk/Source/WebCore/loader/cache/CachedResource.cpp	2011-05-21 15:30:02 UTC (rev 87019)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp	2011-05-21 19:24:56 UTC (rev 87020)
@@ -62,8 +62,12 @@
         case CachedResource::ImageResource:
             return ResourceLoadPriorityLow;
 #if ENABLE(LINK_PREFETCH)
-        case CachedResource::LinkResource:
+        case CachedResource::LinkPrefetch:
             return ResourceLoadPriorityVeryLow;
+        case CachedResource::LinkPrerender:
+            return ResourceLoadPriorityVeryLow;
+        case CachedResource::LinkSubresource:
+            return ResourceLoadPriorityVeryLow;
 #endif
     }
     ASSERT_NOT_REACHED();

Modified: trunk/Source/WebCore/loader/cache/CachedResource.h (87019 => 87020)


--- trunk/Source/WebCore/loader/cache/CachedResource.h	2011-05-21 15:30:02 UTC (rev 87019)
+++ trunk/Source/WebCore/loader/cache/CachedResource.h	2011-05-21 19:24:56 UTC (rev 87020)
@@ -65,7 +65,9 @@
         , XSLStyleSheet
 #endif
 #if ENABLE(LINK_PREFETCH)
-        , LinkResource
+        , LinkPrefetch
+        , LinkPrerender
+        , LinkSubresource
 #endif
     };
 
@@ -132,7 +134,7 @@
     bool isLinkResource() const
     {
 #if ENABLE(LINK_PREFETCH)
-        return type() == LinkResource;
+        return type() == LinkPrefetch || type() == LinkPrerender || type() == LinkSubresource;
 #else
         return false;
 #endif

Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (87019 => 87020)


--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2011-05-21 15:30:02 UTC (rev 87019)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2011-05-21 19:24:56 UTC (rev 87020)
@@ -71,8 +71,12 @@
         return new CachedXSLStyleSheet(url.string());
 #endif
 #if ENABLE(LINK_PREFETCH)
-    case CachedResource::LinkResource:
-        return new CachedResource(url.string(), CachedResource::LinkResource);
+    case CachedResource::LinkPrefetch:
+        return new CachedResource(url.string(), CachedResource::LinkPrefetch);
+    case CachedResource::LinkPrerender:
+        return new CachedResource(url.string(), CachedResource::LinkPrerender);
+    case CachedResource::LinkSubresource:
+        return new CachedResource(url.string(), CachedResource::LinkSubresource);
 #endif
     }
     ASSERT_NOT_REACHED();
@@ -188,10 +192,11 @@
 #endif
 
 #if ENABLE(LINK_PREFETCH)
-CachedResource* CachedResourceLoader::requestLinkResource(const String& url, ResourceLoadPriority priority)
+CachedResource* CachedResourceLoader::requestLinkResource(CachedResource::Type type, const String& url, ResourceLoadPriority priority)
 {
     ASSERT(frame());
-    return requestResource(CachedResource::LinkResource, url, String(), priority);
+    ASSERT(type == CachedResource::LinkPrefetch || type == CachedResource::LinkPrerender || type == CachedResource::LinkSubresource);
+    return requestResource(type, url, String(), priority);
 }
 #endif
 
@@ -213,7 +218,9 @@
     case CachedResource::Script:
     case CachedResource::FontResource:
 #if ENABLE(LINK_PREFETCH)
-    case CachedResource::LinkResource:
+    case CachedResource::LinkPrefetch:
+    case CachedResource::LinkPrerender:
+    case CachedResource::LinkSubresource:
 #endif
         // These types of resources can be loaded from any origin.
         // FIXME: Are we sure about CachedResource::FontResource?
@@ -260,7 +267,9 @@
         break;
     }
 #if ENABLE(LINK_PREFETCH)
-    case CachedResource::LinkResource:
+    case CachedResource::LinkPrefetch:
+    case CachedResource::LinkPrerender:
+    case CachedResource::LinkSubresource:
         // Prefetch cannot affect the current document.
         break;
 #endif
@@ -289,7 +298,9 @@
         break;
     }
 #if ENABLE(LINK_PREFETCH)
-    case CachedResource::LinkResource:
+    case CachedResource::LinkPrefetch:
+    case CachedResource::LinkPrerender:
+    case CachedResource::LinkSubresource:
         break;
 #endif
     }

Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.h (87019 => 87020)


--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.h	2011-05-21 15:30:02 UTC (rev 87019)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.h	2011-05-21 19:24:56 UTC (rev 87020)
@@ -70,7 +70,7 @@
     CachedXSLStyleSheet* requestXSLStyleSheet(const String& url);
 #endif
 #if ENABLE(LINK_PREFETCH)
-    CachedResource* requestLinkResource(const String &url, ResourceLoadPriority priority = ResourceLoadPriorityUnresolved);
+    CachedResource* requestLinkResource(CachedResource::Type, const String &url, ResourceLoadPriority priority = ResourceLoadPriorityUnresolved);
 #endif
 
     // Logs an access denied message to the console for the specified URL.

Modified: trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp (87019 => 87020)


--- trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp	2011-05-21 15:30:02 UTC (rev 87019)
+++ trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp	2011-05-21 19:24:56 UTC (rev 87020)
@@ -45,11 +45,8 @@
 
 namespace WebCore {
     
-static ResourceRequest::TargetType cachedResourceTypeToTargetType(CachedResource::Type type, ResourceLoadPriority priority)
+static ResourceRequest::TargetType cachedResourceTypeToTargetType(CachedResource::Type type)
 {
-#if !ENABLE(LINK_PREFETCH)
-    UNUSED_PARAM(priority);
-#endif
     switch (type) {
     case CachedResource::CSSStyleSheet:
 #if ENABLE(XSLT)
@@ -63,10 +60,12 @@
     case CachedResource::ImageResource:
         return ResourceRequest::TargetIsImage;
 #if ENABLE(LINK_PREFETCH)
-    case CachedResource::LinkResource:
-        if (priority == ResourceLoadPriorityLowest)
-            return ResourceRequest::TargetIsPrefetch;
+    case CachedResource::LinkPrefetch:
+        return ResourceRequest::TargetIsPrefetch;
+    case CachedResource::LinkPrerender:
         return ResourceRequest::TargetIsSubresource;
+    case CachedResource::LinkSubresource:
+        return ResourceRequest::TargetIsSubresource;
 #endif
     }
     ASSERT_NOT_REACHED();
@@ -93,7 +92,7 @@
     RefPtr<CachedResourceRequest> request = adoptRef(new CachedResourceRequest(cachedResourceLoader, resource, incremental));
 
     ResourceRequest resourceRequest(resource->url());
-    resourceRequest.setTargetType(cachedResourceTypeToTargetType(resource->type(), resource->loadPriority()));
+    resourceRequest.setTargetType(cachedResourceTypeToTargetType(resource->type()));
 
     if (!resource->accept().isEmpty())
         resourceRequest.setHTTPAccept(resource->accept());
@@ -116,7 +115,7 @@
     }
     
 #if ENABLE(LINK_PREFETCH)
-    if (resource->type() == CachedResource::LinkResource)
+    if (resource->type() == CachedResource::LinkPrefetch || resource->type() == CachedResource::LinkPrerender || resource->type() == CachedResource::LinkSubresource)
         resourceRequest.setHTTPHeaderField("Purpose", "prefetch");
 #endif
 

Modified: trunk/Source/WebCore/platform/network/ResourceRequestBase.h (87019 => 87020)


--- trunk/Source/WebCore/platform/network/ResourceRequestBase.h	2011-05-21 15:30:02 UTC (rev 87019)
+++ trunk/Source/WebCore/platform/network/ResourceRequestBase.h	2011-05-21 19:24:56 UTC (rev 87020)
@@ -65,6 +65,7 @@
             TargetIsWorker,
             TargetIsSharedWorker,
             TargetIsPrefetch,
+            TargetIsPrerender,
             TargetIsFavicon,
         };
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to