Skip to content

Commit

Permalink
Bug 1574087. Make MathML length, dir, display, displaystyle and mathv…
Browse files Browse the repository at this point in the history
…ariant case insensitive. r=emilio

See w3c/mathml#22

* mathml/relations/css-styling/attribute-mapping-001.html (length, dir)
* mathml/relations/html5-tree/display-1.html (display)
* mathml/relations/css-styling/displaystyle-1.html (displaystyle)
* mathml/relations/css-styling/displaystyle-2.html (displaystyle)
* mathml/relations/css-styling/mathvariant-case-sensitivity.html (mathvariant)

layout/reftests/bugs/355548-3.xml has been updated now that units are case
insensitive.

Note:
* mathml/relations/css-styling/attribute-mapping-002.html also checks
  case insensitiveness of mathvariant and displaystyle but for now we map
  these attributes to internal -moz-* CSS properties.
* mathcolor and mathbackground values are already case insensitive, this
  is verified by mathml/relations/css-styling/attribute-mapping-001.html

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

--HG--
extra : moz-landing-system : lando
  • Loading branch information
fred-wang committed Aug 15, 2019
1 parent 47760e6 commit 3aec893
Show file tree
Hide file tree
Showing 10 changed files with 353 additions and 296 deletions.
24 changes: 13 additions & 11 deletions dom/mathml/nsMathMLElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ bool nsMathMLElement::ParseNamedSpaceValue(const nsString& aString,
// number)"
//
/* static */
// XXXfredw: Deprecate legacy MathML syntax and use the CSS parser instead.
// See https://github.com/mathml-refresh/mathml/issues/63
bool nsMathMLElement::ParseNumericValue(const nsString& aString,
nsCSSValue& aCSSValue, uint32_t aFlags,
Document* aDocument) {
Expand Down Expand Up @@ -359,23 +361,23 @@ bool nsMathMLElement::ParseNumericValue(const nsString& aString,
} else if (unit.EqualsLiteral("%")) {
aCSSValue.SetPercentValue(floatValue / 100.0f);
return true;
} else if (unit.EqualsLiteral("em"))
} else if (unit.LowerCaseEqualsLiteral("em"))
cssUnit = eCSSUnit_EM;
else if (unit.EqualsLiteral("ex"))
else if (unit.LowerCaseEqualsLiteral("ex"))
cssUnit = eCSSUnit_XHeight;
else if (unit.EqualsLiteral("px"))
else if (unit.LowerCaseEqualsLiteral("px"))
cssUnit = eCSSUnit_Pixel;
else if (unit.EqualsLiteral("in"))
else if (unit.LowerCaseEqualsLiteral("in"))
cssUnit = eCSSUnit_Inch;
else if (unit.EqualsLiteral("cm"))
else if (unit.LowerCaseEqualsLiteral("cm"))
cssUnit = eCSSUnit_Centimeter;
else if (unit.EqualsLiteral("mm"))
else if (unit.LowerCaseEqualsLiteral("mm"))
cssUnit = eCSSUnit_Millimeter;
else if (unit.EqualsLiteral("pt"))
else if (unit.LowerCaseEqualsLiteral("pt"))
cssUnit = eCSSUnit_Point;
else if (unit.EqualsLiteral("pc"))
else if (unit.LowerCaseEqualsLiteral("pc"))
cssUnit = eCSSUnit_Pica;
else if (unit.EqualsLiteral("q"))
else if (unit.LowerCaseEqualsLiteral("q"))
cssUnit = eCSSUnit_Quarter;
else { // unexpected unit
if (!(aFlags & PARSE_SUPPRESS_WARNINGS)) {
Expand Down Expand Up @@ -673,7 +675,7 @@ void nsMathMLElement::MapMathMLAttributesInto(
NS_MATHML_MATHVARIANT_LOOPED,
NS_MATHML_MATHVARIANT_STRETCHED};
for (uint32_t i = 0; i < ArrayLength(sizes); ++i) {
if (str.EqualsASCII(sizes[i])) {
if (str.LowerCaseEqualsASCII(sizes[i])) {
aDecls.SetKeywordValue(eCSSProperty__moz_math_variant, values[i]);
break;
}
Expand Down Expand Up @@ -799,7 +801,7 @@ void nsMathMLElement::MapMathMLAttributesInto(
static const int32_t dirValues[MOZ_ARRAY_LENGTH(dirs)] = {
NS_STYLE_DIRECTION_LTR, NS_STYLE_DIRECTION_RTL};
for (uint32_t i = 0; i < ArrayLength(dirs); ++i) {
if (str.EqualsASCII(dirs[i])) {
if (str.LowerCaseEqualsASCII(dirs[i])) {
aDecls.SetKeywordValue(eCSSProperty_direction, dirValues[i]);
break;
}
Expand Down
14 changes: 7 additions & 7 deletions layout/mathml/mathml.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ math {
-moz-float-edge: margin-box;
-moz-math-display: inline;
}
math[display="block"] {
math[display="block" i] {
display: block;
text-align: -moz-center;
-moz-math-display: block;
}
math[display="inline"] {
math[display="inline" i] {
display: inline;
-moz-math-display: inline;
}
math[displaystyle="false"] {
math[displaystyle="false" i] {
-moz-math-display: inline;
}
math[displaystyle="true"] {
math[displaystyle="true" i] {
-moz-math-display: block;
}

Expand Down Expand Up @@ -233,10 +233,10 @@ mtable[framespacing] > mtr > mtd {
/*
Map mstyle@displaystyle to -moz-math-display.
*/
mstyle[displaystyle="false"] {
mstyle[displaystyle="false" i] {
-moz-math-display: inline;
}
mstyle[displaystyle="true"] {
mstyle[displaystyle="true" i] {
-moz-math-display: block;
}

Expand Down Expand Up @@ -316,7 +316,7 @@ munderover > :not(:first-child) {
mtable element sets displaystyle to "false" within the table elements.
*/
mtable { -moz-math-display: inline; }
mtable[displaystyle="true"] { -moz-math-display: block; }
mtable[displaystyle="true" i] { -moz-math-display: block; }

/*
The mscarries element sets displaystyle to "false", and increments
Expand Down
2 changes: 1 addition & 1 deletion layout/reftests/bugs/355548-3-ref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
<m:mstyle><m:mi style="font-size:48px;">Id</m:mi></m:mstyle>
<m:mstyle><m:mi style="font-size:48px;">Id</m:mi></m:mstyle>
<m:mstyle><m:mi style="font-size:48px;">Id</m:mi></m:mstyle>
<m:mstyle><m:mi style="font-size:48px;">Id</m:mi></m:mstyle>
</m:math></p>

<p><m:math>
Expand All @@ -61,6 +60,7 @@
<m:mstyle><m:mi style="font-size:0;">Id</m:mi></m:mstyle>
<m:mstyle><m:mi style="font-size:0;">Id</m:mi></m:mstyle>
<m:mstyle><m:mi style="font-size:0;">Id</m:mi></m:mstyle>
<m:mstyle><m:mi style="font-size:20px;">Id</m:mi></m:mstyle>
</m:math></p>

</body>
Expand Down
2 changes: 1 addition & 1 deletion layout/reftests/bugs/355548-3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
<p><m:math><m:mstyle scriptlevel="0" scriptsizemultiplier="0.5" scriptminsize="18px" style="font-size:48px;">
<!-- test invalid values for MathML length attributes -->
<m:mstyle mathsize="20 px"><m:mi>Id</m:mi></m:mstyle>
<m:mstyle mathsize="20PX"><m:mi>Id</m:mi></m:mstyle>
<m:mstyle mathsize=".px"><m:mi>Id</m:mi></m:mstyle>
<m:mstyle mathsize="..px"><m:mi>Id</m:mi></m:mstyle>
<m:mstyle mathsize="+20px"><m:mi>Id</m:mi></m:mstyle>
Expand All @@ -72,6 +71,7 @@
<m:mstyle mathsize=".0px"><m:mi>Id</m:mi></m:mstyle>
<m:mstyle mathsize="-0px"><m:mi>Id</m:mi></m:mstyle>
<m:mstyle mathsize="0"><m:mi>Id</m:mi></m:mstyle>
<m:mstyle mathsize="20PX"><m:mi>Id</m:mi></m:mstyle>
</m:mstyle></m:math></p>

</body>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,196 +1,12 @@
[attribute-mapping-001.html]
[mathsize on the msub element is mapped to CSS font-size]
expected: FAIL

[dir on the msup element is mapped to CSS direction]
expected: FAIL

[mathsize on the mstyle element is mapped to CSS font-size]
expected: FAIL

[dir on the math element is mapped to CSS direction]
expected: FAIL

[dir on the munder element is mapped to CSS direction]
expected: FAIL

[dir on the munderover element is mapped to CSS direction]
expected: FAIL

[mathsize on the maction element is mapped to CSS font-size]
expected: FAIL

[mathsize on the mi element is mapped to CSS font-size]
expected: FAIL

[dir on the mover element is mapped to CSS direction]
expected: FAIL

[mathsize on the mtable element is mapped to CSS font-size]
expected: FAIL

[mathsize on the mn element is mapped to CSS font-size]
expected: FAIL

[dir on the msqrt element is mapped to CSS direction]
expected: FAIL

[dir on the mtr element is mapped to CSS direction]
expected: FAIL

[mathsize on the msqrt element is mapped to CSS font-size]
expected: FAIL

[mathsize on the mrow element is mapped to CSS font-size]
expected: FAIL

[mathsize on the mfrac element is mapped to CSS font-size]
expected: FAIL

[mathsize on the munder element is mapped to CSS font-size]
expected: FAIL

[mathsize on the mtr element is mapped to CSS font-size]
expected: FAIL

[mathsize on the annotation-xml element is mapped to CSS font-size]
expected: FAIL

[mathsize on the none element is mapped to CSS font-size]
expected: FAIL

[dir on the merror element is mapped to CSS direction]
expected: FAIL

[dir on the mfrac element is mapped to CSS direction]
expected: FAIL

[mathsize on the menclose element is mapped to CSS font-size]
expected: FAIL

[mathsize on the mroot element is mapped to CSS font-size]
expected: FAIL

[mathsize on the munderover element is mapped to CSS font-size]
expected: FAIL

[mathcolor on the merror element is mapped to CSS color]
expected: FAIL

[mathsize on the msubsup element is mapped to CSS font-size]
expected: FAIL

[dir on the mtd element is mapped to CSS direction]
expected: FAIL

[mathsize on the mprescripts element is mapped to CSS font-size]
expected: FAIL

[dir on the maction element is mapped to CSS direction]
expected: FAIL

[dir on the annotation-xml element is mapped to CSS direction]
expected: FAIL

[mathsize on the ms element is mapped to CSS font-size]
expected: FAIL

[dir on the mstyle element is mapped to CSS direction]
expected: FAIL

[dir on the mtext element is mapped to CSS direction]
expected: FAIL

[dir on the mspace element is mapped to CSS direction]
expected: FAIL

[dir on the mphantom element is mapped to CSS direction]
expected: FAIL

[dir on the annotation element is mapped to CSS direction]
expected: FAIL

[dir on the none element is mapped to CSS direction]
expected: FAIL

[dir on the mrow element is mapped to CSS direction]
expected: FAIL

[dir on the menclose element is mapped to CSS direction]
expected: FAIL

[mathsize on the mspace element is mapped to CSS font-size]
expected: FAIL

[dir on the mroot element is mapped to CSS direction]
expected: FAIL

[dir on the mo element is mapped to CSS direction]
expected: FAIL

[dir on the mprescripts element is mapped to CSS direction]
expected: FAIL

[mathsize on the math element is mapped to CSS font-size]
expected: FAIL

[mathsize on the mover element is mapped to CSS font-size]
expected: FAIL

[mathsize on the mtd element is mapped to CSS font-size]
expected: FAIL

[mathsize on the merror element is mapped to CSS font-size]
expected: FAIL

[dir on the msub element is mapped to CSS direction]
expected: FAIL

[mathsize on the mmultiscripts element is mapped to CSS font-size]
expected: FAIL

[dir on the mmultiscripts element is mapped to CSS direction]
expected: FAIL

[dir on the mi element is mapped to CSS direction]
expected: FAIL

[dir on the mn element is mapped to CSS direction]
expected: FAIL

[mathsize on the msup element is mapped to CSS font-size]
expected: FAIL

[mathsize on the mphantom element is mapped to CSS font-size]
expected: FAIL

[mathsize on the mo element is mapped to CSS font-size]
expected: FAIL

[dir on the msubsup element is mapped to CSS direction]
expected: FAIL

[mathsize on the mtext element is mapped to CSS font-size]
expected: FAIL

[dir on the ms element is mapped to CSS direction]
expected: FAIL

[dir on the mpadded element is mapped to CSS direction]
expected: FAIL

[mathsize on the annotation element is mapped to CSS font-size]
expected: FAIL

[mathsize on the mpadded element is mapped to CSS font-size]
expected: FAIL

[dir on the mtable element is mapped to CSS direction]
expected: FAIL

[dir on the semantics element is mapped to CSS direction]
expected: FAIL

[mathsize on the semantics element is mapped to CSS font-size]
expected: FAIL

Loading

0 comments on commit 3aec893

Please sign in to comment.