bug 777117 - add table cell accessible interface r=davidb
authorTrevor Saunders <trev.saunders@gmail.com>
Tue, 24 Jul 2012 11:58:25 -0400
changeset 101205 4c8cfae37b567acd295bbf7662431d00c8922708
parent 101204 ffc57e09995e050a1af0b9845c794559ecef365f
child 101206 23460a801bb64264122cbbd71b87916d5e89f7ce
child 101232 b5c4b792f3f2a047e3517472d72842a76afb77cd
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersdavidb
bugs777117, 100644
milestone17.0a1
bug 777117 - add table cell accessible interface r=davidb From 5d763ba823c357e2023c0e8b4ee6c7c173433d23 Mon Sep 17 00:00:00 2001 --- accessible/src/generic/ARIAGridAccessible.cpp | 9 +++- accessible/src/generic/ARIAGridAccessible.h | 9 +++- accessible/src/generic/TableCellAccessible.h | 71 +++++++++++++++++++++++++ accessible/src/html/HTMLTableAccessible.cpp | 9 +++- accessible/src/html/HTMLTableAccessible.h | 9 +++- accessible/src/xpcom/xpcAccessibleTableCell.h | 37 +++++++++++++ accessible/src/xul/XULListboxAccessible.cpp | 9 +++- accessible/src/xul/XULListboxAccessible.h | 9 +++- accessible/src/xul/XULTreeGridAccessible.cpp | 9 +++- accessible/src/xul/XULTreeGridAccessible.h | 9 +++- 10 files changed, 168 insertions(+), 12 deletions(-) create mode 100644 accessible/src/generic/TableCellAccessible.h create mode 100644 accessible/src/xpcom/xpcAccessibleTableCell.h
accessible/src/generic/ARIAGridAccessible.cpp
accessible/src/generic/ARIAGridAccessible.h
accessible/src/generic/TableCellAccessible.h
accessible/src/html/HTMLTableAccessible.cpp
accessible/src/html/HTMLTableAccessible.h
accessible/src/xpcom/xpcAccessibleTableCell.h
accessible/src/xul/XULListboxAccessible.cpp
accessible/src/xul/XULListboxAccessible.h
accessible/src/xul/XULTreeGridAccessible.cpp
accessible/src/xul/XULTreeGridAccessible.h
--- a/accessible/src/generic/ARIAGridAccessible.cpp
+++ b/accessible/src/generic/ARIAGridAccessible.cpp
@@ -526,17 +526,17 @@ ARIAGridAccessible::SetARIASelected(Acce
 ////////////////////////////////////////////////////////////////////////////////
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // Constructor
 
 ARIAGridCellAccessible::
   ARIAGridCellAccessible(nsIContent* aContent, DocAccessible* aDoc) :
-  HyperTextAccessibleWrap(aContent, aDoc)
+  HyperTextAccessibleWrap(aContent, aDoc), xpcAccessibleTableCell(this)
 {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsISupports
 
 NS_IMPL_ISUPPORTS_INHERITED1(ARIAGridCellAccessible,
                              HyperTextAccessible,
@@ -784,8 +784,15 @@ ARIAGridCellAccessible::GetAttributesInt
 
   nsAutoString stringIdx;
   stringIdx.AppendInt(idx);
   nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::tableCellIndex,
                          stringIdx);
 
   return NS_OK;
 }
+
+void
+ARIAGridCellAccessible::Shutdown()
+{
+  mTableCell = nsnull;
+  HyperTextAccessibleWrap::Shutdown();
+}
--- a/accessible/src/generic/ARIAGridAccessible.h
+++ b/accessible/src/generic/ARIAGridAccessible.h
@@ -5,17 +5,19 @@
 
 #ifndef MOZILLA_A11Y_ARIAGridAccessible_h_
 #define MOZILLA_A11Y_ARIAGridAccessible_h_
 
 #include "nsIAccessibleTable.h"
 
 #include "HyperTextAccessibleWrap.h"
 #include "TableAccessible.h"
+#include "TableCellAccessible.h"
 #include "xpcAccessibleTable.h"
+#include "xpcAccessibleTableCell.h"
 
 namespace mozilla {
 namespace a11y {
 
 /**
  * Accessible for ARIA grid and treegrid.
  */
 class ARIAGridAccessible : public AccessibleWrap,
@@ -90,28 +92,31 @@ protected:
                            bool aNotify = true);
 };
 
 
 /**
  * Accessible for ARIA gridcell and rowheader/columnheader.
  */
 class ARIAGridCellAccessible : public HyperTextAccessibleWrap,
-                               public nsIAccessibleTableCell
+                               public nsIAccessibleTableCell,
+                               public TableCellAccessible,
+                               public xpcAccessibleTableCell
 {
 public:
   ARIAGridCellAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIAccessibleTableCell
-  NS_DECL_NSIACCESSIBLETABLECELL
+  NS_DECL_OR_FORWARD_NSIACCESSIBLETABLECELL_WITH_XPCACCESSIBLETABLECELL
 
   // Accessible
+  virtual void Shutdown();
   virtual void ApplyARIAState(PRUint64* aState) const;
   virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
 };
 
 } // namespace a11y
 } // namespace mozilla
 
 #endif
