Backed out changeset 08e41d18e1f8 for a case-folding collision.
authorMs2ger <ms2ger@gmail.com>
Tue, 28 Aug 2012 10:24:30 +0200
changeset 105682 70ade35f81309f17553bfd68a3dbf6f7aef91818
parent 105681 08e41d18e1f8448b08c9b3be9d0a2d0abb7aa139
child 105683 98a07ac71ddc0dea77ada9fec41ef56c756e2ee7
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
milestone18.0a1
backs out08e41d18e1f8448b08c9b3be9d0a2d0abb7aa139
Backed out changeset 08e41d18e1f8 for a case-folding collision.
accessible/src/base/AccCollector.cpp
accessible/src/base/AccCollector.h
accessible/src/base/AccIterator.cpp
accessible/src/base/AccIterator.h
accessible/src/base/Filters.cpp
accessible/src/base/Filters.h
accessible/src/base/Makefile.in
accessible/src/base/Relation.h
accessible/src/base/nsAccessNode.h
accessible/src/generic/ARIAGridAccessible-inl.h
accessible/src/generic/ARIAGridAccessible.cpp
accessible/src/generic/ARIAGridAccessible.h
accessible/src/generic/Accessible.cpp
accessible/src/generic/Accessible.h
accessible/src/generic/DocAccessible.h
accessible/tests/mochitest/table/test_indexes_ariagrid.html
--- a/accessible/src/base/AccCollector.cpp
+++ b/accessible/src/base/AccCollector.cpp
@@ -1,18 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "AccCollector.h"
 
 #include "Accessible.h"
 
