Changeset 84110 in webkit
- Timestamp:
- Apr 17, 2011 2:30:32 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r84098 r84110 1 2011-04-17 Gavin Peters <gavinp@chromium.org> 2 3 Reviewed by Adam Barth. 4 5 Add support for link rel type "subresource" 6 https://bugs.webkit.org/show_bug.cgi?id=57842 7 8 Link rel=prefetch is great for cache warming for resources on 9 subsequent pages, but it launches requests at too low a priority 10 to use for subresources of the current page. 11 12 During testing, I was dissapointed to see the results for the http 13 test below don't give the subresource priority ordering. This is 14 another instance of https://bugs.webkit.org/show_bug.cgi?id=49238 15 which I'll be working on next, and thus fix the test. 16 17 * fast/dom/HTMLLinkElement/subresource-expected.txt: Added. 18 * fast/dom/HTMLLinkElement/subresource.html: Added. 19 * http/tests/misc/link-rel-prefetch-and-subresource-expected.txt: Added. 20 * http/tests/misc/link-rel-prefetch-and-subresource.html: Added. 21 * platform/gtk/Skipped: 22 * platform/mac/Skipped: 23 * platform/qt/Skipped: 24 * platform/win/Skipped: 25 1 26 2011-04-16 Dan Bernstein <mitz@apple.com> 2 27 -
trunk/LayoutTests/platform/gtk/Skipped
r84053 r84110 513 513 http/tests/mime/standard-mode-loads-stylesheet-with-text-css-and-invalid-type.html 514 514 http/tests/misc/acid3.html 515 http/tests/misc/link-rel-prefetch-and-subresource.html 515 516 http/tests/misc/policy-delegate-called-twice.html 516 517 http/tests/misc/prefetch-purpose.html … … 925 926 fast/dom/HTMLLinkElement/prefetch-onload.html 926 927 fast/dom/HTMLLinkElement/prefetch-beforeload.html 928 fast/dom/HTMLLinkElement/subresource.html 927 929 928 930 # Tests failing because the context menu is grabbing mouse events. -
trunk/LayoutTests/platform/mac/Skipped
r84053 r84110 187 187 fast/dom/HTMLLinkElement/prefetch-onerror.html 188 188 fast/dom/HTMLLinkElement/prefetch-onload.html 189 fast/dom/HTMLLinkElement/subresource.html 190 http/tests/misc/link-rel-prefetch-and-subresource.html 189 191 http/tests/misc/prefetch-purpose.html 190 192 -
trunk/LayoutTests/platform/qt/Skipped
r84057 r84110 2959 2959 fast/dom/HTMLLinkElement/prefetch-onerror.html 2960 2960 fast/dom/HTMLLinkElement/prefetch-onload.html 2961 fast/dom/HTMLLinkElement/subresource.html 2962 http/tests/misc/link-rel-prefetch-and-subresource.html 2961 2963 http/tests/misc/prefetch-purpose.html 2962 2964 -
trunk/LayoutTests/platform/win/Skipped
r84053 r84110 996 996 fast/dom/HTMLLinkElement/prefetch-onerror.html 997 997 fast/dom/HTMLLinkElement/prefetch-onload.html 998 fast/dom/HTMLLinkElement/subresource.html 999 http/tests/misc/link-rel-prefetch-and-subresource.html 998 1000 http/tests/misc/prefetch-purpose.html 999 1001 -
trunk/Source/WebCore/ChangeLog
r84107 r84110 1 2011-04-17 Gavin Peters <gavinp@chromium.org> 2 3 Reviewed by Adam Barth. 4 5 Add support for link rel type "subresource" 6 https://bugs.webkit.org/show_bug.cgi?id=57842 7 8 Link rel=prefetch is great for cache warming for resources on 9 subsequent pages, but it launches requests at too low a priority 10 to use for subresources of the current page. 11 12 Particularly after https://bugs.webkit.org/show_bug.cgi?id=51940 13 is implemented, a rel type that launches requests at an higher 14 priority is going to be very useful. This rel type is in the 15 HTML5 spec at http://wiki.whatwg.org/wiki/RelExtensions . An 16 expected use case will be for servers to provide subresource hints 17 in link headers, which will allow servers to help make the web 18 faster. 19 20 This feature continues my implementation of the Link header, which 21 we've talked about in WebKit-dev in 22 https://lists.webkit.org/pipermail/webkit-dev/2011-February/016034.html. 23 24 Tests: fast/dom/HTMLLinkElement/subresource.html 25 http/tests/misc/link-rel-prefetch-and-subresource.html 26 27 * html/HTMLLinkElement.cpp: 28 (WebCore::HTMLLinkElement::~HTMLLinkElement): 29 (WebCore::HTMLLinkElement::tokenizeRelAttribute): 30 (WebCore::HTMLLinkElement::process): 31 (WebCore::HTMLLinkElement::onloadTimerFired): 32 (WebCore::HTMLLinkElement::notifyFinished): 33 * html/HTMLLinkElement.h: 34 (WebCore::HTMLLinkElement::RelAttribute::RelAttribute): 35 * loader/cache/CachedResource.cpp: 36 (WebCore::defaultPriorityForResourceType): 37 * loader/cache/CachedResource.h: 38 (WebCore::CachedResource::isLinkResource): 39 * loader/cache/CachedResourceLoader.cpp: 40 (WebCore::createResource): 41 (WebCore::CachedResourceLoader::requestLinkResource): 42 (WebCore::CachedResourceLoader::canRequest): 43 (WebCore::CachedResourceLoader::incrementRequestCount): 44 (WebCore::CachedResourceLoader::decrementRequestCount): 45 * loader/cache/CachedResourceLoader.h: 46 * loader/cache/CachedResourceRequest.cpp: 47 (WebCore::cachedResourceTypeToTargetType): 48 (WebCore::CachedResourceRequest::load): 49 1 50 2011-04-17 Dan Bernstein <mitz@apple.com> 2 51 -
trunk/Source/WebCore/html/HTMLLinkElement.cpp
r82342 r84110 27 27 #include "Attribute.h" 28 28 #include "CachedCSSStyleSheet.h" 29 #include "CachedResource.h" 29 30 #include "CachedResourceLoader.h" 30 31 #include "CSSStyleSelector.h" … … 79 80 80 81 #if ENABLE(LINK_PREFETCH) 81 if (m_cachedLink Prefetch)82 m_cachedLink Prefetch->removeClient(this);82 if (m_cachedLinkResource) 83 m_cachedLinkResource->removeClient(this); 83 84 #endif 84 85 } … … 164 165 #if ENABLE(LINK_PREFETCH) 165 166 relAttribute.m_isLinkPrefetch = false; 167 relAttribute.m_isLinkSubresource = false; 166 168 #endif 167 169 if (equalIgnoringCase(rel, "stylesheet")) … … 171 173 else if (equalIgnoringCase(rel, "dns-prefetch")) 172 174 relAttribute.m_isDNSPrefetch = true; 173 #if ENABLE(LINK_PREFETCH)174 else if (equalIgnoringCase(rel, "prefetch"))175 relAttribute.m_isLinkPrefetch = true;176 #endif177 175 else if (equalIgnoringCase(rel, "alternate stylesheet") || equalIgnoringCase(rel, "stylesheet alternate")) { 178 176 relAttribute.m_isStyleSheet = true; … … 192 190 else if (equalIgnoringCase(*it, "icon")) 193 191 relAttribute.m_isIcon = true; 192 #if ENABLE(LINK_PREFETCH) 193 else if (equalIgnoringCase(*it, "prefetch")) 194 relAttribute.m_isLinkPrefetch = true; 195 else if (equalIgnoringCase(*it, "subresource")) 196 relAttribute.m_isLinkSubresource = true; 197 #endif 194 198 } 195 199 } … … 233 237 234 238 #if ENABLE(LINK_PREFETCH) 235 if ( m_relAttribute.m_isLinkPrefetch&& m_url.isValid() && document()->frame()) {239 if ((m_relAttribute.m_isLinkPrefetch || m_relAttribute.m_isLinkSubresource) && m_url.isValid() && document()->frame()) { 236 240 if (!checkBeforeLoadEvent()) 237 241 return; 238 m_cachedLinkPrefetch = document()->cachedResourceLoader()->requestLinkPrefetch(m_url); 239 if (m_cachedLinkPrefetch) 240 m_cachedLinkPrefetch->addClient(this); 242 ResourceLoadPriority priority = ResourceLoadPriorityUnresolved; 243 if (m_relAttribute.m_isLinkSubresource) 244 priority = ResourceLoadPriorityLow; 245 246 m_cachedLinkResource = document()->cachedResourceLoader()->requestLinkResource(m_url, priority); 247 if (m_cachedLinkResource) 248 m_cachedLinkResource->addClient(this); 241 249 } 242 250 #endif … … 410 418 { 411 419 ASSERT_UNUSED(timer, timer == &m_onloadTimer); 412 if (m_cachedLink Prefetch->errorOccurred())420 if (m_cachedLinkResource->errorOccurred()) 413 421 dispatchEvent(Event::create(eventNames().errorEvent, false, false)); 414 422 else 415 423 dispatchEvent(Event::create(eventNames().loadEvent, false, false)); 416 424 417 m_cachedLink Prefetch->removeClient(this);418 m_cachedLink Prefetch= 0;425 m_cachedLinkResource->removeClient(this); 426 m_cachedLinkResource = 0; 419 427 } 420 428 … … 422 430 { 423 431 m_onloadTimer.startOneShot(0); 424 ASSERT(m_cachedLink Prefetch.get() == resource);432 ASSERT(m_cachedLinkResource.get() == resource); 425 433 } 426 434 #endif -
trunk/Source/WebCore/html/HTMLLinkElement.h
r82342 r84110 45 45 #if ENABLE(LINK_PREFETCH) 46 46 bool m_isLinkPrefetch; 47 bool m_isLinkSubresource; 47 48 #endif 48 49 … … 54 55 #if ENABLE(LINK_PREFETCH) 55 56 , m_isLinkPrefetch(false) 57 , m_isLinkSubresource(false) 56 58 #endif 57 59 { … … 127 129 RefPtr<CSSStyleSheet> m_sheet; 128 130 #if ENABLE(LINK_PREFETCH) 129 CachedResourceHandle<CachedResource> m_cachedLink Prefetch;131 CachedResourceHandle<CachedResource> m_cachedLinkResource; 130 132 Timer<HTMLLinkElement> m_onloadTimer; 131 133 #endif -
trunk/Source/WebCore/loader/cache/CachedResource.cpp
r82764 r84110 63 63 return ResourceLoadPriorityLow; 64 64 #if ENABLE(LINK_PREFETCH) 65 case CachedResource::Link Prefetch:65 case CachedResource::LinkResource: 66 66 return ResourceLoadPriorityVeryLow; 67 67 #endif -
trunk/Source/WebCore/loader/cache/CachedResource.h
r82217 r84110 66 66 #endif 67 67 #if ENABLE(LINK_PREFETCH) 68 , Link Prefetch68 , LinkResource 69 69 #endif 70 70 }; … … 130 130 131 131 virtual bool isImage() const { return false; } 132 bool is Prefetch() const132 bool isLinkResource() const 133 133 { 134 134 #if ENABLE(LINK_PREFETCH) 135 return type() == Link Prefetch;135 return type() == LinkResource; 136 136 #else 137 137 return false; -
trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp
r83235 r84110 72 72 #endif 73 73 #if ENABLE(LINK_PREFETCH) 74 case CachedResource::Link Prefetch:75 return new CachedResource(url.string(), CachedResource::Link Prefetch);74 case CachedResource::LinkResource: 75 return new CachedResource(url.string(), CachedResource::LinkResource); 76 76 #endif 77 77 } … … 189 189 190 190 #if ENABLE(LINK_PREFETCH) 191 CachedResource* CachedResourceLoader::requestLink Prefetch(const String& url)191 CachedResource* CachedResourceLoader::requestLinkResource(const String& url, ResourceLoadPriority priority) 192 192 { 193 193 ASSERT(frame()); 194 return requestResource(CachedResource::Link Prefetch, url, String());194 return requestResource(CachedResource::LinkResource, url, String(), priority); 195 195 } 196 196 #endif … … 207 207 case CachedResource::FontResource: 208 208 #if ENABLE(LINK_PREFETCH) 209 case CachedResource::Link Prefetch:209 case CachedResource::LinkResource: 210 210 #endif 211 211 // These types of resources can be loaded from any origin. … … 249 249 } 250 250 #if ENABLE(LINK_PREFETCH) 251 case CachedResource::Link Prefetch:251 case CachedResource::LinkResource: 252 252 // Prefetch cannot affect the current document. 253 253 break; … … 594 594 void CachedResourceLoader::incrementRequestCount(const CachedResource* res) 595 595 { 596 if (res->is Prefetch())596 if (res->isLinkResource()) 597 597 return; 598 598 … … 602 602 void CachedResourceLoader::decrementRequestCount(const CachedResource* res) 603 603 { 604 if (res->is Prefetch())604 if (res->isLinkResource()) 605 605 return; 606 606 -
trunk/Source/WebCore/loader/cache/CachedResourceLoader.h
r80695 r84110 70 70 #endif 71 71 #if ENABLE(LINK_PREFETCH) 72 CachedResource* requestLink Prefetch(const String &url);72 CachedResource* requestLinkResource(const String &url, ResourceLoadPriority priority = ResourceLoadPriorityUnresolved); 73 73 #endif 74 74 -
trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp
r78558 r84110 43 43 namespace WebCore { 44 44 45 static ResourceRequest::TargetType cachedResourceTypeToTargetType(CachedResource::Type type) 46 { 45 static ResourceRequest::TargetType cachedResourceTypeToTargetType(CachedResource::Type type, ResourceLoadPriority priority) 46 { 47 #if !ENABLE(LINK_PREFETCH) 48 UNUSED_PARAM(priority); 49 #endif 47 50 switch (type) { 48 51 case CachedResource::CSSStyleSheet: … … 58 61 return ResourceRequest::TargetIsImage; 59 62 #if ENABLE(LINK_PREFETCH) 60 case CachedResource::LinkPrefetch: 61 return ResourceRequest::TargetIsPrefetch; 63 case CachedResource::LinkResource: 64 if (priority == ResourceLoadPriorityLowest) 65 return ResourceRequest::TargetIsPrefetch; 66 return ResourceRequest::TargetIsSubresource; 62 67 #endif 63 68 } … … 86 91 87 92 ResourceRequest resourceRequest(resource->url()); 88 resourceRequest.setTargetType(cachedResourceTypeToTargetType(resource->type() ));93 resourceRequest.setTargetType(cachedResourceTypeToTargetType(resource->type(), resource->loadPriority())); 89 94 90 95 if (!resource->accept().isEmpty()) … … 109 114 110 115 #if ENABLE(LINK_PREFETCH) 111 if (resource->type() == CachedResource::Link Prefetch)116 if (resource->type() == CachedResource::LinkResource) 112 117 resourceRequest.setHTTPHeaderField("Purpose", "prefetch"); 113 118 #endif
Note: See TracChangeset
for help on using the changeset viewer.