new file mode 100644
--- /dev/null
+++ b/accessible/src/generic/TableCellAccessible.h
@@ -0,0 +1,71 @@
+/* -*- 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_TableCellAccessible_h__
+#define mozilla_a11y_TableCellAccessible_h__
+
+#include "nsTArray.h"
+#include "mozilla/StandardInteger.h"
+
+class Accessible;
+
+namespace mozilla {
+namespace a11y {
+
+  class TableAccessible;
+
+/**
+ * abstract interface implemented by table cell accessibles.
+ */
+class TableCellAccessible
+{
+public:
+
+  /**
+   * Return the table this cell is in.
+   */
+  virtual TableAccessible* Table() { return nullptr; }
+
+  /**
+   * Return the Column of the table this cell is in.
+   */
+  virtual uint32_t ColIdx() { return 0; }
+
+  /**
+   * Return the the row of the table this cell is in.
+   */
+  virtual uint32_t RowIdx() { return 0; }
+
+  /**
+   * Return the column extent of this cell.
+   */
+  virtual uint32_t ColExtent() { return 0; }
+
+  /**
+   * Return the row extent of this cell.
+   */
+  virtual uint32_t RowExtent() { return 0; }
+
+  /**
+   * Return the column header cells for this cell.
+   */
+  virtual void ColHeaderCells(nsTArray<Accessible*>* aCells) { }
+
+  /**
+   * Return the row header cells for this cell.
+   */
+  virtual void RowHeaderCells(nsTArray<Accessible*>* aCells) { }
+
+  /**
+   * Returns true if this cell is selected.
+   */
+  virtual bool Selected() { return false; }
+};
+
+}
+}
+
+#endif // mozilla_a11y_TableCellAccessible_h__
--- a/accessible/src/html/HTMLTableAccessible.cpp
+++ b/accessible/src/html/HTMLTableAccessible.cpp
@@ -40,30 +40,37 @@ using namespace mozilla;
 using namespace mozilla::a11y;
 
 ////////////////////////////////////////////////////////////////////////////////
 // HTMLTableCellAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 HTMLTableCellAccessible::
   HTMLTableCellAccessible(nsIContent* aContent, DocAccessible* aDoc) :
