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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Marco Zehe 2019-11-18 05:34:15 +00:00
parent 716f5cc49d
commit 78545b8343
9 changed files with 49 additions and 13 deletions

View File

@ -258,6 +258,8 @@ 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)

View File

@ -1045,7 +1045,13 @@ enum Role {
*/
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

View File

@ -1630,4 +1630,13 @@ ROLE(FORM_LANDMARK,
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

View File

@ -1039,4 +1039,10 @@ interface nsIAccessibleRole : nsISupports
*/
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;
};

View File

@ -871,6 +871,10 @@ struct RoleDescrComparator {
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) {

View File

@ -1002,13 +1002,15 @@
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);

View File

@ -51,6 +51,7 @@ 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;

View File

@ -546,19 +546,23 @@
// ////////////////////////////////////////////////////////////////////////
// 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, 18, attrs, defAttrs, 17, 28);
testTextAttrs(ID, 0, attrs, defMarkAttrs, 0, 7);
ID = "area19";
attrs = {};
testTextAttrs(ID, 11, attrs, defAttrs, 11, 22);
// ////////////////////////////////////////////////////////////////////////
// area20, "aOffset as -1 (Mozilla Bug 789621)" test
@ -724,7 +728,7 @@
</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>

View File

@ -56,3 +56,5 @@ timer = timer
tooltip = tooltip
separator = separator
tabPanel = tab panel
# The roleDescription for the html:mark element
highlight = highlight