Bug 523068 - group attributes should be calculated from groupPosition(), r=marcoz, davidb

This commit is contained in:
Alexander Surkov 2010-01-06 18:36:50 +08:00
parent 20519041b1
commit 8820f384e6
26 changed files with 546 additions and 388 deletions

View File

@ -705,16 +705,19 @@ nsAttributeCharacteristics nsARIAMap::gWAIUnivAttrMap[] = {
{&nsAccessibilityAtoms::aria_haspopup, ATTR_BYPASSOBJ | ATTR_VALTOKEN },
{&nsAccessibilityAtoms::aria_invalid, ATTR_BYPASSOBJ | ATTR_VALTOKEN },
{&nsAccessibilityAtoms::aria_labelledby, ATTR_BYPASSOBJ },
{&nsAccessibilityAtoms::aria_level, ATTR_BYPASSOBJ }, /* handled via groupPosition */
{&nsAccessibilityAtoms::aria_live, ATTR_VALTOKEN },
{&nsAccessibilityAtoms::aria_multiline, ATTR_BYPASSOBJ | ATTR_VALTOKEN },
{&nsAccessibilityAtoms::aria_multiselectable, ATTR_BYPASSOBJ | ATTR_VALTOKEN },
{&nsAccessibilityAtoms::aria_owns, ATTR_BYPASSOBJ },
{&nsAccessibilityAtoms::aria_orientation, ATTR_VALTOKEN },
{&nsAccessibilityAtoms::aria_posinset, ATTR_BYPASSOBJ }, /* handled via groupPosition */
{&nsAccessibilityAtoms::aria_pressed, ATTR_BYPASSOBJ | ATTR_VALTOKEN },
{&nsAccessibilityAtoms::aria_readonly, ATTR_BYPASSOBJ | ATTR_VALTOKEN },
{&nsAccessibilityAtoms::aria_relevant, ATTR_BYPASSOBJ },
{&nsAccessibilityAtoms::aria_required, ATTR_BYPASSOBJ | ATTR_VALTOKEN },
{&nsAccessibilityAtoms::aria_selected, ATTR_BYPASSOBJ | ATTR_VALTOKEN },
{&nsAccessibilityAtoms::aria_setsize, ATTR_BYPASSOBJ }, /* handled via groupPosition */
{&nsAccessibilityAtoms::aria_sort, ATTR_VALTOKEN },
{&nsAccessibilityAtoms::aria_valuenow, ATTR_BYPASSOBJ },
{&nsAccessibilityAtoms::aria_valuemin, ATTR_BYPASSOBJ },

View File

@ -80,58 +80,10 @@ nsAccUtils::SetAccAttr(nsIPersistentProperties *aAttributes,
aAttributes->SetStringProperty(attrName, aAttrValue, oldValue);
}
void
nsAccUtils::GetAccGroupAttrs(nsIPersistentProperties *aAttributes,
PRInt32 *aLevel, PRInt32 *aPosInSet,
PRInt32 *aSetSize)
{
*aLevel = 0;
*aPosInSet = 0;
*aSetSize = 0;
nsAutoString value;
PRInt32 error = NS_OK;
GetAccAttr(aAttributes, nsAccessibilityAtoms::level, value);
if (!value.IsEmpty()) {
PRInt32 level = value.ToInteger(&error);
if (NS_SUCCEEDED(error))
*aLevel = level;
}
GetAccAttr(aAttributes, nsAccessibilityAtoms::posinset, value);
if (!value.IsEmpty()) {
PRInt32 posInSet = value.ToInteger(&error);
if (NS_SUCCEEDED(error))
*aPosInSet = posInSet;
}
GetAccAttr(aAttributes, nsAccessibilityAtoms::setsize, value);
if (!value.IsEmpty()) {
PRInt32 sizeSet = value.ToInteger(&error);
if (NS_SUCCEEDED(error))
*aSetSize = sizeSet;
}
}
PRBool
nsAccUtils::HasAccGroupAttrs(nsIPersistentProperties *aAttributes)
{
nsAutoString value;
GetAccAttr(aAttributes, nsAccessibilityAtoms::setsize, value);
if (!value.IsEmpty()) {
GetAccAttr(aAttributes, nsAccessibilityAtoms::posinset, value);
return !value.IsEmpty();
}
return PR_FALSE;
}
void
nsAccUtils::SetAccGroupAttrs(nsIPersistentProperties *aAttributes,
PRInt32 aLevel, PRInt32 aPosInSet,
PRInt32 aSetSize)
PRInt32 aLevel, PRInt32 aSetSize,
PRInt32 aPosInSet)
{
nsAutoString value;
@ -152,8 +104,9 @@ nsAccUtils::SetAccGroupAttrs(nsIPersistentProperties *aAttributes,
}
void
nsAccUtils::SetAccAttrsForXULSelectControlItem(nsIDOMNode *aNode,
nsIPersistentProperties *aAttributes)
nsAccUtils::GetPositionAndSizeForXULSelectControlItem(nsIDOMNode *aNode,
PRInt32 *aPosInSet,
PRInt32 *aSetSize)
{
nsCOMPtr<nsIDOMXULSelectControlItemElement> item(do_QueryInterface(aNode));
if (!item)
@ -170,7 +123,9 @@ nsAccUtils::SetAccAttrsForXULSelectControlItem(nsIDOMNode *aNode,
PRInt32 indexOf = 0;
control->GetIndexOfItem(item, &indexOf);
PRUint32 setSize = itemsCount, posInSet = indexOf;
*aSetSize = itemsCount;
*aPosInSet = indexOf;
for (PRUint32 index = 0; index < itemsCount; index++) {
nsCOMPtr<nsIDOMXULSelectControlItemElement> currItem;
control->GetItemAtIndex(index, getter_AddRefs(currItem));
@ -181,18 +136,19 @@ nsAccUtils::SetAccAttrsForXULSelectControlItem(nsIDOMNode *aNode,
getter_AddRefs(itemAcc));
if (!itemAcc ||
State(itemAcc) & nsIAccessibleStates::STATE_INVISIBLE) {
setSize--;
(*aSetSize)--;
if (index < static_cast<PRUint32>(indexOf))
posInSet--;
(*aPosInSet)--;
}
}
SetAccGroupAttrs(aAttributes, 0, posInSet + 1, setSize);
(*aPosInSet)++; // group position is 1-index based.
}
void
nsAccUtils::SetAccAttrsForXULContainerItem(nsIDOMNode *aNode,
nsIPersistentProperties *aAttributes)
nsAccUtils::GetPositionAndSizeForXULContainerItem(nsIDOMNode *aNode,
PRInt32 *aPosInSet,
PRInt32 *aSetSize)
{
nsCOMPtr<nsIDOMXULContainerItemElement> item(do_QueryInterface(aNode));
if (!item)
@ -212,7 +168,7 @@ nsAccUtils::SetAccAttrsForXULContainerItem(nsIDOMNode *aNode,
container->GetIndexOfItem(item, &indexOf);
// Calculate set size and position in the set.
PRUint32 setSize = 0, posInSet = 0;
*aSetSize = 0, *aPosInSet = 0;
for (PRInt32 index = indexOf; index >= 0; index--) {
nsCOMPtr<nsIDOMXULElement> item;
container->GetItemAtIndex(index, getter_AddRefs(item));
@ -228,8 +184,8 @@ nsAccUtils::SetAccAttrsForXULContainerItem(nsIDOMNode *aNode,
PRUint32 itemState = State(itemAcc);
if (!(itemState & nsIAccessibleStates::STATE_INVISIBLE)) {
setSize++;
posInSet++;
(*aSetSize)++;
(*aPosInSet)++;
}
}
}
@ -250,9 +206,22 @@ nsAccUtils::SetAccAttrsForXULContainerItem(nsIDOMNode *aNode,
PRUint32 itemState = State(itemAcc);
if (!(itemState & nsIAccessibleStates::STATE_INVISIBLE))
setSize++;
(*aSetSize)++;
}
}
}
PRInt32
nsAccUtils::GetLevelForXULContainerItem(nsIDOMNode *aNode)
{
nsCOMPtr<nsIDOMXULContainerItemElement> item(do_QueryInterface(aNode));
if (!item)
return 0;
nsCOMPtr<nsIDOMXULContainerElement> container;
item->GetParentContainer(getter_AddRefs(container));
if (!container)
return 0;
// Get level of the item.
PRInt32 level = -1;
@ -263,8 +232,8 @@ nsAccUtils::SetAccAttrsForXULContainerItem(nsIDOMNode *aNode,
container->GetParentContainer(getter_AddRefs(parentContainer));
parentContainer.swap(container);
}
SetAccGroupAttrs(aAttributes, level, posInSet, setSize);
return level;
}
void

View File

@ -85,46 +85,33 @@ public:
nsIAtom *aAttrName,
const nsAString& aAttrValue);
/**
* Return values of group attributes ('level', 'setsize', 'posinset')
*/
static void GetAccGroupAttrs(nsIPersistentProperties *aAttributes,
PRInt32 *aLevel,
PRInt32 *aPosInSet,
PRInt32 *aSetSize);
/**
* Returns true if there are level, posinset and sizeset attributes.
*/
static PRBool HasAccGroupAttrs(nsIPersistentProperties *aAttributes);
/**
* Set group attributes ('level', 'setsize', 'posinset').
*/
static void SetAccGroupAttrs(nsIPersistentProperties *aAttributes,
PRInt32 aLevel,
PRInt32 aPosInSet,
PRInt32 aSetSize);
PRInt32 aLevel, PRInt32 aSetSize,
PRInt32 aPosInSet);
/**
* Set group attributes - 'level', 'setsize', 'posinset'.
*
* @param aNode - XUL element that implements
* nsIDOMXULSelectControlItemElement interface
* @param aAttributes - attributes container
* Compute position in group (posinset) and group size (setsize) for
* nsIDOMXULSelectControlItemElement node.
*/
static void SetAccAttrsForXULSelectControlItem(nsIDOMNode *aNode,
nsIPersistentProperties *aAttributes);
static void GetPositionAndSizeForXULSelectControlItem(nsIDOMNode *aNode,
PRInt32 *aPosInSet,
PRInt32 *aSetSize);
/**
* Set group attributes - 'level', 'setsize', 'posinset'.
*
* @param aNode XUL element that implements
* nsIDOMXULContainerItemElement interface
* @param aAttributes attributes container
* Compute group position and group size (posinset and setsize) for
* nsIDOMXULContainerItemElement node.
*/
static void SetAccAttrsForXULContainerItem(nsIDOMNode *aNode,
nsIPersistentProperties *aAttributes);
static void GetPositionAndSizeForXULContainerItem(nsIDOMNode *aNode,
PRInt32 *aPosInSet,
PRInt32 *aSetSize);
/**
* Compute group level for nsIDOMXULContainerItemElement node.
*/
static PRInt32 GetLevelForXULContainerItem(nsIDOMNode *aNode);
/**
* Set container-foo live region attributes for the given node.

View File

@ -1506,13 +1506,10 @@ nsAccessible::GetAttributes(nsIPersistentProperties **aAttributes)
nsAccUtils::SetAccAttr(attributes, nsAccessibilityAtoms::checkable, NS_LITERAL_STRING("true"));
// Group attributes (level/setsize/posinset)
if (!nsAccUtils::HasAccGroupAttrs(attributes)) {
// Calculate group attributes based on accessible hierarhy if they weren't
// provided by ARIA or by accessible class implementation.
PRUint32 role = nsAccUtils::Role(this);
rv = ComputeGroupAttributes(role, attributes);
NS_ENSURE_SUCCESS(rv, rv);
}
PRInt32 level = 0, posInSet = 0, setSize = 0;
rv = GroupPosition(&level, &setSize, &posInSet);
if (NS_SUCCEEDED(rv))
nsAccUtils::SetAccGroupAttrs(attributes, level, setSize, posInSet);
// Expose object attributes from ARIA attributes.
PRUint32 numAttrs = content->GetAttrCount();
@ -1655,37 +1652,71 @@ nsAccessible::GroupPosition(PRInt32 *aGroupLevel,
PRInt32 *aSimilarItemsInGroup,
PRInt32 *aPositionInGroup)
{
// Every element exposes level/posinset/sizeset for IAccessdible::attributes
// if they make sense for it. These attributes are mapped into groupPosition.
// If 'level' attribute doesn't make sense element then it isn't represented
// via IAccessible::attributes and groupLevel of groupPosition method is 0.
// Elements that expose 'level' attribute only (like html headings elements)
// don't support this method and all arguments are equalled 0.
NS_ENSURE_ARG_POINTER(aGroupLevel);
NS_ENSURE_ARG_POINTER(aSimilarItemsInGroup);
NS_ENSURE_ARG_POINTER(aPositionInGroup);
*aGroupLevel = 0;
NS_ENSURE_ARG_POINTER(aSimilarItemsInGroup);
*aSimilarItemsInGroup = 0;
NS_ENSURE_ARG_POINTER(aPositionInGroup);
*aPositionInGroup = 0;
nsCOMPtr<nsIPersistentProperties> attributes;
nsresult rv = GetAttributes(getter_AddRefs(attributes));
NS_ENSURE_SUCCESS(rv, rv);
if (!attributes) {
if (IsDefunct())
return NS_ERROR_FAILURE;
}
PRInt32 level, posInSet, setSize;
nsAccUtils::GetAccGroupAttrs(attributes, &level, &posInSet, &setSize);
if (!posInSet && !setSize)
// Get group position from ARIA attributes.
nsCOMPtr<nsIContent> content = nsCoreUtils::GetRoleContent(mDOMNode);
if (!content)
return NS_OK;
*aGroupLevel = level;
nsAutoString value;
PRInt32 error = NS_OK;
*aPositionInGroup = posInSet;
*aSimilarItemsInGroup = setSize;
content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::aria_level, value);
if (!value.IsEmpty()) {
PRInt32 level = value.ToInteger(&error);
if (NS_SUCCEEDED(error))
*aGroupLevel = level;
}
content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::aria_posinset, value);
if (!value.IsEmpty()) {
PRInt32 posInSet = value.ToInteger(&error);
if (NS_SUCCEEDED(error))
*aPositionInGroup = posInSet;
}
content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::aria_setsize, value);
if (!value.IsEmpty()) {
PRInt32 sizeSet = value.ToInteger(&error);
if (NS_SUCCEEDED(error))
*aSimilarItemsInGroup = sizeSet;
}
// If ARIA is missed and the accessible is visible then calculate group
// position from hierarchy.
if (nsAccUtils::State(this) & nsIAccessibleStates::STATE_INVISIBLE)
return NS_OK;
// Calculate group level if ARIA is missed.
if (*aGroupLevel == 0) {
PRInt32 level = GetLevelInternal();
if (level != 0)
*aGroupLevel = level;
}
// Calculate position in group and group size if ARIA is missed.
if (*aSimilarItemsInGroup == 0 || *aPositionInGroup == 0) {
PRInt32 posInSet = 0, setSize = 0;
GetPositionAndSizeInternal(&posInSet, &setSize);
if (posInSet != 0 && setSize != 0) {
if (*aPositionInGroup == 0)
*aPositionInGroup = posInSet;
if (*aSimilarItemsInGroup == 0)
*aSimilarItemsInGroup = setSize;
}
}
return NS_OK;
}
@ -3291,40 +3322,29 @@ nsAccessible::GetActionRule(PRUint32 aStates)
return eNoAction;
}
nsresult
nsAccessible::ComputeGroupAttributes(PRUint32 aRole,
nsIPersistentProperties *aAttributes)
void
nsAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet, PRInt32 *aSetSize)
{
// The role of an accessible can be specified by ARIA attribute but ARIA
// posinset, level, setsize may be skipped. As well this method is used
// for non ARIA accessibles to avoid GetAccessibleInternal() method
// implementation in subclasses. For example, it's being used to calculate
// group attributes for HTML li elements.
PRUint32 role = nsAccUtils::Role(this);
if (role != nsIAccessibleRole::ROLE_LISTITEM &&
role != nsIAccessibleRole::ROLE_MENUITEM &&
role != nsIAccessibleRole::ROLE_CHECK_MENU_ITEM &&
role != nsIAccessibleRole::ROLE_RADIO_MENU_ITEM &&
role != nsIAccessibleRole::ROLE_RADIOBUTTON &&
role != nsIAccessibleRole::ROLE_PAGETAB &&
role != nsIAccessibleRole::ROLE_OPTION &&
role != nsIAccessibleRole::ROLE_OUTLINEITEM &&
role != nsIAccessibleRole::ROLE_ROW &&
role != nsIAccessibleRole::ROLE_GRID_CELL)
return;
// If accessible is invisible we don't want to calculate group attributes for
// it.
if (nsAccUtils::State(this) & nsIAccessibleStates::STATE_INVISIBLE)
return NS_OK;
if (aRole != nsIAccessibleRole::ROLE_LISTITEM &&
aRole != nsIAccessibleRole::ROLE_MENUITEM &&
aRole != nsIAccessibleRole::ROLE_CHECK_MENU_ITEM &&
aRole != nsIAccessibleRole::ROLE_RADIO_MENU_ITEM &&
aRole != nsIAccessibleRole::ROLE_RADIOBUTTON &&
aRole != nsIAccessibleRole::ROLE_PAGETAB &&
aRole != nsIAccessibleRole::ROLE_OPTION &&
aRole != nsIAccessibleRole::ROLE_OUTLINEITEM &&
aRole != nsIAccessibleRole::ROLE_ROW &&
aRole != nsIAccessibleRole::ROLE_GRID_CELL)
return NS_OK;
PRUint32 baseRole = aRole;
if (aRole == nsIAccessibleRole::ROLE_CHECK_MENU_ITEM ||
aRole == nsIAccessibleRole::ROLE_RADIO_MENU_ITEM)
PRUint32 baseRole = role;
if (role == nsIAccessibleRole::ROLE_CHECK_MENU_ITEM ||
role == nsIAccessibleRole::ROLE_RADIO_MENU_ITEM)
baseRole = nsIAccessibleRole::ROLE_MENUITEM;
nsCOMPtr<nsIAccessible> parent = GetParent();
NS_ENSURE_TRUE(parent, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(parent,);
// Compute 'posinset' and 'setsize' attributes.
PRInt32 positionInGroup = 0;
@ -3332,7 +3352,7 @@ nsAccessible::ComputeGroupAttributes(PRUint32 aRole,
nsCOMPtr<nsIAccessible> sibling, nextSibling;
parent->GetFirstChild(getter_AddRefs(sibling));
NS_ENSURE_STATE(sibling);
NS_ENSURE_TRUE(sibling,);
PRBool foundCurrent = PR_FALSE;
PRUint32 siblingRole, siblingBaseRole;
@ -3369,13 +3389,21 @@ nsAccessible::ComputeGroupAttributes(PRUint32 aRole,
sibling = nextSibling;
}
// Compute 'level' attribute.
PRInt32 groupLevel = 0;
if (aRole == nsIAccessibleRole::ROLE_OUTLINEITEM) {
*aPosInSet = positionInGroup;
*aSetSize = setSize;
}
PRInt32
nsAccessible::GetLevelInternal()
{
PRUint32 role = nsAccUtils::Role(this);
nsCOMPtr<nsIAccessible> parent = GetParent();
if (role == nsIAccessibleRole::ROLE_OUTLINEITEM) {
// Always expose 'level' attribute for 'outlineitem' accessible. The number
// of nested 'grouping' accessibles containing 'outlineitem' accessible is
// its level.
groupLevel = 1;
PRInt32 level = 1;
nsCOMPtr<nsIAccessible> nextParent;
while (parent) {
PRUint32 parentRole = nsAccUtils::Role(parent);
@ -3383,24 +3411,30 @@ nsAccessible::ComputeGroupAttributes(PRUint32 aRole,
if (parentRole == nsIAccessibleRole::ROLE_OUTLINE)
break;
if (parentRole == nsIAccessibleRole::ROLE_GROUPING)
++ groupLevel;
++ level;
parent->GetParent(getter_AddRefs(nextParent));
parent.swap(nextParent);
}
} else if (aRole == nsIAccessibleRole::ROLE_LISTITEM) {
return level;
}
if (role == nsIAccessibleRole::ROLE_LISTITEM) {
// Expose 'level' attribute on nested lists. We assume nested list is a last
// child of listitem of parent list. We don't handle the case when nested
// lists have more complex structure, for example when there are accessibles
// between parent listitem and nested list.
// Calculate 'level' attribute based on number of parent listitems.
PRInt32 level = 0;
nsCOMPtr<nsIAccessible> nextParent;
while (parent) {
PRUint32 parentRole = nsAccUtils::Role(parent);
if (parentRole == nsIAccessibleRole::ROLE_LISTITEM)
++ groupLevel;
++ level;
else if (parentRole != nsIAccessibleRole::ROLE_LIST)
break;
@ -3408,35 +3442,36 @@ nsAccessible::ComputeGroupAttributes(PRUint32 aRole,
parent.swap(nextParent);
}
if (groupLevel == 0) {
if (level == 0) {
// If this listitem is on top of nested lists then expose 'level'
// attribute.
nsCOMPtr<nsIAccessible> parent = GetParent();
nsCOMPtr<nsIAccessible> parent(GetParent()), sibling, nextSibling;
parent->GetFirstChild(getter_AddRefs(sibling));
while (sibling) {
nsCOMPtr<nsIAccessible> siblingChild;
sibling->GetLastChild(getter_AddRefs(siblingChild));
if (nsAccUtils::Role(siblingChild) == nsIAccessibleRole::ROLE_LIST) {
groupLevel = 1;
level = 1;
break;
}
sibling->GetNextSibling(getter_AddRefs(nextSibling));
sibling.swap(nextSibling);
}
} else
groupLevel++; // level is 1-index based
} else {
++ level; // level is 1-index based
}
} else if (aRole == nsIAccessibleRole::ROLE_ROW &&
nsAccUtils::Role(GetParent()) == nsIAccessibleRole::ROLE_TREE_TABLE) {
// It is a row inside flatten treegrid. Group level is always 1 until it is
// overriden by aria-level attribute.
groupLevel = 1;
return level;
}
nsAccUtils::SetAccGroupAttrs(aAttributes, groupLevel, positionInGroup,
setSize);
if (role == nsIAccessibleRole::ROLE_ROW &&
nsAccUtils::Role(parent) == nsIAccessibleRole::ROLE_TREE_TABLE) {
// It is a row inside flatten treegrid. Group level is always 1 until it is
// overriden by aria-level attribute.
return 1;
}
return NS_OK;
return 0;
}

View File

@ -103,11 +103,11 @@ private:
#define NS_ACCESSIBLE_IMPL_CID \
{ /* 07c5a6d6-4e87-4b57-8613-4c39e1b5150a */ \
0x07c5a6d6, \
0x4e87, \
0x4b57, \
{ 0x86, 0x13, 0x4c, 0x39, 0xe1, 0xb5, 0x15, 0x0a } \
{ /* 81a84b69-de5a-412f-85ff-deb005c5a68d */ \
0x81a84b69, \
0xde5a, \
0x412f, \
{ 0x85, 0xff, 0xde, 0xb0, 0x05, 0xc5, 0xa6, 0x8d } \
}
class nsAccessible : public nsAccessNodeWrap,
@ -198,6 +198,21 @@ public:
PRBool aDeepestChild,
nsIAccessible **aChild);
/**
* Return calculated group level based on accessible hierarchy.
*/
virtual PRInt32 GetLevelInternal();
/**
* Calculate position in group and group size ('posinset' and 'setsize') based
* on accessible hierarchy.
*
* @param aPosInSet [out] accessible position in the group
* @param aSetSize [out] the group size
*/
virtual void GetPositionAndSizeInternal(PRInt32 *aPosInSet,
PRInt32 *aSetSize);
//////////////////////////////////////////////////////////////////////////////
// Initializing methods
@ -428,17 +443,6 @@ protected:
*/
PRUint32 GetActionRule(PRUint32 aStates);
/**
* Compute group attributes ('posinset', 'setsize' and 'level') based
* on accessible hierarchy. Used by GetAttributes() method if group attributes
* weren't provided by ARIA or by internal accessible implementation.
*
* @param aRole [in] role of this accessible
* @param aAttributes [in, out] object attributes
*/
nsresult ComputeGroupAttributes(PRUint32 aRole,
nsIPersistentProperties *aAttributes);
/**
* Fires platform accessible event. It's notification method only. It does
* change nothing on Gecko side. Mostly you should use

View File

@ -141,7 +141,9 @@ nsHTMLCheckboxAccessible::GetStateInternal(PRUint32 *aState,
return NS_OK;
}
//------ Radio button -------
////////////////////////////////////////////////////////////////////////////////
// nsHTMLRadioButtonAccessible
////////////////////////////////////////////////////////////////////////////////
nsHTMLRadioButtonAccessible::nsHTMLRadioButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsRadioButtonAccessible(aNode, aShell)
@ -169,22 +171,16 @@ nsHTMLRadioButtonAccessible::GetStateInternal(PRUint32 *aState,
return NS_OK;
}
nsresult
nsHTMLRadioButtonAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
void
nsHTMLRadioButtonAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet,
PRInt32 *aSetSize)
{
NS_ENSURE_ARG_POINTER(aAttributes);
NS_ENSURE_TRUE(mDOMNode, NS_ERROR_FAILURE);
nsresult rv = nsRadioButtonAccessible::GetAttributesInternal(aAttributes);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString nsURI;
mDOMNode->GetNamespaceURI(nsURI);
nsAutoString tagName;
mDOMNode->GetLocalName(tagName);
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
NS_ENSURE_STATE(content);
nsAutoString type;
content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::type, type);
@ -205,12 +201,12 @@ nsHTMLRadioButtonAccessible::GetAttributesInternal(nsIPersistentProperties *aAtt
document->GetElementsByTagNameNS(nsURI, tagName, getter_AddRefs(inputs));
}
NS_ENSURE_TRUE(inputs, NS_OK);
NS_ENSURE_TRUE(inputs, );
PRUint32 inputsCount = 0;
inputs->GetLength(&inputsCount);
// Get posinset and setsize.
// Compute posinset and setsize.
PRInt32 indexOf = 0;
PRInt32 count = 0;
@ -232,12 +228,13 @@ nsHTMLRadioButtonAccessible::GetAttributesInternal(nsIPersistentProperties *aAtt
}
}
nsAccUtils::SetAccGroupAttrs(aAttributes, 0, indexOf, count);
return NS_OK;
*aPosInSet = indexOf;
*aSetSize = count;
}
// ----- Button -----
////////////////////////////////////////////////////////////////////////////////
// nsHTMLButtonAccessible
////////////////////////////////////////////////////////////////////////////////
nsHTMLButtonAccessible::nsHTMLButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsHyperTextAccessibleWrap(aNode, aShell)

View File

@ -67,8 +67,9 @@ public:
nsHTMLRadioButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
// nsAccessible
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
virtual void GetPositionAndSizeInternal(PRInt32 *aPosInSet,
PRInt32 *aSetSize);
};
class nsHTMLButtonAccessible : public nsHyperTextAccessibleWrap

View File

@ -448,7 +448,9 @@ nsHyperTextAccessibleWrap(aDOMNode, aShell)
SetParent(parentAccessible);
}
/** We are a ListItem */
////////////////////////////////////////////////////////////////////////////////
// nsHTMLSelectOptionAccessible: nsAccessible public
nsresult
nsHTMLSelectOptionAccessible::GetRoleInternal(PRUint32 *aRole)
{
@ -491,49 +493,6 @@ nsHTMLSelectOptionAccessible::GetNameInternal(nsAString& aName)
return NS_OK;
}
nsresult
nsHTMLSelectOptionAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
{
NS_ENSURE_ARG_POINTER(aAttributes);
if (!mDOMNode) {
return NS_ERROR_FAILURE; // Accessible shut down
}
nsresult rv = nsHyperTextAccessibleWrap::GetAttributesInternal(aAttributes);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMNode> parentNode;
mDOMNode->GetParentNode(getter_AddRefs(parentNode));
nsCOMPtr<nsIDOMElement> parentElement(do_QueryInterface(parentNode));
NS_ENSURE_TRUE(parentElement, NS_ERROR_FAILURE);
nsAutoString parentTagName;
parentNode->GetLocalName(parentTagName);
PRInt32 level = parentTagName.LowerCaseEqualsLiteral("optgroup") ? 2 : 1;
if (level == 1 && nsAccUtils::Role(this) != nsIAccessibleRole::ROLE_HEADING) {
level = 0; // In a single level list, the level is irrelevant
}
nsAutoString tagName;
mDOMNode->GetLocalName(tagName); // Will be looking for similar DOM siblings
nsCOMPtr<nsIDOMNodeList> siblings;
parentElement->GetElementsByTagName(tagName, getter_AddRefs(siblings));
PRInt32 posInSet = 0;
PRUint32 setSize = 0;
if (siblings) {
siblings->GetLength(&setSize);
nsCOMPtr<nsIDOMNode> itemNode;
while (NS_SUCCEEDED(siblings->Item(posInSet ++, getter_AddRefs(itemNode))) &&
itemNode != mDOMNode) {
// Keep looping, to increment posInSet
}
}
nsAccUtils::SetAccGroupAttrs(aAttributes, level, posInSet,
static_cast<PRInt32>(setSize));
return NS_OK;
}
nsIFrame* nsHTMLSelectOptionAccessible::GetBoundsFrame()
{
PRUint32 state;
@ -641,6 +600,54 @@ nsHTMLSelectOptionAccessible::GetStateInternal(PRUint32 *aState,
return NS_OK;
}
PRInt32
nsHTMLSelectOptionAccessible::GetLevelInternal()
{
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
nsIContent *parentContent = content->GetParent();
PRInt32 level =
parentContent->NodeInfo()->Equals(nsAccessibilityAtoms::optgroup) ? 2 : 1;
if (level == 1 &&
nsAccUtils::Role(this) != nsIAccessibleRole::ROLE_HEADING) {
level = 0; // In a single level list, the level is irrelevant
}
return level;
}
void
nsHTMLSelectOptionAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet,
PRInt32 *aSetSize)
{
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
nsIContent *parentContent = content->GetParent();
PRInt32 posInSet = 0, setSize = 0;
PRBool isContentFound = PR_FALSE;
PRUint32 childCount = parentContent->GetChildCount();
for (PRUint32 childIdx = 0; childIdx < childCount; childIdx++) {
nsIContent *childContent = parentContent->GetChildAt(childIdx);
if (childContent->NodeInfo()->Equals(content->NodeInfo())) {
if (!isContentFound) {
if (childContent == content)
isContentFound = PR_TRUE;
posInSet++;
}
setSize++;
}
}
*aSetSize = setSize;
*aPosInSet = posInSet;
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLSelectOptionAccessible: nsIAccessible
/** select us! close combo box if necessary*/
NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
{
@ -715,6 +722,9 @@ NS_IMETHODIMP nsHTMLSelectOptionAccessible::DoAction(PRUint8 index)
return NS_ERROR_INVALID_ARG;
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLSelectOptionAccessible: static methods
/**
* Helper method for getting the focused DOM Node from our parent(list) node. We
* need to use the frame to get the focused option because for some reason we
@ -813,6 +823,9 @@ void nsHTMLSelectOptionAccessible::SelectionChangedIfOption(nsIContent *aPossibl
nsAccUtils::FireAccEvent(eventType, optionAccessible);
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLSelectOptionAccessible: private methods
nsIContent* nsHTMLSelectOptionAccessible::GetSelectState(PRUint32* aState,
PRUint32* aExtraState)
{

View File

@ -162,7 +162,10 @@ public:
virtual nsresult GetNameInternal(nsAString& aName);
virtual nsresult GetRoleInternal(PRUint32 *aRole);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
virtual PRInt32 GetLevelInternal();
virtual void GetPositionAndSizeInternal(PRInt32 *aPosInSet,
PRInt32 *aSetSize);
nsIFrame* GetBoundsFrame();
static nsresult GetFocusedOptionNode(nsIDOMNode *aListNode, nsIDOMNode **aFocusedOptionNode);

View File

@ -1194,41 +1194,35 @@ nsHyperTextAccessible::GetDefaultTextAttributes(nsIPersistentProperties **aAttri
return textAttrsMgr.GetAttributes(*aAttributes);
}
PRInt32
nsHyperTextAccessible::GetLevelInternal()
{
nsCOMPtr<nsIContent> content = nsCoreUtils::GetRoleContent(mDOMNode);
NS_ENSURE_TRUE(content, 0);
nsIAtom *tag = content->Tag();
if (tag == nsAccessibilityAtoms::h1)
return 1;
if (tag == nsAccessibilityAtoms::h2)
return 2;
if (tag == nsAccessibilityAtoms::h3)
return 3;
if (tag == nsAccessibilityAtoms::h4)
return 4;
if (tag == nsAccessibilityAtoms::h5)
return 5;
if (tag == nsAccessibilityAtoms::h6)
return 6;
return nsAccessibleWrap::GetLevelInternal();
}
nsresult
nsHyperTextAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
{
if (!mDOMNode) {
return NS_ERROR_FAILURE; // Node already shut down
}
nsresult rv = nsAccessibleWrap::GetAttributesInternal(aAttributes);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIContent> content = nsCoreUtils::GetRoleContent(mDOMNode);
NS_ENSURE_TRUE(content, NS_ERROR_UNEXPECTED);
nsIAtom *tag = content->Tag();
PRInt32 headLevel = 0;
if (tag == nsAccessibilityAtoms::h1)
headLevel = 1;
else if (tag == nsAccessibilityAtoms::h2)
headLevel = 2;
else if (tag == nsAccessibilityAtoms::h3)
headLevel = 3;
else if (tag == nsAccessibilityAtoms::h4)
headLevel = 4;
else if (tag == nsAccessibilityAtoms::h5)
headLevel = 5;
else if (tag == nsAccessibilityAtoms::h6)
headLevel = 6;
if (headLevel) {
nsAutoString strHeadLevel;
strHeadLevel.AppendInt(headLevel);
nsAccUtils::SetAccAttr(aAttributes, nsAccessibilityAtoms::level,
strHeadLevel);
}
// Indicate when the current object uses block-level formatting
// via formatting: block
// XXX: 'formatting' attribute is deprecated and will be removed in Mozilla2,

View File

@ -83,6 +83,7 @@ public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_HYPERTEXTACCESSIBLE_IMPL_CID)
// nsAccessible
virtual PRInt32 GetLevelInternal();
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
virtual nsresult GetRoleInternal(PRUint32 *aRole);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);

View File

@ -370,20 +370,11 @@ __try {
nsAutoString description;
// Try to get group attributes to make a positional description string. We
// can't use nsIAccessible::groupPosition because the method isn't supposed
// to work with elements exposing 'level' attribute only (like HTML headings).
nsCOMPtr<nsIPersistentProperties> attributes;
nsresult rv = xpAccessible->GetAttributes(getter_AddRefs(attributes));
NS_ENSURE_SUCCESS(rv, rv);
if (!attributes)
return NS_ERROR_FAILURE;
// Try to get group position to make a positional description string.
PRInt32 groupLevel = 0;
PRInt32 itemsInGroup = 0;
PRInt32 positionInGroup = 0;
nsAccUtils::GetAccGroupAttrs(attributes, &groupLevel, &positionInGroup,
&itemsInGroup);
GroupPosition(&groupLevel, &itemsInGroup, &positionInGroup);
if (positionInGroup > 0) {
if (groupLevel > 0) {
@ -1340,18 +1331,22 @@ __try {
PRInt32 groupLevel = 0;
PRInt32 similarItemsInGroup = 0;
PRInt32 positionInGroup = 0;
nsresult rv = GroupPosition(&groupLevel, &similarItemsInGroup,
&positionInGroup);
if (NS_FAILED(rv))
return GetHRESULT(rv);
// Group information for accessibles having level only (like html headings
// elements) isn't exposed by this method. AT should look for 'level' object
// attribute.
if (!similarItemsInGroup && !positionInGroup)
return S_FALSE;
*aGroupLevel = groupLevel;
*aSimilarItemsInGroup = similarItemsInGroup;
*aPositionInGroup = positionInGroup;
if (NS_FAILED(rv))
return GetHRESULT(rv);
if (groupLevel ==0 && similarItemsInGroup == 0 && positionInGroup == 0)
return S_FALSE;
return S_OK;
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }

View File

@ -659,9 +659,9 @@ nsXULProgressMeterAccessible::SetCurrentValue(double aValue)
}
/**
* XUL Radio Button
*/
////////////////////////////////////////////////////////////////////////////////
// nsXULRadioButtonAccessible
////////////////////////////////////////////////////////////////////////////////
/** Constructor */
nsXULRadioButtonAccessible::nsXULRadioButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
@ -692,20 +692,19 @@ nsXULRadioButtonAccessible::GetStateInternal(PRUint32 *aState,
return NS_OK;
}
nsresult
nsXULRadioButtonAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
void
nsXULRadioButtonAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet,
PRInt32 *aSetSize)
{
NS_ENSURE_ARG_POINTER(aAttributes);
NS_ENSURE_TRUE(mDOMNode, NS_ERROR_FAILURE);
nsresult rv = nsFormControlAccessible::GetAttributesInternal(aAttributes);
NS_ENSURE_SUCCESS(rv, rv);
nsAccUtils::SetAccAttrsForXULSelectControlItem(mDOMNode, aAttributes);
return NS_OK;
nsAccUtils::GetPositionAndSizeForXULSelectControlItem(mDOMNode, aPosInSet,
aSetSize);
}
////////////////////////////////////////////////////////////////////////////////
// nsXULRadioGroupAccessible
////////////////////////////////////////////////////////////////////////////////
/**
* XUL Radio Group
* The Radio Group proxies for the Radio Buttons themselves. The Group gets
@ -773,15 +772,10 @@ nsXULButtonAccessible(aNode, aShell)
{
}
nsresult
nsXULToolbarButtonAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
void
nsXULToolbarButtonAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet,
PRInt32 *aSetSize)
{
NS_ENSURE_ARG_POINTER(aAttributes);
NS_ENSURE_TRUE(mDOMNode, NS_ERROR_FAILURE);
nsresult rv = nsXULButtonAccessible::GetAttributesInternal(aAttributes);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIAccessible> parent(GetParent());
PRInt32 setSize = 0;
PRInt32 posInSet = 0;
@ -804,10 +798,9 @@ nsXULToolbarButtonAccessible::GetAttributesInternal(nsIPersistentProperties *aAt
sibling.swap(tempSibling);
}
}
nsAccUtils::SetAccGroupAttrs(aAttributes, 0, posInSet, setSize);
return NS_OK;
*aPosInSet = posInSet;
*aSetSize = setSize;
}
PRBool

View File

@ -148,6 +148,9 @@ public:
virtual nsresult GetRoleInternal(PRUint32 *aRole);
};
/**
* Used for XUL radio button (xul:radio).
*/
class nsXULRadioButtonAccessible : public nsRadioButtonAccessible
{
@ -155,8 +158,9 @@ public:
nsXULRadioButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
// nsAccessible
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
virtual void GetPositionAndSizeInternal(PRInt32 *aPosInSet,
PRInt32 *aSetSize);
};
class nsXULRadioGroupAccessible : public nsXULSelectableAccessible
@ -182,7 +186,11 @@ class nsXULToolbarButtonAccessible : public nsXULButtonAccessible
{
public:
nsXULToolbarButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
// nsAccessible
virtual void GetPositionAndSizeInternal(PRInt32 *aPosInSet,
PRInt32 *aSetSize);
static PRBool IsSeparator(nsIAccessible *aAccessible);
};

View File

@ -1009,19 +1009,12 @@ nsXULListitemAccessible::GetAllowsAnonChildAccessibles()
return PR_TRUE;
}
nsresult
nsXULListitemAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
void
nsXULListitemAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet,
PRInt32 *aSetSize)
{
NS_ENSURE_ARG_POINTER(aAttributes);
// Call base class instead of nsXULMenuAccessible because menu accessible
// has own implementation of group attributes setting which interferes with
// this one.
nsresult rv = nsAccessible::GetAttributesInternal(aAttributes);
NS_ENSURE_SUCCESS(rv, rv);
nsAccUtils::SetAccAttrsForXULSelectControlItem(mDOMNode, aAttributes);
return NS_OK;
nsAccUtils::GetPositionAndSizeForXULSelectControlItem(mDOMNode, aPosInSet,
aSetSize);
}

