Bug 592193 - add dexpcom version of nsIAccessible::role, part3: reduce amount of nsAccUtils::Role calls, r=marcoz, a=davidb
This commit is contained in:
@@ -52,7 +52,7 @@ AccGroupInfo::AccGroupInfo(nsAccessible* aItem, PRUint32 aRole) :
|
||||
mPosInSet = 1;
|
||||
for (PRInt32 idx = indexInParent - 1; idx >=0 ; idx--) {
|
||||
nsAccessible* sibling = parent->GetChildAt(idx);
|
||||
PRUint32 siblingRole = nsAccUtils::Role(sibling);
|
||||
PRUint32 siblingRole = sibling->Role();
|
||||
|
||||
// If the sibling is separator then the group is ended.
|
||||
if (siblingRole == nsIAccessibleRole::ROLE_SEPARATOR)
|
||||
@@ -96,7 +96,7 @@ AccGroupInfo::AccGroupInfo(nsAccessible* aItem, PRUint32 aRole) :
|
||||
for (PRInt32 idx = indexInParent + 1; idx < siblingCount; idx++) {
|
||||
nsAccessible* sibling = parent->GetChildAt(idx);
|
||||
|
||||
PRUint32 siblingRole = nsAccUtils::Role(sibling);
|
||||
PRUint32 siblingRole = sibling->Role();
|
||||
|
||||
// If the sibling is separator then the group is ended.
|
||||
if (siblingRole == nsIAccessibleRole::ROLE_SEPARATOR)
|
||||
@@ -131,7 +131,7 @@ AccGroupInfo::AccGroupInfo(nsAccessible* aItem, PRUint32 aRole) :
|
||||
return;
|
||||
|
||||
// Compute parent.
|
||||
PRUint32 parentRole = nsAccUtils::Role(parent);
|
||||
PRUint32 parentRole = parent->Role();
|
||||
|
||||
// In the case of ARIA row in treegrid, return treegrid since ARIA
|
||||
// groups aren't used to organize levels in ARIA treegrids.
|
||||
@@ -153,14 +153,18 @@ AccGroupInfo::AccGroupInfo(nsAccessible* aItem, PRUint32 aRole) :
|
||||
}
|
||||
|
||||
nsAccessible* parentPrevSibling = parent->GetSiblingAtOffset(-1);
|
||||
PRUint32 parentPrevSiblingRole = nsAccUtils::Role(parentPrevSibling);
|
||||
if (!parentPrevSibling)
|
||||
return;
|
||||
|
||||
PRUint32 parentPrevSiblingRole = parentPrevSibling->Role();
|
||||
if (parentPrevSiblingRole == nsIAccessibleRole::ROLE_TEXT_LEAF) {
|
||||
// XXX Sometimes an empty text accessible is in the hierarchy here,
|
||||
// although the text does not appear to be rendered, GetRenderedText()
|
||||
// says that it is so we need to skip past it to find the true
|
||||
// previous sibling.
|
||||
parentPrevSibling = parentPrevSibling->GetSiblingAtOffset(-1);
|
||||
parentPrevSiblingRole = nsAccUtils::Role(parentPrevSibling);
|
||||
if (parentPrevSibling)
|
||||
parentPrevSiblingRole = parentPrevSibling->Role();
|
||||
}
|
||||
|
||||
// Previous sibling of parent group is a tree item, this is the
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
*/
|
||||
static AccGroupInfo* CreateGroupInfo(nsAccessible* aAccessible)
|
||||
{
|
||||
PRUint32 role = nsAccUtils::Role(aAccessible);
|
||||
PRUint32 role = aAccessible->Role();
|
||||
if (role != nsIAccessibleRole::ROLE_ROW &&
|
||||
role != nsIAccessibleRole::ROLE_GRID_CELL &&
|
||||
role != nsIAccessibleRole::ROLE_OUTLINEITEM &&
|
||||
|
||||
@@ -55,13 +55,13 @@ filters::GetSelectable(nsAccessible* aAccessible)
|
||||
bool
|
||||
filters::GetRow(nsAccessible* aAccessible)
|
||||
{
|
||||
return nsAccUtils::Role(aAccessible) == nsIAccessibleRole::ROLE_ROW;
|
||||
return aAccessible->Role() == nsIAccessibleRole::ROLE_ROW;
|
||||
}
|
||||
|
||||
bool
|
||||
filters::GetCell(nsAccessible* aAccessible)
|
||||
{
|
||||
PRUint32 role = nsAccUtils::Role(aAccessible);
|
||||
PRUint32 role = aAccessible->Role();
|
||||
return role == nsIAccessibleRole::ROLE_GRID_CELL ||
|
||||
role == nsIAccessibleRole::ROLE_ROWHEADER ||
|
||||
role == nsIAccessibleRole::ROLE_COLUMNHEADER;
|
||||
|
||||
@@ -808,7 +808,7 @@ nsARIAGridAccessible::SetARIASelected(nsAccessible *aAccessible,
|
||||
if (aIsSelected)
|
||||
return NS_OK;
|
||||
|
||||
PRUint32 role = nsAccUtils::Role(aAccessible);
|
||||
PRUint32 role = aAccessible->Role();
|
||||
|
||||
// If the given accessible is row that was unselected then remove
|
||||
// aria-selected from cell accessible.
|
||||
@@ -831,7 +831,7 @@ nsARIAGridAccessible::SetARIASelected(nsAccessible *aAccessible,
|
||||
role == nsIAccessibleRole::ROLE_COLUMNHEADER) {
|
||||
nsAccessible *row = aAccessible->GetParent();
|
||||
|
||||
if (nsAccUtils::Role(row) == nsIAccessibleRole::ROLE_ROW &&
|
||||
if (row && row->Role() == nsIAccessibleRole::ROLE_ROW &&
|
||||
nsAccUtils::IsARIASelected(row)) {
|
||||
rv = SetARIASelected(row, PR_FALSE, PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@@ -948,15 +948,17 @@ nsARIAGridCellAccessible::GetTable(nsIAccessibleTable **aTable)
|
||||
NS_ENSURE_ARG_POINTER(aTable);
|
||||
*aTable = nsnull;
|
||||
|
||||
nsCOMPtr<nsIAccessible> thisRow;
|
||||
GetParent(getter_AddRefs(thisRow));
|
||||
if (nsAccUtils::Role(thisRow) != nsIAccessibleRole::ROLE_ROW)
|
||||
nsAccessible* thisRow = GetParent();
|
||||
if (!thisRow || thisRow->Role() != nsIAccessibleRole::ROLE_ROW)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIAccessible> table;
|
||||
thisRow->GetParent(getter_AddRefs(table));
|
||||
if (nsAccUtils::Role(table) != nsIAccessibleRole::ROLE_TABLE &&
|
||||
nsAccUtils::Role(table) != nsIAccessibleRole::ROLE_TREE_TABLE)
|
||||
nsAccessible* table = thisRow->GetParent();
|
||||
if (!table)
|
||||
return NS_OK;
|
||||
|
||||
PRUint32 tableRole = table->Role();
|
||||
if (tableRole != nsIAccessibleRole::ROLE_TABLE &&
|
||||
tableRole != nsIAccessibleRole::ROLE_TREE_TABLE)
|
||||
return NS_OK;
|
||||
|
||||
CallQueryInterface(table, aTable);
|
||||
@@ -972,20 +974,20 @@ nsARIAGridCellAccessible::GetColumnIndex(PRInt32 *aColumnIndex)
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsAccessible* row = GetParent();
|
||||
if (!row)
|
||||
return NS_OK;
|
||||
|
||||
*aColumnIndex = 0;
|
||||
|
||||
nsCOMPtr<nsIAccessible> prevCell, tmpAcc;
|
||||
GetPreviousSibling(getter_AddRefs(prevCell));
|
||||
|
||||
while (prevCell) {
|
||||
PRUint32 role = nsAccUtils::Role(prevCell);
|
||||
PRInt32 indexInRow = GetIndexInParent();
|
||||
for (PRInt32 idx = 0; idx < indexInRow; idx++) {
|
||||
nsAccessible* cell = row->GetChildAt(idx);
|
||||
PRUint32 role = cell->Role();
|
||||
if (role == nsIAccessibleRole::ROLE_GRID_CELL ||
|
||||
role == nsIAccessibleRole::ROLE_ROWHEADER ||
|
||||
role == nsIAccessibleRole::ROLE_COLUMNHEADER)
|
||||
(*aColumnIndex)++;
|
||||
|
||||
prevCell->GetPreviousSibling(getter_AddRefs(tmpAcc));
|
||||
tmpAcc.swap(prevCell);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@@ -1000,15 +1002,21 @@ nsARIAGridCellAccessible::GetRowIndex(PRInt32 *aRowIndex)
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIAccessible> row, prevRow;
|
||||
GetParent(getter_AddRefs(row));
|
||||
nsAccessible* row = GetParent();
|
||||
if (!row)
|
||||
return NS_OK;
|
||||
|
||||
while (row) {
|
||||
if (nsAccUtils::Role(row) == nsIAccessibleRole::ROLE_ROW)
|
||||
nsAccessible* table = row->GetParent();
|
||||
if (!table)
|
||||
return NS_OK;
|
||||
|
||||
*aRowIndex = 0;
|
||||
|
||||
PRInt32 indexInTable = row->GetIndexInParent();
|
||||
for (PRInt32 idx = 0; idx < indexInTable; idx++) {
|
||||
row = table->GetChildAt(idx);
|
||||
if (row->Role() == nsIAccessibleRole::ROLE_ROW)
|
||||
(*aRowIndex)++;
|
||||
|
||||
row->GetPreviousSibling(getter_AddRefs(prevRow));
|
||||
row.swap(prevRow);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@@ -1088,7 +1096,7 @@ nsARIAGridCellAccessible::IsSelected(PRBool *aIsSelected)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsAccessible *row = GetParent();
|
||||
if (nsAccUtils::Role(row) != nsIAccessibleRole::ROLE_ROW)
|
||||
if (!row || row->Role() != nsIAccessibleRole::ROLE_ROW)
|
||||
return NS_OK;
|
||||
|
||||
if (!nsAccUtils::IsARIASelected(row) && !nsAccUtils::IsARIASelected(this))
|
||||
@@ -1112,8 +1120,8 @@ nsARIAGridCellAccessible::GetARIAState(PRUint32 *aState, PRUint32 *aExtraState)
|
||||
return NS_OK;
|
||||
|
||||
// Check aria-selected="true" on the row.
|
||||
nsAccessible *row = GetParent();
|
||||
if (nsAccUtils::Role(row) != nsIAccessibleRole::ROLE_ROW)
|
||||
nsAccessible* row = GetParent();
|
||||
if (!row || row->Role() != nsIAccessibleRole::ROLE_ROW)
|
||||
return NS_OK;
|
||||
|
||||
nsIContent *rowContent = row->GetContent();
|
||||
@@ -1141,8 +1149,8 @@ nsARIAGridCellAccessible::GetAttributesInternal(nsIPersistentProperties *aAttrib
|
||||
|
||||
// Expose "table-cell-index" attribute.
|
||||
|
||||
nsAccessible *thisRow = GetParent();
|
||||
if (nsAccUtils::Role(thisRow) != nsIAccessibleRole::ROLE_ROW)
|
||||
nsAccessible* thisRow = GetParent();
|
||||
if (!thisRow || thisRow->Role() != nsIAccessibleRole::ROLE_ROW)
|
||||
return NS_OK;
|
||||
|
||||
PRInt32 colIdx = 0, colCount = 0;
|
||||
@@ -1152,16 +1160,20 @@ nsARIAGridCellAccessible::GetAttributesInternal(nsIPersistentProperties *aAttrib
|
||||
if (child == this)
|
||||
colIdx = colCount;
|
||||
|
||||
PRUint32 role = nsAccUtils::Role(child);
|
||||
PRUint32 role = child->Role();
|
||||
if (role == nsIAccessibleRole::ROLE_GRID_CELL ||
|
||||
role == nsIAccessibleRole::ROLE_ROWHEADER ||
|
||||
role == nsIAccessibleRole::ROLE_COLUMNHEADER)
|
||||
colCount++;
|
||||
}
|
||||
|
||||
nsAccessible *table = thisRow->GetParent();
|
||||
if (nsAccUtils::Role(table) != nsIAccessibleRole::ROLE_TABLE &&
|
||||
nsAccUtils::Role(table) != nsIAccessibleRole::ROLE_TREE_TABLE)
|
||||
nsAccessible* table = thisRow->GetParent();
|
||||
if (!table)
|
||||
return NS_OK;
|
||||
|
||||
PRUint32 tableRole = table->Role();
|
||||
if (tableRole != nsIAccessibleRole::ROLE_TABLE &&
|
||||
tableRole != nsIAccessibleRole::ROLE_TREE_TABLE)
|
||||
return NS_OK;
|
||||
|
||||
PRInt32 rowIdx = 0;
|
||||
@@ -1171,7 +1183,7 @@ nsARIAGridCellAccessible::GetAttributesInternal(nsIPersistentProperties *aAttrib
|
||||
if (child == thisRow)
|
||||
break;
|
||||
|
||||
if (nsAccUtils::Role(child) == nsIAccessibleRole::ROLE_ROW)
|
||||
if (child->Role() == nsIAccessibleRole::ROLE_ROW)
|
||||
rowIdx++;
|
||||
}
|
||||
|
||||
|
||||
@@ -103,14 +103,14 @@ nsAccUtils::SetAccGroupAttrs(nsIPersistentProperties *aAttributes,
|
||||
PRInt32
|
||||
nsAccUtils::GetDefaultLevel(nsAccessible *aAccessible)
|
||||
{
|
||||
PRUint32 role = nsAccUtils::Role(aAccessible);
|
||||
PRUint32 role = aAccessible->Role();
|
||||
|
||||
if (role == nsIAccessibleRole::ROLE_OUTLINEITEM)
|
||||
return 1;
|
||||
|
||||
if (role == nsIAccessibleRole::ROLE_ROW) {
|
||||
nsAccessible *parent = aAccessible->GetParent();
|
||||
if (Role(parent) == nsIAccessibleRole::ROLE_TREE_TABLE) {
|
||||
if (parent && parent->Role() == 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;
|
||||
@@ -357,7 +357,7 @@ nsAccUtils::GetAncestorWithRole(nsAccessible *aDescendant, PRUint32 aRole)
|
||||
nsAccessible *document = aDescendant->GetDocAccessible();
|
||||
nsAccessible *parent = aDescendant;
|
||||
while ((parent = parent->GetParent())) {
|
||||
PRUint32 testRole = nsAccUtils::Role(parent);
|
||||
PRUint32 testRole = parent->Role();
|
||||
if (testRole == aRole)
|
||||
return parent;
|
||||
|
||||
|
||||
@@ -943,7 +943,7 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode,
|
||||
|
||||
if (tableAccessible) {
|
||||
if (!roleMapEntry) {
|
||||
PRUint32 role = nsAccUtils::Role(tableAccessible);
|
||||
PRUint32 role = tableAccessible->Role();
|
||||
if (role != nsIAccessibleRole::ROLE_TABLE &&
|
||||
role != nsIAccessibleRole::ROLE_TREE_TABLE) {
|
||||
// No ARIA role and not in table: override role. For example,
|
||||
|
||||
@@ -1832,7 +1832,7 @@ nsAccessible::Role()
|
||||
} else if (mRoleMapEntry->role == nsIAccessibleRole::ROLE_LISTBOX) {
|
||||
// A listbox inside of a combobox needs a special role because of ATK
|
||||
// mapping to menu.
|
||||
if (nsAccUtils::Role(mParent) == nsIAccessibleRole::ROLE_COMBOBOX) {
|
||||
if (mParent && mParent->Role() == nsIAccessibleRole::ROLE_COMBOBOX) {
|
||||
return nsIAccessibleRole::ROLE_COMBOBOX_LIST;
|
||||
|
||||
nsCOMPtr<nsIAccessible> possibleCombo =
|
||||
@@ -1843,7 +1843,7 @@ nsAccessible::Role()
|
||||
}
|
||||
|
||||
} else if (mRoleMapEntry->role == nsIAccessibleRole::ROLE_OPTION) {
|
||||
if (nsAccUtils::Role(mParent) == nsIAccessibleRole::ROLE_COMBOBOX_LIST)
|
||||
if (mParent && mParent->Role() == nsIAccessibleRole::ROLE_COMBOBOX_LIST)
|
||||
return nsIAccessibleRole::ROLE_COMBOBOX_OPTION;
|
||||
}
|
||||
|
||||
@@ -3352,7 +3352,7 @@ nsAccessible::GetLevelInternal()
|
||||
{
|
||||
PRInt32 level = nsAccUtils::GetDefaultLevel(this);
|
||||
|
||||
PRUint32 role = nsAccUtils::Role(this);
|
||||
PRUint32 role = Role();
|
||||
nsAccessible* parent = GetParent();
|
||||
|
||||
if (role == nsIAccessibleRole::ROLE_OUTLINEITEM) {
|
||||
@@ -3362,7 +3362,7 @@ nsAccessible::GetLevelInternal()
|
||||
level = 1;
|
||||
|
||||
while (parent) {
|
||||
PRUint32 parentRole = nsAccUtils::Role(parent);
|
||||
PRUint32 parentRole = parent->Role();
|
||||
|
||||
if (parentRole == nsIAccessibleRole::ROLE_OUTLINE)
|
||||
break;
|
||||
@@ -3382,7 +3382,7 @@ nsAccessible::GetLevelInternal()
|
||||
level = 0;
|
||||
|
||||
while (parent) {
|
||||
PRUint32 parentRole = nsAccUtils::Role(parent);
|
||||
PRUint32 parentRole = parent->Role();
|
||||
|
||||
if (parentRole == nsIAccessibleRole::ROLE_LISTITEM)
|
||||
++ level;
|
||||
|
||||
@@ -257,17 +257,17 @@ nsLinkableAccessible::CacheActionContent()
|
||||
}
|
||||
|
||||
while ((walkUpContent = walkUpContent->GetParent())) {
|
||||
isOnclick = nsCoreUtils::HasClickListener(walkUpContent);
|
||||
nsAccessible *walkUpAcc =
|
||||
nsAccessible* walkUpAcc =
|
||||
GetAccService()->GetAccessibleInWeakShell(walkUpContent, mWeakShell);
|
||||
|
||||
if (nsAccUtils::Role(walkUpAcc) == nsIAccessibleRole::ROLE_LINK &&
|
||||
if (walkUpAcc && walkUpAcc->Role() == nsIAccessibleRole::ROLE_LINK &&
|
||||
nsAccUtils::State(walkUpAcc) & nsIAccessibleStates::STATE_LINKED) {
|
||||
mIsLink = PR_TRUE;
|
||||
mActionContent = walkUpContent;
|
||||
return;
|
||||
}
|
||||
|
||||
isOnclick = nsCoreUtils::HasClickListener(walkUpContent);
|
||||
if (isOnclick) {
|
||||
mActionContent = walkUpContent;
|
||||
mIsOnclick = PR_TRUE;
|
||||
|
||||
@@ -1285,7 +1285,7 @@ nsDocAccessible::HandleAccEvent(AccEvent* aAccEvent)
|
||||
void
|
||||
nsDocAccessible::FireValueChangeForTextFields(nsAccessible *aAccessible)
|
||||
{
|
||||
if (nsAccUtils::Role(aAccessible) != nsIAccessibleRole::ROLE_ENTRY)
|
||||
if (aAccessible->Role() != nsIAccessibleRole::ROLE_ENTRY)
|
||||
return;
|
||||
|
||||
// Dependent value change event for text changes in textfields
|
||||
@@ -1372,7 +1372,7 @@ nsDocAccessible::CreateTextChangeEventForNode(nsAccessible *aContainerAccessible
|
||||
PRInt32 offset = 0;
|
||||
if (aChangeChild) {
|
||||
// Don't fire event for the first html:br in an editor.
|
||||
if (nsAccUtils::Role(aChangeChild) == nsIAccessibleRole::ROLE_WHITESPACE) {
|
||||
if (aChangeChild->Role() == nsIAccessibleRole::ROLE_WHITESPACE) {
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
textAccessible->GetAssociatedEditor(getter_AddRefs(editor));
|
||||
if (editor) {
|
||||
@@ -1624,8 +1624,7 @@ nsDocAccessible::RefreshNodes(nsINode *aStartNode)
|
||||
nsAccessible *accessible = GetCachedAccessible(aStartNode);
|
||||
if (accessible) {
|
||||
// Fire menupopup end if a menu goes away
|
||||
PRUint32 role = nsAccUtils::Role(accessible);
|
||||
if (role == nsIAccessibleRole::ROLE_MENUPOPUP) {
|
||||
if (accessible->Role() == nsIAccessibleRole::ROLE_MENUPOPUP) {
|
||||
nsCOMPtr<nsIDOMXULPopupElement> popup(do_QueryInterface(aStartNode));
|
||||
if (!popup) {
|
||||
// Popup elements already fire these via DOMMenuInactive
|
||||
|
||||
@@ -532,8 +532,7 @@ nsAccEventQueue::CreateTextChangeEventFor(AccHideEvent* aEvent)
|
||||
return;
|
||||
|
||||
// Don't fire event for the first html:br in an editor.
|
||||
if (nsAccUtils::Role(aEvent->mAccessible) ==
|
||||
nsIAccessibleRole::ROLE_WHITESPACE) {
|
||||
if (aEvent->mAccessible->Role() == nsIAccessibleRole::ROLE_WHITESPACE) {
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
textAccessible->GetAssociatedEditor(getter_AddRefs(editor));
|
||||
if (editor) {
|
||||
|
||||
@@ -385,7 +385,7 @@ nsRootAccessible::FireAccessibleFocusEvent(nsAccessible *aAccessible,
|
||||
}
|
||||
|
||||
gLastFocusedAccessiblesState = nsAccUtils::State(finalFocusAccessible);
|
||||
PRUint32 role = nsAccUtils::Role(finalFocusAccessible);
|
||||
PRUint32 role = finalFocusAccessible->Role();
|
||||
if (role == nsIAccessibleRole::ROLE_MENUITEM) {
|
||||
if (!mCurrentARIAMenubar) { // Entering menus
|
||||
// The natural role is the role that this type of element normally has
|
||||
@@ -673,7 +673,7 @@ nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
|
||||
HandlePopupShownEvent(accessible);
|
||||
}
|
||||
else if (eventType.EqualsLiteral("DOMMenuInactive")) {
|
||||
if (nsAccUtils::Role(accessible) == nsIAccessibleRole::ROLE_MENUPOPUP) {
|
||||
if (accessible->Role() == nsIAccessibleRole::ROLE_MENUPOPUP) {
|
||||
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_END,
|
||||
accessible);
|
||||
}
|
||||
@@ -707,7 +707,7 @@ nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
|
||||
if (nsAccUtils::State(containerAccessible) & nsIAccessibleStates::STATE_COLLAPSED) {
|
||||
nsAccessible *containerParent = containerAccessible->GetParent();
|
||||
NS_ENSURE_TRUE(containerParent, NS_ERROR_FAILURE);
|
||||
if (nsAccUtils::Role(containerParent) != nsIAccessibleRole::ROLE_COMBOBOX) {
|
||||
if (containerParent->Role() != nsIAccessibleRole::ROLE_COMBOBOX) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
@@ -856,7 +856,7 @@ nsRootAccessible::GetRelationByType(PRUint32 aRelationType,
|
||||
nsresult
|
||||
nsRootAccessible::HandlePopupShownEvent(nsAccessible *aAccessible)
|
||||
{
|
||||
PRUint32 role = nsAccUtils::Role(aAccessible);
|
||||
PRUint32 role = aAccessible->Role();
|
||||
|
||||
if (role == nsIAccessibleRole::ROLE_MENUPOPUP) {
|
||||
// Don't fire menupopup events for combobox and autocomplete lists.
|
||||
@@ -876,12 +876,14 @@ nsRootAccessible::HandlePopupShownEvent(nsAccessible *aAccessible)
|
||||
|
||||
if (role == nsIAccessibleRole::ROLE_COMBOBOX_LIST) {
|
||||
// Fire expanded state change event for comboboxes and autocompeletes.
|
||||
nsAccessible *comboboxAcc = aAccessible->GetParent();
|
||||
PRUint32 comboboxRole = nsAccUtils::Role(comboboxAcc);
|
||||
nsAccessible* combobox = aAccessible->GetParent();
|
||||
NS_ENSURE_STATE(combobox);
|
||||
|
||||
PRUint32 comboboxRole = combobox->Role();
|
||||
if (comboboxRole == nsIAccessibleRole::ROLE_COMBOBOX ||
|
||||
comboboxRole == nsIAccessibleRole::ROLE_AUTOCOMPLETE) {
|
||||
nsRefPtr<AccEvent> event =
|
||||
new AccStateChangeEvent(comboboxAcc,
|
||||
new AccStateChangeEvent(combobox,
|
||||
nsIAccessibleStates::STATE_EXPANDED,
|
||||
PR_FALSE, PR_TRUE);
|
||||
NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);
|
||||
@@ -914,16 +916,17 @@ nsRootAccessible::HandlePopupHidingEvent(nsINode *aNode,
|
||||
if (!aAccessible)
|
||||
return NS_OK;
|
||||
|
||||
PRUint32 role = nsAccUtils::Role(aAccessible);
|
||||
if (role != nsIAccessibleRole::ROLE_COMBOBOX_LIST)
|
||||
if (aAccessible->Role() != nsIAccessibleRole::ROLE_COMBOBOX_LIST)
|
||||
return NS_OK;
|
||||
|
||||
nsAccessible *comboboxAcc = aAccessible->GetParent();
|
||||
PRUint32 comboboxRole = nsAccUtils::Role(comboboxAcc);
|
||||
nsAccessible* combobox = aAccessible->GetParent();
|
||||
NS_ENSURE_STATE(combobox);
|
||||
|
||||
PRUint32 comboboxRole = combobox->Role();
|
||||
if (comboboxRole == nsIAccessibleRole::ROLE_COMBOBOX ||
|
||||
comboboxRole == nsIAccessibleRole::ROLE_AUTOCOMPLETE) {
|
||||
nsRefPtr<AccEvent> event =
|
||||
new AccStateChangeEvent(comboboxAcc,
|
||||
new AccStateChangeEvent(combobox,
|
||||
nsIAccessibleStates::STATE_EXPANDED,
|
||||
PR_FALSE, PR_FALSE);
|
||||
NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
@@ -64,9 +64,7 @@ nsTextEquivUtils::GetNameFromSubtree(nsAccessible *aAccessible,
|
||||
|
||||
gInitiatorAcc = aAccessible;
|
||||
|
||||
PRUint32 role = nsAccUtils::Role(aAccessible);
|
||||
PRUint32 nameRule = gRoleToNameRulesMap[role];
|
||||
|
||||
PRUint32 nameRule = gRoleToNameRulesMap[aAccessible->Role()];
|
||||
if (nameRule == eFromSubtree) {
|
||||
//XXX: is it necessary to care the accessible is not a document?
|
||||
if (aAccessible->IsContent()) {
|
||||
@@ -269,9 +267,7 @@ nsTextEquivUtils::AppendFromAccessible(nsAccessible *aAccessible,
|
||||
// into subtree if accessible allows "text equivalent from subtree rule" or
|
||||
// it's not root and not control.
|
||||
if (isEmptyTextEquiv) {
|
||||
PRUint32 role = nsAccUtils::Role(aAccessible);
|
||||
PRUint32 nameRule = gRoleToNameRulesMap[role];
|
||||
|
||||
PRUint32 nameRule = gRoleToNameRulesMap[aAccessible->Role()];
|
||||
if (nameRule & eFromSubtreeIfRec) {
|
||||
rv = AppendFromAccessibleChildren(aAccessible, aString);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@@ -294,9 +290,7 @@ nsresult
|
||||
nsTextEquivUtils::AppendFromValue(nsAccessible *aAccessible,
|
||||
nsAString *aString)
|
||||
{
|
||||
PRUint32 role = nsAccUtils::Role(aAccessible);
|
||||
PRUint32 nameRule = gRoleToNameRulesMap[role];
|
||||
|
||||
PRUint32 nameRule = gRoleToNameRulesMap[aAccessible->Role()];
|
||||
if (nameRule != eFromValue)
|
||||
return NS_OK_NO_NAME_CLAUSE_HANDLED;
|
||||
|
||||
|
||||
@@ -460,7 +460,8 @@ nsHTMLTextFieldAccessible::GetStateInternal(PRUint32 *aState,
|
||||
*aState |= nsIAccessibleStates::STATE_PROTECTED;
|
||||
}
|
||||
else {
|
||||
if (nsAccUtils::Role(GetParent()) == nsIAccessibleRole::ROLE_AUTOCOMPLETE)
|
||||
nsAccessible* parent = GetParent();
|
||||
if (parent && parent->Role() == nsIAccessibleRole::ROLE_AUTOCOMPLETE)
|
||||
*aState |= nsIAccessibleStates::STATE_HASPOPUP;
|
||||
}
|
||||
|
||||
@@ -662,7 +663,7 @@ nsHTMLLegendAccessible::GetRelationByType(PRUint32 aRelationType,
|
||||
// Look for groupbox parent
|
||||
nsAccessible* groupbox = GetParent();
|
||||
|
||||
if (nsAccUtils::Role(groupbox) == nsIAccessibleRole::ROLE_GROUPING) {
|
||||
if (groupbox && groupbox->Role() == nsIAccessibleRole::ROLE_GROUPING) {
|
||||
// XXX: if group box exposes more than one relation of the given type
|
||||
// then we fail.
|
||||
nsCOMPtr<nsIAccessible> testLabelAccessible =
|
||||
|
||||
@@ -104,7 +104,7 @@ nsHTMLSelectListAccessible::GetStateInternal(PRUint32 *aState,
|
||||
PRUint32
|
||||
nsHTMLSelectListAccessible::NativeRole()
|
||||
{
|
||||
if (nsAccUtils::Role(mParent) == nsIAccessibleRole::ROLE_COMBOBOX)
|
||||
if (mParent && mParent->Role() == nsIAccessibleRole::ROLE_COMBOBOX)
|
||||
return nsIAccessibleRole::ROLE_COMBOBOX_LIST;
|
||||
|
||||
return nsIAccessibleRole::ROLE_LISTBOX;
|
||||
@@ -199,7 +199,7 @@ nsHTMLSelectOptionAccessible::
|
||||
PRUint32
|
||||
nsHTMLSelectOptionAccessible::NativeRole()
|
||||
{
|
||||
if (nsAccUtils::Role(mParent) == nsIAccessibleRole::ROLE_COMBOBOX_LIST)
|
||||
if (mParent && mParent->Role() == nsIAccessibleRole::ROLE_COMBOBOX_LIST)
|
||||
return nsIAccessibleRole::ROLE_COMBOBOX_OPTION;
|
||||
|
||||
return nsIAccessibleRole::ROLE_OPTION;
|
||||
@@ -348,10 +348,8 @@ nsHTMLSelectOptionAccessible::GetLevelInternal()
|
||||
PRInt32 level =
|
||||
parentContent->NodeInfo()->Equals(nsAccessibilityAtoms::optgroup) ? 2 : 1;
|
||||
|
||||
if (level == 1 &&
|
||||
nsAccUtils::Role(this) != nsIAccessibleRole::ROLE_HEADING) {
|
||||
if (level == 1 && Role() != nsIAccessibleRole::ROLE_HEADING)
|
||||
level = 0; // In a single level list, the level is irrelevant
|
||||
}
|
||||
|
||||
return level;
|
||||
}
|
||||
|
||||
@@ -267,20 +267,15 @@ nsHTMLTableCellAccessible::IsSelected(PRBool *aIsSelected)
|
||||
already_AddRefed<nsIAccessibleTable>
|
||||
nsHTMLTableCellAccessible::GetTableAccessible()
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> childAcc(this), parentAcc;
|
||||
childAcc->GetParent(getter_AddRefs(parentAcc));
|
||||
|
||||
while (parentAcc) {
|
||||
PRUint32 role = nsAccUtils::Role(parentAcc);
|
||||
nsAccessible* parent = this;
|
||||
while ((parent = parent->GetParent())) {
|
||||
PRUint32 role = parent->Role();
|
||||
if (role == nsIAccessibleRole::ROLE_TABLE ||
|
||||
role == nsIAccessibleRole::ROLE_TREE_TABLE) {
|
||||
nsIAccessibleTable* tableAcc = nsnull;
|
||||
CallQueryInterface(parentAcc, &tableAcc);
|
||||
CallQueryInterface(parent, &tableAcc);
|
||||
return tableAcc;
|
||||
}
|
||||
|
||||
parentAcc.swap(childAcc);
|
||||
childAcc->GetParent(getter_AddRefs(parentAcc));
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
@@ -334,9 +329,9 @@ nsHTMLTableCellAccessible::GetHeaderCells(PRInt32 aRowOrColumnHeaderCell,
|
||||
|
||||
if (headerCell &&
|
||||
(aRowOrColumnHeaderCell == nsAccUtils::eRowHeaderCells &&
|
||||
nsAccUtils::Role(headerCell) == nsIAccessibleRole::ROLE_ROWHEADER ||
|
||||
headerCell->Role() == nsIAccessibleRole::ROLE_ROWHEADER ||
|
||||
aRowOrColumnHeaderCell == nsAccUtils::eColumnHeaderCells &&
|
||||
nsAccUtils::Role(headerCell) == nsIAccessibleRole::ROLE_COLUMNHEADER))
|
||||
headerCell->Role() == nsIAccessibleRole::ROLE_COLUMNHEADER))
|
||||
headerCells->AppendElement(static_cast<nsIAccessible*>(headerCell),
|
||||
PR_FALSE);
|
||||
}
|
||||
@@ -453,7 +448,7 @@ nsHTMLTableAccessible::CacheChildren()
|
||||
|
||||
nsRefPtr<nsAccessible> child;
|
||||
while ((child = walker.GetNextChild())) {
|
||||
if (nsAccUtils::Role(child) == nsIAccessibleRole::ROLE_CAPTION) {
|
||||
if (child->Role() == nsIAccessibleRole::ROLE_CAPTION) {
|
||||
InsertChildAt(0, child);
|
||||
while ((child = walker.GetNextChild()) && AppendChild(child));
|
||||
break;
|
||||
@@ -532,9 +527,8 @@ nsHTMLTableAccessible::GetRelationByType(PRUint32 aRelationType,
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::GetCaption(nsIAccessible **aCaption)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> firstChild;
|
||||
GetFirstChild(getter_AddRefs(firstChild));
|
||||
if (nsAccUtils::Role(firstChild) == nsIAccessibleRole::ROLE_CAPTION)
|
||||
nsAccessible* firstChild = GetChildAt(0);
|
||||
if (firstChild && firstChild->Role() == nsIAccessibleRole::ROLE_CAPTION)
|
||||
NS_ADDREF(*aCaption = firstChild);
|
||||
|
||||
return NS_OK;
|
||||
@@ -1389,8 +1383,7 @@ nsHTMLTableAccessible::IsProbablyForLayout(PRBool *aIsProbablyForLayout)
|
||||
|
||||
// Check to see if an ARIA role overrides the role from native markup,
|
||||
// but for which we still expose table semantics (treegrid, for example).
|
||||
PRBool hasNonTableRole =
|
||||
(nsAccUtils::Role(this) != nsIAccessibleRole::ROLE_TABLE);
|
||||
PRBool hasNonTableRole = (Role() != nsIAccessibleRole::ROLE_TABLE);
|
||||
if (hasNonTableRole) {
|
||||
RETURN_LAYOUT_ANSWER(PR_FALSE, "Has role attribute");
|
||||
}
|
||||
|
||||
@@ -279,8 +279,7 @@ nsHyperTextAccessible::GetPosAndText(PRInt32& aStartOffset, PRInt32& aEndOffset,
|
||||
PRInt32 startOffset = aStartOffset;
|
||||
PRInt32 endOffset = aEndOffset;
|
||||
// XXX this prevents text interface usage on <input type="password">
|
||||
PRBool isPassword =
|
||||
(nsAccUtils::Role(this) == nsIAccessibleRole::ROLE_PASSWORD_TEXT);
|
||||
PRBool isPassword = (Role() == nsIAccessibleRole::ROLE_PASSWORD_TEXT);
|
||||
|
||||
// Clear out parameters and set up loop
|
||||
if (aText) {
|
||||
@@ -804,7 +803,7 @@ nsHyperTextAccessible::GetRelativeOffset(nsIPresShell *aPresShell,
|
||||
nsAccessible *firstChild = mChildren.SafeElementAt(0, nsnull);
|
||||
// For line selection with needsStart, set start of line exactly to line break
|
||||
if (pos.mContentOffset == 0 && firstChild &&
|
||||
nsAccUtils::Role(firstChild) == nsIAccessibleRole::ROLE_STATICTEXT &&
|
||||
firstChild->Role() == nsIAccessibleRole::ROLE_STATICTEXT &&
|
||||
static_cast<PRInt32>(nsAccUtils::TextLength(firstChild)) == hyperTextOffset) {
|
||||
// XXX Bullet hack -- we should remove this once list bullets use anonymous content
|
||||
hyperTextOffset = 0;
|
||||
@@ -816,7 +815,7 @@ nsHyperTextAccessible::GetRelativeOffset(nsIPresShell *aPresShell,
|
||||
else if (aAmount == eSelectEndLine && finalAccessible) {
|
||||
// If not at very end of hypertext, we may need change the end of line offset by 1,
|
||||
// to make sure we are in the right place relative to the line ending
|
||||
if (nsAccUtils::Role(finalAccessible) == nsIAccessibleRole::ROLE_WHITESPACE) { // Landed on <br> hard line break
|
||||
if (finalAccessible->Role() == nsIAccessibleRole::ROLE_WHITESPACE) { // Landed on <br> hard line break
|
||||
// if aNeedsStart, set end of line exactly 1 character past line break
|
||||
// XXX It would be cleaner if we did not have to have the hard line break check,
|
||||
// and just got the correct results from PeekOffset() for the <br> case -- the returned offset should
|
||||
@@ -983,7 +982,7 @@ nsresult nsHyperTextAccessible::GetTextHelper(EGetTextType aType, nsAccessibleTe
|
||||
nsRefPtr<nsAccessible> endAcc;
|
||||
nsIFrame *endFrame = GetPosAndText(startOffset, endOffset, nsnull, nsnull,
|
||||
nsnull, getter_AddRefs(endAcc));
|
||||
if (nsAccUtils::Role(endAcc) == nsIAccessibleRole::ROLE_STATICTEXT) {
|
||||
if (endAcc && endAcc->Role() == nsIAccessibleRole::ROLE_STATICTEXT) {
|
||||
// Static text like list bullets will ruin our forward calculation,
|
||||
// since the caret cannot be in the static text. Start just after the static text.
|
||||
startOffset = endOffset = finalStartOffset +
|
||||
|
||||
@@ -104,7 +104,7 @@ nsAccessibleWrap::GetNativeType ()
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
||||
|
||||
PRUint32 role = nsAccUtils::Role(this);
|
||||
PRUint32 role = Role();
|
||||
switch (role) {
|
||||
case nsIAccessibleRole::ROLE_PUSHBUTTON:
|
||||
case nsIAccessibleRole::ROLE_SPLITBUTTON:
|
||||
|
||||
@@ -408,7 +408,8 @@ __try {
|
||||
// a ROLE_OUTLINEITEM for consistency and compatibility.
|
||||
// We need this because ARIA has a role of "row" for both grid and treegrid
|
||||
if (xpRole == nsIAccessibleRole::ROLE_ROW) {
|
||||
if (nsAccUtils::Role(GetParent()) == nsIAccessibleRole::ROLE_TREE_TABLE)
|
||||
nsAccessible* xpParent = GetParent();
|
||||
if (xpParent && xpParent->Role() == nsIAccessibleRole::ROLE_TREE_TABLE)
|
||||
msaaRole = ROLE_SYSTEM_OUTLINEITEM;
|
||||
}
|
||||
|
||||
@@ -1198,7 +1199,8 @@ __try {
|
||||
// Special case, if there is a ROLE_ROW inside of a ROLE_TREE_TABLE, then call
|
||||
// the IA2 role a ROLE_OUTLINEITEM.
|
||||
if (xpRole == nsIAccessibleRole::ROLE_ROW) {
|
||||
if (nsAccUtils::Role(GetParent()) == nsIAccessibleRole::ROLE_TREE_TABLE)
|
||||
nsAccessible* xpParent = GetParent();
|
||||
if (xpParent && xpParent->Role() == nsIAccessibleRole::ROLE_TREE_TABLE)
|
||||
*aRole = ROLE_SYSTEM_OUTLINEITEM;
|
||||
}
|
||||
|
||||
|
||||
@@ -262,7 +262,7 @@ STDMETHODIMP nsDocAccessibleWrap::get_accValue(
|
||||
if (FAILED(hr) || *pszValue || varChild.lVal != CHILDID_SELF)
|
||||
return hr;
|
||||
// If document is being used to create a widget, don't use the URL hack
|
||||
PRUint32 role = nsAccUtils::Role(this);
|
||||
PRUint32 role = Role();
|
||||
if (role != nsIAccessibleRole::ROLE_DOCUMENT &&
|
||||
role != nsIAccessibleRole::ROLE_APPLICATION &&
|
||||
role != nsIAccessibleRole::ROLE_DIALOG &&
|
||||
|
||||
@@ -164,7 +164,7 @@ nsXULColorPickerAccessible::CacheChildren()
|
||||
|
||||
nsRefPtr<nsAccessible> child;
|
||||
while ((child = walker.GetNextChild())) {
|
||||
PRUint32 role = nsAccUtils::Role(child);
|
||||
PRUint32 role = child->Role();
|
||||
|
||||
// Get an accessbile for menupopup or panel elements.
|
||||
if (role == nsIAccessibleRole::ROLE_ALERT) {
|
||||
|
||||
@@ -211,7 +211,7 @@ nsXULButtonAccessible::CacheChildren()
|
||||
|
||||
nsRefPtr<nsAccessible> child;
|
||||
while ((child = walker.GetNextChild())) {
|
||||
PRUint32 role = nsAccUtils::Role(child);
|
||||
PRUint32 role = child->Role();
|
||||
|
||||
if (role == nsIAccessibleRole::ROLE_MENUPOPUP) {
|
||||
// Get an accessbile for menupopup or panel elements.
|
||||
@@ -476,7 +476,7 @@ nsXULGroupboxAccessible::GetRelationByType(PRUint32 aRelationType,
|
||||
PRInt32 childCount = GetChildCount();
|
||||
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
|
||||
nsAccessible *childAcc = GetChildAt(childIdx);
|
||||
if (nsAccUtils::Role(childAcc) == nsIAccessibleRole::ROLE_LABEL) {
|
||||
if (childAcc->Role() == nsIAccessibleRole::ROLE_LABEL) {
|
||||
// Ensure that it's our label
|
||||
// XXX: we'll fail if group accessible expose more than one relation
|
||||
// targets.
|
||||
|
||||
@@ -642,7 +642,7 @@ nsXULListboxAccessible::GetSelectedCells(nsIArray **aCells)
|
||||
PRInt32 cellCount = item->GetChildCount();
|
||||
for (PRInt32 cellIdx = 0; cellIdx < cellCount; cellIdx++) {
|
||||
nsAccessible *cell = mChildren[cellIdx];
|
||||
if (nsAccUtils::Role(cell) == nsIAccessibleRole::ROLE_CELL)
|
||||
if (cell->Role() == nsIAccessibleRole::ROLE_CELL)
|
||||
selCells->AppendElement(static_cast<nsIAccessible*>(cell), PR_FALSE);
|
||||
}
|
||||
}
|
||||
@@ -925,13 +925,13 @@ nsXULListitemAccessible::NativeRole()
|
||||
return nsIAccessibleRole::ROLE_NOTHING;
|
||||
}
|
||||
|
||||
if (nsAccUtils::Role(list) == nsIAccessibleRole::ROLE_TABLE)
|
||||
if (list->Role() == nsIAccessibleRole::ROLE_TABLE)
|
||||
return nsIAccessibleRole::ROLE_ROW;
|
||||
|
||||
if (mIsCheckbox)
|
||||
return nsIAccessibleRole::ROLE_CHECKBUTTON;
|
||||
|
||||
if (nsAccUtils::Role(mParent) == nsIAccessibleRole::ROLE_COMBOBOX_LIST)
|
||||
if (mParent && mParent->Role() == nsIAccessibleRole::ROLE_COMBOBOX_LIST)
|
||||
return nsIAccessibleRole::ROLE_COMBOBOX_OPTION;
|
||||
|
||||
return nsIAccessibleRole::ROLE_RICH_OPTION;
|
||||
@@ -1040,14 +1040,12 @@ nsXULListCellAccessible::GetTable(nsIAccessibleTable **aTable)
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIAccessible> thisRow;
|
||||
GetParent(getter_AddRefs(thisRow));
|
||||
if (nsAccUtils::Role(thisRow) != nsIAccessibleRole::ROLE_ROW)
|
||||
nsAccessible* thisRow = GetParent();
|
||||
if (!thisRow || thisRow->Role() != nsIAccessibleRole::ROLE_ROW)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIAccessible> table;
|
||||
thisRow->GetParent(getter_AddRefs(table));
|
||||
if (nsAccUtils::Role(table) != nsIAccessibleRole::ROLE_TABLE)
|
||||
nsAccessible* table = thisRow->GetParent();
|
||||
if (!table || table->Role() != nsIAccessibleRole::ROLE_TABLE)
|
||||
return NS_OK;
|
||||
|
||||
CallQueryInterface(table, aTable);
|
||||
@@ -1063,21 +1061,21 @@ nsXULListCellAccessible::GetColumnIndex(PRInt32 *aColumnIndex)
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsAccessible* row = GetParent();
|
||||
if (!row)
|
||||
return NS_OK;
|
||||
|
||||
*aColumnIndex = 0;
|
||||
|
||||
nsCOMPtr<nsIAccessible> prevCell, tmpAcc;
|
||||
GetPreviousSibling(getter_AddRefs(prevCell));
|
||||
|
||||
while (prevCell) {
|
||||
PRUint32 role = nsAccUtils::Role(prevCell);
|
||||
PRInt32 indexInRow = GetIndexInParent();
|
||||
for (PRInt32 idx = 0; idx < indexInRow; idx++) {
|
||||
nsAccessible* cell = row->GetChildAt(idx);
|
||||
PRUint32 role = cell->Role();
|
||||
if (role == nsIAccessibleRole::ROLE_CELL ||
|
||||
role == nsIAccessibleRole::ROLE_GRID_CELL ||
|
||||
role == nsIAccessibleRole::ROLE_ROWHEADER ||
|
||||
role == nsIAccessibleRole::ROLE_COLUMNHEADER)
|
||||
(*aColumnIndex)++;
|
||||
|
||||
prevCell->GetPreviousSibling(getter_AddRefs(tmpAcc));
|
||||
tmpAcc.swap(prevCell);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@@ -1092,15 +1090,21 @@ nsXULListCellAccessible::GetRowIndex(PRInt32 *aRowIndex)
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIAccessible> row, prevRow;
|
||||
GetParent(getter_AddRefs(row));
|
||||
nsAccessible* row = GetParent();
|
||||
if (!row)
|
||||
return NS_OK;
|
||||
|
||||
while (row) {
|
||||
if (nsAccUtils::Role(row) == nsIAccessibleRole::ROLE_ROW)
|
||||
nsAccessible* table = row->GetParent();
|
||||
if (!table)
|
||||
return NS_OK;
|
||||
|
||||
*aRowIndex = 0;
|
||||
|
||||
PRInt32 indexInTable = row->GetIndexInParent();
|
||||
for (PRInt32 idx = 0; idx < indexInTable; idx++) {
|
||||
row = table->GetChildAt(idx);
|
||||
if (row->Role() == nsIAccessibleRole::ROLE_ROW)
|
||||
(*aRowIndex)++;
|
||||
|
||||
row->GetPreviousSibling(getter_AddRefs(prevRow));
|
||||
row.swap(prevRow);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@@ -1152,7 +1156,7 @@ nsXULListCellAccessible::GetColumnHeaderCells(nsIArray **aHeaderCells)
|
||||
PRInt32 tableChildCount = tableAcc->GetChildCount();
|
||||
for (PRInt32 childIdx = 0; childIdx < tableChildCount; childIdx++) {
|
||||
nsAccessible *child = tableAcc->GetChildAt(childIdx);
|
||||
if (nsAccUtils::Role(child) == nsIAccessibleRole::ROLE_LIST) {
|
||||
if (child->Role() == nsIAccessibleRole::ROLE_LIST) {
|
||||
list = child;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -329,8 +329,7 @@ nsXULMenuitemAccessible::GetStateInternal(PRUint32 *aState,
|
||||
}
|
||||
|
||||
// Combo box listitem
|
||||
PRBool isComboboxOption =
|
||||
(nsAccUtils::Role(this) == nsIAccessibleRole::ROLE_COMBOBOX_OPTION);
|
||||
PRBool isComboboxOption = (Role() == nsIAccessibleRole::ROLE_COMBOBOX_OPTION);
|
||||
if (isComboboxOption) {
|
||||
// Is selected?
|
||||
PRBool isSelected = PR_FALSE;
|
||||
@@ -353,7 +352,7 @@ nsXULMenuitemAccessible::GetStateInternal(PRUint32 *aState,
|
||||
// Set selected option offscreen/invisible according to combobox state
|
||||
nsAccessible* grandParentAcc = parentAcc->GetParent();
|
||||
NS_ENSURE_TRUE(grandParentAcc, NS_ERROR_FAILURE);
|
||||
NS_ASSERTION(nsAccUtils::Role(grandParentAcc) == nsIAccessibleRole::ROLE_COMBOBOX,
|
||||
NS_ASSERTION(grandParentAcc->Role() == nsIAccessibleRole::ROLE_COMBOBOX,
|
||||
"grandparent of combobox listitem is not combobox");
|
||||
PRUint32 grandParentState, grandParentExtState;
|
||||
grandParentAcc->GetState(&grandParentState, &grandParentExtState);
|
||||
@@ -486,7 +485,7 @@ nsXULMenuitemAccessible::NativeRole()
|
||||
if (xulContainer)
|
||||
return nsIAccessibleRole::ROLE_PARENT_MENUITEM;
|
||||
|
||||
if (nsAccUtils::Role(mParent) == nsIAccessibleRole::ROLE_COMBOBOX_LIST)
|
||||
if (mParent && mParent->Role() == nsIAccessibleRole::ROLE_COMBOBOX_LIST)
|
||||
return nsIAccessibleRole::ROLE_COMBOBOX_OPTION;
|
||||
|
||||
if (mContent->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type,
|
||||
@@ -666,7 +665,7 @@ nsXULMenupopupAccessible::NativeRole()
|
||||
// If accessible is not bound to the tree (this happens while children are
|
||||
// cached) return general role.
|
||||
if (mParent) {
|
||||
PRUint32 role = nsAccUtils::Role(mParent);
|
||||
PRUint32 role = mParent->Role();
|
||||
if (role == nsIAccessibleRole::ROLE_COMBOBOX ||
|
||||
role == nsIAccessibleRole::ROLE_AUTOCOMPLETE) {
|
||||
return nsIAccessibleRole::ROLE_COMBOBOX_LIST;
|
||||
@@ -675,7 +674,8 @@ nsXULMenupopupAccessible::NativeRole()
|
||||
if (role == nsIAccessibleRole::ROLE_PUSHBUTTON) {
|
||||
// Some widgets like the search bar have several popups, owned by buttons.
|
||||
nsAccessible* grandParent = mParent->GetParent();
|
||||
if (nsAccUtils::Role(grandParent) == nsIAccessibleRole::ROLE_AUTOCOMPLETE)
|
||||
if (grandParent &&
|
||||
grandParent->Role() == nsIAccessibleRole::ROLE_AUTOCOMPLETE)
|
||||
return nsIAccessibleRole::ROLE_COMBOBOX_LIST;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,11 +102,9 @@ nsXULTextAccessible::GetRelationByType(PRUint32 aRelationType,
|
||||
// Caption is the label for groupbox
|
||||
nsIContent *parent = mContent->GetParent();
|
||||
if (parent && parent->Tag() == nsAccessibilityAtoms::caption) {
|
||||
nsCOMPtr<nsIAccessible> parentAccessible;
|
||||
GetParent(getter_AddRefs(parentAccessible));
|
||||
if (nsAccUtils::Role(parentAccessible) == nsIAccessibleRole::ROLE_GROUPING)
|
||||
return nsRelUtils::
|
||||
AddTarget(aRelationType, aRelation, parentAccessible);
|
||||
nsAccessible* parent = GetParent();
|
||||
if (parent && parent->Role() == nsIAccessibleRole::ROLE_GROUPING)
|
||||
return nsRelUtils::AddTarget(aRelationType, aRelation, parent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user