Bug 477876 - expose checkable='true' object attribute, r=surkov, r=MarcoZ

This commit is contained in:
David Bolter 2009-02-21 08:43:51 +01:00
parent 914fadd965
commit c21cc8b611
5 changed files with 37 additions and 33 deletions

View File

@ -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
},

View File

@ -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")

View File

@ -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);
}

View File

@ -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");

View File

@ -20,9 +20,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=475006
<script type="application/javascript">
function doTest()
{
testAttrs("atomic", {"atomic" : "true"}, true);
testAttrs("autocomplete", {"autocomplete" : "true"}, true);
// bug 477876 testAttrs("checked", {"checkable" : "true"}, true);
// aria
testAttrs("atomic", {"atomic" : "true"}, true);
testAttrs("autocomplete", {"autocomplete" : "true"}, true);
testAttrs("checkbox", {"checkable" : "true"}, true);
testAttrs("checkedCheckbox", {"checkable" : "true"}, true);
testAttrs("checkedMenuitem", {"checkable" : "true"}, true);
testAttrs("checkedOption", {"checkable" : "true"}, true);
testAttrs("checkedRadio", {"checkable" : "true"}, true);
testAttrs("checkedTreeitem", {"checkable" : "true"}, true);
testAttrs("dropeffect", {"dropeffect" : "copy"}, true);
// live object attribute
@ -41,6 +47,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=475006
testAttrs("statusChild", {"container-live" : "polite"}, true);
testAttrs("timerChild", {"container-live" : "off"}, true);
// html
testAttrs("radio", {"checkable" : "true"}, true);
testAttrs("checkbox", {"checkable" : "true"}, true);
SimpleTest.finish();
}
@ -60,9 +70,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=475006
<pre id="test">
</pre>
<!-- aria -->
<div id="atomic" aria-atomic="true"></div>
<div id="autocomplete" role="textbox" aria-autocomplete="true"></div>
<div id="checked" aria-checked="true"></div>
<div id="checkbox" role="checkbox"></div>
<div id="checkedCheckbox" role="checkbox" aria-checked="true"></div>
<div id="checkedMenuitem" role="menuitem" aria-checked="true"></div>
<div id="checkedOption" role="option" aria-checked="true"></div>
<div id="checkedRadio" role="radio" aria-checked="true"></div>
<div id="checkedTreeitem" role="treeitem" aria-checked="true"></div>
<div id="dropeffect" aria-dropeffect="copy"></div>
<div id="live" aria-live="polite">excuse <div id="liveChild">me</div></div>
@ -71,6 +87,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=475006
<div id="marquee" role="marquee">excuse <div id="marqueeChild">me</div></div>
<div id="status" role="status">excuse <div id="statusChild">me</div></div>
<div id="timer" role="timer">excuse <div id="timerChild">me</div></div>
<!-- html -->
<input id="radio" type="radio"/>
<input id="checkbox" type="checkbox"/>
</body>
</html>