From c21cc8b61164dffec98f9636db62c6f04dc0a837 Mon Sep 17 00:00:00 2001 From: David Bolter Date: Sat, 21 Feb 2009 08:43:51 +0100 Subject: [PATCH] Bug 477876 - expose checkable='true' object attribute, r=surkov, r=MarcoZ --- accessible/src/base/nsARIAMap.cpp | 6 ++-- accessible/src/base/nsAccessibilityAtomList.h | 1 + accessible/src/base/nsAccessible.cpp | 24 +++------------ .../mochitest/test_aria_token_attrs.html | 10 +++---- .../tests/mochitest/test_objectattrs.html | 29 +++++++++++++++---- 5 files changed, 37 insertions(+), 33 deletions(-) diff --git a/accessible/src/base/nsARIAMap.cpp b/accessible/src/base/nsARIAMap.cpp index be73f3d7a8c..064517fd5a4 100644 --- a/accessible/src/base/nsARIAMap.cpp +++ b/accessible/src/base/nsARIAMap.cpp @@ -103,8 +103,8 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] = eClickAction, eNoLiveAttr, kNoReqStates, - {&nsAccessibilityAtoms::aria_pressed, kBoolState, nsIAccessibleStates::STATE_PRESSED}, - {&nsAccessibilityAtoms::aria_pressed, "mixed", nsIAccessibleStates::STATE_MIXED}, + {&nsAccessibilityAtoms::aria_pressed, kBoolState, nsIAccessibleStates::STATE_PRESSED | nsIAccessibleStates::STATE_CHECKABLE}, + {&nsAccessibilityAtoms::aria_pressed, "mixed", nsIAccessibleStates::STATE_MIXED | nsIAccessibleStates::STATE_CHECKABLE}, kEndEntry }, { @@ -380,7 +380,7 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] = eNoValue, eSelectAction, eNoLiveAttr, - kNoReqStates, + nsIAccessibleStates::STATE_CHECKABLE, {&nsAccessibilityAtoms::aria_checked, kBoolState, nsIAccessibleStates::STATE_CHECKED}, kEndEntry }, diff --git a/accessible/src/base/nsAccessibilityAtomList.h b/accessible/src/base/nsAccessibilityAtomList.h index 8ef576e755d..98d9df11a79 100644 --- a/accessible/src/base/nsAccessibilityAtomList.h +++ b/accessible/src/base/nsAccessibilityAtomList.h @@ -188,6 +188,7 @@ ACCESSIBILITY_ATOM(type, "type") ACCESSIBILITY_ATOM(value, "value") // Alphabetical list of object attributes +ACCESSIBILITY_ATOM(checkable, "checkable") ACCESSIBILITY_ATOM(display, "display") ACCESSIBILITY_ATOM(textAlign, "text-align") ACCESSIBILITY_ATOM(textIndent, "text-indent") diff --git a/accessible/src/base/nsAccessible.cpp b/accessible/src/base/nsAccessible.cpp index 99ec53c7f45..adca88323dd 100644 --- a/accessible/src/base/nsAccessible.cpp +++ b/accessible/src/base/nsAccessible.cpp @@ -1691,31 +1691,15 @@ nsAccessible::GetAttributes(nsIPersistentProperties **aAttributes) attributes->SetStringProperty(NS_LITERAL_CSTRING("valuetext"), valuetext, oldValueUnused); } - - PRUint32 role = nsAccUtils::Role(this); - if (role == nsIAccessibleRole::ROLE_CHECKBUTTON || - role == nsIAccessibleRole::ROLE_PUSHBUTTON || - role == nsIAccessibleRole::ROLE_MENUITEM || - role == nsIAccessibleRole::ROLE_LISTITEM || - role == nsIAccessibleRole::ROLE_OPTION || - role == nsIAccessibleRole::ROLE_RADIOBUTTON || - role == nsIAccessibleRole::ROLE_RICH_OPTION || - role == nsIAccessibleRole::ROLE_OUTLINEITEM || - content->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::aria_checked)) { - // Might be checkable -- checking role & ARIA attribute first is faster than getting state - PRUint32 state = 0; - GetState(&state, nsnull); - if (state & nsIAccessibleStates::STATE_CHECKABLE) { - // No official state for checkable, so use object attribute to expose that - attributes->SetStringProperty(NS_LITERAL_CSTRING("checkable"), NS_LITERAL_STRING("true"), - oldValueUnused); - } - } + // Expose checkable object attribute if the accessible has checkable state + if (nsAccUtils::State(this) & nsIAccessibleStates::STATE_CHECKABLE) + 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); } diff --git a/accessible/tests/mochitest/test_aria_token_attrs.html b/accessible/tests/mochitest/test_aria_token_attrs.html index 7baf64c79d7..b2114f9c6c2 100644 --- a/accessible/tests/mochitest/test_aria_token_attrs.html +++ b/accessible/tests/mochitest/test_aria_token_attrs.html @@ -55,11 +55,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=452388 testStates("native_checkbox_nativeunchecked_ariaabsent", STATE_CHECKABLE, 0, STATE_CHECKED); // test button aria-pressed states - testStates("button_pressed_true", STATE_PRESSED); - testStates("button_pressed_false", 0, 0, STATE_PRESSED); - testStates("button_pressed_empty", 0, 0, STATE_PRESSED); - testStates("button_pressed_undefined", 0, 0, STATE_PRESSED); - testStates("button_pressed_absent", 0, 0, STATE_PRESSED); + testStates("button_pressed_true", STATE_PRESSED | STATE_CHECKABLE); + testStates("button_pressed_false", 0, 0, STATE_PRESSED | STATE_CHECKABLE); + testStates("button_pressed_empty", 0, 0, STATE_PRESSED | STATE_CHECKABLE); + testStates("button_pressed_undefined", 0, 0, STATE_PRESSED | STATE_CHECKABLE); + testStates("button_pressed_absent", 0, 0, STATE_PRESSED | STATE_CHECKABLE); // test aria-pressed state mapping to roles PUSHBUTTON vs TOGGLEBUTTON var aButton = getAccessible("button_pressed_true"); diff --git a/accessible/tests/mochitest/test_objectattrs.html b/accessible/tests/mochitest/test_objectattrs.html index 8c849f5cef9..f9585db7b8b 100644 --- a/accessible/tests/mochitest/test_objectattrs.html +++ b/accessible/tests/mochitest/test_objectattrs.html @@ -20,9 +20,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=475006