From 673c1a7a7275424c44153cb08895009bbc17cf62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= Date: Thu, 15 Aug 2019 09:09:33 +0000 Subject: [PATCH] Bug 1574087. Make MathML length, dir, display, displaystyle and mathvariant case insensitive. r=emilio See https://github.com/mathml-refresh/mathml/issues/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) 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 --- dom/mathml/nsMathMLElement.cpp | 24 +-- layout/mathml/mathml.css | 14 +- .../attribute-mapping-001.html.ini | 184 ------------------ .../css-styling/displaystyle-1.html.ini | 73 ------- .../css-styling/displaystyle-2.html.ini | 12 -- .../relations/html5-tree/display-1.html.ini | 7 - .../mathvariant-case-sensitivity-ref.html | 163 ++++++++++++++++ .../mathvariant-case-sensitivity.html | 168 ++++++++++++++++ 8 files changed, 351 insertions(+), 294 deletions(-) delete mode 100644 testing/web-platform/meta/mathml/relations/css-styling/displaystyle-1.html.ini delete mode 100644 testing/web-platform/meta/mathml/relations/html5-tree/display-1.html.ini create mode 100644 testing/web-platform/tests/mathml/relations/css-styling/mathvariant-case-sensitivity-ref.html create mode 100644 testing/web-platform/tests/mathml/relations/css-styling/mathvariant-case-sensitivity.html diff --git a/dom/mathml/nsMathMLElement.cpp b/dom/mathml/nsMathMLElement.cpp index 522d1fd6f8673..b70b743ddea18 100644 --- a/dom/mathml/nsMathMLElement.cpp +++ b/dom/mathml/nsMathMLElement.cpp @@ -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) { @@ -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)) { @@ -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; } @@ -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; } diff --git a/layout/mathml/mathml.css b/layout/mathml/mathml.css index 99ad96c6520bb..aa83fc071e48d 100644 --- a/layout/mathml/mathml.css +++ b/layout/mathml/mathml.css @@ -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; } @@ -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; } @@ -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 diff --git a/testing/web-platform/meta/mathml/relations/css-styling/attribute-mapping-001.html.ini b/testing/web-platform/meta/mathml/relations/css-styling/attribute-mapping-001.html.ini index a7eb012fc1754..831309899d25a 100644 --- a/testing/web-platform/meta/mathml/relations/css-styling/attribute-mapping-001.html.ini +++ b/testing/web-platform/meta/mathml/relations/css-styling/attribute-mapping-001.html.ini @@ -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 - diff --git a/testing/web-platform/meta/mathml/relations/css-styling/displaystyle-1.html.ini b/testing/web-platform/meta/mathml/relations/css-styling/displaystyle-1.html.ini deleted file mode 100644 index 15038d8d6b2f3..0000000000000 --- a/testing/web-platform/meta/mathml/relations/css-styling/displaystyle-1.html.ini +++ /dev/null @@ -1,73 +0,0 @@ -[displaystyle-1.html] - [mover element (alternate_case)] - expected: FAIL - - [mover element (uppercase)] - expected: FAIL - - [munder element (uppercase)] - expected: FAIL - - [msub element (uppercase)] - expected: FAIL - - [math element (explicit display, alternate_case)] - expected: FAIL - - [munderover element (alternate_case)] - expected: FAIL - - [mroot element (uppercase)] - expected: FAIL - - [mstyle element (uppercase)] - expected: FAIL - - [mroot element (alternate_case)] - expected: FAIL - - [mtable element (alternate_case)] - expected: FAIL - - [munder element (alternate_case)] - expected: FAIL - - [msubsup element (alternate_case)] - expected: FAIL - - [math element (explicit display, uppercase)] - expected: FAIL - - [mstyle element (alternate_case)] - expected: FAIL - - [math element (uppercase)] - expected: FAIL - - [mfrac element (uppercase)] - expected: FAIL - - [mtable element (uppercase)] - expected: FAIL - - [msub element (alternate_case)] - expected: FAIL - - [mfrac element (alternate_case)] - expected: FAIL - - [munderover element (uppercase)] - expected: FAIL - - [msubsup element (uppercase)] - expected: FAIL - - [math element (alternate_case)] - expected: FAIL - - [msup element (uppercase)] - expected: FAIL - - [msup element (alternate_case)] - expected: FAIL - diff --git a/testing/web-platform/meta/mathml/relations/css-styling/displaystyle-2.html.ini b/testing/web-platform/meta/mathml/relations/css-styling/displaystyle-2.html.ini index e5b85585842c4..d5b796e84ca96 100644 --- a/testing/web-platform/meta/mathml/relations/css-styling/displaystyle-2.html.ini +++ b/testing/web-platform/meta/mathml/relations/css-styling/displaystyle-2.html.ini @@ -53,9 +53,6 @@ [mroot element (alternate_case)] expected: FAIL - [mtable element (alternate_case)] - expected: FAIL - [munder element (alternate_case)] expected: FAIL @@ -65,12 +62,6 @@ [msubsup element (alternate_case)] expected: FAIL - [mfrac element (uppercase)] - expected: FAIL - - [mtable element (uppercase)] - expected: FAIL - [msubsup element (lowercase)] expected: FAIL @@ -80,9 +71,6 @@ [mover element (lowercase)] expected: FAIL - [mfrac element (alternate_case)] - expected: FAIL - [munderover element (uppercase)] expected: FAIL diff --git a/testing/web-platform/meta/mathml/relations/html5-tree/display-1.html.ini b/testing/web-platform/meta/mathml/relations/html5-tree/display-1.html.ini deleted file mode 100644 index 24c50180875db..0000000000000 --- a/testing/web-platform/meta/mathml/relations/html5-tree/display-1.html.ini +++ /dev/null @@ -1,7 +0,0 @@ -[display-1.html] - [Test display math alternate_case] - expected: FAIL - - [Test display math uppercase] - expected: FAIL - diff --git a/testing/web-platform/tests/mathml/relations/css-styling/mathvariant-case-sensitivity-ref.html b/testing/web-platform/tests/mathml/relations/css-styling/mathvariant-case-sensitivity-ref.html new file mode 100644 index 0000000000000..28d9acc1f4c24 --- /dev/null +++ b/testing/web-platform/tests/mathml/relations/css-styling/mathvariant-case-sensitivity-ref.html @@ -0,0 +1,163 @@ + + + + +mathvariant case sensitivity + + +

