зеркало из https://github.com/mozilla/gecko-dev.git
Bug 457219 - collapsed and expanded states are exposed both, r=marcoz, aaronlev
This commit is contained in:
Родитель
dc484fbeef
Коммит
b8b067f3c5
|
@ -2464,6 +2464,17 @@ nsAccessible::GetFinalState(PRUint32 *aState, PRUint32 *aExtraState)
|
|||
}
|
||||
}
|
||||
|
||||
const PRUint32 kExpandCollapseStates =
|
||||
nsIAccessibleStates::STATE_COLLAPSED | nsIAccessibleStates::STATE_EXPANDED;
|
||||
if ((*aState & kExpandCollapseStates) == kExpandCollapseStates) {
|
||||
// Cannot be both expanded and collapsed -- this happens in ARIA expanded
|
||||
// combobox because of limitation of nsARIAMap.
|
||||
// XXX: Perhaps we will be able to make this less hacky if we support
|
||||
// extended states in nsARIAMap, e.g. derive COLLAPSED from
|
||||
// EXPANDABLE && !EXPANDED.
|
||||
*aState &= ~nsIAccessibleStates::STATE_COLLAPSED;
|
||||
}
|
||||
|
||||
// Set additional states which presence depends on another states.
|
||||
if (!aExtraState)
|
||||
return NS_OK;
|
||||
|
@ -2473,19 +2484,9 @@ nsAccessible::GetFinalState(PRUint32 *aState, PRUint32 *aExtraState)
|
|||
nsIAccessibleStates::EXT_STATE_SENSITIVE;
|
||||
}
|
||||
|
||||
const PRUint32 kExpandCollapseStates =
|
||||
nsIAccessibleStates::STATE_COLLAPSED | nsIAccessibleStates::STATE_EXPANDED;
|
||||
if (*aState & kExpandCollapseStates) {
|
||||
if ((*aState & nsIAccessibleStates::STATE_COLLAPSED) ||
|
||||
(*aState & nsIAccessibleStates::STATE_EXPANDED))
|
||||
*aExtraState |= nsIAccessibleStates::EXT_STATE_EXPANDABLE;
|
||||
if ((*aState & kExpandCollapseStates) == kExpandCollapseStates) {
|
||||
// Cannot be both expanded and collapsed -- this happens
|
||||
// in ARIA expanded combobox because of limitation of nsARIAMap
|
||||
// XXX Perhaps we will be able to make this less hacky if
|
||||
// we support extended states in nsARIAMap, e.g. derive
|
||||
// COLLAPSED from EXPANDABLE && !EXPANDED
|
||||
*aExtraState &= ~nsIAccessibleStates::STATE_COLLAPSED;
|
||||
}
|
||||
}
|
||||
|
||||
if (mRoleMapEntry) {
|
||||
// If an object has an ancestor with the activedescendant property
|
||||
|
|
|
@ -54,6 +54,7 @@ _TEST_FILES =\
|
|||
nsIAccessible_name.js \
|
||||
nsIAccessible_name.xbl \
|
||||
nsIAccessible_selects.js \
|
||||
nsIAccessible_states.js \
|
||||
nsIAccessibleEditableText.js \
|
||||
test_aria_activedescendant.html \
|
||||
test_aria_role_article.html \
|
||||
|
@ -68,6 +69,7 @@ _TEST_FILES =\
|
|||
test_nsIAccessible_name.html \
|
||||
test_nsIAccessible_name.xul \
|
||||
test_nsIAccessible_selects.html \
|
||||
test_nsIAccessible_states.html \
|
||||
test_nsIAccessible_focus.html \
|
||||
test_nsIAccessibleDocument.html \
|
||||
test_nsIAccessibleEditableText.html \
|
||||
|
|
|
@ -32,6 +32,7 @@ const nsIDOMNode = Components.interfaces.nsIDOMNode;
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Roles
|
||||
|
||||
const ROLE_COMBOBOX = nsIAccessibleRole.ROLE_COMBOBOX;
|
||||
const ROLE_COMBOBOX_LIST = nsIAccessibleRole.ROLE_COMBOBOX_LIST;
|
||||
const ROLE_COMBOBOX_OPTION = nsIAccessibleRole.ROLE_COMBOBOX_OPTION;
|
||||
|
@ -42,6 +43,7 @@ const ROLE_TEXT_LEAF = nsIAccessibleRole.ROLE_TEXT_LEAF;
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// States
|
||||
|
||||
const STATE_COLLAPSED = nsIAccessibleStates.STATE_COLLAPSED;
|
||||
const STATE_EXPANDED = nsIAccessibleStates.STATE_EXPANDED;
|
||||
const STATE_EXTSELECTABLE = nsIAccessibleStates.STATE_EXTSELECTABLE;
|
||||
|
@ -49,9 +51,13 @@ const STATE_FOCUSABLE = nsIAccessibleStates.STATE_FOCUSABLE;
|
|||
const STATE_FOCUSED = nsIAccessibleStates.STATE_FOCUSED;
|
||||
const STATE_HASPOPUP = nsIAccessibleStates.STATE_HASPOPUP;
|
||||
const STATE_MULTISELECTABLE = nsIAccessibleStates.STATE_MULTISELECTABLE;
|
||||
const STATE_READONLY = nsIAccessibleStates.STATE_READONLY;
|
||||
const STATE_SELECTABLE = nsIAccessibleStates.STATE_SELECTABLE;
|
||||
const STATE_SELECTED = nsIAccessibleStates.STATE_SELECTED;
|
||||
|
||||
const EXT_STATE_EDITABLE = nsIAccessibleStates.EXT_STATE_EDITABLE;
|
||||
const EXT_STATE_EXPANDABLE = nsIAccessibleStates.EXT_STATE_EXPANDABLE;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Accessible general
|
||||
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
function testStates(aAccOrElmOrID, aState, aExtraState, aAbsentState)
|
||||
{
|
||||
var [state, extraState] = getStates(aAccOrElmOrID);
|
||||
|
||||
is(state & aState, aState,
|
||||
"wrong state bits for " + aAccOrElmOrID + "!");
|
||||
|
||||
if (aExtraState)
|
||||
is(extraState & aExtraState, aExtraState,
|
||||
"wrong extra state bits for " + aAccOrElmOrID + "!");
|
||||
|
||||
if (aAbsentState)
|
||||
is(state & aAbsentState, 0,
|
||||
"state bits should not be present in ID " + aAccOrElmOrID + "!");
|
||||
|
||||
if (state & STATE_READONLY)
|
||||
is(extraState & EXT_STATE_EDITABLE, 0,
|
||||
"Read-only " + aAccOrElmOrID + " cannot be editable!");
|
||||
|
||||
if (extraState & EXT_STATE_EDITABLE)
|
||||
is(state & STATE_READONLY, 0,
|
||||
"Editable " + aAccOrElmOrID + " cannot be readonly!");
|
||||
|
||||
if (state & STATE_COLLAPSED || state & STATE_EXPANDED)
|
||||
is(extraState & EXT_STATE_EXPANDABLE, EXT_STATE_EXPANDABLE,
|
||||
"Collapsed or expanded " + aAccOrElmOrID + " should be expandable!");
|
||||
|
||||
if (state & STATE_COLLAPSED)
|
||||
is(state & STATE_EXPANDED, 0,
|
||||
"Collapsed " + aAccOrElmOrID + " cannot be expanded!");
|
||||
|
||||
if (state & STATE_EXPANDED)
|
||||
is(state & STATE_COLLAPSED, 0,
|
||||
"Expanded " + aAccOrElmOrID + " cannot be collapsed!");
|
||||
}
|
||||
|
||||
function getStringStates(aAccOrElmOrID)
|
||||
{
|
||||
var [state, extraState] = getStates(aAccOrElmOrID);
|
||||
var list = gAccRetrieval.getStringStates(state, extraState);
|
||||
|
||||
var str = "";
|
||||
for (var index = 0; index < list.length; index++)
|
||||
str += list.item(index) + ", ";
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
function getStates(aAccOrElmOrID)
|
||||
{
|
||||
var acc = getAccessible(aAccOrElmOrID);
|
||||
if (!acc)
|
||||
return [0, 0];
|
||||
|
||||
var state = {}, extraState = {};
|
||||
acc.getFinalState(state, extraState);
|
||||
|
||||
return [state.value, extraState.value];
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
<html>
|
||||
|
||||
<head>
|
||||
<title>nsIAccessible states testing</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/a11y/accessible/nsIAccessible_states.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
function doTest()
|
||||
{
|
||||
testStates("combobox", STATE_COLLAPSED);
|
||||
testStates("combobox_expanded", STATE_EXPANDED);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(doTest);
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=457219"
|
||||
title="nsIAccessible states testing">
|
||||
Mozilla Bug 457219
|
||||
</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<div id="combobox" role="combobox">combobox</div>
|
||||
|
||||
<div id="combobox_expanded" role="combobox"
|
||||
aria-expanded="true">combobox</div>
|
||||
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче