Skip to content

Commit

Permalink
Export MathML dir-* tests to WPT.
Browse files Browse the repository at this point in the history
- dir-3.html/dir-5.html: These are approximative verifications of overall
  RTL directionality using "covering rectangles". Export them with a
  a specific font in order to make them a bit more robust.
  For dir-5.html we use scripts-spaceafterscript3000.woff and adjust the
  rects accordingly but the test might change later depending on the
  outcome of w3c/mathml-core#217.

- dir-4-ref.html: Removed (the test was removed in bug 1783995).

Differential Revision: https://phabricator.services.mozilla.com/D199702

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1876684
gecko-commit: eb00222e557742d5a6c66534f38345ddf71deaa5
gecko-reviewers: emilio
  • Loading branch information
fred-wang authored and mbrodesser-Igalia committed Feb 19, 2024
1 parent f978992 commit 75f061e
Show file tree
Hide file tree
Showing 4 changed files with 263 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head><title>Test dir=rtl</title></head>
<body style="background: white;">

<div style="position: absolute; top: 0px; left: 0px;">
<div style="width: 40px; height: 3000px; background: black;"></div>
</div>

</body>
</html>
120 changes: 120 additions & 0 deletions mathml/presentation-markup/direction/direction-overall-002.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Verify dir attribute on various containers</title>
<link rel="help" href="https://w3c.github.io/mathml-core/#attributes-common-to-html-and-mathml-elements">
<link rel="help" href="https://w3c.github.io/mathml-core/#css-styling">
<meta name="assert" content="Verify dir attribute on various elements.">
<link rel="match" href="direction-overall-002-ref.html">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<style>
math {
font: 25px/1 Ahem;
}
</style>
</head>

</head>
<body style="background: white;">

<!-- The visible part of the formulas below should be covered by the
black rectangle when dir=rtl -->

<div style="position: absolute; top: 5px; left: 5px;">
<!-- msup -->
<math dir="rtl">
<msup>
<mspace width="20px" height="20px"/>
<mspace width="20px" height="20px" mathbackground="red"/>
</msup>
</math><br/>
<!-- msub -->
<math dir="rtl">
<msub>
<mspace width="20px" height="20px"/>
<mspace width="20px" height="20px" mathbackground="orange"/>
</msub>
</math><br/>
<!-- msubsup -->
<math dir="rtl">
<msubsup>
<mspace width="20px" height="20px"/>
<mspace width="20px" height="20px" mathbackground="green"/>
<mspace width="20px" height="20px" mathbackground="blue"/>
</msubsup>
</math><br/>
<!-- mmultiscripts -->
<math dir="rtl">
<mmultiscripts>
<mspace/>
<mspace width="20px" height="20px" mathbackground="cyan"/>
<mspace width="20px" height="20px" mathbackground="yellow"/>
<mprescripts/>
<mspace width="20px" height="20px"/>
<mspace width="20px" height="20px"/>
</mmultiscripts>
</math><br/>
<!-- munder (mo with movablelimits=true and displaystyle=false) -->
<math dir="rtl">
<munder>
<mpadded width="20px">
<mphantom>
<mo movablelimits="true" displaystyle="false">|</mo>
</mphantom>
</mpadded>
<mspace width="20px" height="20px" mathbackground="magenta"/>
</munder>
</math><br/>
<!-- mover (mo with movablelimits=true and displaystyle=false) -->
<math dir="rtl">
<mover>
<mpadded width="20px">
<mphantom>
<mo movablelimits="true" displaystyle="false">|</mo>
</mphantom>
</mpadded>
<mspace width="20px" height="20px" mathbackground="cyan"/>
</mover>
</math><br/>
<!-- munderover (mo with movablelimits=true and displaystyle=false) -->
<math dir="rtl">
<munderover>
<mpadded width="20px">
<mphantom>
<mo movablelimits="true" displaystyle="false">|</mo>
</mphantom>
</mpadded>
<mspace width="20px" height="20px" mathbackground="yellow"/>
<mspace width="20px" height="20px" mathbackground="grey"/>
</munderover>
</math><br/>
<!-- mroot -->
<math dir="rtl">
<mstyle mathcolor="white">
<mroot>
<mspace width="20px" height="20px" mathbackground="orange"/>
<mspace width="20px" height="20px"/>
</mroot>
</mstyle>
</math><br/>
<!-- msqrt -->
<math dir="rtl">
<mstyle mathcolor="white">
<msqrt>
<!-- Here, we assume that (width of radical + width of mspace)
is greater than the width of the black rectangle (i.e.
width of radical > 30 - 25 = 5px), so the test fails if the
radical is placed on the left. -->
<mspace width="25px" height="20px" mathbackground="grey"/>
</msqrt>
</mstyle>
</math>
</div>

