[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

abarth at webkit.org abarth at webkit.org
Thu Oct 29 20:42:45 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit 1c893f46dc880fce3c9da0d86b909bc3e4df8d00
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Oct 10 02:27:21 2009 +0000

    2009-10-09  Adam Barth  <abarth at webkit.org>
    
            Reviewed by Darin Adler.
    
            Factor HistoryController out of FrameLoader
            https://bugs.webkit.org/show_bug.cgi?id=30246
    
            Update API call.
    
            * WebView.cpp:
            (WebView::loadBackForwardListFromOtherView):
    2009-10-09  Adam Barth  <abarth at webkit.org>
    
            Reviewed by Darin Adler.
    
            Factor HistoryController out of FrameLoader
            https://bugs.webkit.org/show_bug.cgi?id=30246
    
            Update API call.
    
            * WebCoreSupport/WebFrameLoaderClient.mm:
            (WebFrameLoaderClient::restoreViewState):
            * WebView/WebView.mm:
            (-[WebView _loadBackForwardListFromOtherView:]):
    2009-10-09  Adam Barth  <abarth at webkit.org>
    
            Reviewed by Darin Adler.
    
            Factor HistoryController out of FrameLoader
            https://bugs.webkit.org/show_bug.cgi?id=30246
    
            HistoryController is in charge of managing the current / previous /
            provisional HistoryItems.  The split isn't perfect, but it's a place to
            start.  I'll move HistoryController into its own file in another patch.
    
            * WebCore.base.exp:
            * loader/FrameLoader.cpp:
            (WebCore::HistoryController::HistoryController):
            (WebCore::HistoryController::~HistoryController):
            (WebCore::FrameLoader::FrameLoader):
            (WebCore::FrameLoader::closeURL):
            (WebCore::FrameLoader::begin):
            (WebCore::HistoryController::restoreDocumentState):
            (WebCore::HistoryController::setCurrentItem):
            (WebCore::HistoryController::setProvisionalItem):
            (WebCore::FrameLoader::loadURLIntoChildFrame):
            (WebCore::FrameLoader::canCachePageContainingThisFrame):
            (WebCore::FrameLoader::logCanCacheFrameDecision):
            (WebCore::FrameLoader::scrollToAnchor):
            (WebCore::FrameLoader::commitProvisionalLoad):
            (WebCore::FrameLoader::transitionToCommitted):
            (WebCore::FrameLoader::checkLoadCompleteForThisFrame):
            (WebCore::FrameLoader::didFirstLayout):
            (WebCore::HistoryController::updateForFrameLoadCompleted):
            (WebCore::FrameLoader::frameLoadCompleted):
            (WebCore::FrameLoader::detachFromParent):
            (WebCore::FrameLoader::receivedMainResourceError):
            (WebCore::FrameLoader::continueFragmentScrollAfterNavigationPolicy):
            (WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
            (WebCore::HistoryController::addHistoryItemForFragmentScroll):
            (WebCore::FrameLoader::loadProvisionalItemFromCachedPage):
            (WebCore::FrameLoader::shouldTreatURLAsSameAsCurrent):
            (WebCore::HistoryController::createHistoryItem):
            (WebCore::FrameLoader::checkDidPerformFirstNavigation):
            (WebCore::HistoryController::addBackForwardItemClippedAtTarget):
            (WebCore::HistoryController::createHistoryItemTree):
            (WebCore::HistoryController::saveScrollPositionAndViewStateToItem):
            (WebCore::HistoryController::restoreScrollPositionAndViewState):
            (WebCore::HistoryController::invalidateCurrentItemCachedPage):
            (WebCore::HistoryController::saveDocumentState):
            (WebCore::FrameLoader::loadItem):
            (WebCore::HistoryController::urlsMatchItem):
            (WebCore::HistoryController::goToItem):
            (WebCore::HistoryController::recursiveGoToItem):
            (WebCore::HistoryController::childFramesMatchItem):
            (WebCore::HistoryController::updateForStandardLoad):
            (WebCore::HistoryController::updateForClientRedirect):
            (WebCore::HistoryController::updateForBackForwardNavigation):
            (WebCore::HistoryController::updateForReload):
            (WebCore::HistoryController::updateForRedirectWithLockedBackForwardList):
            (WebCore::HistoryController::updateForCommit):
            (WebCore::HistoryController::updateForAnchorScroll):
            (WebCore::HistoryController::saveDocumentAndScrollState):
            (WebCore::HistoryController::setCurrentItemTitle):
            (WebCore::FrameLoader::didChangeTitle):
            * loader/FrameLoader.h:
            (WebCore::HistoryController::current):
            (WebCore::HistoryController::provisional):
            (WebCore::FrameLoader::policyChecker):
            (WebCore::FrameLoader::history):
            (WebCore::FrameLoader::creatingInitialEmptyDocument):
            * page/Page.cpp:
            (WebCore::Page::goToItem):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49413 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 826b69c..2ce6350 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,73 @@
+2009-10-09  Adam Barth  <abarth at webkit.org>
+
+        Reviewed by Darin Adler.
+
+        Factor HistoryController out of FrameLoader
+        https://bugs.webkit.org/show_bug.cgi?id=30246
+
+        HistoryController is in charge of managing the current / previous /
+        provisional HistoryItems.  The split isn't perfect, but it's a place to
+        start.  I'll move HistoryController into its own file in another patch.
+
+        * WebCore.base.exp:
+        * loader/FrameLoader.cpp:
+        (WebCore::HistoryController::HistoryController):
+        (WebCore::HistoryController::~HistoryController):
+        (WebCore::FrameLoader::FrameLoader):
+        (WebCore::FrameLoader::closeURL):
+        (WebCore::FrameLoader::begin):
+        (WebCore::HistoryController::restoreDocumentState):
+        (WebCore::HistoryController::setCurrentItem):
+        (WebCore::HistoryController::setProvisionalItem):
+        (WebCore::FrameLoader::loadURLIntoChildFrame):
+        (WebCore::FrameLoader::canCachePageContainingThisFrame):
+        (WebCore::FrameLoader::logCanCacheFrameDecision):
+        (WebCore::FrameLoader::scrollToAnchor):
+        (WebCore::FrameLoader::commitProvisionalLoad):
+        (WebCore::FrameLoader::transitionToCommitted):
+        (WebCore::FrameLoader::checkLoadCompleteForThisFrame):
+        (WebCore::FrameLoader::didFirstLayout):
+        (WebCore::HistoryController::updateForFrameLoadCompleted):
+        (WebCore::FrameLoader::frameLoadCompleted):
+        (WebCore::FrameLoader::detachFromParent):
+        (WebCore::FrameLoader::receivedMainResourceError):
+        (WebCore::FrameLoader::continueFragmentScrollAfterNavigationPolicy):
+        (WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
+        (WebCore::HistoryController::addHistoryItemForFragmentScroll):
+        (WebCore::FrameLoader::loadProvisionalItemFromCachedPage):
+        (WebCore::FrameLoader::shouldTreatURLAsSameAsCurrent):
+        (WebCore::HistoryController::createHistoryItem):
+        (WebCore::FrameLoader::checkDidPerformFirstNavigation):
+        (WebCore::HistoryController::addBackForwardItemClippedAtTarget):
+        (WebCore::HistoryController::createHistoryItemTree):
+        (WebCore::HistoryController::saveScrollPositionAndViewStateToItem):
+        (WebCore::HistoryController::restoreScrollPositionAndViewState):
+        (WebCore::HistoryController::invalidateCurrentItemCachedPage):
+        (WebCore::HistoryController::saveDocumentState):
+        (WebCore::FrameLoader::loadItem):
+        (WebCore::HistoryController::urlsMatchItem):
+        (WebCore::HistoryController::goToItem):
+        (WebCore::HistoryController::recursiveGoToItem):
+        (WebCore::HistoryController::childFramesMatchItem):
+        (WebCore::HistoryController::updateForStandardLoad):
+        (WebCore::HistoryController::updateForClientRedirect):
+        (WebCore::HistoryController::updateForBackForwardNavigation):
+        (WebCore::HistoryController::updateForReload):
+        (WebCore::HistoryController::updateForRedirectWithLockedBackForwardList):
+        (WebCore::HistoryController::updateForCommit):
+        (WebCore::HistoryController::updateForAnchorScroll):
+        (WebCore::HistoryController::saveDocumentAndScrollState):
+        (WebCore::HistoryController::setCurrentItemTitle):
+        (WebCore::FrameLoader::didChangeTitle):
+        * loader/FrameLoader.h:
+        (WebCore::HistoryController::current):
+        (WebCore::HistoryController::provisional):
+        (WebCore::FrameLoader::policyChecker):
+        (WebCore::FrameLoader::history):
+        (WebCore::FrameLoader::creatingInitialEmptyDocument):
+        * page/Page.cpp:
+        (WebCore::Page::goToItem):
+
 2009-10-09  Alexey Proskuryakov  <ap at apple.com>
 
         Unreviewed - fixing an obvious typo in my previous check-in.
diff --git a/WebCore/WebCore.base.exp b/WebCore/WebCore.base.exp
index 2995b72..5bf52cb 100644
--- a/WebCore/WebCore.base.exp
+++ b/WebCore/WebCore.base.exp
@@ -162,15 +162,11 @@ __ZN7WebCore11FrameLoader14stopAllLoadersENS_14DatabasePolicyE
 __ZN7WebCore11FrameLoader16detachFromParentEv
 __ZN7WebCore11FrameLoader16loadFrameRequestERKNS_16FrameLoadRequestEbbN3WTF10PassRefPtrINS_5EventEEENS5_INS_9FormStateEEE
 __ZN7WebCore11FrameLoader17stopForUserCancelEb
-__ZN7WebCore11FrameLoader18currentHistoryItemEv
 __ZN7WebCore11FrameLoader21loadURLIntoChildFrameERKNS_4KURLERKNS_6StringEPNS_5FrameE
-__ZN7WebCore11FrameLoader21setCurrentHistoryItemEN3WTF10PassRefPtrINS_11HistoryItemEEE
 __ZN7WebCore11FrameLoader22findFrameForNavigationERKNS_12AtomicStringE
 __ZN7WebCore11FrameLoader23isProcessingUserGestureEv
 __ZN7WebCore11FrameLoader23timeOfLastCompletedLoadEv
 __ZN7WebCore11FrameLoader26reloadWithOverrideEncodingERKNS_6StringE
-__ZN7WebCore11FrameLoader26saveDocumentAndScrollStateEv
-__ZN7WebCore11FrameLoader36saveScrollPositionAndViewStateToItemEPNS_11HistoryItemE
 __ZN7WebCore11FrameLoader4loadERKNS_15ResourceRequestERKNS_14SubstituteDataEb
 __ZN7WebCore11FrameLoader4loadERKNS_15ResourceRequestERKNS_6StringEb
 __ZN7WebCore11FrameLoader4loadERKNS_15ResourceRequestEb
@@ -388,6 +384,7 @@ __ZN7WebCore16threadGlobalDataEv
 __ZN7WebCore17CredentialStorage3getERKNS_15ProtectionSpaceE
 __ZN7WebCore17DOMImplementation14isTextMIMETypeERKNS_6StringE
 __ZN7WebCore17GlyphPageTreeNode18treeGlyphPageCountEv
+__ZN7WebCore17HistoryController26saveDocumentAndScrollStateEv
 __ZN7WebCore17HTMLPlugInElement11getNPObjectEv
 __ZN7WebCore17equalIgnoringCaseEPNS_10StringImplES1_
 __ZN7WebCore18deprecatedParseURLERKNS_6StringE
diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp
index 10db87f..36909d4 100644
--- a/WebCore/loader/FrameLoader.cpp
+++ b/WebCore/loader/FrameLoader.cpp
@@ -163,10 +163,20 @@ static inline bool canReferToParentFrameEncoding(const Frame* frame, const Frame
     return parentFrame && parentFrame->document()->securityOrigin()->canAccess(frame->document()->securityOrigin());
 }
 
+HistoryController::HistoryController(Frame* frame)
+    : m_frame(frame)
+{
+}
+
+HistoryController::~HistoryController()
+{
+}
+
 FrameLoader::FrameLoader(Frame* frame, FrameLoaderClient* client)
     : m_frame(frame)
     , m_client(client)
     , m_policyChecker(frame)
+    , m_history(frame)
     , m_state(FrameStateCommittedPage)
     , m_loadType(FrameLoadTypeStandard)
     , m_delegateIsHandlingProvisionalLoadError(false)
@@ -563,7 +573,7 @@ void FrameLoader::stop()
 
 bool FrameLoader::closeURL()
 {
-    saveDocumentState();
+    history()->saveDocumentState();
     
     // Should only send the pagehide event here if the current document exists and has not been placed in the page cache.    
     Document* currentDocument = m_frame->document();
@@ -826,7 +836,7 @@ void FrameLoader::begin(const KURL& url, bool dispatch, SecurityOrigin* origin)
             document->parseDNSPrefetchControlHeader(dnsPrefetchControl);
     }
 
-    restoreDocumentState();
+    history()->restoreDocumentState();
 
     document->implicitOpen();
     
@@ -1013,13 +1023,13 @@ void FrameLoader::commitIconURLToIconDatabase(const KURL& icon)
     iconDatabase()->setIconURLForPageURL(icon.string(), originalRequestURL().string());
 }
 
-void FrameLoader::restoreDocumentState()
+void HistoryController::restoreDocumentState()
 {
     Document* doc = m_frame->document();
         
     HistoryItem* itemToRestore = 0;
     
-    switch (loadType()) {
+    switch (m_frame->loader()->loadType()) {
         case FrameLoadTypeReload:
         case FrameLoadTypeReloadFromOrigin:
         case FrameLoadTypeSame:
@@ -1031,7 +1041,7 @@ void FrameLoader::restoreDocumentState()
         case FrameLoadTypeIndexedBackForward:
         case FrameLoadTypeRedirectWithLockedBackForwardList:
         case FrameLoadTypeStandard:
-            itemToRestore = m_currentHistoryItem.get(); 
+            itemToRestore = m_currentItem.get(); 
     }
     
     if (!itemToRestore)
@@ -1202,11 +1212,21 @@ KURL FrameLoader::completeURL(const String& url)
     return m_frame->document()->completeURL(url);
 }
 
+void HistoryController::setCurrentItem(HistoryItem* item)
+{
+    m_currentItem = item;
+}
+
+void HistoryController::setProvisionalItem(HistoryItem* item)
+{
+    m_provisionalItem = item;
+}
+
 void FrameLoader::loadURLIntoChildFrame(const KURL& url, const String& referer, Frame* childFrame)
 {
     ASSERT(childFrame);
 
-    HistoryItem* parentItem = currentHistoryItem();
+    HistoryItem* parentItem = history()->currentItem();
     FrameLoadType loadType = this->loadType();
     FrameLoadType childLoadType = FrameLoadTypeRedirectWithLockedBackForwardList;
 
@@ -1222,7 +1242,7 @@ void FrameLoader::loadURLIntoChildFrame(const KURL& url, const String& referer,
             // this is needed is Radar 3213556.
             workingURL = KURL(ParsedURLString, childItem->originalURLString());
             childLoadType = loadType;
-            childFrame->loader()->m_provisionalHistoryItem = childItem;
+            childFrame->loader()->history()->setProvisionalItem(childItem);
         }
     }
 
@@ -1546,7 +1566,7 @@ bool FrameLoader::canCachePageContainingThisFrame()
         && !SharedWorkerRepository::hasSharedWorkers(m_frame->document())
 #endif
         && !m_frame->document()->usingGeolocation()
-        && m_currentHistoryItem
+        && history()->currentItem()
         && !m_quickRedirectComing
         && !m_documentLoader->isLoadingInAPISense()
         && !m_documentLoader->isStopping()
@@ -1697,7 +1717,7 @@ bool FrameLoader::logCanCacheFrameDecision(int indentLevel)
 #endif
         if (m_frame->document()->usingGeolocation())
             { PCLOG("   -Frame uses Geolocation"); cannotCache = true; }
-        if (!m_currentHistoryItem)
+        if (!history()->currentItem())
             { PCLOG("   -No current history item"); cannotCache = true; }
         if (m_quickRedirectComing)
             { PCLOG("   -Quick redirect is coming"); cannotCache = true; }
@@ -1775,7 +1795,7 @@ void FrameLoader::scrollToAnchor(const KURL& url)
     }
     
     m_URL = url;
-    updateHistoryForAnchorScroll();
+    history()->updateForAnchorScroll();
 
     // If we were in the autoscroll/panScroll mode we want to stop it before following the link to the anchor
     m_frame->eventHandler()->stopAutoscrollTimer();
@@ -2418,7 +2438,7 @@ void FrameLoader::commitProvisionalLoad(PassRefPtr<CachedPage> prpCachedPage)
 
     // Check to see if we need to cache the page we are navigating away from into the back/forward cache.
     // We are doing this here because we know for sure that a new page is about to be loaded.
-    cachePageForHistoryItem(m_currentHistoryItem.get());
+    cachePageForHistoryItem(history()->currentItem());
     
     if (m_loadType != FrameLoadTypeReplace)
         closeOldDataSources();
@@ -2452,7 +2472,7 @@ void FrameLoader::commitProvisionalLoad(PassRefPtr<CachedPage> prpCachedPage)
     LOG(Loading, "WebCoreLoading %s: Finished committing provisional load to URL %s", m_frame->tree()->name().string().utf8().data(), m_URL.string().utf8().data());
 
     if (m_loadType == FrameLoadTypeStandard && m_documentLoader->isClientRedirect())
-        updateHistoryForClientRedirect();
+        history()->updateForClientRedirect();
 
     if (m_loadingFromCachedPage) {
         m_frame->document()->documentDidBecomeActive();
@@ -2475,7 +2495,7 @@ void FrameLoader::commitProvisionalLoad(PassRefPtr<CachedPage> prpCachedPage)
             sendRemainingDelegateMessages(identifier, response, static_cast<int>(response.expectedContentLength()), error);
         }
         
-        pageCache()->remove(m_currentHistoryItem.get());
+        pageCache()->remove(history()->currentItem());
 
         m_documentLoader->setPrimaryLoadComplete(true);
 
@@ -2493,7 +2513,7 @@ void FrameLoader::transitionToCommitted(PassRefPtr<CachedPage> cachedPage)
         return;
 
     m_client->setCopiesOnScroll();
-    updateHistoryForCommit();
+    history()->updateForCommit();
 
     // The call to closeURL() invokes the unload event handler, which can execute arbitrary
     // JavaScript. If the script initiates a new load, we need to abandon the current load,
@@ -2525,7 +2545,7 @@ void FrameLoader::transitionToCommitted(PassRefPtr<CachedPage> cachedPage)
         case FrameLoadTypeIndexedBackForward:
             if (Page* page = m_frame->page())
                 if (page->backForwardList()) {
-                    updateHistoryForBackForwardNavigation();
+                    history()->updateForBackForwardNavigation();
 
                     // Create a document view for this document, or used the cached view.
                     if (cachedPage) {
@@ -2543,12 +2563,12 @@ void FrameLoader::transitionToCommitted(PassRefPtr<CachedPage> cachedPage)
         case FrameLoadTypeReloadFromOrigin:
         case FrameLoadTypeSame:
         case FrameLoadTypeReplace:
-            updateHistoryForReload();
+            history()->updateForReload();
             m_client->transitionToCommittedForNewPage();
             break;
 
         case FrameLoadTypeStandard:
-            updateHistoryForStandardLoad();
+            history()->updateForStandardLoad();
 #ifndef BUILDING_ON_TIGER
             // This code was originally added for a Leopard performance imporvement. We decided to 
             // ifdef it to fix correctness issues on Tiger documented in <rdar://problem/5441823>.
@@ -2559,7 +2579,7 @@ void FrameLoader::transitionToCommitted(PassRefPtr<CachedPage> cachedPage)
             break;
 
         case FrameLoadTypeRedirectWithLockedBackForwardList:
-            updateHistoryForRedirectWithLockedBackForwardList();
+            history()->updateForRedirectWithLockedBackForwardList();
             m_client->transitionToCommittedForNewPage();
             break;
 
@@ -2908,7 +2928,7 @@ void FrameLoader::checkLoadCompleteForThisFrame()
             RefPtr<HistoryItem> item;
             if (Page* page = m_frame->page())
                 if (isBackForwardLoadType(loadType()) && m_frame == page->mainFrame())
-                    item = m_currentHistoryItem;
+                    item = history()->currentItem();
                 
             bool shouldReset = true;
             if (!(pdl->isLoadingInAPISense() && !pdl->isStopping())) {
@@ -2957,7 +2977,7 @@ void FrameLoader::checkLoadCompleteForThisFrame()
             // If the user had a scroll point, scroll to it, overriding the anchor point if any.
             if (Page* page = m_frame->page())
                 if ((isBackForwardLoadType(m_loadType) || m_loadType == FrameLoadTypeReload || m_loadType == FrameLoadTypeReloadFromOrigin) && page->backForwardList())
-                    restoreScrollPositionAndViewState();
+                    history()->restoreScrollPositionAndViewState();
 
             if (m_creatingInitialEmptyDocument || !m_committedFirstRealDocumentLoad)
                 return;
@@ -3018,7 +3038,7 @@ void FrameLoader::didFirstLayout()
 {
     if (Page* page = m_frame->page())
         if (isBackForwardLoadType(m_loadType) && page->backForwardList())
-            restoreScrollPositionAndViewState();
+            history()->restoreScrollPositionAndViewState();
 
     m_firstLayoutDone = true;
     m_client->dispatchDidFirstLayout();
@@ -3029,15 +3049,20 @@ void FrameLoader::didFirstVisuallyNonEmptyLayout()
     m_client->dispatchDidFirstVisuallyNonEmptyLayout();
 }
 
+void HistoryController::updateForFrameLoadCompleted()
+{
+    // Even if already complete, we might have set a previous item on a frame that
+    // didn't do any data loading on the past transaction. Make sure to clear these out.
+    m_previousItem = 0;
+}
+
 void FrameLoader::frameLoadCompleted()
 {
     // Note: Can be called multiple times.
 
     m_client->frameLoadCompleted();
 
-    // Even if already complete, we might have set a previous item on a frame that
-    // didn't do any data loading on the past transaction. Make sure to clear these out.
-    m_previousHistoryItem = 0;
+    history()->updateForFrameLoadCompleted();
 
     // After a canceled provisional load, firstLayoutDone is false.
     // Reset it to true if we're displaying a page.
@@ -3138,7 +3163,7 @@ void FrameLoader::detachFromParent()
 
     closeURL();
     stopAllLoaders();
-    saveScrollPositionAndViewStateToItem(currentHistoryItem());
+    history()->saveScrollPositionAndViewStateToItem(history()->currentItem());
     detachChildren();
 
 #if ENABLE(INSPECTOR)
@@ -3380,7 +3405,7 @@ void FrameLoader::receivedMainResourceError(const ResourceError& error, bool isC
     RefPtr<Frame> protect(m_frame);
 
     RefPtr<DocumentLoader> loader = activeDocumentLoader();
-    
+
     if (isComplete) {
         // FIXME: Don't want to do this if an entirely new load is going, so should check
         // that both data sources on the frame are either this or nil.
@@ -3388,7 +3413,7 @@ void FrameLoader::receivedMainResourceError(const ResourceError& error, bool isC
         if (m_client->shouldFallBack(error))
             handleFallbackContent();
     }
-    
+
     if (m_state == FrameStateProvisional && m_provisionalDocumentLoader) {
         if (m_submittedFormURL == m_provisionalDocumentLoader->originalRequestCopy().url())
             m_submittedFormURL = KURL();
@@ -3396,7 +3421,7 @@ void FrameLoader::receivedMainResourceError(const ResourceError& error, bool isC
         // We might have made a page cache item, but now we're bailing out due to an error before we ever
         // transitioned to the new page (before WebFrameState == commit).  The goal here is to restore any state
         // so that the existing view (that wenever got far enough to replace) can continue being used.
-        invalidateCurrentItemCachedPage();
+        history()->invalidateCurrentItemCachedPage();
         
         // Call clientRedirectCancelledOrFinished here so that the frame load delegate is notified that the redirect's
         // status has changed, if there was a redirect. The frame load delegate may have saved some state about
@@ -3406,8 +3431,7 @@ void FrameLoader::receivedMainResourceError(const ResourceError& error, bool isC
         if (m_sentRedirectNotification)
             clientRedirectCancelledOrFinished(false);
     }
-    
-    
+
     loader->mainReceivedError(error, isComplete);
 }
 
@@ -3441,7 +3465,7 @@ void FrameLoader::continueFragmentScrollAfterNavigationPolicy(const ResourceRequ
         // we have already saved away the scroll and doc state for the long slow load,
         // but it's not an obvious case.
 
-        addHistoryItemForFragmentScroll();
+        history()->updateBackForwardListForFragmentScroll();
     }
     
     scrollToAnchor(url);
@@ -3490,7 +3514,7 @@ void FrameLoader::continueLoadAfterNavigationPolicy(const ResourceRequest&, Pass
     // through this method already, nested; otherwise, policyDataSource should still be set.
     ASSERT(m_policyDocumentLoader || !m_provisionalDocumentLoader->unreachableURL().isEmpty());
 
-    bool isTargetItem = m_provisionalHistoryItem ? m_provisionalHistoryItem->isTargetItem() : false;
+    bool isTargetItem = history()->provisionalItem() ? history()->provisionalItem()->isTargetItem() : false;
 
     // Two reasons we can't continue:
     //    1) Navigation policy delegate said we can't so request is nil. A primary case of this 
@@ -3513,7 +3537,7 @@ void FrameLoader::continueLoadAfterNavigationPolicy(const ResourceRequest&, Pass
         if ((isTargetItem || isLoadingMainFrame()) && isBackForwardLoadType(policyChecker()->loadType()))
             if (Page* page = m_frame->page()) {
                 Frame* mainFrame = page->mainFrame();
-                if (HistoryItem* resetItem = mainFrame->loader()->m_currentHistoryItem.get()) {
+                if (HistoryItem* resetItem = mainFrame->loader()->history()->currentItem()) {
                     page->backForwardList()->goToItem(resetItem);
                     Settings* settings = m_frame->settings();
                     page->setGlobalHistoryItem((!settings || settings->privateBrowsingEnabled()) ? 0 : resetItem);
@@ -3670,14 +3694,14 @@ bool FrameLoader::shouldInterruptLoadForXFrameOptions(const String& content, con
     return false;
 }
 
-void FrameLoader::addHistoryItemForFragmentScroll()
+void HistoryController::updateBackForwardListForFragmentScroll()
 {
-    addBackForwardItemClippedAtTarget(false);
+    updateBackForwardListClippedAtTarget(false);
 }
 
 bool FrameLoader::loadProvisionalItemFromCachedPage()
 {
-    RefPtr<CachedPage> cachedPage = pageCache()->get(m_provisionalHistoryItem.get());
+    RefPtr<CachedPage> cachedPage = pageCache()->get(history()->provisionalItem());
     if (!cachedPage || !cachedPage->document())
         return false;
 
@@ -3721,14 +3745,14 @@ void FrameLoader::pageHidden()
 
 bool FrameLoader::shouldTreatURLAsSameAsCurrent(const KURL& url) const
 {
-    if (!m_currentHistoryItem)
+    if (!history()->currentItem())
         return false;
-    return url == m_currentHistoryItem->url() || url == m_currentHistoryItem->originalURL();
+    return url == history()->currentItem()->url() || url == history()->currentItem()->originalURL();
 }
 
-PassRefPtr<HistoryItem> FrameLoader::createHistoryItem(bool useOriginal)
+PassRefPtr<HistoryItem> HistoryController::createItem(bool useOriginal)
 {
-    DocumentLoader* docLoader = documentLoader();
+    DocumentLoader* docLoader = m_frame->loader()->documentLoader();
     
     KURL unreachableURL = docLoader ? docLoader->unreachableURL() : KURL();
     
@@ -3777,13 +3801,25 @@ PassRefPtr<HistoryItem> FrameLoader::createHistoryItem(bool useOriginal)
     }
     
     // Set the item for which we will save document state
-    m_previousHistoryItem = m_currentHistoryItem;
-    m_currentHistoryItem = item;
+    m_previousItem = m_currentItem;
+    m_currentItem = item;
     
     return item.release();
 }
+    
+void FrameLoader::checkDidPerformFirstNavigation()
+{
+    Page* page = m_frame->page();
+    if (!page)
+        return;
 
-void FrameLoader::addBackForwardItemClippedAtTarget(bool doClip)
+    if (!m_didPerformFirstNavigation && page->backForwardList()->entries().size() == 1) {
+        m_didPerformFirstNavigation = true;
+        m_client->didPerformFirstNavigation();
+    }
+}
+
+void HistoryController::updateBackForwardListClippedAtTarget(bool doClip)
 {
     // In the case of saving state about a page with frames, we store a tree of items that mirrors the frame tree.  
     // The item that was the target of the user's navigation is designated as the "targetItem".  
@@ -3794,41 +3830,38 @@ void FrameLoader::addBackForwardItemClippedAtTarget(bool doClip)
     if (!page)
         return;
 
-    if (documentLoader()->urlForHistory().isEmpty())
+    if (m_frame->loader()->documentLoader()->urlForHistory().isEmpty())
         return;
 
     Frame* mainFrame = page->mainFrame();
     ASSERT(mainFrame);
     FrameLoader* frameLoader = mainFrame->loader();
 
-    if (!frameLoader->m_didPerformFirstNavigation && page->backForwardList()->entries().size() == 1) {
-        frameLoader->m_didPerformFirstNavigation = true;
-        m_client->didPerformFirstNavigation();
-    }
+    frameLoader->checkDidPerformFirstNavigation();
 
-    RefPtr<HistoryItem> item = frameLoader->createHistoryItemTree(m_frame, doClip);
-    LOG(BackForward, "WebCoreBackForward - Adding backforward item %p for frame %s", item.get(), documentLoader()->url().string().ascii().data());
+    RefPtr<HistoryItem> item = frameLoader->history()->createItemTree(m_frame, doClip);
+    LOG(BackForward, "WebCoreBackForward - Adding backforward item %p for frame %s", item.get(), m_frame->loader()->documentLoader()->url().string().ascii().data());
     page->backForwardList()->addItem(item);
 }
 
-PassRefPtr<HistoryItem> FrameLoader::createHistoryItemTree(Frame* targetFrame, bool clipAtTarget)
+PassRefPtr<HistoryItem> HistoryController::createItemTree(Frame* targetFrame, bool clipAtTarget)
 {
-    RefPtr<HistoryItem> bfItem = createHistoryItem(m_frame->tree()->parent() ? true : false);
-    if (m_previousHistoryItem)
-        saveScrollPositionAndViewStateToItem(m_previousHistoryItem.get());
+    RefPtr<HistoryItem> bfItem = createItem(m_frame->tree()->parent() ? true : false);
+    if (m_previousItem)
+        saveScrollPositionAndViewStateToItem(m_previousItem.get());
     if (!(clipAtTarget && m_frame == targetFrame)) {
         // save frame state for items that aren't loading (khtml doesn't save those)
         saveDocumentState();
         for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) {
             FrameLoader* childLoader = child->loader();
             bool hasChildLoaded = childLoader->frameHasLoaded();
-            
+
             // If the child is a frame corresponding to an <object> element that never loaded,
             // we don't want to create a history item, because that causes fallback content
             // to be ignored on reload.
             
             if (!(!hasChildLoaded && childLoader->isHostedByObjectElement()))
-                bfItem->addChildItem(childLoader->createHistoryItemTree(targetFrame, clipAtTarget));
+                bfItem->addChildItem(childLoader->history()->createItemTree(targetFrame, clipAtTarget));
         }
     }
     if (m_frame == targetFrame)
@@ -3844,14 +3877,14 @@ Frame* FrameLoader::findFrameForNavigation(const AtomicString& name)
     return frame;
 }
 
-void FrameLoader::saveScrollPositionAndViewStateToItem(HistoryItem* item)
+void HistoryController::saveScrollPositionAndViewStateToItem(HistoryItem* item)
 {
     if (!item || !m_frame->view())
         return;
         
     item->setScrollPoint(m_frame->view()->scrollPosition());
     // FIXME: It would be great to work out a way to put this code in WebCore instead of calling through to the client.
-    m_client->saveViewStateToItem(item);
+    m_frame->loader()->client()->saveViewStateToItem(item);
 }
 
 /*
@@ -3865,34 +3898,34 @@ void FrameLoader::saveScrollPositionAndViewStateToItem(HistoryItem* item)
  2) If the layout happens after the load completes, the attempt to restore at load completion time silently
  fails.  We then successfully restore it when the layout happens.
 */
-void FrameLoader::restoreScrollPositionAndViewState()
+void HistoryController::restoreScrollPositionAndViewState()
 {
-    if (!m_committedFirstRealDocumentLoad)
+    if (!m_frame->loader()->committedFirstRealDocumentLoad())
         return;
 
-    ASSERT(m_currentHistoryItem);
+    ASSERT(m_currentItem);
     
     // FIXME: As the ASSERT attests, it seems we should always have a currentItem here.
     // One counterexample is <rdar://problem/4917290>
     // For now, to cover this issue in release builds, there is no technical harm to returning
     // early and from a user standpoint - as in the above radar - the previous page load failed 
     // so there *is* no scroll or view state to restore!
-    if (!m_currentHistoryItem)
+    if (!m_currentItem)
         return;
     
     // FIXME: It would be great to work out a way to put this code in WebCore instead of calling
     // through to the client. It's currently used only for the PDF view on Mac.
-    m_client->restoreViewState();
+    m_frame->loader()->client()->restoreViewState();
     
     if (FrameView* view = m_frame->view())
         if (!view->wasScrolledByUser())
-            view->setScrollPosition(m_currentHistoryItem->scrollPoint());
+            view->setScrollPosition(m_currentItem->scrollPoint());
 }
 
-void FrameLoader::invalidateCurrentItemCachedPage()
+void HistoryController::invalidateCurrentItemCachedPage()
 {
     // When we are pre-commit, the currentItem is where the pageCache data resides    
-    CachedPage* cachedPage = pageCache()->get(m_currentHistoryItem.get());
+    CachedPage* cachedPage = pageCache()->get(currentItem());
 
     // FIXME: This is a grotesque hack to fix <rdar://problem/4059059> Crash in RenderFlow::detach
     // Somehow the PageState object is not properly updated, and is holding onto a stale document.
@@ -3905,12 +3938,14 @@ void FrameLoader::invalidateCurrentItemCachedPage()
     }
     
     if (cachedPage)
-        pageCache()->remove(m_currentHistoryItem.get());
+        pageCache()->remove(currentItem());
 }
 
-void FrameLoader::saveDocumentState()
+void HistoryController::saveDocumentState()
 {
-    if (m_creatingInitialEmptyDocument)
+    // FIXME: Reading this bit of FrameLoader state here is unfortunate.  I need to study
+    // this more to see if we can remove this dependency.
+    if (m_frame->loader()->creatingInitialEmptyDocument())
         return;
 
     // For a standard page load, we will have a previous item set, which will be used to
@@ -3924,7 +3959,7 @@ void FrameLoader::saveDocumentState()
     // that previousItem be cleared at the end of a page transition.  We leverage the
     // checkLoadComplete recursion to achieve this goal.
 
-    HistoryItem* item = m_previousHistoryItem ? m_previousHistoryItem.get() : m_currentHistoryItem.get();
+    HistoryItem* item = m_previousItem ? m_previousItem.get() : m_currentItem.get();
     if (!item)
         return;
 
@@ -3938,6 +3973,9 @@ void FrameLoader::saveDocumentState()
 }
 
 // Loads content into this frame, as specified by history item
+// FIXME: This function should really be split into a couple pieces, some of
+// which should be methods of HistoryController and some of which should be
+// methods of FrameLoader.
 void FrameLoader::loadItem(HistoryItem* item, FrameLoadType loadType)
 {
     if (!m_frame->page())
@@ -3956,7 +3994,7 @@ void FrameLoader::loadItem(HistoryItem* item, FrameLoadType loadType)
     // check for all that as an additional optimization.
     // We also do not do anchor-style navigation if we're posting a form or navigating from
     // a page that was resulted from a form post.
-    bool shouldScroll = !formData && !(m_currentHistoryItem && m_currentHistoryItem->formData()) && urlsMatchItem(item);
+    bool shouldScroll = !formData && !(history()->currentItem() && history()->currentItem()->formData()) && history()->urlsMatchItem(item);
 
 #if ENABLE(WML)
     // All WML decks should go through the real load mechanism, not the scroll-to-anchor code
@@ -3966,12 +4004,12 @@ void FrameLoader::loadItem(HistoryItem* item, FrameLoadType loadType)
 
     if (shouldScroll) {
         // Must do this maintenance here, since we don't go through a real page reload
-        saveScrollPositionAndViewStateToItem(m_currentHistoryItem.get());
+        history()->saveScrollPositionAndViewStateToItem(history()->currentItem());
 
         if (FrameView* view = m_frame->view())
             view->setWasScrolledByUser(false);
 
-        m_currentHistoryItem = item;
+        history()->setCurrentItem(item);
 
         // FIXME: Form state might need to be saved here too.
 
@@ -3980,7 +4018,7 @@ void FrameLoader::loadItem(HistoryItem* item, FrameLoadType loadType)
         scrollToAnchor(item->url());
     
         // must do this maintenance here, since we don't go through a real page reload
-        restoreScrollPositionAndViewState();
+        history()->restoreScrollPositionAndViewState();
         
         // Fake the URL change by updating the data source's request.  This will no longer
         // be necessary if we do the better fix described above.
@@ -3992,7 +4030,7 @@ void FrameLoader::loadItem(HistoryItem* item, FrameLoadType loadType)
         m_client->didFinishLoad();
     } else {
         // Remember this item so we can traverse any child items as child frames load
-        m_provisionalHistoryItem = item;
+        history()->setProvisionalItem(item);
 
         bool inPageCache = false;
         
@@ -4009,7 +4047,7 @@ void FrameLoader::loadItem(HistoryItem* item, FrameLoadType loadType)
                 loadWithDocumentLoader(cachedPage->documentLoader(), loadType, 0);   
                 inPageCache = true;
             } else {
-                LOG(PageCache, "Not restoring page for %s from back/forward cache because cache entry has expired", m_provisionalHistoryItem->url().string().ascii().data());
+                LOG(PageCache, "Not restoring page for %s from back/forward cache because cache entry has expired", history()->provisionalItem()->url().string().ascii().data());
                 pageCache()->remove(item);
             }
         }
@@ -4085,9 +4123,9 @@ void FrameLoader::loadItem(HistoryItem* item, FrameLoadType loadType)
 }
 
 // Walk the frame tree and ensure that the URLs match the URLs in the item.
-bool FrameLoader::urlsMatchItem(HistoryItem* item) const
+bool HistoryController::urlsMatchItem(HistoryItem* item) const
 {
-    const KURL& currentURL = documentLoader()->url();
+    const KURL& currentURL = m_frame->loader()->documentLoader()->url();
     if (!equalIgnoringFragmentIdentifier(currentURL, item->url()))
         return false;
 
@@ -4096,7 +4134,7 @@ bool FrameLoader::urlsMatchItem(HistoryItem* item) const
     unsigned size = childItems.size();
     for (unsigned i = 0; i < size; ++i) {
         Frame* childFrame = m_frame->tree()->child(childItems[i]->target());
-        if (childFrame && !childFrame->loader()->urlsMatchItem(childItems[i].get()))
+        if (childFrame && !childFrame->loader()->history()->urlsMatchItem(childItems[i].get()))
             return false;
     }
 
@@ -4105,7 +4143,7 @@ bool FrameLoader::urlsMatchItem(HistoryItem* item) const
 
 // Main funnel for navigating to a previous location (back/forward, non-search snap-back)
 // This includes recursion to handle loading into framesets properly
-void FrameLoader::goToItem(HistoryItem* targetItem, FrameLoadType type)
+void HistoryController::goToItem(HistoryItem* targetItem, FrameLoadType type)
 {
     ASSERT(!m_frame->tree()->parent());
     
@@ -4116,7 +4154,7 @@ void FrameLoader::goToItem(HistoryItem* targetItem, FrameLoadType type)
     Page* page = m_frame->page();
     if (!page)
         return;
-    if (!m_client->shouldGoToHistoryItem(targetItem))
+    if (!m_frame->loader()->client()->shouldGoToHistoryItem(targetItem))
         return;
 
     // Set the BF cursor before commit, which lets the user quickly click back/forward again.
@@ -4134,16 +4172,16 @@ void FrameLoader::goToItem(HistoryItem* targetItem, FrameLoadType type)
 // tracking whether each frame already has the content the item requests.  If there is
 // a match (by URL), we just restore scroll position and recurse.  Otherwise we must
 // reload that frame, and all its kids.
-void FrameLoader::recursiveGoToItem(HistoryItem* item, HistoryItem* fromItem, FrameLoadType type)
+void HistoryController::recursiveGoToItem(HistoryItem* item, HistoryItem* fromItem, FrameLoadType type)
 {
     ASSERT(item);
     ASSERT(fromItem);
-    
+
     KURL itemURL = item->url();
     KURL currentURL;
-    if (documentLoader())
-        currentURL = documentLoader()->url();
-    
+    if (m_frame->loader()->documentLoader())
+        currentURL = m_frame->loader()->documentLoader()->url();
+
     // Always reload the target frame of the item we're going to.  This ensures that we will
     // do -some- load for the transition, which means a proper notification will be posted
     // to the app.
@@ -4157,14 +4195,14 @@ void FrameLoader::recursiveGoToItem(HistoryItem* item, HistoryItem* fromItem, Fr
     {
         // This content is good, so leave it alone and look for children that need reloading
         // Save form state (works from currentItem, since prevItem is nil)
-        ASSERT(!m_previousHistoryItem);
+        ASSERT(!m_previousItem);
         saveDocumentState();
-        saveScrollPositionAndViewStateToItem(m_currentHistoryItem.get());
+        saveScrollPositionAndViewStateToItem(m_currentItem.get());
 
         if (FrameView* view = m_frame->view())
             view->setWasScrolledByUser(false);
 
-        m_currentHistoryItem = item;
+        m_currentItem = item;
                 
         // Restore form state (works from currentItem)
         restoreDocumentState();
@@ -4181,16 +4219,16 @@ void FrameLoader::recursiveGoToItem(HistoryItem* item, HistoryItem* fromItem, Fr
             ASSERT(fromChildItem || fromItem->isTargetItem());
             Frame* childFrame = m_frame->tree()->child(childFrameName);
             ASSERT(childFrame);
-            childFrame->loader()->recursiveGoToItem(childItems[i].get(), fromChildItem, type);
+            childFrame->loader()->history()->recursiveGoToItem(childItems[i].get(), fromChildItem, type);
         }
     } else {
-        loadItem(item, type);
+        m_frame->loader()->loadItem(item, type);
     }
 }
 
 // helper method that determines whether the subframes described by the item's subitems
 // match our own current frameset
-bool FrameLoader::childFramesMatchItem(HistoryItem* item) const
+bool HistoryController::childFramesMatchItem(HistoryItem* item) const
 {
     const HistoryItemVector& childItems = item->children();
     if (childItems.size() != m_frame->tree()->childCount())
@@ -4208,61 +4246,63 @@ bool FrameLoader::childFramesMatchItem(HistoryItem* item) const
 
 // There are 3 things you might think of as "history", all of which are handled by these functions.
 //
-//     1) Back/forward: The m_currentHistoryItem is part of this mechanism.
+//     1) Back/forward: The m_currentItem is part of this mechanism.
 //     2) Global history: Handled by the client.
 //     3) Visited links: Handled by the PageGroup.
 
-void FrameLoader::updateHistoryForStandardLoad()
+void HistoryController::updateForStandardLoad()
 {
-    LOG(History, "WebCoreHistory: Updating History for Standard Load in frame %s", documentLoader()->url().string().ascii().data());
+    LOG(History, "WebCoreHistory: Updating History for Standard Load in frame %s", m_frame->loader()->documentLoader()->url().string().ascii().data());
+
+    FrameLoader* frameLoader = m_frame->loader();
 
     Settings* settings = m_frame->settings();
     bool needPrivacy = !settings || settings->privateBrowsingEnabled();
-    const KURL& historyURL = documentLoader()->urlForHistory();
+    const KURL& historyURL = frameLoader->documentLoader()->urlForHistory();
 
-    if (!documentLoader()->isClientRedirect()) {
+    if (!frameLoader->documentLoader()->isClientRedirect()) {
         if (!historyURL.isEmpty()) {
-            addBackForwardItemClippedAtTarget(true);
+            updateBackForwardListClippedAtTarget(true);
             if (!needPrivacy) {
-                m_client->updateGlobalHistory();
-                m_documentLoader->setDidCreateGlobalHistoryEntry(true);
-                if (m_documentLoader->unreachableURL().isEmpty())
-                    m_client->updateGlobalHistoryRedirectLinks();
+                frameLoader->client()->updateGlobalHistory();
+                frameLoader->documentLoader()->setDidCreateGlobalHistoryEntry(true);
+                if (frameLoader->documentLoader()->unreachableURL().isEmpty())
+                    frameLoader->client()->updateGlobalHistoryRedirectLinks();
             }
             if (Page* page = m_frame->page())
                 page->setGlobalHistoryItem(needPrivacy ? 0 : page->backForwardList()->currentItem());
         }
-    } else if (documentLoader()->unreachableURL().isEmpty() && m_currentHistoryItem) {
-        m_currentHistoryItem->setURL(documentLoader()->url());
-        m_currentHistoryItem->setFormInfoFromRequest(documentLoader()->request());
+    } else if (frameLoader->documentLoader()->unreachableURL().isEmpty() && m_currentItem) {
+        m_currentItem->setURL(frameLoader->documentLoader()->url());
+        m_currentItem->setFormInfoFromRequest(frameLoader->documentLoader()->request());
     }
 
     if (!historyURL.isEmpty() && !needPrivacy) {
         if (Page* page = m_frame->page())
             page->group().addVisitedLink(historyURL);
 
-        if (!m_documentLoader->didCreateGlobalHistoryEntry() && documentLoader()->unreachableURL().isEmpty() && !url().isEmpty())
-            m_client->updateGlobalHistoryRedirectLinks();
+        if (!frameLoader->documentLoader()->didCreateGlobalHistoryEntry() && frameLoader->documentLoader()->unreachableURL().isEmpty() && !frameLoader->url().isEmpty())
+            frameLoader->client()->updateGlobalHistoryRedirectLinks();
     }
 }
 
-void FrameLoader::updateHistoryForClientRedirect()
+void HistoryController::updateForClientRedirect()
 {
 #if !LOG_DISABLED
-    if (documentLoader())
-        LOG(History, "WebCoreHistory: Updating History for client redirect in frame %s", documentLoader()->title().utf8().data());
+    if (m_frame->loader()->documentLoader())
+        LOG(History, "WebCoreHistory: Updating History for client redirect in frame %s", m_frame->loader()->documentLoader()->title().utf8().data());
 #endif
 
     // Clear out form data so we don't try to restore it into the incoming page.  Must happen after
     // webcore has closed the URL and saved away the form state.
-    if (m_currentHistoryItem) {
-        m_currentHistoryItem->clearDocumentState();
-        m_currentHistoryItem->clearScrollPoint();
+    if (m_currentItem) {
+        m_currentItem->clearDocumentState();
+        m_currentItem->clearScrollPoint();
     }
 
     Settings* settings = m_frame->settings();
     bool needPrivacy = !settings || settings->privateBrowsingEnabled();
-    const KURL& historyURL = documentLoader()->urlForHistory();
+    const KURL& historyURL = m_frame->loader()->documentLoader()->urlForHistory();
 
     if (!historyURL.isEmpty() && !needPrivacy) {
         if (Page* page = m_frame->page())
@@ -4270,103 +4310,104 @@ void FrameLoader::updateHistoryForClientRedirect()
     }
 }
 
-void FrameLoader::updateHistoryForBackForwardNavigation()
+void HistoryController::updateForBackForwardNavigation()
 {
 #if !LOG_DISABLED
-    if (documentLoader())
-        LOG(History, "WebCoreHistory: Updating History for back/forward navigation in frame %s", documentLoader()->title().utf8().data());
+    if (m_frame->loader()->documentLoader())
+        LOG(History, "WebCoreHistory: Updating History for back/forward navigation in frame %s", m_frame->loader()->documentLoader()->title().utf8().data());
 #endif
 
     // Must grab the current scroll position before disturbing it
-    saveScrollPositionAndViewStateToItem(m_previousHistoryItem.get());
+    saveScrollPositionAndViewStateToItem(m_previousItem.get());
 }
 
-void FrameLoader::updateHistoryForReload()
+void HistoryController::updateForReload()
 {
 #if !LOG_DISABLED
-    if (documentLoader())
-        LOG(History, "WebCoreHistory: Updating History for reload in frame %s", documentLoader()->title().utf8().data());
+    if (m_frame->loader()->documentLoader())
+        LOG(History, "WebCoreHistory: Updating History for reload in frame %s", m_frame->loader()->documentLoader()->title().utf8().data());
 #endif
 
-    if (m_currentHistoryItem) {
-        pageCache()->remove(m_currentHistoryItem.get());
+    if (m_currentItem) {
+        pageCache()->remove(m_currentItem.get());
     
-        if (loadType() == FrameLoadTypeReload || loadType() == FrameLoadTypeReloadFromOrigin)
-            saveScrollPositionAndViewStateToItem(m_currentHistoryItem.get());
+        if (m_frame->loader()->loadType() == FrameLoadTypeReload || m_frame->loader()->loadType() == FrameLoadTypeReloadFromOrigin)
+            saveScrollPositionAndViewStateToItem(m_currentItem.get());
     
         // Sometimes loading a page again leads to a different result because of cookies. Bugzilla 4072
-        if (documentLoader()->unreachableURL().isEmpty())
-            m_currentHistoryItem->setURL(documentLoader()->requestURL());
+        if (m_frame->loader()->documentLoader()->unreachableURL().isEmpty())
+            m_currentItem->setURL(m_frame->loader()->documentLoader()->requestURL());
     }
 }
 
-void FrameLoader::updateHistoryForRedirectWithLockedBackForwardList()
+void HistoryController::updateForRedirectWithLockedBackForwardList()
 {
 #if !LOG_DISABLED
-    if (documentLoader())
-        LOG(History, "WebCoreHistory: Updating History for redirect load in frame %s", documentLoader()->title().utf8().data());
+    if (m_frame->loader()->documentLoader())
+        LOG(History, "WebCoreHistory: Updating History for redirect load in frame %s", m_frame->loader()->documentLoader()->title().utf8().data());
 #endif
     
     Settings* settings = m_frame->settings();
     bool needPrivacy = !settings || settings->privateBrowsingEnabled();
-    const KURL& historyURL = documentLoader()->urlForHistory();
+    const KURL& historyURL = m_frame->loader()->documentLoader()->urlForHistory();
 
-    if (documentLoader()->isClientRedirect()) {
-        if (!m_currentHistoryItem && !m_frame->tree()->parent()) {
+    if (m_frame->loader()->documentLoader()->isClientRedirect()) {
+        if (!m_currentItem && !m_frame->tree()->parent()) {
             if (!historyURL.isEmpty()) {
-                addBackForwardItemClippedAtTarget(true);
+                updateBackForwardListClippedAtTarget(true);
                 if (!needPrivacy) {
-                    m_client->updateGlobalHistory();
-                    m_documentLoader->setDidCreateGlobalHistoryEntry(true);
-                    if (m_documentLoader->unreachableURL().isEmpty())
-                        m_client->updateGlobalHistoryRedirectLinks();
+                    m_frame->loader()->client()->updateGlobalHistory();
+                    m_frame->loader()->documentLoader()->setDidCreateGlobalHistoryEntry(true);
+                    if (m_frame->loader()->documentLoader()->unreachableURL().isEmpty())
+                        m_frame->loader()->client()->updateGlobalHistoryRedirectLinks();
                 }
                 if (Page* page = m_frame->page())
                     page->setGlobalHistoryItem(needPrivacy ? 0 : page->backForwardList()->currentItem());
             }
         }
-        if (m_currentHistoryItem) {
-            m_currentHistoryItem->setURL(documentLoader()->url());
-            m_currentHistoryItem->setFormInfoFromRequest(documentLoader()->request());
+        if (m_currentItem) {
+            m_currentItem->setURL(m_frame->loader()->documentLoader()->url());
+            m_currentItem->setFormInfoFromRequest(m_frame->loader()->documentLoader()->request());
         }
     } else {
         Frame* parentFrame = m_frame->tree()->parent();
-        if (parentFrame && parentFrame->loader()->m_currentHistoryItem)
-            parentFrame->loader()->m_currentHistoryItem->setChildItem(createHistoryItem(true));
+        if (parentFrame && parentFrame->loader()->history()->m_currentItem)
+            parentFrame->loader()->history()->m_currentItem->setChildItem(createItem(true));
     }
 
     if (!historyURL.isEmpty() && !needPrivacy) {
         if (Page* page = m_frame->page())
             page->group().addVisitedLink(historyURL);
 
-        if (!m_documentLoader->didCreateGlobalHistoryEntry() && documentLoader()->unreachableURL().isEmpty() && !url().isEmpty())
-            m_client->updateGlobalHistoryRedirectLinks();
+        if (!m_frame->loader()->documentLoader()->didCreateGlobalHistoryEntry() && m_frame->loader()->documentLoader()->unreachableURL().isEmpty() && !m_frame->loader()->url().isEmpty())
+            m_frame->loader()->client()->updateGlobalHistoryRedirectLinks();
     }
 }
 
-void FrameLoader::updateHistoryForCommit()
+void HistoryController::updateForCommit()
 {
+    FrameLoader* frameLoader = m_frame->loader();
 #if !LOG_DISABLED
-    if (documentLoader())
-        LOG(History, "WebCoreHistory: Updating History for commit in frame %s", documentLoader()->title().utf8().data());
+    if (frameLoader->documentLoader())
+        LOG(History, "WebCoreHistory: Updating History for commit in frame %s", frameLoader->documentLoader()->title().utf8().data());
 #endif
-    FrameLoadType type = loadType();
+    FrameLoadType type = frameLoader->loadType();
     if (isBackForwardLoadType(type) ||
-        ((type == FrameLoadTypeReload || type == FrameLoadTypeReloadFromOrigin) && !provisionalDocumentLoader()->unreachableURL().isEmpty())) {
+        ((type == FrameLoadTypeReload || type == FrameLoadTypeReloadFromOrigin) && !frameLoader->provisionalDocumentLoader()->unreachableURL().isEmpty())) {
         // Once committed, we want to use current item for saving DocState, and
         // the provisional item for restoring state.
         // Note previousItem must be set before we close the URL, which will
         // happen when the data source is made non-provisional below
-        m_previousHistoryItem = m_currentHistoryItem;
-        ASSERT(m_provisionalHistoryItem);
-        m_currentHistoryItem = m_provisionalHistoryItem;
-        m_provisionalHistoryItem = 0;
+        m_previousItem = m_currentItem;
+        ASSERT(m_provisionalItem);
+        m_currentItem = m_provisionalItem;
+        m_provisionalItem = 0;
     }
 }
 
-void FrameLoader::updateHistoryForAnchorScroll()
+void HistoryController::updateForAnchorScroll()
 {
-    if (m_URL.isEmpty())
+    if (m_frame->loader()->url().isEmpty())
         return;
 
     Settings* settings = m_frame->settings();
@@ -4377,29 +4418,19 @@ void FrameLoader::updateHistoryForAnchorScroll()
     if (!page)
         return;
 
-    page->group().addVisitedLink(m_URL);
+    page->group().addVisitedLink(m_frame->loader()->url());
 }
 
 // Walk the frame tree, telling all frames to save their form state into their current
 // history item.
-void FrameLoader::saveDocumentAndScrollState()
+void HistoryController::saveDocumentAndScrollState()
 {
     for (Frame* frame = m_frame; frame; frame = frame->tree()->traverseNext(m_frame)) {
-        frame->loader()->saveDocumentState();
-        frame->loader()->saveScrollPositionAndViewStateToItem(frame->loader()->currentHistoryItem());
+        frame->loader()->history()->saveDocumentState();
+        frame->loader()->history()->saveScrollPositionAndViewStateToItem(frame->loader()->history()->currentItem());
     }
 }
 
-HistoryItem* FrameLoader::currentHistoryItem()
-{
-    return m_currentHistoryItem.get();
-}
-
-void FrameLoader::setCurrentHistoryItem(PassRefPtr<HistoryItem> item)
-{
-    m_currentHistoryItem = item;
-}
-
 void FrameLoader::setMainDocumentError(DocumentLoader* loader, const ResourceError& error)
 {
     m_client->setMainDocumentError(loader, error);
@@ -4537,14 +4568,19 @@ PassRefPtr<Widget> FrameLoader::createJavaAppletWidget(const IntSize& size, HTML
     return widget;
 }
 
+void HistoryController::setCurrentItemTitle(const String& title)
+{
+    if (m_currentItem)
+        m_currentItem->setTitle(title);
+}
+
 void FrameLoader::didChangeTitle(DocumentLoader* loader)
 {
     m_client->didChangeTitle(loader);
 
     if (loader == m_documentLoader) {
         // Must update the entries in the back-forward list too.
-        if (m_currentHistoryItem)
-            m_currentHistoryItem->setTitle(loader->title());
+        history()->setCurrentItemTitle(loader->title());
         // This must go through the WebFrame because it has the right notion of the current b/f item.
         m_client->setTitle(loader->title(), loader->urlForHistory());
         m_client->setMainFrameDocumentReady(true); // update observers with new DOMDocument
diff --git a/WebCore/loader/FrameLoader.h b/WebCore/loader/FrameLoader.h
index 897fb08..4666a0d 100644
--- a/WebCore/loader/FrameLoader.h
+++ b/WebCore/loader/FrameLoader.h
@@ -79,6 +79,56 @@ namespace WebCore {
 
     bool isBackForwardLoadType(FrameLoadType);
 
+    class HistoryController : public Noncopyable {
+    public:
+        HistoryController(Frame*);
+        ~HistoryController();
+
+        void saveScrollPositionAndViewStateToItem(HistoryItem*);
+        void restoreScrollPositionAndViewState();
+
+        void updateBackForwardListForFragmentScroll();
+
+        void saveDocumentState();
+        void saveDocumentAndScrollState();
+        void restoreDocumentState();
+
+        void invalidateCurrentItemCachedPage();
+
+        void goToItem(HistoryItem*, FrameLoadType);
+        bool urlsMatchItem(HistoryItem*) const;
+
+        void updateForBackForwardNavigation();
+        void updateForReload();
+        void updateForStandardLoad();
+        void updateForRedirectWithLockedBackForwardList();
+        void updateForClientRedirect();
+        void updateForCommit();
+        void updateForAnchorScroll();
+        void updateForFrameLoadCompleted();
+
+        HistoryItem* currentItem() const { return m_currentItem.get(); }
+        void setCurrentItem(HistoryItem*);
+        void setCurrentItemTitle(const String&);
+
+        HistoryItem* provisionalItem() const { return m_provisionalItem.get(); }
+        void setProvisionalItem(HistoryItem*);
+
+    private:
+        PassRefPtr<HistoryItem> createItem(bool useOriginal);
+        PassRefPtr<HistoryItem> createItemTree(Frame* targetFrame, bool clipAtTarget);
+
+        void recursiveGoToItem(HistoryItem*, HistoryItem*, FrameLoadType);
+        bool childFramesMatchItem(HistoryItem*) const;
+        void updateBackForwardListClippedAtTarget(bool doClip);
+
+        Frame* m_frame;
+
+        RefPtr<HistoryItem> m_currentItem;
+        RefPtr<HistoryItem> m_previousItem;
+        RefPtr<HistoryItem> m_provisionalItem;
+    };
+
     class FrameLoader : public Noncopyable {
     public:
         FrameLoader(Frame*, FrameLoaderClient*);
@@ -88,7 +138,8 @@ namespace WebCore {
 
         Frame* frame() const { return m_frame; }
 
-        PolicyChecker* policyChecker() { return &m_policyChecker; }
+        PolicyChecker* policyChecker() const { return &m_policyChecker; }
+        HistoryController* history() const { return &m_history; }
 
         // FIXME: This is not cool, people. There are too many different functions that all start loads.
         // We should aim to consolidate these into a smaller set of functions, and try to reuse more of
@@ -255,7 +306,6 @@ namespace WebCore {
 
         void dispatchWindowObjectAvailable();
         void dispatchDocumentElementAvailable();
-        void restoreDocumentState();
 
         // Mixed content related functions.
         static bool isMixedContent(SecurityOrigin* context, const KURL&);
@@ -286,6 +336,8 @@ namespace WebCore {
         void finishedParsing();
         void checkCompleted();
 
+        void checkDidPerformFirstNavigation();
+
         bool isComplete() const;
 
         bool requestObject(RenderPart* frame, const String& url, const AtomicString& frameName,
@@ -300,14 +352,9 @@ namespace WebCore {
         void commitProvisionalLoad(PassRefPtr<CachedPage>);
         bool isLoadingFromCachedPage() const { return m_loadingFromCachedPage; }
 
-        void goToItem(HistoryItem*, FrameLoadType);
-        void saveDocumentAndScrollState();
-
-        HistoryItem* currentHistoryItem();
-        void setCurrentHistoryItem(PassRefPtr<HistoryItem>);
-
         bool committingFirstRealLoad() const { return !m_creatingInitialEmptyDocument && !m_committedFirstRealDocumentLoad; }
         bool committedFirstRealDocumentLoad() const { return m_committedFirstRealDocumentLoad; }
+        bool creatingInitialEmptyDocument() const { return m_creatingInitialEmptyDocument; }
 
         void iconLoadDecisionAvailable();
 
@@ -328,6 +375,7 @@ namespace WebCore {
         bool allChildrenAreComplete() const; // immediate children, not all descendants
         void clientRedirected(const KURL&, double delay, double fireDate, bool lockBackForwardList);
         void clientRedirectCancelledOrFinished(bool cancelWithLoadInProgress);
+        void loadItem(HistoryItem*, FrameLoadType);
 
         // FIXME: This is public because this asynchronous callback from the FrameLoaderClient
         // uses the policy machinery (and therefore is called via the PolicyChecker).  Once we
@@ -335,32 +383,12 @@ namespace WebCore {
         void continueLoadAfterWillSubmitForm();
 
     private:
-        PassRefPtr<HistoryItem> createHistoryItem(bool useOriginal);
-        PassRefPtr<HistoryItem> createHistoryItemTree(Frame* targetFrame, bool clipAtTarget);
-
         bool canCachePageContainingThisFrame();
 #ifndef NDEBUG
         void logCanCachePageDecision();
         bool logCanCacheFrameDecision(int indentLevel);
 #endif
 
-        void addBackForwardItemClippedAtTarget(bool doClip);
-        void restoreScrollPositionAndViewState();
-        void saveDocumentState();
-        void loadItem(HistoryItem*, FrameLoadType);
-        bool urlsMatchItem(HistoryItem*) const;
-        void invalidateCurrentItemCachedPage();
-        void recursiveGoToItem(HistoryItem*, HistoryItem*, FrameLoadType);
-        bool childFramesMatchItem(HistoryItem*) const;
-
-        void updateHistoryForBackForwardNavigation();
-        void updateHistoryForReload();
-        void updateHistoryForStandardLoad();
-        void updateHistoryForRedirectWithLockedBackForwardList();
-        void updateHistoryForClientRedirect();
-        void updateHistoryForCommit();
-        void updateHistoryForAnchorScroll();
-
         void checkTimerFired(Timer<FrameLoader>*);
 
         void started();
@@ -401,7 +429,6 @@ namespace WebCore {
         void continueFragmentScrollAfterNavigationPolicy(const ResourceRequest&, bool shouldContinue);
 
         bool shouldScrollToAnchor(bool isFormSubmission, FrameLoadType, const KURL&);
-        void addHistoryItemForFragmentScroll();
 
         void checkLoadCompleteForThisFrame();
 
@@ -467,12 +494,11 @@ namespace WebCore {
 
         bool shouldTreatURLAsSameAsCurrent(const KURL&) const;
 
-        void saveScrollPositionAndViewStateToItem(HistoryItem*);
-
         Frame* m_frame;
         FrameLoaderClient* m_client;
 
-        PolicyChecker m_policyChecker;
+        mutable PolicyChecker m_policyChecker;
+        mutable HistoryController m_history;
 
         FrameState m_state;
         FrameLoadType m_loadType;
@@ -534,10 +560,6 @@ namespace WebCore {
         bool m_isDisplayingInitialEmptyDocument;
         bool m_committedFirstRealDocumentLoad;
 
-        RefPtr<HistoryItem> m_currentHistoryItem;
-        RefPtr<HistoryItem> m_previousHistoryItem;
-        RefPtr<HistoryItem> m_provisionalHistoryItem;
-        
         bool m_didPerformFirstNavigation;
         bool m_loadingFromCachedPage;
         
diff --git a/WebCore/page/Page.cpp b/WebCore/page/Page.cpp
index f0600e4..8a685f4 100644
--- a/WebCore/page/Page.cpp
+++ b/WebCore/page/Page.cpp
@@ -291,7 +291,7 @@ void Page::goToItem(HistoryItem* item, FrameLoadType type)
         databasePolicy = DatabasePolicyContinue;
 #endif
     m_mainFrame->loader()->stopAllLoaders(databasePolicy);
-    m_mainFrame->loader()->goToItem(item, type);
+    m_mainFrame->loader()->history()->goToItem(item, type);
 }
 
 int Page::getHistoryLength()
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index d9a7ab9..9b4bbec 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,17 @@
+2009-10-09  Adam Barth  <abarth at webkit.org>
+
+        Reviewed by Darin Adler.
+
+        Factor HistoryController out of FrameLoader
+        https://bugs.webkit.org/show_bug.cgi?id=30246
+
+        Update API call.
+
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::restoreViewState):
+        * WebView/WebView.mm:
+        (-[WebView _loadBackForwardListFromOtherView:]):
+
 2009-10-09  Mark Rowe  <mrowe at apple.com>
 
         Reviewed by Brady Eidson.
diff --git a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
index fcdd54d..bc6c8f4 100644
--- a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
+++ b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
@@ -988,7 +988,7 @@ void WebFrameLoaderClient::saveViewStateToItem(HistoryItem* item)
 
 void WebFrameLoaderClient::restoreViewState()
 {
-    HistoryItem* currentItem = core(m_webFrame.get())->loader()->currentHistoryItem();
+    HistoryItem* currentItem = core(m_webFrame.get())->loader()->history()->currentItem();
     ASSERT(currentItem);
 
     // FIXME: As the ASSERT attests, it seems we should always have a currentItem here.
diff --git a/WebKit/mac/WebView/WebView.mm b/WebKit/mac/WebView/WebView.mm
index e2dff16..9d1fe8c 100644
--- a/WebKit/mac/WebView/WebView.mm
+++ b/WebKit/mac/WebView/WebView.mm
@@ -1187,7 +1187,7 @@ static bool fastDocumentTeardownEnabled()
             // If this item is showing , save away its current scroll and form state,
             // since that might have changed since loading and it is normally not saved
             // until we leave that page.
-            otherView->_private->page->mainFrame()->loader()->saveDocumentAndScrollState();
+            otherView->_private->page->mainFrame()->loader()->history()->saveDocumentAndScrollState();
         }
         RefPtr<HistoryItem> newItem = otherBackForwardList->itemAtIndex(i)->copy();
         if (i == 0) 
diff --git a/WebKit/win/ChangeLog b/WebKit/win/ChangeLog
index 667fe58..94f7263 100644
--- a/WebKit/win/ChangeLog
+++ b/WebKit/win/ChangeLog
@@ -1,3 +1,15 @@
+2009-10-09  Adam Barth  <abarth at webkit.org>
+
+        Reviewed by Darin Adler.
+
+        Factor HistoryController out of FrameLoader
+        https://bugs.webkit.org/show_bug.cgi?id=30246
+
+        Update API call.
+
+        * WebView.cpp:
+        (WebView::loadBackForwardListFromOtherView):
+
 2009-10-08  Jon Honeycutt  <jhoneycutt at apple.com>
 
         Remove the WebKitPluginHalterEnabledPreferenceKey in favor of checking
diff --git a/WebKit/win/WebView.cpp b/WebKit/win/WebView.cpp
index 64d0aa9..4b60bf3 100644
--- a/WebKit/win/WebView.cpp
+++ b/WebKit/win/WebView.cpp
@@ -4810,7 +4810,7 @@ HRESULT STDMETHODCALLTYPE WebView::loadBackForwardListFromOtherView(
             // If this item is showing , save away its current scroll and form state,
             // since that might have changed since loading and it is normally not saved
             // until we leave that page.
-            otherWebView->m_page->mainFrame()->loader()->saveDocumentAndScrollState();
+            otherWebView->m_page->mainFrame()->loader()->history()->saveDocumentAndScrollState();
         }
         RefPtr<HistoryItem> newItem = otherBackForwardList->itemAtIndex(i)->copy();
         if (!i) 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list