diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index a40b0950276..36ae7c4dfe8 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -1248,21 +1248,17 @@ nsDocShell::GetEldestPresContext(nsPresContext** aPresContext) NS_IMETHODIMP nsDocShell::GetPresContext(nsPresContext ** aPresContext) { - nsresult rv = NS_OK; - NS_ENSURE_ARG_POINTER(aPresContext); *aPresContext = nsnull; - if (mContentViewer) { - nsCOMPtr docv(do_QueryInterface(mContentViewer)); + nsresult rv = EnsureContentViewer(); + if (NS_FAILED(rv)) + return rv; // we're probably being destroyed + + nsCOMPtr docv(do_QueryInterface(mContentViewer)); + NS_ENSURE_TRUE(docv, NS_ERROR_NO_INTERFACE); - if (docv) { - rv = docv->GetPresContext(aPresContext); - } - } - - // Fail silently, if no PresContext is available... - return rv; + return docv->GetPresContext(aPresContext); } NS_IMETHODIMP diff --git a/mozilla/dom/src/base/nsGlobalWindow.cpp b/mozilla/dom/src/base/nsGlobalWindow.cpp index fc7dfdc17b4..5d7ea921dcc 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.cpp +++ b/mozilla/dom/src/base/nsGlobalWindow.cpp @@ -4936,8 +4936,8 @@ nsGlobalWindow::Activate() NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE); return widget->SetFocus(); - */ + nsCOMPtr treeOwnerAsWin; GetTreeOwner(getter_AddRefs(treeOwnerAsWin)); if (treeOwnerAsWin) { @@ -4952,10 +4952,7 @@ nsGlobalWindow::Activate() nsCOMPtr presShell; mDocShell->GetPresShell(getter_AddRefs(presShell)); - if (!presShell) { - NS_WARNING( "no preshell for window" ); - return NS_ERROR_FAILURE; - } + NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); nsIViewManager* vm = presShell->GetViewManager(); NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE); diff --git a/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp b/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp index 4e5396eef51..283ae7cb073 100644 --- a/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp +++ b/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp @@ -1787,19 +1787,14 @@ NS_IMETHODIMP nsWebBrowser::Activate(void) if (mWWatch) mWWatch->SetActiveWindow(win); - /* Activate the window itself. Do this only if the PresShell has - been created, since DOMWindow->Activate asserts otherwise. - (This method can be called during window creation before - the PresShell exists. For ex, Windows apps responding to - WM_ACTIVATE). */ - NS_ENSURE_STATE(mDocShell); - nsCOMPtr presShell; - mDocShell->GetPresShell(getter_AddRefs(presShell)); - if(presShell) { - nsCOMPtr privateDOMWindow = do_QueryInterface(win); - if(privateDOMWindow) - privateDOMWindow->Activate(); - } + /* Activate the window itself. Note that this method can be called during + window creation before the PresShell exists (for ex, Windows apps + responding to WM_ACTIVATE), which case nsGlobalWindow::Activate() + will return early. + */ + nsCOMPtr privateDOMWindow = do_QueryInterface(win); + if (privateDOMWindow) + privateDOMWindow->Activate(); } mActivating = PR_FALSE; @@ -1814,12 +1809,6 @@ NS_IMETHODIMP nsWebBrowser::Deactivate(void) This seems harmless and maybe safer, but we have no real evidence either way just yet. */ - NS_ENSURE_STATE(mDocShell); - nsCOMPtr presShell; - mDocShell->GetPresShell(getter_AddRefs(presShell)); - if(!presShell) - return NS_OK; - nsCOMPtr domWindow; GetContentDOMWindow(getter_AddRefs(domWindow)); if (domWindow) {