-  HyperTextAccessibleWrap(aContent, aDoc)
+  HyperTextAccessibleWrap(aContent, aDoc), xpcAccessibleTableCell(this)
 {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // HTMLTableCellAccessible: nsISupports implementation
 
 NS_IMPL_ISUPPORTS_INHERITED1(HTMLTableCellAccessible,
                              HyperTextAccessible,
                              nsIAccessibleTableCell)
 
 ////////////////////////////////////////////////////////////////////////////////
 // HTMLTableCellAccessible: Accessible implementation
 
+  void
+  HTMLTableCellAccessible::Shutdown()
+{
+  mTableCell = nsnull;
+  HyperTextAccessibleWrap::Shutdown();
+}
+
 role
 HTMLTableCellAccessible::NativeRole()
 {
   return roles::CELL;
 }
 
 PRUint64
 HTMLTableCellAccessible::NativeState()
--- a/accessible/src/html/HTMLTableAccessible.h
+++ b/accessible/src/html/HTMLTableAccessible.h
@@ -4,40 +4,45 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_a11y_HTMLTableAccessible_h__
 #define mozilla_a11y_HTMLTableAccessible_h__
 
 #include "HyperTextAccessibleWrap.h"
 #include "nsIAccessibleTable.h"
 #include "TableAccessible.h"
+#include "TableCellAccessible.h"
 #include "xpcAccessibleTable.h"
+#include "xpcAccessibleTableCell.h"
 
 class nsITableLayout;
 class nsITableCellLayout;
 
 namespace mozilla {
 namespace a11y {
 
 /**
  * HTML table cell accessible (html:td).
  */
 class HTMLTableCellAccessible : public HyperTextAccessibleWrap,
-                                public nsIAccessibleTableCell
+                                public nsIAccessibleTableCell,
+                                public TableCellAccessible,
+                                public xpcAccessibleTableCell
 {
 public:
   HTMLTableCellAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIAccessibleTableCell
-  NS_DECL_NSIACCESSIBLETABLECELL
+  NS_DECL_OR_FORWARD_NSIACCESSIBLETABLECELL_WITH_XPCACCESSIBLETABLECELL
 
   // Accessible
+  virtual void Shutdown();
   virtual a11y::role NativeRole();
   virtual PRUint64 NativeState();
   virtual PRUint64 NativeInteractiveState() const;
   virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
 
 protected:
   /**
    * Return host table accessible.
new file mode 100644
--- /dev/null
+++ b/accessible/src/xpcom/xpcAccessibleTableCell.h
@@ -0,0 +1,37 @@
+/* -*- 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_XPCOM_XPACESSIBLETABLECELL_H_
+#define MOZILLA_A11Y_XPCOM_XPACESSIBLETABLECELL_H_
+
+namespace mozilla {
+namespace a11y {
+class TableAccessible;
+class TableCellAccessible;
+}
+}
+
+class xpcAccessibleTableCell
+{
+public:
+  xpcAccessibleTableCell(mozilla::a11y::TableCellAccessible* aTableCell) :
+    mTableCell(aTableCell) { }
+
+protected:
+  mozilla::a11y::TableCellAccessible* mTableCell;
+};
+
+#define NS_DECL_OR_FORWARD_NSIACCESSIBLETABLECELL_WITH_XPCACCESSIBLETABLECELL \
+  NS_IMETHOD GetTable(nsIAccessibleTable * *aTable); \
+  NS_IMETHOD GetColumnIndex(PRInt32 *aColumnIndex); \
+  NS_IMETHOD GetRowIndex(PRInt32 *aRowIndex); \
+  NS_IMETHOD GetColumnExtent(PRInt32 *aColumnExtent); \
+  NS_IMETHOD GetRowExtent(PRInt32 *aRowExtent); \
+  NS_IMETHOD GetColumnHeaderCells(nsIArray * *aColumnHeaderCells); \
+  NS_IMETHOD GetRowHeaderCells(nsIArray * *aRowHeaderCells); \
+  NS_IMETHOD IsSelected(bool *_retval ); 
+
+#endif // MOZILLA_A11Y_XPCOM_XPACESSIBLETABLECELL_H_
--- a/accessible/src/xul/XULListboxAccessible.cpp
+++ b/accessible/src/xul/XULListboxAccessible.cpp
@@ -722,17 +722,17 @@ XULListitemAccessible::ContainerWidget()
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULListCellAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 XULListCellAccessible::
   XULListCellAccessible(nsIContent* aContent, DocAccessible* aDoc) :
-  HyperTextAccessibleWrap(aContent, aDoc)
+  HyperTextAccessibleWrap(aContent, aDoc), xpcAccessibleTableCell(this)
 {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsISupports
 
 NS_IMPL_ISUPPORTS_INHERITED1(XULListCellAccessible,
                              HyperTextAccessible,
@@ -929,16 +929,23 @@ XULListCellAccessible::IsSelected(bool* 
   GetRowIndex(&rowIdx);
 
   return table->IsRowSelected(rowIdx, aIsSelected);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULListCellAccessible. Accessible implementation
 
+void
+XULListCellAccessible::Shutdown()
+{
+  mTableCell = nsnull;
+  HyperTextAccessibleWrap::Shutdown();
+}
+
 role
 XULListCellAccessible::NativeRole()
 {
   return roles::CELL;
 }
 
 nsresult
 XULListCellAccessible::GetAttributesInternal(nsIPersistentProperties* aAttributes)
--- a/accessible/src/xul/XULListboxAccessible.h
+++ b/accessible/src/xul/XULListboxAccessible.h
@@ -4,17 +4,19 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_a11y_XULListboxAccessible_h__
 #define mozilla_a11y_XULListboxAccessible_h__
 
 #include "BaseAccessibles.h"
 #include "nsIAccessibleTable.h"
 #include "TableAccessible.h"
+#include "TableCellAccessible.h"
 #include "xpcAccessibleTable.h"
+#include "xpcAccessibleTableCell.h"
 #include "XULMenuAccessible.h"
 #include "XULSelectControlAccessible.h"
 
 class nsIWeakReference;
 
 namespace mozilla {
 namespace a11y {
 
@@ -146,28 +148,31 @@ protected:
 private:
   bool mIsCheckbox;
 };
 
 /**
  * Class represents xul:listcell.
  */
 class XULListCellAccessible : public HyperTextAccessibleWrap,
-                              public nsIAccessibleTableCell
+                              public nsIAccessibleTableCell,
+                              public TableCellAccessible,
+                              public xpcAccessibleTableCell
 {
 public:
   XULListCellAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIAccessibleTableCell
-  NS_DECL_NSIACCESSIBLETABLECELL
+  NS_DECL_OR_FORWARD_NSIACCESSIBLETABLECELL_WITH_XPCACCESSIBLETABLECELL
 
   // Accessible
+  virtual void Shutdown();
   virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
   virtual a11y::role NativeRole();
 };
 
 } // namespace a11y
 } // namespace mozilla
 
 #endif
--- a/accessible/src/xul/XULTreeGridAccessible.cpp
+++ b/accessible/src/xul/XULTreeGridAccessible.cpp
@@ -459,17 +459,17 @@ XULTreeGridRowAccessible::CacheChildren(
 // XULTreeGridCellAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 XULTreeGridCellAccessible::
   XULTreeGridCellAccessible(nsIContent* aContent, DocAccessible* aDoc,
                             XULTreeGridRowAccessible* aRowAcc,
                             nsITreeBoxObject* aTree, nsITreeView* aTreeView,
                             PRInt32 aRow, nsITreeColumn* aColumn) :
-  LeafAccessible(aContent, aDoc), mTree(aTree),
+  LeafAccessible(aContent, aDoc), xpcAccessibleTableCell(this), mTree(aTree),
   mTreeView(aTreeView), mRow(aRow), mColumn(aColumn)
 {
   mParent = aRowAcc;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeGridCellAccessible: nsISupports implementation
 
@@ -493,16 +493,23 @@ NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION
                                 XULTreeGridCellAccessible)
 NS_INTERFACE_TABLE_TAIL_INHERITING(LeafAccessible)
 NS_IMPL_ADDREF_INHERITED(XULTreeGridCellAccessible, LeafAccessible)
 NS_IMPL_RELEASE_INHERITED(XULTreeGridCellAccessible, LeafAccessible)
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeGridCellAccessible: nsIAccessible implementation
 
+  void
+  XULTreeGridCellAccessible::Shutdown()
+{
+  mTableCell = nsnull;
+  LeafAccessible::Shutdown();
+}
+
 Accessible*
 XULTreeGridCellAccessible::FocusedChild()
 {
   return nsnull;
 }
 
 ENameValueFlag
 XULTreeGridCellAccessible::Name(nsString& aName)
--- a/accessible/src/xul/XULTreeGridAccessible.h
+++ b/accessible/src/xul/XULTreeGridAccessible.h
@@ -3,17 +3,19 @@
  * 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_XULTreeGridAccessible_h__
 #define mozilla_a11y_XULTreeGridAccessible_h__
 
 #include "XULTreeAccessible.h"
 #include "TableAccessible.h"
+#include "TableCellAccessible.h"
 #include "xpcAccessibleTable.h"
+#include "xpcAccessibleTableCell.h"
 
 namespace mozilla {
 namespace a11y {
 
 /**
  * Represents accessible for XUL tree in the case when it has multiple columns.
  */
 class XULTreeGridAccessible : public XULTreeAccessible,
@@ -115,17 +117,19 @@ protected:
 {  /* 84588ad4-549c-4196-a932-4c5ca5de5dff */         \
   0x84588ad4,                                         \
   0x549c,                                             \
   0x4196,                                             \
   { 0xa9, 0x32, 0x4c, 0x5c, 0xa5, 0xde, 0x5d, 0xff }  \
 }
 
 class XULTreeGridCellAccessible : public LeafAccessible,
-                                  public nsIAccessibleTableCell
+                                  public nsIAccessibleTableCell,
+                                  public TableCellAccessible,
+                                  public xpcAccessibleTableCell
 {
 public:
 
   XULTreeGridCellAccessible(nsIContent* aContent, DocAccessible* aDoc,
                             XULTreeGridRowAccessible* aRowAcc,
                             nsITreeBoxObject* aTree, nsITreeView* aTreeView,
                             PRInt32 aRow, nsITreeColumn* aColumn);
 
@@ -138,23 +142,24 @@ public:
 
   NS_IMETHOD GetBounds(PRInt32* aX, PRInt32* aY,
                        PRInt32* aWidth, PRInt32* aHeight);
 
   NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
   NS_IMETHOD DoAction(PRUint8 aIndex);
 
   // nsIAccessibleTableCell
-  NS_DECL_NSIACCESSIBLETABLECELL
+  NS_DECL_OR_FORWARD_NSIACCESSIBLETABLECELL_WITH_XPCACCESSIBLETABLECELL
 
   // nsAccessNode
   virtual bool Init();
   virtual bool IsPrimaryForNode() const;
 
   // Accessible
+  virtual void Shutdown();
   virtual ENameValueFlag Name(nsString& aName);
   virtual Accessible* FocusedChild();
   virtual nsresult GetAttributesInternal(nsIPersistentProperties* aAttributes);
   virtual PRInt32 IndexInParent() const;
   virtual Relation RelationByType(PRUint32 aType);
   virtual a11y::role NativeRole();
   virtual PRUint64 NativeState();
   virtual PRUint64 NativeInteractiveState() const;