Commit 672cb851 authored by akling@apple.com's avatar akling@apple.com

FrameLoader::history() should return a reference.

<https://webkit.org/b/120163>

Reviewed by Anders Carlsson.

Rehued by Anders Carlsson.

FrameLoader::m_history is never null, so make history() return a reference.
Also made HistoryController::m_frame a reference, since HistoryController's
lifetime is tied to FrameLoader, which is tied to the Frame.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154458 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ac4bd2b4
2013-08-22 Andreas Kling <akling@apple.com>
FrameLoader::history() should return a reference.
<https://webkit.org/b/120163>
Reviewed by Anders Carlsson.
Rehued by Anders Carlsson.
FrameLoader::m_history is never null, so make history() return a reference.
Also made HistoryController::m_frame a reference, since HistoryController's
lifetime is tied to FrameLoader, which is tied to the Frame.
2013-08-21 Simon Fraser <simon.fraser@apple.com>
Reloading this video test shows garbage briefly
......@@ -138,7 +138,7 @@ void CachedFrameBase::restore()
m_document->enqueuePageshowEvent(PageshowEventPersisted);
HistoryItem* historyItem = frame.loader().history()->currentItem();
HistoryItem* historyItem = frame.loader().history().currentItem();
m_document->enqueuePopstateEvent(historyItem && historyItem->stateObject() ? historyItem->stateObject() : SerializedScriptValue::nullValue());
#if ENABLE(TOUCH_EVENTS)
......
......@@ -136,7 +136,7 @@ static unsigned logCanCacheFrameDecision(Frame* frame, int indentLevel)
rejectReasons |= 1 << HasSharedWorkers;
}
#endif
if (!frame->loader().history()->currentItem()) {
if (!frame->loader().history().currentItem()) {
PCLOG(" -No current history item");
rejectReasons |= 1 << NoHistoryItem;
}
......@@ -325,7 +325,7 @@ bool PageCache::canCachePageContainingThisFrame(Frame* frame)
#if ENABLE(SHARED_WORKERS)
&& !SharedWorkerRepository::hasSharedWorkers(document)
#endif
&& frameLoader.history()->currentItem()
&& frameLoader.history().currentItem()
&& !frameLoader.quickRedirectComing()
&& !documentLoader->isLoadingInAPISense()
&& !documentLoader->isStopping()
......
This diff is collapsed.
/*
* Copyright (C) 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights reserved.
* Copyright (C) 2006, 2007, 2008, 2009, 2011, 2013 Apple Inc. All rights reserved.
* Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
* Copyright (C) Research In Motion Limited 2009. All rights reserved.
* Copyright (C) 2011 Google Inc. All rights reserved.
......@@ -92,7 +92,7 @@ public:
Frame& frame() const { return m_frame; }
PolicyChecker* policyChecker() const { return m_policyChecker.get(); }
HistoryController* history() const { return m_history.get(); }
HistoryController& history() const { return *m_history; }
ResourceLoadNotifier* notifier() const { return &m_notifer; }
SubframeLoader* subframeLoader() const { return &m_subframeLoader; }
IconController* icon() const { return m_icon.get(); }
......@@ -386,7 +386,7 @@ private:
// header dependencies unless performance testing proves otherwise.
// Some of these could be lazily created for memory savings on devices.
OwnPtr<PolicyChecker> m_policyChecker;
OwnPtr<HistoryController> m_history;
const OwnPtr<HistoryController> m_history;
mutable ResourceLoadNotifier m_notifer;
mutable SubframeLoader m_subframeLoader;
mutable FrameLoaderStateMachine m_stateMachine;
......
This diff is collapsed.
......@@ -48,7 +48,7 @@ class HistoryController {
public:
enum HistoryUpdateType { UpdateAll, UpdateAllExceptBackForwardList };
explicit HistoryController(Frame*);
explicit HistoryController(Frame&);
~HistoryController();
void saveScrollPositionAndViewStateToItem(HistoryItem*);
......@@ -94,7 +94,7 @@ private:
void initializeItem(HistoryItem*);
PassRefPtr<HistoryItem> createItem();
PassRefPtr<HistoryItem> createItemTree(Frame* targetFrame, bool clipAtTarget);
PassRefPtr<HistoryItem> createItemTree(Frame& targetFrame, bool clipAtTarget);
void recursiveSetProvisionalItem(HistoryItem*, HistoryItem*, FrameLoadType);
void recursiveGoToItem(HistoryItem*, HistoryItem*, FrameLoadType);
......@@ -107,7 +107,7 @@ private:
void updateBackForwardListClippedAtTarget(bool doClip);
void updateCurrentItem();
Frame* m_frame;
Frame& m_frame;
RefPtr<HistoryItem> m_currentItem;
RefPtr<HistoryItem> m_previousItem;
......
......@@ -67,7 +67,7 @@ PassRefPtr<SerializedScriptValue> History::stateInternal() const
if (!m_frame)
return 0;
if (HistoryItem* historyItem = m_frame->loader().history()->currentItem())
if (HistoryItem* historyItem = m_frame->loader().history().currentItem())
return historyItem->stateObject();
return 0;
......@@ -148,9 +148,9 @@ void History::stateObjectAdded(PassRefPtr<SerializedScriptValue> data, const Str
}
if (stateObjectType == StateObjectPush)
m_frame->loader().history()->pushState(data, title, fullURL.string());
m_frame->loader().history().pushState(data, title, fullURL.string());
else if (stateObjectType == StateObjectReplace)
m_frame->loader().history()->replaceState(data, title, fullURL.string());
m_frame->loader().history().replaceState(data, title, fullURL.string());
if (!urlString.isEmpty())
m_frame->document()->updateURLForPushOrReplaceState(fullURL);
......
......@@ -426,10 +426,10 @@ void Page::goToItem(HistoryItem* item, FrameLoadType type)
// being deref()-ed. Make sure we can still use it with HistoryController::goToItem later.
RefPtr<HistoryItem> protector(item);
if (m_mainFrame->loader().history()->shouldStopLoadingForHistoryItem(item))
if (m_mainFrame->loader().history().shouldStopLoadingForHistoryItem(item))
m_mainFrame->loader().stopAllLoaders();
m_mainFrame->loader().history()->goToItem(item, type);
m_mainFrame->loader().history().goToItem(item, type);
}
int Page::getHistoryLength()
......
......@@ -700,7 +700,7 @@ void Internals::selectColorInColorChooser(Element* element, const String& colorV
Vector<String> Internals::formControlStateOfPreviousHistoryItem(ExceptionCode& ec)
{
HistoryItem* mainItem = frame()->loader().history()->previousItem();
HistoryItem* mainItem = frame()->loader().history().previousItem();
if (!mainItem) {
ec = INVALID_ACCESS_ERR;
return Vector<String>();
......@@ -715,7 +715,7 @@ Vector<String> Internals::formControlStateOfPreviousHistoryItem(ExceptionCode& e
void Internals::setFormControlStateOfPreviousHistoryItem(const Vector<String>& state, ExceptionCode& ec)
{
HistoryItem* mainItem = frame()->loader().history()->previousItem();
HistoryItem* mainItem = frame()->loader().history().previousItem();
if (!mainItem) {
ec = INVALID_ACCESS_ERR;
return;
......@@ -1861,8 +1861,8 @@ PassRefPtr<MemoryInfo> Internals::memoryInfo() const
Vector<String> Internals::getReferencedFilePaths() const
{
frame()->loader().history()->saveDocumentAndScrollState();
return FormController::getReferencedFilePaths(frame()->loader().history()->currentItem()->documentState());
frame()->loader().history().saveDocumentAndScrollState();
return FormController::getReferencedFilePaths(frame()->loader().history().currentItem()->documentState());
}
void Internals::startTrackingRepaints(Document* document, ExceptionCode& ec)
......
......@@ -1113,7 +1113,7 @@ void WebFrameLoaderClient::saveViewStateToItem(HistoryItem* item)
void WebFrameLoaderClient::restoreViewState()
{
HistoryItem* currentItem = core(m_webFrame.get())->loader().history()->currentItem();
HistoryItem* currentItem = core(m_webFrame.get())->loader().history().currentItem();
ASSERT(currentItem);
// FIXME: As the ASSERT attests, it seems we should always have a currentItem here.
......
......@@ -1296,7 +1296,7 @@ static bool fastDocumentTeardownEnabled()
// If this item is showing , save away its current scroll and form state,
// since that might have changed since loading and it is normally not saved
// until we leave that page.
otherView->_private->page->mainFrame()->loader().history()->saveDocumentAndScrollState();
otherView->_private->page->mainFrame()->loader().history().saveDocumentAndScrollState();
}
RefPtr<HistoryItem> newItem = otherBackForwardList->itemAtIndex(i)->copy();
if (i == 0)
......
......@@ -5383,7 +5383,7 @@ HRESULT STDMETHODCALLTYPE WebView::loadBackForwardListFromOtherView(
// If this item is showing , save away its current scroll and form state,
// since that might have changed since loading and it is normally not saved
// until we leave that page.
otherWebView->m_page->mainFrame()->loader().history()->saveDocumentAndScrollState();
otherWebView->m_page->mainFrame()->loader().history().saveDocumentAndScrollState();
}
RefPtr<HistoryItem> newItem = otherBackForwardList->itemAtIndex(i)->copy();
if (!i)
......
......@@ -1113,7 +1113,7 @@ void WebFrameLoaderClient::saveViewStateToItem(HistoryItem*)
void WebFrameLoaderClient::restoreViewState()
{
// Inform the UI process of the scale factor.
double scaleFactor = m_frame->coreFrame()->loader().history()->currentItem()->pageScaleFactor();
double scaleFactor = m_frame->coreFrame()->loader().history().currentItem()->pageScaleFactor();
// A scale factor of 0 means the history item has the default scale factor, thus we do not need to update it.
if (scaleFactor)
......
......@@ -1053,7 +1053,7 @@ void WebPage::goToBackForwardItem(uint64_t backForwardItemID)
void WebPage::tryRestoreScrollPosition()
{
m_page->mainFrame()->loader().history()->restoreScrollPositionAndViewState();
m_page->mainFrame()->loader().history().restoreScrollPositionAndViewState();
}
void WebPage::layoutIfNeeded()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment