Changeset 87020 in webkit


Ignore:
Timestamp:
May 21, 2011 12:24:56 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

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:
Location:
trunk
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r87017 r87020  
     12011-05-21  Gavin Peters  <gavinp@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Add rel type prerender to distinguish prerender from prefetch
     6        https://bugs.webkit.org/show_bug.cgi?id=61079
     7
     8        Chrome right now uses <link rel=prefetch ...> for one of two things,
     9        to warm the cache in the same way as firefox, or to launch a speculative
     10        rendering of a web page, for faster "loading" when the user navigates to it.
     11
     12        This new rel type will let us distinguish the two cases; the rel type prerender
     13        isn't used on the web today, but the Google Web Search example prerendering application
     14        is ready to experiment with it.
     15
     16        * fast/dom/HTMLLinkElement/prerender-expected.txt: Added.
     17        * fast/dom/HTMLLinkElement/prerender.html: Added.
     18        * platform/gtk/Skipped:
     19        * platform/mac/Skipped:
     20        * platform/qt/Skipped:
     21        * platform/win/Skipped:
     22
    1232011-05-21  Kent Tamura  <tkent@chromium.org>
    224
  • trunk/LayoutTests/platform/gtk/Skipped

    r86911 r87020  
    944944fast/dom/HTMLLinkElement/prefetch-onload.html
    945945fast/dom/HTMLLinkElement/prefetch-beforeload.html
     946fast/dom/HTMLLinkElement/prerender.html
    946947fast/dom/HTMLLinkElement/subresource.html
    947948
  • trunk/LayoutTests/platform/mac/Skipped

    r86764 r87020  
    187187fast/dom/HTMLLinkElement/prefetch-onerror.html
    188188fast/dom/HTMLLinkElement/prefetch-onload.html
     189fast/dom/HTMLLinkElement/prerender.html
    189190fast/dom/HTMLLinkElement/subresource.html
    190191http/tests/misc/link-rel-prefetch-and-subresource.html
  • trunk/LayoutTests/platform/qt/Skipped

    r86959 r87020  
    19711971fast/dom/HTMLLinkElement/prefetch-onerror.html
    19721972fast/dom/HTMLLinkElement/prefetch-onload.html
     1973fast/dom/HTMLLinkElement/prerender.html
    19731974fast/dom/HTMLLinkElement/subresource.html
    19741975http/tests/misc/link-rel-prefetch-and-subresource.html
  • trunk/LayoutTests/platform/win/Skipped

    r86962 r87020  
    10071007fast/dom/HTMLLinkElement/prefetch-onerror.html
    10081008fast/dom/HTMLLinkElement/prefetch-onload.html
     1009http/tests/misc/link-rel-prefetch-and-subresource.html
     1010fast/dom/HTMLLinkElement/prerender.html
    10091011fast/dom/HTMLLinkElement/subresource.html
    1010 http/tests/misc/link-rel-prefetch-and-subresource.html
    10111012http/tests/misc/prefetch-purpose.html
    10121013
  • trunk/Source/WebCore/ChangeLog

    r87019 r87020  
     12011-05-21  Gavin Peters  <gavinp@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Add rel type prerender to distinguish prerender from prefetch
     6        https://bugs.webkit.org/show_bug.cgi?id=61079
     7
     8        Chrome right now uses <link rel=prefetch ...> for one of two things,
     9        to warm the cache in the same way as firefox, or to launch a speculative
     10        rendering of a web page, for faster "loading" when the user navigates to it.
     11
     12        This new rel type will let us distinguish the two cases; the rel type prerender
     13        isn't used on the web today, but the Google Web Search example prerendering application
     14        is ready to experiment with it.
     15
     16        Test: fast/dom/HTMLLinkElement/prerender.html
     17
     18        * html/HTMLLinkElement.cpp:
     19        (WebCore::HTMLLinkElement::tokenizeRelAttribute):
     20        (WebCore::HTMLLinkElement::process):
     21        * html/HTMLLinkElement.h:
     22        (WebCore::HTMLLinkElement::RelAttribute::RelAttribute):
     23        * loader/cache/CachedResource.cpp:
     24        (WebCore::defaultPriorityForResourceType):
     25        * loader/cache/CachedResource.h:
     26        (WebCore::CachedResource::isLinkResource):
     27        * loader/cache/CachedResourceLoader.cpp:
     28        (WebCore::createResource):
     29        (WebCore::CachedResourceLoader::requestLinkResource):
     30        (WebCore::CachedResourceLoader::canRequest):
     31        * loader/cache/CachedResourceLoader.h:
     32        * loader/cache/CachedResourceRequest.cpp:
     33        (WebCore::cachedResourceTypeToTargetType):
     34        (WebCore::CachedResourceRequest::load):
     35        * platform/network/ResourceRequestBase.h:
     36
    1372011-05-21  Emil A Eklund  <eae@chromium.org>
    238
  • trunk/Source/WebCore/html/HTMLLinkElement.cpp

    r85785 r87020  
    166166#if ENABLE(LINK_PREFETCH)
    167167    relAttribute.m_isLinkPrefetch = false;
     168    relAttribute.m_isLinkPrerender = false;
    168169    relAttribute.m_isLinkSubresource = false;
    169170#endif
     
    206207            else if (equalIgnoringCase(*it, "prefetch"))
    207208              relAttribute.m_isLinkPrefetch = true;
     209            else if (equalIgnoringCase(*it, "prerender"))
     210              relAttribute.m_isLinkPrerender = true;
    208211            else if (equalIgnoringCase(*it, "subresource"))
    209212              relAttribute.m_isLinkSubresource = true;
     
    250253
    251254#if ENABLE(LINK_PREFETCH)
    252     if ((m_relAttribute.m_isLinkPrefetch || m_relAttribute.m_isLinkSubresource) && m_url.isValid() && document()->frame()) {
     255    if ((m_relAttribute.m_isLinkPrefetch || m_relAttribute.m_isLinkPrerender || m_relAttribute.m_isLinkSubresource) && m_url.isValid() && document()->frame()) {
    253256        if (!checkBeforeLoadEvent())
    254257            return;
    255258        ResourceLoadPriority priority = ResourceLoadPriorityUnresolved;
    256         if (m_relAttribute.m_isLinkSubresource)
     259        CachedResource::Type type = CachedResource::LinkPrefetch;
     260        // We only make one request to the cachedresourcelodaer if multiple rel types are
     261        // specified,
     262        if (m_relAttribute.m_isLinkSubresource) {
    257263            priority = ResourceLoadPriorityLow;
    258 
    259         m_cachedLinkResource = document()->cachedResourceLoader()->requestLinkResource(m_url, priority);
     264            type = CachedResource::LinkSubresource;
     265        } else if (m_relAttribute.m_isLinkPrerender)
     266            type = CachedResource::LinkPrerender;
     267
     268        m_cachedLinkResource = document()->cachedResourceLoader()->requestLinkResource(type, m_url, priority);
    260269        if (m_cachedLinkResource)
    261270            m_cachedLinkResource->addClient(this);
  • trunk/Source/WebCore/html/HTMLLinkElement.h

    r85785 r87020  
    4646#if ENABLE(LINK_PREFETCH)
    4747        bool m_isLinkPrefetch;
     48        bool m_isLinkPrerender;
    4849        bool m_isLinkSubresource;
    4950#endif
     
    5657#if ENABLE(LINK_PREFETCH)
    5758            , m_isLinkPrefetch(false)
     59            , m_isLinkPrerender(false)
    5860            , m_isLinkSubresource(false)
    5961#endif
  • trunk/Source/WebCore/loader/cache/CachedResource.cpp

    r85375 r87020  
    6363            return ResourceLoadPriorityLow;
    6464#if ENABLE(LINK_PREFETCH)
    65         case CachedResource::LinkResource:
     65        case CachedResource::LinkPrefetch:
     66            return ResourceLoadPriorityVeryLow;
     67        case CachedResource::LinkPrerender:
     68            return ResourceLoadPriorityVeryLow;
     69        case CachedResource::LinkSubresource:
    6670            return ResourceLoadPriorityVeryLow;
    6771#endif
  • trunk/Source/WebCore/loader/cache/CachedResource.h

    r84110 r87020  
    6666#endif
    6767#if ENABLE(LINK_PREFETCH)
    68         , LinkResource
     68        , LinkPrefetch
     69        , LinkPrerender
     70        , LinkSubresource
    6971#endif
    7072    };
     
    133135    {
    134136#if ENABLE(LINK_PREFETCH)
    135         return type() == LinkResource;
     137        return type() == LinkPrefetch || type() == LinkPrerender || type() == LinkSubresource;
    136138#else
    137139        return false;
  • trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp

    r86542 r87020  
    7272#endif
    7373#if ENABLE(LINK_PREFETCH)
    74     case CachedResource::LinkResource:
    75         return new CachedResource(url.string(), CachedResource::LinkResource);
     74    case CachedResource::LinkPrefetch:
     75        return new CachedResource(url.string(), CachedResource::LinkPrefetch);
     76    case CachedResource::LinkPrerender:
     77        return new CachedResource(url.string(), CachedResource::LinkPrerender);
     78    case CachedResource::LinkSubresource:
     79        return new CachedResource(url.string(), CachedResource::LinkSubresource);
    7680#endif
    7781    }
     
    189193
    190194#if ENABLE(LINK_PREFETCH)
    191 CachedResource* CachedResourceLoader::requestLinkResource(const String& url, ResourceLoadPriority priority)
     195CachedResource* CachedResourceLoader::requestLinkResource(CachedResource::Type type, const String& url, ResourceLoadPriority priority)
    192196{
    193197    ASSERT(frame());
    194     return requestResource(CachedResource::LinkResource, url, String(), priority);
     198    ASSERT(type == CachedResource::LinkPrefetch || type == CachedResource::LinkPrerender || type == CachedResource::LinkSubresource);
     199    return requestResource(type, url, String(), priority);
    195200}
    196201#endif
     
    214219    case CachedResource::FontResource:
    215220#if ENABLE(LINK_PREFETCH)
    216     case CachedResource::LinkResource:
     221    case CachedResource::LinkPrefetch:
     222    case CachedResource::LinkPrerender:
     223    case CachedResource::LinkSubresource:
    217224#endif
    218225        // These types of resources can be loaded from any origin.
     
    261268    }
    262269#if ENABLE(LINK_PREFETCH)
    263     case CachedResource::LinkResource:
     270    case CachedResource::LinkPrefetch:
     271    case CachedResource::LinkPrerender:
     272    case CachedResource::LinkSubresource:
    264273        // Prefetch cannot affect the current document.
    265274        break;
     
    290299    }
    291300#if ENABLE(LINK_PREFETCH)
    292     case CachedResource::LinkResource:
     301    case CachedResource::LinkPrefetch:
     302    case CachedResource::LinkPrerender:
     303    case CachedResource::LinkSubresource:
    293304        break;
    294305#endif
  • trunk/Source/WebCore/loader/cache/CachedResourceLoader.h

    r86601 r87020  
    7171#endif
    7272#if ENABLE(LINK_PREFETCH)
    73     CachedResource* requestLinkResource(const String &url, ResourceLoadPriority priority = ResourceLoadPriorityUnresolved);
     73    CachedResource* requestLinkResource(CachedResource::Type, const String &url, ResourceLoadPriority priority = ResourceLoadPriorityUnresolved);
    7474#endif
    7575
  • trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp

    r86949 r87020  
    4646namespace WebCore {
    4747   
    48 static ResourceRequest::TargetType cachedResourceTypeToTargetType(CachedResource::Type type, ResourceLoadPriority priority)
    49 {
    50 #if !ENABLE(LINK_PREFETCH)
    51     UNUSED_PARAM(priority);
    52 #endif
     48static ResourceRequest::TargetType cachedResourceTypeToTargetType(CachedResource::Type type)
     49{
    5350    switch (type) {
    5451    case CachedResource::CSSStyleSheet:
     
    6461        return ResourceRequest::TargetIsImage;
    6562#if ENABLE(LINK_PREFETCH)
    66     case CachedResource::LinkResource:
    67         if (priority == ResourceLoadPriorityLowest)
    68             return ResourceRequest::TargetIsPrefetch;
     63    case CachedResource::LinkPrefetch:
     64        return ResourceRequest::TargetIsPrefetch;
     65    case CachedResource::LinkPrerender:
     66        return ResourceRequest::TargetIsSubresource;
     67    case CachedResource::LinkSubresource:
    6968        return ResourceRequest::TargetIsSubresource;
    7069#endif
     
    9493
    9594    ResourceRequest resourceRequest(resource->url());
    96     resourceRequest.setTargetType(cachedResourceTypeToTargetType(resource->type(), resource->loadPriority()));
     95    resourceRequest.setTargetType(cachedResourceTypeToTargetType(resource->type()));
    9796
    9897    if (!resource->accept().isEmpty())
     
    117116   
    118117#if ENABLE(LINK_PREFETCH)
    119     if (resource->type() == CachedResource::LinkResource)
     118    if (resource->type() == CachedResource::LinkPrefetch || resource->type() == CachedResource::LinkPrerender || resource->type() == CachedResource::LinkSubresource)
    120119        resourceRequest.setHTTPHeaderField("Purpose", "prefetch");
    121120#endif
  • trunk/Source/WebCore/platform/network/ResourceRequestBase.h

    r84120 r87020  
    6666            TargetIsSharedWorker,
    6767            TargetIsPrefetch,
     68            TargetIsPrerender,
    6869            TargetIsFavicon,
    6970        };
Note: See TracChangeset for help on using the changeset viewer.