Bug 390284. Support ARIA roles that are dependent on a role + ARIA properties. r=evan.yan, a=dsicore

This commit is contained in:
aaronleventhal@moonset.net 2007-08-03 18:54:07 -07:00
Родитель 8515f2abd3
Коммит e6dac1351b
3 изменённых файлов: 31 добавлений и 7 удалений

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

@ -179,12 +179,15 @@ ACCESSIBILITY_ATOM(activedescendant, "activedescendant")
ACCESSIBILITY_ATOM(checked, "checked")
ACCESSIBILITY_ATOM(droppable, "droppable")
ACCESSIBILITY_ATOM(expanded, "expanded")
ACCESSIBILITY_ATOM(haspopup, "haspopup")
ACCESSIBILITY_ATOM(invalid, "invalid")
ACCESSIBILITY_ATOM(level, "level")
ACCESSIBILITY_ATOM(multiselectable, "multiselectable")
ACCESSIBILITY_ATOM(posinset, "posinset")
ACCESSIBILITY_ATOM(pressed, "pressed")
ACCESSIBILITY_ATOM(required, "required")
ACCESSIBILITY_ATOM(role, "role")
ACCESSIBILITY_ATOM(secret, "secret")
ACCESSIBILITY_ATOM(selected, "selected")
ACCESSIBILITY_ATOM(setsize, "setsize")
ACCESSIBILITY_ATOM(valuenow, "valuenow") // For DHTML widget values

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

@ -2043,6 +2043,34 @@ NS_IMETHODIMP nsAccessible::GetFinalRole(PRUint32 *aRole)
{
if (mRoleMapEntry) {
*aRole = mRoleMapEntry->role;
// These unfortunate exceptions don't fit into the ARIA table
// This is where the nsIAccessible role depends on both the role and ARIA state
if (*aRole == nsIAccessibleRole::ROLE_ENTRY) {
nsCOMPtr<nsIContent> content = do_QueryInterface(mDOMNode);
if (content &&
content->AttrValueIs(kNameSpaceID_WAIProperties , nsAccessibilityAtoms::secret,
nsAccessibilityAtoms::_true, eCaseMatters)) {
// For entry field with aaa:secret="true"
*aRole = nsIAccessibleRole::ROLE_PASSWORD_TEXT;
}
}
else if (*aRole == nsIAccessibleRole::ROLE_PUSHBUTTON) {
nsCOMPtr<nsIContent> content = do_QueryInterface(mDOMNode);
if (content) {
if (content->HasAttr(kNameSpaceID_WAIProperties, nsAccessibilityAtoms::pressed)) {
// For aaa:pressed="false" or aaa:pressed="true"
// For simplicity, any pressed attribute indicates it's a toggle button
*aRole = nsIAccessibleRole::ROLE_TOGGLE_BUTTON;
}
else if (content->AttrValueIs(kNameSpaceID_WAIProperties, nsAccessibilityAtoms::haspopup,
nsAccessibilityAtoms::_true, eCaseMatters)) {
// For button with aaa:haspopup="true"
*aRole = nsIAccessibleRole::ROLE_BUTTONMENU;
}
}
}
if (*aRole != nsIAccessibleRole::ROLE_NOTHING) {
return NS_OK;
}

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

@ -434,13 +434,6 @@ STDMETHODIMP nsAccessibleWrap::get_accRole(
NS_ASSERTION(gWindowsRoleMap[nsIAccessibleRole::ROLE_LAST_ENTRY].msaaRole == ROLE_WINDOWS_LAST_ENTRY,
"MSAA role map skewed");
// Special case, not a great place for this, but it's better than adding extra role buttonmenu role to ARIA
// Other APIs do not have a special role for this.
// Really the HASPOPUP state should have been enough for MSAA, but this avoids asking vendors for a fix.
if (msaaRole == ROLE_SYSTEM_PUSHBUTTON && (State(xpAccessible) & nsIAccessibleStates::STATE_HASPOPUP)) {
msaaRole = ROLE_SYSTEM_BUTTONMENU;
}
// Special case, if there is a ROLE_ROW inside of a ROLE_TREE_TABLE, then call the MSAA role
// a ROLE_OUTLINEITEM for consistency and compatibility.
// We need this because ARIA has a role of "row" for both grid and treegrid