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
authorJames Teh <jteh@mozilla.com>
Wed, 13 Nov 2019 16:01:02 +0000
changeset 501852 597cb65dad667703d23017c879e5b7628015bbb0
parent 501851 a01e42ada2cdf66cae108e9ef16f3ed2890142e9
child 501853 4264dbdf0850c10c6f36806461126c52bd9b74f9
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyzen
bugs1594337
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
accessible/base/FocusManager.cpp
--- a/accessible/base/FocusManager.cpp
+++ b/accessible/base/FocusManager.cpp
@@ -167,31 +167,25 @@ void FocusManager::ActiveItemChanged(Acc
 #ifdef A11Y_LOG
     if (logging::IsEnabled(logging::eFocus)) logging::ActiveWidget(widget);
 #endif
     if (!widget || !widget->IsActiveWidget() || !widget->AreItemsOperable())
       return;
   }
   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();
       }
     }
   }
 
   // If active item is changed then fire accessible focus event on it, otherwise
   // if there's no an active item then fire focus event to accessible having
   // DOM focus.
   Accessible* target = FocusedAccessible();