View File

@ -129,7 +129,8 @@ public:
virtual nsresult GetNameInternal(nsAString& aName);
virtual nsresult GetRoleInternal(PRUint32 *aRole);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
virtual void GetPositionAndSizeInternal(PRInt32 *aPosInSet,
PRInt32 *aSetSize);
virtual PRBool GetAllowsAnonChildAccessibles();
protected:

View File

@ -502,17 +502,18 @@ nsXULMenuitemAccessible::GetRoleInternal(PRUint32 *aRole)
return NS_OK;
}
nsresult
nsXULMenuitemAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
PRInt32
nsXULMenuitemAccessible::GetLevelInternal()
{
NS_ENSURE_ARG_POINTER(aAttributes);
NS_ENSURE_TRUE(mDOMNode, NS_ERROR_FAILURE);
return nsAccUtils::GetLevelForXULContainerItem(mDOMNode);
}
nsresult rv = nsAccessible::GetAttributesInternal(aAttributes);
NS_ENSURE_SUCCESS(rv, rv);
nsAccUtils::SetAccAttrsForXULContainerItem(mDOMNode, aAttributes);
return NS_OK;
void
nsXULMenuitemAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet,
PRInt32 *aSetSize)
{
nsAccUtils::GetPositionAndSizeForXULContainerItem(mDOMNode, aPosInSet,
aSetSize);
}
PRBool

