Title: [89715] trunk/Source/WebCore
Revision
89715
Author
[email protected]
Date
2011-06-24 17:09:37 -0700 (Fri, 24 Jun 2011)

Log Message

2011-06-23  Darin Adler  <[email protected]>

        Reviewed by Adam Barth.

        Remove some unneeded functions from FrameLoader
        https://bugs.webkit.org/show_bug.cgi?id=63295

        Removing 7 of the functions in FrameLoader.h is probably a step
        in the right direction.

        * loader/DocumentLoader.cpp:
        (WebCore::DocumentLoader::handledOnloadEvents):
        Moved the call to stopDeferringEvents in here from FrameLoader.
        * loader/DocumentLoader.h: Ditto.

        * loader/DocumentWriter.h: Fixed a typo.

        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::setFirstPartyForCookies): Changed this to
        use a non-recursive tree walk instead of recursion.
        (WebCore::FrameLoader::stopAllLoaders): Moved the code from
        stopLoadingSubframes inline, since it's only two lines of code.
        (WebCore::FrameLoader::checkLoadCompleteForThisFrame): Moved
        the code from markLoadComplete inline, since it's only one line.
        (WebCore::FrameLoader::checkLoadComplete): Changed this to use a
        non-recursive tree walk instead of recursion, eliminating the
        recursiveCheckLoadComplete function completely.
        (WebCore::FrameLoader::handledOnloadEvents): Moved the call to
        stopDeferringEvents into DocumentLoader.

        * loader/FrameLoader.h: Removed unneeded forward declarations,
        and now-unneeded functions setupForReplaceByMIMEType,
        isStopping, isLoadingFromCachedPage, stopLoadingSubframes,
        markLoadComplete, mainReceivedError, and recursiveCheckLoadComplete.
        Also made allChildrenAreComplete private.

        * loader/MainResourceLoader.cpp:
        (WebCore::MainResourceLoader::continueAfterContentPolicy):
        Call DocumentLoader::isStopping so we can remove the function
        from FrameLoader that just calls through. Other call sites were
        using DocumentLoader::isStopping directly.
        (WebCore::MainResourceLoader::didReceiveResponse): Call
        DocumentLoader::setupForReplaceByMIMEType so we can remove the
        function from FrameLoader that just calls through. This was
        the only call site.

        * loader/ResourceLoader.cpp:
        (WebCore::ResourceLoader::init): Call the
        ResourceLoader::cancelledError function instead of calling
        directly to FrameLoader.

        * loader/ResourceLoader.h: Made response an inline function.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (89714 => 89715)


--- trunk/Source/WebCore/ChangeLog	2011-06-25 00:03:25 UTC (rev 89714)
+++ trunk/Source/WebCore/ChangeLog	2011-06-25 00:09:37 UTC (rev 89715)
@@ -1,3 +1,56 @@
+2011-06-23  Darin Adler  <[email protected]>
+
+        Reviewed by Adam Barth.
+
+        Remove some unneeded functions from FrameLoader
+        https://bugs.webkit.org/show_bug.cgi?id=63295
+
+        Removing 7 of the functions in FrameLoader.h is probably a step
+        in the right direction.
+
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::handledOnloadEvents):
+        Moved the call to stopDeferringEvents in here from FrameLoader.
+        * loader/DocumentLoader.h: Ditto.
+
+        * loader/DocumentWriter.h: Fixed a typo.
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::setFirstPartyForCookies): Changed this to
+        use a non-recursive tree walk instead of recursion.
+        (WebCore::FrameLoader::stopAllLoaders): Moved the code from
+        stopLoadingSubframes inline, since it's only two lines of code.
+        (WebCore::FrameLoader::checkLoadCompleteForThisFrame): Moved
+        the code from markLoadComplete inline, since it's only one line.
+        (WebCore::FrameLoader::checkLoadComplete): Changed this to use a
+        non-recursive tree walk instead of recursion, eliminating the
+        recursiveCheckLoadComplete function completely.
+        (WebCore::FrameLoader::handledOnloadEvents): Moved the call to
+        stopDeferringEvents into DocumentLoader.
+
+        * loader/FrameLoader.h: Removed unneeded forward declarations,
+        and now-unneeded functions setupForReplaceByMIMEType,
+        isStopping, isLoadingFromCachedPage, stopLoadingSubframes,
+        markLoadComplete, mainReceivedError, and recursiveCheckLoadComplete.
+        Also made allChildrenAreComplete private.
+
+        * loader/MainResourceLoader.cpp:
+        (WebCore::MainResourceLoader::continueAfterContentPolicy):
+        Call DocumentLoader::isStopping so we can remove the function
+        from FrameLoader that just calls through. Other call sites were
+        using DocumentLoader::isStopping directly.
+        (WebCore::MainResourceLoader::didReceiveResponse): Call
+        DocumentLoader::setupForReplaceByMIMEType so we can remove the
+        function from FrameLoader that just calls through. This was
+        the only call site.
+
+        * loader/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::init): Call the
+        ResourceLoader::cancelledError function instead of calling
+        directly to FrameLoader.
+
+        * loader/ResourceLoader.h: Made response an inline function.
+
 2011-06-24  Alexey Proskuryakov  <[email protected]>
 
         Rubber-stamped by Maciej Stachowiak.

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (89714 => 89715)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2011-06-25 00:03:25 UTC (rev 89714)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2011-06-25 00:09:37 UTC (rev 89715)
@@ -915,4 +915,12 @@
     iconDatabase().iconDataForIconURL(urlString, m_iconDataCallback);
 }
 
