From 0421d864fc4c0c7fbfd6b606e215d995c6721f8a Mon Sep 17 00:00:00 2001
From: Butkovits Atila
Date: Wed, 21 Sep 2022 15:06:25 +0300
Subject: [PATCH] Backed out 3 changesets (bug 1790009) for causing mochitest
failures at browser_misused_characters_in_strings.js. CLOSED TREE
Backed out changeset 73ff5b4bf98c (bug 1790009)
Backed out changeset 236e1d9535ed (bug 1790009)
Backed out changeset 90ee5367d506 (bug 1790009)
---
layout/mathml/mathfont.properties | 33 +++++
layout/mathml/nsMathMLOperators.cpp | 128 ++++++++++--------
layout/mathml/nsMathMLOperators.h | 27 ++--
layout/mathml/nsMathMLmoFrame.cpp | 24 +---
layout/mathml/updateOperatorDictionary.pl | 13 --
.../operator-dictionary-combining.html | 53 +-------
...-dictionary-empty-and-three-chars-ref.html | 32 -----
...ator-dictionary-empty-and-three-chars.html | 39 ------
8 files changed, 124 insertions(+), 225 deletions(-)
delete mode 100644 testing/web-platform/tests/mathml/presentation-markup/operators/operator-dictionary-empty-and-three-chars-ref.html
delete mode 100644 testing/web-platform/tests/mathml/presentation-markup/operators/operator-dictionary-empty-and-three-chars.html
diff --git a/layout/mathml/mathfont.properties b/layout/mathml/mathfont.properties
index be4b62dafdbc..9fceebc8c22a 100644
--- a/layout/mathml/mathfont.properties
+++ b/layout/mathml/mathfont.properties
@@ -1200,7 +1200,16 @@ operator.\u0026.prefix = lspace:0 rspace:5 # &
operator.\u002B\u002B.prefix = lspace:0 rspace:2 # ++
operator.\u002D\u002D.prefix = lspace:0 rspace:2 # --
operator.\u002E\u002E.postfix = lspace:0 rspace:0 # ..
+operator.\u002E\u002E\u002E.postfix = lspace:0 rspace:0 # ...
operator.\u003B.postfix = lspace:0 rspace:0 separator # ;
+operator.\u003C\u20D2.infix = lspace:5 rspace:5 # <⃒
+operator.\u003E\u20D2.infix = lspace:5 rspace:5 # >⃒
+operator.\u006C\u0069\u006D.prefix = lspace:0 rspace:3 movablelimits # lim
+operator.\u006D\u0061\u0078.prefix = lspace:0 rspace:3 movablelimits # max
+operator.\u006D\u0069\u006E.prefix = lspace:0 rspace:3 movablelimits # min
+operator.\u007C\u007C\u007C.infix = lspace:2 rspace:2 stretchy fence symmetric direction:vertical # multiple character operator: |||
+operator.\u007C\u007C\u007C.postfix = lspace:0 rspace:0 stretchy fence symmetric direction:vertical # multiple character operator: |||
+operator.\u007C\u007C\u007C.prefix = lspace:0 rspace:0 stretchy fence symmetric direction:vertical # multiple character operator: |||
operator.\u007E.infix = lspace:2 rspace:2 stretchy direction:horizontal # ~
operator.\u0332.postfix = lspace:0 rspace:0 stretchy accent direction:horizontal # _
operator.\u03F6.infix = lspace:5 rspace:5 # greek reversed lunate epsilon symbol
@@ -1226,7 +1235,20 @@ operator.\u2234.infix = lspace:5 rspace:5 # ∴
operator.\u2235.infix = lspace:5 rspace:5 # ∵
operator.\u223D\u0331.infix = lspace:3 rspace:3 # reversed tilde with underline
operator.\u223F.infix = lspace:3 rspace:3 # sine wave
+operator.\u2242\u0338.infix = lspace:5 rspace:5 # ≂̸
+operator.\u224E\u0338.infix = lspace:5 rspace:5 # ≎̸
+operator.\u224F\u0338.infix = lspace:5 rspace:5 # ≏̸
+operator.\u2266\u0338.infix = lspace:5 rspace:5 # ≧̸
+operator.\u226A\u0338.infix = lspace:5 rspace:5 # ≪̸
+operator.\u226B\u0338.infix = lspace:5 rspace:5 # ≫̸
+operator.\u227F\u0338.infix = lspace:5 rspace:5 # ≿̸
+operator.\u2282\u020D2.infix = lspace:5 rspace:5 # ⊂⃒
+operator.\u2282\u20D2.infix = lspace:5 rspace:5 # subset of with vertical line
+operator.\u2283\u020D2.infix = lspace:5 rspace:5 # ⊃⃒
+operator.\u2283\u20D2.infix = lspace:5 rspace:5 # superset of with vertical line
operator.\u228E.prefix = lspace:1 rspace:2 largeop movablelimits symmetric direction:vertical # ⊎
+operator.\u228F\u0338.infix = lspace:5 rspace:5 # ⊏̸
+operator.\u2290\u0338.infix = lspace:5 rspace:5 # ⊐̸
operator.\u2295.prefix = lspace:0 rspace:3 largeop movablelimits symmetric direction:vertical # ⊕
operator.\u2296.prefix = lspace:0 rspace:3 largeop movablelimits symmetric direction:vertical # ⊖
operator.\u2297.prefix = lspace:0 rspace:3 largeop movablelimits symmetric direction:vertical # ⊗
@@ -1328,6 +1350,8 @@ operator.\u29CA.infix = lspace:3 rspace:3 # triangle with dot above
operator.\u29CB.infix = lspace:3 rspace:3 # triangle with underbar
operator.\u29CC.infix = lspace:3 rspace:3 # s in triangle
operator.\u29CD.infix = lspace:3 rspace:3 # triangle with serifs at bottom
+operator.\u29CF\u0338.infix = lspace:5 rspace:5 # ⧏̸
+operator.\u29D0\u0338.infix = lspace:5 rspace:5 # ⧐̸
operator.\u29D8.infix = lspace:3 rspace:3 # left wiggly fence
operator.\u29D9.infix = lspace:3 rspace:3 # right wiggly fence
operator.\u29DB.infix = lspace:3 rspace:3 # right double wiggly fence
@@ -1350,6 +1374,15 @@ operator.\u29F2.infix = lspace:3 rspace:3 # error-barred white circle
operator.\u29F3.infix = lspace:3 rspace:3 # error-barred black circle
operator.\u29FE.infix = lspace:4 rspace:4 # tiny
operator.\u29FF.infix = lspace:4 rspace:4 # miny
+operator.\u2A7D\u0338.infix = lspace:5 rspace:5 # ⩽̸
+operator.\u2A7E\u0338.infix = lspace:5 rspace:5 # ⩾̸
+operator.\u2AA1\u0338.infix = lspace:5 rspace:5 # ⪡̸
+operator.\u2AA2\u0338.infix = lspace:5 rspace:5 # ⪢̸
+operator.\u2AAF\u0338.infix = lspace:5 rspace:5 # ⪯̸
+operator.\u2AB0\u0338.infix = lspace:5 rspace:5 # ⪰̸
+operator.\u2AC5\u0338.infix = lspace:5 rspace:5 # ⫅̸
+operator.\u2AC6\u0338.infix = lspace:5 rspace:5 # ⫅̸
+operator.\u2ADD\u0338.infix = lspace:5 rspace:5 # nonforking with slash
operator.\u2AEC.infix = lspace:5 rspace:5 # double stroke not sign
operator.\u2AED.infix = lspace:5 rspace:5 # reversed double stroke not sign
operator.\u2AEF.infix = lspace:5 rspace:5 # vertical line with circle above
diff --git a/layout/mathml/nsMathMLOperators.cpp b/layout/mathml/nsMathMLOperators.cpp
index c02cccfffc05..5dd7e444490f 100644
--- a/layout/mathml/nsMathMLOperators.cpp
+++ b/layout/mathml/nsMathMLOperators.cpp
@@ -309,7 +309,7 @@ static OperatorData* GetOperatorData(const nsString& aOperator,
return gOperatorTable->Get(key);
}
-bool nsMathMLOperators::LookupOperator(const nsString& aOperator,
+void nsMathMLOperators::LookupOperator(const nsString& aOperator,
const uint8_t aForm,
nsOperatorFlags* aFlags,
float* aLeadingSpace,
@@ -317,59 +317,70 @@ bool nsMathMLOperators::LookupOperator(const nsString& aOperator,
NS_ASSERTION(aFlags && aLeadingSpace && aTrailingSpace, "bad usage");
NS_ASSERTION(aForm > 0 && aForm < 4, "*** invalid call ***");
- // Operator strings must be of length 1 or 2 in UTF-16.
- // https://w3c.github.io/mathml-core/#dfn-algorithm-to-determine-the-category-of-an-operator
- if (aOperator.IsEmpty() || aOperator.Length() > 2) {
- return false;
- }
-
- // Ignore the combining "negation" suffix for 2-character strings.
- // https://w3c.github.io/mathml-core/#dfn-algorithm-to-determine-the-category-of-an-operator
- if (aOperator.Length() == 2 &&
- (aOperator[1] == 0x0338 || aOperator[1] == 0x20D2)) {
- nsAutoString newOperator;
- newOperator.Append(aOperator[0]);
- return LookupOperator(newOperator, aForm, aFlags, aLeadingSpace,
- aTrailingSpace);
- }
-
if (!gGlobalsInitialized) {
InitOperatorGlobals();
}
if (gOperatorTable) {
- if (OperatorData* data = GetOperatorData(aOperator, aForm)) {
- NS_ASSERTION(data->mStr.Equals(aOperator), "bad setup");
- *aFlags = data->mFlags;
- *aLeadingSpace = data->mLeadingSpace;
- *aTrailingSpace = data->mTrailingSpace;
- return true;
+ // The MathML REC says:
+ // If the operator does not occur in the dictionary with the specified form,
+ // the renderer should use one of the forms which is available there, in the
+ // order of preference: infix, postfix, prefix.
+
+ OperatorData* found;
+ if (!(found = GetOperatorData(aOperator, aForm))) {
+ for (const auto& form :
+ {NS_MATHML_OPERATOR_FORM_INFIX, NS_MATHML_OPERATOR_FORM_POSTFIX,
+ NS_MATHML_OPERATOR_FORM_PREFIX}) {
+ if (form == aForm) {
+ // This form was tried above, skip it.
+ continue;
+ }
+ if ((found = GetOperatorData(aOperator, form))) {
+ break;
+ }
+ }
+ }
+ if (found) {
+ NS_ASSERTION(found->mStr.Equals(aOperator), "bad setup");
+ *aLeadingSpace = found->mLeadingSpace;
+ *aTrailingSpace = found->mTrailingSpace;
+ *aFlags &= ~NS_MATHML_OPERATOR_FORM; // clear the form bits
+ *aFlags |= found->mFlags; // just add bits without overwriting
}
}
-
- return false;
}
-bool nsMathMLOperators::LookupOperatorWithFallback(const nsString& aOperator,
- const uint8_t aForm,
- nsOperatorFlags* aFlags,
- float* aLeadingSpace,
- float* aTrailingSpace) {
- if (LookupOperator(aOperator, aForm, aFlags, aLeadingSpace, aTrailingSpace)) {
- return true;
+void nsMathMLOperators::LookupOperators(const nsString& aOperator,
+ nsOperatorFlags* aFlags,
+ float* aLeadingSpace,
+ float* aTrailingSpace) {
+ if (!gGlobalsInitialized) {
+ InitOperatorGlobals();
}
- for (const auto& form :
- {NS_MATHML_OPERATOR_FORM_INFIX, NS_MATHML_OPERATOR_FORM_POSTFIX,
- NS_MATHML_OPERATOR_FORM_PREFIX}) {
- if (form == aForm) {
- // This form was tried above, skip it.
- continue;
- }
- if (LookupOperator(aOperator, form, aFlags, aLeadingSpace,
- aTrailingSpace)) {
- return true;
+
+ aFlags[NS_MATHML_OPERATOR_FORM_INFIX] = 0;
+ aLeadingSpace[NS_MATHML_OPERATOR_FORM_INFIX] = 0.0f;
+ aTrailingSpace[NS_MATHML_OPERATOR_FORM_INFIX] = 0.0f;
+
+ aFlags[NS_MATHML_OPERATOR_FORM_POSTFIX] = 0;
+ aLeadingSpace[NS_MATHML_OPERATOR_FORM_POSTFIX] = 0.0f;
+ aTrailingSpace[NS_MATHML_OPERATOR_FORM_POSTFIX] = 0.0f;
+
+ aFlags[NS_MATHML_OPERATOR_FORM_PREFIX] = 0;
+ aLeadingSpace[NS_MATHML_OPERATOR_FORM_PREFIX] = 0.0f;
+ aTrailingSpace[NS_MATHML_OPERATOR_FORM_PREFIX] = 0.0f;
+
+ if (gOperatorTable) {
+ for (const auto& form :
+ {NS_MATHML_OPERATOR_FORM_INFIX, NS_MATHML_OPERATOR_FORM_POSTFIX,
+ NS_MATHML_OPERATOR_FORM_PREFIX}) {
+ if (OperatorData* found = GetOperatorData(aOperator, form)) {
+ aFlags[form] = found->mFlags;
+ aLeadingSpace[form] = found->mLeadingSpace;
+ aTrailingSpace[form] = found->mTrailingSpace;
+ }
}
}
- return false;
}
/* static */
@@ -392,22 +403,19 @@ bool nsMathMLOperators::IsIntegralOperator(const nsString& aOperator) {
/* static */
nsStretchDirection nsMathMLOperators::GetStretchyDirection(
const nsString& aOperator) {
- // Search any entry for that operator and return the corresponding direction.
- // It is assumed that all the forms have same direction.
- for (const auto& form :
- {NS_MATHML_OPERATOR_FORM_INFIX, NS_MATHML_OPERATOR_FORM_POSTFIX,
- NS_MATHML_OPERATOR_FORM_PREFIX}) {
- nsOperatorFlags flags;
- float dummy;
- if (nsMathMLOperators::LookupOperator(aOperator, form, &flags, &dummy,
- &dummy)) {
- if (NS_MATHML_OPERATOR_IS_DIRECTION_VERTICAL(flags)) {
- return NS_STRETCH_DIRECTION_VERTICAL;
- }
- if (NS_MATHML_OPERATOR_IS_DIRECTION_HORIZONTAL(flags)) {
- return NS_STRETCH_DIRECTION_HORIZONTAL;
- }
- }
+ // LookupOperator will search infix, postfix and prefix forms of aOperator and
+ // return the first form found. It is assumed that all these forms have same
+ // direction.
+ nsOperatorFlags flags = 0;
+ float dummy;
+ nsMathMLOperators::LookupOperator(aOperator, NS_MATHML_OPERATOR_FORM_INFIX,
+ &flags, &dummy, &dummy);
+
+ if (NS_MATHML_OPERATOR_IS_DIRECTION_VERTICAL(flags)) {
+ return NS_STRETCH_DIRECTION_VERTICAL;
+ } else if (NS_MATHML_OPERATOR_IS_DIRECTION_HORIZONTAL(flags)) {
+ return NS_STRETCH_DIRECTION_HORIZONTAL;
+ } else {
+ return NS_STRETCH_DIRECTION_UNSUPPORTED;
}
- return NS_STRETCH_DIRECTION_UNSUPPORTED;
}
diff --git a/layout/mathml/nsMathMLOperators.h b/layout/mathml/nsMathMLOperators.h
index 2fca9360dc22..4fc1f50e299e 100644
--- a/layout/mathml/nsMathMLOperators.h
+++ b/layout/mathml/nsMathMLOperators.h
@@ -66,21 +66,24 @@ class nsMathMLOperators {
// LookupOperator:
// Given the string value of an operator and its form (last two bits of
// flags), this method returns attributes of the operator in the output
- // parameters. The return value indicates whether an entry was found.
- static bool LookupOperator(const nsString& aOperator, const uint8_t aForm,
+ // parameters. If the operator is not found under the supplied form, then the
+ // other forms are tried in the following order: infix, postfix, prefix. The
+ // caller can test the output parameter aFlags to know exactly under which
+ // form the operator was found in the Operator Dictionary.
+ static void LookupOperator(const nsString& aOperator, const uint8_t aForm,
nsOperatorFlags* aFlags, float* aLeadingSpace,
float* aTrailingSpace);
- // LookupOperatorWithFallback:
- // Same as LookupOperator but if the operator is not found under the supplied
- // form, then the other forms are tried in the following order: infix, postfix
- // prefix. The caller can test the output parameter aFlags to know exactly
- // under which form the operator was found in the Operator Dictionary.
- static bool LookupOperatorWithFallback(const nsString& aOperator,
- const uint8_t aForm,
- nsOperatorFlags* aFlags,
- float* aLeadingSpace,
- float* aTrailingSpace);
+ // LookupOperators:
+ // Helper to return all the forms under which an operator is listed in the
+ // Operator Dictionary. The caller must pass arrays of size 4, and use
+ // aFlags[NS_MATHML_OPERATOR_FORM_{INFIX|POSTFIX|PREFIX}],
+ // aLeadingSpace[], etc, to access the attributes of the operator under a
+ // particular form. If the operator wasn't found under a form, its entry
+ // aFlags[form] is set to zero.
+ static void LookupOperators(const nsString& aOperator,
+ nsOperatorFlags* aFlags, float* aLeadingSpace,
+ float* aTrailingSpace);
// Helper functions used by the nsMathMLChar class.
static bool IsMirrorableOperator(const nsString& aOperator);
diff --git a/layout/mathml/nsMathMLmoFrame.cpp b/layout/mathml/nsMathMLmoFrame.cpp
index 4455016f11b4..792c77973005 100644
--- a/layout/mathml/nsMathMLmoFrame.cpp
+++ b/layout/mathml/nsMathMLmoFrame.cpp
@@ -131,16 +131,12 @@ void nsMathMLmoFrame::ProcessTextData() {
// lookup all the forms under which the operator is listed in the dictionary,
// and record whether the operator has accent="true" or movablelimits="true"
- nsOperatorFlags allFlags = 0;
- for (const auto& form :
- {NS_MATHML_OPERATOR_FORM_INFIX, NS_MATHML_OPERATOR_FORM_POSTFIX,
- NS_MATHML_OPERATOR_FORM_PREFIX}) {
- nsOperatorFlags flags = 0;
- float dummy;
- if (nsMathMLOperators::LookupOperator(data, form, &flags, &dummy, &dummy)) {
- allFlags |= flags;
- }
- }
+ nsOperatorFlags flags[4];
+ float lspace[4], rspace[4];
+ nsMathMLOperators::LookupOperators(data, flags, lspace, rspace);
+ nsOperatorFlags allFlags = flags[NS_MATHML_OPERATOR_FORM_INFIX] |
+ flags[NS_MATHML_OPERATOR_FORM_POSTFIX] |
+ flags[NS_MATHML_OPERATOR_FORM_PREFIX];
mFlags |= allFlags & NS_MATHML_OPERATOR_ACCENT;
mFlags |= allFlags & NS_MATHML_OPERATOR_MOVABLELIMITS;
@@ -331,13 +327,7 @@ void nsMathMLmoFrame::ProcessOperatorData() {
// lookup the operator dictionary
nsAutoString data;
mMathMLChar.GetData(data);
- nsOperatorFlags flags = 0;
- if (nsMathMLOperators::LookupOperatorWithFallback(data, form, &flags,
- &lspace, &rspace)) {
- mFlags &= ~NS_MATHML_OPERATOR_FORM; // clear the form bits
- mFlags |= flags; // just add bits without overwriting
- }
-
+ nsMathMLOperators::LookupOperator(data, form, &mFlags, &lspace, &rspace);
// Spacing is zero if our outermost embellished operator is not in an
// inferred mrow.
if (!NS_MATHML_OPERATOR_EMBELLISH_IS_ISOLATED(mFlags) &&
diff --git a/layout/mathml/updateOperatorDictionary.pl b/layout/mathml/updateOperatorDictionary.pl
index d9b8c3f6011f..f81a279b4887 100755
--- a/layout/mathml/updateOperatorDictionary.pl
+++ b/layout/mathml/updateOperatorDictionary.pl
@@ -134,19 +134,6 @@ if ($ARGV[0] eq "check") {
@moz_keys = (keys %moz_hash);
# check the validity of our private data
while ($key = pop(@moz_keys)) {
-
- if ($key =~ /\\u.+\\u.+\\u.+/) {
- $valid = 0;
- $nb_errors++;
- print $file_syntax_errors "error: \"$key\" has more than 2 characters\n";
- }
-
- if ($key =~ /\\u20D2\./ || $key =~ /\\u0338\./) {
- $valid = 0;
- $nb_errors++;
- print $file_syntax_errors "error: \"$key\" ends with character U+20D2 or U+0338\n";
- }
-
@moz = @{ $moz_hash{$key} };
$entry = &generateEntry($key, @moz);
$valid = 1;
diff --git a/testing/web-platform/tests/mathml/presentation-markup/operators/operator-dictionary-combining.html b/testing/web-platform/tests/mathml/presentation-markup/operators/operator-dictionary-combining.html
index 8c891a2a25f5..2b4177bb06cd 100644
--- a/testing/web-platform/tests/mathml/presentation-markup/operators/operator-dictionary-combining.html
+++ b/testing/web-platform/tests/mathml/presentation-markup/operators/operator-dictionary-combining.html
@@ -33,12 +33,7 @@
var epsilon = 1;
var emToPx = 25;
- [
- "equal",
- "vertical_bar",
- "left_normal_factor_semidirect_product",
- "there_exists",
- ].forEach(id => {
+ ["equal", "vertical_bar"].forEach(id => {
var div = document.getElementById(id);
var ref = div.getElementsByClassName("reference")[0];
var totalSpaceRef = spaceBetween(ref, 0, 2);
@@ -109,51 +104,5 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-