Bug 785067 - Outparamdel nsGlobalWindow::SaveWindowState; r=mrbkap

This commit is contained in:
Ms2ger 2012-09-06 09:20:26 +02:00
parent edc358740e
commit da816a754b
4 changed files with 8 additions and 14 deletions

View File

@ -6944,9 +6944,7 @@ nsDocShell::CaptureState()
if (!privWin)
return NS_ERROR_FAILURE;
nsCOMPtr<nsISupports> windowState;
nsresult rv = privWin->SaveWindowState(getter_AddRefs(windowState));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISupports> windowState = privWin->SaveWindowState();
#ifdef DEBUG_PAGE_CACHE
nsCOMPtr<nsIURI> uri;
@ -6958,7 +6956,7 @@ nsDocShell::CaptureState()
printf(" SH URI: %s\n", spec.get());
#endif
rv = mOSHE->SetWindowState(windowState);
nsresult rv = mOSHE->SetWindowState(windowState);
NS_ENSURE_SUCCESS(rv, rv);
// Suspend refresh URIs and save off the timer queue

View File

@ -10300,16 +10300,14 @@ nsGlobalWindow::EnsureSizeUpToDate()
}
}
nsresult
nsGlobalWindow::SaveWindowState(nsISupports **aState)
already_AddRefed<nsISupports>
nsGlobalWindow::SaveWindowState()
{
NS_PRECONDITION(IsOuterWindow(), "Can't save the inner window's state");
*aState = nullptr;
if (!mContext || !mJSObject) {
// The window may be getting torn down; don't bother saving state.
return NS_OK;
return nullptr;
}
nsGlobalWindow *inner = GetCurrentInnerWindowInternal();
@ -10324,14 +10322,12 @@ nsGlobalWindow::SaveWindowState(nsISupports **aState)
nsCOMPtr<nsISupports> state = new WindowStateHolder(inner,
mInnerWindowHolder);
NS_ENSURE_TRUE(state, NS_ERROR_OUT_OF_MEMORY);
#ifdef DEBUG_PAGE_CACHE
printf("saving window state, state = %p\n", (void*)state);
#endif
state.swap(*aState);
return NS_OK;
return state.forget();
}
nsresult

View File

@ -348,7 +348,7 @@ public:
virtual NS_HIDDEN_(void) PopPopupControlState(PopupControlState state) const;
virtual NS_HIDDEN_(PopupControlState) GetPopupControlState() const;
virtual NS_HIDDEN_(nsresult) SaveWindowState(nsISupports **aState);
virtual already_AddRefed<nsISupports> SaveWindowState();
virtual NS_HIDDEN_(nsresult) RestoreWindowState(nsISupports *aState);
virtual NS_HIDDEN_(void) SuspendTimeouts(uint32_t aIncrease = 1,
bool aFreezeChildren = true);

View File

@ -291,7 +291,7 @@ public:
// Returns an object containing the window's state. This also suspends
// all running timeouts in the window.
virtual nsresult SaveWindowState(nsISupports **aState) = 0;
virtual already_AddRefed<nsISupports> SaveWindowState() = 0;
// Restore the window state from aState.
virtual nsresult RestoreWindowState(nsISupports *aState) = 0;