+void DocumentLoader::handledOnloadEvents()
+{
+    m_wasOnloadHandled = true;
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+    applicationCacheHost()->stopDeferringEvents();
+#endif
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/loader/DocumentLoader.h (89714 => 89715)


--- trunk/Source/WebCore/loader/DocumentLoader.h	2011-06-25 00:03:25 UTC (rev 89714)
+++ trunk/Source/WebCore/loader/DocumentLoader.h	2011-06-25 00:09:37 UTC (rev 89715)
@@ -123,7 +123,7 @@
         void prepareForLoadStart();
         bool isClientRedirect() const { return m_isClientRedirect; }
         void setIsClientRedirect(bool isClientRedirect) { m_isClientRedirect = isClientRedirect; }
-        void handledOnloadEvents() { m_wasOnloadHandled = true; }
+        void handledOnloadEvents();
         bool wasOnloadHandled() { return m_wasOnloadHandled; }
         bool isLoadingInAPISense() const;
         void setPrimaryLoadComplete(bool);

Modified: trunk/Source/WebCore/loader/DocumentWriter.h (89714 => 89715)


--- trunk/Source/WebCore/loader/DocumentWriter.h	2011-06-25 00:03:25 UTC (rev 89714)
+++ trunk/Source/WebCore/loader/DocumentWriter.h	2011-06-25 00:09:37 UTC (rev 89715)
@@ -70,7 +70,7 @@
 
     void setDecoder(TextResourceDecoder*);
 
-    // Exposed for DoucmentParser::appendBytes
+    // Exposed for DocumentParser::appendBytes.
     TextResourceDecoder* createDecoderIfNeeded();
     void reportDataReceived();
 

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (89714 => 89715)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2011-06-25 00:03:25 UTC (rev 89714)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2011-06-25 00:09:37 UTC (rev 89715)
@@ -41,9 +41,7 @@
 #include "CachedPage.h"
 #include "CachedResourceLoader.h"
 #include "Chrome.h"
-#if ENABLE(TOUCH_EVENTS)
 #include "ChromeClient.h"
-#endif
 #include "Console.h"
 #include "ContentSecurityPolicy.h"
 #include "DOMImplementation.h"
@@ -983,9 +981,8 @@
 
 void FrameLoader::setFirstPartyForCookies(const KURL& url)
 {
-    m_frame->document()->setFirstPartyForCookies(url);
-    for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling())
-        child->loader()->setFirstPartyForCookies(url);
+    for (Frame* frame = m_frame; frame; frame = frame->tree()->traverseNext(m_frame))
+        frame->document()->setFirstPartyForCookies(url);
 }
 
 // This does the same kind of work that didOpenURL does, except it relies on the fact
@@ -1095,11 +1092,6 @@
     detachChildren();
 }
 
