Skip to content
Permalink
Browse files
2011-05-21 Gavin Peters <gavinp@chromium.org>
        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  <gavinp@chromium.org>

        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:

Canonical link: https://commits.webkit.org/76619@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@87020 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
webkit-commit-queue committed May 21, 2011
1 parent f4a36cf commit 68eaaceeceffb790b1831c0f521b50e1c9d69bdb
Showing 16 changed files with 137 additions and 24 deletions.
@@ -1,3 +1,25 @@
2011-05-21 Gavin Peters <gavinp@chromium.org>

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 <tkent@chromium.org>

[GTK] [Chromium] Update test results for r87014.
@@ -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.
@@ -0,0 +1,20 @@
<body>
<div id="console"></div>
<script src="../../js/resources/js-test-pre.js"></script>
<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="prefetch.link" rel="prerender" onload="prefetch_onload()" onerror="testFailed('onerror')" />
</html>

@@ -943,6 +943,7 @@ fast/dom/HTMLLinkElement/prefetch.html
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.
@@ -186,6 +186,7 @@ fast/dom/HTMLLinkElement/prefetch.html
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
@@ -1970,6 +1970,7 @@ fast/dom/HTMLLinkElement/prefetch.html
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
@@ -1006,8 +1006,9 @@ fast/dom/HTMLLinkElement/prefetch.html
fast/dom/HTMLLinkElement/prefetch-beforeload.html
fast/dom/HTMLLinkElement/prefetch-onerror.html
fast/dom/HTMLLinkElement/prefetch-onload.html
fast/dom/HTMLLinkElement/subresource.html
http/tests/misc/link-rel-prefetch-and-subresource.html
fast/dom/HTMLLinkElement/prerender.html
fast/dom/HTMLLinkElement/subresource.html
http/tests/misc/prefetch-purpose.html

# LayoutTestController::pageProperty is not implemented for WIN yet.
@@ -1,3 +1,39 @@
2011-05-21 Gavin Peters <gavinp@chromium.org>

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 <eae@chromium.org>

Reviewed by Eric Seidel.
@@ -165,6 +165,7 @@ void HTMLLinkElement::tokenizeRelAttribute(const AtomicString& rel, RelAttribute
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 @@ void HTMLLinkElement::tokenizeRelAttribute(const AtomicString& rel, RelAttribute
#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 @@ void HTMLLinkElement::process()
}

#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);
}
@@ -45,6 +45,7 @@ class HTMLLinkElement : public HTMLElement, public CachedResourceClient {
bool m_isDNSPrefetch;
#if ENABLE(LINK_PREFETCH)
bool m_isLinkPrefetch;
bool m_isLinkPrerender;
bool m_isLinkSubresource;
#endif

@@ -55,6 +56,7 @@ class HTMLLinkElement : public HTMLElement, public CachedResourceClient {
, m_isDNSPrefetch(false)
#if ENABLE(LINK_PREFETCH)
, m_isLinkPrefetch(false)
, m_isLinkPrerender(false)
, m_isLinkSubresource(false)
#endif
{
@@ -62,7 +62,11 @@ static ResourceLoadPriority defaultPriorityForResourceType(CachedResource::Type
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
}
@@ -65,7 +65,9 @@ class CachedResource {
, XSLStyleSheet
#endif
#if ENABLE(LINK_PREFETCH)
, LinkResource
, LinkPrefetch
, LinkPrerender
, LinkSubresource
#endif
};

@@ -132,7 +134,7 @@ class CachedResource {
bool isLinkResource() const
{
#if ENABLE(LINK_PREFETCH)
return type() == LinkResource;
return type() == LinkPrefetch || type() == LinkPrerender || type() == LinkSubresource;
#else
return false;
#endif
@@ -71,8 +71,12 @@ static CachedResource* createResource(CachedResource::Type type, const KURL& url
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 @@ CachedXSLStyleSheet* CachedResourceLoader::requestXSLStyleSheet(const String& ur
#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 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const KURL& url
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 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const KURL& url
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 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const KURL& url
break;
}
#if ENABLE(LINK_PREFETCH)
case CachedResource::LinkResource:
case CachedResource::LinkPrefetch:
case CachedResource::LinkPrerender:
case CachedResource::LinkSubresource:
break;
#endif
}
@@ -70,7 +70,7 @@ friend class ResourceCacheValidationSuppressor;
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.
@@ -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,9 +60,11 @@ static ResourceRequest::TargetType cachedResourceTypeToTargetType(CachedResource
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
}
@@ -93,7 +92,7 @@ PassRefPtr<CachedResourceRequest> CachedResourceRequest::load(CachedResourceLoad
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 @@ PassRefPtr<CachedResourceRequest> CachedResourceRequest::load(CachedResourceLoad
}

#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

@@ -65,6 +65,7 @@ namespace WebCore {
TargetIsWorker,
TargetIsSharedWorker,
TargetIsPrefetch,
TargetIsPrerender,
TargetIsFavicon,
};

0 comments on commit 68eaace

Please sign in to comment.