Bug 1369072 - part3: nsXBLPrototypeHandler::DispatchXBLCommand() should use controller of visible window r=smaug

With previous change, KeyboardEvent is dispatched even when invisible window
has focus.  However, nsRootWindow::GetControllerForCommand() returns controller
for focused window even when the window is invisible because it uses
nsFocusManager::GetFocusedDescendant() to retrieve focused window.

Perhaps, we can assume that users won't expect to do something with invisible
window when they type some keys.  Then, nsRootWindow::GetControllerForCommand()
should return controller for visible ancestor window if focused window is
invisible.

This patch makes nsFocusManager::GetFocusedDescendant() can return only visible
descendants.  However, it already has a bool argument.  Therefore, it should
have a flag instead of adding new flag.  Most changes of this patch is replacing
its callers.

Then, nsRootWindow::GetControllerForCommand() and nsRootWindow::GetControllers()
should have a bool flag if it should return controller(s) for visible window.
This patch adds a bool flag for it.  Fortunately, the interface isn't scriptable.

Finally, this patch makes nsXBLPrototypeHandler::DispatchXBLCommand() and
EventStateManager::DoContentCommandEvent() retrieve controller for visible
window since they are always handles user input.

MozReview-Commit-ID: GygttTHuKRm

--HG--
extra : rebase_source : 1341273c4606298cb9b890b9312d9f5c8a75d144
This commit is contained in:
Masayuki Nakano 2017-09-07 22:54:49 +09:00
Родитель e4c9fce848
Коммит 4ce89d8f61
22 изменённых файлов: 152 добавлений и 48 удалений

Просмотреть файл