<div style="position: absolute; top: 0px; left: 0px;">
<div style="width: 40px; height: 3000px; background: black"></div>
</div>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html>
<head><title>Test dir=rtl</title></head>
<body>

<div style="position: absolute;
top: 5px; left: 5px; width: 200px; height: 200px;">
<div style="position: absolute; width: 70px; height: 200px;
left: 0px; background: red;"></div>
<div style="position: absolute; width: 70px; height: 200px;
left: 70px; background: green;"></div>
<div style="position: absolute; width: 70px; height: 200px;
left: 140px; background: magenta;"></div>
<div style="position: absolute; width: 70px; height: 200px;
left: 210px; background: blue;"></div>
<div style="position: absolute; width: 70px; height: 200px;
left: 280px; background: yellow;"></div>-->
</div>


<div style="position: absolute;
top: 5px; left: 5px; width: 200px; height: 200px;">
<div style="position: absolute; width: 10px; height: 200px;
left: -5px; background: black;"></div>
<div style="position: absolute; width: 10px; height: 200px;
left: 65px; background: black;"></div>
<div style="position: absolute; width: 10px; height: 200px;
left: 135px; background: black;"></div>
<div style="position: absolute; width: 10px; height: 200px;
left: 205px; background: black;"></div>
<div style="position: absolute; width: 10px; height: 200px;
left: 275px; background: black;"></div>
<div style="position: absolute; width: 10px; height: 200px;
left: 345px; background: black;"></div>
</div>

</body>
</html>
94 changes: 94 additions & 0 deletions mathml/presentation-markup/direction/direction-overall-003.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Verify dir attribute on various containers</title>
<link rel="help" href="https://w3c.github.io/mathml-core/#attributes-common-to-html-and-mathml-elements">
<link rel="help" href="https://w3c.github.io/mathml-core/#css-styling">
<meta name="assert" content="Verify dir attribute on various mmultiscripts.">
<link rel="match" href="direction-overall-003-ref.html">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<style>
math {
/* Ensure the space after script is 30px */
font: 10px spaceafterscript3000;
}
@font-face {
font-family: spaceafterscript3000;
src: url("/fonts/math/scripts-spaceafterscript3000.woff");
}
</style>
</head>
<body>

<!-- mmultiscripts. The formulas
1 3 3 1
X in dir=ltr and X in dir=rtl
2 4 4 2
do not match perfectly, so we use an alternative == reftest here
which is less strict. -->

<!-- five vertical bands: red, green, magenta, blue and yellow -->
<div style="position: absolute;
top: 5px; left: 5px; width: 200px; height: 200px;">
<div style="position: absolute; width: 70px; height: 200px;
left: 0px; background: red;"></div>
<div style="position: absolute; width: 70px; height: 200px;
left: 70px; background: green;"></div>
<div style="position: absolute; width: 70px; height: 200px;
left: 140px; background: magenta;"></div>
<div style="position: absolute; width: 70px; height: 200px;
left: 210px; background: blue;"></div>
<div style="position: absolute; width: 70px; height: 200px;
left: 280px; background: yellow;"></div>-->
</div>

<!-- a mmultiscripts element whose children are squares of different
colors. In dir=rtl, the color of each square should match the one of
the band over which the square is positioned. Hence, this
mmultiscripts should not be visible. -->
<div style="position: absolute;
top: 5px; left: 5px; width: 200px; height: 200px;">
<math dir="rtl">
<mmultiscripts>
<mspace width="40px" height="40px" mathbackground="magenta"/>

<mspace width="40px" height="40px" mathbackground="green"/>
<mspace width="40px" height="40px" mathbackground="green"/>

<mspace width="40px" height="40px" mathbackground="red"/>
<mspace width="40px" height="40px" mathbackground="red"/>

<mprescripts/>

<mspace width="40px" height="40px" mathbackground="yellow"/>
<mspace width="40px" height="40px" mathbackground="yellow"/>

<mspace width="40px" height="40px" mathbackground="blue"/>
<mspace width="40px" height="40px" mathbackground="blue"/>
</mmultiscripts>
</math>
</div>

<!-- We add black vertical bands to cover spaces between the children of
mmultiscripts. -->
<div style="position: absolute;
top: 5px; left: 5px; width: 200px; height: 200px;">
<div style="position: absolute; width: 10px; height: 200px;
left: -5px; background: black;"></div>
<div style="position: absolute; width: 10px; height: 200px;
left: 65px; background: black;"></div>
<div style="position: absolute; width: 10px; height: 200px;
left: 135px; background: black;"></div>
<div style="position: absolute; width: 10px; height: 200px;
left: 205px; background: black;"></div>
<div style="position: absolute; width: 10px; height: 200px;
left: 275px; background: black;"></div>
<div style="position: absolute; width: 10px; height: 200px;
left: 345px; background: black;"></div>
</div>

</body>
</html>

0 comments on commit 75f061e

Please sign in to comment.