tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 2a7cdc4e8e9cb6110be94ff7652b23487a3e8410
parent b7a31d0c386f7164a14147801a97d46c3db4d3b4
Author: Frédéric Wang <fwang@igalia.com>
Date:   Mon, 13 Oct 2025 09:05:43 +0000

Bug 1993884 - Remove MathML centered_operators preference. r=emilio,layout-reviewers

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

Diffstat:
Mlayout/mathml/nsMathMLOperators.h | 4----
Mlayout/mathml/nsMathMLmoFrame.cpp | 37+++++++++----------------------------
Mmodules/libpref/init/StaticPrefList.yaml | 7-------
Dtesting/web-platform/mozilla/meta/mathml/fonts/opentype-axis-height.html.ini | 5-----
Dtesting/web-platform/mozilla/tests/mathml/fonts/opentype-axis-height.html | 51---------------------------------------------------
5 files changed, 9 insertions(+), 95 deletions(-)

diff --git a/layout/mathml/nsMathMLOperators.h b/layout/mathml/nsMathMLOperators.h @@ -25,7 +25,6 @@ enum nsOperatorFlagEnum : nsOperatorFlags { NS_MATHML_OPERATOR_MUTABLE = 1 << 30, NS_MATHML_OPERATOR_EMBELLISH_ANCESTOR = 1 << 29, NS_MATHML_OPERATOR_EMBELLISH_ISOLATED = 1 << 28, - NS_MATHML_OPERATOR_CENTERED = 1 << 27, NS_MATHML_OPERATOR_INVISIBLE = 1 << 26, // define the bits used in the Operator Dictionary @@ -114,9 +113,6 @@ class nsMathMLOperators { (NS_MATHML_OPERATOR_EMBELLISH_ISOLATED == \ ((_flags) & NS_MATHML_OPERATOR_EMBELLISH_ISOLATED)) -#define NS_MATHML_OPERATOR_IS_CENTERED(_flags) \ - (NS_MATHML_OPERATOR_CENTERED == ((_flags) & NS_MATHML_OPERATOR_CENTERED)) - #define NS_MATHML_OPERATOR_IS_INVISIBLE(_flags) \ (NS_MATHML_OPERATOR_INVISIBLE == ((_flags) & NS_MATHML_OPERATOR_INVISIBLE)) diff --git a/layout/mathml/nsMathMLmoFrame.cpp b/layout/mathml/nsMathMLmoFrame.cpp @@ -124,7 +124,7 @@ void nsMathMLmoFrame::ProcessTextData() { mFlags |= NS_MATHML_OPERATOR_FORCE_MATHML_CHAR; } - // cache the special bits: mutable, accent, movablelimits, centered. + // cache the special bits: mutable, accent, movablelimits. // we need to do this in anticipation of other requirements, and these // bits don't change. Do not reset these bits unless the text gets changed. @@ -144,21 +144,6 @@ void nsMathMLmoFrame::ProcessTextData() { mFlags |= allFlags & NS_MATHML_OPERATOR_ACCENT; mFlags |= allFlags & NS_MATHML_OPERATOR_MOVABLELIMITS; - if (!StaticPrefs::mathml_centered_operators_disabled()) { - // see if this is an operator that should be centered to cater for - // fonts that are not math-aware - if (1 == length) { - if ((ch == '+') || (ch == '=') || (ch == '*') || - (ch == 0x2212) || // &minus; - (ch == 0x2264) || // &le; - (ch == 0x2265) || // &ge; - (ch == 0x00D7)) { // &times; - mFlags |= NS_MATHML_OPERATOR_CENTERED; - mFlags |= NS_MATHML_OPERATOR_FORCE_MATHML_CHAR; - } - } - } - // cache the operator mMathMLChar.SetData(data); @@ -197,8 +182,8 @@ void nsMathMLmoFrame::ProcessOperatorData() { // it mutable irrespective of the form of the embellished container. // Also remember the other special bits that we want to carry forward. mFlags &= NS_MATHML_OPERATOR_MUTABLE | NS_MATHML_OPERATOR_ACCENT | - NS_MATHML_OPERATOR_MOVABLELIMITS | NS_MATHML_OPERATOR_CENTERED | - NS_MATHML_OPERATOR_INVISIBLE | NS_MATHML_OPERATOR_FORCE_MATHML_CHAR; + NS_MATHML_OPERATOR_MOVABLELIMITS | NS_MATHML_OPERATOR_INVISIBLE | + NS_MATHML_OPERATOR_FORCE_MATHML_CHAR; if (!mEmbellishData.coreFrame) { // i.e., we haven't been here before, the default form is infix @@ -620,8 +605,7 @@ nsMathMLmoFrame::Stretch(DrawTarget* aDrawTarget, return NSToCoordRound(0.2f * (float)em); }(); - // Operators that are stretchy, or those that are to be centered - // to cater for fonts that are not math-aware, are handled by the MathMLChar + // Operators that are stretchy are handled by the MathMLChar // ('form' is reset if stretch fails -- i.e., we don't bother to stretch next // time) bool useMathMLChar = UseMathMLChar(); @@ -764,22 +748,19 @@ nsMathMLmoFrame::Stretch(DrawTarget* aDrawTarget, // if the returned direction is 'unsupported', the char didn't actually // change. So we do the centering only if necessary - if (mMathMLChar.GetStretchDirection() != NS_STRETCH_DIRECTION_UNSUPPORTED || - NS_MATHML_OPERATOR_IS_CENTERED(mFlags)) { + if (mMathMLChar.GetStretchDirection() != NS_STRETCH_DIRECTION_UNSUPPORTED) { bool largeopOnly = (NS_STRETCH_LARGEOP & stretchHint) != 0 && (NS_STRETCH_VARIABLE_MASK & stretchHint) == 0; - if (isVertical || NS_MATHML_OPERATOR_IS_CENTERED(mFlags)) { + if (isVertical) { // the desired size returned by mMathMLChar maybe different // from the size of the container. // the mMathMLChar.mRect.y calculation is subtle, watch out!!! height = mBoundingMetrics.ascent + mBoundingMetrics.descent; - if (NS_MATHML_OPERATOR_IS_SYMMETRIC(mFlags) || - NS_MATHML_OPERATOR_IS_CENTERED(mFlags)) { - // For symmetric and vertical operators, or for operators that are - // always centered ('+', '*', etc) we want to center about the axis of - // the container + if (NS_MATHML_OPERATOR_IS_SYMMETRIC(mFlags)) { + // For symmetric and vertical operators, we want to center about the + // axis of the container mBoundingMetrics.descent = height / 2 - axisHeight; } else if (!largeopOnly) { // Align the center of the char with the center of the container diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml @@ -11149,13 +11149,6 @@ mirror: always rust: true -# Whether to disable forced centering of binary operators (+, =, ...). -- name: mathml.centered_operators.disabled - type: bool - value: true - mirror: always - rust: true - # Whether to disable extra top/bottom spacing for stretchy operators. - name: mathml.top_bottom_spacing_for_stretchy_operators.disabled type: bool diff --git a/testing/web-platform/mozilla/meta/mathml/fonts/opentype-axis-height.html.ini b/testing/web-platform/mozilla/meta/mathml/fonts/opentype-axis-height.html.ini @@ -1,5 +0,0 @@ -# This test verifies that the AxisHeight parameter is used to adjust vertical -# positions of NS_MATHML_OPERATOR_CENTERED operators. It should be removed once -# the code for this legacy behavior is completely deleted. -[opentype-axis-height.html] - prefs: [mathml.centered_operators.disabled: false] diff --git a/testing/web-platform/mozilla/tests/mathml/fonts/opentype-axis-height.html b/testing/web-platform/mozilla/tests/mathml/fonts/opentype-axis-height.html @@ -1,51 +0,0 @@ -<!doctype html> -<html> - <head> - <title>Open Type MATH - axis-height</title> - <script src="/resources/testharness.js"></script> - <script src="/resources/testharnessreport.js"></script> - <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=961365"/> - <meta charset="utf-8"/> - <style type="text/css"> - math { - font-size: 10px; - } - @font-face { - font-family: axis-height-1; - src: url(axis-height-1.otf); - } - @font-face { - font-family: axis-height-2; - src: url(axis-height-2.otf); - } - </style> - <script type="application/javascript"> - setup({explicit_done : true}); - - var epsilon = 5; - - function getBox(aId) { - return document.getElementById(aId).getBoundingClientRect(); - } - - function doTest() { - test(function() { - assert_approx_equals(getBox("plus1").top - getBox("plus2").top, 10 * 20, epsilon); - }, "AxisHeight"); - done(); - } - </script> - </head> - <body onload="doTest()"> - - <p> - <math style="font-family: axis-height-1;"> - <mo id="plus1">+</mo> - </math> - <math style="font-family: axis-height-2;"> - <mo id="plus2">+</mo> - </math> - </p> - - </body> -</html>