Changeset 49413 in webkit


Ignore:
Timestamp:
Oct 9, 2009 7:27:21 PM (14 years ago)
Author:
abarth@webkit.org
Message:

2009-10-09 Adam Barth <abarth@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@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@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):
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r49410 r49413  
     12009-10-09  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Factor HistoryController out of FrameLoader
     6        https://bugs.webkit.org/show_bug.cgi?id=30246
     7
     8        HistoryController is in charge of managing the current / previous /
     9        provisional HistoryItems.  The split isn't perfect, but it's a place to
     10        start.  I'll move HistoryController into its own file in another patch.
     11
     12        * WebCore.base.exp:
     13        * loader/FrameLoader.cpp:
     14        (WebCore::HistoryController::HistoryController):
     15        (WebCore::HistoryController::~HistoryController):
     16        (WebCore::FrameLoader::FrameLoader):
     17        (WebCore::FrameLoader::closeURL):
     18        (WebCore::FrameLoader::begin):
     19        (WebCore::HistoryController::restoreDocumentState):
     20        (WebCore::HistoryController::setCurrentItem):
     21        (WebCore::HistoryController::setProvisionalItem):
     22        (WebCore::FrameLoader::loadURLIntoChildFrame):
     23        (WebCore::FrameLoader::canCachePageContainingThisFrame):
     24        (WebCore::FrameLoader::logCanCacheFrameDecision):
     25        (WebCore::FrameLoader::scrollToAnchor):
     26        (WebCore::FrameLoader::commitProvisionalLoad):
     27        (WebCore::FrameLoader::transitionToCommitted):
     28        (WebCore::FrameLoader::checkLoadCompleteForThisFrame):
     29        (WebCore::FrameLoader::didFirstLayout):
     30        (WebCore::HistoryController::updateForFrameLoadCompleted):
     31        (WebCore::FrameLoader::frameLoadCompleted):
     32        (WebCore::FrameLoader::detachFromParent):
     33        (WebCore::FrameLoader::receivedMainResourceError):
     34        (WebCore::FrameLoader::continueFragmentScrollAfterNavigationPolicy):
     35        (WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
     36        (WebCore::HistoryController::addHistoryItemForFragmentScroll):
     37        (WebCore::FrameLoader::loadProvisionalItemFromCachedPage):
     38        (WebCore::FrameLoader::shouldTreatURLAsSameAsCurrent):
     39        (WebCore::HistoryController::createHistoryItem):
     40        (WebCore::FrameLoader::checkDidPerformFirstNavigation):
     41        (WebCore::HistoryController::addBackForwardItemClippedAtTarget):
     42        (WebCore::HistoryController::createHistoryItemTree):
     43        (WebCore::HistoryController::saveScrollPositionAndViewStateToItem):
     44        (WebCore::HistoryController::restoreScrollPositionAndViewState):
     45        (WebCore::HistoryController::invalidateCurrentItemCachedPage):
     46        (WebCore::HistoryController::saveDocumentState):
     47        (WebCore::FrameLoader::loadItem):
     48        (WebCore::HistoryController::urlsMatchItem):
     49        (WebCore::HistoryController::goToItem):
     50        (WebCore::HistoryController::recursiveGoToItem):
     51        (WebCore::HistoryController::childFramesMatchItem):
     52        (WebCore::HistoryController::updateForStandardLoad):
     53        (WebCore::HistoryController::updateForClientRedirect):
     54        (WebCore::HistoryController::updateForBackForwardNavigation):
     55        (WebCore::HistoryController::updateForReload):
     56        (WebCore::HistoryController::updateForRedirectWithLockedBackForwardList):
     57        (WebCore::HistoryController::updateForCommit):
     58        (WebCore::HistoryController::updateForAnchorScroll):
     59        (WebCore::HistoryController::saveDocumentAndScrollState):
     60        (WebCore::HistoryController::setCurrentItemTitle):
     61        (WebCore::FrameLoader::didChangeTitle):
     62        * loader/FrameLoader.h:
     63        (WebCore::HistoryController::current):
     64        (WebCore::HistoryController::provisional):
     65        (WebCore::FrameLoader::policyChecker):
     66        (WebCore::FrameLoader::history):
     67        (WebCore::FrameLoader::creatingInitialEmptyDocument):
     68        * page/Page.cpp:
     69        (WebCore::Page::goToItem):
     70
    1712009-10-09  Alexey Proskuryakov  <ap@apple.com>
    272
  • trunk/WebCore/WebCore.base.exp

    r49385 r49413  
    163163__ZN7WebCore11FrameLoader16loadFrameRequestERKNS_16FrameLoadRequestEbbN3WTF10PassRefPtrINS_5EventEEENS5_INS_9FormStateEEE
    164164__ZN7WebCore11FrameLoader17stopForUserCancelEb
    165 __ZN7WebCore11FrameLoader18currentHistoryItemEv
    166165__ZN7WebCore11FrameLoader21loadURLIntoChildFrameERKNS_4KURLERKNS_6StringEPNS_5FrameE
    167 __ZN7WebCore11FrameLoader21setCurrentHistoryItemEN3WTF10PassRefPtrINS_11HistoryItemEEE
    168166__ZN7WebCore11FrameLoader22findFrameForNavigationERKNS_12AtomicStringE
    169167__ZN7WebCore11FrameLoader23isProcessingUserGestureEv
    170168__ZN7WebCore11FrameLoader23timeOfLastCompletedLoadEv
    171169__ZN7WebCore11FrameLoader26reloadWithOverrideEncodingERKNS_6StringE
    172 __ZN7WebCore11FrameLoader26saveDocumentAndScrollStateEv
    173 __ZN7WebCore11FrameLoader36saveScrollPositionAndViewStateToItemEPNS_11HistoryItemE
    174170__ZN7WebCore11FrameLoader4loadERKNS_15ResourceRequestERKNS_14SubstituteDataEb
    175171__ZN7WebCore11FrameLoader4loadERKNS_15ResourceRequestERKNS_6StringEb
     
    389385__ZN7WebCore17DOMImplementation14isTextMIMETypeERKNS_6StringE
    390386__ZN7WebCore17GlyphPageTreeNode18treeGlyphPageCountEv
     387__ZN7WebCore17HistoryController26saveDocumentAndScrollStateEv
    391388__ZN7WebCore17HTMLPlugInElement11getNPObjectEv
    392389__ZN7WebCore17equalIgnoringCaseEPNS_10StringImplES1_
  • trunk/WebCore/loader/FrameLoader.cpp

    r49372 r49413  
    164164}
    165165
     166HistoryController::HistoryController(Frame* frame)
     167    : m_frame(frame)
     168{
     169}
     170
     171HistoryController::~HistoryController()
     172{
     173}
     174
    166175FrameLoader::FrameLoader(Frame* frame, FrameLoaderClient* client)
    167176    : m_frame(frame)
    168177    , m_client(client)
    169178    , m_policyChecker(frame)
     179    , m_history(frame)
    170180    , m_state(FrameStateCommittedPage)
    171181    , m_loadType(FrameLoadTypeStandard)
     
    564574bool FrameLoader::closeURL()
    565575{
    566     saveDocumentState();
     576    history()->saveDocumentState();
    567577   
    568578    // Should only send the pagehide event here if the current document exists and has not been placed in the page cache.   
     
    827837    }
    828838
    829     restoreDocumentState();
     839    history()->restoreDocumentState();
    830840
    831841    document->implicitOpen();
     
    10141024}
    10151025
    1016 void FrameLoader::restoreDocumentState()
     1026void HistoryController::restoreDocumentState()
    10171027{
    10181028    Document* doc = m_frame->document();
     
    10201030    HistoryItem* itemToRestore = 0;
    10211031   
    1022     switch (loadType()) {
     1032    switch (m_frame->loader()->loadType()) {
    10231033        case FrameLoadTypeReload:
    10241034        case FrameLoadTypeReloadFromOrigin:
     
    10321042        case FrameLoadTypeRedirectWithLockedBackForwardList:
    10331043        case FrameLoadTypeStandard:
    1034             itemToRestore = m_currentHistoryItem.get();
     1044            itemToRestore = m_currentItem.get();
    10351045    }
    10361046   
     
    12031213}
    12041214
     1215void HistoryController::setCurrentItem(HistoryItem* item)
     1216{
     1217    m_currentItem = item;
     1218}
     1219
     1220void HistoryController::setProvisionalItem(HistoryItem* item)
     1221{
     1222    m_provisionalItem = item;
     1223}
     1224
    12051225void FrameLoader::loadURLIntoChildFrame(const KURL& url, const String& referer, Frame* childFrame)
    12061226{
    12071227    ASSERT(childFrame);
    12081228
    1209     HistoryItem* parentItem = currentHistoryItem();
     1229    HistoryItem* parentItem = history()->currentItem();
    12101230    FrameLoadType loadType = this->loadType();
    12111231    FrameLoadType childLoadType = FrameLoadTypeRedirectWithLockedBackForwardList;
     
    12231243            workingURL = KURL(ParsedURLString, childItem->originalURLString());
    12241244            childLoadType = loadType;
    1225             childFrame->loader()->m_provisionalHistoryItem = childItem;
     1245            childFrame->loader()->history()->setProvisionalItem(childItem);
    12261246        }
    12271247    }
     
    15471567#endif
    15481568        && !m_frame->document()->usingGeolocation()
    1549         && m_currentHistoryItem
     1569        && history()->currentItem()
    15501570        && !m_quickRedirectComing
    15511571        && !m_documentLoader->isLoadingInAPISense()
     
    16981718        if (m_frame->document()->usingGeolocation())
    16991719            { PCLOG("   -Frame uses Geolocation"); cannotCache = true; }
    1700         if (!m_currentHistoryItem)
     1720        if (!history()->currentItem())
    17011721            { PCLOG("   -No current history item"); cannotCache = true; }
    17021722        if (m_quickRedirectComing)
     
    17761796   
    17771797    m_URL = url;
    1778     updateHistoryForAnchorScroll();
     1798    history()->updateForAnchorScroll();
    17791799
    17801800    // If we were in the autoscroll/panScroll mode we want to stop it before following the link to the anchor
     
    24192439    // Check to see if we need to cache the page we are navigating away from into the back/forward cache.
    24202440    // We are doing this here because we know for sure that a new page is about to be loaded.
    2421     cachePageForHistoryItem(m_currentHistoryItem.get());
     2441    cachePageForHistoryItem(history()->currentItem());
    24222442   
    24232443    if (m_loadType != FrameLoadTypeReplace)
     
    24532473
    24542474    if (m_loadType == FrameLoadTypeStandard && m_documentLoader->isClientRedirect())
    2455         updateHistoryForClientRedirect();
     2475        history()->updateForClientRedirect();
    24562476
    24572477    if (m_loadingFromCachedPage) {
     
    24762496        }
    24772497       
    2478         pageCache()->remove(m_currentHistoryItem.get());
     2498        pageCache()->remove(history()->currentItem());
    24792499
    24802500        m_documentLoader->setPrimaryLoadComplete(true);
     
    24942514
    24952515    m_client->setCopiesOnScroll();
    2496     updateHistoryForCommit();
     2516    history()->updateForCommit();
    24972517
    24982518    // The call to closeURL() invokes the unload event handler, which can execute arbitrary
     
    25262546            if (Page* page = m_frame->page())
    25272547                if (page->backForwardList()) {
    2528                     updateHistoryForBackForwardNavigation();
     2548                    history()->updateForBackForwardNavigation();
    25292549
    25302550                    // Create a document view for this document, or used the cached view.
     
    25442564        case FrameLoadTypeSame:
    25452565        case FrameLoadTypeReplace:
    2546             updateHistoryForReload();
     2566            history()->updateForReload();
    25472567            m_client->transitionToCommittedForNewPage();
    25482568            break;
    25492569
    25502570        case FrameLoadTypeStandard:
    2551             updateHistoryForStandardLoad();
     2571            history()->updateForStandardLoad();
    25522572#ifndef BUILDING_ON_TIGER
    25532573            // This code was originally added for a Leopard performance imporvement. We decided to
     
    25602580
    25612581        case FrameLoadTypeRedirectWithLockedBackForwardList:
    2562             updateHistoryForRedirectWithLockedBackForwardList();
     2582            history()->updateForRedirectWithLockedBackForwardList();
    25632583            m_client->transitionToCommittedForNewPage();
    25642584            break;
     
    29092929            if (Page* page = m_frame->page())
    29102930                if (isBackForwardLoadType(loadType()) && m_frame == page->mainFrame())
    2911                     item = m_currentHistoryItem;
     2931                    item = history()->currentItem();
    29122932               
    29132933            bool shouldReset = true;
     
    29582978            if (Page* page = m_frame->page())
    29592979                if ((isBackForwardLoadType(m_loadType) || m_loadType == FrameLoadTypeReload || m_loadType == FrameLoadTypeReloadFromOrigin) && page->backForwardList())
    2960                     restoreScrollPositionAndViewState();
     2980                    history()->restoreScrollPositionAndViewState();
    29612981
    29622982            if (m_creatingInitialEmptyDocument || !m_committedFirstRealDocumentLoad)
     
    30193039    if (Page* page = m_frame->page())
    30203040        if (isBackForwardLoadType(m_loadType) && page->backForwardList())
    3021             restoreScrollPositionAndViewState();
     3041            history()->restoreScrollPositionAndViewState();
    30223042
    30233043    m_firstLayoutDone = true;
     
    30303050}
    30313051
    3032 void FrameLoader::frameLoadCompleted()
    3033 {
    3034     // Note: Can be called multiple times.
    3035 
    3036     m_client->frameLoadCompleted();
    3037 
     3052void HistoryController::updateForFrameLoadCompleted()
     3053{
    30383054    // Even if already complete, we might have set a previous item on a frame that
    30393055    // didn't do any data loading on the past transaction. Make sure to clear these out.
    3040     m_previousHistoryItem = 0;
     3056    m_previousItem = 0;
     3057}
     3058
     3059void FrameLoader::frameLoadCompleted()
     3060{
     3061    // Note: Can be called multiple times.
     3062
     3063    m_client->frameLoadCompleted();
     3064
     3065    history()->updateForFrameLoadCompleted();
    30413066
    30423067    // After a canceled provisional load, firstLayoutDone is false.
     
    31393164    closeURL();
    31403165    stopAllLoaders();
    3141     saveScrollPositionAndViewStateToItem(currentHistoryItem());
     3166    history()->saveScrollPositionAndViewStateToItem(history()->currentItem());
    31423167    detachChildren();
    31433168
     
    33813406
    33823407    RefPtr<DocumentLoader> loader = activeDocumentLoader();
    3383    
     3408
    33843409    if (isComplete) {
    33853410        // FIXME: Don't want to do this if an entirely new load is going, so should check
     
    33893414            handleFallbackContent();
    33903415    }
    3391    
     3416
    33923417    if (m_state == FrameStateProvisional && m_provisionalDocumentLoader) {
    33933418        if (m_submittedFormURL == m_provisionalDocumentLoader->originalRequestCopy().url())
     
    33973422        // transitioned to the new page (before WebFrameState == commit).  The goal here is to restore any state
    33983423        // so that the existing view (that wenever got far enough to replace) can continue being used.
    3399         invalidateCurrentItemCachedPage();
     3424        history()->invalidateCurrentItemCachedPage();
    34003425       
    34013426        // Call clientRedirectCancelledOrFinished here so that the frame load delegate is notified that the redirect's
     
    34073432            clientRedirectCancelledOrFinished(false);
    34083433    }
    3409    
    3410    
     3434
    34113435    loader->mainReceivedError(error, isComplete);
    34123436}
     
    34423466        // but it's not an obvious case.
    34433467
    3444         addHistoryItemForFragmentScroll();
     3468        history()->updateBackForwardListForFragmentScroll();
    34453469    }
    34463470   
     
    34913515    ASSERT(m_policyDocumentLoader || !m_provisionalDocumentLoader->unreachableURL().isEmpty());
    34923516
    3493     bool isTargetItem = m_provisionalHistoryItem ? m_provisionalHistoryItem->isTargetItem() : false;
     3517    bool isTargetItem = history()->provisionalItem() ? history()->provisionalItem()->isTargetItem() : false;
    34943518
    34953519    // Two reasons we can't continue:
     
    35143538            if (Page* page = m_frame->page()) {
    35153539                Frame* mainFrame = page->mainFrame();
    3516                 if (HistoryItem* resetItem = mainFrame->loader()->m_currentHistoryItem.get()) {
     3540                if (HistoryItem* resetItem = mainFrame->loader()->history()->currentItem()) {
    35173541                    page->backForwardList()->goToItem(resetItem);
    35183542                    Settings* settings = m_frame->settings();
     
    36713695}
    36723696
    3673 void FrameLoader::addHistoryItemForFragmentScroll()
    3674 {
    3675     addBackForwardItemClippedAtTarget(false);
     3697void HistoryController::updateBackForwardListForFragmentScroll()
     3698{
     3699    updateBackForwardListClippedAtTarget(false);
    36763700}
    36773701
    36783702bool FrameLoader::loadProvisionalItemFromCachedPage()
    36793703{
    3680     RefPtr<CachedPage> cachedPage = pageCache()->get(m_provisionalHistoryItem.get());
     3704    RefPtr<CachedPage> cachedPage = pageCache()->get(history()->provisionalItem());
    36813705    if (!cachedPage || !cachedPage->document())
    36823706        return false;
     
    37223746bool FrameLoader::shouldTreatURLAsSameAsCurrent(const KURL& url) const
    37233747{
    3724     if (!m_currentHistoryItem)
     3748    if (!history()->currentItem())
    37253749        return false;
    3726     return url == m_currentHistoryItem->url() || url == m_currentHistoryItem->originalURL();
    3727 }
    3728 
    3729 PassRefPtr<HistoryItem> FrameLoader::createHistoryItem(bool useOriginal)
    3730 {
    3731     DocumentLoader* docLoader = documentLoader();
     3750    return url == history()->currentItem()->url() || url == history()->currentItem()->originalURL();
     3751}
     3752
     3753PassRefPtr<HistoryItem> HistoryController::createItem(bool useOriginal)
     3754{
     3755    DocumentLoader* docLoader = m_frame->loader()->documentLoader();
    37323756   
    37333757    KURL unreachableURL = docLoader ? docLoader->unreachableURL() : KURL();
     
    37783802   
    37793803    // Set the item for which we will save document state
    3780     m_previousHistoryItem = m_currentHistoryItem;
    3781     m_currentHistoryItem = item;
     3804    m_previousItem = m_currentItem;
     3805    m_currentItem = item;
    37823806   
    37833807    return item.release();
    37843808}
    3785 
    3786 void FrameLoader::addBackForwardItemClippedAtTarget(bool doClip)
     3809   
     3810void FrameLoader::checkDidPerformFirstNavigation()
     3811{
     3812    Page* page = m_frame->page();
     3813    if (!page)
     3814        return;
     3815
     3816    if (!m_didPerformFirstNavigation && page->backForwardList()->entries().size() == 1) {
     3817        m_didPerformFirstNavigation = true;
     3818        m_client->didPerformFirstNavigation();
     3819    }
     3820}
     3821
     3822void HistoryController::updateBackForwardListClippedAtTarget(bool doClip)
    37873823{
    37883824    // In the case of saving state about a page with frames, we store a tree of items that mirrors the frame tree. 
     
    37953831        return;
    37963832
    3797     if (documentLoader()->urlForHistory().isEmpty())
     3833    if (m_frame->loader()->documentLoader()->urlForHistory().isEmpty())
    37983834        return;
    37993835
     
    38023838    FrameLoader* frameLoader = mainFrame->loader();
    38033839
    3804     if (!frameLoader->m_didPerformFirstNavigation && page->backForwardList()->entries().size() == 1) {
    3805         frameLoader->m_didPerformFirstNavigation = true;
    3806         m_client->didPerformFirstNavigation();
    3807     }
    3808 
    3809     RefPtr<HistoryItem> item = frameLoader->createHistoryItemTree(m_frame, doClip);
    3810     LOG(BackForward, "WebCoreBackForward - Adding backforward item %p for frame %s", item.get(), documentLoader()->url().string().ascii().data());
     3840    frameLoader->checkDidPerformFirstNavigation();
     3841
     3842    RefPtr<HistoryItem> item = frameLoader->history()->createItemTree(m_frame, doClip);
     3843    LOG(BackForward, "WebCoreBackForward - Adding backforward item %p for frame %s", item.get(), m_frame->loader()->documentLoader()->url().string().ascii().data());
    38113844    page->backForwardList()->addItem(item);
    38123845}
    38133846
    3814 PassRefPtr<HistoryItem> FrameLoader::createHistoryItemTree(Frame* targetFrame, bool clipAtTarget)
    3815 {
    3816     RefPtr<HistoryItem> bfItem = createHistoryItem(m_frame->tree()->parent() ? true : false);
    3817     if (m_previousHistoryItem)
    3818         saveScrollPositionAndViewStateToItem(m_previousHistoryItem.get());
     3847PassRefPtr<HistoryItem> HistoryController::createItemTree(Frame* targetFrame, bool clipAtTarget)
     3848{
     3849    RefPtr<HistoryItem> bfItem = createItem(m_frame->tree()->parent() ? true : false);
     3850    if (m_previousItem)
     3851        saveScrollPositionAndViewStateToItem(m_previousItem.get());
    38193852    if (!(clipAtTarget && m_frame == targetFrame)) {
    38203853        // save frame state for items that aren't loading (khtml doesn't save those)
     
    38233856            FrameLoader* childLoader = child->loader();
    38243857            bool hasChildLoaded = childLoader->frameHasLoaded();
    3825            
     3858
    38263859            // If the child is a frame corresponding to an <object> element that never loaded,
    38273860            // we don't want to create a history item, because that causes fallback content
     
    38293862           
    38303863            if (!(!hasChildLoaded && childLoader->isHostedByObjectElement()))
    3831                 bfItem->addChildItem(childLoader->createHistoryItemTree(targetFrame, clipAtTarget));
     3864                bfItem->addChildItem(childLoader->history()->createItemTree(targetFrame, clipAtTarget));
    38323865        }
    38333866    }
     
    38453878}
    38463879
    3847 void FrameLoader::saveScrollPositionAndViewStateToItem(HistoryItem* item)
     3880void HistoryController::saveScrollPositionAndViewStateToItem(HistoryItem* item)
    38483881{
    38493882    if (!item || !m_frame->view())
     
    38523885    item->setScrollPoint(m_frame->view()->scrollPosition());
    38533886    // FIXME: It would be great to work out a way to put this code in WebCore instead of calling through to the client.
    3854     m_client->saveViewStateToItem(item);
     3887    m_frame->loader()->client()->saveViewStateToItem(item);
    38553888}
    38563889
     
    38663899 fails.  We then successfully restore it when the layout happens.
    38673900*/
    3868 void FrameLoader::restoreScrollPositionAndViewState()
    3869 {
    3870     if (!m_committedFirstRealDocumentLoad)
    3871         return;
    3872 
    3873     ASSERT(m_currentHistoryItem);
     3901void HistoryController::restoreScrollPositionAndViewState()
     3902{
     3903    if (!m_frame->loader()->committedFirstRealDocumentLoad())
     3904        return;
     3905
     3906    ASSERT(m_currentItem);
    38743907   
    38753908    // FIXME: As the ASSERT attests, it seems we should always have a currentItem here.
     
    38783911    // early and from a user standpoint - as in the above radar - the previous page load failed
    38793912    // so there *is* no scroll or view state to restore!
    3880     if (!m_currentHistoryItem)
     3913    if (!m_currentItem)
    38813914        return;
    38823915   
    38833916    // FIXME: It would be great to work out a way to put this code in WebCore instead of calling
    38843917    // through to the client. It's currently used only for the PDF view on Mac.
    3885     m_client->restoreViewState();
     3918    m_frame->loader()->client()->restoreViewState();
    38863919   
    38873920    if (FrameView* view = m_frame->view())
    38883921        if (!view->wasScrolledByUser())
    3889             view->setScrollPosition(m_currentHistoryItem->scrollPoint());
    3890 }
    3891 
    3892 void FrameLoader::invalidateCurrentItemCachedPage()
     3922            view->setScrollPosition(m_currentItem->scrollPoint());
     3923}
     3924
     3925void HistoryController::invalidateCurrentItemCachedPage()
    38933926{
    38943927    // When we are pre-commit, the currentItem is where the pageCache data resides   
    3895     CachedPage* cachedPage = pageCache()->get(m_currentHistoryItem.get());
     3928    CachedPage* cachedPage = pageCache()->get(currentItem());
    38963929
    38973930    // FIXME: This is a grotesque hack to fix <rdar://problem/4059059> Crash in RenderFlow::detach
     
    39063939   
    39073940    if (cachedPage)
    3908         pageCache()->remove(m_currentHistoryItem.get());
    3909 }
    3910 
    3911 void FrameLoader::saveDocumentState()
    3912 {
    3913     if (m_creatingInitialEmptyDocument)
     3941        pageCache()->remove(currentItem());
     3942}
     3943
     3944void HistoryController::saveDocumentState()
     3945{
     3946    // FIXME: Reading this bit of FrameLoader state here is unfortunate.  I need to study
     3947    // this more to see if we can remove this dependency.
     3948    if (m_frame->loader()->creatingInitialEmptyDocument())
    39143949        return;
    39153950
     
    39253960    // checkLoadComplete recursion to achieve this goal.
    39263961
    3927     HistoryItem* item = m_previousHistoryItem ? m_previousHistoryItem.get() : m_currentHistoryItem.get();
     3962    HistoryItem* item = m_previousItem ? m_previousItem.get() : m_currentItem.get();
    39283963    if (!item)
    39293964        return;
     
    39393974
    39403975// Loads content into this frame, as specified by history item
     3976// FIXME: This function should really be split into a couple pieces, some of
     3977// which should be methods of HistoryController and some of which should be
     3978// methods of FrameLoader.
    39413979void FrameLoader::loadItem(HistoryItem* item, FrameLoadType loadType)
    39423980{
     
    39573995    // We also do not do anchor-style navigation if we're posting a form or navigating from
    39583996    // a page that was resulted from a form post.
    3959     bool shouldScroll = !formData && !(m_currentHistoryItem && m_currentHistoryItem->formData()) && urlsMatchItem(item);
     3997    bool shouldScroll = !formData && !(history()->currentItem() && history()->currentItem()->formData()) && history()->urlsMatchItem(item);
    39603998
    39613999#if ENABLE(WML)
     
    39674005    if (shouldScroll) {
    39684006        // Must do this maintenance here, since we don't go through a real page reload
    3969         saveScrollPositionAndViewStateToItem(m_currentHistoryItem.get());
     4007        history()->saveScrollPositionAndViewStateToItem(history()->currentItem());
    39704008
    39714009        if (FrameView* view = m_frame->view())
    39724010            view->setWasScrolledByUser(false);
    39734011
    3974         m_currentHistoryItem = item;
     4012        history()->setCurrentItem(item);
    39754013
    39764014        // FIXME: Form state might need to be saved here too.
     
    39814019   
    39824020        // must do this maintenance here, since we don't go through a real page reload
    3983         restoreScrollPositionAndViewState();
     4021        history()->restoreScrollPositionAndViewState();
    39844022       
    39854023        // Fake the URL change by updating the data source's request.  This will no longer
     
    39934031    } else {
    39944032        // Remember this item so we can traverse any child items as child frames load
    3995         m_provisionalHistoryItem = item;
     4033        history()->setProvisionalItem(item);
    39964034
    39974035        bool inPageCache = false;
     
    40104048                inPageCache = true;
    40114049            } else {
    4012                 LOG(PageCache, "Not restoring page for %s from back/forward cache because cache entry has expired", m_provisionalHistoryItem->url().string().ascii().data());
     4050                LOG(PageCache, "Not restoring page for %s from back/forward cache because cache entry has expired", history()->provisionalItem()->url().string().ascii().data());
    40134051                pageCache()->remove(item);
    40144052            }
     
    40864124
    40874125// Walk the frame tree and ensure that the URLs match the URLs in the item.
    4088 bool FrameLoader::urlsMatchItem(HistoryItem* item) const
    4089 {
    4090     const KURL& currentURL = documentLoader()->url();
     4126bool HistoryController::urlsMatchItem(HistoryItem* item) const
     4127{
     4128    const KURL& currentURL = m_frame->loader()->documentLoader()->url();
    40914129    if (!equalIgnoringFragmentIdentifier(currentURL, item->url()))
    40924130        return false;
     
    40974135    for (unsigned i = 0; i < size; ++i) {
    40984136        Frame* childFrame = m_frame->tree()->child(childItems[i]->target());
    4099         if (childFrame && !childFrame->loader()->urlsMatchItem(childItems[i].get()))
     4137        if (childFrame && !childFrame->loader()->history()->urlsMatchItem(childItems[i].get()))
    41004138            return false;
    41014139    }
     
    41064144// Main funnel for navigating to a previous location (back/forward, non-search snap-back)
    41074145// This includes recursion to handle loading into framesets properly
    4108 void FrameLoader::goToItem(HistoryItem* targetItem, FrameLoadType type)
     4146void HistoryController::goToItem(HistoryItem* targetItem, FrameLoadType type)
    41094147{
    41104148    ASSERT(!m_frame->tree()->parent());
     
    41174155    if (!page)
    41184156        return;
    4119     if (!m_client->shouldGoToHistoryItem(targetItem))
     4157    if (!m_frame->loader()->client()->shouldGoToHistoryItem(targetItem))
    41204158        return;
    41214159
     
    41354173// a match (by URL), we just restore scroll position and recurse.  Otherwise we must
    41364174// reload that frame, and all its kids.
    4137 void FrameLoader::recursiveGoToItem(HistoryItem* item, HistoryItem* fromItem, FrameLoadType type)
     4175void HistoryController::recursiveGoToItem(HistoryItem* item, HistoryItem* fromItem, FrameLoadType type)
    41384176{
    41394177    ASSERT(item);
    41404178    ASSERT(fromItem);
    4141    
     4179
    41424180    KURL itemURL = item->url();
    41434181    KURL currentURL;
    4144     if (documentLoader())
    4145         currentURL = documentLoader()->url();
    4146    
     4182    if (m_frame->loader()->documentLoader())
     4183        currentURL = m_frame->loader()->documentLoader()->url();
     4184
    41474185    // Always reload the target frame of the item we're going to.  This ensures that we will
    41484186    // do -some- load for the transition, which means a proper notification will be posted
     
    41584196        // This content is good, so leave it alone and look for children that need reloading
    41594197        // Save form state (works from currentItem, since prevItem is nil)
    4160         ASSERT(!m_previousHistoryItem);
     4198        ASSERT(!m_previousItem);
    41614199        saveDocumentState();
    4162         saveScrollPositionAndViewStateToItem(m_currentHistoryItem.get());
     4200        saveScrollPositionAndViewStateToItem(m_currentItem.get());
    41634201
    41644202        if (FrameView* view = m_frame->view())
    41654203            view->setWasScrolledByUser(false);
    41664204
    4167         m_currentHistoryItem = item;
     4205        m_currentItem = item;
    41684206               
    41694207        // Restore form state (works from currentItem)
     
    41824220            Frame* childFrame = m_frame->tree()->child(childFrameName);
    41834221            ASSERT(childFrame);
    4184             childFrame->loader()->recursiveGoToItem(childItems[i].get(), fromChildItem, type);
     4222            childFrame->loader()->history()->recursiveGoToItem(childItems[i].get(), fromChildItem, type);
    41854223        }
    41864224    } else {
    4187         loadItem(item, type);
     4225        m_frame->loader()->loadItem(item, type);
    41884226    }
    41894227}
     
    41914229// helper method that determines whether the subframes described by the item's subitems
    41924230// match our own current frameset
    4193 bool FrameLoader::childFramesMatchItem(HistoryItem* item) const
     4231bool HistoryController::childFramesMatchItem(HistoryItem* item) const
    41944232{
    41954233    const HistoryItemVector& childItems = item->children();
     
    42094247// There are 3 things you might think of as "history", all of which are handled by these functions.
    42104248//
    4211 //     1) Back/forward: The m_currentHistoryItem is part of this mechanism.
     4249//     1) Back/forward: The m_currentItem is part of this mechanism.
    42124250//     2) Global history: Handled by the client.
    42134251//     3) Visited links: Handled by the PageGroup.
    42144252
    4215 void FrameLoader::updateHistoryForStandardLoad()
    4216 {
    4217     LOG(History, "WebCoreHistory: Updating History for Standard Load in frame %s", documentLoader()->url().string().ascii().data());
     4253void HistoryController::updateForStandardLoad()
     4254{
     4255    LOG(History, "WebCoreHistory: Updating History for Standard Load in frame %s", m_frame->loader()->documentLoader()->url().string().ascii().data());
     4256
     4257    FrameLoader* frameLoader = m_frame->loader();
    42184258
    42194259    Settings* settings = m_frame->settings();
    42204260    bool needPrivacy = !settings || settings->privateBrowsingEnabled();
    4221     const KURL& historyURL = documentLoader()->urlForHistory();
    4222 
    4223     if (!documentLoader()->isClientRedirect()) {
     4261    const KURL& historyURL = frameLoader->documentLoader()->urlForHistory();
     4262
     4263    if (!frameLoader->documentLoader()->isClientRedirect()) {
    42244264        if (!historyURL.isEmpty()) {
    4225             addBackForwardItemClippedAtTarget(true);
     4265            updateBackForwardListClippedAtTarget(true);
    42264266            if (!needPrivacy) {
    4227                 m_client->updateGlobalHistory();
    4228                 m_documentLoader->setDidCreateGlobalHistoryEntry(true);
    4229                 if (m_documentLoader->unreachableURL().isEmpty())
    4230                     m_client->updateGlobalHistoryRedirectLinks();
     4267                frameLoader->client()->updateGlobalHistory();
     4268                frameLoader->documentLoader()->setDidCreateGlobalHistoryEntry(true);
     4269                if (frameLoader->documentLoader()->unreachableURL().isEmpty())
     4270                    frameLoader->client()->updateGlobalHistoryRedirectLinks();
    42314271            }
    42324272            if (Page* page = m_frame->page())
    42334273                page->setGlobalHistoryItem(needPrivacy ? 0 : page->backForwardList()->currentItem());
    42344274        }
    4235     } else if (documentLoader()->unreachableURL().isEmpty() && m_currentHistoryItem) {
    4236         m_currentHistoryItem->setURL(documentLoader()->url());
    4237         m_currentHistoryItem->setFormInfoFromRequest(documentLoader()->request());
     4275    } else if (frameLoader->documentLoader()->unreachableURL().isEmpty() && m_currentItem) {
     4276        m_currentItem->setURL(frameLoader->documentLoader()->url());
     4277        m_currentItem->setFormInfoFromRequest(frameLoader->documentLoader()->request());
    42384278    }
    42394279
     
    42424282            page->group().addVisitedLink(historyURL);
    42434283
    4244         if (!m_documentLoader->didCreateGlobalHistoryEntry() && documentLoader()->unreachableURL().isEmpty() && !url().isEmpty())
    4245             m_client->updateGlobalHistoryRedirectLinks();
    4246     }
    4247 }
    4248 
    4249 void FrameLoader::updateHistoryForClientRedirect()
     4284        if (!frameLoader->documentLoader()->didCreateGlobalHistoryEntry() && frameLoader->documentLoader()->unreachableURL().isEmpty() && !frameLoader->url().isEmpty())
     4285            frameLoader->client()->updateGlobalHistoryRedirectLinks();
     4286    }
     4287}
     4288
     4289void HistoryController::updateForClientRedirect()
    42504290{
    42514291#if !LOG_DISABLED
    4252     if (documentLoader())
    4253         LOG(History, "WebCoreHistory: Updating History for client redirect in frame %s", documentLoader()->title().utf8().data());
     4292    if (m_frame->loader()->documentLoader())
     4293        LOG(History, "WebCoreHistory: Updating History for client redirect in frame %s", m_frame->loader()->documentLoader()->title().utf8().data());
    42544294#endif
    42554295
    42564296    // Clear out form data so we don't try to restore it into the incoming page.  Must happen after
    42574297    // webcore has closed the URL and saved away the form state.
    4258     if (m_currentHistoryItem) {
    4259         m_currentHistoryItem->clearDocumentState();
    4260         m_currentHistoryItem->clearScrollPoint();
     4298    if (m_currentItem) {
     4299        m_currentItem->clearDocumentState();
     4300        m_currentItem->clearScrollPoint();
    42614301    }
    42624302
    42634303    Settings* settings = m_frame->settings();
    42644304    bool needPrivacy = !settings || settings->privateBrowsingEnabled();
    4265     const KURL& historyURL = documentLoader()->urlForHistory();
     4305    const KURL& historyURL = m_frame->loader()->documentLoader()->urlForHistory();
    42664306
    42674307    if (!historyURL.isEmpty() && !needPrivacy) {
     
    42714311}
    42724312
    4273 void FrameLoader::updateHistoryForBackForwardNavigation()
     4313void HistoryController::updateForBackForwardNavigation()
    42744314{
    42754315#if !LOG_DISABLED
    4276     if (documentLoader())
    4277         LOG(History, "WebCoreHistory: Updating History for back/forward navigation in frame %s", documentLoader()->title().utf8().data());
     4316    if (m_frame->loader()->documentLoader())
     4317        LOG(History, "WebCoreHistory: Updating History for back/forward navigation in frame %s", m_frame->loader()->documentLoader()->title().utf8().data());
    42784318#endif
    42794319
    42804320    // Must grab the current scroll position before disturbing it
    4281     saveScrollPositionAndViewStateToItem(m_previousHistoryItem.get());
    4282 }
    4283 
    4284 void FrameLoader::updateHistoryForReload()
     4321    saveScrollPositionAndViewStateToItem(m_previousItem.get());
     4322}
     4323
     4324void HistoryController::updateForReload()
    42854325{
    42864326#if !LOG_DISABLED
    4287     if (documentLoader())
    4288         LOG(History, "WebCoreHistory: Updating History for reload in frame %s", documentLoader()->title().utf8().data());
     4327    if (m_frame->loader()->documentLoader())
     4328        LOG(History, "WebCoreHistory: Updating History for reload in frame %s", m_frame->loader()->documentLoader()->title().utf8().data());
    42894329#endif
    42904330
    4291     if (m_currentHistoryItem) {
    4292         pageCache()->remove(m_currentHistoryItem.get());
    4293    
    4294         if (loadType() == FrameLoadTypeReload || loadType() == FrameLoadTypeReloadFromOrigin)
    4295             saveScrollPositionAndViewStateToItem(m_currentHistoryItem.get());
     4331    if (m_currentItem) {
     4332        pageCache()->remove(m_currentItem.get());
     4333   
     4334        if (m_frame->loader()->loadType() == FrameLoadTypeReload || m_frame->loader()->loadType() == FrameLoadTypeReloadFromOrigin)
     4335            saveScrollPositionAndViewStateToItem(m_currentItem.get());
    42964336   
    42974337        // Sometimes loading a page again leads to a different result because of cookies. Bugzilla 4072
    4298         if (documentLoader()->unreachableURL().isEmpty())
    4299             m_currentHistoryItem->setURL(documentLoader()->requestURL());
    4300     }
    4301 }
    4302 
    4303 void FrameLoader::updateHistoryForRedirectWithLockedBackForwardList()
     4338        if (m_frame->loader()->documentLoader()->unreachableURL().isEmpty())
     4339            m_currentItem->setURL(m_frame->loader()->documentLoader()->requestURL());
     4340    }
     4341}
     4342
     4343void HistoryController::updateForRedirectWithLockedBackForwardList()
    43044344{
    43054345#if !LOG_DISABLED
    4306     if (documentLoader())
    4307         LOG(History, "WebCoreHistory: Updating History for redirect load in frame %s", documentLoader()->title().utf8().data());
     4346    if (m_frame->loader()->documentLoader())
     4347        LOG(History, "WebCoreHistory: Updating History for redirect load in frame %s", m_frame->loader()->documentLoader()->title().utf8().data());
    43084348#endif
    43094349   
    43104350    Settings* settings = m_frame->settings();
    43114351    bool needPrivacy = !settings || settings->privateBrowsingEnabled();
    4312     const KURL& historyURL = documentLoader()->urlForHistory();
    4313 
    4314     if (documentLoader()->isClientRedirect()) {
    4315         if (!m_currentHistoryItem && !m_frame->tree()->parent()) {
     4352    const KURL& historyURL = m_frame->loader()->documentLoader()->urlForHistory();
     4353
     4354    if (m_frame->loader()->documentLoader()->isClientRedirect()) {
     4355        if (!m_currentItem && !m_frame->tree()->parent()) {
    43164356            if (!historyURL.isEmpty()) {
    4317                 addBackForwardItemClippedAtTarget(true);
     4357                updateBackForwardListClippedAtTarget(true);
    43184358                if (!needPrivacy) {
    4319                     m_client->updateGlobalHistory();
    4320                     m_documentLoader->setDidCreateGlobalHistoryEntry(true);
    4321                     if (m_documentLoader->unreachableURL().isEmpty())
    4322                         m_client->updateGlobalHistoryRedirectLinks();
     4359                    m_frame->loader()->client()->updateGlobalHistory();
     4360                    m_frame->loader()->documentLoader()->setDidCreateGlobalHistoryEntry(true);
     4361                    if (m_frame->loader()->documentLoader()->unreachableURL().isEmpty())
     4362                        m_frame->loader()->client()->updateGlobalHistoryRedirectLinks();
    43234363                }
    43244364                if (Page* page = m_frame->page())
     
    43264366            }
    43274367        }
    4328         if (m_currentHistoryItem) {
    4329             m_currentHistoryItem->setURL(documentLoader()->url());
    4330             m_currentHistoryItem->setFormInfoFromRequest(documentLoader()->request());
     4368        if (m_currentItem) {
     4369            m_currentItem->setURL(m_frame->loader()->documentLoader()->url());
     4370            m_currentItem->setFormInfoFromRequest(m_frame->loader()->documentLoader()->request());
    43314371        }
    43324372    } else {
    43334373        Frame* parentFrame = m_frame->tree()->parent();
    4334         if (parentFrame && parentFrame->loader()->m_currentHistoryItem)
    4335             parentFrame->loader()->m_currentHistoryItem->setChildItem(createHistoryItem(true));
     4374        if (parentFrame && parentFrame->loader()->history()->m_currentItem)
     4375            parentFrame->loader()->history()->m_currentItem->setChildItem(createItem(true));
    43364376    }
    43374377
     
    43404380            page->group().addVisitedLink(historyURL);
    43414381
    4342         if (!m_documentLoader->didCreateGlobalHistoryEntry() && documentLoader()->unreachableURL().isEmpty() && !url().isEmpty())
    4343             m_client->updateGlobalHistoryRedirectLinks();
    4344     }
    4345 }
    4346 
    4347 void FrameLoader::updateHistoryForCommit()
    4348 {
     4382        if (!m_frame->loader()->documentLoader()->didCreateGlobalHistoryEntry() && m_frame->loader()->documentLoader()->unreachableURL().isEmpty() && !m_frame->loader()->url().isEmpty())
     4383            m_frame->loader()->client()->updateGlobalHistoryRedirectLinks();
     4384    }
     4385}
     4386
     4387void HistoryController::updateForCommit()
     4388{
     4389    FrameLoader* frameLoader = m_frame->loader();
    43494390#if !LOG_DISABLED
    4350     if (documentLoader())
    4351         LOG(History, "WebCoreHistory: Updating History for commit in frame %s", documentLoader()->title().utf8().data());
     4391    if (frameLoader->documentLoader())
     4392        LOG(History, "WebCoreHistory: Updating History for commit in frame %s", frameLoader->documentLoader()->title().utf8().data());
    43524393#endif
    4353     FrameLoadType type = loadType();
     4394    FrameLoadType type = frameLoader->loadType();
    43544395    if (isBackForwardLoadType(type) ||
    4355         ((type == FrameLoadTypeReload || type == FrameLoadTypeReloadFromOrigin) && !provisionalDocumentLoader()->unreachableURL().isEmpty())) {
     4396        ((type == FrameLoadTypeReload || type == FrameLoadTypeReloadFromOrigin) && !frameLoader->provisionalDocumentLoader()->unreachableURL().isEmpty())) {
    43564397        // Once committed, we want to use current item for saving DocState, and
    43574398        // the provisional item for restoring state.
    43584399        // Note previousItem must be set before we close the URL, which will
    43594400        // happen when the data source is made non-provisional below
    4360         m_previousHistoryItem = m_currentHistoryItem;
    4361         ASSERT(m_provisionalHistoryItem);
    4362         m_currentHistoryItem = m_provisionalHistoryItem;
    4363         m_provisionalHistoryItem = 0;
    4364     }
    4365 }
    4366 
    4367 void FrameLoader::updateHistoryForAnchorScroll()
    4368 {
    4369     if (m_URL.isEmpty())
     4401        m_previousItem = m_currentItem;
     4402        ASSERT(m_provisionalItem);
     4403        m_currentItem = m_provisionalItem;
     4404        m_provisionalItem = 0;
     4405    }
     4406}
     4407
     4408void HistoryController::updateForAnchorScroll()
     4409{
     4410    if (m_frame->loader()->url().isEmpty())
    43704411        return;
    43714412
     
    43784419        return;
    43794420
    4380     page->group().addVisitedLink(m_URL);
     4421    page->group().addVisitedLink(m_frame->loader()->url());
    43814422}
    43824423
    43834424// Walk the frame tree, telling all frames to save their form state into their current
    43844425// history item.
    4385 void FrameLoader::saveDocumentAndScrollState()
     4426void HistoryController::saveDocumentAndScrollState()
    43864427{
    43874428    for (Frame* frame = m_frame; frame; frame = frame->tree()->traverseNext(m_frame)) {
    4388         frame->loader()->saveDocumentState();
    4389         frame->loader()->saveScrollPositionAndViewStateToItem(frame->loader()->currentHistoryItem());
    4390     }
    4391 }
    4392 
    4393 HistoryItem* FrameLoader::currentHistoryItem()
    4394 {
    4395     return m_currentHistoryItem.get();
    4396 }
    4397 
    4398 void FrameLoader::setCurrentHistoryItem(PassRefPtr<HistoryItem> item)
    4399 {
    4400     m_currentHistoryItem = item;
     4429        frame->loader()->history()->saveDocumentState();
     4430        frame->loader()->history()->saveScrollPositionAndViewStateToItem(frame->loader()->history()->currentItem());
     4431    }
    44014432}
    44024433
     
    45384569}
    45394570
     4571void HistoryController::setCurrentItemTitle(const String& title)
     4572{
     4573    if (m_currentItem)
     4574        m_currentItem->setTitle(title);
     4575}
     4576
    45404577void FrameLoader::didChangeTitle(DocumentLoader* loader)
    45414578{
     
    45444581    if (loader == m_documentLoader) {
    45454582        // Must update the entries in the back-forward list too.
    4546         if (m_currentHistoryItem)
    4547             m_currentHistoryItem->setTitle(loader->title());
     4583        history()->setCurrentItemTitle(loader->title());
    45484584        // This must go through the WebFrame because it has the right notion of the current b/f item.
    45494585        m_client->setTitle(loader->title(), loader->urlForHistory());
  • trunk/WebCore/loader/FrameLoader.h

    r49372 r49413  
    8080    bool isBackForwardLoadType(FrameLoadType);
    8181
     82    class HistoryController : public Noncopyable {
     83    public:
     84        HistoryController(Frame*);
     85        ~HistoryController();
     86
     87        void saveScrollPositionAndViewStateToItem(HistoryItem*);
     88        void restoreScrollPositionAndViewState();
     89
     90        void updateBackForwardListForFragmentScroll();
     91
     92        void saveDocumentState();
     93        void saveDocumentAndScrollState();
     94        void restoreDocumentState();
     95
     96        void invalidateCurrentItemCachedPage();
     97
     98        void goToItem(HistoryItem*, FrameLoadType);
     99        bool urlsMatchItem(HistoryItem*) const;
     100
     101        void updateForBackForwardNavigation();
     102        void updateForReload();
     103        void updateForStandardLoad();
     104        void updateForRedirectWithLockedBackForwardList();
     105        void updateForClientRedirect();
     106        void updateForCommit();
     107        void updateForAnchorScroll();
     108        void updateForFrameLoadCompleted();
     109
     110        HistoryItem* currentItem() const { return m_currentItem.get(); }
     111        void setCurrentItem(HistoryItem*);
     112        void setCurrentItemTitle(const String&);
     113
     114        HistoryItem* provisionalItem() const { return m_provisionalItem.get(); }
     115        void setProvisionalItem(HistoryItem*);
     116
     117    private:
     118        PassRefPtr<HistoryItem> createItem(bool useOriginal);
     119        PassRefPtr<HistoryItem> createItemTree(Frame* targetFrame, bool clipAtTarget);
     120
     121        void recursiveGoToItem(HistoryItem*, HistoryItem*, FrameLoadType);
     122        bool childFramesMatchItem(HistoryItem*) const;
     123        void updateBackForwardListClippedAtTarget(bool doClip);
     124
     125        Frame* m_frame;
     126
     127        RefPtr<HistoryItem> m_currentItem;
     128        RefPtr<HistoryItem> m_previousItem;
     129        RefPtr<HistoryItem> m_provisionalItem;
     130    };
     131
    82132    class FrameLoader : public Noncopyable {
    83133    public:
     
    89139        Frame* frame() const { return m_frame; }
    90140
    91         PolicyChecker* policyChecker() { return &m_policyChecker; }
     141        PolicyChecker* policyChecker() const { return &m_policyChecker; }
     142        HistoryController* history() const { return &m_history; }
    92143
    93144        // FIXME: This is not cool, people. There are too many different functions that all start loads.
     
    256307        void dispatchWindowObjectAvailable();
    257308        void dispatchDocumentElementAvailable();
    258         void restoreDocumentState();
    259309
    260310        // Mixed content related functions.
     
    287337        void checkCompleted();
    288338
     339        void checkDidPerformFirstNavigation();
     340
    289341        bool isComplete() const;
    290342
     
    301353        bool isLoadingFromCachedPage() const { return m_loadingFromCachedPage; }
    302354
    303         void goToItem(HistoryItem*, FrameLoadType);
    304         void saveDocumentAndScrollState();
    305 
    306         HistoryItem* currentHistoryItem();
    307         void setCurrentHistoryItem(PassRefPtr<HistoryItem>);
    308 
    309355        bool committingFirstRealLoad() const { return !m_creatingInitialEmptyDocument && !m_committedFirstRealDocumentLoad; }
    310356        bool committedFirstRealDocumentLoad() const { return m_committedFirstRealDocumentLoad; }
     357        bool creatingInitialEmptyDocument() const { return m_creatingInitialEmptyDocument; }
    311358
    312359        void iconLoadDecisionAvailable();
     
    329376        void clientRedirected(const KURL&, double delay, double fireDate, bool lockBackForwardList);
    330377        void clientRedirectCancelledOrFinished(bool cancelWithLoadInProgress);
     378        void loadItem(HistoryItem*, FrameLoadType);
    331379
    332380        // FIXME: This is public because this asynchronous callback from the FrameLoaderClient
     
    336384
    337385    private:
    338         PassRefPtr<HistoryItem> createHistoryItem(bool useOriginal);
    339         PassRefPtr<HistoryItem> createHistoryItemTree(Frame* targetFrame, bool clipAtTarget);
    340 
    341386        bool canCachePageContainingThisFrame();
    342387#ifndef NDEBUG
     
    344389        bool logCanCacheFrameDecision(int indentLevel);
    345390#endif
    346 
    347         void addBackForwardItemClippedAtTarget(bool doClip);
    348         void restoreScrollPositionAndViewState();
    349         void saveDocumentState();
    350         void loadItem(HistoryItem*, FrameLoadType);
    351         bool urlsMatchItem(HistoryItem*) const;
    352         void invalidateCurrentItemCachedPage();
    353         void recursiveGoToItem(HistoryItem*, HistoryItem*, FrameLoadType);
    354         bool childFramesMatchItem(HistoryItem*) const;
    355 
    356         void updateHistoryForBackForwardNavigation();
    357         void updateHistoryForReload();
    358         void updateHistoryForStandardLoad();
    359         void updateHistoryForRedirectWithLockedBackForwardList();
    360         void updateHistoryForClientRedirect();
    361         void updateHistoryForCommit();
    362         void updateHistoryForAnchorScroll();
    363391
    364392        void checkTimerFired(Timer<FrameLoader>*);
     
    402430
    403431        bool shouldScrollToAnchor(bool isFormSubmission, FrameLoadType, const KURL&);
    404         void addHistoryItemForFragmentScroll();
    405432
    406433        void checkLoadCompleteForThisFrame();
     
    468495        bool shouldTreatURLAsSameAsCurrent(const KURL&) const;
    469496
    470         void saveScrollPositionAndViewStateToItem(HistoryItem*);
    471 
    472497        Frame* m_frame;
    473498        FrameLoaderClient* m_client;
    474499
    475         PolicyChecker m_policyChecker;
     500        mutable PolicyChecker m_policyChecker;
     501        mutable HistoryController m_history;
    476502
    477503        FrameState m_state;
     
    535561        bool m_committedFirstRealDocumentLoad;
    536562
    537         RefPtr<HistoryItem> m_currentHistoryItem;
    538         RefPtr<HistoryItem> m_previousHistoryItem;
    539         RefPtr<HistoryItem> m_provisionalHistoryItem;
    540        
    541563        bool m_didPerformFirstNavigation;
    542564        bool m_loadingFromCachedPage;
  • trunk/WebCore/page/Page.cpp

    r49385 r49413  
    292292#endif
    293293    m_mainFrame->loader()->stopAllLoaders(databasePolicy);
    294     m_mainFrame->loader()->goToItem(item, type);
     294    m_mainFrame->loader()->history()->goToItem(item, type);
    295295}
    296296
  • trunk/WebKit/mac/ChangeLog

    r49411 r49413  
     12009-10-09  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Factor HistoryController out of FrameLoader
     6        https://bugs.webkit.org/show_bug.cgi?id=30246
     7
     8        Update API call.
     9
     10        * WebCoreSupport/WebFrameLoaderClient.mm:
     11        (WebFrameLoaderClient::restoreViewState):
     12        * WebView/WebView.mm:
     13        (-[WebView _loadBackForwardListFromOtherView:]):
     14
    1152009-10-09  Mark Rowe  <mrowe@apple.com>
    216
  • trunk/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm

    r49320 r49413  
    989989void WebFrameLoaderClient::restoreViewState()
    990990{
    991     HistoryItem* currentItem = core(m_webFrame.get())->loader()->currentHistoryItem();
     991    HistoryItem* currentItem = core(m_webFrame.get())->loader()->history()->currentItem();
    992992    ASSERT(currentItem);
    993993
  • trunk/WebKit/mac/WebView/WebView.mm

    r49385 r49413  
    11881188            // since that might have changed since loading and it is normally not saved
    11891189            // until we leave that page.
    1190             otherView->_private->page->mainFrame()->loader()->saveDocumentAndScrollState();
     1190            otherView->_private->page->mainFrame()->loader()->history()->saveDocumentAndScrollState();
    11911191        }
    11921192        RefPtr<HistoryItem> newItem = otherBackForwardList->itemAtIndex(i)->copy();
  • trunk/WebKit/win/ChangeLog

    r49385 r49413  
     12009-10-09  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Factor HistoryController out of FrameLoader
     6        https://bugs.webkit.org/show_bug.cgi?id=30246
     7
     8        Update API call.
     9
     10        * WebView.cpp:
     11        (WebView::loadBackForwardListFromOtherView):
     12
    1132009-10-08  Jon Honeycutt  <jhoneycutt@apple.com>
    214
  • trunk/WebKit/win/WebView.cpp

    r49385 r49413  
    48114811            // since that might have changed since loading and it is normally not saved
    48124812            // until we leave that page.
    4813             otherWebView->m_page->mainFrame()->loader()->saveDocumentAndScrollState();
     4813            otherWebView->m_page->mainFrame()->loader()->history()->saveDocumentAndScrollState();
    48144814        }
    48154815        RefPtr<HistoryItem> newItem = otherBackForwardList->itemAtIndex(i)->copy();
Note: See TracChangeset for help on using the changeset viewer.