Fix for bug 83707 by hyatt. This should be in the trunk already
clears up the intial focus issues "fixed" by bug 83220 and bug 81668 git-svn-id: svn://10.0.0.236/branches/Accessible_052901_Branch4@96462 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -2381,23 +2381,15 @@ PresShell::EndObservingDocument()
|
||||
char* nsPresShell_ReflowStackPointerTop;
|
||||
#endif
|
||||
|
||||
static void CheckForFocus(nsIDocument* aDocument)
|
||||
static void CheckForFocus(nsPIDOMWindow* aOurWindow, nsIFocusController* aFocusController, nsIDocument* aDocument)
|
||||
{
|
||||
// Now that we have a root frame, set focus in to the presshell, but
|
||||
// only do this if our window is currently focused
|
||||
// Restore focus if we're the active window or a parent of a previously
|
||||
// active window.
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObject;
|
||||
aDocument->GetScriptGlobalObject(getter_AddRefs(globalObject));
|
||||
nsCOMPtr<nsPIDOMWindow> ourWindow = do_QueryInterface(globalObject);
|
||||
nsCOMPtr<nsIFocusController> focusController;
|
||||
ourWindow->GetRootFocusController(getter_AddRefs(focusController));
|
||||
|
||||
if (focusController) {
|
||||
// Suppress the command dispatcher.
|
||||
focusController->SetSuppressFocus(PR_TRUE, "PresShell suppression on Web page loads");
|
||||
if (aFocusController) {
|
||||
nsCOMPtr<nsIDOMWindowInternal> focusedWindow;
|
||||
focusController->GetFocusedWindow(getter_AddRefs(focusedWindow));
|
||||
aFocusController->GetFocusedWindow(getter_AddRefs(focusedWindow));
|
||||
|
||||
// See if the command dispatcher is holding on to an orphan window.
|
||||
// This happens when you move from an inner frame to an outer frame
|
||||
@@ -2408,23 +2400,22 @@ static void CheckForFocus(nsIDocument* aDocument)
|
||||
if (!domDoc) {
|
||||
// We're pointing to garbage. Go ahead and let this
|
||||
// presshell take the focus.
|
||||
focusedWindow = do_QueryInterface(ourWindow);
|
||||
focusController->SetFocusedWindow(focusedWindow);
|
||||
focusedWindow = do_QueryInterface(aOurWindow);
|
||||
aFocusController->SetFocusedWindow(focusedWindow);
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMWindowInternal> domWindow = do_QueryInterface(ourWindow);
|
||||
nsCOMPtr<nsIDOMWindowInternal> domWindow = do_QueryInterface(aOurWindow);
|
||||
if (domWindow == focusedWindow) {
|
||||
PRBool active;
|
||||
focusController->GetActive(&active);
|
||||
focusController->SetFocusedElement(nsnull);
|
||||
aFocusController->GetActive(&active);
|
||||
aFocusController->SetFocusedElement(nsnull);
|
||||
if(active) {
|
||||
// We need to restore focus and make sure we null
|
||||
// out the focused element.
|
||||
domWindow->Focus();
|
||||
}
|
||||
}
|
||||
focusController->SetSuppressFocus(PR_FALSE, "PresShell suppression on Web page loads");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4458,6 +4449,16 @@ PresShell::IsPaintingSuppressed(PRBool* aResult)
|
||||
void
|
||||
PresShell::UnsuppressAndInvalidate()
|
||||
{
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObject;
|
||||
mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject));
|
||||
nsCOMPtr<nsPIDOMWindow> ourWindow = do_QueryInterface(globalObject);
|
||||
nsCOMPtr<nsIFocusController> focusController;
|
||||
ourWindow->GetRootFocusController(getter_AddRefs(focusController));
|
||||
if (focusController)
|
||||
// Suppress focus. The act of tearing down the old content viewer
|
||||
// causes us to blur incorrectly.
|
||||
focusController->SetSuppressFocus(PR_TRUE, "PresShell suppression on Web page loads");
|
||||
|
||||
nsCOMPtr<nsISupports> container;
|
||||
nsCOMPtr<nsIContentViewer> cv;
|
||||
nsCOMPtr<nsIDocumentViewer> dv;
|
||||
@@ -4485,7 +4486,10 @@ PresShell::UnsuppressAndInvalidate()
|
||||
((nsFrame*)rootFrame)->Invalidate(mPresContext, rect, PR_FALSE);
|
||||
}
|
||||
|
||||
CheckForFocus(mDocument);
|
||||
CheckForFocus(ourWindow, focusController, mDocument);
|
||||
|
||||
if (focusController) // Unsuppress now that we've shown the new window and focused it.
|
||||
focusController->SetSuppressFocus(PR_FALSE, "PresShell suppression on Web page loads");
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
||||
Reference in New Issue
Block a user