Bug 1594337: When dismissing a pop-up or the menu bar, if focus is inside an OOP iframe, restore a11y focus inside the iframe. r=yzen

Previously, we only restored focus within the top level remote browser.
This is fine for remote documents without iframes or only in-process iframes, as was the case with e10s.
For Fission, if an OOP iframe has focus, we need to get the appropriate nested remote browser.
Fortunately, BrowserParent::GetFocused was introduced to do exactly this.

Differential Revision: https://phabricator.services.mozilla.com/D52803

--HG--
extra : moz-landing-system : lando
This commit is contained in:
James Teh 2019-11-13 16:01:02 +00:00
Родитель d33d08e09e
Коммит f6c5c02224
1 изменённых файлов: 6 добавлений и 12 удалений

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

@ -172,21 +172,15 @@ void FocusManager::ActiveItemChanged(Accessible* aItem, bool aCheckIfActive) {
}
mActiveItem = aItem;
// If mActiveItem is null we may need to shift a11y focus back to a tab
// If mActiveItem is null we may need to shift a11y focus back to a remote
// document. For example, when combobox popup is closed, then
// the focus should be moved back to the combobox.
if (!mActiveItem && XRE_IsParentProcess()) {
nsFocusManager* domfm = nsFocusManager::GetFocusManager();
if (domfm) {
nsIContent* focusedElm = domfm->GetFocusedElement();
if (EventStateManager::IsRemoteTarget(focusedElm)) {
dom::BrowserParent* tab = dom::BrowserParent::GetFrom(focusedElm);
if (tab) {
a11y::DocAccessibleParent* dap = tab->GetTopLevelDocAccessible();
if (dap) {
Unused << dap->SendRestoreFocus();
}
}
dom::BrowserParent* browser = dom::BrowserParent::GetFocused();
if (browser) {
a11y::DocAccessibleParent* dap = browser->GetTopLevelDocAccessible();
if (dap) {
Unused << dap->SendRestoreFocus();
}
}
}