mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 15:25:52 +00:00
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:
commit
d09975b2fa
@ -2286,17 +2286,19 @@ static void CheckForFocus(nsPIDOMWindow* aOurWindow,
|
|||||||
if (!aFocusController)
|
if (!aFocusController)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIDOMWindowInternal> ourWin = do_QueryInterface(aOurWindow);
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMWindowInternal> focusedWindow;
|
nsCOMPtr<nsIDOMWindowInternal> focusedWindow;
|
||||||
aFocusController->GetFocusedWindow(getter_AddRefs(focusedWindow));
|
aFocusController->GetFocusedWindow(getter_AddRefs(focusedWindow));
|
||||||
if (!focusedWindow) {
|
if (!focusedWindow) {
|
||||||
// This happens if the window has not been shown yet. We don't need to
|
// This should never really happen, but if it does, assume
|
||||||
// focus anything now because showing the window will set the focus.
|
// we can focus ourself to keep the window from being keydead.
|
||||||
return;
|
focusedWindow = ourWin;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Walk up the document chain, starting with focusedWindow's document.
|
// Walk up the document chain, starting with focusedWindow's document.
|
||||||
// We stop walking when we find a document that has a null DOMWindow
|
// 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
|
// 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
|
// that means there is a child document which loaded before us that's
|
||||||
// already been given focus.
|
// already been given focus.
|
||||||
@ -2319,7 +2321,7 @@ static void CheckForFocus(nsPIDOMWindow* aOurWindow,
|
|||||||
while (curDoc) {
|
while (curDoc) {
|
||||||
nsPIDOMWindow *curWin = curDoc->GetWindow();
|
nsPIDOMWindow *curWin = curDoc->GetWindow();
|
||||||
|
|
||||||
if (!curWin || curWin == aOurWindow)
|
if (!curWin || curWin == ourWin)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
curDoc = curDoc->GetParentDocument();
|
curDoc = curDoc->GetParentDocument();
|
||||||
@ -2328,20 +2330,20 @@ static void CheckForFocus(nsPIDOMWindow* aOurWindow,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!curDoc) {
|
if (!curDoc) {
|
||||||
// We reached the top of the document chain, and did not encounter
|
// We reached the top of the document chain, and did not encounter ourWin
|
||||||
// aOurWindow or a windowless document. So, focus should be unaffected
|
// or a windowless document. So, focus should be unaffected by this
|
||||||
// by this document load.
|
// document load.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool active;
|
PRBool active;
|
||||||
aFocusController->GetActive(&active);
|
aFocusController->GetActive(&active);
|
||||||
if (active)
|
if (active)
|
||||||
aOurWindow->Focus();
|
ourWin->Focus();
|
||||||
|
|
||||||
// We need to ensure that the focus controller is updated, since it may be
|
// We need to ensure that the focus controller is updated, since it may be
|
||||||
// suppressed when this function is called.
|
// suppressed when this function is called.
|
||||||
aFocusController->SetFocusedWindow(aOurWindow);
|
aFocusController->SetFocusedWindow(ourWin);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
Loading…
Reference in New Issue
Block a user