Bug 982125 - make HTML5 <mark> accessible, r=Jamie
authorMarco Zehe <mzehe@mozilla.com>
Mon, 18 Nov 2019 05:34:15 +0000
changeset 502372 4d4efd40bafa1416175ed5de1816ee0db962251f
parent 502371 b168e040a286c97238b3eec0d680298273d1af84
child 502373 cbe50feba8e1ce4deb5b9dac66bd6feb4970b34f
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersJamie
bugs982125
milestone72.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 982125 - make HTML5 <mark> accessible, r=Jamie Mark the html:mark element to the new ROLE_MARK, which currently maps the same as role_text, and the xml-role of "mark", make sure we expose the roleDescription on Mac, and adjust the test so it tests that the attributes don't pick up any unexpected color for this particular element. So, the background attribute is empty when there is no unexpected, non-default background color. Differential Revision: https://phabricator.services.mozilla.com/D52989
accessible/base/MarkupMap.h
accessible/base/Role.h
accessible/base/RoleMap.h
accessible/interfaces/nsIAccessibleRole.idl
accessible/mac/mozAccessible.mm
accessible/tests/mochitest/elm/test_HTMLSpec.html
accessible/tests/mochitest/role.js
accessible/tests/mochitest/textattrs/test_general.html
dom/locales/en-US/chrome/accessibility/mac/accessible.properties
--- a/accessible/base/MarkupMap.h
+++ b/accessible/base/MarkupMap.h
@@ -253,16 +253,18 @@ MARKUPMAP(
       return nullptr;
     },
     0)
 
 MARKUPMAP(main, New_HyperText, roles::LANDMARK)
 
 MARKUPMAP(map, nullptr, roles::TEXT_CONTAINER)
 
+MARKUPMAP(mark, New_HyperText, roles::MARK, Attr(xmlroles, mark))
+
 MARKUPMAP(math, New_HyperText, roles::MATHML_MATH)
 
 MARKUPMAP(mi_, New_HyperText, roles::MATHML_IDENTIFIER)
 
 MARKUPMAP(mn_, New_HyperText, roles::MATHML_NUMBER)
 
 MARKUPMAP(mo_, New_HyperText, roles::MATHML_OPERATOR,
           AttrFromDOM(accent_, accent_), AttrFromDOM(fence_, fence_),
--- a/accessible/base/Role.h
+++ b/accessible/base/Role.h
@@ -1040,17 +1040,23 @@ enum Role {
 
   /**
    * An html:form element with a label provided by WAI-ARIA.
    * This may also be used if role="form" with a label should be exposed
    * differently in the future.
    */
   FORM_LANDMARK = 178,
 
-  LAST_ROLE = FORM_LANDMARK
+  /**
+   * The html:mark element.
+   * May also be used if WAI-ARIA gets an equivalent role.
+   */
+  MARK = 179,
+
+  LAST_ROLE = MARK
 };
 
 }  // namespace roles
 
 typedef enum mozilla::a11y::roles::Role role;
 
 }  // namespace a11y
 }  // namespace mozilla
--- a/accessible/base/RoleMap.h
+++ b/accessible/base/RoleMap.h
@@ -1625,9 +1625,18 @@ ROLE(CONTENT_INSERTION,
 ROLE(FORM_LANDMARK,
      "form",
      ATK_ROLE_LANDMARK,
      NSAccessibilityGroupRole,
      USE_ROLE_STRING,
      IA2_ROLE_FORM,
      java::SessionAccessibility::CLASSNAME_VIEW,
      eNoNameRule)
+
+ROLE(MARK,
+     "mark",
+     ATK_ROLE_STATIC,
+     NSAccessibilityGroupRole,
+     USE_ROLE_STRING,
+     IA2_ROLE_TEXT_FRAME,
+     java::SessionAccessibility::CLASSNAME_VIEW,
+     eNameFromSubtreeIfReqRule)
 // clang-format on
--- a/accessible/interfaces/nsIAccessibleRole.idl
+++ b/accessible/interfaces/nsIAccessibleRole.idl
@@ -1034,9 +1034,15 @@ interface nsIAccessibleRole : nsISupport
 
   /**
    * An html:form element with a label provided by WAI-ARIA.
    * This may also be used if role="form" with a label should be exposed
    * differently in the future.
    */
   const unsigned long ROLE_FORM_LANDMARK = 178;
 
+  /**
+   * The html:mark element.
+   * May also be used if WAI-ARIA gets an equivalent role.
+   */
+  const unsigned long ROLE_MARK = 179;
+
 };
