Commit 3782f076 authored by Wes Kocher's avatar Wes Kocher
Browse files

Merge m-c to autoland, a=merge CLOSED TREE

 UPGRADE_NSS_RELEASE UPGRADE_NSPR_RELEASE
MozReview-Commit-ID: 9AadPvosTet

--HG--
extra : amend_source : 5de33acae6003b4eb8fb3492b38b2856419e29ad
parents aa9f5488 bb1d0618
Loading
Loading
Loading
Loading
+24 −1
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
#include "nsFocusManager.h"
#include "mozilla/EventStateManager.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/TabParent.h"

namespace mozilla {
namespace a11y {
@@ -190,13 +191,35 @@ FocusManager::ActiveItemChanged(Accessible* aItem, bool aCheckIfActive)
  }
  mActiveItem = aItem;

  // If mActiveItem is null, we might need to shift a11y focus to a remote
  // element.
  if (!mActiveItem && XRE_IsParentProcess()) {
    nsFocusManager* domfm = nsFocusManager::GetFocusManager();
    if (domfm) {
      nsIContent* focusedElm = domfm->GetFocusedContent();
      if (focusedElm) {
        bool remote = EventStateManager::IsRemoteTarget(focusedElm);
        if (remote) {
          dom::TabParent* tab = dom::TabParent::GetFrom(focusedElm);
          if (tab) {
            a11y::DocAccessibleParent* dap = tab->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();
  if (target)
  if (target) {
    DispatchFocusEvent(target->Document(), target);
  }
}

void
FocusManager::ForceFocusEvent()
+8 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@

#include "DocAccessibleChild.h"

#include "nsAccessibilityService.h"
#include "Accessible-inl.h"
#include "ProxyAccessible.h"
#include "Relation.h"
@@ -2003,5 +2004,12 @@ DocAccessibleChild::RecvDOMNodeID(const uint64_t& aID, nsString* aDOMNodeID)
  return IPC_OK();
}

mozilla::ipc::IPCResult
DocAccessibleChild::RecvRestoreFocus()
{
  FocusMgr()->ForceFocusEvent();
  return IPC_OK();
}

}
}
+2 −0
Original line number Diff line number Diff line
@@ -38,6 +38,8 @@ public:
    MOZ_COUNT_DTOR_INHERITED(DocAccessibleChild, DocAccessibleChildBase);
  }

  virtual mozilla::ipc::IPCResult RecvRestoreFocus() override;

  /*
   * Return the state for the accessible with given ID.
   */
+6 −0
Original line number Diff line number Diff line
@@ -73,6 +73,12 @@ parent:
child:
  async __delete__();

  /*
   * Called as a result of focus shifting from chrome to content
   * elements through keyboard navigation.
   */
  async RestoreFocus();

  // Accessible
  nested(inside_sync) sync State(uint64_t aID) returns(uint64_t states);
  nested(inside_sync) sync NativeState(uint64_t aID) returns(uint64_t states);
+8 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@

#include "DocAccessibleChild.h"

#include "nsAccessibilityService.h"
#include "Accessible-inl.h"
#include "mozilla/a11y/PlatformChild.h"
#include "mozilla/ClearOnShutdown.h"
@@ -307,6 +308,13 @@ DocAccessibleChild::SendBindChildDoc(DocAccessibleChild* aChildDoc,
  return true;
}

ipc::IPCResult
DocAccessibleChild::RecvRestoreFocus()
{
  FocusMgr()->ForceFocusEvent();
  return IPC_OK();
}

} // namespace a11y
} // namespace mozilla
Loading