@ -13678,7 +13678,8 @@ nsDocShell::EnsureFind()
// default to our window
nsCOMPtr<nsPIDOMWindowOuter> ourWindow = do_QueryInterface(scriptGO);
nsCOMPtr<nsPIDOMWindowOuter> windowToSearch;
nsFocusManager::GetFocusedDescendant(ourWindow, true,
nsFocusManager::GetFocusedDescendant(ourWindow,
nsFocusManager::eIncludeAllDescendants,
getter_AddRefs(windowToSearch));
nsCOMPtr<nsIWebBrowserFindInFrames> findInFrames = do_QueryInterface(mFind);
@ -13993,7 +13994,8 @@ nsDocShell::GetControllerForCommand(const char* aCommand,
nsCOMPtr<nsPIWindowRoot> 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

Просмотреть файл

@ -2158,7 +2158,9 @@ Element::ShouldBlur(nsIContent *aContent)
nsCOMPtr<nsPIDOMWindowOuter> focusedFrame;
nsIContent* contentToBlur =
nsFocusManager::GetFocusedDescendant(window, false, getter_AddRefs(focusedFrame));
nsFocusManager::GetFocusedDescendant(window,
nsFocusManager::eOnlyCurrentWindow,
getter_AddRefs(focusedFrame));
if (contentToBlur == aContent)
return true;

Просмотреть файл

@ -3832,7 +3832,9 @@ Selection::NotifySelectionListeners()
nsFocusManager* fm = nsFocusManager::GetFocusManager();
nsCOMPtr<nsPIDOMWindowOuter> focusedWindow;
nsIContent* focusedContent =
fm->GetFocusedDescendant(window, false, getter_AddRefs(focusedWindow));
nsFocusManager::GetFocusedDescendant(window,
nsFocusManager::eOnlyCurrentWindow,
getter_AddRefs(focusedWindow));
nsCOMPtr<Element> 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

Просмотреть файл

@ -3604,7 +3604,8 @@ nsIDocument::GetActiveElement()
if (nsCOMPtr<nsPIDOMWindowOuter> window = GetWindow()) {
nsCOMPtr<nsPIDOMWindowOuter> 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) {

Просмотреть файл

@ -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<nsPIDOMWindowOuter> focusedWindow;
nsCOMPtr<nsIContent> 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<nsPIDOMWindowOuter> currentWindow;
nsCOMPtr<nsIContent> 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<nsPIDOMWindowOuter> currentWindow;
nsCOMPtr<nsIContent> 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<nsPIDOMWindowOuter> newWindow;
nsCOMPtr<nsPIDOMWindowOuter> 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<nsPIDOMWindowOuter> 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<nsPIDOMWindowOuter> 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,

Просмотреть файл

@ -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);
/**

Просмотреть файл

@ -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<nsCString>& aEnabledCommands,
nsTArray<nsCString>& aDisabledCommands) = 0;

Просмотреть файл

@ -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<nsPIDOMWindowOuter> focusedWindow;
nsIContent* focusedContent =
nsFocusManager::GetFocusedDescendant(mWindow, true, getter_AddRefs(focusedWindow));
nsFocusManager::GetFocusedDescendant(mWindow, searchRange,
getter_AddRefs(focusedWindow));
if (focusedContent) {
#ifdef MOZ_XUL
RefPtr<nsXULElement> 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<nsIControllers> controllers;
GetControllers(getter_AddRefs(controllers));
GetControllers(aForVisibleWindow, getter_AddRefs(controllers));
if (controllers) {
nsCOMPtr<nsIController> 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<nsPIDOMWindowOuter> focusedWindow;
nsFocusManager::GetFocusedDescendant(mWindow, true, getter_AddRefs(focusedWindow));
nsFocusManager::GetFocusedDescendant(mWindow, searchRange,
getter_AddRefs(focusedWindow));
while (focusedWindow) {
nsCOMPtr<nsIControllers> controllers;
focusedWindow->GetControllers(getter_AddRefs(controllers));
@ -340,14 +350,16 @@ nsWindowRoot::GetEnabledDisabledCommands(nsTArray<nsCString>& aEnabledCommands,
nsTHashtable<nsCharPtrHashKey> commandsHandled;
nsCOMPtr<nsIControllers> controllers;
GetControllers(getter_AddRefs(controllers));
GetControllers(false, getter_AddRefs(controllers));
if (controllers) {
GetEnabledDisabledCommandsForControllers(controllers, commandsHandled,
aEnabledCommands, aDisabledCommands);
}
nsCOMPtr<nsPIDOMWindowOuter> 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) {

Просмотреть файл

@ -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<nsCString>& aEnabledCommands,

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -515,8 +515,10 @@ ContentEventHandler::GetFocusedContent()
}
nsCOMPtr<nsPIDOMWindowOuter> window = doc->GetWindow();
nsCOMPtr<nsPIDOMWindowOuter> focusedWindow;
return nsFocusManager::GetFocusedDescendant(window, true,
getter_AddRefs(focusedWindow));
return nsFocusManager::GetFocusedDescendant(
window,
nsFocusManager::eIncludeAllDescendants,
getter_AddRefs(focusedWindow));
}
bool

Просмотреть файл

@ -5172,8 +5172,10 @@ EventStateManager::GetFocusedContent()
return nullptr;
nsCOMPtr<nsPIDOMWindowOuter> 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<nsIController> 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

Просмотреть файл

@ -2822,7 +2822,8 @@ nsHTMLDocument::EditingStateChanged()
if (designMode) {
nsCOMPtr<nsPIDOMWindowOuter> focusedWindow;
nsIContent* focusedContent =
nsFocusManager::GetFocusedDescendant(window, false,
nsFocusManager::GetFocusedDescendant(window,
nsFocusManager::eOnlyCurrentWindow,
getter_AddRefs(focusedWindow));
if (focusedContent) {
nsIFrame* focusedFrame = focusedContent->GetPrimaryFrame();

Просмотреть файл

@ -1826,7 +1826,10 @@ ContentIsFocusedWithinWindow(nsIContent* aContent)
}
nsCOMPtr<nsPIDOMWindowOuter> focusedFrame;
nsCOMPtr<nsIContent> focusedContent = fm->GetFocusedDescendant(rootWindow, true, getter_AddRefs(focusedFrame));
nsCOMPtr<nsIContent> focusedContent =
nsFocusManager::GetFocusedDescendant(rootWindow,
nsFocusManager::eIncludeAllDescendants,
getter_AddRefs(focusedFrame));
return (focusedContent.get() == aContent);
}

Просмотреть файл

@ -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<nsPIDOMWindowOuter> 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.

Просмотреть файл

@ -110,7 +110,10 @@ nsXULCommandDispatcher::GetRootFocusedContentAndWindow(nsPIDOMWindowOuter** aWin
if (nsCOMPtr<nsPIDOMWindowOuter> win = mDocument->GetWindow()) {
if (nsCOMPtr<nsPIDOMWindowOuter> 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<nsPIWindowRoot> 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<nsPIWindowRoot> 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

Просмотреть файл

@ -5210,7 +5210,8 @@ EditorBase::IsActiveInDOMWindow()
nsPIDOMWindowOuter* ourWindow = document->GetWindow();
nsCOMPtr<nsPIDOMWindowOuter> win;
nsIContent* content =
nsFocusManager::GetFocusedDescendant(ourWindow, false,
nsFocusManager::GetFocusedDescendant(ourWindow,
nsFocusManager::eOnlyCurrentWindow,
getter_AddRefs(win));
return SameCOMIdentity(content, piTarget);
}

Просмотреть файл

@ -81,7 +81,8 @@ DoCommandCallback(Command aCommand, void* aData)
const char* commandStr = WidgetKeyboardEvent::GetCommandStr(aCommand);
nsCOMPtr<nsIController> controller;
root->GetControllerForCommand(commandStr, getter_AddRefs(controller));
root->GetControllerForCommand(commandStr, false /* for any window */,
getter_AddRefs(controller));
if (!controller) {
return;
}

Просмотреть файл

@ -4919,7 +4919,8 @@ HTMLEditor::IsActiveInDOMWindow()
nsPIDOMWindowOuter* ourWindow = document->GetWindow();
nsCOMPtr<nsPIDOMWindowOuter> win;
nsIContent* content =
nsFocusManager::GetFocusedDescendant(ourWindow, false,
nsFocusManager::GetFocusedDescendant(ourWindow,
nsFocusManager::eOnlyCurrentWindow,
getter_AddRefs(win));
if (!content) {
return false;

Просмотреть файл

@ -1634,7 +1634,8 @@ PresShell::GetSelectionControllerForFocusedContent(nsIContent** aFocusedContent)
if (mDocument) {
nsCOMPtr<nsPIDOMWindowOuter> focusedWindow;
nsCOMPtr<nsIContent> 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<nsPIDOMWindowOuter> rootWindow = GetRootWindow();
NS_ENSURE_TRUE(rootWindow, nullptr);
nsCOMPtr<nsPIDOMWindowOuter> 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<nsPIDOMWindowOuter> window = mDocument->GetWindow();
nsCOMPtr<nsPIDOMWindowOuter> focusedWindow;
nsCOMPtr<nsIContent> 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

Просмотреть файл

@ -3193,7 +3193,8 @@ nsPrintEngine::FindFocusedDOMWindow()
NS_ENSURE_TRUE(rootWindow, nullptr);
nsCOMPtr<nsPIDOMWindowOuter> focusedWindow;
nsFocusManager::GetFocusedDescendant(rootWindow, true,
nsFocusManager::GetFocusedDescendant(rootWindow,
nsFocusManager::eIncludeAllDescendants,
getter_AddRefs(focusedWindow));
NS_ENSURE_TRUE(focusedWindow, nullptr);

Просмотреть файл

@ -798,8 +798,10 @@ nsWebBrowserFind::GetFrameSelection(nsPIDOMWindowOuter* aWindow)
nsPresContext* presContext = presShell->GetPresContext();
nsCOMPtr<nsPIDOMWindowOuter> focusedWindow;
nsCOMPtr<nsIContent> focusedContent = nsFocusManager::GetFocusedDescendant(
aWindow, false, getter_AddRefs(focusedWindow));
nsCOMPtr<nsIContent> focusedContent =
nsFocusManager::GetFocusedDescendant(aWindow,
nsFocusManager::eOnlyCurrentWindow,
getter_AddRefs(focusedWindow));
nsIFrame* frame =
focusedContent ? focusedContent->GetPrimaryFrame() : nullptr;