Bug 467139 - NameFromSubtree rule should be based on role, r=aaronlev, marcoz, davidb, sr=neil

This commit is contained in:
Alexander Surkov 2008-12-03 15:18:41 +08:00
Родитель 2272dd26f2
Коммит 7310d2896f
17 изменённых файлов: 268 добавлений и 128 удалений

Просмотреть файл

@ -81,6 +81,7 @@ CPPSRCS = \
nsAccessibilityAtoms.cpp \ nsAccessibilityAtoms.cpp \
nsCoreUtils.cpp \ nsCoreUtils.cpp \
nsAccUtils.cpp \ nsAccUtils.cpp \
nsNameUtils.cpp \
nsAccessibilityService.cpp \ nsAccessibilityService.cpp \
nsAccessible.cpp \ nsAccessible.cpp \
nsAccessibleRelation.cpp \ nsAccessibleRelation.cpp \

Просмотреть файл

@ -63,7 +63,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"alert", "alert",
nsIAccessibleRole::ROLE_ALERT, nsIAccessibleRole::ROLE_ALERT,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -72,7 +71,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"alertdialog", "alertdialog",
nsIAccessibleRole::ROLE_ALERT, nsIAccessibleRole::ROLE_ALERT,
eNameOkFromChildren,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -81,7 +79,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"application", "application",
nsIAccessibleRole::ROLE_APPLICATION, nsIAccessibleRole::ROLE_APPLICATION,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -90,7 +87,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"article", "article",
nsIAccessibleRole::ROLE_DOCUMENT, nsIAccessibleRole::ROLE_DOCUMENT,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -99,7 +95,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"button", "button",
nsIAccessibleRole::ROLE_PUSHBUTTON, nsIAccessibleRole::ROLE_PUSHBUTTON,
eNameOkFromChildren,
eNoValue, eNoValue,
eClickAction, eClickAction,
kNoReqStates, kNoReqStates,
@ -110,7 +105,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"checkbox", "checkbox",
nsIAccessibleRole::ROLE_CHECKBUTTON, nsIAccessibleRole::ROLE_CHECKBUTTON,
eNameOkFromChildren,
eNoValue, eNoValue,
eCheckUncheckAction, eCheckUncheckAction,
nsIAccessibleStates::STATE_CHECKABLE, nsIAccessibleStates::STATE_CHECKABLE,
@ -122,7 +116,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"columnheader", "columnheader",
nsIAccessibleRole::ROLE_COLUMNHEADER, nsIAccessibleRole::ROLE_COLUMNHEADER,
eNameOkFromChildren,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -134,7 +127,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"combobox", "combobox",
nsIAccessibleRole::ROLE_COMBOBOX, nsIAccessibleRole::ROLE_COMBOBOX,
eNameLabelOrTitle,
eHasValueMinMax, eHasValueMinMax,
eOpenCloseAction, eOpenCloseAction,
nsIAccessibleStates::STATE_COLLAPSED | nsIAccessibleStates::STATE_HASPOPUP, nsIAccessibleStates::STATE_COLLAPSED | nsIAccessibleStates::STATE_HASPOPUP,
@ -146,7 +138,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"description", "description",
nsIAccessibleRole::ROLE_TEXT_CONTAINER, nsIAccessibleRole::ROLE_TEXT_CONTAINER,
eNameOkFromChildren,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -155,7 +146,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"dialog", "dialog",
nsIAccessibleRole::ROLE_DIALOG, nsIAccessibleRole::ROLE_DIALOG,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -164,7 +154,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"document", "document",
nsIAccessibleRole::ROLE_DOCUMENT, nsIAccessibleRole::ROLE_DOCUMENT,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -173,7 +162,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"grid", "grid",
nsIAccessibleRole::ROLE_TABLE, nsIAccessibleRole::ROLE_TABLE,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
nsIAccessibleStates::STATE_FOCUSABLE, nsIAccessibleStates::STATE_FOCUSABLE,
@ -184,7 +172,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"gridcell", "gridcell",
nsIAccessibleRole::ROLE_CELL, nsIAccessibleRole::ROLE_CELL,
eNameOkFromChildren,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -198,7 +185,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"group", "group",
nsIAccessibleRole::ROLE_GROUPING, nsIAccessibleRole::ROLE_GROUPING,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -207,7 +193,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"heading", "heading",
nsIAccessibleRole::ROLE_HEADING, nsIAccessibleRole::ROLE_HEADING,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -216,7 +201,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"img", "img",
nsIAccessibleRole::ROLE_GRAPHIC, nsIAccessibleRole::ROLE_GRAPHIC,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -225,7 +209,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"label", "label",
nsIAccessibleRole::ROLE_LABEL, nsIAccessibleRole::ROLE_LABEL,
eNameOkFromChildren,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -234,7 +217,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"link", "link",
nsIAccessibleRole::ROLE_LINK, nsIAccessibleRole::ROLE_LINK,
eNameOkFromChildren,
eNoValue, eNoValue,
eJumpAction, eJumpAction,
nsIAccessibleStates::STATE_LINKED, nsIAccessibleStates::STATE_LINKED,
@ -243,7 +225,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"list", "list",
nsIAccessibleRole::ROLE_LIST, nsIAccessibleRole::ROLE_LIST,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
nsIAccessibleStates::STATE_READONLY, nsIAccessibleStates::STATE_READONLY,
@ -253,7 +234,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"listbox", "listbox",
nsIAccessibleRole::ROLE_LISTBOX, nsIAccessibleRole::ROLE_LISTBOX,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -264,7 +244,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"listitem", "listitem",
nsIAccessibleRole::ROLE_LISTITEM, nsIAccessibleRole::ROLE_LISTITEM,
eNameOkFromChildren,
eNoValue, eNoValue,
eNoAction, // XXX: should depend on state, parent accessible eNoAction, // XXX: should depend on state, parent accessible
nsIAccessibleStates::STATE_READONLY, nsIAccessibleStates::STATE_READONLY,
@ -278,7 +257,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"math", "math",
nsIAccessibleRole::ROLE_FLAT_EQUATION, nsIAccessibleRole::ROLE_FLAT_EQUATION,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -287,7 +265,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"menu", "menu",
nsIAccessibleRole::ROLE_MENUPOPUP, nsIAccessibleRole::ROLE_MENUPOPUP,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, // XXX: technically accessibles of menupopup role haven't eNoAction, // XXX: technically accessibles of menupopup role haven't
// any action, but menu can be open or close. // any action, but menu can be open or close.
@ -297,7 +274,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"menubar", "menubar",
nsIAccessibleRole::ROLE_MENUBAR, nsIAccessibleRole::ROLE_MENUBAR,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -306,7 +282,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"menuitem", "menuitem",
nsIAccessibleRole::ROLE_MENUITEM, nsIAccessibleRole::ROLE_MENUITEM,
eNameOkFromChildren,
eNoValue, eNoValue,
eClickAction, eClickAction,
kNoReqStates, kNoReqStates,
@ -318,7 +293,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"menuitemcheckbox", "menuitemcheckbox",
nsIAccessibleRole::ROLE_CHECK_MENU_ITEM, nsIAccessibleRole::ROLE_CHECK_MENU_ITEM,
eNameOkFromChildren,
eNoValue, eNoValue,
eClickAction, eClickAction,
nsIAccessibleStates::STATE_CHECKABLE, nsIAccessibleStates::STATE_CHECKABLE,
@ -329,7 +303,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"menuitemradio", "menuitemradio",
nsIAccessibleRole::ROLE_RADIO_MENU_ITEM, nsIAccessibleRole::ROLE_RADIO_MENU_ITEM,
eNameOkFromChildren,
eNoValue, eNoValue,
eClickAction, eClickAction,
nsIAccessibleStates::STATE_CHECKABLE, nsIAccessibleStates::STATE_CHECKABLE,
@ -339,7 +312,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"option", "option",
nsIAccessibleRole::ROLE_OPTION, nsIAccessibleRole::ROLE_OPTION,
eNameOkFromChildren,
eNoValue, eNoValue,
eSelectAction, eSelectAction,
kNoReqStates, kNoReqStates,
@ -353,7 +325,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"presentation", "presentation",
nsIAccessibleRole::ROLE_NOTHING, nsIAccessibleRole::ROLE_NOTHING,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -362,7 +333,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"progressbar", "progressbar",
nsIAccessibleRole::ROLE_PROGRESSBAR, nsIAccessibleRole::ROLE_PROGRESSBAR,
eNameLabelOrTitle,
eHasValueMinMax, eHasValueMinMax,
eNoAction, eNoAction,
nsIAccessibleStates::STATE_READONLY, nsIAccessibleStates::STATE_READONLY,
@ -371,7 +341,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"radio", "radio",
nsIAccessibleRole::ROLE_RADIOBUTTON, nsIAccessibleRole::ROLE_RADIOBUTTON,
eNameOkFromChildren,
eNoValue, eNoValue,
eSelectAction, eSelectAction,
kNoReqStates, kNoReqStates,
@ -381,7 +350,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"radiogroup", "radiogroup",
nsIAccessibleRole::ROLE_GROUPING, nsIAccessibleRole::ROLE_GROUPING,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -390,7 +358,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"region", "region",
nsIAccessibleRole::ROLE_PANE, nsIAccessibleRole::ROLE_PANE,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -399,7 +366,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"row", "row",
nsIAccessibleRole::ROLE_ROW, nsIAccessibleRole::ROLE_ROW,
eNameOkFromChildren,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -412,7 +378,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"rowheader", "rowheader",
nsIAccessibleRole::ROLE_ROWHEADER, nsIAccessibleRole::ROLE_ROWHEADER,
eNameOkFromChildren,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -424,7 +389,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"section", "section",
nsIAccessibleRole::ROLE_SECTION, nsIAccessibleRole::ROLE_SECTION,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -433,7 +397,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"separator", "separator",
nsIAccessibleRole::ROLE_SEPARATOR, nsIAccessibleRole::ROLE_SEPARATOR,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -442,7 +405,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"slider", "slider",
nsIAccessibleRole::ROLE_SLIDER, nsIAccessibleRole::ROLE_SLIDER,
eNameLabelOrTitle,
eHasValueMinMax, eHasValueMinMax,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -452,7 +414,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"spinbutton", "spinbutton",
nsIAccessibleRole::ROLE_SPINBUTTON, nsIAccessibleRole::ROLE_SPINBUTTON,
eNameLabelOrTitle,
eHasValueMinMax, eHasValueMinMax,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -462,7 +423,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"status", "status",
nsIAccessibleRole::ROLE_STATUSBAR, nsIAccessibleRole::ROLE_STATUSBAR,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -471,7 +431,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"tab", "tab",
nsIAccessibleRole::ROLE_PAGETAB, nsIAccessibleRole::ROLE_PAGETAB,
eNameOkFromChildren,
eNoValue, eNoValue,
eSwitchAction, eSwitchAction,
kNoReqStates, kNoReqStates,
@ -480,7 +439,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"tablist", "tablist",
nsIAccessibleRole::ROLE_PAGETABLIST, nsIAccessibleRole::ROLE_PAGETABLIST,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -489,7 +447,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"tabpanel", "tabpanel",
nsIAccessibleRole::ROLE_PROPERTYPAGE, nsIAccessibleRole::ROLE_PROPERTYPAGE,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -498,7 +455,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"textbox", "textbox",
nsIAccessibleRole::ROLE_ENTRY, nsIAccessibleRole::ROLE_ENTRY,
eNameLabelOrTitle,
eNoValue, eNoValue,
eActivateAction, eActivateAction,
kNoReqStates, kNoReqStates,
@ -512,7 +468,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"toolbar", "toolbar",
nsIAccessibleRole::ROLE_TOOLBAR, nsIAccessibleRole::ROLE_TOOLBAR,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -521,7 +476,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"tooltip", "tooltip",
nsIAccessibleRole::ROLE_TOOLTIP, nsIAccessibleRole::ROLE_TOOLTIP,
eNameOkFromChildren,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -530,7 +484,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"tree", "tree",
nsIAccessibleRole::ROLE_OUTLINE, nsIAccessibleRole::ROLE_OUTLINE,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -541,7 +494,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"treegrid", "treegrid",
nsIAccessibleRole::ROLE_TREE_TABLE, nsIAccessibleRole::ROLE_TREE_TABLE,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -552,7 +504,6 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
{ {
"treeitem", "treeitem",
nsIAccessibleRole::ROLE_OUTLINEITEM, nsIAccessibleRole::ROLE_OUTLINEITEM,
eNameOkFromChildren,
eNoValue, eNoValue,
eActivateAction, // XXX: should expose second 'expand/collapse' action based eActivateAction, // XXX: should expose second 'expand/collapse' action based
// on states // on states
@ -572,7 +523,6 @@ PRUint32 nsARIAMap::gWAIRoleMapLength = NS_ARRAY_LENGTH(nsARIAMap::gWAIRoleMap);
nsRoleMapEntry nsARIAMap::gLandmarkRoleMap = { nsRoleMapEntry nsARIAMap::gLandmarkRoleMap = {
"", "",
nsIAccessibleRole::ROLE_NOTHING, nsIAccessibleRole::ROLE_NOTHING,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,
@ -582,7 +532,6 @@ nsRoleMapEntry nsARIAMap::gLandmarkRoleMap = {
nsRoleMapEntry nsARIAMap::gEmptyRoleMap = { nsRoleMapEntry nsARIAMap::gEmptyRoleMap = {
"", "",
nsIAccessibleRole::ROLE_NOTHING, nsIAccessibleRole::ROLE_NOTHING,
eNameLabelOrTitle,
eNoValue, eNoValue,
eNoAction, eNoAction,
kNoReqStates, kNoReqStates,

Просмотреть файл

@ -43,26 +43,6 @@
#include "prtypes.h" #include "prtypes.h"
#include "nsAccessibilityAtoms.h" #include "nsAccessibilityAtoms.h"
// Name mapping rule: can the name be computed from descendants?
enum ENameRule
{
// eNameLabelOrTitle:
// Collect name from:
// 1) The content subtrees pointed to by labelledby
// which contains the IDs for the label content, or if unspecified
// 2) The title attribute if specified
eNameLabelOrTitle,
// eNameOkFromChildren
// Collect name from:
// 1) The content subtrees pointed to by labelledby
// which contains the IDs for the label content, or if un specified
// 2) The text and text equivalents from descendents,
// as well as the value of controls, collected in depth-first order, or if empty
// 3) The title attribute if specified
eNameOkFromChildren
};
// Is nsIAccessible value supported for this role or not? // Is nsIAccessible value supported for this role or not?
enum EValueRule enum EValueRule
{ {
@ -107,9 +87,6 @@ struct nsRoleMapEntry
// Role mapping rule: maps to this nsIAccessibleRole // Role mapping rule: maps to this nsIAccessibleRole
PRUint32 role; PRUint32 role;
// Name mapping rule: how to compute nsIAccessible name
ENameRule nameRule;
// Value mapping rule: how to compute nsIAccessible value // Value mapping rule: how to compute nsIAccessible value
EValueRule valueRule; EValueRule valueRule;

Просмотреть файл

@ -40,6 +40,7 @@
#include "nsAccessible.h" #include "nsAccessible.h"
#include "nsAccessibleRelation.h" #include "nsAccessibleRelation.h"
#include "nsHyperTextAccessibleWrap.h" #include "nsHyperTextAccessibleWrap.h"
#include "nsNameUtils.h"
#include "nsIAccessibleDocument.h" #include "nsIAccessibleDocument.h"
#include "nsIAccessibleHyperText.h" #include "nsIAccessibleHyperText.h"
@ -1716,12 +1717,8 @@ nsresult nsAccessible::GetTextFromRelationID(nsIAtom *aIDProperty, nsString &aNa
return NS_OK; return NS_OK;
} }
/** nsresult
* Only called if the element is not a nsIDOMXULControlElement. Initially walks up nsAccessible::GetHTMLName(nsAString& aLabel)
* the DOM tree to the form, concatonating label elements as it goes. Then checks for
* labels with the for="controlID" property.
*/
nsresult nsAccessible::GetHTMLName(nsAString& aLabel, PRBool aCanAggregateSubtree)
{ {
nsCOMPtr<nsIContent> content = nsCoreUtils::GetRoleContent(mDOMNode); nsCOMPtr<nsIContent> content = nsCoreUtils::GetRoleContent(mDOMNode);
if (!content) { if (!content) {
@ -1742,9 +1739,10 @@ nsresult nsAccessible::GetHTMLName(nsAString& aLabel, PRBool aCanAggregateSubtre
} }
} }
PRBool canAggregateName = mRoleMapEntry ? PRUint32 role = nsAccUtils::Role(this);
mRoleMapEntry->nameRule == eNameOkFromChildren : PRUint32 canAggregateName =
aCanAggregateSubtree; nsNameUtils::gRoleToNameRulesMap[role] & eFromSubtree;
if (canAggregateName) { if (canAggregateName) {
// Don't use AppendFlatStringFromSubtree for container widgets like menulist // Don't use AppendFlatStringFromSubtree for container widgets like menulist
nsresult rv = AppendFlatStringFromSubtree(content, &aLabel); nsresult rv = AppendFlatStringFromSubtree(content, &aLabel);
@ -1775,7 +1773,8 @@ nsresult nsAccessible::GetHTMLName(nsAString& aLabel, PRBool aCanAggregateSubtre
* the control that uses the control="controlID" syntax will use * the control that uses the control="controlID" syntax will use
* the child label for its Name. * the child label for its Name.
*/ */
nsresult nsAccessible::GetXULName(nsAString& aLabel, PRBool aCanAggregateSubtree) nsresult
nsAccessible::GetXULName(nsAString& aLabel)
{ {
// CASE #1 (via label attribute) -- great majority of the cases // CASE #1 (via label attribute) -- great majority of the cases
nsresult rv = NS_OK; nsresult rv = NS_OK;
@ -1851,9 +1850,9 @@ nsresult nsAccessible::GetXULName(nsAString& aLabel, PRBool aCanAggregateSubtree
parent = parent->GetParent(); parent = parent->GetParent();
} }
PRBool canAggregateName = mRoleMapEntry ? PRUint32 role = nsAccUtils::Role(this);
mRoleMapEntry->nameRule == eNameOkFromChildren : PRUint32 canAggregateName =
aCanAggregateSubtree; nsNameUtils::gRoleToNameRulesMap[role] & eFromSubtree;
return canAggregateName ? return canAggregateName ?
AppendFlatStringFromSubtree(content, &aLabel) : NS_OK; AppendFlatStringFromSubtree(content, &aLabel) : NS_OK;
@ -3421,10 +3420,10 @@ nsAccessible::GetNameInternal(nsAString& aName)
return NS_OK; return NS_OK;
if (content->IsNodeOfType(nsINode::eHTML)) if (content->IsNodeOfType(nsINode::eHTML))
return GetHTMLName(aName, PR_FALSE); return GetHTMLName(aName);
if (content->IsNodeOfType(nsINode::eXUL)) if (content->IsNodeOfType(nsINode::eXUL))
return GetXULName(aName, PR_FALSE); return GetXULName(aName);
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -180,9 +180,19 @@ protected:
*/ */
nsresult GetTextFromRelationID(nsIAtom *aIDProperty, nsString &aName); nsresult GetTextFromRelationID(nsIAtom *aIDProperty, nsString &aName);
// Name helpers //////////////////////////////////////////////////////////////////////////////
nsresult GetHTMLName(nsAString& _retval, PRBool aCanAggregateSubtree = PR_TRUE); // Name helpers.
nsresult GetXULName(nsAString& aName, PRBool aCanAggregateSubtree = PR_TRUE);
/**
* Compute the name of HTML node.
*/
nsresult GetHTMLName(nsAString& aName);
/**
* Compute the name for XUL node.
*/
nsresult GetXULName(nsAString& aName);
// For accessibles that are not lists of choices, the name of the subtree should be the // For accessibles that are not lists of choices, the name of the subtree should be the
// sum of names in the subtree // sum of names in the subtree
nsresult AppendFlatStringFromSubtree(nsIContent *aContent, nsAString *aFlatString); nsresult AppendFlatStringFromSubtree(nsIContent *aContent, nsAString *aFlatString);

Просмотреть файл

@ -0,0 +1,168 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alexander Surkov <surkov.alexander@gmail.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* 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 ***** */
#include "nsNameUtils.h"
////////////////////////////////////////////////////////////////////////////////
// Name rules to role map.
PRUint32 nsNameUtils::gRoleToNameRulesMap[] =
{
eNoRule, // ROLE_NOTHING
eNoRule, // ROLE_TITLEBAR
eNoRule, // ROLE_MENUBAR
eNoRule, // ROLE_SCROLLBAR
eNoRule, // ROLE_GRIP
eNoRule, // ROLE_SOUND
eNoRule, // ROLE_CURSOR
eNoRule, // ROLE_CARET
eNoRule, // ROLE_ALERT
eNoRule, // ROLE_WINDOW
eNoRule, // ROLE_INTERNAL_FRAME
eNoRule, // ROLE_MENUPOPUP
eFromSubtree, // ROLE_MENUITEM
eFromSubtree, // ROLE_TOOLTIP
eNoRule, // ROLE_APPLICATION
eNoRule, // ROLE_DOCUMENT
eNoRule, // ROLE_PANE
eNoRule, // ROLE_CHART
eNoRule, // ROLE_DIALOG
eNoRule, // ROLE_BORDER
eNoRule, // ROLE_GROUPING
eNoRule, // ROLE_SEPARATOR
eNoRule, // ROLE_TOOLBAR
eNoRule, // ROLE_STATUSBAR
eNoRule, // ROLE_TABLE
eFromSubtree, // ROLE_COLUMNHEADER
eFromSubtree, // ROLE_ROWHEADER
eFromSubtree, // ROLE_COLUMN
eFromSubtree, // ROLE_ROW
eFromSubtree, // ROLE_CELL
eFromSubtree, // ROLE_LINK
eFromSubtree, // ROLE_HELPBALLOON
eNoRule, // ROLE_CHARACTER
eNoRule, // ROLE_LIST
eFromSubtree, // ROLE_LISTITEM
eNoRule, // ROLE_OUTLINE
eFromSubtree, // ROLE_OUTLINEITEM
eFromSubtree, // ROLE_PAGETAB
eNoRule, // ROLE_PROPERTYPAGE
eNoRule, // ROLE_INDICATOR
eNoRule, // ROLE_GRAPHIC
eNoRule, // ROLE_STATICTEXT
eNoRule, // ROLE_TEXT_LEAF
eFromSubtree, // ROLE_PUSHBUTTON
eFromSubtree, // ROLE_CHECKBUTTON
eFromSubtree, // ROLE_RADIOBUTTON
eNoRule, // ROLE_COMBOBOX
eNoRule, // ROLE_DROPLIST
eNoRule, // ROLE_PROGRESSBAR
eNoRule, // ROLE_DIAL
eNoRule, // ROLE_HOTKEYFIELD
eNoRule, // ROLE_SLIDER
eNoRule, // ROLE_SPINBUTTON
eNoRule, // ROLE_DIAGRAM
eNoRule, // ROLE_ANIMATION
eNoRule, // ROLE_EQUATION
eFromSubtree, // ROLE_BUTTONDROPDOWN
eFromSubtree, // ROLE_BUTTONMENU
eFromSubtree, // ROLE_BUTTONDROPDOWNGRID
eNoRule, // ROLE_WHITESPACE
eNoRule, // ROLE_PAGETABLIST
eNoRule, // ROLE_CLOCK
eNoRule, // ROLE_SPLITBUTTON
eNoRule, // ROLE_IPADDRESS
eNoRule, // ROLE_ACCEL_LABEL
eNoRule, // ROLE_ARROW
eNoRule, // ROLE_CANVAS
eFromSubtree, // ROLE_CHECK_MENU_ITEM
eNoRule, // ROLE_COLOR_CHOOSER
eNoRule, // ROLE_DATE_EDITOR
eNoRule, // ROLE_DESKTOP_ICON
eNoRule, // ROLE_DESKTOP_FRAME
eNoRule, // ROLE_DIRECTORY_PANE
eNoRule, // ROLE_FILE_CHOOSER
eNoRule, // ROLE_FONT_CHOOSER
eNoRule, // ROLE_CHROME_WINDOW
eNoRule, // ROLE_GLASS_PANE
eNoRule, // ROLE_HTML_CONTAINER
eNoRule, // ROLE_ICON
eNoRule, // ROLE_LABEL
eNoRule, // ROLE_LAYERED_PANE
eNoRule, // ROLE_OPTION_PANE
eNoRule, // ROLE_PASSWORD_TEXT
eNoRule, // ROLE_POPUP_MENU
eFromSubtree, // ROLE_RADIO_MENU_ITEM
eNoRule, // ROLE_ROOT_PANE
eNoRule, // ROLE_SCROLL_PANE
eNoRule, // ROLE_SPLIT_PANE
eFromSubtree, // ROLE_TABLE_COLUMN_HEADER
eFromSubtree, // ROLE_TABLE_ROW_HEADER
eFromSubtree, // ROLE_TEAR_OFF_MENU_ITEM
eNoRule, // ROLE_TERMINAL
eNoRule, // ROLE_TEXT_CONTAINER
eFromSubtree, // ROLE_TOGGLE_BUTTON
eNoRule, // ROLE_TREE_TABLE
eNoRule, // ROLE_VIEWPORT
eNoRule, // ROLE_HEADER
eNoRule, // ROLE_FOOTER
eNoRule, // ROLE_PARAGRAPH
eNoRule, // ROLE_RULER
eNoRule, // ROLE_AUTOCOMPLETE
eNoRule, // ROLE_EDITBAR
eNoRule, // ROLE_ENTRY
eNoRule, // ROLE_CAPTION
eNoRule, // ROLE_DOCUMENT_FRAME
eNoRule, // ROLE_HEADING
eNoRule, // ROLE_PAGE
eNoRule, // ROLE_SECTION
eNoRule, // ROLE_REDUNDANT_OBJECT
eNoRule, // ROLE_FORM
eNoRule, // ROLE_IME
eNoRule, // ROLE_APP_ROOT
eFromSubtree, // ROLE_PARENT_MENUITEM
eNoRule, // ROLE_CALENDAR
eNoRule, // ROLE_COMBOBOX_LIST
eFromSubtree, // ROLE_COMBOBOX_OPTION
eNoRule, // ROLE_IMAGE_MAP
eFromSubtree, // ROLE_OPTION
eFromSubtree, // ROLE_RICH_OPTION
eNoRule, // ROLE_LISTBOX
eNoRule // ROLE_FLAT_EQUATION
};

Просмотреть файл

@ -0,0 +1,71 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alexander Surkov <surkov.alexander@gmail.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* 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 _nsNameUtils_H_
#define _nsNameUtils_H_
#include "prtypes.h"
/**
* Name from subtree calculation rules.
*/
enum ENameFromSubtreeRule
{
// do not walk into subtree to compute the name
eNoRule = 0x00,
// compute the name from the subtree
eFromSubtree = 0x01
};
/**
* The class provides utils methods to compute the accessible name and
* description.
*/
class nsNameUtils
{
public:
/**
* Map array from roles to name rules (bit state of ENameFromSubtreeRule).
*/
static PRUint32 gRoleToNameRulesMap[];
};
#endif

Просмотреть файл

@ -369,12 +369,6 @@ nsHTML4ButtonAccessible::GetStateInternal(PRUint32 *aState,
return NS_OK; return NS_OK;
} }
nsresult
nsHTML4ButtonAccessible::GetNameInternal(nsAString& aName)
{
return GetHTMLName(aName, PR_TRUE);
}
// --- textfield ----- // --- textfield -----
nsHTMLTextFieldAccessible::nsHTMLTextFieldAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell): nsHTMLTextFieldAccessible::nsHTMLTextFieldAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):

Просмотреть файл

@ -86,7 +86,7 @@ public:
NS_IMETHOD DoAction(PRUint8 index); NS_IMETHOD DoAction(PRUint8 index);
// nsAccessible // nsAccessible
virtual nsresult GetNameInternal(nsAString& aName); virtual nsresult GetNameInternal(nsAString& aName);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
}; };
@ -105,7 +105,6 @@ public:
NS_IMETHOD DoAction(PRUint8 index); NS_IMETHOD DoAction(PRUint8 index);
// nsAccessible // nsAccessible
virtual nsresult GetNameInternal(nsAString& aName);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
}; };

Просмотреть файл

@ -57,12 +57,6 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLLinkAccessible, nsHyperTextAccessibleWrap,
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// nsIAccessible // nsIAccessible
nsresult
nsHTMLLinkAccessible::GetNameInternal(nsAString& aName)
{
return GetHTMLName(aName, PR_TRUE);
}
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLLinkAccessible::GetRole(PRUint32 *aRole) nsHTMLLinkAccessible::GetRole(PRUint32 *aRole)
{ {

Просмотреть файл

@ -61,7 +61,6 @@ public:
NS_IMETHOD GetURI(PRInt32 aIndex, nsIURI **aURI); NS_IMETHOD GetURI(PRInt32 aIndex, nsIURI **aURI);
// nsAccessible // nsAccessible
virtual nsresult GetNameInternal(nsAString& aName);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
protected: protected:

Просмотреть файл

@ -91,12 +91,6 @@ nsXULColorPickerTileAccessible::GetStateInternal(PRUint32 *aState,
return NS_OK; return NS_OK;
} }
nsresult
nsXULColorPickerTileAccessible::GetNameInternal(nsAString& aName)
{
return GetXULName(aName);
}
NS_IMETHODIMP nsXULColorPickerTileAccessible::GetValue(nsAString& _retval) NS_IMETHODIMP nsXULColorPickerTileAccessible::GetValue(nsAString& _retval)
{ {
if (!mDOMNode) if (!mDOMNode)

Просмотреть файл

@ -52,7 +52,6 @@ public:
NS_IMETHOD GetValue(nsAString& _retval); NS_IMETHOD GetValue(nsAString& _retval);
// nsAccessible // nsAccessible
virtual nsresult GetNameInternal(nsAString& aName);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
}; };

Просмотреть файл

@ -127,12 +127,6 @@ nsXULColumnItemAccessible::GetStateInternal(PRUint32 *aState,
return NS_OK; return NS_OK;
} }
nsresult
nsXULColumnItemAccessible::GetNameInternal(nsAString& aName)
{
return GetXULName(aName);
}
NS_IMETHODIMP NS_IMETHODIMP
nsXULColumnItemAccessible::GetNumActions(PRUint8 *aNumActions) nsXULColumnItemAccessible::GetNumActions(PRUint8 *aNumActions)
{ {

Просмотреть файл

@ -79,7 +79,6 @@ public:
NS_IMETHOD DoAction(PRUint8 aIndex); NS_IMETHOD DoAction(PRUint8 aIndex);
// nsAccessible // nsAccessible
virtual nsresult GetNameInternal(nsAString& aName);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
enum { eAction_Click = 0 }; enum { eAction_Click = 0 };

Просмотреть файл

@ -117,12 +117,6 @@ nsLeafAccessible(aDomNode, aShell)
{ {
} }
nsresult
nsXULTooltipAccessible::GetNameInternal(nsAString& aName)
{
return GetXULName(aName, PR_TRUE);
}
nsresult nsresult
nsXULTooltipAccessible::GetStateInternal(PRUint32 *aState, nsXULTooltipAccessible::GetStateInternal(PRUint32 *aState,
PRUint32 *aExtraState) PRUint32 *aExtraState)

Просмотреть файл

@ -72,7 +72,6 @@ public:
NS_IMETHOD GetRole(PRUint32 *_retval); NS_IMETHOD GetRole(PRUint32 *_retval);
// nsAccessible // nsAccessible
virtual nsresult GetNameInternal(nsAString& aName);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
}; };