From 3b2b3cbc7cd1212b3bd4dc7fa1f0853ebe71c23c Mon Sep 17 00:00:00 2001 From: Alexander Surkov Date: Tue, 3 Nov 2015 11:03:34 -0500 Subject: [PATCH] Bug 582024 - ARIA active-descendant should work for ARIA owned elements, r=yzen --- accessible/generic/Accessible.cpp | 24 ++++++++++--------- .../test_focus_aria_activedescendant.html | 13 ++++++---- .../tests/mochitest/states/test_aria.html | 4 +++- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/accessible/generic/Accessible.cpp b/accessible/generic/Accessible.cpp index a3e72048af2..fce078d694c 100644 --- a/accessible/generic/Accessible.cpp +++ b/accessible/generic/Accessible.cpp @@ -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, - nsGkAtoms::_true, eCaseMatters)) { - // ancestor has aria-disabled property, this is 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)) { *aState |= states::UNAVAILABLE; break; } diff --git a/accessible/tests/mochitest/events/test_focus_aria_activedescendant.html b/accessible/tests/mochitest/events/test_focus_aria_activedescendant.html index 4c2a2a29624..4cd57fe3b38 100644 --- a/accessible/tests/mochitest/events/test_focus_aria_activedescendant.html +++ b/accessible/tests/mochitest/events/test_focus_aria_activedescendant.html @@ -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
   
-
+
item1
item2
+
item3
diff --git a/accessible/tests/mochitest/states/test_aria.html b/accessible/tests/mochitest/states/test_aria.html index d0f268fca29..7d1ecf65083 100644 --- a/accessible/tests/mochitest/states/test_aria.html +++ b/accessible/tests/mochitest/states/test_aria.html @@ -500,7 +500,8 @@
-
+
Item 1
Item 2
Item 3
@@ -508,6 +509,7 @@
A slider
+
Item 5