bug 767272 - don't use nsIAccessibleTable type stuff in ia2AccessibleTable r=surkov
☠☠ backed out by f0653eede02f ☠ ☠
authorTrevor Saunders <trev.saunders@gmail.com>
Wed, 09 Jan 2013 03:51:30 -0500
changeset 130021 422c0104079ecc89f11c755e3e898c1aefd3f9ad
parent 130020 8d016fb6d8479285f67ec16c7a8fee0f2c422b44
child 130022 0ebed8dbb21c947028243d51c2adba9677637403
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs767272
milestone21.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 767272 - don't use nsIAccessibleTable type stuff in ia2AccessibleTable r=surkov
accessible/src/msaa/ARIAGridAccessibleWrap.cpp
accessible/src/msaa/ARIAGridAccessibleWrap.h
accessible/src/msaa/HTMLTableAccessibleWrap.cpp
accessible/src/msaa/HTMLTableAccessibleWrap.h
accessible/src/msaa/XULListboxAccessibleWrap.cpp
accessible/src/msaa/XULListboxAccessibleWrap.h
accessible/src/msaa/XULTreeGridAccessibleWrap.cpp
accessible/src/msaa/XULTreeGridAccessibleWrap.h
accessible/src/windows/ia2/ia2AccessibleTable.cpp
accessible/src/windows/ia2/ia2AccessibleTable.h
--- a/accessible/src/msaa/ARIAGridAccessibleWrap.cpp
+++ b/accessible/src/msaa/ARIAGridAccessibleWrap.cpp
@@ -16,16 +16,22 @@ using namespace mozilla::a11y;
 
 NS_IMPL_ISUPPORTS_INHERITED0(ARIAGridAccessibleWrap,
                              ARIAGridAccessible)
 
 IMPL_IUNKNOWN_INHERITED1(ARIAGridAccessibleWrap,
                          AccessibleWrap,
                          ia2AccessibleTable)
 
+void
+ARIAGridAccessibleWrap::Shutdown()
+{
+  ia2AccessibleTable::mTable = nullptr;
+  ARIAGridAccessible::Shutdown();
+}
 
 ////////////////////////////////////////////////////////////////////////////////
 // ARIAGridCellAccessibleWrap
 ////////////////////////////////////////////////////////////////////////////////
 
 NS_IMPL_ISUPPORTS_INHERITED0(ARIAGridCellAccessibleWrap,
                              ARIAGridCellAccessible)
 
