diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index 7b383a8a77b..9b841b8393d 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -846,6 +846,13 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext, } if (focusController) { + // Make sure the focus controller is up-to-date, since restoring + // focus memory may have caused focus to go elsewhere. + + if (gLastFocusedDocument && gLastFocusedDocument == mDocument) { + nsCOMPtr focusElement = do_QueryInterface(mCurrentFocus); + focusController->SetFocusedElement(focusElement); + } PRBool isSuppressed; focusController->GetSuppressFocus(&isSuppressed); @@ -857,14 +864,6 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext, focusController->GetSuppressFocus(&isSuppressed); } focusController->SetSuppressFocusScroll(PR_FALSE); - - // Make sure the focus controller is up-to-date, since restoring - // focus memory may have caused focus to go elsewhere. - - if (gLastFocusedDocument && gLastFocusedDocument == mDocument) { - nsCOMPtr focusElement = do_QueryInterface(mCurrentFocus); - focusController->SetFocusedElement(focusElement); - } } } break; diff --git a/mozilla/dom/src/base/nsFocusController.cpp b/mozilla/dom/src/base/nsFocusController.cpp index 67766ea6d00..a7603c51a85 100644 --- a/mozilla/dom/src/base/nsFocusController.cpp +++ b/mozilla/dom/src/base/nsFocusController.cpp @@ -360,8 +360,7 @@ nsFocusController::Focus(nsIDOMEvent* aEvent) else mPreviousElement = nsnull; - if (!mCurrentElement && mCurrentWindow != mPreviousWindow) { - mNeedUpdateCommands = PR_TRUE; + if (!mCurrentElement) { UpdateCommands(); } } @@ -518,6 +517,8 @@ nsFocusController::SetSuppressFocus(PRBool aSuppressFocus, const char* aReason) // because nsPresShell::UnsuppressPainting may have just now unsuppressed // focus on the currently focused window if (!mSuppressFocus) { + // Always update commands if we have a current element + mNeedUpdateCommands = mNeedUpdateCommands || mCurrentElement; UpdateCommands(); } diff --git a/mozilla/mailnews/compose/resources/content/MsgComposeCommands.js b/mozilla/mailnews/compose/resources/content/MsgComposeCommands.js index 5ebda33fee2..72a984d8051 100644 --- a/mozilla/mailnews/compose/resources/content/MsgComposeCommands.js +++ b/mozilla/mailnews/compose/resources/content/MsgComposeCommands.js @@ -1430,6 +1430,13 @@ var gMsgEditorCreationObserver = var editor = GetCurrentEditor(); if (editor && GetCurrentCommandManager() == aSubject) InitEditor(editor); + // Now that we know this document is an editor, update commands now if + // the document has focus, or next time it receives focus via + // CommandUpdate_MsgCompose() + if (gLastWindowToHaveFocus == document.commandDispatcher.focusedWindow) + updateComposeItems(); + else + gLastWindowToHaveFocus = null; } } } diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index b1c3fcec308..b085adad47a 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -486,10 +486,6 @@ nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent) nsCOMPtr domWindow = do_QueryInterface(piWin); - if (domWindow == focusedWindow) { - break; // Already focused - } - focusController->SetSuppressFocus(PR_TRUE, "Activation Suppression"); NS_ASSERTION(domWindow,