- Revision
- 112949
- Author
- [email protected]
- Date
- 2012-04-02 15:08:19 -0700 (Mon, 02 Apr 2012)
Log Message
Simplify main resource load start/end in FrameLoader
and DocumentLoader.
https://bugs.webkit.org/show_bug.cgi?id=82935
1. Have FrameLoader call prepareForLoadStart() on itself directly, rather
than through DocumentLoader.
2. Remove DocumentLoader::m_primaryLoadComplete, since this is basically equivalent
to m_mainResourceLoader.
3. Rename setPrimaryLoadComplete() to clearMainResourceLoader(), and only call it at
the end of the main resource load.
4. Move clearing DocumentLoader::m_mainResourceError into startLoadingMainResource(),
which leaves DocumentLoader::prepareForLoadStart() empty.
Reviewed by Adam Barth.
No new tests, refactor only.
* WebCore.exp.in:
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::DocumentLoader):
(WebCore):
(WebCore::DocumentLoader::mainReceivedError):
(WebCore::DocumentLoader::finishedLoading):
(WebCore::DocumentLoader::clearMainResourceLoader):
(WebCore::DocumentLoader::isLoadingInAPISense):
(WebCore::DocumentLoader::startLoadingMainResource):
* loader/DocumentLoader.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::commitProvisionalLoad):
(WebCore::FrameLoader::continueLoadAfterWillSubmitForm):
(WebCore::FrameLoader::loadProvisionalItemFromCachedPage):
* loader/FrameLoader.h: prepareForLoadStart() is now called directly,
so make it private.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (112948 => 112949)
--- trunk/Source/WebCore/ChangeLog 2012-04-02 22:05:59 UTC (rev 112948)
+++ trunk/Source/WebCore/ChangeLog 2012-04-02 22:08:19 UTC (rev 112949)
@@ -1,3 +1,39 @@
+2012-04-02 Nate Chapin <[email protected]>
+
+ Simplify main resource load start/end in FrameLoader
+ and DocumentLoader.
+ https://bugs.webkit.org/show_bug.cgi?id=82935
+
+ 1. Have FrameLoader call prepareForLoadStart() on itself directly, rather
+ than through DocumentLoader.
+ 2. Remove DocumentLoader::m_primaryLoadComplete, since this is basically equivalent
+ to m_mainResourceLoader.
+ 3. Rename setPrimaryLoadComplete() to clearMainResourceLoader(), and only call it at
+ the end of the main resource load.
+ 4. Move clearing DocumentLoader::m_mainResourceError into startLoadingMainResource(),
+ which leaves DocumentLoader::prepareForLoadStart() empty.
+
+ Reviewed by Adam Barth.
+
+ No new tests, refactor only.
+
+ * WebCore.exp.in:
+ * loader/DocumentLoader.cpp:
+ (WebCore::DocumentLoader::DocumentLoader):
+ (WebCore):
+ (WebCore::DocumentLoader::mainReceivedError):
+ (WebCore::DocumentLoader::finishedLoading):
+ (WebCore::DocumentLoader::clearMainResourceLoader):
+ (WebCore::DocumentLoader::isLoadingInAPISense):
+ (WebCore::DocumentLoader::startLoadingMainResource):
+ * loader/DocumentLoader.h:
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::commitProvisionalLoad):
+ (WebCore::FrameLoader::continueLoadAfterWillSubmitForm):
+ (WebCore::FrameLoader::loadProvisionalItemFromCachedPage):
+ * loader/FrameLoader.h: prepareForLoadStart() is now called directly,
+ so make it private.
+
2012-04-02 Tim Horton <[email protected]>
ASSERTION FAILED: m_purgePreventCount in FontCache::getCachedFontData running svg/custom/animate-disallowed-use-element.svg
Modified: trunk/Source/WebCore/WebCore.exp.in (112948 => 112949)
--- trunk/Source/WebCore/WebCore.exp.in 2012-04-02 22:05:59 UTC (rev 112948)
+++ trunk/Source/WebCore/WebCore.exp.in 2012-04-02 22:08:19 UTC (rev 112949)
@@ -327,7 +327,6 @@
__ZN7WebCore14DocumentLoader13attachToFrameEv
__ZN7WebCore14DocumentLoader15detachFromFrameEv
__ZN7WebCore14DocumentLoader18addArchiveResourceEN3WTF10PassRefPtrINS_15ArchiveResourceEEE
-__ZN7WebCore14DocumentLoader19prepareForLoadStartEv
__ZN7WebCore14DocumentLoader21addPlugInStreamLoaderEPNS_14ResourceLoaderE
__ZN7WebCore14DocumentLoader22addAllArchiveResourcesEPNS_7ArchiveE
__ZN7WebCore14DocumentLoader22cancelMainResourceLoadERKNS_13ResourceErrorE
Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (112948 => 112949)
--- trunk/Source/WebCore/loader/DocumentLoader.cpp 2012-04-02 22:05:59 UTC (rev 112948)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp 2012-04-02 22:08:19 UTC (rev 112949)
@@ -91,7 +91,6 @@
, m_committed(false)
, m_isStopping(false)
, m_gotFirstByte(false)
- , m_primaryLoadComplete(false)
, m_isClientRedirect(false)
, m_wasOnloadHandled(false)
, m_stopRecordingResponses(false)
@@ -188,11 +187,6 @@
frameLoader()->client()->setMainDocumentError(this, error);
}
-void DocumentLoader::clearErrors()
-{
- m_mainDocumentError = ResourceError();
-}
-
void DocumentLoader::mainReceivedError(const ResourceError& error)
{
ASSERT(!error.isNull());
@@ -202,7 +196,7 @@
if (!frameLoader())
return;
setMainDocumentError(error);
- setPrimaryLoadComplete(true);
+ clearMainResourceLoader();
frameLoader()->receivedMainResourceError(error);
}
@@ -294,7 +288,7 @@
m_writer.end();
if (!m_mainDocumentError.isNull() || frameLoader()->stateMachine()->creatingInitialEmptyDocument())
return;
- setPrimaryLoadComplete(true);
+ clearMainResourceLoader();
frameLoader()->checkLoadComplete();
}
@@ -414,27 +408,15 @@
m_frame = 0;
}
-void DocumentLoader::prepareForLoadStart()
+void DocumentLoader::clearMainResourceLoader()
{
- ASSERT(!m_isStopping);
- setPrimaryLoadComplete(false);
- ASSERT(frameLoader());
- clearErrors();
- frameLoader()->prepareForLoadStart();
-}
-
-void DocumentLoader::setPrimaryLoadComplete(bool flag)
-{
- m_primaryLoadComplete = flag;
- if (flag) {
- if (m_mainResourceLoader) {
- m_mainResourceData = m_mainResourceLoader->resourceData();
- m_mainResourceLoader = 0;
- }
-
- if (this == frameLoader()->activeDocumentLoader())
- checkLoadComplete();
+ if (m_mainResourceLoader) {
+ m_mainResourceData = m_mainResourceLoader->resourceData();
+ m_mainResourceLoader = 0;
}
+
+ if (this == frameLoader()->activeDocumentLoader())
+ checkLoadComplete();
}
bool DocumentLoader::isLoadingInAPISense() const
@@ -446,7 +428,7 @@
return true;
Document* doc = m_frame->document();
- if ((!m_primaryLoadComplete || !m_frame->document()->loadEventFinished()) && isLoading())
+ if ((m_mainResourceLoader || !m_frame->document()->loadEventFinished()) && isLoading())
return true;
if (doc->cachedResourceLoader()->requestCount())
return true;
@@ -797,6 +779,7 @@
void DocumentLoader::startLoadingMainResource()
{
+ m_mainDocumentError = ResourceError();
timing()->markNavigationStart(m_frame);
ASSERT(!m_mainResourceLoader);
m_mainResourceLoader = MainResourceLoader::create(m_frame);
@@ -805,7 +788,7 @@
// If not, it would be great to remove this line of code.
frameLoader()->addExtraFieldsToMainResourceRequest(m_request);
- // Protect MainResourceLoader::load() method chain from setPrimaryLoadComplete() stomping m_mainResourceLoader.
+ // Protect MainResourceLoader::load() method chain from clearMainResourceLoader() stomping m_mainResourceLoader.
RefPtr<MainResourceLoader> protectedMainResourceLoader(m_mainResourceLoader);
if (!protectedMainResourceLoader->load(m_request, m_substituteData)) {
// FIXME: If this should really be caught, we should just ASSERT this doesn't happen;
Modified: trunk/Source/WebCore/loader/DocumentLoader.h (112948 => 112949)
--- trunk/Source/WebCore/loader/DocumentLoader.h 2012-04-02 22:05:59 UTC (rev 112948)
+++ trunk/Source/WebCore/loader/DocumentLoader.h 2012-04-02 22:08:19 UTC (rev 112949)
@@ -118,13 +118,11 @@
const ResourceError& mainDocumentError() const { return m_mainDocumentError; }
void mainReceivedError(const ResourceError&);
void setResponse(const ResourceResponse& response) { m_response = response; }
- void prepareForLoadStart();
bool isClientRedirect() const { return m_isClientRedirect; }
void setIsClientRedirect(bool isClientRedirect) { m_isClientRedirect = isClientRedirect; }
void handledOnloadEvents();
bool wasOnloadHandled() { return m_wasOnloadHandled; }
bool isLoadingInAPISense() const;
- void setPrimaryLoadComplete(bool);
void setTitle(const StringWithDirection&);
const String& overrideEncoding() const { return m_overrideEncoding; }
@@ -254,11 +252,11 @@
private:
void setupForReplace();
void commitIfReady();
- void clearErrors();
void setMainDocumentError(const ResourceError&);
void commitLoad(const char*, int);
bool doesProgressiveLoad(const String& MIMEType) const;
void checkLoadComplete();
+ void clearMainResourceLoader();
void deliverSubstituteResourcesAfterDelay();
void substituteResourceDeliveryTimerFired(Timer<DocumentLoader>*);
@@ -298,7 +296,6 @@
bool m_committed;
bool m_isStopping;
bool m_gotFirstByte;
- bool m_primaryLoadComplete;
bool m_isClientRedirect;
// FIXME: Document::m_processingLoadEvent and DocumentLoader::m_wasOnloadHandled are roughly the same
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (112948 => 112949)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2012-04-02 22:05:59 UTC (rev 112948)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2012-04-02 22:08:19 UTC (rev 112949)
@@ -1732,8 +1732,6 @@
pageCache()->remove(history()->currentItem());
- m_documentLoader->setPrimaryLoadComplete(true);
-
// FIXME: Why only this frame and not parent frames?
checkLoadCompleteForThisFrame();
}
@@ -2199,8 +2197,7 @@
if (!m_provisionalDocumentLoader)
return;
- // DocumentLoader calls back to our prepareForLoadStart
- m_provisionalDocumentLoader->prepareForLoadStart();
+ prepareForLoadStart();
// The load might be cancelled inside of prepareForLoadStart(), nulling out the m_provisionalDocumentLoader,
// so we need to null check it again.
@@ -2914,7 +2911,7 @@
DocumentLoader* provisionalLoader = provisionalDocumentLoader();
LOG(PageCache, "WebCorePageCache: Loading provisional DocumentLoader %p with URL '%s' from CachedPage", provisionalDocumentLoader(), provisionalDocumentLoader()->url().string().utf8().data());
- provisionalLoader->prepareForLoadStart();
+ prepareForLoadStart();
m_loadingFromCachedPage = true;
Modified: trunk/Source/WebCore/loader/FrameLoader.h (112948 => 112949)
--- trunk/Source/WebCore/loader/FrameLoader.h 2012-04-02 22:05:59 UTC (rev 112948)
+++ trunk/Source/WebCore/loader/FrameLoader.h 2012-04-02 22:08:19 UTC (rev 112949)
@@ -94,7 +94,6 @@
IconController* icon() const { return &m_icon; }
void prepareForHistoryNavigation();
- void prepareForLoadStart();
void setupForReplace();
// FIXME: These are all functions which start loads. We have too many.
@@ -357,6 +356,7 @@
void loadInSameDocument(const KURL&, SerializedScriptValue* stateObject, bool isNewNavigation);
+ void prepareForLoadStart();
void provisionalLoadStarted();
bool didOpenURL();