From e5a1c32097e42fa983decdc14159526d14ca0440 Mon Sep 17 00:00:00 2001 From: James Teh Date: Thu, 12 Jul 2018 20:22:09 -0400 Subject: [PATCH] Bug 1475376: Support aria-valuetext for implicit ARIA roles. r=MarcoZ For example, maps to role="slider", so aria-valuetext should be supported. MozReview-Commit-ID: IYBVTHP3ZLo --HG-- extra : rebase_source : 906dfacf92d040abf97b46ff67bafbabc5c9a1ea --- accessible/generic/Accessible.cpp | 11 ++++++++--- accessible/tests/mochitest/value/test_progress.html | 3 +++ accessible/tests/mochitest/value/test_range.html | 3 +++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/accessible/generic/Accessible.cpp b/accessible/generic/Accessible.cpp index 708c6bd09208..40d0d53fed05 100644 --- a/accessible/generic/Accessible.cpp +++ b/accessible/generic/Accessible.cpp @@ -1355,10 +1355,11 @@ void Accessible::Value(nsString& aValue) const { const nsRoleMapEntry* roleMapEntry = ARIARoleMap(); - if (!roleMapEntry) - return; - if (roleMapEntry->valueRule != eNoValue) { + if ((roleMapEntry && roleMapEntry->valueRule != eNoValue) || + // Bug 1475376: aria-valuetext should also be supported for implicit ARIA + // roles; e.g. . + HasNumericValue()) { // aria-valuenow is a number, and aria-valuetext is the optional text // equivalent. For the string value, we will try the optional text // equivalent first. @@ -1374,6 +1375,10 @@ Accessible::Value(nsString& aValue) const return; } + if (!roleMapEntry) { + return; + } + // Value of textbox is a textified subtree. if (roleMapEntry->Is(nsGkAtoms::textbox)) { nsTextEquivUtils::GetTextEquivFromSubtree(this, aValue); diff --git a/accessible/tests/mochitest/value/test_progress.html b/accessible/tests/mochitest/value/test_progress.html index 65b1daa536bd..fa12b19dbc99 100644 --- a/accessible/tests/mochitest/value/test_progress.html +++ b/accessible/tests/mochitest/value/test_progress.html @@ -26,6 +26,7 @@ testValue("pr_one", "100%", 1, 0, 1, 0); testValue("pr_42", "100%", 42, 0, 1, 0); testValue("pr_21", "50%", 21, 0, 42, 0); + testValue("pr_valuetext", "value", 0, 0, 1, 0); SimpleTest.finish(); } @@ -56,5 +57,7 @@ this will be read by legacy browsers this will be read by legacy browsers this will be read by legacy browsers + + this will be read by legacy browsers diff --git a/accessible/tests/mochitest/value/test_range.html b/accessible/tests/mochitest/value/test_range.html index e0905c48b548..919bb903eda4 100644 --- a/accessible/tests/mochitest/value/test_range.html +++ b/accessible/tests/mochitest/value/test_range.html @@ -25,6 +25,7 @@ testValue("range_step", "50", 50, 0, 100, 1); testValue("range_min42", "71", 71, 42, 100, 1); testValue("range_max42", "21", 21, 0, 42, 1); + testValue("range_valuetext", "value", 50, 0, 100, 1); SimpleTest.finish(); } @@ -54,5 +55,7 @@ + +