Skip to content

Commit

Permalink
Map MathML elements to specific roles
Browse files Browse the repository at this point in the history
This CL introduces the minimal number of MathML roles so that one can
implement role and attribute mapping for ATK and AX API [1]. Exact
roles for some tags are still being discussed on the spec side and
might change in the future [2] [3] [4] [5] [6]. On Windows and Android
platforms, math roles is a bit undefined and so some dummy role mapping
is used right now. Node tests are added to cover all elements of MathML
Core. These new tests also verify that the MathML element tags are
exposed as an AtkObject attribute.

[1] https://w3c.github.io/mathml-aam/
[2] w3c/mathml-aam#9
[3] w3c/mathml-aam#11
[4] w3c/mathml-aam#12
[5] w3c/mathml-aam#13
[6] w3c/mathml-aam#14

AX-Relnotes: MathML elements are exposed in the accessible tree with specific roles.
Bug: 6606, 1038895, 1051115, 1038897, 1038898, 1038899, 1038900, 1038901, 1038911, 1038913, 1052420
Change-Id: I7e857a0cfc05616a30bf4842e334c1dfde082d49
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3207929
Commit-Queue: Frédéric Wang <[email protected]>
Reviewed-by: Nektarios Paisios <[email protected]>
Reviewed-by: Tom Sepez <[email protected]>
Cr-Commit-Position: refs/heads/main@{#933442}
  • Loading branch information
fred-wang authored and Chromium LUCI CQ committed Oct 20, 2021
1 parent 5e0bc9d commit d6d648b
Show file tree
Hide file tree
Showing 141 changed files with 1,052 additions and 70 deletions.
23 changes: 23 additions & 0 deletions content/browser/accessibility/browser_accessibility_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,29 @@ std::u16string BrowserAccessibilityAndroid::GetRoleDescription() const {
case ax::mojom::Role::kMathMLMath:
message_id = IDS_AX_ROLE_MATH;
break;
case ax::mojom::Role::kMathMLFraction:
case ax::mojom::Role::kMathMLIdentifier:
case ax::mojom::Role::kMathMLMultiscripts:
case ax::mojom::Role::kMathMLNoneScript:
case ax::mojom::Role::kMathMLNumber:
case ax::mojom::Role::kMathMLOperator:
case ax::mojom::Role::kMathMLOver:
case ax::mojom::Role::kMathMLPrescriptDelimiter:
case ax::mojom::Role::kMathMLRoot:
case ax::mojom::Role::kMathMLRow:
case ax::mojom::Role::kMathMLSquareRoot:
case ax::mojom::Role::kMathMLStringLiteral:
case ax::mojom::Role::kMathMLSub:
case ax::mojom::Role::kMathMLSubSup:
case ax::mojom::Role::kMathMLSup:
case ax::mojom::Role::kMathMLTable:
case ax::mojom::Role::kMathMLTableCell:
case ax::mojom::Role::kMathMLTableRow:
case ax::mojom::Role::kMathMLText:
case ax::mojom::Role::kMathMLUnder:
case ax::mojom::Role::kMathMLUnderOver:
// No role description.
break;
case ax::mojom::Role::kMenu:
message_id = IDS_AX_ROLE_MENU;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "base/files/file_util.h"
#include "content/browser/accessibility/dump_accessibility_browsertest_base.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/shell/browser/shell.h"
Expand All @@ -24,6 +25,9 @@ class DumpAccessibilityNodeTest : public DumpAccessibilityTestBase {
// which include a select element descendant.
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kDisableAXMenuList, "false");
// Enable MathMLCore for some MathML tests.
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kEnableBlinkFeatures, "MathMLCore");
}

