diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index c7c7b782e4f5..eb40d86622a5 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -13678,7 +13678,8 @@ nsDocShell::EnsureFind() // default to our window nsCOMPtr ourWindow = do_QueryInterface(scriptGO); nsCOMPtr windowToSearch; - nsFocusManager::GetFocusedDescendant(ourWindow, true, + nsFocusManager::GetFocusedDescendant(ourWindow, + nsFocusManager::eIncludeAllDescendants, getter_AddRefs(windowToSearch)); nsCOMPtr findInFrames = do_QueryInterface(mFind); @@ -13993,7 +13994,8 @@ nsDocShell::GetControllerForCommand(const char* aCommand, nsCOMPtr root = mScriptGlobal->GetTopWindowRoot(); NS_ENSURE_TRUE(root, NS_ERROR_FAILURE); - return root->GetControllerForCommand(aCommand, aResult); + return root->GetControllerForCommand(aCommand, false /* for any window */, + aResult); } NS_IMETHODIMP diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index ea189132eea9..b81f1e618319 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -2158,7 +2158,9 @@ Element::ShouldBlur(nsIContent *aContent) nsCOMPtr focusedFrame; nsIContent* contentToBlur = - nsFocusManager::GetFocusedDescendant(window, false, getter_AddRefs(focusedFrame)); + nsFocusManager::GetFocusedDescendant(window, + nsFocusManager::eOnlyCurrentWindow, + getter_AddRefs(focusedFrame)); if (contentToBlur == aContent) return true; diff --git a/dom/base/Selection.cpp b/dom/base/Selection.cpp index 83c5156e2a0e..3d93b82ff298 100644 --- a/dom/base/Selection.cpp +++ b/dom/base/Selection.cpp @@ -3832,7 +3832,9 @@ Selection::NotifySelectionListeners() nsFocusManager* fm = nsFocusManager::GetFocusManager(); nsCOMPtr focusedWindow; nsIContent* focusedContent = - fm->GetFocusedDescendant(window, false, getter_AddRefs(focusedWindow)); + nsFocusManager::GetFocusedDescendant(window, + nsFocusManager::eOnlyCurrentWindow, + getter_AddRefs(focusedWindow)); nsCOMPtr focusedElement = do_QueryInterface(focusedContent); // When all selected ranges are in an editing host, it should take focus. // But otherwise, we shouldn't move focus since Chromium doesn't move diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index efebae247706..981b69c9314f 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -3604,7 +3604,8 @@ nsIDocument::GetActiveElement() if (nsCOMPtr window = GetWindow()) { nsCOMPtr focusedWindow; nsIContent* focusedContent = - nsFocusManager::GetFocusedDescendant(window, false, + nsFocusManager::GetFocusedDescendant(window, + nsFocusManager::eOnlyCurrentWindow, getter_AddRefs(focusedWindow)); // be safe and make sure the element is from this document if (focusedContent && focusedContent->OwnerDoc() == this) { diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index 5d85e587408a..a4ba4d4f76cd 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -299,7 +299,8 @@ GetCurrentWindow(nsIContent* aContent) // static nsIContent* -nsFocusManager::GetFocusedDescendant(nsPIDOMWindowOuter* aWindow, bool aDeep, +nsFocusManager::GetFocusedDescendant(nsPIDOMWindowOuter* aWindow, + SearchRange aSearchRange, nsPIDOMWindowOuter** aFocusedWindow) { NS_ENSURE_TRUE(aWindow, nullptr); @@ -308,13 +309,34 @@ nsFocusManager::GetFocusedDescendant(nsPIDOMWindowOuter* aWindow, bool aDeep, nsIContent* currentContent = nullptr; nsPIDOMWindowOuter* window = aWindow; - while (window) { + for (;;) { *aFocusedWindow = window; currentContent = window->GetFocusedNode(); - if (!currentContent || !aDeep) + if (!currentContent || aSearchRange == eOnlyCurrentWindow) { break; + } window = GetContentWindow(currentContent); + if (!window) { + break; + } + + if (aSearchRange == eIncludeAllDescendants) { + continue; + } + + MOZ_ASSERT(aSearchRange == eIncludeVisibleDescendants); + + // If the child window doesn't have PresShell, it means the window is + // invisible. + nsIDocShell* docShell = window->GetDocShell(); + if (!docShell) { + break; + } + nsIPresShell* presShell = docShell->GetPresShell(); + if (!presShell) { + break; + } } NS_IF_ADDREF(*aFocusedWindow); @@ -628,7 +650,10 @@ nsFocusManager::GetFocusedElementForWindow(mozIDOMWindowProxy* aWindow, nsCOMPtr focusedWindow; nsCOMPtr focusedContent = - GetFocusedDescendant(window, aDeep, getter_AddRefs(focusedWindow)); + GetFocusedDescendant(window, + aDeep ? nsFocusManager::eIncludeAllDescendants : + nsFocusManager::eOnlyCurrentWindow, + getter_AddRefs(focusedWindow)); if (focusedContent) CallQueryInterface(focusedContent, aElement); @@ -738,7 +763,8 @@ nsFocusManager::WindowRaised(mozIDOMWindowProxy* aWindow) // retrieve the last focused element within the window that was raised nsCOMPtr currentWindow; nsCOMPtr currentFocus = - GetFocusedDescendant(window, true, getter_AddRefs(currentWindow)); + GetFocusedDescendant(window, eIncludeAllDescendants, + getter_AddRefs(currentWindow)); NS_ASSERTION(currentWindow, "window raised with no window current"); if (!currentWindow) @@ -910,7 +936,8 @@ nsFocusManager::WindowShown(mozIDOMWindowProxy* aWindow, bool aNeedsFocus) if (aNeedsFocus) { nsCOMPtr currentWindow; nsCOMPtr currentFocus = - GetFocusedDescendant(window, true, getter_AddRefs(currentWindow)); + GetFocusedDescendant(window, eIncludeAllDescendants, + getter_AddRefs(currentWindow)); if (currentWindow) Focus(currentWindow, currentFocus, 0, true, false, false, true); } @@ -1213,7 +1240,8 @@ nsFocusManager::SetFocusInner(nsIContent* aNewContent, int32_t aFlags, nsCOMPtr newWindow; nsCOMPtr subWindow = GetContentWindow(contentToFocus); if (subWindow) { - contentToFocus = GetFocusedDescendant(subWindow, true, getter_AddRefs(newWindow)); + contentToFocus = GetFocusedDescendant(subWindow, eIncludeAllDescendants, + getter_AddRefs(newWindow)); // since a window is being refocused, clear aFocusChanged so that the // caret position isn't updated. aFocusChanged = false; @@ -2290,7 +2318,8 @@ nsFocusManager::RaiseWindow(nsPIDOMWindowOuter* aWindow) // But on other platforms, we can just focus the toplevel widget to raise // the window. nsCOMPtr childWindow; - GetFocusedDescendant(aWindow, true, getter_AddRefs(childWindow)); + GetFocusedDescendant(aWindow, eIncludeAllDescendants, + getter_AddRefs(childWindow)); if (!childWindow) childWindow = aWindow; @@ -2654,7 +2683,8 @@ nsFocusManager::DetermineElementToMoveFocus(nsPIDOMWindowOuter* aWindow, // When moving between documents, make sure to get the right // starting content in a descendant. nsCOMPtr focusedWindow; - startContent = GetFocusedDescendant(aWindow, true, getter_AddRefs(focusedWindow)); + startContent = GetFocusedDescendant(aWindow, eIncludeAllDescendants, + getter_AddRefs(focusedWindow)); } else if (aType != MOVEFOCUS_LASTDOC) { // Otherwise, start at the focused node. If MOVEFOCUS_LASTDOC is used, diff --git a/dom/base/nsFocusManager.h b/dom/base/nsFocusManager.h index e32fbec55f85..d848c4648ac8 100644 --- a/dom/base/nsFocusManager.h +++ b/dom/base/nsFocusManager.h @@ -134,7 +134,17 @@ public: * * aWindow and aFocusedWindow must both be non-null. */ - static nsIContent* GetFocusedDescendant(nsPIDOMWindowOuter* aWindow, bool aDeep, + enum SearchRange + { + // Return focused content in aWindow. So, aFocusedWindow is always aWindow. + eOnlyCurrentWindow, + // Return focused content in aWindow or one of all sub windows. + eIncludeAllDescendants, + // Return focused content in aWindow or one of visible sub windows. + eIncludeVisibleDescendants, + }; + static nsIContent* GetFocusedDescendant(nsPIDOMWindowOuter* aWindow, + SearchRange aSearchRange, nsPIDOMWindowOuter** aFocusedWindow); /** diff --git a/dom/base/nsPIWindowRoot.h b/dom/base/nsPIWindowRoot.h index ec39e48a86bf..ba8eeb13c1f6 100644 --- a/dom/base/nsPIWindowRoot.h +++ b/dom/base/nsPIWindowRoot.h @@ -36,9 +36,20 @@ public: virtual nsIDOMNode* GetPopupNode() = 0; virtual void SetPopupNode(nsIDOMNode* aNode) = 0; + /** + * @param aForVisibleWindow true if caller needs controller which is + * associated with visible window. + */ virtual nsresult GetControllerForCommand(const char *aCommand, + bool aForVisibleWindow, nsIController** aResult) = 0; - virtual nsresult GetControllers(nsIControllers** aResult) = 0; + + /** + * @param aForVisibleWindow true if caller needs controllers which are + * associated with visible window. + */ + virtual nsresult GetControllers(bool aForVisibleWindow, + nsIControllers** aResult) = 0; virtual void GetEnabledDisabledCommands(nsTArray& aEnabledCommands, nsTArray& aDisabledCommands) = 0; diff --git a/dom/base/nsWindowRoot.cpp b/dom/base/nsWindowRoot.cpp index acd30b04cffd..05b57a60d1f9 100644 --- a/dom/base/nsWindowRoot.cpp +++ b/dom/base/nsWindowRoot.cpp @@ -207,7 +207,8 @@ nsWindowRoot::GetWindow() } nsresult -nsWindowRoot::GetControllers(nsIControllers** aResult) +nsWindowRoot::GetControllers(bool aForVisibleWindow, + nsIControllers** aResult) { *aResult = nullptr; @@ -215,9 +216,13 @@ nsWindowRoot::GetControllers(nsIControllers** aResult) // describes controllers, so this code would have no special // knowledge of what object might have controllers. + nsFocusManager::SearchRange searchRange = + aForVisibleWindow ? nsFocusManager::eIncludeVisibleDescendants : + nsFocusManager::eIncludeAllDescendants; nsCOMPtr focusedWindow; nsIContent* focusedContent = - nsFocusManager::GetFocusedDescendant(mWindow, true, getter_AddRefs(focusedWindow)); + nsFocusManager::GetFocusedDescendant(mWindow, searchRange, + getter_AddRefs(focusedWindow)); if (focusedContent) { #ifdef MOZ_XUL RefPtr xulElement = nsXULElement::FromContent(focusedContent); @@ -250,7 +255,8 @@ nsWindowRoot::GetControllers(nsIControllers** aResult) } nsresult -nsWindowRoot::GetControllerForCommand(const char * aCommand, +nsWindowRoot::GetControllerForCommand(const char* aCommand, + bool aForVisibleWindow, nsIController** _retval) { NS_ENSURE_ARG_POINTER(_retval); @@ -258,7 +264,7 @@ nsWindowRoot::GetControllerForCommand(const char * aCommand, { nsCOMPtr controllers; - GetControllers(getter_AddRefs(controllers)); + GetControllers(aForVisibleWindow, getter_AddRefs(controllers)); if (controllers) { nsCOMPtr controller; controllers->GetControllerForCommand(aCommand, getter_AddRefs(controller)); @@ -269,8 +275,12 @@ nsWindowRoot::GetControllerForCommand(const char * aCommand, } } + nsFocusManager::SearchRange searchRange = + aForVisibleWindow ? nsFocusManager::eIncludeVisibleDescendants : + nsFocusManager::eIncludeAllDescendants; nsCOMPtr focusedWindow; - nsFocusManager::GetFocusedDescendant(mWindow, true, getter_AddRefs(focusedWindow)); + nsFocusManager::GetFocusedDescendant(mWindow, searchRange, + getter_AddRefs(focusedWindow)); while (focusedWindow) { nsCOMPtr controllers; focusedWindow->GetControllers(getter_AddRefs(controllers)); @@ -340,14 +350,16 @@ nsWindowRoot::GetEnabledDisabledCommands(nsTArray& aEnabledCommands, nsTHashtable commandsHandled; nsCOMPtr controllers; - GetControllers(getter_AddRefs(controllers)); + GetControllers(false, getter_AddRefs(controllers)); if (controllers) { GetEnabledDisabledCommandsForControllers(controllers, commandsHandled, aEnabledCommands, aDisabledCommands); } nsCOMPtr focusedWindow; - nsFocusManager::GetFocusedDescendant(mWindow, true, getter_AddRefs(focusedWindow)); + nsFocusManager::GetFocusedDescendant(mWindow, + nsFocusManager::eIncludeAllDescendants, + getter_AddRefs(focusedWindow)); while (focusedWindow) { focusedWindow->GetControllers(getter_AddRefs(controllers)); if (controllers) { diff --git a/dom/base/nsWindowRoot.h b/dom/base/nsWindowRoot.h index 214f49d52331..850bf6d23873 100644 --- a/dom/base/nsWindowRoot.h +++ b/dom/base/nsWindowRoot.h @@ -43,8 +43,10 @@ public: virtual nsPIDOMWindowOuter* GetWindow() override; - virtual nsresult GetControllers(nsIControllers** aResult) override; + virtual nsresult GetControllers(bool aForVisibleWindow, + nsIControllers** aResult) override; virtual nsresult GetControllerForCommand(const char * aCommand, + bool aForVisibleWindow, nsIController** _retval) override; virtual void GetEnabledDisabledCommands(nsTArray& aEnabledCommands, diff --git a/dom/commandhandler/nsCommandManager.cpp b/dom/commandhandler/nsCommandManager.cpp index e43151ddc717..617735817d74 100644 --- a/dom/commandhandler/nsCommandManager.cpp +++ b/dom/commandhandler/nsCommandManager.cpp @@ -256,5 +256,6 @@ nsCommandManager::GetControllerForCommand(const char* aCommand, NS_ENSURE_TRUE(root, NS_ERROR_FAILURE); // no target window; send command to focus controller - return root->GetControllerForCommand(aCommand, aResult); + return root->GetControllerForCommand(aCommand, false /* for any window */, + aResult); } diff --git a/dom/events/ContentEventHandler.cpp b/dom/events/ContentEventHandler.cpp index be038ea78c4e..3dfc9bfbb67a 100644 --- a/dom/events/ContentEventHandler.cpp +++ b/dom/events/ContentEventHandler.cpp @@ -515,8 +515,10 @@ ContentEventHandler::GetFocusedContent() } nsCOMPtr window = doc->GetWindow(); nsCOMPtr focusedWindow; - return nsFocusManager::GetFocusedDescendant(window, true, - getter_AddRefs(focusedWindow)); + return nsFocusManager::GetFocusedDescendant( + window, + nsFocusManager::eIncludeAllDescendants, + getter_AddRefs(focusedWindow)); } bool diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index 834879cb534d..dc8990f9a638 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -5172,8 +5172,10 @@ EventStateManager::GetFocusedContent() return nullptr; nsCOMPtr focusedWindow; - return nsFocusManager::GetFocusedDescendant(mDocument->GetWindow(), false, - getter_AddRefs(focusedWindow)); + return nsFocusManager::GetFocusedDescendant( + mDocument->GetWindow(), + nsFocusManager::eOnlyCurrentWindow, + getter_AddRefs(focusedWindow)); } //------------------------------------------------------- @@ -5236,8 +5238,11 @@ EventStateManager::DoContentCommandEvent(WidgetContentCommandEvent* aEvent) default: return NS_ERROR_NOT_IMPLEMENTED; } + // If user tries to do something, user must try to do it in visible window. + // So, let's retrieve controller of visible window. nsCOMPtr controller; - nsresult rv = root->GetControllerForCommand(cmd, getter_AddRefs(controller)); + nsresult rv = root->GetControllerForCommand(cmd, true, + getter_AddRefs(controller)); NS_ENSURE_SUCCESS(rv, rv); if (!controller) { // When GetControllerForCommand succeeded but there is no controller, the diff --git a/dom/html/nsHTMLDocument.cpp b/dom/html/nsHTMLDocument.cpp index 5deb153bdbc1..be33b94adc77 100644 --- a/dom/html/nsHTMLDocument.cpp +++ b/dom/html/nsHTMLDocument.cpp @@ -2822,7 +2822,8 @@ nsHTMLDocument::EditingStateChanged() if (designMode) { nsCOMPtr focusedWindow; nsIContent* focusedContent = - nsFocusManager::GetFocusedDescendant(window, false, + nsFocusManager::GetFocusedDescendant(window, + nsFocusManager::eOnlyCurrentWindow, getter_AddRefs(focusedWindow)); if (focusedContent) { nsIFrame* focusedFrame = focusedContent->GetPrimaryFrame(); diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index efb5ca15f1d0..3a5d8f5216bf 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -1826,7 +1826,10 @@ ContentIsFocusedWithinWindow(nsIContent* aContent) } nsCOMPtr focusedFrame; - nsCOMPtr focusedContent = fm->GetFocusedDescendant(rootWindow, true, getter_AddRefs(focusedFrame)); + nsCOMPtr focusedContent = + nsFocusManager::GetFocusedDescendant(rootWindow, + nsFocusManager::eIncludeAllDescendants, + getter_AddRefs(focusedFrame)); return (focusedContent.get() == aContent); } diff --git a/dom/xbl/nsXBLPrototypeHandler.cpp b/dom/xbl/nsXBLPrototypeHandler.cpp index 51b30b428a34..99db6b67e722 100644 --- a/dom/xbl/nsXBLPrototypeHandler.cpp +++ b/dom/xbl/nsXBLPrototypeHandler.cpp @@ -516,10 +516,14 @@ nsXBLPrototypeHandler::DispatchXBLCommand(EventTarget* aTarget, nsIDOMEvent* aEv } NS_LossyConvertUTF16toASCII command(mHandlerText); - if (windowRoot) - windowRoot->GetControllerForCommand(command.get(), getter_AddRefs(controller)); - else + if (windowRoot) { + // If user tries to do something, user must try to do it in visible window. + // So, let's retrieve controller of visible window. + windowRoot->GetControllerForCommand(command.get(), true, + getter_AddRefs(controller)); + } else { controller = GetController(aTarget); // We're attached to the receiver possibly. + } // We are the default action for this command. // Stop any other default action from executing. @@ -541,7 +545,10 @@ nsXBLPrototypeHandler::DispatchXBLCommand(EventTarget* aTarget, nsIDOMEvent* aEv if (windowToCheck) { nsCOMPtr focusedWindow; focusedContent = - nsFocusManager::GetFocusedDescendant(windowToCheck, true, getter_AddRefs(focusedWindow)); + nsFocusManager::GetFocusedDescendant( + windowToCheck, + nsFocusManager::eIncludeAllDescendants, + getter_AddRefs(focusedWindow)); } // If the focus is in an editable region, don't scroll. diff --git a/dom/xul/nsXULCommandDispatcher.cpp b/dom/xul/nsXULCommandDispatcher.cpp index fc05f644009a..f85dd27cb04a 100644 --- a/dom/xul/nsXULCommandDispatcher.cpp +++ b/dom/xul/nsXULCommandDispatcher.cpp @@ -110,7 +110,10 @@ nsXULCommandDispatcher::GetRootFocusedContentAndWindow(nsPIDOMWindowOuter** aWin if (nsCOMPtr win = mDocument->GetWindow()) { if (nsCOMPtr rootWindow = win->GetPrivateRoot()) { - return nsFocusManager::GetFocusedDescendant(rootWindow, true, aWindow); + return nsFocusManager::GetFocusedDescendant( + rootWindow, + nsFocusManager::eIncludeAllDescendants, + aWindow); } } @@ -438,7 +441,7 @@ nsXULCommandDispatcher::GetControllers(nsIControllers** aResult) nsCOMPtr root = GetWindowRoot(); NS_ENSURE_TRUE(root, NS_ERROR_FAILURE); - return root->GetControllers(aResult); + return root->GetControllers(false /* for any window */, aResult); } NS_IMETHODIMP @@ -447,7 +450,8 @@ nsXULCommandDispatcher::GetControllerForCommand(const char *aCommand, nsIControl nsCOMPtr root = GetWindowRoot(); NS_ENSURE_TRUE(root, NS_ERROR_FAILURE); - return root->GetControllerForCommand(aCommand, _retval); + return root->GetControllerForCommand(aCommand, false /* for any window */, + _retval); } NS_IMETHODIMP diff --git a/editor/libeditor/EditorBase.cpp b/editor/libeditor/EditorBase.cpp index d56059d75663..5bd150521d6a 100644 --- a/editor/libeditor/EditorBase.cpp +++ b/editor/libeditor/EditorBase.cpp @@ -5210,7 +5210,8 @@ EditorBase::IsActiveInDOMWindow() nsPIDOMWindowOuter* ourWindow = document->GetWindow(); nsCOMPtr win; nsIContent* content = - nsFocusManager::GetFocusedDescendant(ourWindow, false, + nsFocusManager::GetFocusedDescendant(ourWindow, + nsFocusManager::eOnlyCurrentWindow, getter_AddRefs(win)); return SameCOMIdentity(content, piTarget); } diff --git a/editor/libeditor/EditorEventListener.cpp b/editor/libeditor/EditorEventListener.cpp index 8b05b8c7bc32..45495a1eb0ed 100644 --- a/editor/libeditor/EditorEventListener.cpp +++ b/editor/libeditor/EditorEventListener.cpp @@ -81,7 +81,8 @@ DoCommandCallback(Command aCommand, void* aData) const char* commandStr = WidgetKeyboardEvent::GetCommandStr(aCommand); nsCOMPtr controller; - root->GetControllerForCommand(commandStr, getter_AddRefs(controller)); + root->GetControllerForCommand(commandStr, false /* for any window */, + getter_AddRefs(controller)); if (!controller) { return; } diff --git a/editor/libeditor/HTMLEditor.cpp b/editor/libeditor/HTMLEditor.cpp index fd1736c32819..63a686d949d5 100644 --- a/editor/libeditor/HTMLEditor.cpp +++ b/editor/libeditor/HTMLEditor.cpp @@ -4919,7 +4919,8 @@ HTMLEditor::IsActiveInDOMWindow() nsPIDOMWindowOuter* ourWindow = document->GetWindow(); nsCOMPtr win; nsIContent* content = - nsFocusManager::GetFocusedDescendant(ourWindow, false, + nsFocusManager::GetFocusedDescendant(ourWindow, + nsFocusManager::eOnlyCurrentWindow, getter_AddRefs(win)); if (!content) { return false; diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index 9ff0540899fe..a22a2bfa074d 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -1634,7 +1634,8 @@ PresShell::GetSelectionControllerForFocusedContent(nsIContent** aFocusedContent) if (mDocument) { nsCOMPtr focusedWindow; nsCOMPtr focusedContent = - nsFocusManager::GetFocusedDescendant(mDocument->GetWindow(), false, + nsFocusManager::GetFocusedDescendant(mDocument->GetWindow(), + nsFocusManager::eOnlyCurrentWindow, getter_AddRefs(focusedWindow)); if (focusedContent) { nsIFrame* frame = focusedContent->GetPrimaryFrame(); @@ -6795,7 +6796,8 @@ PresShell::GetFocusedDOMWindowInOurWindow() nsCOMPtr rootWindow = GetRootWindow(); NS_ENSURE_TRUE(rootWindow, nullptr); nsCOMPtr focusedWindow; - nsFocusManager::GetFocusedDescendant(rootWindow, true, + nsFocusManager::GetFocusedDescendant(rootWindow, + nsFocusManager::eIncludeAllDescendants, getter_AddRefs(focusedWindow)); return focusedWindow.forget(); } @@ -7798,7 +7800,8 @@ PresShell::HandleEvent(nsIFrame* aFrame, nsCOMPtr window = mDocument->GetWindow(); nsCOMPtr focusedWindow; nsCOMPtr eventTarget = - nsFocusManager::GetFocusedDescendant(window, false, + nsFocusManager::GetFocusedDescendant(window, + nsFocusManager::eOnlyCurrentWindow, getter_AddRefs(focusedWindow)); // otherwise, if there is no focused content or the focused content has diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp index 24c99b850aff..9ffe6b9e5e8a 100644 --- a/layout/printing/nsPrintEngine.cpp +++ b/layout/printing/nsPrintEngine.cpp @@ -3193,7 +3193,8 @@ nsPrintEngine::FindFocusedDOMWindow() NS_ENSURE_TRUE(rootWindow, nullptr); nsCOMPtr focusedWindow; - nsFocusManager::GetFocusedDescendant(rootWindow, true, + nsFocusManager::GetFocusedDescendant(rootWindow, + nsFocusManager::eIncludeAllDescendants, getter_AddRefs(focusedWindow)); NS_ENSURE_TRUE(focusedWindow, nullptr); diff --git a/toolkit/components/find/nsWebBrowserFind.cpp b/toolkit/components/find/nsWebBrowserFind.cpp index 08dc3a437dfe..6a2b850bd9b7 100644 --- a/toolkit/components/find/nsWebBrowserFind.cpp +++ b/toolkit/components/find/nsWebBrowserFind.cpp @@ -798,8 +798,10 @@ nsWebBrowserFind::GetFrameSelection(nsPIDOMWindowOuter* aWindow) nsPresContext* presContext = presShell->GetPresContext(); nsCOMPtr focusedWindow; - nsCOMPtr focusedContent = nsFocusManager::GetFocusedDescendant( - aWindow, false, getter_AddRefs(focusedWindow)); + nsCOMPtr focusedContent = + nsFocusManager::GetFocusedDescendant(aWindow, + nsFocusManager::eOnlyCurrentWindow, + getter_AddRefs(focusedWindow)); nsIFrame* frame = focusedContent ? focusedContent->GetPrimaryFrame() : nullptr;