-void FrameLoader::setupForReplaceByMIMEType(const String& newMIMEType)
-{
-    activeDocumentLoader()->setupForReplaceByMIMEType(newMIMEType);
-}
-
 // This is a hack to allow keep navigation to http/https feeds working. To remove this
 // we need to introduce new API akin to registerURLSchemeAsLocal, that registers a
 // protocols navigation policy.
@@ -1555,12 +1547,6 @@
     return false;
 }
 
-void FrameLoader::stopLoadingSubframes(ClearProvisionalItemPolicy clearProvisionalItemPolicy)
-{
-    for (RefPtr<Frame> child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling())
-        child->loader()->stopAllLoaders(clearProvisionalItemPolicy);
-}
-
 void FrameLoader::stopAllLoaders(ClearProvisionalItemPolicy clearProvisionalItemPolicy)
 {
     ASSERT(!m_frame->document() || !m_frame->document()->inPageCache());
@@ -1580,7 +1566,8 @@
     if (clearProvisionalItemPolicy == ShouldClearProvisionalItem)
         history()->setProvisionalItem(0);
 
-    stopLoadingSubframes(clearProvisionalItemPolicy);
+    for (RefPtr<Frame> child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling())
+        child->loader()->stopAllLoaders(clearProvisionalItemPolicy);
     if (m_provisionalDocumentLoader)
         m_provisionalDocumentLoader->stopLoading();
     if (m_documentLoader)
@@ -1714,11 +1701,6 @@
     setState(FrameStateComplete);
 }
 
-void FrameLoader::markLoadComplete()
-{
-    setState(FrameStateComplete);
-}
-
 void FrameLoader::commitProvisionalLoad()
 {
     RefPtr<CachedPage> cachedPage = m_loadingFromCachedPage ? pageCache()->get(history()->provisionalItem()) : 0;
@@ -2040,11 +2022,6 @@
     cachedFrame.restore();
 }
 
-bool FrameLoader::isStopping() const
-{
-    return activeDocumentLoader()->isStopping();
-}
-
 void FrameLoader::finishedLoading()
 {
     // Retain because the stop may release the last reference to it.
@@ -2240,7 +2217,7 @@
             if (!dl || (dl->isLoadingInAPISense() && !dl->isStopping()))
                 return;
 
-            markLoadComplete();
+            setState(FrameStateComplete);
 
             // FIXME: Is this subsequent work important if we already navigated away?
             // Maybe there are bugs because of that, or extra work we can skip because
@@ -2362,21 +2339,7 @@
     m_frame->tree()->removeChild(child);
 }
 
-void FrameLoader::recursiveCheckLoadComplete()
-{
-    Vector<RefPtr<Frame>, 10> frames;
-    
-    for (RefPtr<Frame> frame = m_frame->tree()->firstChild(); frame; frame = frame->tree()->nextSibling())
-        frames.append(frame);
-    
-    unsigned size = frames.size();
-    for (unsigned i = 0; i < size; i++)
-        frames[i]->loader()->recursiveCheckLoadComplete();
-    
-    checkLoadCompleteForThisFrame();
-}
-
-// Called every time a resource is completely loaded, or an error is received.
+// Called every time a resource is completely loaded or an error is received.
 void FrameLoader::checkLoadComplete()
 {
     ASSERT(m_client->hasWebView());
@@ -2385,8 +2348,14 @@
 
     // FIXME: Always traversing the entire frame tree is a bit inefficient, but 
     // is currently needed in order to null out the previous history item for all frames.
-    if (Page* page = m_frame->page())
-        page->mainFrame()->loader()->recursiveCheckLoadComplete();
+    if (Page* page = m_frame->page()) {
+        Vector<RefPtr<Frame>, 10> frames;
+        for (RefPtr<Frame> frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext())
+            frames.append(frame);
+        // To process children before their parents, iterate the vector backwards.
+        for (size_t i = frames.size(); i; --i)
+            frames[i - 1]->loader()->checkLoadCompleteForThisFrame();
+    }
 }
 
 int FrameLoader::numPendingOrLoadingRequests(bool recurse) const
@@ -2411,12 +2380,8 @@
 {
     m_client->dispatchDidHandleOnloadEvents();
 
-    if (documentLoader()) {
+    if (documentLoader())
         documentLoader()->handledOnloadEvents();
-#if ENABLE(OFFLINE_WEB_APPLICATIONS)
-        documentLoader()->applicationCacheHost()->stopDeferringEvents();
-#endif
-    }
 }
 
 void FrameLoader::frameDetached()
