Bug 582024 - ARIA active-descendant should work for ARIA owned elements, r=yzen

This commit is contained in:
Alexander Surkov 2015-11-03 11:03:34 -05:00
parent a167ada93b
commit 3b2b3cbc7c
3 changed files with 24 additions and 17 deletions

View File

@ -1238,11 +1238,13 @@ Accessible::ApplyARIAState(uint64_t* aState) const
*aState &= ~states::READONLY;
if (mContent->HasID()) {
// If has a role & ID and aria-activedescendant on the container, assume focusable
nsIContent *ancestorContent = mContent;
while ((ancestorContent = ancestorContent->GetParent()) != nullptr) {
if (ancestorContent->HasAttr(kNameSpaceID_None, nsGkAtoms::aria_activedescendant)) {
// ancestor has activedescendant property, this content could be active
// If has a role & ID and aria-activedescendant on the container, assume
// focusable.
const Accessible* ancestor = this;
while ((ancestor = ancestor->Parent()) && !ancestor->IsDoc()) {
dom::Element* el = ancestor->Elm();
if (el &&
el->HasAttr(kNameSpaceID_None, nsGkAtoms::aria_activedescendant)) {
*aState |= states::FOCUSABLE;
break;
}
@ -1251,12 +1253,12 @@ Accessible::ApplyARIAState(uint64_t* aState) const
}
if (*aState & states::FOCUSABLE) {
// Special case: aria-disabled propagates from ancestors down to any focusable descendant
nsIContent *ancestorContent = mContent;
while ((ancestorContent = ancestorContent->GetParent()) != nullptr) {
if (ancestorContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::aria_disabled,
// Propogate aria-disabled from ancestors down to any focusable descendant.
const Accessible* ancestor = this;
while ((ancestor = ancestor->Parent()) && !ancestor->IsDoc()) {
dom::Element* el = ancestor->Elm();
if (el && el->AttrValueIs(kNameSpaceID_None, nsGkAtoms::aria_disabled,
nsGkAtoms::_true, eCaseMatters)) {
// ancestor has aria-disabled property, this is disabled
*aState |= states::UNAVAILABLE;
break;
}

View File

@ -51,7 +51,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=429547
var container = getNode(aID);
var itemNode = document.createElement("div");
itemNode.setAttribute("id", aNewItemID);
itemNode.textContent = "item3";
itemNode.textContent = aNewItemID;
container.appendChild(itemNode);
container.setAttribute("aria-activedescendant", aNewItemID);
@ -68,14 +68,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=429547
{
gQueue = new eventQueue();
gQueue.push(new synthFocus("container", new focusChecker("item1")));
gQueue.push(new changeARIAActiveDescendant("container", "item2"));
gQueue.push(new synthFocus("listbox", new focusChecker("item1")));
gQueue.push(new changeARIAActiveDescendant("listbox", "item2"));
gQueue.push(new changeARIAActiveDescendant("listbox", "item3"));
gQueue.push(new synthFocus("combobox_entry", new focusChecker("combobox_entry")));
gQueue.push(new changeARIAActiveDescendant("combobox", "combobox_option2"));
todo(false, "No focus for inserted element, bug 687011");
//gQueue.push(new insertItemNFocus("container", "item3"));
//gQueue.push(new insertItemNFocus("listbox", "item4"));
gQueue.invoke(); // Will call SimpleTest.finish();
}
@ -101,10 +102,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=429547
<pre id="test">
</pre>
<div role="listbox" aria-activedescendant="item1" id="container" tabindex="1">
<div role="listbox" aria-activedescendant="item1" id="listbox" tabindex="1"
aria-owns="item3">
<div role="listitem" id="item1">item1</div>
<div role="listitem" id="item2">item2</div>
</div>
<div role="listitem" id="item3">item3</div>
<div role="combobox" id="combobox">
<input id="combobox_entry">

View File

@ -500,7 +500,8 @@
<!-- Test that aria-disabled state gets propagated to all descendants -->
<div id="group" role="group" aria-disabled="true">
<button>hi</button>
<div tabindex="0" role="listbox" aria-activedescendant="item1">
<div tabindex="0" role="listbox" aria-activedescendant="item1"
aria-owns="item5">
<div role="option" id="item1">Item 1</div>
<div role="option" id="item2">Item 2</div>
<div role="option" id="item3">Item 3</div>
@ -508,6 +509,7 @@
</div>
<div role="slider" tabindex="0">A slider</div>
</div>
<div role="option" id="item5">Item 5</div>
<!-- Test active state -->
<div id="as_listbox" tabindex="0" role="listbox"