Backed out changeset 893b2c3b521f (Bug 365467 Focus controller's initial window and element can get out of sync r+sr=jst) to fix unittest bustage

This commit is contained in:
Ted Mielczarek 2008-10-08 12:43:41 -04:00
commit d09975b2fa

View File

@ -2286,17 +2286,19 @@ static void CheckForFocus(nsPIDOMWindow* aOurWindow,
if (!aFocusController)
return;
nsCOMPtr<nsIDOMWindowInternal> ourWin = do_QueryInterface(aOurWindow);
nsCOMPtr<nsIDOMWindowInternal> focusedWindow;
aFocusController->GetFocusedWindow(getter_AddRefs(focusedWindow));
if (!focusedWindow) {
// This happens if the window has not been shown yet. We don't need to
// focus anything now because showing the window will set the focus.
return;
// This should never really happen, but if it does, assume
// we can focus ourself to keep the window from being keydead.
focusedWindow = ourWin;
}
// Walk up the document chain, starting with focusedWindow's document.
// We stop walking when we find a document that has a null DOMWindow
// (meaning that the DOMWindow has a new document now) or find aOurWindow
// (meaning that the DOMWindow has a new document now) or find ourWin
// as the document's window. We also stop if we hit aDocument, since
// that means there is a child document which loaded before us that's
// already been given focus.
@ -2319,7 +2321,7 @@ static void CheckForFocus(nsPIDOMWindow* aOurWindow,
while (curDoc) {
nsPIDOMWindow *curWin = curDoc->GetWindow();
if (!curWin || curWin == aOurWindow)
if (!curWin || curWin == ourWin)
break;
curDoc = curDoc->GetParentDocument();
@ -2328,20 +2330,20 @@ static void CheckForFocus(nsPIDOMWindow* aOurWindow,
}
if (!curDoc) {
// We reached the top of the document chain, and did not encounter
// aOurWindow or a windowless document. So, focus should be unaffected
// by this document load.
// We reached the top of the document chain, and did not encounter ourWin
// or a windowless document. So, focus should be unaffected by this
// document load.
return;
}
PRBool active;
aFocusController->GetActive(&active);
if (active)
aOurWindow->Focus();
ourWin->Focus();
// We need to ensure that the focus controller is updated, since it may be
// suppressed when this function is called.
aFocusController->SetFocusedWindow(aOurWindow);
aFocusController->SetFocusedWindow(ourWin);
}
NS_IMETHODIMP