Changeset 112144 in webkit
- Timestamp:
- Mar 26, 2012 1:34:00 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r112142 r112144 1 2012-03-26 Nate Chapin <japhet@chromium.org> 2 3 Simplify setting loading state in DocumentLoader 4 https://bugs.webkit.org/show_bug.cgi?id=82099 5 6 Reviewed by Adam Barth. 7 8 The logic for deciding what to return for DocumentLoader::isLoading() 9 is crazy. It's indirectly based on the ResourceLoaders that have 10 registered themselves with the DocumentLoader, but we can make that 11 relationship more direct. 12 13 * loader/DocumentLoader.cpp: 14 (WebCore::DocumentLoader::checkLoadComplete): Renamed from updateLoading, since it's not actually 15 updating anything anymore. It now calls DOMWindow::finishedLoading() if loading is in fact done. 16 (WebCore::DocumentLoader::startLoadingMainResource): The only reason this had a return value was to call 17 updateLoading() if loading failed. Just call checkLoadComplete() directly (this allows it to 18 be private, whereas updateLoading() was public). 19 (WebCore::DocumentLoader::subresourceLoaderFinishedLoadingOnePart): 20 * loader/DocumentLoader.h: 21 (WebCore::DocumentLoader::isLoading): Rather than holding a separate bool, return based on the presence 22 of non-multipart ResourceLoaders directly. 23 * loader/FrameLoader.cpp: 24 (WebCore::FrameLoader::isLoading): Depend on DocumentLoader::isLoading() for the activeDocumentLoader(), 25 rather than indirectly the other way around. 26 (WebCore::FrameLoader::checkLoadCompleteForThisFrame): Remove several assertions that should now be 27 absolutely identical to the remaining !pdl->isLoading(). 28 (WebCore::FrameLoader::continueLoadAfterWillSubmitForm): 29 1 30 2012-03-26 James Robinson <jamesr@chromium.org> 2 31 -
trunk/Source/WebCore/loader/DocumentLoader.cpp
r111361 r112144 91 91 , m_committed(false) 92 92 , m_isStopping(false) 93 , m_loading(false)94 93 , m_gotFirstByte(false) 95 94 , m_primaryLoadComplete(false) … … 214 213 void DocumentLoader::stopLoading() 215 214 { 216 // In some rare cases, calling FrameLoader::stopLoading could set m_loading tofalse.215 // In some rare cases, calling FrameLoader::stopLoading could cause isLoading() to return false. 217 216 // (This can happen when there's a single XMLHttpRequest currently loading and stopLoading causes it 218 217 // to stop loading. Because of this, we need to save it so we don't return early. 219 bool loading = m_loading;218 bool loading = isLoading(); 220 219 221 220 if (m_committed) { … … 237 236 // If something above restarted loading we might run into mysterious crashes like 238 237 // https://bugs.webkit.org/show_bug.cgi?id=62764 and <rdar://problem/9328684> 239 ASSERT(! m_loading);238 ASSERT(!isLoading()); 240 239 return; 241 240 } … … 372 371 } 373 372 374 void DocumentLoader::updateLoading() 375 { 376 if (!m_frame) { 377 setLoading(false); 378 return; 379 } 373 void DocumentLoader::checkLoadComplete() 374 { 375 if (!m_frame || isLoading()) 376 return; 380 377 ASSERT(this == frameLoader()->activeDocumentLoader()); 381 bool wasLoading = m_loading; 382 setLoading(frameLoader()->isLoading()); 383 384 if (wasLoading && !m_loading) { 385 if (DOMWindow* window = m_frame->existingDOMWindow()) 386 window->finishedLoading(); 387 } 378 379 if (DOMWindow* window = m_frame->existingDOMWindow()) 380 window->finishedLoading(); 388 381 } 389 382 … … 424 417 ASSERT(frameLoader()); 425 418 clearErrors(); 426 427 setLoading(true);428 429 419 frameLoader()->prepareForLoadStart(); 430 420 } … … 440 430 441 431 if (this == frameLoader()->activeDocumentLoader()) 442 updateLoading();432 checkLoadComplete(); 443 433 } 444 434 } … … 771 761 { 772 762 m_subresourceLoaders.add(loader); 773 setLoading(true);774 763 } 775 764 … … 777 766 { 778 767 m_subresourceLoaders.remove(loader); 779 updateLoading();768 checkLoadComplete(); 780 769 if (Frame* frame = m_frame) 781 770 frame->loader()->checkLoadComplete(); … … 785 774 { 786 775 m_plugInStreamLoaders.add(loader); 787 setLoading(true);788 776 } 789 777 … … 791 779 { 792 780 m_plugInStreamLoaders.remove(loader); 793 updateLoading();781 checkLoadComplete(); 794 782 } 795 783 … … 799 787 } 800 788 801 bool DocumentLoader::isLoadingSubresources() const802 {803 return !m_subresourceLoaders.isEmpty();804 }805 806 bool DocumentLoader::isLoadingPlugIns() const807 {808 return !m_plugInStreamLoaders.isEmpty();809 }810 811 789 bool DocumentLoader::isLoadingMultipartContent() const 812 790 { … … 814 792 } 815 793 816 boolDocumentLoader::startLoadingMainResource(unsigned long identifier)794 void DocumentLoader::startLoadingMainResource(unsigned long identifier) 817 795 { 818 796 ASSERT(!m_mainResourceLoader); … … 831 809 LOG_ERROR("could not create WebResourceHandle for URL %s -- should be caught by policy handler level", m_request.url().string().ascii().data()); 832 810 m_mainResourceLoader = 0; 833 return false; 834 } 835 836 return true; 811 ASSERT(!isLoading()); 812 checkLoadComplete(); 813 } 837 814 } 838 815 … … 846 823 m_multipartSubresourceLoaders.add(loader); 847 824 m_subresourceLoaders.remove(loader); 848 updateLoading();825 checkLoadComplete(); 849 826 if (Frame* frame = m_frame) 850 827 frame->loader()->checkLoadComplete(); -
trunk/Source/WebCore/loader/DocumentLoader.h
r111361 r112144 111 111 void setCommitted(bool committed) { m_committed = committed; } 112 112 bool isCommitted() const { return m_committed; } 113 bool isLoading() const { return m_loading; } 114 void setLoading(bool loading) { m_loading = loading; } 115 void updateLoading(); 113 bool isLoading() const { return isLoadingMainResource() || !m_subresourceLoaders.isEmpty() || !m_plugInStreamLoaders.isEmpty(); } 116 114 void receivedData(const char*, int); 117 115 void setupForReplaceByMIMEType(const String& newMIMEType); … … 196 194 void setDefersLoading(bool); 197 195 198 boolstartLoadingMainResource(unsigned long identifier);196 void startLoadingMainResource(unsigned long identifier); 199 197 void cancelMainResourceLoad(const ResourceError&); 200 198 … … 208 206 209 207 bool isLoadingMainResource() const; 210 bool isLoadingSubresources() const;211 bool isLoadingPlugIns() const;212 208 bool isLoadingMultipartContent() const; 213 209 … … 263 259 void commitLoad(const char*, int); 264 260 bool doesProgressiveLoad(const String& MIMEType) const; 261 void checkLoadComplete(); 265 262 266 263 void deliverSubstituteResourcesAfterDelay(); … … 301 298 bool m_committed; 302 299 bool m_isStopping; 303 bool m_loading;304 300 bool m_gotFirstByte; 305 301 bool m_primaryLoadComplete; -
trunk/Source/WebCore/loader/FrameLoader.cpp
r111901 r112144 1639 1639 if (!docLoader) 1640 1640 return false; 1641 return docLoader->isLoading MainResource() || docLoader->isLoadingSubresources() || docLoader->isLoadingPlugIns();1641 return docLoader->isLoading(); 1642 1642 } 1643 1643 … … 2213 2213 2214 2214 ASSERT(!pdl->isLoading()); 2215 ASSERT(!pdl->isLoadingMainResource());2216 ASSERT(!pdl->isLoadingSubresources());2217 ASSERT(!pdl->isLoadingPlugIns());2218 2215 2219 2216 // If we're in the middle of loading multipart data, we need to restore the document loader. … … 2317 2314 2318 2315 m_provisionalDocumentLoader->timing()->markNavigationStart(frame()); 2319 2320 if (!m_provisionalDocumentLoader->startLoadingMainResource(identifier)) 2321 m_provisionalDocumentLoader->updateLoading(); 2316 m_provisionalDocumentLoader->startLoadingMainResource(identifier); 2322 2317 } 2323 2318
Note: See TracChangeset
for help on using the changeset viewer.