Bug 525153: In DocumentViewerImpl::LoadComplete, don't call OnPageShow if docshell is being destroyed. r=smaug sr=bz

This commit is contained in:
Daniel Holbert 2009-10-31 17:06:47 -07:00
parent f84651ffa7
commit 05d1532e81
2 changed files with 18 additions and 4 deletions

View File

@ -72,8 +72,11 @@ GetCSSComputedValue(nsIContent* aElem,
nsIDocument* doc = aElem->GetCurrentDoc();
NS_ABORT_IF_FALSE(doc,"any target element that's actively being animated "
"must be in a document");
nsPIDOMWindow* win = doc->GetWindow();
NS_ABORT_IF_FALSE(win, "actively animated document w/ no window");
nsRefPtr<nsComputedDOMStyle>
computedStyle(doc->GetWindow()->LookupComputedStyleFor(aElem));
computedStyle(win->LookupComputedStyleFor(aElem));
if (computedStyle) {
// NOTE: This will produce an empty string for shorthand values
computedStyle->GetPropertyValue(aPropID, aResult);

View File

@ -1054,8 +1054,19 @@ DocumentViewerImpl::LoadComplete(nsresult aStatus)
// Notify the document that it has been shown (regardless of whether
// it was just loaded). Note: mDocument may be null now if the above
// firing of onload caused the document to unload.
if (mDocument)
mDocument->OnPageShow(restoring, nsnull);
if (mDocument) {
// Re-get window, since it might have changed during above firing of onload
window = mDocument->GetWindow();
if (window) {
nsIDocShell *docShell = window->GetDocShell();
PRBool beingDestroyed;
if (docShell &&
NS_SUCCEEDED(docShell->IsBeingDestroyed(&beingDestroyed)) &&
!beingDestroyed) {
mDocument->OnPageShow(restoring, nsnull);
}
}
}
// Now that the document has loaded, we can tell the presshell
// to unsuppress painting.
@ -4002,7 +4013,7 @@ NS_IMETHODIMP
DocumentViewerImpl::ExitPrintPreview()
{
printf("TEST-INFO ExitPrintPreview: mPrintEngine=%p, GetIsPrinting()=%d\n",
mPrintEngine.get(), GetIsPrinting());
static_cast<void*>(mPrintEngine.get()), GetIsPrinting());
if (GetIsPrinting())
return NS_ERROR_FAILURE;
NS_ENSURE_TRUE(mPrintEngine, NS_ERROR_FAILURE);