-using namespace mozilla::a11y;
-
 ////////////////////////////////////////////////////////////////////////////////
 // nsAccCollector
 ////////////////////////////////////////////////////////////////////////////////
 
 AccCollector::
   AccCollector(Accessible* aRoot, filters::FilterFuncPtr aFilterFunc) :
   mFilterFunc(aFilterFunc), mRoot(aRoot), mRootChildIdx(0)
 {
@@ -53,34 +51,34 @@ AccCollector::GetIndexAt(Accessible* aAc
 // nsAccCollector protected
 
 Accessible*
 AccCollector::EnsureNGetObject(uint32_t aIndex)
 {
   uint32_t childCount = mRoot->ChildCount();
   while (mRootChildIdx < childCount) {
     Accessible* child = mRoot->GetChildAt(mRootChildIdx++);
-    if (!(mFilterFunc(child) & filters::eMatch))
+    if (!mFilterFunc(child))
       continue;
 
     AppendObject(child);
     if (mObjects.Length() - 1 == aIndex)
       return mObjects[aIndex];
   }
 
   return nullptr;
 }
 
 int32_t
 AccCollector::EnsureNGetIndex(Accessible* aAccessible)
 {
   uint32_t childCount = mRoot->ChildCount();
   while (mRootChildIdx < childCount) {
     Accessible* child = mRoot->GetChildAt(mRootChildIdx++);
-    if (!(mFilterFunc(child) & filters::eMatch))
+    if (!mFilterFunc(child))
       continue;
 
     AppendObject(child);
     if (child == aAccessible)
       return mObjects.Length() - 1;
   }
 
   return -1;
@@ -100,18 +98,17 @@ int32_t
 EmbeddedObjCollector::GetIndexAt(Accessible* aAccessible)
 {
   if (aAccessible->mParent != mRoot)
     return -1;
 
   if (aAccessible->mIndexOfEmbeddedChild != -1)
     return aAccessible->mIndexOfEmbeddedChild;
 
-  return mFilterFunc(aAccessible) & filters::eMatch ?
-    EnsureNGetIndex(aAccessible) : -1;
+  return mFilterFunc(aAccessible) ? EnsureNGetIndex(aAccessible) : -1;
 }
 
 void
 EmbeddedObjCollector::AppendObject(Accessible* aAccessible)
 {
   aAccessible->mIndexOfEmbeddedChild = mObjects.Length();
   mObjects.AppendElement(aAccessible);
 }
--- a/accessible/src/base/AccCollector.h
+++ b/accessible/src/base/AccCollector.h
@@ -1,24 +1,20 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef mozilla_a11y_AccCollector_h__
-#define mozilla_a11y_AccCollector_h__
+#ifndef AccCollector_h_
+#define AccCollector_h_
 
-#include "Filters.h"
+#include "filters.h"
 
+#include "nscore.h"
 #include "nsTArray.h"
 
-class Accessible;
-
-namespace mozilla {
-namespace a11y {
-
 /**
  * Collect accessible children complying with filter function. Provides quick
  * access to accessible by index.
  */
 class AccCollector
 {
 public:
   AccCollector(Accessible* aRoot, filters::FilterFuncPtr aFilterFunc);
@@ -81,15 +77,12 @@ public:
 
 protected:
   // Make sure it's used by Accessible class only.
   EmbeddedObjCollector(Accessible* aRoot) :
     AccCollector(aRoot, filters::GetEmbeddedObject) { }
 
   virtual void AppendObject(Accessible* aAccessible);
 
-  friend class ::Accessible;
+  friend class Accessible;
 };
 
-} // namespace a11y
-} // namespace mozilla
-
 #endif
--- a/accessible/src/base/AccIterator.cpp
+++ b/accessible/src/base/AccIterator.cpp
@@ -13,18 +13,19 @@
 using namespace mozilla;
 using namespace mozilla::a11y;
 
 ////////////////////////////////////////////////////////////////////////////////
 // AccIterator
 ////////////////////////////////////////////////////////////////////////////////
 
 AccIterator::AccIterator(Accessible* aAccessible,
-                         filters::FilterFuncPtr aFilterFunc) :
-  mFilterFunc(aFilterFunc)
+                         filters::FilterFuncPtr aFilterFunc,
+                         IterationType aIterationType) :
+  mFilterFunc(aFilterFunc), mIsDeep(aIterationType != eFlatNav)
 {
   mState = new IteratorState(aAccessible);
 }
 
 AccIterator::~AccIterator()
 {
   while (mState) {
     IteratorState *tmp = mState;
@@ -34,29 +35,29 @@ AccIterator::~AccIterator()
 }
 
 Accessible*
 AccIterator::Next()
 {
   while (mState) {
     Accessible* child = mState->mParent->GetChildAt(mState->mIndex++);
     if (!child) {
-      IteratorState* tmp = mState;
+      IteratorState *tmp = mState;
       mState = mState->mParentState;
       delete tmp;
 
       continue;
     }
 
-    uint32_t result = mFilterFunc(child);
-    if (result & filters::eMatch)
+    bool isComplying = mFilterFunc(child);
+    if (isComplying)
       return child;
 
-    if (!(result & filters::eSkipSubtree)) {
-      IteratorState* childState = new IteratorState(child, mState);
+    if (mIsDeep) {
+      IteratorState *childState = new IteratorState(child, mState);
       mState = childState;
     }
   }
 
   return nullptr;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
--- a/accessible/src/base/AccIterator.h
+++ b/accessible/src/base/AccIterator.h
@@ -1,23 +1,21 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef mozilla_a11y_AccIterator_h__
-#define mozilla_a11y_AccIterator_h__
+#ifndef nsAccIterator_h_
+#define nsAccIterator_h_
 
+#include "nsAccessibilityService.h"
+#include "filters.h"
+#include "nscore.h"
 #include "DocAccessible.h"
-#include "Filters.h"
-#include "nsAccessibilityService.h"
-
-namespace mozilla {
-namespace a11y {
 
 /**
  * AccIterable is a basic interface for iterators over accessibles.
  */
 class AccIterable
 {
 public:
   virtual ~AccIterable() { }
@@ -30,17 +28,34 @@ private:
 
 /**
  * Allows to iterate through accessible children or subtree complying with
  * filter function.
  */
 class AccIterator : public AccIterable
 {
 public:
-  AccIterator(Accessible* aRoot, filters::FilterFuncPtr aFilterFunc);
+  /**
+   * Used to define iteration type.
+   */
+  enum IterationType {
+    /**
+     * Navigation happens through direct children.
+     */
+    eFlatNav,
+
+    /**
+     * Navigation through subtree excluding iterator root; if the accessible
+     * complies with filter, iterator ignores its children.
+     */
+    eTreeNav
+  };
+
+  AccIterator(Accessible* aRoot, filters::FilterFuncPtr aFilterFunc,
+              IterationType aIterationType = eFlatNav);
   virtual ~AccIterator();
 
   /**
    * Return next accessible complying with filter function. Return the first
    * accessible for the first time.
    */
   virtual Accessible* Next();
 
@@ -50,21 +65,22 @@ private:
   AccIterator& operator =(const AccIterator&);
 
   struct IteratorState
   {
     IteratorState(Accessible* aParent, IteratorState* mParentState = nullptr);
 
     Accessible* mParent;
     int32_t mIndex;
-    IteratorState* mParentState;
+    IteratorState *mParentState;
   };
 
   filters::FilterFuncPtr mFilterFunc;
-  IteratorState* mState;
+  bool mIsDeep;
+  IteratorState *mState;
 };
 
 
 /**
  * Allows to traverse through related accessibles that are pointing to the given
  * dependent accessible by relation attribute.
  */
 class RelatedAccIterator : public AccIterable
@@ -261,12 +277,9 @@ public:
 private:
   SingleAccIterator();
   SingleAccIterator(const SingleAccIterator&);
   SingleAccIterator& operator = (const SingleAccIterator&);
 
   nsRefPtr<Accessible> mAcc;
 };
 
-} // namespace a11y
-} // namespace mozilla
-
 #endif
deleted file mode 100644
--- a/accessible/src/base/Filters.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "Filters.h"
-
-#include "Accessible-inl.h"
-#include "nsAccUtils.h"
-#include "Role.h"
-#include "States.h"
-
-using namespace mozilla::a11y;
-using namespace mozilla::a11y::filters;
-
-uint32_t
-filters::GetSelected(Accessible* aAccessible)
-{
-  if (aAccessible->State() & states::SELECTED)
-    return eMatch | eSkipSubtree;
-
-  return eSkip;
-}
-
-uint32_t
-filters::GetSelectable(Accessible* aAccessible)
-{
-  if (aAccessible->InteractiveState() & states::SELECTABLE)
-    return eMatch | eSkipSubtree;
-
-  return eSkip;
-}
-
-uint32_t
-filters::GetRow(Accessible* aAccessible)
-{
-  a11y::role role = aAccessible->Role();
-  if (role == roles::ROW)
-    return eMatch | eSkipSubtree;
-
-  // Look for rows inside rowgroup.
-  if (role == roles::SECTION)
-    return eSkip;
-
-  return eSkipSubtree;
-}
-
-uint32_t
-filters::GetCell(Accessible* aAccessible)
-{
-  a11y::role role = aAccessible->Role();
-  return role == roles::GRID_CELL || role == roles::ROWHEADER ||
-    role == roles::COLUMNHEADER ? eMatch : eSkipSubtree;
-}
-
-uint32_t
-filters::GetEmbeddedObject(Accessible* aAccessible)
-{
-  return nsAccUtils::IsEmbeddedObject(aAccessible) ?
-    eMatch | eSkipSubtree : eSkipSubtree;
-}
deleted file mode 100644
--- a/accessible/src/base/Filters.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_a11y_Filters_h__
-#define mozilla_a11y_Filters_h__
-
-#include "mozilla/StandardInteger.h"
-
-class Accessible;
-
-/**
- * Predefined filters used for nsAccIterator and nsAccCollector.
- */
-namespace mozilla {
-namespace a11y {
-namespace filters {
-
-enum EResult {
-  eSkip = 0,
-  eMatch = 1,
-  eSkipSubtree = 2
-};
-
-/**
- * Return true if the traversed accessible complies with filter.
- */
-typedef uint32_t (*FilterFuncPtr) (Accessible*);
-
-/**
- * Matches selected/selectable accessibles in subtree.
- */
-uint32_t GetSelected(Accessible* aAccessible);
-uint32_t GetSelectable(Accessible* aAccessible);
-
-/**
- * Matches row accessibles in subtree.
- */
-uint32_t GetRow(Accessible* aAccessible);
-
-/**
- * Matches cell accessibles in children.
- */
-uint32_t GetCell(Accessible* aAccessible);
-
-/**
- * Matches embedded objects in children.
- */
-uint32_t GetEmbeddedObject(Accessible* aAccessible);
-
-} // namespace filters
-} // namespace a11y
-} // namespace mozilla
-
-#endif
--- a/accessible/src/base/Makefile.in
+++ b/accessible/src/base/Makefile.in
@@ -15,17 +15,17 @@ LIBXUL_LIBRARY = 1
 
 
 CPPSRCS = \
   AccCollector.cpp \
   AccEvent.cpp \
   AccGroupInfo.cpp \
   AccIterator.cpp \
   ARIAStateMap.cpp \
-  Filters.cpp \
+  filters.cpp \
   FocusManager.cpp \
   NotificationController.cpp \
   nsAccDocManager.cpp \
   nsAccessNode.cpp \
   nsARIAMap.cpp \
   nsCoreUtils.cpp \
   nsAccUtils.cpp \
   nsAccessibilityService.cpp \
--- a/accessible/src/base/Relation.h
+++ b/accessible/src/base/Relation.h
@@ -14,38 +14,36 @@ namespace a11y {
 
 /**
  * This class is used to return Relation objects from functions.  A copy
  * constructor doesn't work here because we need to mutate the old relation to
  * have its nsAutoPtr forget what it points to.
  */
 struct RelationCopyHelper
 {
-  RelationCopyHelper(mozilla::a11y::AccIterable* aFirstIter,
-                     mozilla::a11y::AccIterable* aLastIter) :
+  RelationCopyHelper(AccIterable* aFirstIter, AccIterable* aLastIter) :
     mFirstIter(aFirstIter), mLastIter(aLastIter) { }
 
-  mozilla::a11y::AccIterable* mFirstIter;
-  mozilla::a11y::AccIterable* mLastIter;
+  AccIterable* mFirstIter;
+  AccIterable* mLastIter;
 };
 
 /**
  * A collection of relation targets of a certain type.  Targets are computed
  * lazily while enumerating.
  */
 class Relation
 {
 public:
   Relation() : mFirstIter(nullptr), mLastIter(nullptr) { }
 
   Relation(const RelationCopyHelper aRelation) :
     mFirstIter(aRelation.mFirstIter), mLastIter(aRelation.mLastIter) { }
 
-  Relation(mozilla::a11y::AccIterable* aIter) :
-    mFirstIter(aIter), mLastIter(aIter) { }
+  Relation(AccIterable* aIter) : mFirstIter(aIter), mLastIter(aIter) { }
 
   Relation(Accessible* aAcc) :
     mFirstIter(nullptr), mLastIter(nullptr)
     { AppendTarget(aAcc); }
 
   Relation(DocAccessible* aDocument, nsIContent* aContent) :
     mFirstIter(nullptr), mLastIter(nullptr)
     { AppendTarget(aDocument, aContent); }
@@ -64,33 +62,33 @@ public:
     return *this;
   }
 
   operator RelationCopyHelper()
   {
     return RelationCopyHelper(mFirstIter.forget(), mLastIter);
   }
 
-  inline void AppendIter(mozilla::a11y::AccIterable* aIter)
+  inline void AppendIter(AccIterable* aIter)
   {
     if (mLastIter)
       mLastIter->mNextIter = aIter;
     else
       mFirstIter = aIter;
 
     mLastIter = aIter;
   }
 
   /**
    * Append the given accessible to the set of related accessibles.
    */
   inline void AppendTarget(Accessible* aAcc)
   {
     if (aAcc)
-      AppendIter(new mozilla::a11y::SingleAccIterator(aAcc));
+      AppendIter(new SingleAccIterator(aAcc));
   }
 
   /**
    * Append the one accessible for this content node to the set of related
    * accessibles.
    */
   void AppendTarget(DocAccessible* aDocument, nsIContent* aContent)
   {
@@ -113,17 +111,17 @@ public:
       mLastIter = nullptr;
 
     return target;
   }
 
 private:
   Relation& operator = (const Relation&);
 
-  nsAutoPtr<mozilla::a11y::AccIterable> mFirstIter;
-  mozilla::a11y::AccIterable* mLastIter;
+  nsAutoPtr<AccIterable> mFirstIter;
+  AccIterable* mLastIter;
 };
 
 } // namespace a11y
 } // namespace mozilla
 
 #endif
 
--- a/accessible/src/base/nsAccessNode.h
+++ b/accessible/src/base/nsAccessNode.h
@@ -98,17 +98,17 @@ public:
 
   /**
    * Return true if the accessible is primary accessible for the given DOM node.
    *
    * Accessible hierarchy may be complex for single DOM node, in this case
    * these accessibles share the same DOM node. The primary accessible "owns"
    * that DOM node in terms it gets stored in the accessible to node map.
    */
-  virtual bool IsPrimaryForNode() const;//hello
+  virtual bool IsPrimaryForNode() const;
 
   /**
    * Interface methods on nsIAccessible shared with ISimpleDOM.
    */
   void Language(nsAString& aLocale);
 
 protected:
   void LastRelease();
deleted file mode 100644
--- a/accessible/src/generic/ARIAGridAccessible-inl.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_a11y_ARIAGridAccessible_inl_h__
-#define mozilla_a11y_ARIAGridAccessible_inl_h__
-
-#include "ARIAGridAccessible.h"
-
-#include "AccIterator.h"
-
-inline Accessible*
-mozilla::a11y::ARIAGridCellAccessible::TableFor(Accessible* aRow) const
-{
-  if (aRow) {
-    Accessible* table = aRow->Parent();
-    if (table) {
-      roles::Role tableRole = table->Role();
-      if (tableRole == roles::SECTION) { // if there's a rowgroup.
-        table = table->Parent();
-        if (table)
-          tableRole = table->Role();
-      }
-
-      return tableRole == roles::TABLE || tableRole == roles::TREE_TABLE ?
-        table : nullptr;
-    }
-  }
-
-  return nullptr;
-}
-
-inline int32_t
-mozilla::a11y::ARIAGridCellAccessible::RowIndexFor(Accessible* aRow) const
-{
-  Accessible* table = TableFor(aRow);
-  if (table) {
-    int32_t rowIdx = 0;
-    Accessible* row = nullptr;
-    AccIterator rowIter(table, filters::GetRow);
-    while ((row = rowIter.Next()) && row != aRow)
-      rowIdx++;
-
-    if (row)
-      return rowIdx;
-  }
-
-  return -1;
-}
-
-#endif
--- a/accessible/src/generic/ARIAGridAccessible.cpp
+++ b/accessible/src/generic/ARIAGridAccessible.cpp
@@ -1,14 +1,14 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "ARIAGridAccessible-inl.h"
+#include "ARIAGridAccessible.h"
 
 #include "Accessible-inl.h"
 #include "AccIterator.h"
 #include "nsAccUtils.h"
 #include "Role.h"
 #include "States.h"
 
 #include "nsIMutableArray.h"
@@ -546,20 +546,29 @@ NS_IMPL_ISUPPORTS_INHERITED1(ARIAGridCel
 // nsIAccessibleTableCell
 
 NS_IMETHODIMP
 ARIAGridCellAccessible::GetTable(nsIAccessibleTable** aTable)
 {
   NS_ENSURE_ARG_POINTER(aTable);
   *aTable = nullptr;
 
-  Accessible* table = TableFor(Row());
-  if (table)
-    CallQueryInterface(table, aTable);
+  Accessible* thisRow = Parent();
+  if (!thisRow || thisRow->Role() != roles::ROW)
+    return NS_OK;
 
+  Accessible* table = thisRow->Parent();
+  if (!table)
+    return NS_OK;
+
+  roles::Role tableRole = table->Role();
+  if (tableRole != roles::TABLE && tableRole != roles::TREE_TABLE)
+    return NS_OK;
+
+  CallQueryInterface(table, aTable);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 ARIAGridCellAccessible::GetColumnIndex(int32_t* aColumnIndex)
 {
   NS_ENSURE_ARG_POINTER(aColumnIndex);
   *aColumnIndex = -1;
@@ -589,17 +598,33 @@ NS_IMETHODIMP
 ARIAGridCellAccessible::GetRowIndex(int32_t* aRowIndex)
 {
   NS_ENSURE_ARG_POINTER(aRowIndex);
   *aRowIndex = -1;
 
   if (IsDefunct())
     return NS_ERROR_FAILURE;
 
-  *aRowIndex = RowIndexFor(Row());
+  Accessible* row = Parent();
+  if (!row)
+    return NS_OK;
+
+  Accessible* table = row->Parent();
+  if (!table)
+    return NS_OK;
+
+  *aRowIndex = 0;
+
+  int32_t indexInTable = row->IndexInParent();
+  for (int32_t idx = 0; idx < indexInTable; idx++) {
+    row = table->GetChildAt(idx);
+    if (row->Role() == roles::ROW)
+      (*aRowIndex)++;
+  }
+
   return NS_OK;
 }
 
 NS_IMETHODIMP
 ARIAGridCellAccessible::GetColumnExtent(int32_t* aExtentCount)
 {
   NS_ENSURE_ARG_POINTER(aExtentCount);
   *aExtentCount = 0;
@@ -708,42 +733,62 @@ ARIAGridCellAccessible::ApplyARIAState(u
     *aState |= states::SELECTABLE | states::SELECTED;
 }
 
 nsresult
 ARIAGridCellAccessible::GetAttributesInternal(nsIPersistentProperties* aAttributes)
 {
   if (IsDefunct())
     return NS_ERROR_FAILURE;
-
+  
   nsresult rv = HyperTextAccessibleWrap::GetAttributesInternal(aAttributes);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Expose "table-cell-index" attribute.
-  Accessible* thisRow = Row();
-  if (!thisRow)
+
+  Accessible* thisRow = Parent();
+  if (!thisRow || thisRow->Role() != roles::ROW)
     return NS_OK;
 
   int32_t colIdx = 0, colCount = 0;
   uint32_t childCount = thisRow->ChildCount();
   for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
     Accessible* child = thisRow->GetChildAt(childIdx);
     if (child == this)
       colIdx = colCount;
 
     roles::Role role = child->Role();
     if (role == roles::GRID_CELL || role == roles::ROWHEADER ||
         role == roles::COLUMNHEADER)
       colCount++;
   }
 
-  int32_t rowIdx = RowIndexFor(thisRow);
+  Accessible* table = thisRow->Parent();
+  if (!table)
+    return NS_OK;
+
+  roles::Role tableRole = table->Role();
+  if (tableRole != roles::TABLE && tableRole != roles::TREE_TABLE)
+    return NS_OK;
+
+  int32_t rowIdx = 0;
+  childCount = table->ChildCount();
+  for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
+    Accessible* child = table->GetChildAt(childIdx);
+    if (child == thisRow)
+      break;
+
+    if (child->Role() == roles::ROW)
+      rowIdx++;
+  }
+
+  int32_t idx = rowIdx * colCount + colIdx;
 
   nsAutoString stringIdx;
-  stringIdx.AppendInt(rowIdx * colCount + colIdx);
+  stringIdx.AppendInt(idx);
   nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::tableCellIndex,
                          stringIdx);
 
   return NS_OK;
 }
 
 void
 ARIAGridCellAccessible::Shutdown()
--- a/accessible/src/generic/ARIAGridAccessible.h
+++ b/accessible/src/generic/ARIAGridAccessible.h
@@ -55,17 +55,16 @@ public:
   virtual void SelectedColIndices(nsTArray<uint32_t>* aCols);
   virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows);
   virtual void SelectCol(uint32_t aColIdx);
   virtual void SelectRow(uint32_t aRowIdx);
   virtual void UnselectCol(uint32_t aColIdx);
   virtual void UnselectRow(uint32_t aRowIdx);
 
 protected:
-
   /**
    * Return true if the given row index is valid.
    */
   bool IsValidRow(int32_t aRow);
 
   /**
    * Retrn true if the given column index is valid.
    */
@@ -110,35 +109,14 @@ public:
 
   // nsIAccessibleTableCell
   NS_DECL_OR_FORWARD_NSIACCESSIBLETABLECELL_WITH_XPCACCESSIBLETABLECELL
 
   // Accessible
   virtual void Shutdown();
   virtual void ApplyARIAState(uint64_t* aState) const;
   virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
-
-protected:
-
-  /**
-   * Return a containing row.
-   */
-  Accessible* Row() const
-  {
-    Accessible* row = Parent();
-    return row && row->Role() == roles::ROW ? row : nullptr;
-  }
-
-  /**
-   * Return a table for the given row.
-   */
-  Accessible* TableFor(Accessible* aRow) const;
-
-  /**
-   * Return index of the given row.
-   */
-  int32_t RowIndexFor(Accessible* aRow) const;
 };
 
 } // namespace a11y
 } // namespace mozilla
 
 #endif