--- a/accessible/src/msaa/ARIAGridAccessibleWrap.h
+++ b/accessible/src/msaa/ARIAGridAccessibleWrap.h
@@ -19,23 +19,25 @@ namespace a11y {
  * IA2 wrapper class for ARIAGridAccessible implementing IAccessibleTable and
  * IAccessibleTable2 interfaces.
  */
 class ARIAGridAccessibleWrap : public ARIAGridAccessible,
                                public ia2AccessibleTable
 {
 public:
   ARIAGridAccessibleWrap(nsIContent* aContent, DocAccessible* aDoc) :
-    ARIAGridAccessible(aContent, aDoc) {}
+    ARIAGridAccessible(aContent, aDoc), ia2AccessibleTable(this) {}
 
   // IUnknown
   DECL_IUNKNOWN_INHERITED
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
+
+  virtual void Shutdown() MOZ_OVERRIDE;
 };
 
 /**
  * IA2 wrapper class for ARIAGridCellAccessible implementing
  * IAccessibleTableCell interface.
  */
 class ARIAGridCellAccessibleWrap : public ARIAGridCellAccessible,
                                    public ia2AccessibleTableCell
--- a/accessible/src/msaa/HTMLTableAccessibleWrap.cpp
+++ b/accessible/src/msaa/HTMLTableAccessibleWrap.cpp
@@ -15,16 +15,22 @@ using namespace mozilla::a11y;
 
 NS_IMPL_ISUPPORTS_INHERITED0(HTMLTableAccessibleWrap,
                              HTMLTableAccessible)
 
 IMPL_IUNKNOWN_INHERITED1(HTMLTableAccessibleWrap,
                          AccessibleWrap,
                          ia2AccessibleTable)
 
+void
+HTMLTableAccessibleWrap::Shutdown()
+{
+  ia2AccessibleTable::mTable = nullptr;
+  HTMLTableAccessible::Shutdown();
+}
 
 ////////////////////////////////////////////////////////////////////////////////
 // HTMLTableCellAccessibleWrap
 ////////////////////////////////////////////////////////////////////////////////
 
 NS_IMPL_ISUPPORTS_INHERITED0(HTMLTableCellAccessibleWrap,
                              HTMLTableCellAccessible)
 
--- a/accessible/src/msaa/HTMLTableAccessibleWrap.h
+++ b/accessible/src/msaa/HTMLTableAccessibleWrap.h
@@ -20,23 +20,25 @@ namespace a11y {
  * IA2 wrapper class for HTMLTableAccessible implementing IAccessibleTable
  * and IAccessibleTable2 interfaces.
  */
 class HTMLTableAccessibleWrap : public HTMLTableAccessible,
                                 public ia2AccessibleTable
 {
 public:
   HTMLTableAccessibleWrap(nsIContent* aContent, DocAccessible* aDoc) :
-    HTMLTableAccessible(aContent, aDoc) {}
+    HTMLTableAccessible(aContent, aDoc), ia2AccessibleTable(this)  {}
 
   // IUnknown
   DECL_IUNKNOWN_INHERITED
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
+
+  virtual void Shutdown() MOZ_OVERRIDE;
 };
 
 
 /**
  * IA2 wrapper class for HTMLTableCellAccessible implementing
  * IAccessibleTableCell interface.
  */
 class HTMLTableCellAccessibleWrap : public HTMLTableCellAccessible,
--- a/accessible/src/msaa/XULListboxAccessibleWrap.cpp
+++ b/accessible/src/msaa/XULListboxAccessibleWrap.cpp
@@ -6,30 +6,30 @@
 #include "XULListboxAccessibleWrap.h"
 
 using namespace mozilla::a11y;
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULListboxAccessibleWrap
 ////////////////////////////////////////////////////////////////////////////////
 
-XULListboxAccessibleWrap::
-  XULListboxAccessibleWrap(nsIContent* aContent, DocAccessible* aDoc) :
-  XULListboxAccessible(aContent, aDoc)
-{
-}
-
 NS_IMPL_ISUPPORTS_INHERITED0(XULListboxAccessibleWrap,
                              XULListboxAccessible)
 
 IMPL_IUNKNOWN_QUERY_HEAD(XULListboxAccessibleWrap)
 IMPL_IUNKNOWN_QUERY_CLASS_COND(ia2AccessibleTable, IsMulticolumn());
 IMPL_IUNKNOWN_QUERY_CLASS(AccessibleWrap)
 IMPL_IUNKNOWN_QUERY_TAIL
 
+void
+XULListboxAccessibleWrap::Shutdown()
+{
+  ia2AccessibleTable::mTable = nullptr;
+  XULListboxAccessible::Shutdown();
+}
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULListCellAccessibleWrap
 ////////////////////////////////////////////////////////////////////////////////
 
 XULListCellAccessibleWrap::
   XULListCellAccessibleWrap(nsIContent* aContent, DocAccessible* aDoc) :
   XULListCellAccessible(aContent, aDoc)
--- a/accessible/src/msaa/XULListboxAccessibleWrap.h
+++ b/accessible/src/msaa/XULListboxAccessibleWrap.h
@@ -17,23 +17,26 @@ namespace a11y {
 /**
  * IA2 wrapper class for XULListboxAccessible class implementing
  * IAccessibleTable and IAccessibleTable2 interfaces.
  */
 class XULListboxAccessibleWrap : public XULListboxAccessible,
                                  public ia2AccessibleTable
 {
 public:
-  XULListboxAccessibleWrap(nsIContent* aContent, DocAccessible* aDoc);
+  XULListboxAccessibleWrap(nsIContent* aContent, DocAccessible* aDoc) :
+    XULListboxAccessible(aContent, aDoc), ia2AccessibleTable(this) {}
 
   // IUnknown
   DECL_IUNKNOWN_INHERITED
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
+
+  virtual void Shutdown() MOZ_OVERRIDE;
 };
 
 /**
  * IA2 wrapper class for XULListCellAccessible class, implements
  * IAccessibleTableCell interface.
  */
 class XULListCellAccessibleWrap : public XULListCellAccessible,
                                   public ia2AccessibleTableCell
--- a/accessible/src/msaa/XULTreeGridAccessibleWrap.cpp
+++ b/accessible/src/msaa/XULTreeGridAccessibleWrap.cpp
@@ -6,29 +6,29 @@
 #include "XULTreeGridAccessibleWrap.h"
 
 using namespace mozilla::a11y;
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeGridAccessibleWrap
 ////////////////////////////////////////////////////////////////////////////////
 
-XULTreeGridAccessibleWrap::
-  XULTreeGridAccessibleWrap(nsIContent* aContent, DocAccessible* aDoc) :
-  XULTreeGridAccessible(aContent, aDoc)
-{
-}
-
 NS_IMPL_ISUPPORTS_INHERITED0(XULTreeGridAccessibleWrap,
                              XULTreeGridAccessible)
 
 IMPL_IUNKNOWN_INHERITED1(XULTreeGridAccessibleWrap,
                          AccessibleWrap,
                          ia2AccessibleTable)
 
+void
+XULTreeGridAccessibleWrap::Shutdown()
+{
+  ia2AccessibleTable::mTable = nullptr;
+  XULTreeGridAccessibleWrap::Shutdown();
+}
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeGridCellAccessibleWrap
 ////////////////////////////////////////////////////////////////////////////////
 
 XULTreeGridCellAccessibleWrap::
   XULTreeGridCellAccessibleWrap(nsIContent* aContent,
                                 DocAccessible* aDoc,
--- a/accessible/src/msaa/XULTreeGridAccessibleWrap.h
+++ b/accessible/src/msaa/XULTreeGridAccessibleWrap.h
@@ -17,23 +17,26 @@ namespace a11y {
 /**
  * IA2 wrapper class for XULTreeGridAccessible class implementing
  * IAccessibleTable and IAccessibleTable2 interfaces.
  */
 class XULTreeGridAccessibleWrap : public XULTreeGridAccessible,
                                   public ia2AccessibleTable
 {
 public:
-  XULTreeGridAccessibleWrap(nsIContent* aContent, DocAccessible* aDoc);
+  XULTreeGridAccessibleWrap(nsIContent* aContent, DocAccessible* aDoc) :
+    XULTreeGridAccessible(aContent, aDoc), ia2AccessibleTable(this) {}
 
   // IUnknown
   DECL_IUNKNOWN_INHERITED
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
+
+  virtual void Shutdown() MOZ_OVERRIDE;
 };
 
 /**
  * IA2 wrapper class for XULTreeGridCellAccessible class, implements
  * IAccessibleTableCell interface.
  */
 class XULTreeGridCellAccessibleWrap : public XULTreeGridCellAccessible,
                                       public ia2AccessibleTableCell
--- a/accessible/src/windows/ia2/ia2AccessibleTable.cpp
+++ b/accessible/src/windows/ia2/ia2AccessibleTable.cpp
@@ -6,31 +6,25 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ia2AccessibleTable.h"
 
 #include "Accessible2.h"
 #include "AccessibleTable_i.c"
 #include "AccessibleTable2_i.c"
 
-#include "nsIAccessible.h"
-#include "nsIAccessibleTable.h"
-#include "nsIWinAccessNode.h"
-#include "nsAccessNodeWrap.h"
-#include "nsWinUtils.h"
+#include "AccessibleWrap.h"
 #include "Statistics.h"
+#include "TableAccessible.h"
 
 #include "nsCOMPtr.h"
 #include "nsString.h"
 
 using namespace mozilla::a11y;
 
-#define CANT_QUERY_ASSERTION_MSG \
-"Subclass of ia2AccessibleTable doesn't implement nsIAccessibleTable"\
-
 // IUnknown
 
 STDMETHODIMP
 ia2AccessibleTable::QueryInterface(REFIID iid, void** ppv)
 {
   *ppv = NULL;
 
   if (IID_IAccessibleTable == iid) {
@@ -48,152 +42,101 @@ ia2AccessibleTable::QueryInterface(REFII
 
   return E_NOINTERFACE;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // IAccessibleTable
 
 STDMETHODIMP
-ia2AccessibleTable::get_accessibleAt(long aRow, long aColumn,
-                                   IUnknown **aAccessible)
+ia2AccessibleTable::get_accessibleAt(long aRowIdx, long aColIdx,
+                                     IUnknown** aAccessible)
 {
-  A11Y_TRYBLOCK_BEGIN
-
-  *aAccessible = NULL;
-
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
-
-  nsCOMPtr<nsIAccessible> cell;
-  nsresult rv = tableAcc->GetCellAt(aRow, aColumn, getter_AddRefs(cell));
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
-
-  nsCOMPtr<nsIWinAccessNode> winAccessNode(do_QueryInterface(cell));
-  if (!winAccessNode)
-    return E_FAIL;
-
-  void *instancePtr = NULL;
-  rv = winAccessNode->QueryNativeInterface(IID_IAccessible2, &instancePtr);
-  if (NS_FAILED(rv))
-    return E_FAIL;
-
-  *aAccessible = static_cast<IUnknown*>(instancePtr);
-  return S_OK;
-
-  A11Y_TRYBLOCK_END
+  return get_cellAt(aRowIdx, aColIdx, aAccessible);
 }
 
 STDMETHODIMP
 ia2AccessibleTable::get_caption(IUnknown** aAccessible)
 {
   A11Y_TRYBLOCK_BEGIN
 
   *aAccessible = NULL;
-
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
 
-  nsCOMPtr<nsIAccessible> caption;
-  nsresult rv = tableAcc->GetCaption(getter_AddRefs(caption));
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
-
+  AccessibleWrap* caption = static_cast<AccessibleWrap*>(mTable->Caption());
   if (!caption)
     return S_FALSE;
 
-  nsCOMPtr<nsIWinAccessNode> winAccessNode(do_QueryInterface(caption));
-  if (!winAccessNode)
-    return E_FAIL;
-
-  void *instancePtr = NULL;
-  rv = winAccessNode->QueryNativeInterface(IID_IAccessible2, &instancePtr);
-  if (NS_FAILED(rv))
-    return E_FAIL;
-
-  *aAccessible = static_cast<IUnknown*>(instancePtr);
+  (*aAccessible = static_cast<IAccessible*>(caption))->AddRef();
   return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
-ia2AccessibleTable::get_childIndex(long aRowIndex, long aColumnIndex,
-                                   long* aChildIndex)
+ia2AccessibleTable::get_childIndex(long aRowIdx, long aColIdx,
+                                   long* aChildIdx)
 {
   A11Y_TRYBLOCK_BEGIN
 
-  *aChildIndex = 0;
-
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
+  *aChildIdx = 0;
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
 
-  int32_t childIndex = 0;
-  nsresult rv = tableAcc->GetCellIndexAt(aRowIndex, aColumnIndex, &childIndex);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
+  if (aRowIdx < 0 || aColIdx < 0 ||
+      static_cast<uint32_t>(aRowIdx) >= mTable->RowCount() ||
+      static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
+    return E_INVALIDARG;
 
-  *aChildIndex = childIndex;
+  *aChildIdx = mTable->CellIndexAt(aRowIdx, aColIdx);
   return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
-ia2AccessibleTable::get_columnDescription(long aColumn, BSTR* aDescription)
+ia2AccessibleTable::get_columnDescription(long aColIdx, BSTR* aDescription)
 {
   A11Y_TRYBLOCK_BEGIN
 
   *aDescription = NULL;
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
 
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
+  if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
+    return E_INVALIDARG;
 
   nsAutoString descr;
-  nsresult rv = tableAcc->GetColumnDescription (aColumn, descr);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
-
+  mTable->ColDescription(aColIdx, descr);
   if (descr.IsEmpty())
     return S_FALSE;
 
   *aDescription = ::SysAllocStringLen(descr.get(), descr.Length());
   return *aDescription ? S_OK : E_OUTOFMEMORY;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
-ia2AccessibleTable::get_columnExtentAt(long aRow, long aColumn,
-                                      long* nColumnsSpanned)
+ia2AccessibleTable::get_columnExtentAt(long aRowIdx, long aColIdx,
+                                      long* aSpan)
 {
   A11Y_TRYBLOCK_BEGIN
 
-  *nColumnsSpanned = 0;
-
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
+  *aSpan = 0;
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
 
-  int32_t columnsSpanned = 0;
-  nsresult rv = tableAcc->GetColumnExtentAt(aRow, aColumn, &columnsSpanned);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
+  if (aRowIdx < 0 || aColIdx < 0 ||
+      static_cast<uint32_t>(aRowIdx) >= mTable->RowCount() ||
+      static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
+    return E_INVALIDARG;
 
-  *nColumnsSpanned = columnsSpanned;
+  *aSpan = mTable->ColExtentAt(aRowIdx, aColIdx);
   return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
 ia2AccessibleTable::get_columnHeader(IAccessibleTable** aAccessibleTable,
                                     long* aStartingRowIndex)
@@ -203,198 +146,139 @@ ia2AccessibleTable::get_columnHeader(IAc
   *aAccessibleTable = NULL;
   *aStartingRowIndex = -1;
   return E_NOTIMPL;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
-ia2AccessibleTable::get_columnIndex(long aChildIndex, long* aColumnIndex)
+ia2AccessibleTable::get_columnIndex(long aCellIdx, long* aColIdx)
 {
   A11Y_TRYBLOCK_BEGIN
 
-  *aColumnIndex = 0;
-
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
+  *aColIdx = 0;
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
 
-  int32_t columnIndex = 0;
-  nsresult rv = tableAcc->GetColumnIndexAt(aChildIndex, &columnIndex);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
+  if (aCellIdx < 0 ||
+      static_cast<uint32_t>(aCellIdx) >= mTable->ColCount() * mTable->RowCount())
+    return E_INVALIDARG;
 
-  *aColumnIndex = columnIndex;
+  *aColIdx = mTable->ColIndexAt(aCellIdx);
   return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
-ia2AccessibleTable::get_nColumns(long* aColumnCount)
+ia2AccessibleTable::get_nColumns(long* aColCount)
 {
   A11Y_TRYBLOCK_BEGIN
 
-  *aColumnCount = 0;
-
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
+  *aColCount = 0;
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
 
-  int32_t columnCount = 0;
-  nsresult rv = tableAcc->GetColumnCount(&columnCount);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
-
-  *aColumnCount = columnCount;
+  *aColCount = mTable->ColCount();
   return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
 ia2AccessibleTable::get_nRows(long* aRowCount)
 {
   A11Y_TRYBLOCK_BEGIN
 
   *aRowCount = 0;
-
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
 
-  int32_t rowCount = 0;
-  nsresult rv = tableAcc->GetRowCount(&rowCount);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
-
-  *aRowCount = rowCount;
+  *aRowCount = mTable->RowCount();
   return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
 ia2AccessibleTable::get_nSelectedChildren(long* aChildCount)
 {
-  A11Y_TRYBLOCK_BEGIN
-
-  *aChildCount = 0;
-
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
-
-  uint32_t count = 0;
-  nsresult rv = tableAcc->GetSelectedCellCount(&count);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
-
-  *aChildCount = count;
-  return S_OK;
-
-  A11Y_TRYBLOCK_END
+  return get_nSelectedCells(aChildCount);
 }
 
 STDMETHODIMP
-ia2AccessibleTable::get_nSelectedColumns(long* aColumnCount)
+ia2AccessibleTable::get_nSelectedColumns(long* aColCount)
 {
   A11Y_TRYBLOCK_BEGIN
 
-  *aColumnCount = 0;
-
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
+  *aColCount = 0;
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
 
-  uint32_t count = 0;
-  nsresult rv = tableAcc->GetSelectedColumnCount(&count);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
-
-  *aColumnCount = count;
+  *aColCount = mTable->SelectedColCount();
   return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
 ia2AccessibleTable::get_nSelectedRows(long* aRowCount)
 {
   A11Y_TRYBLOCK_BEGIN
 
   *aRowCount = 0;
-
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
 
-  uint32_t count = 0;
-  nsresult rv = tableAcc->GetSelectedRowCount(&count);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
+  *aRowCount = mTable->SelectedRowCount();
 
-  *aRowCount = count;
   return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
-ia2AccessibleTable::get_rowDescription(long aRow, BSTR* aDescription)
+ia2AccessibleTable::get_rowDescription(long aRowIdx, BSTR* aDescription)
 {
   A11Y_TRYBLOCK_BEGIN
 
   *aDescription = NULL;
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
 
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
+  if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount())
+    return E_INVALIDARG;
 
   nsAutoString descr;
-  nsresult rv = tableAcc->GetRowDescription (aRow, descr);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
-
+  mTable->RowDescription(aRowIdx, descr);
   if (descr.IsEmpty())
     return S_FALSE;
 
   *aDescription = ::SysAllocStringLen(descr.get(), descr.Length());
   return *aDescription ? S_OK : E_OUTOFMEMORY;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
-ia2AccessibleTable::get_rowExtentAt(long aRow, long aColumn,
-                                    long* aNRowsSpanned)
+ia2AccessibleTable::get_rowExtentAt(long aRowIdx, long aColIdx, long* aSpan)
 {
   A11Y_TRYBLOCK_BEGIN
 
-  *aNRowsSpanned = 0;
-
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
+  *aSpan = 0;
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
 
-  int32_t rowsSpanned = 0;
-  nsresult rv = tableAcc->GetRowExtentAt(aRow, aColumn, &rowsSpanned);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
+  if (aRowIdx < 0 || aColIdx < 0 ||
+      static_cast<uint32_t>(aRowIdx) >= mTable->RowCount() ||
+      static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
+    return E_INVALIDARG;
 
-  *aNRowsSpanned = rowsSpanned;
+  *aSpan = mTable->RowExtentAt(aRowIdx, aColIdx);
   return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
 ia2AccessibleTable::get_rowHeader(IAccessibleTable** aAccessibleTable,
                                   long* aStartingColumnIndex)
@@ -404,66 +288,79 @@ ia2AccessibleTable::get_rowHeader(IAcces
   *aAccessibleTable = NULL;
   *aStartingColumnIndex = -1;
   return E_NOTIMPL;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
-ia2AccessibleTable::get_rowIndex(long aChildIndex, long* aRowIndex)
+ia2AccessibleTable::get_rowIndex(long aCellIdx, long* aRowIdx)
 {
   A11Y_TRYBLOCK_BEGIN
 
-  *aRowIndex = 0;
-
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
+  *aRowIdx = 0;
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
 
-  int32_t rowIndex = 0;
-  nsresult rv = tableAcc->GetRowIndexAt(aChildIndex, &rowIndex);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
+  if (aCellIdx < 0 ||
+      static_cast<uint32_t>(aCellIdx) >= mTable->ColCount() * mTable->RowCount())
+    return E_INVALIDARG;
 
-  *aRowIndex = rowIndex;
+  *aRowIdx = mTable->RowIndexAt(aCellIdx);
   return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
 ia2AccessibleTable::get_selectedChildren(long aMaxChildren, long** aChildren,
                                          long* aNChildren)
 {
   A11Y_TRYBLOCK_BEGIN
 
-  return GetSelectedItems(aChildren, aNChildren, ITEMSTYPE_CELLS);
+  *aChildren = NULL;
+  *aNChildren = 0;
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
+
+  nsAutoTArray<uint32_t, 30> cellIndices;
+  mTable->SelectedCellIndices(&cellIndices);
+
+  uint32_t maxCells = cellIndices.Length();
+  if (maxCells == 0)
+    return S_FALSE;
+
+  *aChildren = static_cast<LONG*>(moz_xmalloc(sizeof(LONG) * maxCells));
+  *aNChildren = maxCells;
+  for (uint32_t i = 0; i < maxCells; i++)
+    *aChildren[i] = cellIndices[i];
+
+  return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
 ia2AccessibleTable::get_selectedColumns(long aMaxColumns, long** aColumns,
                                         long* aNColumns)
 {
   A11Y_TRYBLOCK_BEGIN
 
-  return GetSelectedItems(aColumns, aNColumns, ITEMSTYPE_COLUMNS);
+  return get_selectedColumns(aColumns, aNColumns);
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
 ia2AccessibleTable::get_selectedRows(long aMaxRows, long** aRows, long* aNRows)
 {
   A11Y_TRYBLOCK_BEGIN
 
-  return GetSelectedItems(aRows, aNRows, ITEMSTYPE_ROWS);
+  return get_selectedRows(aRows, aNRows);
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
 ia2AccessibleTable::get_summary(IUnknown** aAccessible)
 {
   A11Y_TRYBLOCK_BEGIN
@@ -475,300 +372,297 @@ ia2AccessibleTable::get_summary(IUnknown
 
   *aAccessible = NULL;
   return S_FALSE;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
-ia2AccessibleTable::get_isColumnSelected(long aColumn, boolean* aIsSelected)
+ia2AccessibleTable::get_isColumnSelected(long aColIdx, boolean* aIsSelected)
 {
   A11Y_TRYBLOCK_BEGIN
 
   *aIsSelected = false;
-
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
 
-  bool isSelected = false;
-  nsresult rv = tableAcc->IsColumnSelected(aColumn, &isSelected);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
+  if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
+    return E_INVALIDARG;
 
-  *aIsSelected = isSelected;
+  *aIsSelected = mTable->IsColSelected(aColIdx);
   return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
-ia2AccessibleTable::get_isRowSelected(long aRow, boolean* aIsSelected)
+ia2AccessibleTable::get_isRowSelected(long aRowIdx, boolean* aIsSelected)
 {
   A11Y_TRYBLOCK_BEGIN
 
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
+  *aIsSelected = false;
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
 
-  bool isSelected = false;
-  nsresult rv = tableAcc->IsRowSelected(aRow, &isSelected);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
+  if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount())
+    return E_INVALIDARG;
 
-  *aIsSelected = isSelected;
+  *aIsSelected = mTable->IsRowSelected(aRowIdx);
   return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
-ia2AccessibleTable::get_isSelected(long aRow, long aColumn,
+ia2AccessibleTable::get_isSelected(long aRowIdx, long aColIdx,
                                    boolean* aIsSelected)
 {
   A11Y_TRYBLOCK_BEGIN
 
   *aIsSelected = false;
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
 
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
+  if (aRowIdx < 0 || aColIdx < 0 ||
+      static_cast<uint32_t>(aColIdx) >= mTable->ColCount() ||
+      static_cast<uint32_t>(aRowIdx) >= mTable->RowCount())
+    return E_INVALIDARG;
+
+  *aIsSelected = mTable->IsCellSelected(aRowIdx, aColIdx);
+  return S_OK;
 
-  bool isSelected = false;
-  nsresult rv = tableAcc->IsCellSelected(aRow, aColumn, &isSelected);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
+  A11Y_TRYBLOCK_END
+}
+
+STDMETHODIMP
+ia2AccessibleTable::selectRow(long aRowIdx)
+{
+  A11Y_TRYBLOCK_BEGIN
 
-  *aIsSelected = isSelected;
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
+
+  if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount())
+    return E_INVALIDARG;
+
+  mTable->SelectRow(aRowIdx);
   return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
-ia2AccessibleTable::selectRow(long aRow)
+ia2AccessibleTable::selectColumn(long aColIdx)
 {
   A11Y_TRYBLOCK_BEGIN
 
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
 
-  nsresult rv = tableAcc->SelectRow(aRow);
-  return GetHRESULT(rv);
+  if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
+    return E_INVALIDARG;
+
+  mTable->SelectCol(aColIdx);
+  return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
-ia2AccessibleTable::selectColumn(long aColumn)
+ia2AccessibleTable::unselectRow(long aRowIdx)
 {
   A11Y_TRYBLOCK_BEGIN
 
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
-
-  nsresult rv = tableAcc->SelectColumn(aColumn);
-  return GetHRESULT(rv);
-
-  A11Y_TRYBLOCK_END
-}
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
 
-STDMETHODIMP
-ia2AccessibleTable::unselectRow(long aRow)
-{
-  A11Y_TRYBLOCK_BEGIN
+  if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount())
+    return E_INVALIDARG;
 
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
-
-  nsresult rv = tableAcc->UnselectRow(aRow);
-  return GetHRESULT(rv);
+  mTable->UnselectRow(aRowIdx);
+  return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
-ia2AccessibleTable::unselectColumn(long aColumn)
+ia2AccessibleTable::unselectColumn(long aColIdx)
 {
   A11Y_TRYBLOCK_BEGIN
 
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
 
-  nsresult rv = tableAcc->UnselectColumn(aColumn);
-  return GetHRESULT(rv);
+  if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
+    return E_INVALIDARG;
+
+  mTable->UnselectCol(aColIdx);
+  return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
-ia2AccessibleTable::get_rowColumnExtentsAtIndex(long aIndex, long* aRow,
-                                                long* aColumn,
+ia2AccessibleTable::get_rowColumnExtentsAtIndex(long aCellIdx, long* aRowIdx,
+                                                long* aColIdx,
                                                 long* aRowExtents,
-                                                long* aColumnExtents,
+                                                long* aColExtents,
                                                 boolean* aIsSelected)
 {
   A11Y_TRYBLOCK_BEGIN
 
-  *aRow = 0;
-  *aColumn = 0;
+  *aRowIdx = 0;
+  *aColIdx = 0;
   *aRowExtents = 0;
-  *aColumnExtents = 0;
+  *aColExtents = 0;
   *aIsSelected = false;
-
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
-
-  int32_t rowIdx = -1, columnIdx = -1;
-  nsresult rv = tableAcc->GetRowAndColumnIndicesAt(aIndex, &rowIdx, &columnIdx);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
 
-  int32_t rowExtents = 0;
-  rv = tableAcc->GetRowExtentAt(rowIdx, columnIdx, &rowExtents);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
-
-  int32_t columnExtents = 0;
-  rv = tableAcc->GetColumnExtentAt(rowIdx, columnIdx, &columnExtents);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
+  if (aCellIdx < 0 ||
+      static_cast<uint32_t>(aCellIdx) >= mTable->ColCount() * mTable->RowCount())
+    return E_INVALIDARG;
 
-  bool isSelected = false;
-  rv = tableAcc->IsCellSelected(rowIdx, columnIdx, &isSelected);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
+  int32_t colIdx = 0, rowIdx = 0;
+  mTable->RowAndColIndicesAt(aCellIdx, &rowIdx, &colIdx);
+  *aRowIdx = rowIdx;
+  *aColIdx = colIdx;
+  *aRowExtents = mTable->RowExtentAt(rowIdx, colIdx);
+  *aColExtents = mTable->ColExtentAt(rowIdx, colIdx);
+  *aIsSelected = mTable->IsCellSelected(rowIdx, colIdx);
 
-  *aRow = rowIdx;
-  *aColumn = columnIdx;
-  *aRowExtents = rowExtents;
-  *aColumnExtents = columnExtents;
-  *aIsSelected = isSelected;
   return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
 ia2AccessibleTable::get_modelChange(IA2TableModelChange* aModelChange)
 {
   return E_NOTIMPL;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // IAccessibleTable2
 
 STDMETHODIMP
-ia2AccessibleTable::get_cellAt(long aRow, long aColumn, IUnknown** aCell)
+ia2AccessibleTable::get_cellAt(long aRowIdx, long aColIdx, IUnknown** aCell)
 {
-  return get_accessibleAt(aRow, aColumn, aCell);
+  A11Y_TRYBLOCK_BEGIN
+
+  *aCell = NULL;
+
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
+
+  AccessibleWrap* cell =
+    static_cast<AccessibleWrap*>(mTable->CellAt(aRowIdx, aColIdx));
+  if (!cell)
+    return E_INVALIDARG;
+
+  (*aCell = static_cast<IAccessible*>(cell))->AddRef();
+  return S_OK;
+
+  A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
 ia2AccessibleTable::get_nSelectedCells(long* aCellCount)
 {
-  return get_nSelectedChildren(aCellCount);
+  A11Y_TRYBLOCK_BEGIN
+
+  *aCellCount = 0;
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
+
+  *aCellCount = mTable->SelectedCellCount();
+  return S_OK;
+
+  A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
 ia2AccessibleTable::get_selectedCells(IUnknown*** aCells, long* aNSelectedCells)
 {
   A11Y_TRYBLOCK_BEGIN
 
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
+  *aCells = NULL;
+  *aNSelectedCells = 0;
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
+
+  nsAutoTArray<Accessible*, 30> cells;
+  mTable->SelectedCells(&cells);
+  if (cells.IsEmpty())
+    return S_FALSE;
 
-  nsCOMPtr<nsIArray> geckoCells;
-  nsresult rv = tableAcc->GetSelectedCells(getter_AddRefs(geckoCells));
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
+  *aCells =
+    static_cast<IUnknown**>(::CoTaskMemAlloc(sizeof(IUnknown*) *
+                                             cells.Length()));
+  if (!*aCells)
+    return E_OUTOFMEMORY;
 
-  return nsWinUtils::ConvertToIA2Array(geckoCells, aCells, aNSelectedCells);
+  for (uint32_t i = 0; i < cells.Length(); i++) {
+    *aCells[i] =
+      static_cast<IAccessible*>(static_cast<AccessibleWrap*>(cells[i]));
+    (*aCells[i])->AddRef();
+  }
+
+  *aNSelectedCells = cells.Length();
+  return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
 ia2AccessibleTable::get_selectedColumns(long** aColumns, long* aNColumns)
 {
   A11Y_TRYBLOCK_BEGIN
 
-  return GetSelectedItems(aColumns, aNColumns, ITEMSTYPE_COLUMNS);
+  *aColumns = NULL;
+  *aNColumns = 0;
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
+
+  nsAutoTArray<uint32_t, 30> colIndices;
+  mTable->SelectedColIndices(&colIndices);
+
+  uint32_t maxCols = colIndices.Length();
+  if (maxCols == 0)
+    return S_FALSE;
+
+  *aColumns = static_cast<LONG*>(moz_xmalloc(sizeof(LONG) * maxCols));
+  *aNColumns = maxCols;
+  for (uint32_t i = 0; i < maxCols; i++)
+    *aColumns[i] = colIndices[i];
+
+  return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
 ia2AccessibleTable::get_selectedRows(long** aRows, long* aNRows)
 {
   A11Y_TRYBLOCK_BEGIN
 
-  return GetSelectedItems(aRows, aNRows, ITEMSTYPE_ROWS);
+  *aRows = NULL;
+  *aNRows = 0;
+  if (!mTable)
+    return CO_E_OBJNOTCONNECTED;
+
+  nsAutoTArray<uint32_t, 30> rowIndices;
+  mTable->SelectedRowIndices(&rowIndices);
+
+  uint32_t maxRows = rowIndices.Length();
+  if (maxRows == 0)
+    return S_FALSE;
+
+  *aRows = static_cast<LONG*>(moz_xmalloc(sizeof(LONG) * maxRows));
+  *aNRows = maxRows;
+  for (uint32_t i = 0; i < maxRows; i++)
+    *aRows[i] = rowIndices[i];
+
+  return S_OK;
 
   A11Y_TRYBLOCK_END
 }
-
-////////////////////////////////////////////////////////////////////////////////
-// ia2AccessibleTable public
-
-HRESULT
-ia2AccessibleTable::GetSelectedItems(long** aItems, long* aItemsCount,
-                                     eItemsType aType)
-{
-  *aItemsCount = 0;
-
-  nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryObject(this));
-  NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
-  if (!tableAcc)
-    return E_FAIL;
-
-  uint32_t size = 0;
-  int32_t *items = nullptr;
-
-  nsresult rv = NS_OK;
-  switch (aType) {
-    case ITEMSTYPE_CELLS:
-      rv = tableAcc->GetSelectedCellIndices(&size, &items);
-      break;
-    case ITEMSTYPE_COLUMNS:
-      rv = tableAcc->GetSelectedColumnIndices(&size, &items);
-      break;
-    case ITEMSTYPE_ROWS:
-      rv = tableAcc->GetSelectedRowIndices(&size, &items);
-      break;
-    default:
-      return E_FAIL;
-  }
-
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
-
-  if (size == 0 || !items)
-    return S_FALSE;
-
-  *aItems = static_cast<long*>(nsMemory::Alloc((size) * sizeof(long)));
-  if (!*aItems)
-    return E_OUTOFMEMORY;
-
-  *aItemsCount = size;
-  for (uint32_t index = 0; index < size; ++index)
-    (*aItems)[index] = items[index];
-
-  nsMemory::Free(items);
-  return S_OK;
-}
-
--- a/accessible/src/windows/ia2/ia2AccessibleTable.h
+++ b/accessible/src/windows/ia2/ia2AccessibleTable.h
@@ -3,21 +3,24 @@
  */
 /* 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 _ACCESSIBLE_TABLE_H
 #define _ACCESSIBLE_TABLE_H
 
-#include "nsISupports.h"
-
 #include "AccessibleTable.h"
 #include "AccessibleTable2.h"
 
+namespace mozilla {
+namespace a11y {
+
+class TableAccessible;
+
 class ia2AccessibleTable : public IAccessibleTable,
                            public IAccessibleTable2
 {
 public:
 
   // IUnknown
   STDMETHODIMP QueryInterface(REFIID, void**);
 
@@ -156,22 +159,18 @@ public:
   virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_selectedColumns(
       /* [out, size_is(,*nColumns)] */ long **selectedColumns,
       /* [out, retval] */ long *nColumns);
 
   virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_selectedRows(
       /* [out, size_is(,*nRows)] */ long **selectedRows, 
       /* [out, retval] */ long *nRows);
 
-  // nsISupports
-  NS_IMETHOD QueryInterface(const nsIID& uuid, void** result) = 0;
+protected:
+  ia2AccessibleTable(TableAccessible* aTable) : mTable(aTable) {}
 
-private:
-  enum eItemsType {
-    ITEMSTYPE_CELLS,
-    ITEMSTYPE_COLUMNS,
-    ITEMSTYPE_ROWS
-  };
-
-  HRESULT GetSelectedItems(long **aItems, long *aItemsCount, eItemsType aType);
+  TableAccessible* mTable;
 };
 
+} // namespace a11y
+} // namespace mozilla
+
 #endif