Changeset 35801 in webkit
- Timestamp:
- Aug 15, 2008 3:58:06 PM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r35800 r35801 1 2008-08-15 Antti Koivisto <antti@apple.com> 2 3 Reviewed by Anders. 4 5 Don't start preloading body resources before the head is complete. This prevents 6 body preloads from slowing down initial display when there is limited amount 7 of bandwidth available. 8 9 Works by queuing up found body preloads to DocLoader and only issuing them 10 after document has rendering. 11 12 With bandwidth capped to 300kbit/s this speeds up cnn.com initial display by ~25% or 5s 13 without affecting complete load time. 14 15 * html/PreloadScanner.cpp: 16 (WebCore::PreloadScanner::PreloadScanner): 17 (WebCore::PreloadScanner::scanningBody): 18 (WebCore::PreloadScanner::emitTag): 19 (WebCore::PreloadScanner::emitCSSRule): 20 * html/PreloadScanner.h: 21 * loader/DocLoader.cpp: 22 (WebCore::DocLoader::preload): 23 (WebCore::DocLoader::checkForPendingPreloads): 24 (WebCore::DocLoader::requestPreload): 25 * loader/DocLoader.h: 26 * loader/loader.cpp: 27 (WebCore::Loader::Host::didFinishLoading): 28 (WebCore::Loader::Host::didFail): 29 1 30 2008-08-15 Ada Chan <adachan@apple.com> 2 31 -
trunk/WebCore/html/PreloadScanner.cpp
r35298 r35801 67 67 : m_inProgress(false) 68 68 , m_timeUsed(0) 69 , m_bodySeen(false) 69 70 , m_document(doc) 70 71 { … … 119 120 m_cssRule.clear(); 120 121 m_cssRuleValue.clear(); 122 } 123 124 bool PreloadScanner::scanningBody() const 125 { 126 return m_document->body() || m_bodySeen; 121 127 } 122 128 … … 811 817 m_contentModel = PCDATA; 812 818 819 if (tag == bodyTag) 820 m_bodySeen = true; 821 813 822 if (m_urlToLoad.isEmpty()) { 814 823 m_linkIsStyleSheet = false; … … 817 826 818 827 if (tag == scriptTag) 819 m_document->docLoader()->preload(CachedResource::Script, m_urlToLoad, m_charset );828 m_document->docLoader()->preload(CachedResource::Script, m_urlToLoad, m_charset, scanningBody()); 820 829 else if (tag == imgTag) 821 m_document->docLoader()->preload(CachedResource::ImageResource, m_urlToLoad, String() );830 m_document->docLoader()->preload(CachedResource::ImageResource, m_urlToLoad, String(), scanningBody()); 822 831 else if (tag == linkTag && m_linkIsStyleSheet) 823 m_document->docLoader()->preload(CachedResource::CSSStyleSheet, m_urlToLoad, m_charset );832 m_document->docLoader()->preload(CachedResource::CSSStyleSheet, m_urlToLoad, m_charset, scanningBody()); 824 833 825 834 m_urlToLoad = String(); … … 835 844 String url = parseURL(value); 836 845 if (!url.isEmpty()) 837 m_document->docLoader()->preload(CachedResource::CSSStyleSheet, url, String() );846 m_document->docLoader()->preload(CachedResource::CSSStyleSheet, url, String(), scanningBody()); 838 847 } 839 848 m_cssRule.clear(); -
trunk/WebCore/html/PreloadScanner.h
r31964 r35801 46 46 void end(); 47 47 bool inProgress() const { return m_inProgress; } 48 49 bool scanningBody() const; 48 50 49 51 static unsigned consumeEntity(SegmentedString&, bool& notEnoughCharacters); … … 134 136 double m_timeUsed; 135 137 138 bool m_bodySeen; 136 139 Document* m_document; 137 140 }; -
trunk/WebCore/loader/DocLoader.cpp
r34815 r35801 300 300 } 301 301 302 void DocLoader::preload(CachedResource::Type type, const String& url, const String& charset) 302 void DocLoader::preload(CachedResource::Type type, const String& url, const String& charset, bool referencedFromBody) 303 { 304 bool hasRendering = m_doc->body() && m_doc->body()->renderer(); 305 if (!hasRendering && (referencedFromBody || type == CachedResource::ImageResource)) { 306 // Don't preload images or body resources before we have something to draw. This prevents 307 // preloads from body delaying first display when bandwidth is limited. 308 PendingPreload pendingPreload = { type, url, charset }; 309 m_pendingPreloads.append(pendingPreload); 310 return; 311 } 312 requestPreload(type, url, charset); 313 } 314 315 void DocLoader::checkForPendingPreloads() 316 { 317 unsigned count = m_pendingPreloads.size(); 318 if (!count || !m_doc->body() || !m_doc->body()->renderer()) 319 return; 320 for (unsigned i = 0; i < count; ++i) { 321 PendingPreload& preload = m_pendingPreloads[i]; 322 requestPreload(preload.m_type, preload.m_url, preload.m_charset); 323 } 324 m_pendingPreloads.clear(); 325 } 326 327 void DocLoader::requestPreload(CachedResource::Type type, const String& url, const String& charset) 303 328 { 304 329 String encoding; -
trunk/WebCore/loader/DocLoader.h
r34815 r35801 99 99 100 100 void clearPreloads(); 101 void preload(CachedResource::Type type, const String& url, const String& charset); 101 void preload(CachedResource::Type, const String& url, const String& charset, bool referencedFromBody); 102 void checkForPendingPreloads(); 102 103 void printPreloadStats(); 103 104 104 105 private: 105 106 CachedResource* requestResource(CachedResource::Type, const String& url, const String& charset, bool isPreload = false); 107 void requestPreload(CachedResource::Type, const String& url, const String& charset); 106 108 107 109 void checkForReload(const KURL&); … … 117 119 118 120 ListHashSet<CachedResource*> m_preloads; 121 struct PendingPreload { 122 CachedResource::Type m_type; 123 String m_url; 124 String m_charset; 125 }; 126 Vector<PendingPreload> m_pendingPreloads; 119 127 120 128 //29 bits left -
trunk/WebCore/loader/loader.cpp
r35799 r35801 282 282 283 283 docLoader->setLoadInProgress(false); 284 285 docLoader->checkForPendingPreloads(); 284 286 285 287 #if REQUEST_DEBUG … … 321 323 322 324 delete request; 325 326 docLoader->checkForPendingPreloads(); 323 327 324 328 servePendingRequests();
Note: See TracChangeset
for help on using the changeset viewer.