--- a/accessible/src/generic/Accessible.cpp
+++ b/accessible/src/generic/Accessible.cpp
@@ -2723,115 +2723,115 @@ Accessible::IsSelect()
 
 already_AddRefed<nsIArray>
 Accessible::SelectedItems()
 {
   nsCOMPtr<nsIMutableArray> selectedItems = do_CreateInstance(NS_ARRAY_CONTRACTID);
   if (!selectedItems)
     return nullptr;
 
-  AccIterator iter(this, filters::GetSelected);
+  AccIterator iter(this, filters::GetSelected, AccIterator::eTreeNav);
   nsIAccessible* selected = nullptr;
   while ((selected = iter.Next()))
     selectedItems->AppendElement(selected, false);
 
   nsIMutableArray* items = nullptr;
   selectedItems.forget(&items);
   return items;
 }
 
 uint32_t
 Accessible::SelectedItemCount()
 {
   uint32_t count = 0;
-  AccIterator iter(this, filters::GetSelected);
+  AccIterator iter(this, filters::GetSelected, AccIterator::eTreeNav);
   Accessible* selected = nullptr;
   while ((selected = iter.Next()))
     ++count;
 
   return count;
 }
 
 Accessible*
 Accessible::GetSelectedItem(uint32_t aIndex)
 {
-  AccIterator iter(this, filters::GetSelected);
+  AccIterator iter(this, filters::GetSelected, AccIterator::eTreeNav);
   Accessible* selected = nullptr;
 
   uint32_t index = 0;
   while ((selected = iter.Next()) && index < aIndex)
     index++;
 
   return selected;
 }
 
 bool
 Accessible::IsItemSelected(uint32_t aIndex)
 {
   uint32_t index = 0;
-  AccIterator iter(this, filters::GetSelectable);
+  AccIterator iter(this, filters::GetSelectable, AccIterator::eTreeNav);
   Accessible* selected = nullptr;
   while ((selected = iter.Next()) && index < aIndex)
     index++;
 
   return selected &&
     selected->State() & states::SELECTED;
 }
 
 bool
 Accessible::AddItemToSelection(uint32_t aIndex)
 {
   uint32_t index = 0;
-  AccIterator iter(this, filters::GetSelectable);
+  AccIterator iter(this, filters::GetSelectable, AccIterator::eTreeNav);
   Accessible* selected = nullptr;
   while ((selected = iter.Next()) && index < aIndex)
     index++;
 
   if (selected)
     selected->SetSelected(true);
 
   return static_cast<bool>(selected);
 }
 
 bool
 Accessible::RemoveItemFromSelection(uint32_t aIndex)
 {
   uint32_t index = 0;
-  AccIterator iter(this, filters::GetSelectable);
+  AccIterator iter(this, filters::GetSelectable, AccIterator::eTreeNav);
   Accessible* selected = nullptr;
   while ((selected = iter.Next()) && index < aIndex)
     index++;
 
   if (selected)
     selected->SetSelected(false);
 
   return static_cast<bool>(selected);
 }
 
 bool
 Accessible::SelectAll()
 {
   bool success = false;
   Accessible* selectable = nullptr;
 
-  AccIterator iter(this, filters::GetSelectable);
+  AccIterator iter(this, filters::GetSelectable, AccIterator::eTreeNav);
   while((selectable = iter.Next())) {
     success = true;
     selectable->SetSelected(true);
   }
   return success;
 }
 
 bool
 Accessible::UnselectAll()
 {
   bool success = false;
   Accessible* selected = nullptr;
 
-  AccIterator iter(this, filters::GetSelected);
+  AccIterator iter(this, filters::GetSelected, AccIterator::eTreeNav);
   while ((selected = iter.Next())) {
     success = true;
     selected->SetSelected(false);
   }
   return success;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
--- a/accessible/src/generic/Accessible.h
+++ b/accessible/src/generic/Accessible.h
@@ -18,25 +18,25 @@
 #include "nsIContent.h"
 
 #include "nsStringGlue.h"
 #include "nsTArray.h"
 #include "nsRefPtrHashtable.h"
 
 class AccEvent;
 class AccGroupInfo;
+class EmbeddedObjCollector;
 class KeyBinding;
 class Accessible;
 class HyperTextAccessible;
 struct nsRoleMapEntry;
 
 namespace mozilla {
 namespace a11y {
 
-class EmbeddedObjCollector;
 class HTMLImageMapAccessible;
 class HTMLLIAccessible;
 class ImageAccessible;
 class Relation;
 class TableAccessible;
 class TextLeafAccessible;
 class XULTreeAccessible;
 
@@ -870,19 +870,19 @@ protected:
   int32_t mIndexInParent;
 
   static const uint32_t kChildrenFlagsMask =
     eChildrenUninitialized | eMixedChildren | eEmbeddedChildren;
 
   uint32_t mFlags;
   friend class DocAccessible;
 
-  nsAutoPtr<mozilla::a11y::EmbeddedObjCollector> mEmbeddedObjCollector;
+  nsAutoPtr<EmbeddedObjCollector> mEmbeddedObjCollector;
   int32_t mIndexOfEmbeddedChild;
-  friend class mozilla::a11y::EmbeddedObjCollector;
+  friend class EmbeddedObjCollector;
 
   nsAutoPtr<AccGroupInfo> mGroupInfo;
   friend class AccGroupInfo;
 
   /**
    * Non-null indicates author-supplied role; possibly state & value as well
    */
   nsRoleMapEntry* mRoleMapEntry;
--- a/accessible/src/generic/DocAccessible.h
+++ b/accessible/src/generic/DocAccessible.h
@@ -28,24 +28,16 @@ template<class Class, class Arg>
 class TNotification;
 class NotificationController;
 
 class nsIScrollableView;
 class nsAccessiblePivot;
 
 const uint32_t kDefaultCacheSize = 256;
 
-namespace mozilla {
-namespace a11y {
-
-class RelatedAccIterator;
-
-} // namespace a11y
-} // namespace mozilla
-
 class DocAccessible : public HyperTextAccessibleWrap,
                       public nsIAccessibleDocument,
                       public nsIDocumentObserver,
                       public nsIObserver,
                       public nsIScrollPositionListener,
                       public nsSupportsWeakReference,
                       public nsIAccessibleCursorable,
                       public nsIAccessiblePivotObserver
@@ -570,17 +562,17 @@ protected:
   };
 
   /**
    * The cache of IDs pointed by relation attributes.
    */
   typedef nsTArray<nsAutoPtr<AttrRelProvider> > AttrRelProviderArray;
   nsClassHashtable<nsStringHashKey, AttrRelProviderArray> mDependentIDsHash;
 
-  friend class mozilla::a11y::RelatedAccIterator;
+  friend class RelatedAccIterator;
 
   /**
    * Used for our caching algorithm. We store the list of nodes that should be
    * invalidated.
    *
    * @see ProcessInvalidationList
    */
   nsTArray<nsIContent*> mInvalidationList;
--- a/accessible/tests/mochitest/table/test_indexes_ariagrid.html
+++ b/accessible/tests/mochitest/table/test_indexes_ariagrid.html
@@ -23,24 +23,16 @@
       var idxes = [
         [0, 1, 2],
         [3, 4, 5],
         [6, 7, 8],
         [9, 10, 11]
       ];
       testTableIndexes("grid", idxes);
 
-      idxes = [
-        [0, 1, 2],
-        [3, 4, 5],
-        [6, 7, 8],
-        [9, 10, 11]
-      ];
-      testTableIndexes("grid-rowgroups", idxes);
-
       //////////////////////////////////////////////////////////////////////////
       // a bit crazy ARIA grid
       idxes = [
         [0, 1],
         [2, 3]
       ];
       testTableIndexes("grid2", idxes);
 
@@ -54,19 +46,16 @@
 <body>
 
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=386813"
      title="support nsIAccessibleTable on ARIA grid/treegrid">Mozilla Bug 386813</a>
   <a target="_blank"
      title="nsHTMLTableCellAccessible is used in dojo's crazy ARIA grid"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=513848">Mozilla Bug 513848</a>
-  <a target="_blank"
-     title="ARIA grid with rowgroup breaks table row/col counting and indices"
-     href="https://bugzilla.mozilla.org/show_bug.cgi?id=761853">Mozilla Bug 761853</a>
 
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
   </pre>
 
   <div role="grid" id="grid">
     <div role="row">
@@ -86,41 +75,16 @@
     </div>
     <div role="row">
       <span role="rowheader">row3</span>
       <span role="gridcell">cell5</span>
       <span role="gridcell">cell6</span>
     </div>
   </div>
 
-  <div role="grid" id="grid-rowgroups">
-    <div role="row">
-      <span role="columnheader">grid-rowgroups-col1</span>
-      <span role="columnheader">grid-rowgroups-col2</span>
-      <span role="columnheader">grid-rowgroups-col3</span>
-    </div>
-    <div role="rowgroup">
-      <div role="row">
-        <span role="rowheader">grid-rowgroups-row1</span>
-        <span role="gridcell">grid-rowgroups-cell1</span>
-        <span role="gridcell">grid-rowgroups-cell2</span>
-      </div>
-      <div role="row">
-        <span role="rowheader">grid-rowgroups-row2</span>
-        <span role="gridcell">grid-rowgroups-cell3</span>
-        <span role="gridcell">grid-rowgroups-cell4</span>
-      </div>
-    </div>
-    <div role="row">
-      <span role="rowheader">grid-rowgroups-row3</span>
-      <span role="gridcell">grid-rowgroups-cell5</span>
-      <span role="gridcell">grid-rowgroups-cell6</span>
-    </div>
-  </div>
-
   <div role="grid" id="grid2">
     <div role="row">
       <table role="presentation">
         <tr>
           <td role="columnheader">header1</td>
           <td role="columnheader">header2</td>
         </tr>
       </table>