Bug 396336 - header of xul:list is not accessible, r=Evan.Yan, r=enndeakin, sr=neil, a=dsicore
authorsurkov.alexander@gmail.com
Tue, 18 Sep 2007 20:31:14 -0700
changeset 6094 a4af9853a61bf491ac3181a49db4a39727c149fb
parent 6093 e32a2fab66243eceaf437a5bc04bdcd82d6a1cfe
child 6095 6a7f74391703be778f29a1a67eff2262852e24d8
push idunknown
push userunknown
push dateunknown
reviewersEvan.Yan, enndeakin, neil, dsicore
bugs396336
milestone1.9a8pre
Bug 396336 - header of xul:list is not accessible, r=Evan.Yan, r=enndeakin, sr=neil, a=dsicore
accessible/public/nsIAccessibleProvider.idl
accessible/src/atk/nsMaiInterfaceTable.cpp
accessible/src/base/nsAccessibilityService.cpp
accessible/src/xul/nsXULSelectAccessible.cpp
accessible/src/xul/nsXULSelectAccessible.h
accessible/src/xul/nsXULTreeAccessible.cpp
accessible/src/xul/nsXULTreeAccessible.h
toolkit/content/xul.css
--- a/accessible/public/nsIAccessibleProvider.idl
+++ b/accessible/public/nsIAccessibleProvider.idl
@@ -67,16 +67,18 @@ interface nsIAccessibleProvider : nsISup
   const long XULColorPickerTile = 0x00001005;
   const long XULCombobox = 0x00001006;
   const long XULDropmarker = 0x00001007;
   const long XULGroupbox = 0x00001008;
   const long XULImage = 0x00001009;
   const long XULLink = 0x0000100A;
   const long XULListbox = 0x0000100B;
   const long XULListitem = 0x0000100C;
+  const long XULListHead = 0x00001024;
+  const long XULListHeader = 0x00001025;
   const long XULMenubar = 0x0000100D;
   const long XULMenuitem = 0x0000100E;
   const long XULMenupopup = 0x0000100F;
   const long XULMenuSeparator = 0x00001010;
   const long XULProgressMeter = 0x00001011;
   const long XULScale = 0x00001012;
   const long XULStatusBar = 0x00001013;
   const long XULRadioButton = 0x00001014;
@@ -92,17 +94,17 @@ interface nsIAccessibleProvider : nsISup
    as well */
   const long XULTabs = 0x00001018;
 
   const long XULText             = 0x00001019;
   const long XULTextBox          = 0x0000101A;
   const long XULThumb            = 0x0000101B;
   const long XULTree             = 0x0000101C;
   const long XULTreeColumns      = 0x0000101D;
