Bug 1521728 - Expose elements that have a title to the accessibility APIs, even if they wouldn't be accessible otherwise, r=Jamie
authorMarco Zehe <mzehe@mozilla.com>
Wed, 23 Jan 2019 01:31:54 +0000
changeset 454942 66a5303cb9ddf8885275f600ccbd6aff1b336275
parent 454941 8dee9d61a77b4613be713577873eac447c1a5ece
child 454943 925142f4e19ef950e6de891a4265a98ddde43de5
push id35419
push userdluca@mozilla.com
push dateWed, 23 Jan 2019 16:31:25 +0000
treeherdermozilla-central@2e27f3f1ebc6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersJamie
bugs1521728
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1521728 - Expose elements that have a title to the accessibility APIs, even if they wouldn't be accessible otherwise, r=Jamie Elements such as html:span are normally only made accessible with ARIA attributes. Also expose them if they have a title attribute set. It can be assumed that information should be conveyed to the user in such cases. Differential Revision: https://phabricator.services.mozilla.com/D17227
accessible/base/nsAccessibilityService.cpp
accessible/tests/mochitest/elm/test_HTMLSpec.html
--- a/accessible/base/nsAccessibilityService.cpp
+++ b/accessible/base/nsAccessibilityService.cpp
@@ -113,16 +113,22 @@ static bool MustBeAccessible(nsIContent*
   if (aContent->GetPrimaryFrame()->IsFocusable()) return true;
 
   if (aContent->IsElement()) {
     uint32_t attrCount = aContent->AsElement()->GetAttrCount();
     for (uint32_t attrIdx = 0; attrIdx < attrCount; attrIdx++) {
       const nsAttrName* attr = aContent->AsElement()->GetAttrNameAt(attrIdx);
       if (attr->NamespaceEquals(kNameSpaceID_None)) {
         nsAtom* attrAtom = attr->Atom();
+        if (attrAtom == nsGkAtoms::title && aContent->IsHTMLElement()) {
+          // If the author provided a title on an element that would not
+          // be accessible normally, assume an intent and make it accessible.
+          return true;
+        }
+
         nsDependentAtomString attrStr(attrAtom);
         if (!StringBeginsWith(attrStr, NS_LITERAL_STRING("aria-")))
           continue;  // not ARIA
 
         // A global state or a property and in case of token defined.
         uint8_t attrFlags = aria::AttrCharacteristicsFor(attrAtom);
         if ((attrFlags & ATTR_GLOBAL) &&
             (!(attrFlags & ATTR_VALTOKEN) ||
--- a/accessible/tests/mochitest/elm/test_HTMLSpec.html
+++ b/accessible/tests/mochitest/elm/test_HTMLSpec.html
@@ -1246,16 +1246,23 @@
       ok(!isAccessible("source"), "source element is not accessible");
 
       // ////////////////////////////////////////////////////////////////////////
       // HTML:span
 
       ok(!isAccessible("span"), "span element is not accessible");
 
       // ////////////////////////////////////////////////////////////////////////
+      // html:span with a title attribute, which should make it accessible.
+      obj = {
+        role: ROLE_TEXT,
+      };
+      testElm("span_explicit", obj);
+
+      // ////////////////////////////////////////////////////////////////////////
       // HTML:strong contained by paragraph
 
       obj = {
         role: ROLE_PARAGRAPH,
         children: [
           { role: ROLE_TEXT_LEAF }, // plain text
           { role: ROLE_TEXT_LEAF }, // HTML:strong text
         ],
@@ -1757,16 +1764,17 @@
   </ruby>
 
   <p id="s_container">normal<s>striked</s></p>
   <p id="samp_container">normal<samp>sample</samp></p>
   <section id="section">section</section>
   <section id="named_section" aria-label="foo">named section</section>
   <p id="small_container">normal<small>small</small></p>
   <span id="span"></span>
+  <span id="span_explicit" title="explicit"></span>
   <p id="strong_container">normal<strong>strong</strong></p>
   <p id="sub_container">normal<sub>sub</sub></p>
   <p id="sup_container">normal<sup>sup</sup></p>
 
   <svg id="svg"></svg>
   <textarea id="textarea"></textarea>
 
   <p>The concert took place on <time id="time" datetime="2001-05-15 19:00">May 15</time></p>