зеркало из https://github.com/mozilla/gecko-dev.git
reorganize SetFocus to be less likely to bail early on errors; more likely to default to focusing the whole window. and strip the extraneous braces rods added to my previous fix for this bug :) bug 50881 gets slapped down one more time. r=bryner,hyatt a=asa
This commit is contained in:
Родитель
89d2873215
Коммит
5389a6bb30
|
@ -2633,23 +2633,15 @@ nsDocShell::SetFocus()
|
|||
#endif
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
GetPresShell(getter_AddRefs(presShell));
|
||||
if (!presShell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
GetPresContext(getter_AddRefs(presContext));
|
||||
if (!presContext)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
/* Check to make sure the root frame for this document
|
||||
is not collapsed. */
|
||||
nsIFrame* rootFrame;
|
||||
presShell->GetRootFrame(&rootFrame);
|
||||
if (!rootFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (rootFrame) {
|
||||
nsRect frameRect;
|
||||
rootFrame->GetRect(frameRect);
|
||||
if (frameRect.IsEmpty()) {
|
||||
|
@ -2658,19 +2650,10 @@ nsDocShell::SetFocus()
|
|||
#endif
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIEventStateManager> esm;
|
||||
presContext->GetEventStateManager(getter_AddRefs(esm));
|
||||
if (!esm)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
presShell->GetDocument(getter_AddRefs(document));
|
||||
nsCOMPtr<nsIContent>
|
||||
rootContent(getter_AddRefs(document->GetRootContent()));
|
||||
if (!rootContent)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIContent> focusContent;
|
||||
|
||||
// Figure out what type of document this is
|
||||
// if parent doc is content then set focus to document itself
|
||||
|
@ -2690,6 +2673,16 @@ nsDocShell::SetFocus()
|
|||
// this way focus gets removed from the currently focused DocShell
|
||||
SetHasFocus(PR_TRUE);
|
||||
|
||||
nsCOMPtr<nsIContent> focusContent;
|
||||
|
||||
nsCOMPtr<nsIEventStateManager> esm;
|
||||
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
GetPresContext(getter_AddRefs(presContext));
|
||||
if (presContext) {
|
||||
presContext->GetEventStateManager(getter_AddRefs(esm));
|
||||
nsCOMPtr<nsIContent> rootContent(getter_AddRefs(document->GetRootContent()));
|
||||
if (esm && rootContent) {
|
||||
// Either focus the document or the "first" piece of content
|
||||
if (doFocusDoc) {
|
||||
esm->SetContentState(nsnull, NS_EVENT_STATE_FOCUS);
|
||||
|
@ -2704,6 +2697,8 @@ nsDocShell::SetFocus()
|
|||
focusContent = content;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (focusContent) {
|
||||
nsIFrame *focusFrame = nsnull;
|
||||
|
@ -2715,11 +2710,10 @@ nsDocShell::SetFocus()
|
|||
document->GetScriptGlobalObject(getter_AddRefs(sgo));
|
||||
if (sgo) {
|
||||
nsCOMPtr<nsIDOMWindowInternal> domwin(do_QueryInterface(sgo));
|
||||
if (domwin) {
|
||||
if (domwin)
|
||||
domwin->Focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче