Bug 689847 - Expose active state on current item of selectable widgets, r=davidb, tbsaunde

This commit is contained in:
Alexander Surkov 2011-12-07 17:10:22 +08:00
Родитель 8babfd2ddf
Коммит 68704655bd
3 изменённых файлов: 45 добавлений и 29 удалений

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

@ -1542,31 +1542,19 @@ nsAccessible::State()
if (!(state & states::UNAVAILABLE)) {
state |= states::ENABLED | states::SENSITIVE;
// If the object is a current item of container widget then mark it as
// ACTIVE. This allows screen reader virtual buffer modes to know which
// descendant is the current one that would get focus if the user navigates
// to the container widget.
nsAccessible* widget = ContainerWidget();
if (widget && widget->CurrentItem() == this)
state |= states::ACTIVE;
}
if ((state & states::COLLAPSED) || (state & states::EXPANDED))
state |= states::EXPANDABLE;
if (mRoleMapEntry) {
// If an object has an ancestor with the activedescendant property
// pointing at it, we mark it as ACTIVE even if it's not currently focused.
// This allows screen reader virtual buffer modes to know which descendant
// is the current one that would get focus if the user navigates to the container widget.
nsAutoString id;
if (nsCoreUtils::GetID(mContent, id)) {
nsIContent *ancestorContent = mContent;
nsAutoString activeID;
while ((ancestorContent = ancestorContent->GetParent()) != nsnull) {
if (ancestorContent->GetAttr(kNameSpaceID_None, nsGkAtoms::aria_activedescendant, activeID)) {
if (id == activeID) {
state |= states::ACTIVE;
}
break;
}
}
}
}
// For some reasons DOM node may have not a frame. We tract such accessibles
// as invisible.
nsIFrame *frame = GetFrame();
@ -2955,15 +2943,18 @@ nsAccessible::ContainerWidget() const
nsIAtom* idAttribute = mContent->GetIDAttributeName();
if (idAttribute) {
if (mContent->HasAttr(kNameSpaceID_None, idAttribute)) {
nsAccessible* parent = Parent();
do {
for (nsAccessible* parent = Parent(); parent; parent = parent->Parent()) {
nsIContent* parentContent = parent->GetContent();
if (parentContent &&
parentContent->HasAttr(kNameSpaceID_None,
nsGkAtoms::aria_activedescendant)) {
return parent;
}
} while ((parent = parent->Parent()));
// Don't cross DOM document boundaries.
if (parent->IsDocumentNode())
break;
}
}
}
return nsnull;

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

@ -97,6 +97,10 @@
// disabled, too. See bug 429285.
testAriaDisabledTree("group");
// active state caused by aria-activedescendant
testStates("as_item1", 0, EXT_STATE_ACTIVE);
testStates("as_item2", 0, 0, 0, EXT_STATE_ACTIVE);
// universal ARIA properties inherited from file input control
var fileTextField = getAccessible("fileinput").firstChild;
testStates(fileTextField,
@ -184,6 +188,11 @@
title="File input control should be propogate states to descendants">
Mozilla Bug 699017
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=689847"
title="Expose active state on current item of selectable widgets">
Mozilla Bug 689847
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
@ -229,6 +238,13 @@
<div role="slider" tabindex="0">A slider</div>
</div>
<!-- Test active state -->
<div id="as_listbox" tabindex="0" role="listbox"
aria-activedescendant="as_item1">
<div role="option" id="as_item1">Item 1</div>
<div role="option" id="as_item2">Item 2</div>
</div>
<!-- universal ARIA properties should be inherited by text field of file input -->
<input type="file" id="fileinput"
aria-busy="true"

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

@ -25,20 +25,24 @@
testStates(comboboxList, 0, 0, STATE_FOCUSABLE, 0);
var opt1 = comboboxList.firstChild;
testStates(opt1, STATE_SELECTABLE | STATE_SELECTED | STATE_FOCUSABLE, 0,
STATE_FOCUSED, 0);
testStates(opt1, STATE_SELECTABLE | STATE_SELECTED | STATE_FOCUSABLE,
EXT_STATE_ACTIVE, STATE_FOCUSED, 0);
var opt2 = comboboxList.lastChild;
testStates(opt2, STATE_SELECTABLE | STATE_FOCUSABLE, 0, STATE_SELECTED, 0,
STATE_FOCUSED, 0);
STATE_FOCUSED, EXT_STATE_ACTIVE);
// listbox
var listbox = getAccessible("listbox");
testStates(listbox, STATE_FOCUSABLE, 0,
STATE_HASPOPUP | STATE_COLLAPSED | STATE_FOCUSED, 0);
STATE_HASPOPUP | STATE_COLLAPSED | STATE_FOCUSED);
testStates(listbox.firstChild, STATE_SELECTABLE, 0,
STATE_SELECTED | STATE_FOCUSED | STATE_FOCUSED, 0);
testStates(listbox.firstChild, STATE_SELECTABLE, EXT_STATE_ACTIVE,
STATE_SELECTED | STATE_FOCUSED | STATE_FOCUSED);
testStates(listbox.lastChild, STATE_SELECTABLE, 0,
STATE_SELECTED | STATE_FOCUSED | STATE_FOCUSED,
0, 0, EXT_STATE_ACTIVE);
SimpleTest.finish();
}
@ -60,6 +64,11 @@
title="mochitest for selects and lists">
Mozilla Bug 640716
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=689847"
title="Expose active state on current item of selectable widgets">
Mozilla Bug 689847
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">