Backed out changeset 0a9ecb630db6 (bug 1234121) for Marionette-e10s crashes on Linux in test_accessibility.py TestAccessibility.test_click_raises_no_exceptions. r=backout on a CLOSED TREE
authorSebastian Hengst <archaeopteryx@coole-files.de>
Thu, 07 Apr 2016 14:17:13 +0200
changeset 330088 0c5141a1d8d9c8e7892960fd264fd9f0f100c510
parent 330087 e17e914479ba7db1e948f0091dc9ce3a74b858fe
child 330089 c16ab55f03240fb6d6b9d35a7ad4c9fbc06d6789
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1234121
milestone48.0a1
backs out0a9ecb630db6c87f29af6880c70a151d0bf2c5ca
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
Backed out changeset 0a9ecb630db6 (bug 1234121) for Marionette-e10s crashes on Linux in test_accessibility.py TestAccessibility.test_click_raises_no_exceptions. r=backout on a CLOSED TREE
accessible/base/FocusManager.cpp
accessible/base/FocusManager.h
accessible/ipc/DocAccessibleChild.cpp
accessible/ipc/DocAccessibleChild.h
accessible/ipc/DocAccessibleParent.cpp
accessible/ipc/PDocAccessible.ipdl
accessible/ipc/ProxyAccessible.cpp
--- a/accessible/base/FocusManager.cpp
+++ b/accessible/base/FocusManager.cpp
@@ -22,16 +22,56 @@ namespace a11y {
 FocusManager::FocusManager()
 {
 }
 
 FocusManager::~FocusManager()
 {
 }
 
+Accessible*
+FocusManager::FocusedAccessible() const
+{
+  if (mActiveItem)
+    return mActiveItem;
+
+  nsINode* focusedNode = FocusedDOMNode();
+  if (focusedNode) {
+    DocAccessible* doc = 
+      GetAccService()->GetDocAccessible(focusedNode->OwnerDoc());
+    return doc ? doc->GetAccessibleEvenIfNotInMapOrContainer(focusedNode) : nullptr;
+  }
+
+  return nullptr;
+}
+
+bool
+FocusManager::IsFocused(const Accessible* aAccessible) const
+{
+  if (mActiveItem)
+    return mActiveItem == aAccessible;
+
+  nsINode* focusedNode = FocusedDOMNode();
+  if (focusedNode) {
+    // XXX: Before getting an accessible for node having a DOM focus make sure
+    // they belong to the same document because it can trigger unwanted document
+    // accessible creation for temporary about:blank document. Without this
+    // peculiarity we would end up with plain implementation based on
+    // FocusedAccessible() method call. Make sure this issue is fixed in
+    // bug 638465.
+    if (focusedNode->OwnerDoc() == aAccessible->GetNode()->OwnerDoc()) {
+      DocAccessible* doc = 
+        GetAccService()->GetDocAccessible(focusedNode->OwnerDoc());
+      return aAccessible ==
+        (doc ? doc->GetAccessibleEvenIfNotInMapOrContainer(focusedNode) : nullptr);
+    }
+  }
+  return false;
+}
+
 bool
 FocusManager::IsFocusWithin(const Accessible* aContainer) const
 {
   Accessible* child = FocusedAccessible();
   while (child) {
     if (child == aContainer)
       return true;
 
@@ -148,33 +188,19 @@ FocusManager::ActiveItemChanged(Accessib
     if (!widget || !widget->IsActiveWidget() || !widget->AreItemsOperable())
       return;
   }
   mActiveItem = aItem;
 
   // 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 = nullptr;
-  if (aItem) {
-    target = aItem;
-  } else {
-    nsINode* focusedNode = FocusedDOMNode();
-    if (focusedNode) {
-      DocAccessible* doc =
-        GetAccService()->GetDocAccessible(focusedNode->OwnerDoc());
-      if (doc) {
-        target = doc->GetAccessibleEvenIfNotInMapOrContainer(focusedNode);
-      }
-    }
-  }
-
-  if (target) {
+  Accessible* target = FocusedAccessible();
+  if (target)
     DispatchFocusEvent(target->Document(), target);
-  }
 }
 
 void
 FocusManager::ForceFocusEvent()
 {
   nsINode* focusedNode = FocusedDOMNode();
   if (focusedNode) {
     DocAccessible* document =
@@ -265,19 +291,16 @@ FocusManager::ProcessFocusEvent(AccEvent
 
     Accessible* activeItem = target->CurrentItem();
     if (activeItem) {
       mActiveItem = activeItem;
       target = activeItem;
     }
   }
 
-  mFocusedAcc = target;
-  mFocusedProxy = nullptr;
-
   // Fire menu start/end events for ARIA menus.
   if (target->IsARIARole(nsGkAtoms::menuitem)) {
     // The focus was moved into menu.
     Accessible* ARIAMenubar = nullptr;
     for (Accessible* parent = target->Parent(); parent; parent = parent->Parent()) {
       if (parent->IsARIARole(nsGkAtoms::menubar)) {
         ARIAMenubar = parent;
         break;
--- a/accessible/base/FocusManager.h
+++ b/accessible/base/FocusManager.h
@@ -11,42 +11,36 @@ class nsINode;
 class nsIDocument;
 class nsISupports;
 
 namespace mozilla {
 namespace a11y {
 
 class AccEvent;
 class Accessible;
-class ProxyAccessible;
 class DocAccessible;
 
 /**
  * Manage the accessible focus. Used to fire and process accessible events.
  */
 class FocusManager
 {
 public:
   virtual ~FocusManager();
 
   /**
    * Return a focused accessible.
    */
-  Accessible* FocusedAccessible() const { return mFocusedAcc; }
-
-  /**
-   * Return remote focused accessible.
-   */
-  ProxyAccessible* FocusedRemoteAccessible() const { return mFocusedProxy; }
+  Accessible* FocusedAccessible() const;
 
   /**
    * Return true if given accessible is focused.
    */
-  bool IsFocused(const Accessible* aAccessible) const
-    { return aAccessible == mFocusedAcc; }
+  bool IsFocused(const Accessible* aAccessible) const;
+
   /**
    * Return true if the given accessible is an active item, i.e. an item that
    * is current within the active widget.
    */
   inline bool IsActiveItem(const Accessible* aAccessible)
     { return aAccessible == mActiveItem; }
 
   /**
@@ -87,21 +81,16 @@ public:
 
   /**
    * Called when active item is changed. Note: must be called when accessible
    * tree is up to date.
    */
   void ActiveItemChanged(Accessible* aItem, bool aCheckIfActive = true);
 
   /**
-   * Called when focused item in child process is changed.
-   */
-  void RemoteFocusChanged(ProxyAccessible* aProxy) { mFocusedProxy = aProxy; }
-
-  /**
    * Dispatch delayed focus event for the current focus accessible.
    */
   void ForceFocusEvent();
 
   /**
    * Dispatch delayed focus event for the given target.
    */
   void DispatchFocusEvent(DocAccessible* aDocument, Accessible* aTarget);
@@ -130,18 +119,16 @@ private:
   nsINode* FocusedDOMNode() const;
 
   /**
    * Return DOM document having DOM focus.
    */
   nsIDocument* FocusedDOMDocument() const;
 
 private:
-  RefPtr<Accessible> mFocusedAcc;
-  ProxyAccessible* mFocusedProxy;
   RefPtr<Accessible> mActiveItem;
   RefPtr<Accessible> mActiveARIAMenubar;
 };
 
 } // namespace a11y
 } // namespace mozilla
 
 #endif
--- a/accessible/ipc/DocAccessibleChild.cpp
+++ b/accessible/ipc/DocAccessibleChild.cpp
@@ -1884,16 +1884,34 @@ DocAccessibleChild::RecvEmbeddedChildAt(
   if (!acc)
     return true;
 
   *aChildID = reinterpret_cast<uintptr_t>(acc->GetEmbeddedChildAt(aIdx));
   return true;
 }
 
 bool
+DocAccessibleChild::RecvFocusedChild(const uint64_t& aID,
+                                       uint64_t* aChild,
+                                       bool* aOk)
+{
+  *aChild = 0;
+  *aOk = false;
+  Accessible* acc = IdToAccessible(aID);
+  if (acc) {
+    Accessible* child = acc->FocusedChild();
+    if (child) {
+      *aChild = reinterpret_cast<uint64_t>(child->UniqueID());
+      *aOk = true;
+    }
+  }
+  return true;
+}
+
+bool
 DocAccessibleChild::RecvLanguage(const uint64_t& aID,
                                  nsString* aLocale)
 {
   Accessible* acc = IdToAccessible(aID);
   if (acc) {
     acc->Language(*aLocale);
   }
 
--- a/accessible/ipc/DocAccessibleChild.h
+++ b/accessible/ipc/DocAccessibleChild.h
@@ -459,16 +459,20 @@ public:
 
   virtual bool RecvIndexOfEmbeddedChild(const uint64_t& aID,
                                         const uint64_t& aChildID,
                                         uint32_t* aChildIdx) override final;
 
   virtual bool RecvEmbeddedChildAt(const uint64_t& aID, const uint32_t& aIdx,
                                    uint64_t* aChildID) override final;
 
+  virtual bool RecvFocusedChild(const uint64_t& aID,
+                                uint64_t* aChild,
+                                bool* aOk) override;
+
   virtual bool RecvLanguage(const uint64_t& aID, nsString* aLocale) override;
   virtual bool RecvDocType(const uint64_t& aID, nsString* aType) override;
   virtual bool RecvTitle(const uint64_t& aID, nsString* aTitle) override;
   virtual bool RecvURL(const uint64_t& aID, nsString* aURL) override;
   virtual bool RecvMimeType(const uint64_t& aID, nsString* aMime) override;
   virtual bool RecvURLDocTypeMimeType(const uint64_t& aID,
                                       nsString* aURL,
                                       nsString* aDocType,
--- a/accessible/ipc/DocAccessibleParent.cpp
+++ b/accessible/ipc/DocAccessibleParent.cpp
@@ -142,24 +142,16 @@ bool
 DocAccessibleParent::RecvEvent(const uint64_t& aID, const uint32_t& aEventType)
 {
   ProxyAccessible* proxy = GetAccessible(aID);
   if (!proxy) {
     NS_ERROR("no proxy for event!");
     return true;
   }
 
-  switch(aEventType) {
-      case nsIAccessibleEvent::EVENT_FOCUS:
-          FocusMgr()->RemoteFocusChanged(proxy);
-          break;
-      default:
-        break;
-  }
-
   ProxyEvent(proxy, aEventType);
 
   if (!nsCoreUtils::AccEventObserversExist()) {
     return true;
   }
 
   xpcAccessibleGeneric* xpcAcc = GetXPCAccessible(proxy);
   xpcAccessibleDocument* doc = GetAccService()->GetXPCDocument(this);
--- a/accessible/ipc/PDocAccessible.ipdl
+++ b/accessible/ipc/PDocAccessible.ipdl
@@ -237,16 +237,18 @@ child:
   prio(high) sync Step(uint64_t aID) returns(double aStep);
 
   async TakeFocus(uint64_t aID);
   prio(high) sync EmbeddedChildCount(uint64_t aID) returns(uint32_t aCount);
   prio(high) sync IndexOfEmbeddedChild(uint64_t aID, uint64_t aChildID)
     returns(uint32_t childIdx);
   prio(high) sync EmbeddedChildAt(uint64_t aID, uint32_t aChildIdx)
     returns(uint64_t aChild);
+  prio(high) sync FocusedChild(uint64_t aID)
+    returns(uint64_t aChild, bool aOk);
 
   prio(high) sync Language(uint64_t aID) returns(nsString aLocale);
   prio(high) sync DocType(uint64_t aID) returns(nsString aType);
   prio(high) sync Title(uint64_t aID) returns(nsString aTitle);
   prio(high) sync URL(uint64_t aID) returns(nsString aURL);
   prio(high) sync MimeType(uint64_t aID) returns(nsString aMime);
   prio(high) sync URLDocTypeMimeType(uint64_t aID) returns(nsString aURL, nsString aDocType, nsString aMimeType);
 
--- a/accessible/ipc/ProxyAccessible.cpp
+++ b/accessible/ipc/ProxyAccessible.cpp
@@ -1063,26 +1063,20 @@ ProxyAccessible::EmbeddedChildAt(size_t 
   uint64_t childID;
   Unused << mDoc->SendEmbeddedChildAt(mID, aChildIdx, &childID);
   return mDoc->GetAccessible(childID);
 }
 
 ProxyAccessible*
 ProxyAccessible::FocusedChild()
 {
-  ProxyAccessible* focus = FocusMgr()->FocusedRemoteAccessible();
-  if (IsDoc()) {
-      return focus;
-  }
-
-  if (focus && (focus == this || focus->Parent() == this)) {
-    return focus;
-  }
-
-  return nullptr;
+  uint64_t childID = 0;
+  bool ok = false;
+  Unused << mDoc->SendFocusedChild(mID, &childID, &ok);
+  return ok ? mDoc->GetAccessible(childID) : nullptr;
 }
 
 ProxyAccessible*
 ProxyAccessible::ChildAtPoint(int32_t aX, int32_t aY,
                               Accessible::EWhichChildAtPoint aWhichChild)
 {
   uint64_t childID = 0;
   bool ok = false;