-  const long XULTreeColumnitem   = 0x0000101E;
+  const long XULTreeColumnItem   = 0x0000101E;
   const long XULToolbar          = 0x0000101F;
   const long XULToolbarSeparator = 0x00001020;
   const long XULTooltip          = 0x00001021;
   const long XULToolbarButton    = 0x00001022;
 
 
   /**
    * Constants set is used by XForms elements.
--- a/accessible/src/atk/nsMaiInterfaceTable.cpp
+++ b/accessible/src/atk/nsMaiInterfaceTable.cpp
@@ -282,17 +282,17 @@ getColumnHeaderCB(AtkTable *aTable, gint
     nsresult rv = accTable->GetColumnHeader(getter_AddRefs(header));
     NS_ENSURE_SUCCESS(rv, nsnull);
     NS_ENSURE_TRUE(header, nsnull);
 
     // Note: "table column header" has different definition between atk and mai
     //
     // 1. "getColumnHeaderCB" defined in AtkTableIface should return object
     // whose role is "ATK_ROLE_TABLE_COLUMN_HEADER", which is implemented
-    // by nsXULTreeColumnitemAccessible.
+    // by nsXULTreeColumnItemAccessible.
     //
     // 2. "GetColumnHeader" defined in nsIAccessibleTable returns
     // nsXULTreeColumnsAccessibleWrap, which exports nsIAccessibleTable and is
     // "ROLE_LIST".
     nsCOMPtr<nsIAccessible> accHeader;
     header->CellRefAt(0, aColumn, getter_AddRefs(accHeader));
     NS_ENSURE_TRUE(accHeader, nsnull);
 
--- a/accessible/src/base/nsAccessibilityService.cpp
+++ b/accessible/src/base/nsAccessibilityService.cpp
@@ -1598,16 +1598,22 @@ nsresult nsAccessibilityService::GetAcce
       break;
     }
     case nsIAccessibleProvider::XULLink:
       *aAccessible = new nsXULLinkAccessible(aNode, weakShell);
       break;
     case nsIAccessibleProvider::XULListbox:
       *aAccessible = new nsXULListboxAccessible(aNode, weakShell);
       break;
+    case nsIAccessibleProvider::XULListHead:
+      *aAccessible = new nsXULColumnsAccessible(aNode, weakShell);
+      break;
+    case nsIAccessibleProvider::XULListHeader:
+      *aAccessible = new nsXULColumnItemAccessible(aNode, weakShell);
+      break;
     case nsIAccessibleProvider::XULListitem:
       *aAccessible = new nsXULListitemAccessible(aNode, weakShell);
       break;
     case nsIAccessibleProvider::XULMenubar:
       *aAccessible = new nsXULMenubarAccessible(aNode, weakShell);
       break;
     case nsIAccessibleProvider::XULMenuitem:
       *aAccessible = new nsXULMenuitemAccessibleWrap(aNode, weakShell);
@@ -1668,18 +1674,18 @@ nsresult nsAccessibilityService::GetAcce
       *aAccessible = new nsXULThumbAccessible(aNode, weakShell);
       break;
     case nsIAccessibleProvider::XULTree:
       *aAccessible = new nsXULTreeAccessibleWrap(aNode, weakShell);
       break;
     case nsIAccessibleProvider::XULTreeColumns:
       *aAccessible = new nsXULTreeColumnsAccessibleWrap(aNode, weakShell);
       break;
-    case nsIAccessibleProvider::XULTreeColumnitem:
-      *aAccessible = new nsXULTreeColumnitemAccessible(aNode, weakShell);
+    case nsIAccessibleProvider::XULTreeColumnItem:
+      *aAccessible = new nsXULColumnItemAccessible(aNode, weakShell);
       break;
     case nsIAccessibleProvider::XULToolbar:
       *aAccessible = new nsXULToolbarAccessible(aNode, weakShell);
       break;
     case nsIAccessibleProvider::XULToolbarSeparator:
       *aAccessible = new nsXULToolbarSeparatorAccessible(aNode, weakShell);
       break;
     case nsIAccessibleProvider::XULTooltip:
--- a/accessible/src/xul/nsXULSelectAccessible.cpp
+++ b/accessible/src/xul/nsXULSelectAccessible.cpp
@@ -43,34 +43,112 @@
 #include "nsIDOMXULMenuListElement.h"
 #include "nsIDOMXULSelectCntrlItemEl.h"
 #include "nsIDOMXULSelectCntrlEl.h"
 #include "nsIDOMXULTextboxElement.h"
 #include "nsIPresShell.h"
 #include "nsIServiceManager.h"
 #include "nsCaseTreatment.h"
 
-/**
-  * Selects, Listboxes and Comboboxes, are made up of a number of different
-  *  widgets, some of which are shared between the two. This file contains
-  *  all of the widgets for both of the Selects, for XUL only.
-  *  (except nsXULRadioGroupAccessible which inherits
-  *   nsXULSelectableAccessible so that it supports nsIAccessibleSelectable)
-  *
-  *  Listbox:
-  *     - nsXULListboxAccessible              <richlistbox/>
-  *         - nsXULListitemAccessible         <richlistitem/>
-  *
-  *  Comboboxes:
-  *     - nsXULComboboxAccessible             <menulist/>
-  *        - nsXULMenuAccessible              <menupopup/>
-  *            - nsXULMenuitemAccessible      <menuitem/>
-  */
+////////////////////////////////////////////////////////////////////////////////
+// nsXULColumnsAccessible
+
+nsXULColumnsAccessible::
+  nsXULColumnsAccessible(nsIDOMNode *aDOMNode, nsIWeakReference *aShell) :
+  nsAccessibleWrap(aDOMNode, aShell)
+{
+}
+
+NS_IMETHODIMP
+nsXULColumnsAccessible::GetRole(PRUint32 *aRole)
+{
+  NS_ENSURE_ARG_POINTER(aRole);
+
+  *aRole = nsIAccessibleRole::ROLE_LIST;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsXULColumnsAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
+{
+  NS_ENSURE_ARG_POINTER(aState);
+
+  if (aExtraState)
+    *aExtraState = 0;
+
+  *aState = nsIAccessibleStates::STATE_READONLY;
+  return NS_OK;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// nsXULColumnItemAccessible
+
+nsXULColumnItemAccessible::
+  nsXULColumnItemAccessible(nsIDOMNode *aDOMNode, nsIWeakReference *aShell) :
+  nsLeafAccessible(aDOMNode, aShell)
+{
+}
+
+NS_IMETHODIMP
+nsXULColumnItemAccessible::GetRole(PRUint32 *aRole)
+{
+  NS_ENSURE_ARG_POINTER(aRole);
+
+  *aRole = nsIAccessibleRole::ROLE_COLUMNHEADER;
+  return NS_OK;
+}
 
-/** ----- nsXULListboxAccessible ----- */
+NS_IMETHODIMP
+nsXULColumnItemAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
+{
+  NS_ENSURE_ARG_POINTER(aState);
+
+  if (aExtraState)
+    *aExtraState = 0;
+
+  *aState = nsIAccessibleStates::STATE_READONLY;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsXULColumnItemAccessible::GetName(nsAString& aName)
+{
+  return GetXULName(aName);
+}
+
+NS_IMETHODIMP
+nsXULColumnItemAccessible::GetNumActions(PRUint8 *aNumActions)
+{
+  NS_ENSURE_ARG_POINTER(aNumActions);
+
+  *aNumActions = 1;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsXULColumnItemAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
+{
+  if (aIndex != eAction_Click)
+    return NS_ERROR_INVALID_ARG;
+
+  aName.AssignLiteral("click");
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsXULColumnItemAccessible::DoAction(PRUint8 aIndex)
+{
+  if (aIndex != eAction_Click)
+    return NS_ERROR_INVALID_ARG;
+
+  return DoCommand();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// nsXULListboxAccessible
 
 /** Constructor */
 nsXULListboxAccessible::nsXULListboxAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell):
 nsXULSelectableAccessible(aDOMNode, aShell)
 {
 }
 
 /**
--- a/accessible/src/xul/nsXULSelectAccessible.h
+++ b/accessible/src/xul/nsXULSelectAccessible.h
@@ -35,23 +35,59 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 #ifndef __nsXULSelectAccessible_h__
 #define __nsXULSelectAccessible_h__
 
 #include "nsCOMPtr.h"
 #include "nsXULMenuAccessible.h"
+#include "nsBaseWidgetAccessible.h"
 
 class nsIWeakReference;
 
 /**
-  * Selects, Listboxes and Comboboxes, are made up of a number of different
-  *  widgets, some of which are shared between the two. This file contains 
-  *  all of the widgets for both of the Selects, for XUL only.
+ * nsXULColumnsAccessible are accessible for list and tree columns elements
+ * (xul:treecols and xul:listcols).
+ */
+class nsXULColumnsAccessible : public nsAccessibleWrap
+{
+public:
+  nsXULColumnsAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
+
+  // nsIAccessible
+  NS_IMETHOD GetRole(PRUint32 *aRole);
+  NS_IMETHOD GetState(PRUint32 *aState, PRUint32 *aExtraState);
+};
+
+/**
+ * nsXULColumnAccessible are accessibles for list and tree column elements
+ * (xul:listcol and xul:treecol).
+ */
+class nsXULColumnItemAccessible : public nsLeafAccessible
+{
+public:
+  nsXULColumnItemAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
+
+  // nsIAccessible
+  NS_IMETHOD GetRole(PRUint32 *aRole);
+  NS_IMETHOD GetName(nsAString& aName);
+  NS_IMETHOD GetState(PRUint32 *aState, PRUint32 *aExtraState);
+
+  NS_IMETHOD GetNumActions(PRUint8 *aNumActions);
+  NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
+  NS_IMETHOD DoAction(PRUint8 aIndex);
+
+  enum { eAction_Click = 0 };
+};
+
+/**
+  * Listboxes (xul:listbox) and Comboboxes (xul:menulist) are made up of a
+  * number of different widgets, some of which are shared between the two.
+  * This file contains all of the widgets for both of them, for XUL only.
   *
   *  Listbox:
   *     - nsXULListboxAccessible
   *        - nsXULSelectOptionAccessible
   *
   *  Comboboxes:
   *     - nsXULComboboxAccessible      <menulist />
   *        - nsXULMenuAccessible          <menupopup />
--- a/accessible/src/xul/nsXULTreeAccessible.cpp
+++ b/accessible/src/xul/nsXULTreeAccessible.cpp
@@ -1044,60 +1044,28 @@ NS_IMETHODIMP nsXULTreeitemAccessible::G
   } else { 
 #endif
     return nsAccessible::GetAccessibleRelated(aRelationType, aRelated);
 #ifdef MOZ_ACCESSIBILITY_ATK
   }
 #endif
 }
 
-// ---------- nsXULTreeColumnsAccessible ----------
-
-nsXULTreeColumnsAccessible::nsXULTreeColumnsAccessible(nsIDOMNode *aDOMNode, nsIWeakReference *aShell):
-nsAccessibleWrap(aDOMNode, aShell)
+////////////////////////////////////////////////////////////////////////////////
+//  nsXULTreeColumnsAccessible
+nsXULTreeColumnsAccessible::
+  nsXULTreeColumnsAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell):
+  nsXULColumnsAccessible(aDOMNode, aShell)
 {
 }
 
-NS_IMPL_ISUPPORTS_INHERITED0(nsXULTreeColumnsAccessible, nsAccessible)
-
 NS_IMETHODIMP
-nsXULTreeColumnsAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
-{
-  if (aExtraState)
-    *aExtraState = 0;
-
-  *aState = nsIAccessibleStates::STATE_READONLY;
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsXULTreeColumnsAccessible::GetRole(PRUint32 *_retval)
+nsXULTreeColumnsAccessible::GetNextSibling(nsIAccessible **aNextSibling)
 {
-  *_retval = nsIAccessibleRole::ROLE_LIST;
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsXULTreeColumnsAccessible::GetNumActions(PRUint8 *_retval)
-{
-  *_retval = 1;
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsXULTreeColumnsAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
-{
-  if (aIndex == eAction_Click) {
-    aName.AssignLiteral("click");
-    return NS_OK;
-  }
-
-  return NS_ERROR_INVALID_ARG;
-}
-
-NS_IMETHODIMP nsXULTreeColumnsAccessible::GetNextSibling(nsIAccessible **aNextSibling) 
-{
-  nsresult ret = nsAccessible::GetNextSibling(aNextSibling);
+  nsresult ret = nsXULColumnsAccessible::GetNextSibling(aNextSibling);
 
   if (*aNextSibling == nsnull) { // if there is not other sibling, use the first row as its sibling
     nsCOMPtr<nsITreeBoxObject> tree;
     nsCOMPtr<nsITreeView> treeView;
 
     nsXULTreeAccessible::GetTreeBoxObject(mDOMNode, getter_AddRefs(tree));
     if (tree) {
       tree->GetView(getter_AddRefs(treeView));
@@ -1109,78 +1077,11 @@ NS_IMETHODIMP nsXULTreeColumnsAccessible
           nsCOMPtr<nsIAccessibleTreeCache> treeCache(do_QueryInterface(mParent));
           NS_ENSURE_TRUE(treeCache, NS_ERROR_FAILURE);
           ret = treeCache->GetCachedTreeitemAccessible(0, column, aNextSibling);
         }
       }
     }
   }
 
-  return ret;  
-}
-
-NS_IMETHODIMP nsXULTreeColumnsAccessible::GetPreviousSibling(nsIAccessible **aPreviousSibling) 
-{  
-  return nsAccessible::GetPreviousSibling(aPreviousSibling);
-}
-
-NS_IMETHODIMP nsXULTreeColumnsAccessible::DoAction(PRUint8 index)
-{
-  if (index == eAction_Click)
-    return NS_OK;
-
-  return NS_ERROR_INVALID_ARG;
-}
-
-// ---------- nsXULTreeColumnitemAccessible ----------
-
-nsXULTreeColumnitemAccessible::nsXULTreeColumnitemAccessible(nsIDOMNode *aDOMNode, nsIWeakReference *aShell):
-nsLeafAccessible(aDOMNode, aShell)
-{
-}
-
-NS_IMPL_ISUPPORTS_INHERITED0(nsXULTreeColumnitemAccessible, nsLeafAccessible)
-
-NS_IMETHODIMP
-nsXULTreeColumnitemAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
-{
-  if (aExtraState)
-    *aExtraState = 0;
-
-  *aState = nsIAccessibleStates::STATE_READONLY;
-  return NS_OK;
+  return ret;
 }
 
-NS_IMETHODIMP nsXULTreeColumnitemAccessible::GetName(nsAString& _retval)
-{
-  return GetXULName(_retval);
-}
-
-NS_IMETHODIMP nsXULTreeColumnitemAccessible::GetRole(PRUint32 *_retval)
-{
-  *_retval = nsIAccessibleRole::ROLE_COLUMNHEADER;
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsXULTreeColumnitemAccessible::GetNumActions(PRUint8 *_retval)
-{
-  *_retval = 1;
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsXULTreeColumnitemAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
-{
-  if (aIndex == eAction_Click) {
-    aName.AssignLiteral("click");
-    return NS_OK;
-  }
-
-  return NS_ERROR_INVALID_ARG;
-}
-
-NS_IMETHODIMP nsXULTreeColumnitemAccessible::DoAction(PRUint8 index)
-{
-  if (index == eAction_Click) {
-    return DoCommand();
-  }
-
-  return NS_ERROR_INVALID_ARG;
-}
--- a/accessible/src/xul/nsXULTreeAccessible.h
+++ b/accessible/src/xul/nsXULTreeAccessible.h
@@ -33,17 +33,16 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 #ifndef __nsXULTreeAccessible_h__
 #define __nsXULTreeAccessible_h__
 
-#include "nsBaseWidgetAccessible.h"
 #include "nsITreeBoxObject.h"
 #include "nsITreeView.h"
 #include "nsITreeColumns.h"
 #include "nsXULSelectAccessible.h"
 #include "nsIAccessibleTreeCache.h"
 
 
 /*
@@ -130,51 +129,18 @@ public:
 protected:
   PRBool IsExpandable();
   nsCOMPtr<nsITreeBoxObject> mTree;
   nsCOMPtr<nsITreeView> mTreeView;
   PRInt32 mRow;
   nsCOMPtr<nsITreeColumn> mColumn;
 };
 
-class nsXULTreeColumnsAccessible : public nsAccessibleWrap
+class nsXULTreeColumnsAccessible : public nsXULColumnsAccessible
 {
 public:
-  enum { eAction_Click = 0 };
-
-  NS_DECL_ISUPPORTS_INHERITED
-
   nsXULTreeColumnsAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
-  virtual ~nsXULTreeColumnsAccessible() {}
-
-  /* ----- nsIAccessible ----- */
-  NS_IMETHOD GetRole(PRUint32 *_retval);
-  NS_IMETHOD GetState(PRUint32 *aState, PRUint32 *aExtraState);
-  NS_IMETHOD GetNumActions(PRUint8 *_retval);
-  NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
-
-  NS_IMETHOD GetNextSibling(nsIAccessible **_retval); 
-  NS_IMETHOD GetPreviousSibling(nsIAccessible **_retval); 
-
-  NS_IMETHOD DoAction(PRUint8 index);
-};
 
-class nsXULTreeColumnitemAccessible : public nsLeafAccessible
-{
-public:
-  enum { eAction_Click = 0 };
-
-  NS_DECL_ISUPPORTS_INHERITED
-
-  nsXULTreeColumnitemAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
-  virtual ~nsXULTreeColumnitemAccessible() {}
-
-  /* ----- nsIAccessible ----- */
-  NS_IMETHOD GetName(nsAString& _retval);
-  NS_IMETHOD GetRole(PRUint32 *_retval);
-  NS_IMETHOD GetState(PRUint32 *aState, PRUint32 *aExtraState);
-  NS_IMETHOD GetNumActions(PRUint8 *_retval);
-  NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
-
-  NS_IMETHOD DoAction(PRUint8 index);
+  // nsIAccessible
+  NS_IMETHOD GetNextSibling(nsIAccessible **aNextSibling);
 };
 
 #endif
--- a/toolkit/content/xul.css
+++ b/toolkit/content/xul.css
@@ -421,20 +421,16 @@ column {
 }
 
 /******** listbox **********/
 
 listbox {
   -moz-binding: url("chrome://global/content/bindings/listbox.xml#listbox");
 }
 
-listcols, listcol {
-  -moz-binding: url("chrome://global/content/bindings/listbox.xml#listbox-base");
-}
-
 listhead {
   -moz-binding: url("chrome://global/content/bindings/listbox.xml#listhead");
 }
 
 listrows {
   -moz-binding: url("chrome://global/content/bindings/listbox.xml#listrows");
 }