std::vector<ui::AXPropertyFilter> DefaultFilters() const override {
Expand Down Expand Up @@ -166,9 +170,100 @@ IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest,
//
// MathML tests.
//

IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLAction) {
RunMathMLTest(FILE_PATH_LITERAL("maction.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLAnnotation) {
RunMathMLTest(FILE_PATH_LITERAL("annotation.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLAnnotationXML) {
RunMathMLTest(FILE_PATH_LITERAL("annotation-xml.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLError) {
RunMathMLTest(FILE_PATH_LITERAL("merror.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLFraction) {
RunMathMLTest(FILE_PATH_LITERAL("mfrac.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLIdentifier) {
RunMathMLTest(FILE_PATH_LITERAL("mi.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLMath) {
RunMathMLTest(FILE_PATH_LITERAL("math.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLMultiscripts) {
RunMathMLTest(FILE_PATH_LITERAL("mmultiscripts.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLNone) {
RunMathMLTest(FILE_PATH_LITERAL("none.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLNumber) {
RunMathMLTest(FILE_PATH_LITERAL("mn.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLOperator) {
RunMathMLTest(FILE_PATH_LITERAL("mo.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLOver) {
RunMathMLTest(FILE_PATH_LITERAL("mover.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLPadded) {
RunMathMLTest(FILE_PATH_LITERAL("mpadded.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLPhantom) {
RunMathMLTest(FILE_PATH_LITERAL("mphantom.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLPrescripts) {
RunMathMLTest(FILE_PATH_LITERAL("mprescripts.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLRoot) {
RunMathMLTest(FILE_PATH_LITERAL("mroot.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLRow) {
RunMathMLTest(FILE_PATH_LITERAL("mrow.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLSemantics) {
RunMathMLTest(FILE_PATH_LITERAL("semantics.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLSpace) {
RunMathMLTest(FILE_PATH_LITERAL("mspace.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLSquareRoot) {
RunMathMLTest(FILE_PATH_LITERAL("msqrt.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLStringLiteral) {
RunMathMLTest(FILE_PATH_LITERAL("ms.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLStyle) {
RunMathMLTest(FILE_PATH_LITERAL("mstyle.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLSub) {
RunMathMLTest(FILE_PATH_LITERAL("msub.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLSubSup) {
RunMathMLTest(FILE_PATH_LITERAL("msubsup.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLSup) {
RunMathMLTest(FILE_PATH_LITERAL("msup.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLTable) {
RunMathMLTest(FILE_PATH_LITERAL("mtable.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLTableCell) {
RunMathMLTest(FILE_PATH_LITERAL("mtd.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLTableRow) {
RunMathMLTest(FILE_PATH_LITERAL("mtr.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLText) {
RunMathMLTest(FILE_PATH_LITERAL("mtext.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLUnder) {
RunMathMLTest(FILE_PATH_LITERAL("munder.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityNodeTest, MathMLUnderOver) {
RunMathMLTest(FILE_PATH_LITERAL("munderover.html"));
}

//
// AccName tests.
Expand Down
13 changes: 8 additions & 5 deletions content/test/data/accessibility/html/math-expected-android.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
android.webkit.WebView focusable focused scrollable
++android.view.View
++++android.view.View role_description='math'
++++++android.widget.TextView name='%F0%9D%90%B4'
++++++android.widget.TextView name='2'
++++++android.widget.TextView name='+'
++++++android.widget.TextView name='%F0%9D%90%B5'
++++++android.widget.TextView name='2'
++++++android.view.View
++++++++android.view.View
++++++++++android.view.View name='%F0%9D%90%B4'
++++++++++android.view.View name='2'
++++++++android.view.View name='+'
++++++++android.view.View
++++++++++android.view.View name='%F0%9D%90%B5'
++++++++++android.view.View name='2'
21 changes: 12 additions & 9 deletions content/test/data/accessibility/html/math-expected-auralinux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
++[section]
++++[math]
++++++[section]
++++++++[static] name='%F0%9D%90%B4'
++++++[section]
++++++++[static] name='2'
++++++[section]
++++++++[static] name='+'
++++++[section]
++++++++[static] name='%F0%9D%90%B5'
++++++[section]
++++++++[static] name='2'
++++++++[section]
++++++++++[static]
++++++++++++[static] name='%F0%9D%90%B4'
++++++++++[static]
++++++++++++[static] name='2'
++++++++[static]
++++++++++[static] name='+'
++++++++[section]
++++++++++[static]
++++++++++++[static] name='%F0%9D%90%B5'
++++++++++[static]
++++++++++++[static] name='2'
23 changes: 13 additions & 10 deletions content/test/data/accessibility/html/math-expected-mac.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
AXWebArea AXRoleDescription='HTML content'
++AXGroup AXRoleDescription='group'
++++AXGroup AXSubrole=AXDocumentMath AXRoleDescription='math'
++++++AXGroup AXRoleDescription='group'
++++++++AXStaticText AXRoleDescription='text' AXValue='%F0%9D%90%B4'
++++++AXGroup AXRoleDescription='group'
++++++++AXStaticText AXRoleDescription='text' AXValue='2'
++++++AXGroup AXRoleDescription='group'
++++++++AXStaticText AXRoleDescription='text' AXValue='+'
++++++AXGroup AXRoleDescription='group'
++++++++AXStaticText AXRoleDescription='text' AXValue='%F0%9D%90%B5'
++++++AXGroup AXRoleDescription='group'
++++++++AXStaticText AXRoleDescription='text' AXValue='2'
++++++AXGroup AXSubrole=AXMathRow AXRoleDescription='group'
++++++++AXGroup AXSubrole=AXMathSubscriptSuperscript AXRoleDescription='group'
++++++++++AXGroup AXSubrole=AXMathIdentifier AXRoleDescription='group'
++++++++++++AXStaticText AXRoleDescription='text' AXValue='%F0%9D%90%B4'
++++++++++AXGroup AXSubrole=AXMathNumber AXRoleDescription='group'
++++++++++++AXStaticText AXRoleDescription='text' AXValue='2'
++++++++AXGroup AXSubrole=AXMathOperator AXRoleDescription='group'
++++++++++AXStaticText AXRoleDescription='text' AXValue='+'
++++++++AXGroup AXSubrole=AXMathSubscriptSuperscript AXRoleDescription='group'
++++++++++AXGroup AXSubrole=AXMathIdentifier AXRoleDescription='group'
++++++++++++AXStaticText AXRoleDescription='text' AXValue='%F0%9D%90%B5'
++++++++++AXGroup AXSubrole=AXMathNumber AXRoleDescription='group'
++++++++++++AXStaticText AXRoleDescription='text' AXValue='2'
21 changes: 12 additions & 9 deletions content/test/data/accessibility/html/math-expected-uia-win.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ Document
++Group IsControlElement=false
++++Group IsControlElement=false
++++++Group IsControlElement=false
++++++++Text Name='%F0%9D%90%B4'
++++++Group IsControlElement=false
++++++++Text Name='2'
++++++Group IsControlElement=false
++++++++Text Name='+'
++++++Group IsControlElement=false
++++++++Text Name='%F0%9D%90%B5'
++++++Group IsControlElement=false
++++++++Text Name='2'
++++++++Group IsControlElement=false
++++++++++Group IsControlElement=false
++++++++++++Text Name='%F0%9D%90%B4'
++++++++++Group IsControlElement=false
++++++++++++Text Name='2'
++++++++Group IsControlElement=false
++++++++++Text Name='+'
++++++++Group IsControlElement=false
++++++++++Group IsControlElement=false
++++++++++++Text Name='%F0%9D%90%B5'
++++++++++Group IsControlElement=false
++++++++++++Text Name='2'
23 changes: 13 additions & 10 deletions content/test/data/accessibility/html/math-expected-win.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE
++IA2_ROLE_SECTION
++++ROLE_SYSTEM_EQUATION inner_html='<newline> <mrow><newline> <msup><mi>%F0%9D%90%B4</mi><mn>2</mn></msup><newline> <mo>+</mo><newline> <msup><mi>%F0%9D%90%B5</mi><mn>2</mn></msup><newline> </mrow><newline> '
++++++IA2_ROLE_SECTION
++++++++ROLE_SYSTEM_STATICTEXT name='%F0%9D%90%B4'
++++++IA2_ROLE_SECTION
++++++++ROLE_SYSTEM_STATICTEXT name='2'
++++++IA2_ROLE_SECTION
++++++++ROLE_SYSTEM_STATICTEXT name='+'
++++++IA2_ROLE_SECTION
++++++++ROLE_SYSTEM_STATICTEXT name='%F0%9D%90%B5'
++++++IA2_ROLE_SECTION
++++++++ROLE_SYSTEM_STATICTEXT name='2'
++++++ROLE_SYSTEM_GROUPING
++++++++ROLE_SYSTEM_GROUPING
++++++++++ROLE_SYSTEM_GROUPING
++++++++++++ROLE_SYSTEM_STATICTEXT name='%F0%9D%90%B4'
++++++++++ROLE_SYSTEM_GROUPING
++++++++++++ROLE_SYSTEM_STATICTEXT name='2'
++++++++ROLE_SYSTEM_GROUPING
++++++++++ROLE_SYSTEM_STATICTEXT name='+'
++++++++ROLE_SYSTEM_GROUPING
++++++++++ROLE_SYSTEM_GROUPING
++++++++++++ROLE_SYSTEM_STATICTEXT name='%F0%9D%90%B5'
++++++++++ROLE_SYSTEM_GROUPING
++++++++++++ROLE_SYSTEM_STATICTEXT name='2'
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
rootWebArea
++genericContainer ignored
++++genericContainer ignored
++++++radioButton name='Both%C2%A01 + 4%C2%A0and%C2%A0' checkedState=false
++++++radioButton name='Both%C2%A0%C2%A0and%C2%A0' checkedState=false
++++++++staticText name='Both%C2%A0'
++++++++++inlineTextBox name='Both%C2%A0'
++++++++math name='1 + 4'
++++++++++genericContainer
++++++++math
++++++++++mathMLNumber
++++++++++++staticText name='1'
++++++++++++++inlineTextBox name='1'
++++++++++genericContainer
++++++++++mathMLOperator
++++++++++++staticText name='+'
++++++++++++++inlineTextBox name='+'
++++++++++genericContainer
++++++++++mathMLNumber
++++++++++++staticText name='4'
++++++++++++++inlineTextBox name='4'
++++++++staticText name='%C2%A0and%C2%A0'
++++++++++inlineTextBox name='%C2%A0and%C2%A0'
++++++++mathMLMath
++++++++++genericContainer
++++++++++mathMLNumber
++++++++++++staticText name='2'
++++++++++++++inlineTextBox name='2'
++++++++++genericContainer
++++++++++mathMLOperator
++++++++++++staticText name='+'
++++++++++++++inlineTextBox name='+'
++++++++++genericContainer
++++++++++mathMLNumber
++++++++++++staticText name='3'
++++++++++++++inlineTextBox name='3'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[static] tag:annotation
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mathMLText
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AXGroup AXSubrole=AXMathText
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[section] tag:annotation-xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mathMLRow
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AXGroup AXSubrole=AXMathRow
21 changes: 21 additions & 0 deletions content/test/data/accessibility/mathml/annotation-xml.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<!--
@MAC-ALLOW:AXSubrole
@AURALINUX-ALLOW:tag:*
-->
<style>
semantics > annotation-xml { display: math; } /* make annotation visible */
</style>
<math>
<semantics>
<mfrac><mn>1</mn><mn>2</mn></mfrac>
<annotation encoding="application/x-tex">\frac{1}{2}</annotation>
<annotation-xml class="test" encoding="application/mathml-content+xml">
<apply>
<divide/>
<cn>1</cn>
<cn>2</cn>
</apply>
</annotation-xml>
</semantics>
</math>
21 changes: 21 additions & 0 deletions content/test/data/accessibility/mathml/annotation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<!--
@MAC-ALLOW:AXSubrole
@AURALINUX-ALLOW:tag:*
-->
<style>
semantics > annotation { display: math; } /* make annotation visible */
</style>
<math>
<semantics>
<mfrac><mn>1</mn><mn>2</mn></mfrac>
<annotation class="test" encoding="application/x-tex">\frac{1}{2}</annotation>
<annotation-xml encoding="application/mathml-content+xml">
<apply>
<divide/>
<cn>1</cn>
<cn>2</cn>
</apply>
</annotation-xml>
</semantics>
</math>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[section] tag:maction
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mathMLRow
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AXGroup AXSubrole=AXMathRow
13 changes: 13 additions & 0 deletions content/test/data/accessibility/mathml/maction.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<!--
@MAC-ALLOW:AXSubrole
@AURALINUX-ALLOW:tag:*
-->
<math>
<maction class="test">
<mn>1</mn>
<mn>2</mn>
<mn>3</mn>
<mn>4</mn>
</maction>
</math>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[math] tag:math
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mathMLMath
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AXGroup AXSubrole=AXDocumentMath
7 changes: 7 additions & 0 deletions content/test/data/accessibility/mathml/math.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!DOCTYPE html>
<!--
@MAC-ALLOW:AXSubrole
@AURALINUX-ALLOW:tag:*
-->
<math class="test">
</math>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[section] tag:merror
Loading

0 comments on commit d6d648b

Please sign in to comment.