diff options
Diffstat (limited to 'WebCore/page/Page.cpp')
-rw-r--r-- | WebCore/page/Page.cpp | 77 |
1 files changed, 50 insertions, 27 deletions
diff --git a/WebCore/page/Page.cpp b/WebCore/page/Page.cpp index 5609e28..65c3d90 100644 --- a/WebCore/page/Page.cpp +++ b/WebCore/page/Page.cpp @@ -145,20 +145,20 @@ static void onPackageResultAvailable() #endif Page::Page(const PageClients& pageClients) - : m_chrome(new Chrome(this, pageClients.chromeClient)) - , m_dragCaretController(new SelectionController(0, true)) + : m_chrome(adoptPtr(new Chrome(this, pageClients.chromeClient))) + , m_dragCaretController(adoptPtr(new SelectionController(0, true))) #if ENABLE(DRAG_SUPPORT) - , m_dragController(new DragController(this, pageClients.dragClient)) + , m_dragController(adoptPtr(new DragController(this, pageClients.dragClient))) #endif - , m_focusController(new FocusController(this)) + , m_focusController(adoptPtr(new FocusController(this))) #if ENABLE(CONTEXT_MENUS) - , m_contextMenuController(new ContextMenuController(this, pageClients.contextMenuClient)) + , m_contextMenuController(adoptPtr(new ContextMenuController(this, pageClients.contextMenuClient))) #endif #if ENABLE(INSPECTOR) - , m_inspectorController(new InspectorController(this, pageClients.inspectorClient)) + , m_inspectorController(adoptPtr(new InspectorController(this, pageClients.inspectorClient))) #endif #if ENABLE(CLIENT_BASED_GEOLOCATION) - , m_geolocationController(new GeolocationController(this, pageClients.geolocationControllerClient)) + , m_geolocationController(adoptPtr(new GeolocationController(this, pageClients.geolocationControllerClient))) #endif #if ENABLE(DEVICE_ORIENTATION) , m_deviceMotionController(RuntimeEnabledFeatures::deviceMotionEnabled() ? new DeviceMotionController(pageClients.deviceMotionClient) : 0) @@ -167,9 +167,9 @@ Page::Page(const PageClients& pageClients) #if ENABLE(INPUT_SPEECH) , m_speechInputClient(pageClients.speechInputClient) #endif - , m_settings(new Settings(this)) - , m_progress(new ProgressTracker) - , m_backForwardController(new BackForwardController(this, pageClients.backForwardControllerClient)) + , m_settings(adoptPtr(new Settings(this))) + , m_progress(adoptPtr(new ProgressTracker)) + , m_backForwardController(adoptPtr(new BackForwardController(this, pageClients.backForwardClient))) , m_theme(RenderTheme::themeForPage(this)) , m_editorClient(pageClients.editorClient) , m_frameCount(0) @@ -233,7 +233,7 @@ Page::~Page() m_inspectorController->inspectedPageDestroyed(); #endif - backForwardList()->close(); + backForward()->close(); #ifndef NDEBUG pageCounter.decrement(); @@ -302,12 +302,12 @@ void Page::setOpenedByDOM() BackForwardList* Page::backForwardList() const { - return m_backForwardController->list(); + return m_backForwardController->client(); } bool Page::goBack() { - HistoryItem* item = backForwardList()->backItem(); + HistoryItem* item = backForward()->backItem(); if (item) { goToItem(item, FrameLoadTypeBack); @@ -318,7 +318,7 @@ bool Page::goBack() bool Page::goForward() { - HistoryItem* item = backForwardList()->forwardItem(); + HistoryItem* item = backForward()->forwardItem(); if (item) { goToItem(item, FrameLoadTypeForward); @@ -331,9 +331,9 @@ bool Page::canGoBackOrForward(int distance) const { if (distance == 0) return true; - if (distance > 0 && distance <= backForwardList()->forwardListCount()) + if (distance > 0 && distance <= backForward()->forwardCount()) return true; - if (distance < 0 && -distance <= backForwardList()->backListCount()) + if (distance < 0 && -distance <= backForward()->backCount()) return true; return false; } @@ -343,28 +343,32 @@ void Page::goBackOrForward(int distance) if (distance == 0) return; - HistoryItem* item = backForwardList()->itemAtIndex(distance); + HistoryItem* item = backForward()->itemAtIndex(distance); if (!item) { if (distance > 0) { - int forwardListCount = backForwardList()->forwardListCount(); - if (forwardListCount > 0) - item = backForwardList()->itemAtIndex(forwardListCount); + if (int forwardCount = backForward()->forwardCount()) + item = backForward()->itemAtIndex(forwardCount); } else { - int backListCount = backForwardList()->backListCount(); - if (backListCount > 0) - item = backForwardList()->itemAtIndex(-backListCount); + if (int backCount = backForward()->backCount()) + item = backForward()->itemAtIndex(-backCount); } } - ASSERT(item); // we should not reach this line with an empty back/forward list - if (item) - goToItem(item, FrameLoadTypeIndexedBackForward); + ASSERT(item); + if (!item) + return; + + goToItem(item, FrameLoadTypeIndexedBackForward); } void Page::goToItem(HistoryItem* item, FrameLoadType type) { if (defersLoading()) return; + + // stopAllLoaders may end up running onload handlers, which could cause further history traversals that may lead to the passed in HistoryItem + // being deref()-ed. Make sure we can still use it with HistoryController::goToItem later. + RefPtr<HistoryItem> protector(item); // Abort any current load unless we're navigating the current document to a new state object HistoryItem* currentItem = m_mainFrame->loader()->history()->currentItem(); @@ -389,7 +393,7 @@ void Page::goToItem(HistoryItem* item, FrameLoadType type) int Page::getHistoryLength() { - return backForwardList()->backListCount() + 1 + backForwardList()->forwardListCount(); + return backForward()->backCount() + 1 + backForward()->forwardCount(); } void Page::setGlobalHistoryItem(HistoryItem* item) @@ -925,4 +929,23 @@ void Page::checkFrameCountConsistency() const ASSERT(m_frameCount + 1 == frameCount); } #endif + +Page::PageClients::PageClients() + : chromeClient(0) + , contextMenuClient(0) + , editorClient(0) + , dragClient(0) + , inspectorClient(0) + , pluginHalterClient(0) + , geolocationControllerClient(0) + , deviceMotionClient(0) + , deviceOrientationClient(0) + , speechInputClient(0) +{ +} + +Page::PageClients::~PageClients() +{ +} + } // namespace WebCore |