--- a/accessible/mac/mozAccessible.mm
+++ b/accessible/mac/mozAccessible.mm
@@ -866,16 +866,20 @@ struct RoleDescrComparator {
 
 - (NSString*)roleDescription {
   if (mRole == roles::DOCUMENT) return utils::LocalizedString(NS_LITERAL_STRING("htmlContent"));
 
   if (mRole == roles::FIGURE) return utils::LocalizedString(NS_LITERAL_STRING("figure"));
 
   if (mRole == roles::HEADING) return utils::LocalizedString(NS_LITERAL_STRING("heading"));
 
+  if (mRole == roles::MARK) {
+    return utils::LocalizedString(NS_LITERAL_STRING("highlight"));
+  }
+
   NSString* subrole = [self subrole];
 
   if (subrole) {
     size_t idx = 0;
     if (BinarySearchIf(sRoleDescrMap, 0, ArrayLength(sRoleDescrMap), RoleDescrComparator(subrole),
                        &idx)) {
       return utils::LocalizedString(sRoleDescrMap[idx].description);
     }
--- a/accessible/tests/mochitest/elm/test_HTMLSpec.html
+++ b/accessible/tests/mochitest/elm/test_HTMLSpec.html
@@ -997,23 +997,25 @@
       };
       testElm("map", obj);
 
       // ////////////////////////////////////////////////////////////////////////
       // HTML:mark contained by paragraph
 
       obj = {
         role: ROLE_PARAGRAPH,
-        textAttrs: {
-          0: { },
-          6: { "background-color": "rgb(255, 255, 0)" },
-        },
         children: [
           { role: ROLE_TEXT_LEAF }, // plain text
-          { role: ROLE_TEXT_LEAF }, // HTML:mark text
+          { role: ROLE_MARK,  // HTML:mark text
+            attributes: { "xml-roles": "mark" },
+            interfaces: [ nsIAccessibleText, nsIAccessibleHyperText ],
+            textAttrs: {
+              0: { },
+            }
+          }
         ],
       };
       testElm("mark_container", obj);
 
       // ////////////////////////////////////////////////////////////////////////
       // HTML:math
 
       obj = {
--- a/accessible/tests/mochitest/role.js
+++ b/accessible/tests/mochitest/role.js
@@ -46,16 +46,17 @@ const ROLE_HEADING = nsIAccessibleRole.R
 const ROLE_IMAGE_MAP = nsIAccessibleRole.ROLE_IMAGE_MAP;
 const ROLE_INTERNAL_FRAME = nsIAccessibleRole.ROLE_INTERNAL_FRAME;
 const ROLE_LABEL = nsIAccessibleRole.ROLE_LABEL;
 const ROLE_LANDMARK = nsIAccessibleRole.ROLE_LANDMARK;
 const ROLE_LINK = nsIAccessibleRole.ROLE_LINK;
 const ROLE_LIST = nsIAccessibleRole.ROLE_LIST;
 const ROLE_LISTBOX = nsIAccessibleRole.ROLE_LISTBOX;
 const ROLE_LISTITEM = nsIAccessibleRole.ROLE_LISTITEM;
+const ROLE_MARK = nsIAccessibleRole.ROLE_MARK;
 const ROLE_MATHML_MATH = nsIAccessibleRole.ROLE_MATHML_MATH;
 const ROLE_MATHML_IDENTIFIER = nsIAccessibleRole.ROLE_MATHML_IDENTIFIER;
 const ROLE_MATHML_NUMBER = nsIAccessibleRole.ROLE_MATHML_NUMBER;
 const ROLE_MATHML_OPERATOR = nsIAccessibleRole.ROLE_MATHML_OPERATOR;
 const ROLE_MATHML_TEXT = nsIAccessibleRole.ROLE_MATHML_TEXT;
 const ROLE_MATHML_STRING_LITERAL = nsIAccessibleRole.ROLE_MATHML_STRING_LITERAL;
 const ROLE_MATHML_GLYPH = nsIAccessibleRole.ROLE_MATHML_GLYPH;
 const ROLE_MATHML_ROW = nsIAccessibleRole.ROLE_MATHML_ROW;
--- a/accessible/tests/mochitest/textattrs/test_general.html
+++ b/accessible/tests/mochitest/textattrs/test_general.html
@@ -541,29 +541,33 @@
       };
       testTextAttrs(ID, 0, attrs, defAttrs, 0, 3);
       testTextAttrs(ID, 3, { }, defAttrs, 3, 7);
       testTextAttrs(ID, 7, attrs, defAttrs, 7, 8);
 
        // ////////////////////////////////////////////////////////////////////////
       // area19, "HTML5 mark tag" test
       // text enclosed in mark tag will have a different background color
+      // However, since bug 982125, it is its own accessible.
+      // Therefore, anything other than the default background color is
+      // unexpected.
       ID = "area19";
       defAttrs = buildDefaultTextAttrs(ID, "12pt");
 
       attrs = {};
       testTextAttrs(ID, 0, attrs, defAttrs, 0, 10);
 
-      tempElem = getNode(ID).firstChild.nextSibling;
-      gComputedStyle = document.defaultView.getComputedStyle(tempElem);
-      attrs = { "background-color": gComputedStyle.backgroundColor };
-      testTextAttrs(ID, 11, attrs, defAttrs, 10, 17);
+      ID = "area19mark";
+      defMarkAttrs = buildDefaultTextAttrs(ID, "12pt");
+      attrs = {};
+      testTextAttrs(ID, 0, attrs, defMarkAttrs, 0, 7);
 
+      ID = "area19";
       attrs = {};
-      testTextAttrs(ID, 18, attrs, defAttrs, 17, 28);
+      testTextAttrs(ID, 11, attrs, defAttrs, 11, 22);
 
        // ////////////////////////////////////////////////////////////////////////
       // area20, "aOffset as -1 (Mozilla Bug 789621)" test
 
       ID = "area20";
       defAttrs = buildDefaultTextAttrs(ID, "15pt");
       testDefaultTextAttrs(ID, defAttrs);
 
@@ -719,15 +723,15 @@
     </span>
   </p>
 
   <ul>
     <li id="area18" class="gencontent">item</li>
   </ul>
 
   <p id="area19">uncolored
-    <mark>colored</mark> uncolored
+    <mark id="area19mark">colored</mark> uncolored
   </p>
 
   <p id="area20" style="font-size: 15pt;">offset test</p>
 
 </body>
 </html>
--- a/dom/locales/en-US/chrome/accessibility/mac/accessible.properties
+++ b/dom/locales/en-US/chrome/accessibility/mac/accessible.properties
@@ -51,8 +51,10 @@ marquee     =      marquee
 math        =      math
 note        =      note
 region      =      region
 status      =      application status
 timer       =      timer
 tooltip     =      tooltip
 separator    =      separator
 tabPanel     =      tab panel
+# The roleDescription for the html:mark element
+highlight = highlight