Changeset 155529 in webkit
- Timestamp:
- Sep 11, 2013 8:24:45 AM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r155527 r155529 1 2013-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 1 11 2013-09-11 Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com> 2 12 -
trunk/Source/WebCore/history/BackForwardController.cpp
r155512 r155529 33 33 namespace WebCore { 34 34 35 BackForwardController::BackForwardController(Page *page, PassRefPtr<BackForwardClient> client)35 BackForwardController::BackForwardController(Page& page, PassRefPtr<BackForwardClient> client) 36 36 : m_page(page) 37 37 , m_client(client) 38 38 { 39 39 if (!m_client) 40 m_client = BackForwardList::create( page);40 m_client = BackForwardList::create(&page); 41 41 } 42 42 … … 45 45 } 46 46 47 PassOwnPtr<BackForwardController> BackForwardController::create(Page* page, PassRefPtr<BackForwardClient> client)48 {49 return adoptPtr(new BackForwardController(page, client));50 }51 52 47 bool BackForwardController::canGoBackOrForward(int distance) const 53 48 { 54 return m_page ->canGoBackOrForward(distance);49 return m_page.canGoBackOrForward(distance); 55 50 } 56 51 57 52 void BackForwardController::goBackOrForward(int distance) 58 53 { 59 m_page ->goBackOrForward(distance);54 m_page.goBackOrForward(distance); 60 55 } 61 56 62 57 bool BackForwardController::goBack() 63 58 { 64 return m_page ->goBack();59 return m_page.goBack(); 65 60 } 66 61 67 62 bool BackForwardController::goForward() 68 63 { 69 return m_page ->goForward();64 return m_page.goForward(); 70 65 } 71 66 … … 82 77 int BackForwardController::count() const 83 78 { 84 return m_page ->getHistoryLength();79 return m_page.getHistoryLength(); 85 80 } 86 81 -
trunk/Source/WebCore/history/BackForwardController.h
r155504 r155529 40 40 WTF_MAKE_NONCOPYABLE(BackForwardController); WTF_MAKE_FAST_ALLOCATED; 41 41 public: 42 BackForwardController(Page&, PassRefPtr<BackForwardClient>); 42 43 ~BackForwardController(); 43 44 static PassOwnPtr<BackForwardController> create(Page*, PassRefPtr<BackForwardClient>);45 44 46 45 BackForwardClient* client() const { return m_client.get(); } … … 70 69 71 70 private: 72 BackForwardController(Page*, PassRefPtr<BackForwardClient>); 73 74 Page* m_page; 71 Page& m_page; 75 72 RefPtr<BackForwardClient> m_client; 76 73 }; -
trunk/Source/WebCore/history/PageCache.cpp
r155194 r155529 218 218 rejectReasons |= 1 << FrameCannotBeInPageCache; 219 219 220 if (!page->backForward() ->isActive()) {220 if (!page->backForward().isActive()) { 221 221 PCLOG(" -The back/forward list is disabled or has 0 capacity"); 222 222 rejectReasons |= 1 << DisabledBackForwardList; … … 356 356 return m_capacity > 0 357 357 && canCachePageContainingThisFrame(&page->mainFrame()) 358 && page->backForward() ->isActive()358 && page->backForward().isActive() 359 359 && page->settings().usesPageCache() 360 360 #if ENABLE(DEVICE_ORIENTATION) -
trunk/Source/WebCore/loader/FrameLoader.cpp
r155414 r155529 1124 1124 currentItem->setLastVisitWasFailure(true); 1125 1125 history().setCurrentItem(currentItem.get()); 1126 m_frame.page()->backForward() ->setCurrentItem(currentItem.get());1126 m_frame.page()->backForward().setCurrentItem(currentItem.get()); 1127 1127 1128 1128 ASSERT(stateMachine()->isDisplayingInitialEmptyDocument()); … … 2150 2150 if (shouldReset && item) 2151 2151 if (Page* page = m_frame.page()) { 2152 page->backForward() ->setCurrentItem(item.get());2152 page->backForward().setCurrentItem(item.get()); 2153 2153 m_frame.loader().client().updateGlobalHistoryItemForPage(); 2154 2154 } … … 2237 2237 2238 2238 KURL originalURL; 2239 int backCount = page->backForward() ->backCount();2239 int backCount = page->backForward().backCount(); 2240 2240 for (int backIndex = 0; backIndex <= backCount; backIndex++) { 2241 2241 // FIXME: At one point we had code here to check a "was user gesture" flag. 2242 2242 // Do we need to restore that logic? 2243 HistoryItem* historyItem = page->backForward() ->itemAtIndex(-backIndex);2243 HistoryItem* historyItem = page->backForward().itemAtIndex(-backIndex); 2244 2244 if (!historyItem) 2245 2245 continue; … … 2844 2844 if (Page* page = m_frame.page()) { 2845 2845 if (HistoryItem* resetItem = page->mainFrame().loader().history().currentItem()) { 2846 page->backForward() ->setCurrentItem(resetItem);2846 page->backForward().setCurrentItem(resetItem); 2847 2847 m_frame.loader().client().updateGlobalHistoryItemForPage(); 2848 2848 } … … 3061 3061 return; 3062 3062 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()) { 3064 3064 m_didPerformFirstNavigation = true; 3065 3065 m_client.didPerformFirstNavigation(); -
trunk/Source/WebCore/loader/HistoryController.cpp
r155150 r155529 278 278 // - plus, it only makes sense for the top level of the operation through the frametree, 279 279 // 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); 282 282 m_frame.loader().client().updateGlobalHistoryItemForPage(); 283 283 … … 803 803 RefPtr<HistoryItem> topItem = frameLoader.history().createItemTree(m_frame, doClip); 804 804 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()); 806 806 } 807 807 … … 848 848 m_currentItem->setURLString(urlString); 849 849 850 page->backForward() ->addItem(topItem.release());850 page->backForward().addItem(topItem.release()); 851 851 852 852 if (m_frame.settings().privateBrowsingEnabled()) -
trunk/Source/WebCore/loader/NavigationScheduler.cpp
r154962 r155529 206 206 // go(i!=0) from a frame navigates into the history of the frame only, 207 207 // 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); 209 209 } 210 210 … … 403 403 // Invalid history navigations (such as history.forward() during a new load) have the side effect of cancelling any scheduled 404 404 // 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()) { 407 407 cancel(); 408 408 return; -
trunk/Source/WebCore/page/ContextMenuController.cpp
r154938 r155529 293 293 case ContextMenuItemTagGoBack: 294 294 if (Page* page = frame->page()) 295 page->backForward() ->goBackOrForward(-1);295 page->backForward().goBackOrForward(-1); 296 296 break; 297 297 case ContextMenuItemTagGoForward: 298 298 if (Page* page = frame->page()) 299 page->backForward() ->goBackOrForward(1);299 page->backForward().goBackOrForward(1); 300 300 break; 301 301 case ContextMenuItemTagStop: … … 913 913 appendItem(ReloadItem, m_contextMenu.get()); 914 914 #else 915 if (frame->page() && frame->page()->backForward() ->canGoBackOrForward(-1))915 if (frame->page() && frame->page()->backForward().canGoBackOrForward(-1)) 916 916 appendItem(BackItem, m_contextMenu.get()); 917 917 918 if (frame->page() && frame->page()->backForward() ->canGoBackOrForward(1))918 if (frame->page() && frame->page()->backForward().canGoBackOrForward(1)) 919 919 appendItem(ForwardItem, m_contextMenu.get()); 920 920 … … 1294 1294 #if PLATFORM(GTK) 1295 1295 case ContextMenuItemTagGoBack: 1296 shouldEnable = frame->page() && frame->page()->backForward() ->canGoBackOrForward(-1);1296 shouldEnable = frame->page() && frame->page()->backForward().canGoBackOrForward(-1); 1297 1297 break; 1298 1298 case ContextMenuItemTagGoForward: 1299 shouldEnable = frame->page() && frame->page()->backForward() ->canGoBackOrForward(1);1299 shouldEnable = frame->page() && frame->page()->backForward().canGoBackOrForward(1); 1300 1300 break; 1301 1301 case ContextMenuItemTagStop: -
trunk/Source/WebCore/page/DOMWindow.cpp
r155207 r155529 973 973 bool allowScriptsToCloseWindows = m_frame->settings().allowScriptsToCloseWindows(); 974 974 975 if (!(page->openedByDOM() || page->backForward() ->count() <= 1 || allowScriptsToCloseWindows)) {975 if (!(page->openedByDOM() || page->backForward().count() <= 1 || allowScriptsToCloseWindows)) { 976 976 pageConsole()->addMessage(JSMessageSource, WarningMessageLevel, ASCIILiteral("Can't close the window since it was not opened by JavaScript")); 977 977 return; -
trunk/Source/WebCore/page/History.cpp
r154458 r155529 54 54 if (!m_frame->page()) 55 55 return 0; 56 return m_frame->page()->backForward() ->count();56 return m_frame->page()->backForward().count(); 57 57 } 58 58 -
trunk/Source/WebCore/page/Page.cpp
r155506 r155529 142 142 , m_settings(Settings::create(this)) 143 143 , m_progress(ProgressTracker::create()) 144 , m_backForwardController( BackForwardController::create(this, pageClients.backForwardClient))144 , m_backForwardController(createOwned<BackForwardController>(*this, pageClients.backForwardClient)) 145 145 , m_mainFrame(Frame::create(this, 0, pageClients.loaderClientForMainFrame)) 146 146 , m_theme(RenderTheme::themeForPage(this)) … … 231 231 m_scrollingCoordinator->pageDestroyed(); 232 232 233 backForward() ->close();233 backForward().close(); 234 234 235 235 #ifndef NDEBUG … … 357 357 BackForwardClient* Page::backForwardClient() const 358 358 { 359 return m_backForwardController->client();359 return backForward().client(); 360 360 } 361 361 362 362 bool Page::goBack() 363 363 { 364 HistoryItem* item = backForward() ->backItem();364 HistoryItem* item = backForward().backItem(); 365 365 366 366 if (item) { … … 373 373 bool Page::goForward() 374 374 { 375 HistoryItem* item = backForward() ->forwardItem();375 HistoryItem* item = backForward().forwardItem(); 376 376 377 377 if (item) { … … 386 386 if (distance == 0) 387 387 return true; 388 if (distance > 0 && distance <= backForward() ->forwardCount())388 if (distance > 0 && distance <= backForward().forwardCount()) 389 389 return true; 390 if (distance < 0 && -distance <= backForward() ->backCount())390 if (distance < 0 && -distance <= backForward().backCount()) 391 391 return true; 392 392 return false; … … 398 398 return; 399 399 400 HistoryItem* item = backForward() ->itemAtIndex(distance);400 HistoryItem* item = backForward().itemAtIndex(distance); 401 401 if (!item) { 402 402 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); 405 405 } else { 406 if (int backCount = backForward() ->backCount())407 item = backForward() ->itemAtIndex(-backCount);406 if (int backCount = backForward().backCount()) 407 item = backForward().itemAtIndex(-backCount); 408 408 } 409 409 } … … 429 429 int Page::getHistoryLength() 430 430 { 431 return backForward() ->backCount() + 1 + backForward()->forwardCount();431 return backForward().backCount() + 1 + backForward().forwardCount(); 432 432 } 433 433 -
trunk/Source/WebCore/page/Page.h
r155504 r155529 213 213 Settings& settings() const { return *m_settings; } 214 214 ProgressTracker& progress() const { return *m_progress; } 215 BackForwardController * backForward() const { return m_backForwardController.get(); }215 BackForwardController& backForward() const { return *m_backForwardController; } 216 216 217 217 FeatureObserver* featureObserver() { return &m_featureObserver; } … … 464 464 const OwnPtr<ProgressTracker> m_progress; 465 465 466 OwnPtr<BackForwardController> m_backForwardController;466 const OwnPtr<BackForwardController> m_backForwardController; 467 467 const RefPtr<Frame> m_mainFrame; 468 468 -
trunk/Source/WebCore/page/Settings.cpp
r154658 r155529 469 469 m_usesPageCache = usesPageCache; 470 470 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(); 473 473 for (int i = first; i <= last; i++) 474 pageCache()->remove(m_page->backForward() ->itemAtIndex(i));474 pageCache()->remove(m_page->backForward().itemAtIndex(i)); 475 475 } 476 476 } -
trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
r155289 r155529 978 978 if (Page* page = core(m_webFrame.get())->page()) { 979 979 if (!page->settings().privateBrowsingEnabled()) 980 historyItem = page->backForward() ->currentItem();980 historyItem = page->backForward().currentItem(); 981 981 } 982 982 -
trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp
r155289 r155529 826 826 if (Page* page = webView->page()) { 827 827 if (!page->settings().privateBrowsingEnabled()) 828 historyItem = page->backForward() ->currentItem();828 historyItem = page->backForward().currentItem(); 829 829 } 830 830 -
trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardList.cpp
r95901 r155529 44 44 if (!page) 45 45 return 0; 46 return InjectedBundleBackForwardListItem::create(page->backForward() ->itemAtIndex(index));46 return InjectedBundleBackForwardListItem::create(page->backForward().itemAtIndex(index)); 47 47 } 48 48 … … 54 54 if (!page) 55 55 return 0; 56 return page->backForward() ->backCount();56 return page->backForward().backCount(); 57 57 } 58 58 … … 64 64 if (!page) 65 65 return 0; 66 return page->backForward() ->forwardCount();66 return page->backForward().forwardCount(); 67 67 } 68 68 … … 74 74 if (!page) 75 75 return; 76 static_cast<WebBackForwardListProxy*>(page->backForward() ->client())->clear();76 static_cast<WebBackForwardListProxy*>(page->backForward().client())->clear(); 77 77 } 78 78
Note: See TracChangeset
for help on using the changeset viewer.