From fe0998d6189d1215456272931876c16a3441b51f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?=
Date: Mon, 2 Sep 2024 13:59:59 +0000
Subject: [PATCH] Bug 1912435 - Make MathML boolean attributes ASCII
case-insensitive. r=emilio
This commit ensures MathML boolean attributes (namely displaystyle,
mo@stretchy, mo@symmetric, mo@largeop, mo@movablelimits,
munder@accentunder, mover@accent, munderover@accent,
munderover@accentunder) are ASCII case-insensitive [1]. For
displaystyle that was handled in [2]. For mover/munder/munderover
attributes, this is covered by a test case from scriptlevel-001.html
checking both case-insensitivity and dynamic changes at the same time ;
the latter still seems broken, so these checks are moved into separate
test cases. For mo attributes, a new WPT test is added. Note that
mo@accent, mo@fence, mo@separator are not part of MathML Core (with the
two last without visual effect), we make them case-insensitive for
consistency but don't bother adding tests for them.
[1] https://w3c.github.io/mathml-core/#dfn-boolean used here:
[2] https://bugzilla.mozilla.org/show_bug.cgi?id=1574087
Differential Revision: https://phabricator.services.mozilla.com/D218944
---
layout/mathml/nsMathMLmoFrame.cpp | 33 +++++++-----
layout/mathml/nsMathMLmunderoverFrame.cpp | 8 +--
.../css-styling/scriptlevel-001.html.ini | 2 +-
...olean-attributes-case-insensitive-ref.html | 45 ++++++++++++++++
...o-boolean-attributes-case-insensitive.html | 51 +++++++++++++++++++
.../css-styling/scriptlevel-001.html | 40 ++++++++++-----
6 files changed, 148 insertions(+), 31 deletions(-)
create mode 100644 testing/web-platform/tests/mathml/presentation-markup/operators/mo-boolean-attributes-case-insensitive-ref.html
create mode 100644 testing/web-platform/tests/mathml/presentation-markup/operators/mo-boolean-attributes-case-insensitive.html
diff --git a/layout/mathml/nsMathMLmoFrame.cpp b/layout/mathml/nsMathMLmoFrame.cpp
index 8410edc69fc9..6031b75efdf6 100644
--- a/layout/mathml/nsMathMLmoFrame.cpp
+++ b/layout/mathml/nsMathMLmoFrame.cpp
@@ -237,17 +237,19 @@ void nsMathMLmoFrame::ProcessOperatorData() {
// see if the accent attribute is there
mContent->AsElement()->GetAttr(nsGkAtoms::accent_, value);
- if (value.EqualsLiteral("true"))
+ if (value.LowerCaseEqualsLiteral("true")) {
mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENT;
- else if (value.EqualsLiteral("false"))
+ } else if (value.LowerCaseEqualsLiteral("false")) {
mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENT;
+ }
// see if the movablelimits attribute is there
mContent->AsElement()->GetAttr(nsGkAtoms::movablelimits_, value);
- if (value.EqualsLiteral("true"))
+ if (value.LowerCaseEqualsLiteral("true")) {
mEmbellishData.flags |= NS_MATHML_EMBELLISH_MOVABLELIMITS;
- else if (value.EqualsLiteral("false"))
+ } else if (value.LowerCaseEqualsLiteral("false")) {
mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_MOVABLELIMITS;
+ }
// ---------------------------------------------------------------------
// we will be called again to re-sync the rest of our state next time...
@@ -444,36 +446,39 @@ void nsMathMLmoFrame::ProcessOperatorData() {
// don't process them here
mContent->AsElement()->GetAttr(nsGkAtoms::stretchy_, value);
- if (value.EqualsLiteral("false")) {
+ if (value.LowerCaseEqualsLiteral("false")) {
mFlags &= ~NS_MATHML_OPERATOR_STRETCHY;
- } else if (value.EqualsLiteral("true")) {
+ } else if (value.LowerCaseEqualsLiteral("true")) {
mFlags |= NS_MATHML_OPERATOR_STRETCHY;
}
if (NS_MATHML_OPERATOR_IS_FENCE(mFlags)) {
mContent->AsElement()->GetAttr(nsGkAtoms::fence_, value);
- if (value.EqualsLiteral("false"))
+ if (value.LowerCaseEqualsLiteral("false")) {
mFlags &= ~NS_MATHML_OPERATOR_FENCE;
- else
+ } else {
mEmbellishData.flags |= NS_MATHML_EMBELLISH_FENCE;
+ }
}
mContent->AsElement()->GetAttr(nsGkAtoms::largeop_, value);
- if (value.EqualsLiteral("false")) {
+ if (value.LowerCaseEqualsLiteral("false")) {
mFlags &= ~NS_MATHML_OPERATOR_LARGEOP;
- } else if (value.EqualsLiteral("true")) {
+ } else if (value.LowerCaseEqualsLiteral("true")) {
mFlags |= NS_MATHML_OPERATOR_LARGEOP;
}
if (NS_MATHML_OPERATOR_IS_SEPARATOR(mFlags)) {
mContent->AsElement()->GetAttr(nsGkAtoms::separator_, value);
- if (value.EqualsLiteral("false"))
+ if (value.LowerCaseEqualsLiteral("false")) {
mFlags &= ~NS_MATHML_OPERATOR_SEPARATOR;
- else
+ } else {
mEmbellishData.flags |= NS_MATHML_EMBELLISH_SEPARATOR;
+ }
}
mContent->AsElement()->GetAttr(nsGkAtoms::symmetric_, value);
- if (value.EqualsLiteral("false"))
+ if (value.LowerCaseEqualsLiteral("false")) {
mFlags &= ~NS_MATHML_OPERATOR_SYMMETRIC;
- else if (value.EqualsLiteral("true"))
+ } else if (value.LowerCaseEqualsLiteral("true")) {
mFlags |= NS_MATHML_OPERATOR_SYMMETRIC;
+ }
// minsize
//
diff --git a/layout/mathml/nsMathMLmunderoverFrame.cpp b/layout/mathml/nsMathMLmunderoverFrame.cpp
index 84d145c650e3..8cc6db3ff7d4 100644
--- a/layout/mathml/nsMathMLmunderoverFrame.cpp
+++ b/layout/mathml/nsMathMLmunderoverFrame.cpp
@@ -223,9 +223,9 @@ XXX The winner is the outermost setting in conflicting settings like these:
// if we have an accentunder attribute, it overrides what the underscript
// said
if (mContent->AsElement()->GetAttr(nsGkAtoms::accentunder_, value)) {
- if (value.EqualsLiteral("true")) {
+ if (value.LowerCaseEqualsLiteral("true")) {
mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTUNDER;
- } else if (value.EqualsLiteral("false")) {
+ } else if (value.LowerCaseEqualsLiteral("false")) {
mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTUNDER;
}
}
@@ -244,9 +244,9 @@ XXX The winner is the outermost setting in conflicting settings like these:
// if we have an accent attribute, it overrides what the overscript said
if (mContent->AsElement()->GetAttr(nsGkAtoms::accent_, value)) {
- if (value.EqualsLiteral("true")) {
+ if (value.LowerCaseEqualsLiteral("true")) {
mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTOVER;
- } else if (value.EqualsLiteral("false")) {
+ } else if (value.LowerCaseEqualsLiteral("false")) {
mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTOVER;
}
}
diff --git a/testing/web-platform/meta/mathml/relations/css-styling/scriptlevel-001.html.ini b/testing/web-platform/meta/mathml/relations/css-styling/scriptlevel-001.html.ini
index f9cf398b29e2..7f956e77adbf 100644
--- a/testing/web-platform/meta/mathml/relations/css-styling/scriptlevel-001.html.ini
+++ b/testing/web-platform/meta/mathml/relations/css-styling/scriptlevel-001.html.ini
@@ -1,3 +1,3 @@
[scriptlevel-001.html]
- [checking dynamic/case-insensitive accent/accentunder]
+ [checking dynamic accent/accentunder]
expected: FAIL
diff --git a/testing/web-platform/tests/mathml/presentation-markup/operators/mo-boolean-attributes-case-insensitive-ref.html b/testing/web-platform/tests/mathml/presentation-markup/operators/mo-boolean-attributes-case-insensitive-ref.html
new file mode 100644
index 000000000000..7bc63828dc02
--- /dev/null
+++ b/testing/web-platform/tests/mathml/presentation-markup/operators/mo-boolean-attributes-case-insensitive-ref.html
@@ -0,0 +1,45 @@
+
+
+Test case insensitivity of mo boolean attributes (reference)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/testing/web-platform/tests/mathml/presentation-markup/operators/mo-boolean-attributes-case-insensitive.html b/testing/web-platform/tests/mathml/presentation-markup/operators/mo-boolean-attributes-case-insensitive.html
new file mode 100644
index 000000000000..56c8f0a6b5d4
--- /dev/null
+++ b/testing/web-platform/tests/mathml/presentation-markup/operators/mo-boolean-attributes-case-insensitive.html
@@ -0,0 +1,51 @@
+
+
+Test case insensitivity of mo boolean attributes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/testing/web-platform/tests/mathml/relations/css-styling/scriptlevel-001.html b/testing/web-platform/tests/mathml/relations/css-styling/scriptlevel-001.html
index e9be1f2965eb..e411433c9f00 100644
--- a/testing/web-platform/tests/mathml/relations/css-styling/scriptlevel-001.html
+++ b/testing/web-platform/tests/mathml/relations/css-styling/scriptlevel-001.html
@@ -55,43 +55,50 @@
});
test(function() {
- var element = document.querySelector("munder[accentunder='true']");
+ var element = document.getElementById("munder-accentunder")
assert_approx_equals(fontSize(element.children[0]), fontSizeAtScriptLevelZero, epsilon, "base");
assert_approx_equals(fontSize(element.children[1]), fontSizeAtScriptLevelZero, epsilon, "under");
}, `automatic scriptlevel on munder (accentunder=true)`);
test(function() {
- var element = document.querySelector("mover[accent='true']");
+ var element = document.getElementById("mover-accent")
assert_approx_equals(fontSize(element.children[0]), fontSizeAtScriptLevelZero, epsilon, "base");
assert_approx_equals(fontSize(element.children[1]), fontSizeAtScriptLevelZero, epsilon, "over");
}, `automatic scriptlevel on mover (accent=true)`);
test(function() {
- var element = document.querySelector("munderover[accentunder='true']");
+ var element = document.getElementById("munderover-accentunder")
assert_approx_equals(fontSize(element.children[0]), fontSizeAtScriptLevelZero, epsilon, "base");
assert_approx_equals(fontSize(element.children[1]), fontSizeAtScriptLevelZero, epsilon, "under");
assert_approx_equals(fontSize(element.children[2]), fontSizeAtScriptLevelZero * .71, epsilon, "over");
}, `automatic scriptlevel on munderover (accentunder=true)`);
test(function() {
- var element = document.querySelector("munderover[accent='true']");
+ var element = document.getElementById("munderover-accent")
assert_approx_equals(fontSize(element.children[0]), fontSizeAtScriptLevelZero, epsilon, "base");
assert_approx_equals(fontSize(element.children[1]), fontSizeAtScriptLevelZero * .71, epsilon, "under");
assert_approx_equals(fontSize(element.children[2]), fontSizeAtScriptLevelZero, epsilon, "over");
}, `automatic scriptlevel on munderover (accent=true)`);
test(function() {
- var element = document.getElementById("munderover-dynamic-case-insensitive")
+ var element = document.getElementById("munderover-case-insensitive")
+ assert_approx_equals(fontSize(element.children[0]), fontSizeAtScriptLevelZero, epsilon, "base");
+ assert_approx_equals(fontSize(element.children[1]), fontSizeAtScriptLevelZero, epsilon, "under");
+ assert_approx_equals(fontSize(element.children[2]), fontSizeAtScriptLevelZero, epsilon, "over");
+ }, "checking case-insensitivity accent/accentunder");
+
+ test(function() {
+ var element = document.getElementById("munderover-dynamic")
assert_approx_equals(fontSize(element.children[0]), fontSizeAtScriptLevelZero, epsilon, "base");
assert_approx_equals(fontSize(element.children[1]), fontSizeAtScriptLevelZero * .71, epsilon, "under");
assert_approx_equals(fontSize(element.children[2]), fontSizeAtScriptLevelZero, epsilon, "over");
element.removeAttribute("accent");
- element.setAttribute("accentunder", "TrUe");
+ element.setAttribute("accentunder", "true");
assert_approx_equals(fontSize(element.children[0]), fontSizeAtScriptLevelZero, epsilon, "base");
assert_approx_equals(fontSize(element.children[1]), fontSizeAtScriptLevelZero, epsilon, "under");
assert_approx_equals(fontSize(element.children[2]), fontSizeAtScriptLevelZero * .71, epsilon, "over");
- }, "checking dynamic/case-insensitive accent/accentunder");
+ }, "checking dynamic accent/accentunder");
done();
}
@@ -179,26 +186,26 @@