@@ -3117,11 +3082,6 @@
         checkLoadComplete();
 }
 
-void FrameLoader::mainReceivedError(const ResourceError& error, bool isComplete)
-{
-    activeDocumentLoader()->mainReceivedError(error, isComplete);
-}
-
 ResourceError FrameLoader::cancelledError(const ResourceRequest& request) const
 {
     ResourceError error = m_client->cancelledError(request);

Modified: trunk/Source/WebCore/loader/FrameLoader.h (89714 => 89715)


--- trunk/Source/WebCore/loader/FrameLoader.h	2011-06-25 00:03:25 UTC (rev 89714)
+++ trunk/Source/WebCore/loader/FrameLoader.h	2011-06-25 00:09:37 UTC (rev 89715)
@@ -48,39 +48,27 @@
 namespace WebCore {
 
 class Archive;
-class AuthenticationChallenge;
 class CachedFrameBase;
 class CachedPage;
 class CachedResource;
 class Chrome;
 class DOMWrapperWorld;
-class Document;
 class DocumentLoader;
 class Event;
-class FormData;
 class FormState;
 class FormSubmission;
-class Frame;
 class FrameLoaderClient;
 class FrameNetworkingContext;
-class HistoryItem;
-class HTMLFormElement;
 class NavigationAction;
 class NetworkingContext;
 class Page;
-class ProtectionSpace;
 class ResourceError;
-class ResourceLoader;
 class ResourceRequest;
 class ResourceResponse;
-class ScriptSourceCode;
-class ScriptValue;
 class SecurityOrigin;
 class SerializedScriptValue;
-class SharedBuffer;
 class StringWithDirection;
 class SubstituteData;
-class TextResourceDecoder;
 
 struct FrameLoadRequest;
 struct WindowFeatures;
@@ -105,7 +93,6 @@
 
     void prepareForLoadStart();
     void setupForReplace();
-    void setupForReplaceByMIMEType(const String& newMIMEType);
 
     // FIXME: These are all functions which start loads. We have too many.
     void loadURLIntoChildFrame(const KURL&, const String& referer, Frame*);
@@ -166,11 +153,9 @@
     bool willLoadMediaElementURL(KURL&);
 
     void handleFallbackContent();
-    bool isStopping() const;
 
     void finishedLoading();
 
-    // FIXME: Move this method to ResourceLoader with the rest of the ResourceError accessors.
     ResourceError cancelledError(const ResourceRequest&) const;
 
     bool isHostedByObjectElement() const;
@@ -257,21 +242,18 @@
     void setTitle(const StringWithDirection&);
 
     void commitProvisionalLoad();
-    bool isLoadingFromCachedPage() const { return m_loadingFromCachedPage; }
 
     FrameLoaderStateMachine* stateMachine() const { return &m_stateMachine; }
 
     bool shouldAllowNavigation(Frame* targetFrame) const;
     Frame* findFrameForNavigation(const AtomicString& name);
 
-    void applyUserAgent(ResourceRequest& request);
+    void applyUserAgent(ResourceRequest&);
 
     bool shouldInterruptLoadForXFrameOptions(const String&, const KURL&);
 
-    // FIXME: Should these really be public?
     void completed();
     bool allAncestorsAreComplete() const; // including this
-    bool allChildrenAreComplete() const; // immediate children, not all descendants
     void clientRedirected(const KURL&, double delay, double fireDate, bool lockBackForwardList);
     void clientRedirectCancelledOrFinished(bool cancelWithLoadInProgress);
 
@@ -299,6 +281,8 @@
 #endif
 
 private:
+    bool allChildrenAreComplete() const; // immediate children, not all descendants
+
     void checkTimerFired(Timer<FrameLoader>*);
     
     void loadSameDocumentItem(HistoryItem*);
@@ -313,16 +297,10 @@
     
     void addExtraFieldsToRequest(ResourceRequest&, FrameLoadType loadType, bool isMainResource, bool cookiePolicyURLFromRequest);
 
-    // Also not cool.
-    void stopLoadingSubframes(ClearProvisionalItemPolicy);
-
     void clearProvisionalLoad();
-    void markLoadComplete();
     void transitionToCommitted(PassRefPtr<CachedPage>);
     void frameLoadCompleted();
 
-    void mainReceivedError(const ResourceError&, bool isComplete);
-
     static void callContinueLoadAfterNavigationPolicy(void*, const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue);
     static void callContinueLoadAfterNewWindowPolicy(void*, const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, const NavigationAction&, bool shouldContinue);
     static void callContinueFragmentScrollAfterNavigationPolicy(void*, const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue);
@@ -367,8 +345,6 @@
 
     void requestFromDelegate(ResourceRequest&, unsigned long& identifier, ResourceError&);
 
-    void recursiveCheckLoadComplete();
-
     void detachChildren();
     void closeAndRemoveChild(Frame*);
 

Modified: trunk/Source/WebCore/loader/MainResourceLoader.cpp (89714 => 89715)


--- trunk/Source/WebCore/loader/MainResourceLoader.cpp	2011-06-25 00:03:25 UTC (rev 89714)
+++ trunk/Source/WebCore/loader/MainResourceLoader.cpp	2011-06-25 00:09:37 UTC (rev 89715)
@@ -310,11 +310,11 @@
     if (!reachedTerminalState())
         ResourceLoader::didReceiveResponse(r);
 
-    if (frameLoader() && !frameLoader()->isStopping()) {
+    if (frameLoader() && !frameLoader()->activeDocumentLoader()->isStopping()) {
         if (m_substituteData.isValid()) {
             if (m_substituteData.content()->size())
                 didReceiveData(m_substituteData.content()->data(), m_substituteData.content()->size(), m_substituteData.content()->size(), true);
-            if (frameLoader() && !frameLoader()->isStopping()) 
+            if (frameLoader() && !frameLoader()->activeDocumentLoader()->isStopping()) 
                 didFinishLoading(0);
         } else if (shouldLoadAsEmptyDocument(url) || frameLoader()->client()->representationExistsForURLScheme(url.protocol()))
             didFinishLoading(0);
@@ -330,7 +330,7 @@
 {
     ASSERT(m_waitingForContentPolicy);
     m_waitingForContentPolicy = false;
-    if (frameLoader() && !frameLoader()->isStopping())
+    if (frameLoader() && !frameLoader()->activeDocumentLoader()->isStopping())
         continueAfterContentPolicy(policy, m_response);
     deref(); // balances ref in didReceiveResponse
 }
@@ -390,7 +390,7 @@
 #endif
 
     if (m_loadingMultipartContent) {
-        frameLoader()->setupForReplaceByMIMEType(r.mimeType());
+        frameLoader()->activeDocumentLoader()->setupForReplaceByMIMEType(r.mimeType());
         clearResourceData();
     }
     

Modified: trunk/Source/WebCore/loader/ResourceLoader.cpp (89714 => 89715)


--- trunk/Source/WebCore/loader/ResourceLoader.cpp	2011-06-25 00:03:25 UTC (rev 89714)
+++ trunk/Source/WebCore/loader/ResourceLoader.cpp	2011-06-25 00:09:37 UTC (rev 89715)
@@ -132,7 +132,7 @@
 
     willSendRequest(clientRequest, ResourceResponse());
     if (clientRequest.isNull()) {
-        didFail(frameLoader()->cancelledError(m_request));
+        didFail(cancelledError());
         return false;
     }
 
@@ -394,11 +394,6 @@
     releaseResources();
 }
 
-const ResourceResponse& ResourceLoader::response() const
-{
-    return m_response;
-}
-
 ResourceError ResourceLoader::cancelledError()
 {
     return frameLoader()->cancelledError(m_request);

Modified: trunk/Source/WebCore/loader/ResourceLoader.h (89714 => 89715)


--- trunk/Source/WebCore/loader/ResourceLoader.h	2011-06-25 00:03:25 UTC (rev 89714)
+++ trunk/Source/WebCore/loader/ResourceLoader.h	2011-06-25 00:09:37 UTC (rev 89715)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006, 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -182,6 +182,11 @@
         ResourceRequest m_deferredRequest;
     };
 
+inline const ResourceResponse& ResourceLoader::response() const
+{
+    return m_response;
 }
 
+}
+
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to