View File

@ -92,7 +92,9 @@ public:
virtual nsresult GetNameInternal(nsAString& aName);
virtual nsresult GetRoleInternal(PRUint32 *aRole);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
virtual PRInt32 GetLevelInternal();
virtual void GetPositionAndSizeInternal(PRInt32 *aPosInSet,
PRInt32 *aSetSize);
virtual PRBool GetAllowsAnonChildAccessibles();
};

View File

@ -201,20 +201,19 @@ nsXULTabAccessible::GetRelationByType(PRUint32 aRelationType,
return NS_OK;
}
nsresult
nsXULTabAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
void
nsXULTabAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet,
PRInt32 *aSetSize)
{
NS_ENSURE_ARG_POINTER(aAttributes);
NS_ENSURE_TRUE(mDOMNode, NS_ERROR_FAILURE);
nsresult rv = nsLeafAccessible::GetAttributesInternal(aAttributes);
NS_ENSURE_SUCCESS(rv, rv);
nsAccUtils::SetAccAttrsForXULSelectControlItem(mDOMNode, aAttributes);
return NS_OK;
nsAccUtils::GetPositionAndSizeForXULSelectControlItem(mDOMNode, aPosInSet,
aSetSize);
}
////////////////////////////////////////////////////////////////////////////////
// nsXULTabBoxAccessible
////////////////////////////////////////////////////////////////////////////////
/**
* XUL TabBox
* to facilitate naming of the tabPanels object we will give this the name

View File

@ -61,7 +61,8 @@ public:
nsIAccessibleRelation **aRelation);
// nsAccessible
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
virtual void GetPositionAndSizeInternal(PRInt32 *aPosInSet,
PRInt32 *aSetSize);
virtual nsresult GetRoleInternal(PRUint32 *aRole);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
};

View File

@ -962,10 +962,20 @@ nsXULTreeItemAccessibleBase::Shutdown()
////////////////////////////////////////////////////////////////////////////////
// nsXULTreeItemAccessibleBase: nsAccessible public methods
// nsIAccessible::groupPosition
nsresult
nsXULTreeItemAccessibleBase::GetAttributesInternal(nsIPersistentProperties *aAttributes)
nsXULTreeItemAccessibleBase::GroupPosition(PRInt32 *aGroupLevel,
PRInt32 *aSimilarItemsInGroup,
PRInt32 *aPositionInGroup)
{
NS_ENSURE_ARG_POINTER(aAttributes);
NS_ENSURE_ARG_POINTER(aGroupLevel);
*aGroupLevel = 0;
NS_ENSURE_ARG_POINTER(aSimilarItemsInGroup);
*aSimilarItemsInGroup = 0;
NS_ENSURE_ARG_POINTER(aPositionInGroup);
*aPositionInGroup = 0;
if (IsDefunct())
return NS_ERROR_FAILURE;
@ -1005,8 +1015,10 @@ nsXULTreeItemAccessibleBase::GetAttributesInternal(nsIPersistentProperties *aAtt
PRInt32 setSize = topCount + bottomCount;
PRInt32 posInSet = topCount;
// set the group attributes
nsAccUtils::SetAccGroupAttrs(aAttributes, level + 1, posInSet, setSize);
*aGroupLevel = level + 1;
*aSimilarItemsInGroup = setSize;
*aPositionInGroup = posInSet;
return NS_OK;
}

View File

@ -187,6 +187,10 @@ public:
NS_IMETHOD GetRelationByType(PRUint32 aRelationType,
nsIAccessibleRelation **aRelation);
NS_IMETHOD GroupPosition(PRInt32 *aGroupLevel,
PRInt32 *aSimilarItemsInGroup,
PRInt32 *aPositionInGroup);
NS_IMETHOD GetNumActions(PRUint8 *aCount);
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
NS_IMETHOD DoAction(PRUint8 aIndex);
@ -196,7 +200,6 @@ public:
virtual nsresult Shutdown();
// nsAccessible
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
virtual nsIAccessible* GetParent();

View File

@ -28,7 +28,8 @@ function testAbsentAttrs(aAccOrElmOrID, aAbsentAttrs)
}
/**
* Test group object attributes (posinset, setsize and level)
* Test group object attributes (posinset, setsize and level) and
* nsIAccessible::groupPosition() method.
*
* @param aAccOrElmOrID [in] the ID, DOM node or accessible
* @param aPosInSet [in] the value of 'posinset' attribute
@ -37,15 +38,30 @@ function testAbsentAttrs(aAccOrElmOrID, aAbsentAttrs)
*/
function testGroupAttrs(aAccOrElmOrID, aPosInSet, aSetSize, aLevel)
{
var attrs = {
"posinset": String(aPosInSet),
"setsize": String(aSetSize)
};
var acc = getAccessible(aAccOrElmOrID);
var levelObj = {}, posInSetObj = {}, setSizeObj = {};
acc.groupPosition(levelObj, setSizeObj, posInSetObj);
if (aLevel)
attrs["level"] = String(aLevel);
if (aPosInSet && aSetSize) {
is(posInSetObj.value, aPosInSet,
"Wrong group position (posinset) for " + prettyName(aAccOrElmOrID));
is(setSizeObj.value, aSetSize,
"Wrong size of the group (setsize) for " + prettyName(aAccOrElmOrID));
testAttrs(aAccOrElmOrID, attrs, true);
var attrs = {
"posinset": String(aPosInSet),
"setsize": String(aSetSize)
};
testAttrs(aAccOrElmOrID, attrs, true);
}
if (aLevel) {
is(levelObj.value, aLevel,
"Wrong group level for " + prettyName(aAccOrElmOrID));
var attrs = { "level" : String(aLevel) };
testAttrs(aAccOrElmOrID, attrs, true);
}
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -23,6 +23,25 @@
testGroupAttrs("opt1", 1, 2);
testGroupAttrs("opt2", 2, 2);
//////////////////////////////////////////////////////////////////////////
// HTML select with options
// XXX bug 469123
//testGroupAttrs("select2_optgroup", 1, 3, 1);
//testGroupAttrs("select2_opt3", 2, 3, 1);
//testGroupAttrs("select2_opt4", 3, 3, 1);
//testGroupAttrs("select2_opt1", 1, 2, 2);
//testGroupAttrs("select2_opt2", 2, 2, 2);
//////////////////////////////////////////////////////////////////////////
// HTML input@type="radio" within form
testGroupAttrs("radio1", 1, 2);
testGroupAttrs("radio2", 2, 2);
//////////////////////////////////////////////////////////////////////////
// HTML input@type="radio" within document
testGroupAttrs("radio3", 1, 2);
testGroupAttrs("radio4", 2, 2);
//////////////////////////////////////////////////////////////////////////
// HTML ul/ol
testGroupAttrs("li1", 1, 3);
@ -56,6 +75,28 @@
testGroupAttrs("n_li11", 2, 3, 2);
testGroupAttrs("n_li12", 3, 3, 2);
//////////////////////////////////////////////////////////////////////////
// ARIA menu (menuitem, separator, menuitemradio and menuitemcheckbox)
testGroupAttrs("menu_item1", 1, 2);
testGroupAttrs("menu_item2", 2, 2);
testGroupAttrs("menu_item1.1", 1, 2);
testGroupAttrs("menu_item1.2", 2, 2);
testGroupAttrs("menu_item1.3", 1, 3);
testGroupAttrs("menu_item1.4", 2, 3);
testGroupAttrs("menu_item1.5", 3, 3);
//////////////////////////////////////////////////////////////////////////
// ARIA tab
testGroupAttrs("tab_1", 1, 3);
testGroupAttrs("tab_2", 2, 3);
testGroupAttrs("tab_3", 3, 3);
//////////////////////////////////////////////////////////////////////////
// ARIA radio
testGroupAttrs("r1", 1, 3);
testGroupAttrs("r2", 2, 3);
testGroupAttrs("r3", 3, 3);
//////////////////////////////////////////////////////////////////////////
// ARIA grid
testGroupAttrs("grid_row1", 1, 2);
@ -80,6 +121,15 @@
testGroupAttrs("treegrid_cell5", 1, 2);
testGroupAttrs("treegrid_cell6", 2, 2);
//////////////////////////////////////////////////////////////////////////
// HTML headings
testGroupAttrs("h1", 0, 0, 1);
testGroupAttrs("h2", 0, 0, 2);
testGroupAttrs("h3", 0, 0, 3);
testGroupAttrs("h4", 0, 0, 4);
testGroupAttrs("h5", 0, 0, 5);
testGroupAttrs("h6", 0, 0, 6);
SimpleTest.finish();
}
@ -105,6 +155,23 @@
<option id="opt2">option2</option>
</select>
<select size="4">
<optgroup id="select2_optgroup" label="group">
<option id="select2_opt1">option1</option>
<option id="select2_opt2">option2</option>
</optgroup>
<option id="select2_opt3">option3</option>
<option id="select2_opt4">option4</option>
</select>
<form>
<input type="radio" id="radio1" name="group1"/>
<input type="radio" id="radio2" name="group1"/>
</form>
<input type="radio" id="radio3" name="group2"/>
<input type="radio" id="radio4" name="group2"/>
<ul>
<li id="li1">Oranges</li>
<li id="li2">Apples</li>
@ -141,6 +208,32 @@
</span>
</span>
<ul role="menubar">
<li role="menuitem" aria-haspopup="true" id="menu_item1">File
<ul role="menu">
<li role="menuitem" id="menu_item1.1">New</li>
<li role="menuitem" id="menu_item1.2">Open…</li>
<li role="separator">-----</li>
<li role="menuitem" id="menu_item1.3">Item</li>
<li role="menuitemradio" id="menu_item1.4">Radio</li>
<li role="menuitemcheckbox" id="menu_item1.5">Checkbox</li>
</ul>
</li>
<li role="menuitem" aria-haspopup="false" id="menu_item2">Help</li>
</ul>
<ul id="tablist_1" role="tablist">
<li id="tab_1" role="tab">Crust</li>
<li id="tab_2" role="tab">Veges</li>
<li id="tab_3" role="tab">Carnivore</li>
</ul>
<ul id="rg1" role="radiogroup">
<li id="r1" role="radio" aria-checked="false">Thai</li>
<li id="r2" role="radio" aria-checked="false">Subway</li>
<li id="r3" role="radio" aria-checked="false">Jimmy Johns</li>
</ul>
<table role="grid">
<tr role="row" id="grid_row1">
<td role="gridcell" id="grid_cell1">cell1</td>
@ -166,5 +259,13 @@
<div role="gridcell" id="treegrid_cell6">cell2</div>
</div>
</div>
<h1 id="h1">heading1</h1>
<h2 id="h2">heading2</h2>
<h3 id="h3">heading3</h3>
<h4 id="h4">heading4</h4>
<h5 id="h5">heading5</h5>
<h6 id="h6">heading6</h6>
</body>
</html>

