Bug 1890523 - Remove extra space above/below stretchy operators. r=emilio

Gecko always adds .2em space above and below stretchy operators but this
is not part of MathML Core and is causing several WPT failures. The
MATH table does not have any parameter for that so it's likely some
tweak that was added in the early days of MathML that may no longer be
necessary. This patch tentatively removes this feature by placing it
under a disabled-by-default flag.

Tests adjustments:
- table-width-1.xhtml: adjusted to work around antialiasing issue with the
  top/bottom of stretchy operators (in the past the extra space added was
  preventing this issue). This does not affect the testing goal, which is about
  the width.
- stretchy-largeop-with-default-font-2.html: Some tests are failing depending
  on the OS config so mark them as such. In the past, the extra vertical space
  added was hiding the issue.

Differential Revision: https://phabricator.services.mozilla.com/D207014
This commit is contained in:
Frédéric Wang 2024-04-12 14:14:23 +00:00
parent be6b1a6434
commit f82f883577
10 changed files with 31 additions and 57 deletions

View file

@ -596,9 +596,15 @@ nsMathMLmoFrame::Stretch(DrawTarget* aDrawTarget,
// get the leading to be left at the top and the bottom of the stretched char
// this seems more reliable than using fm->GetLeading() on suspicious fonts
nscoord em;
GetEmHeight(fm, em);
nscoord leading = NSToCoordRound(0.2f * em);
const nscoord leading = [&fm] {
if (StaticPrefs::
mathml_top_bottom_spacing_for_stretchy_operators_disabled()) {
return 0;
}
nscoord em;
GetEmHeight(fm, em);
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

View file

@ -9557,6 +9557,13 @@
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
value: true
mirror: always
rust: true
#---------------------------------------------------------------------------
# Prefs starting with "media."
#---------------------------------------------------------------------------

View file

@ -1,17 +1,6 @@
[stretch-along-block-axis-001.html]
expected:
if (os == "android") and fission: [OK, TIMEOUT]
[Taking into account stretch axis.]
expected: FAIL
[Taking into account stretchy property.]
expected: FAIL
[Only operators with a stretchy property and block stretch axis.]
expected: FAIL
[Operators smaller and larger than non-stretchy siblings.]
expected: FAIL
[Embellished operators]
expected: FAIL

View file

@ -1,20 +1,6 @@
[mo-minsize-maxsize-001.html]
expected:
if (os == "android") and fission: [OK, TIMEOUT]
[minsize < maxsize < 0 is treated as maxsize = minsize = 0]
expected: FAIL
[minsize < 0 is treated as 0]
expected: FAIL
[target size = 0 is treated as Tascent = Tdescent = minsize/2]
expected: FAIL
[maxsize < minsize is treated as maxsize = minsize]
expected: FAIL
[minsize/maxsize percentages are relative to the target size]
expected: FAIL
[default minsize/maxsize percentages]
expected: FAIL

View file

@ -1,5 +0,0 @@
[mo-stretch-properties-001.html]
expected:
if (os == "android") and fission: [OK, TIMEOUT]
[Stretchy vertical line]
expected: FAIL

View file

@ -1,17 +0,0 @@
[mo-stretch-properties-dynamic-001.html]
expected:
if (os == "android") and fission: [OK, TIMEOUT]
[symmetric]
expected: FAIL
[largeop]
expected: FAIL
[minsize]
expected: FAIL
[maxsize]
expected: FAIL
[stretchy]
expected: FAIL

View file

@ -0,0 +1,5 @@
[stretchy-largeop-with-default-font-2.html]
[Test that non-stretchy largeops are bigger in display mode.]
expected:
if os == "android": FAIL
if os == "mac": FAIL

View file

@ -11,8 +11,8 @@
function contentOf(aElement) {
return document.getElementById(aElement).textContent;
}
function heightOf(aElement) {
return document.getElementById(aElement).getBoundingClientRect().height;
function boxOf(aElement) {
return document.getElementById(aElement).getBoundingClientRect();
}
promise_test(() => {
return new Promise(resolve => {
@ -21,7 +21,10 @@
const numTests = 10; // zero indexed
for (let i = 0; i < numTests; i++) {
const operatorName = contentOf(`mo${i}`);
assert_greater_than(heightOf(`mo${i}`), heightOf(`moRef${i}`), `size of largeop '${operatorName}'`);
const box = boxOf(`mo${i}`);
const ref = boxOf(`moRef${i}`);
assert_greater_than(box.width, ref.width, `width of largeop '${operatorName}'`);
assert_greater_than(box.height, ref.height, `height of largeop '${operatorName}'`);
}
});
}, "Test that non-stretchy largeops are bigger in display mode.");

View file

@ -3,8 +3,8 @@
<style type="text/css">
html { background-color: grey; }
td { border: 1px solid white;
padding-top: 0;
padding-bottom: 0;
padding-top: 1px;
padding-bottom: 1px;
padding-right: 1px;
padding-left: 1px;
background-color: black;

View file

@ -6,8 +6,8 @@
<style type="text/css">
html { background-color: grey; }
td { border: 1px solid white;
padding-top: 0;
padding-bottom: 0;
padding-top: 1px;
padding-bottom: 1px;
padding-right: 1px;
padding-left: 1px;
background-color: black;