Skip to content

Commit

Permalink
Bug 1732306 - Part 1: Implement emphasis role mappings, r=Jamie
Browse files Browse the repository at this point in the history
This revision implements the mapping for the ARIA 1.2 emphasis role, which was
unsupported in Firefox until now. This change addresses a web platform test
failure. To accomplish this, the revision adds the WAI-defined role, adds a role
enum value, adds platform mappings, and adds a markup role mapping. The change
requires a new static atom for the word "emphasis," also added in this revision.
Finally, this change removes the expected wpt failure and updates other tests.

Differential Revision: https://phabricator.services.mozilla.com/D200130
  • Loading branch information
Nathan LaPre committed Feb 7, 2024
1 parent 34cdfc4 commit 2794697
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 9 deletions.
10 changes: 10 additions & 0 deletions accessible/base/ARIAMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,16 @@ static const nsRoleMapEntry sWAIRoleMaps[] = {
kNoReqStates,
eReadonlyUntilEditable
},
{ // emphasis
nsGkAtoms::emphasis,
roles::EMPHASIS,
kUseMapRole,
eNoValue,
eNoAction,
eNoLiveAttr,
kGenericAccType,
kNoReqStates
},
{ // feed
nsGkAtoms::feed,
roles::GROUPING,
Expand Down
2 changes: 2 additions & 0 deletions accessible/base/HTMLMarkupMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ MARKUPMAP(

MARKUPMAP(dt, New_HTMLDtOrDd<HTMLLIAccessible>, roles::TERM)

MARKUPMAP(em, New_HyperText, roles::EMPHASIS)

MARKUPMAP(
figcaption,
[](Element* aElement, LocalAccessible* aContext) -> LocalAccessible* {
Expand Down
12 changes: 12 additions & 0 deletions accessible/base/RoleMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -1509,4 +1509,16 @@ ROLE(SUPERSCRIPT,
IA2_ROLE_TEXT_FRAME,
java::SessionAccessibility::CLASSNAME_VIEW,
eNameFromSubtreeIfReqRule)

ROLE(EMPHASIS,
"emphasis",
nsGkAtoms::emphasis,
ATK_ROLE_STATIC,
NSAccessibilityGroupRole,
@"AXEmphasisStyleGroup",
ROLE_SYSTEM_GROUPING,
IA2_ROLE_TEXT_FRAME,
java::SessionAccessibility::CLASSNAME_VIEW,
eNameFromSubtreeIfReqRule)

// clang-format on
6 changes: 6 additions & 0 deletions accessible/interfaces/nsIAccessibleRole.idl
Original file line number Diff line number Diff line change
Expand Up @@ -784,4 +784,10 @@ interface nsIAccessibleRole : nsISupports
*/
const unsigned long ROLE_SUPERSCRIPT = 134;

/**
* Represents one or more emphasized characters. Use this role to stress or
* emphasize content.
*/
const unsigned long ROLE_EMPHASIS = 135;

};
11 changes: 9 additions & 2 deletions accessible/tests/mochitest/elm/test_HTMLSpec.html
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,18 @@
role: ROLE_PARAGRAPH,
textAttrs: {
0: { },
6: { "font-style": "italic" },
6: { },
},
children: [
{ role: ROLE_TEXT_LEAF }, // plain text
{ role: ROLE_TEXT_LEAF }, // HTML:em text
{ role: ROLE_EMPHASIS, // HTML:em text
children: [
{ role: ROLE_TEXT_LEAF, },
],
textAttrs: {
0: { },
},
},
],
};
testElm("em_container", obj);
Expand Down
1 change: 1 addition & 0 deletions accessible/tests/mochitest/role.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const ROLE_DIAGRAM = nsIAccessibleRole.ROLE_DIAGRAM;
const ROLE_DIALOG = nsIAccessibleRole.ROLE_DIALOG;
const ROLE_DOCUMENT = nsIAccessibleRole.ROLE_DOCUMENT;
const ROLE_EDITCOMBOBOX = nsIAccessibleRole.ROLE_EDITCOMBOBOX;
const ROLE_EMPHASIS = nsIAccessibleRole.ROLE_EMPHASIS;
const ROLE_ENTRY = nsIAccessibleRole.ROLE_ENTRY;
const ROLE_FIGURE = nsIAccessibleRole.ROLE_FIGURE;
const ROLE_FOOTNOTE = nsIAccessibleRole.ROLE_FOOTNOTE;
Expand Down
3 changes: 0 additions & 3 deletions testing/web-platform/meta/html-aam/roles.html.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
[roles.html]
[el-em]
expected: FAIL

[el-strong]
expected: FAIL

Expand Down
4 changes: 0 additions & 4 deletions testing/web-platform/meta/wai-aria/role/roles.html.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
[roles.html]
[role: emphasis]
expected: FAIL
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1732306

[role: strong]
expected: FAIL
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1732306
Expand Down
1 change: 1 addition & 0 deletions xpcom/ds/StaticAtoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@
Atom("elements", "elements"),
Atom("em", "em"),
Atom("embed", "embed"),
Atom("emphasis", "emphasis"),
Atom("empty", "empty"),
Atom("encoding", "encoding"),
Atom("enctype", "enctype"),
Expand Down

0 comments on commit 2794697

Please sign in to comment.