View File

@ -22,8 +22,8 @@
{
//////////////////////////////////////////////////////////////////////////
// xul:listbox (bug 417317)
testGroupAttrs("item1", "1", "2");
testGroupAttrs("item2", "2", "2");
testGroupAttrs("item1", 1, 2);
testGroupAttrs("item2", 2, 2);
//////////////////////////////////////////////////////////////////////////
// xul:menu (bug 443881)
@ -35,23 +35,33 @@
menu2.open = true;
window.setTimeout(function() {
testGroupAttrs("menu_item1.1", "1", "1");
testGroupAttrs("menu_item1.2", "1", "3");
testGroupAttrs("menu_item1.4", "2", "3");
testGroupAttrs("menu_item2", "3", "3");
testGroupAttrs("menu_item2.1", "1", "2", "1");
testGroupAttrs("menu_item2.2", "2", "2", "1");
testGroupAttrs("menu_item1.1", 1, 1);
testGroupAttrs("menu_item1.2", 1, 3);
testGroupAttrs("menu_item1.4", 2, 3);
testGroupAttrs("menu_item2", 3, 3);
testGroupAttrs("menu_item2.1", 1, 2, 1);
testGroupAttrs("menu_item2.2", 2, 2, 1);
SimpleTest.finish();
}, 200);
}, 200);
//////////////////////////////////////////////////////////////////////////
// xul:tab
testGroupAttrs("tab1", 1, 2);
testGroupAttrs("tab2", 2, 2);
//////////////////////////////////////////////////////////////////////////
// xul:radio
testGroupAttrs("radio1", 1, 2);
testGroupAttrs("radio2", 2, 2);
//////////////////////////////////////////////////////////////////////////
// ARIA menu (bug 441888)
testGroupAttrs("aria-menuitem", "1", "3");
testGroupAttrs("aria-menuitemcheckbox", "2", "3");
testGroupAttrs("aria-menuitemradio", "3", "3");
testGroupAttrs("aria-menuitem2", "1", "1");
testGroupAttrs("aria-menuitem", 1, 3);
testGroupAttrs("aria-menuitemcheckbox", 2, 3);
testGroupAttrs("aria-menuitemradio", 3, 3);
testGroupAttrs("aria-menuitem2", 1, 1);
}
SimpleTest.waitForExplicitFinish();
@ -106,6 +116,22 @@
</menu>
</menubar>
<tabbox>
<tabs>
<tab id="tab1" label="tab1"/>
<tab id="tab2" label="tab3"/>
</tabs>
<tabpanels>
<tabpanel/>
<tabpanel/>
</tabpanels>
</tabbox>
<radiogroup>
<radio id="radio1" label="radio1"/>
<radio id="radio2" label="radio2"/>
</radiogroup>
<vbox>
<description role="menuitem" id="aria-menuitem"
value="conventional menuitem"/>

View File

@ -31,22 +31,22 @@
var tree = getAccessible(treeNode);
var treeitem1 = tree.firstChild.nextSibling;
testGroupAttrs(treeitem1, "1", "4", "1");
testGroupAttrs(treeitem1, 1, 4, 1);
var treeitem2 = treeitem1.nextSibling;
testGroupAttrs(treeitem2, "2", "4", "1");
testGroupAttrs(treeitem2, 2, 4, 1);
var treeitem3 = treeitem2.nextSibling;
testGroupAttrs(treeitem3, "1", "2", "2");
testGroupAttrs(treeitem3, 1, 2, 2);
var treeitem4 = treeitem3.nextSibling;
testGroupAttrs(treeitem4, "2", "2", "2");
testGroupAttrs(treeitem4, 2, 2, 2);
var treeitem5 = treeitem4.nextSibling;
testGroupAttrs(treeitem5, "3", "4", "1");
testGroupAttrs(treeitem5, 3, 4, 1);
var treeitem6 = treeitem5.nextSibling;
testGroupAttrs(treeitem6, "4", "4", "1");
testGroupAttrs(treeitem6, 4, 4, 1);
SimpleTest.finish();
}