+ + 𝕬 + +

+

+ + 𝐀 + +

+

+ + 𝑨 + +

+

+ + 𝗔 + +

+

+ + 𝓐 + +

+

+ + 𝔸 + +

+

+ + 𝔄 + +

+

+ + 𞸰 + +

+

+ + 𝐴 + +

+

+ + 𞺐 + +

+

+ + 𝙰 + +

+

+ + 𝘼 + +

+

+ + 𝖠 + +

+

+ + 𝘈 + +

+

+ + 𝒜 + +

+

+ + 𞹰 + +

+

+ + 𞹒 + +

+ + diff --git a/testing/web-platform/tests/mathml/relations/css-styling/mathvariant-case-sensitivity.html b/testing/web-platform/tests/mathml/relations/css-styling/mathvariant-case-sensitivity.html new file mode 100644 index 0000000000000..0d3e706d961e2 --- /dev/null +++ b/testing/web-platform/tests/mathml/relations/css-styling/mathvariant-case-sensitivity.html @@ -0,0 +1,168 @@ + + + + +mathvariant case sensitivity + + + + + + + +

+ + A + +

+

+ + A + +

+

+ + A + +

+

+ + A + +

+

+ + A + +

+

+ + A + +

+

+ + A + +

+

+ + ف + +

+

+ + A + +

+

+ + ف + +

+

+ + A + +

+

+ + A + +

+

+ + A + +

+

+ + A + +

+

+ + A + +

+

+ + ف + +

+

+ + ق + +

+ +