diff --git a/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp b/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp index 4e95f5b68d6..3055f479539 100644 --- a/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp +++ b/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp @@ -388,6 +388,10 @@ nsTypeAheadFind::Observe(nsISupports *aSubject, const char *aTopic, // -- Attach/Remove window listeners -- nsCOMPtr topLevelWindow(do_QueryInterface(aSubject)); NS_ENSURE_TRUE(topLevelWindow, NS_OK); + nsCOMPtr privateWindow = do_QueryInterface(aSubject); + nsIFocusController *focusController = + privateWindow->GetRootFocusController(); + NS_ENSURE_TRUE(focusController, NS_ERROR_FAILURE); if (isOpening) { if (mAutoStartPref) { @@ -396,16 +400,11 @@ nsTypeAheadFind::Observe(nsISupports *aSubject, const char *aTopic, // Attach nsTypeAheadController to window // so it can handle / and ' shortcuts to start text and link search - nsCOMPtr privateWindow = do_QueryInterface(aSubject); if (privateWindow) { nsCOMPtr controllers; privateWindow->GetControllers(getter_AddRefs(controllers)); NS_ENSURE_TRUE(controllers, NS_ERROR_FAILURE); - nsIFocusController *focusController = - privateWindow->GetRootFocusController(); - NS_ENSURE_TRUE(focusController, NS_ERROR_FAILURE); - nsCOMPtr controller = new nsTypeAheadController(focusController); NS_ENSURE_TRUE(controller, NS_ERROR_FAILURE); @@ -416,6 +415,10 @@ nsTypeAheadFind::Observe(nsISupports *aSubject, const char *aTopic, return NS_OK; } + nsCOMPtr activeWindowInternal; + focusController->GetFocusedWindow(getter_AddRefs(activeWindowInternal)); + nsCOMPtr activeWindow = do_QueryInterface(activeWindowInternal); + RemoveWindowListeners(topLevelWindow); // -- Prevent leaks --- @@ -460,6 +463,11 @@ nsTypeAheadFind::Observe(nsISupports *aSubject, const char *aTopic, RemoveDocListeners(); CancelFind(); } + if (domWin == activeWindow) { + // If popup was still open as its parent window closes, don't stay in + // menu active state which prevents us from operating + mIsMenuBarActive = mIsMenuPopupActive = PR_FALSE; + } } }