mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Fix bug 302962. When someone calls Activate() or Deactivate() on an nsWebBrowser which doesn't have a content viewer yet (and hence no pres shell), don't just bail because nsGlobalWindow will complain. Instead, change nsDocShell to make the content viewer on demand, and go ahead and pass the activate/deactivate onto the dom window. This fixes a serious focus bug in Camino.
r/sr=bryner, a=bsmdedberg.
This commit is contained in:
parent
700f885ac8
commit
cb4ed7c2b3
@ -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<nsIDocumentViewer> docv(do_QueryInterface(mContentViewer));
|
||||
nsresult rv = EnsureContentViewer();
|
||||
if (NS_FAILED(rv))
|
||||
return rv; // we're probably being destroyed
|
||||
|
||||
nsCOMPtr<nsIDocumentViewer> 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
|
||||
|
@ -4936,8 +4936,8 @@ nsGlobalWindow::Activate()
|
||||
NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);
|
||||
|
||||
return widget->SetFocus();
|
||||
|
||||
*/
|
||||
|
||||
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
|
||||
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
|
||||
if (treeOwnerAsWin) {
|
||||
@ -4952,10 +4952,7 @@ nsGlobalWindow::Activate()
|
||||
|
||||
nsCOMPtr<nsIPresShell> 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);
|
||||
|
@ -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<nsIPresShell> presShell;
|
||||
mDocShell->GetPresShell(getter_AddRefs(presShell));
|
||||
if(presShell) {
|
||||
nsCOMPtr<nsPIDOMWindow> 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<nsPIDOMWindow> 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<nsIPresShell> presShell;
|
||||
mDocShell->GetPresShell(getter_AddRefs(presShell));
|
||||
if(!presShell)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
GetContentDOMWindow(getter_AddRefs(domWindow));
|
||||
if (domWindow) {
|
||||
|
Loading…
Reference in New Issue
Block a user