From 0b76713b250125130d89fe690ba0117de22b3fda Mon Sep 17 00:00:00 2001 From: Morgan Reschenberg Date: Fri, 13 Sep 2019 16:43:58 +0000 Subject: [PATCH] Bug 1563598: Display 'container-live' attribute on descendents of implicitly-live elements. r=Jamie Depends on D45402 Differential Revision: https://phabricator.services.mozilla.com/D45609 --HG-- extra : moz-landing-system : lando --- accessible/base/nsAccUtils.cpp | 8 ++++++++ accessible/base/nsAccessibilityService.h | 19 +++++++++++++++++++ .../tests/mochitest/attributes/test_obj.html | 6 ++++++ .../tests/mochitest/tree/test_formctrl.html | 2 +- 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/accessible/base/nsAccUtils.cpp b/accessible/base/nsAccUtils.cpp index c8991b3505f7..b019da92660e 100644 --- a/accessible/base/nsAccUtils.cpp +++ b/accessible/base/nsAccUtils.cpp @@ -20,6 +20,7 @@ #include "nsIPersistentProperties2.h" #include "mozilla/a11y/PDocAccessibleChild.h" #include "mozilla/dom/Element.h" +#include "nsAccessibilityService.h" using namespace mozilla; using namespace mozilla::a11y; @@ -138,7 +139,11 @@ void nsAccUtils::SetLiveContainerAttributes( live); } else if (role) { GetLiveAttrValue(role->liveAttRule, live); + } else if (nsStaticAtom* value = GetAccService()->MarkupAttribute( + ancestor, nsGkAtoms::live)) { + value->ToString(live); } + if (!live.IsEmpty()) { SetAccAttr(aAttributes, nsGkAtoms::containerLive, live); if (role) { @@ -488,6 +493,9 @@ bool nsAccUtils::IsARIALive(const Accessible* aAccessible) { docLive); } else if (role) { GetLiveAttrValue(role->liveAttRule, docLive); + } else if (nsStaticAtom* value = GetAccService()->MarkupAttribute( + ancestor, nsGkAtoms::live)) { + value->ToString(docLive); } if (!docLive.IsEmpty()) { live = docLive; diff --git a/accessible/base/nsAccessibilityService.h b/accessible/base/nsAccessibilityService.h index 94596bef1bdd..a259b60ae954 100644 --- a/accessible/base/nsAccessibilityService.h +++ b/accessible/base/nsAccessibilityService.h @@ -245,6 +245,25 @@ class nsAccessibilityService final : public mozilla::a11y::DocManager, return markupMap ? markupMap->role : mozilla::a11y::roles::NOTHING; } + /** + * Return the associated value for a given attribute if + * it appears in the MarkupMap. Otherwise, it returns null. + */ + nsStaticAtom* MarkupAttribute(const nsIContent* aContent, + nsStaticAtom* aAtom) const { + const mozilla::a11y::HTMLMarkupMapInfo* markupMap = + mHTMLMarkupMap.Get(aContent->NodeInfo()->NameAtom()); + if (markupMap) { + for (size_t i = 0; i < mozilla::ArrayLength(markupMap->attrs); i++) { + const mozilla::a11y::MarkupAttrInfo* info = markupMap->attrs + i; + if (info->name == aAtom) { + return info->value; + } + } + } + return nullptr; + } + /** * Set the object attribute defined by markup for the given element. */ diff --git a/accessible/tests/mochitest/attributes/test_obj.html b/accessible/tests/mochitest/attributes/test_obj.html index 9afb08e648a3..c3552873d0a2 100644 --- a/accessible/tests/mochitest/attributes/test_obj.html +++ b/accessible/tests/mochitest/attributes/test_obj.html @@ -88,6 +88,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=558036 testAttrs("statusChild", {"container-live": "polite"}, true); testAttrs("timerChild", {"container-live": "off"}, true); testAbsentAttrs("tablistChild", {"container-live": "polite"}); + testAttrs("containerLiveOutput", {"container-live": "polite"}, true); + testAttrs("containerLiveOutput1", {"container-live": "polite"}, true); + testAttrs("containerLiveOutput2", {"container-live": "polite"}, true); // container-live-role object attribute testAttrs("log", {"container-live-role": "log"}, true); @@ -166,6 +169,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=558036
   
+ +
Test
+
live region
live region
diff --git a/accessible/tests/mochitest/tree/test_formctrl.html b/accessible/tests/mochitest/tree/test_formctrl.html index f7090dd94717..2dd065c87217 100644 --- a/accessible/tests/mochitest/tree/test_formctrl.html +++ b/accessible/tests/mochitest/tree/test_formctrl.html @@ -72,7 +72,7 @@ // output accTree = { - role: ROLE_SECTION, + role: ROLE_STATUSBAR, children: [ { role: ROLE_TEXT_LEAF,