Changeset 155529 in webkit


Ignore:
Timestamp:
Sep 11, 2013 8:24:45 AM (11 years ago)
Author:
akling@apple.com
Message:

Page::backForward() should return a reference.
<https://webkit.org/b/121151>

Reviewed by Anders Carlsson.

There is always a BackForwardController, so make backForward() return a reference.
Also made it store a Page& internally since it's tied to the lifetime of Page.

Location:
trunk/Source
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r155527 r155529  
     12013-09-11  Andreas Kling  <akling@apple.com>
     2
     3        Page::backForward() should return a reference.
     4        <https://webkit.org/b/121151>
     5
     6        Reviewed by Anders Carlsson.
     7
     8        There is always a BackForwardController, so make backForward() return a reference.
     9        Also made it store a Page& internally since it's tied to the lifetime of Page.
     10
    1112013-09-11  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
    212
  • trunk/Source/WebCore/history/BackForwardController.cpp

    r155512 r155529  
    3333namespace WebCore {
    3434
    35 BackForwardController::BackForwardController(Page* page, PassRefPtr<BackForwardClient> client)
     35BackForwardController::BackForwardController(Page& page, PassRefPtr<BackForwardClient> client)
    3636    : m_page(page)
    3737    , m_client(client)
    3838{
    3939    if (!m_client)
    40         m_client = BackForwardList::create(page);
     40        m_client = BackForwardList::create(&page);
    4141}
    4242
     
    4545}
    4646
    47 PassOwnPtr<BackForwardController> BackForwardController::create(Page* page, PassRefPtr<BackForwardClient> client)
    48 {
    49     return adoptPtr(new BackForwardController(page, client));
    50 }
    51 
    5247bool BackForwardController::canGoBackOrForward(int distance) const
    5348{
    54     return m_page->canGoBackOrForward(distance);
     49    return m_page.canGoBackOrForward(distance);
    5550}
    5651
    5752void BackForwardController::goBackOrForward(int distance)
    5853{
    59     m_page->goBackOrForward(distance);
     54    m_page.goBackOrForward(distance);
    6055}
    6156
    6257bool BackForwardController::goBack()
    6358{
    64     return m_page->goBack();
     59    return m_page.goBack();
    6560}
    6661
    6762bool BackForwardController::goForward()
    6863{
    69     return m_page->goForward();
     64    return m_page.goForward();
    7065}
    7166
     
    8277int BackForwardController::count() const
    8378{
    84     return m_page->getHistoryLength();
     79    return m_page.getHistoryLength();
    8580}
    8681
  • trunk/Source/WebCore/history/BackForwardController.h

    r155504 r155529  
    4040    WTF_MAKE_NONCOPYABLE(BackForwardController); WTF_MAKE_FAST_ALLOCATED;
    4141public:
     42    BackForwardController(Page&, PassRefPtr<BackForwardClient>);
    4243    ~BackForwardController();
    43 
    44     static PassOwnPtr<BackForwardController> create(Page*, PassRefPtr<BackForwardClient>);
    4544
    4645    BackForwardClient* client() const { return m_client.get(); }
     
    7069
    7170private:
    72     BackForwardController(Page*, PassRefPtr<BackForwardClient>);
    73 
    74     Page* m_page;
     71    Page& m_page;
    7572    RefPtr<BackForwardClient> m_client;
    7673};
  • trunk/Source/WebCore/history/PageCache.cpp

    r155194 r155529  
    218218        rejectReasons |= 1 << FrameCannotBeInPageCache;
    219219   
    220     if (!page->backForward()->isActive()) {
     220    if (!page->backForward().isActive()) {
    221221        PCLOG("   -The back/forward list is disabled or has 0 capacity");
    222222        rejectReasons |= 1 << DisabledBackForwardList;
     
    356356    return m_capacity > 0
    357357        && canCachePageContainingThisFrame(&page->mainFrame())
    358         && page->backForward()->isActive()
     358        && page->backForward().isActive()
    359359        && page->settings().usesPageCache()
    360360#if ENABLE(DEVICE_ORIENTATION)
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r155414 r155529  
    11241124        currentItem->setLastVisitWasFailure(true);
    11251125        history().setCurrentItem(currentItem.get());
    1126         m_frame.page()->backForward()->setCurrentItem(currentItem.get());
     1126        m_frame.page()->backForward().setCurrentItem(currentItem.get());
    11271127
    11281128        ASSERT(stateMachine()->isDisplayingInitialEmptyDocument());
     
    21502150            if (shouldReset && item)
    21512151                if (Page* page = m_frame.page()) {
    2152                     page->backForward()->setCurrentItem(item.get());
     2152                    page->backForward().setCurrentItem(item.get());
    21532153                    m_frame.loader().client().updateGlobalHistoryItemForPage();
    21542154                }
     
    22372237
    22382238    KURL originalURL;
    2239     int backCount = page->backForward()->backCount();
     2239    int backCount = page->backForward().backCount();
    22402240    for (int backIndex = 0; backIndex <= backCount; backIndex++) {
    22412241        // FIXME: At one point we had code here to check a "was user gesture" flag.
    22422242        // Do we need to restore that logic?
    2243         HistoryItem* historyItem = page->backForward()->itemAtIndex(-backIndex);
     2243        HistoryItem* historyItem = page->backForward().itemAtIndex(-backIndex);
    22442244        if (!historyItem)
    22452245            continue;
     
    28442844            if (Page* page = m_frame.page()) {
    28452845                if (HistoryItem* resetItem = page->mainFrame().loader().history().currentItem()) {
    2846                     page->backForward()->setCurrentItem(resetItem);
     2846                    page->backForward().setCurrentItem(resetItem);
    28472847                    m_frame.loader().client().updateGlobalHistoryItemForPage();
    28482848                }
     
    30613061        return;
    30623062
    3063     if (!m_didPerformFirstNavigation && page->backForward()->currentItem() && !page->backForward()->backItem() && !page->backForward()->forwardItem()) {
     3063    if (!m_didPerformFirstNavigation && page->backForward().currentItem() && !page->backForward().backItem() && !page->backForward().forwardItem()) {
    30643064        m_didPerformFirstNavigation = true;
    30653065        m_client.didPerformFirstNavigation();
  • trunk/Source/WebCore/loader/HistoryController.cpp

    r155150 r155529  
    278278    // - plus, it only makes sense for the top level of the operation through the frametree,
    279279    // as opposed to happening for some/one of the page commits that might happen soon
    280     RefPtr<HistoryItem> currentItem = page->backForward()->currentItem();
    281     page->backForward()->setCurrentItem(targetItem);
     280    RefPtr<HistoryItem> currentItem = page->backForward().currentItem();
     281    page->backForward().setCurrentItem(targetItem);
    282282    m_frame.loader().client().updateGlobalHistoryItemForPage();
    283283
     
    803803    RefPtr<HistoryItem> topItem = frameLoader.history().createItemTree(m_frame, doClip);
    804804    LOG(BackForward, "WebCoreBackForward - Adding backforward item %p for frame %s", topItem.get(), m_frame.loader().documentLoader()->url().string().ascii().data());
    805     page->backForward()->addItem(topItem.release());
     805    page->backForward().addItem(topItem.release());
    806806}
    807807
     
    848848    m_currentItem->setURLString(urlString);
    849849
    850     page->backForward()->addItem(topItem.release());
     850    page->backForward().addItem(topItem.release());
    851851
    852852    if (m_frame.settings().privateBrowsingEnabled())
  • trunk/Source/WebCore/loader/NavigationScheduler.cpp

    r154962 r155529  
    206206        // go(i!=0) from a frame navigates into the history of the frame only,
    207207        // in both IE and NS (but not in Mozilla). We can't easily do that.
    208         frame->page()->backForward()->goBackOrForward(m_historySteps);
     208        frame->page()->backForward().goBackOrForward(m_historySteps);
    209209    }
    210210
     
    403403    // Invalid history navigations (such as history.forward() during a new load) have the side effect of cancelling any scheduled
    404404    // redirects. We also avoid the possibility of cancelling the current load by avoiding the scheduled redirection altogether.
    405     BackForwardController* backForward = m_frame->page()->backForward();
    406     if (steps > backForward->forwardCount() || -steps > backForward->backCount()) {
     405    BackForwardController& backForward = m_frame->page()->backForward();
     406    if (steps > backForward.forwardCount() || -steps > backForward.backCount()) {
    407407        cancel();
    408408        return;
  • trunk/Source/WebCore/page/ContextMenuController.cpp

    r154938 r155529  
    293293    case ContextMenuItemTagGoBack:
    294294        if (Page* page = frame->page())
    295             page->backForward()->goBackOrForward(-1);
     295            page->backForward().goBackOrForward(-1);
    296296        break;
    297297    case ContextMenuItemTagGoForward:
    298298        if (Page* page = frame->page())
    299             page->backForward()->goBackOrForward(1);
     299            page->backForward().goBackOrForward(1);
    300300        break;
    301301    case ContextMenuItemTagStop:
     
    913913                appendItem(ReloadItem, m_contextMenu.get());
    914914#else
    915                 if (frame->page() && frame->page()->backForward()->canGoBackOrForward(-1))
     915                if (frame->page() && frame->page()->backForward().canGoBackOrForward(-1))
    916916                    appendItem(BackItem, m_contextMenu.get());
    917917
    918                 if (frame->page() && frame->page()->backForward()->canGoBackOrForward(1))
     918                if (frame->page() && frame->page()->backForward().canGoBackOrForward(1))
    919919                    appendItem(ForwardItem, m_contextMenu.get());
    920920
     
    12941294#if PLATFORM(GTK)
    12951295        case ContextMenuItemTagGoBack:
    1296             shouldEnable = frame->page() && frame->page()->backForward()->canGoBackOrForward(-1);
     1296            shouldEnable = frame->page() && frame->page()->backForward().canGoBackOrForward(-1);
    12971297            break;
    12981298        case ContextMenuItemTagGoForward:
    1299             shouldEnable = frame->page() && frame->page()->backForward()->canGoBackOrForward(1);
     1299            shouldEnable = frame->page() && frame->page()->backForward().canGoBackOrForward(1);
    13001300            break;
    13011301        case ContextMenuItemTagStop:
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r155207 r155529  
    973973    bool allowScriptsToCloseWindows = m_frame->settings().allowScriptsToCloseWindows();
    974974
    975     if (!(page->openedByDOM() || page->backForward()->count() <= 1 || allowScriptsToCloseWindows)) {
     975    if (!(page->openedByDOM() || page->backForward().count() <= 1 || allowScriptsToCloseWindows)) {
    976976        pageConsole()->addMessage(JSMessageSource, WarningMessageLevel, ASCIILiteral("Can't close the window since it was not opened by JavaScript"));
    977977        return;
  • trunk/Source/WebCore/page/History.cpp

    r154458 r155529  
    5454    if (!m_frame->page())
    5555        return 0;
    56     return m_frame->page()->backForward()->count();
     56    return m_frame->page()->backForward().count();
    5757}
    5858
  • trunk/Source/WebCore/page/Page.cpp

    r155506 r155529  
    142142    , m_settings(Settings::create(this))
    143143    , m_progress(ProgressTracker::create())
    144     , m_backForwardController(BackForwardController::create(this, pageClients.backForwardClient))
     144    , m_backForwardController(createOwned<BackForwardController>(*this, pageClients.backForwardClient))
    145145    , m_mainFrame(Frame::create(this, 0, pageClients.loaderClientForMainFrame))
    146146    , m_theme(RenderTheme::themeForPage(this))
     
    231231        m_scrollingCoordinator->pageDestroyed();
    232232
    233     backForward()->close();
     233    backForward().close();
    234234
    235235#ifndef NDEBUG
     
    357357BackForwardClient* Page::backForwardClient() const
    358358{
    359     return m_backForwardController->client();
     359    return backForward().client();
    360360}
    361361
    362362bool Page::goBack()
    363363{
    364     HistoryItem* item = backForward()->backItem();
     364    HistoryItem* item = backForward().backItem();
    365365   
    366366    if (item) {
     
    373373bool Page::goForward()
    374374{
    375     HistoryItem* item = backForward()->forwardItem();
     375    HistoryItem* item = backForward().forwardItem();
    376376   
    377377    if (item) {
     
    386386    if (distance == 0)
    387387        return true;
    388     if (distance > 0 && distance <= backForward()->forwardCount())
     388    if (distance > 0 && distance <= backForward().forwardCount())
    389389        return true;
    390     if (distance < 0 && -distance <= backForward()->backCount())
     390    if (distance < 0 && -distance <= backForward().backCount())
    391391        return true;
    392392    return false;
     
    398398        return;
    399399
    400     HistoryItem* item = backForward()->itemAtIndex(distance);
     400    HistoryItem* item = backForward().itemAtIndex(distance);
    401401    if (!item) {
    402402        if (distance > 0) {
    403             if (int forwardCount = backForward()->forwardCount())
    404                 item = backForward()->itemAtIndex(forwardCount);
     403            if (int forwardCount = backForward().forwardCount())
     404                item = backForward().itemAtIndex(forwardCount);
    405405        } else {
    406             if (int backCount = backForward()->backCount())
    407                 item = backForward()->itemAtIndex(-backCount);
     406            if (int backCount = backForward().backCount())
     407                item = backForward().itemAtIndex(-backCount);
    408408        }
    409409    }
     
    429429int Page::getHistoryLength()
    430430{
    431     return backForward()->backCount() + 1 + backForward()->forwardCount();
     431    return backForward().backCount() + 1 + backForward().forwardCount();
    432432}
    433433
  • trunk/Source/WebCore/page/Page.h

    r155504 r155529  
    213213    Settings& settings() const { return *m_settings; }
    214214    ProgressTracker& progress() const { return *m_progress; }
    215     BackForwardController* backForward() const { return m_backForwardController.get(); }
     215    BackForwardController& backForward() const { return *m_backForwardController; }
    216216
    217217    FeatureObserver* featureObserver() { return &m_featureObserver; }
     
    464464    const OwnPtr<ProgressTracker> m_progress;
    465465
    466     OwnPtr<BackForwardController> m_backForwardController;
     466    const OwnPtr<BackForwardController> m_backForwardController;
    467467    const RefPtr<Frame> m_mainFrame;
    468468
  • trunk/Source/WebCore/page/Settings.cpp

    r154658 r155529  
    469469    m_usesPageCache = usesPageCache;
    470470    if (!m_usesPageCache) {
    471         int first = -m_page->backForward()->backCount();
    472         int last = m_page->backForward()->forwardCount();
     471        int first = -m_page->backForward().backCount();
     472        int last = m_page->backForward().forwardCount();
    473473        for (int i = first; i <= last; i++)
    474             pageCache()->remove(m_page->backForward()->itemAtIndex(i));
     474            pageCache()->remove(m_page->backForward().itemAtIndex(i));
    475475    }
    476476}
  • trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm

    r155289 r155529  
    978978    if (Page* page = core(m_webFrame.get())->page()) {
    979979        if (!page->settings().privateBrowsingEnabled())
    980             historyItem = page->backForward()->currentItem();
     980            historyItem = page->backForward().currentItem();
    981981    }
    982982
  • trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp

    r155289 r155529  
    826826    if (Page* page = webView->page()) {
    827827        if (!page->settings().privateBrowsingEnabled())
    828             historyItem = page->backForward()->currentItem();
     828            historyItem = page->backForward().currentItem();
    829829    }
    830830
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardList.cpp

    r95901 r155529  
    4444    if (!page)
    4545        return 0;
    46     return InjectedBundleBackForwardListItem::create(page->backForward()->itemAtIndex(index));
     46    return InjectedBundleBackForwardListItem::create(page->backForward().itemAtIndex(index));
    4747}
    4848
     
    5454    if (!page)
    5555        return 0;
    56     return page->backForward()->backCount();
     56    return page->backForward().backCount();
    5757}
    5858
     
    6464    if (!page)
    6565        return 0;
    66     return page->backForward()->forwardCount();
     66    return page->backForward().forwardCount();
    6767}
    6868
     
    7474    if (!page)
    7575        return;
    76     static_cast<WebBackForwardListProxy*>(page->backForward()->client())->clear();
     76    static_cast<WebBackForwardListProxy*>(page->backForward().client())->clear();
    7777}
    7878
Note: See TracChangeset for help on using the changeset viewer.