mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1890531 - Remove automatic adjustment for "centered operators". r=emilio
The MathML code adjust vertical position of basic binary operators with the NS_MATHML_OPERATOR_CENTERED flag set (e.g. plus, equal or minus signs) so that their centers align with the math axis. This behavior is not defined in MathML Core and is not necessary in practice for math fonts (which are already designed with the desired vertical alignments). This patch tries and removes this by placing that legacy behavior under a disabled-by-default runtime flag. Intent-to-ship: https://groups.google.com/a/mozilla.org/g/dev-platform/c/nlA0t4J0gzo Differential Revision: https://phabricator.services.mozilla.com/D207026
This commit is contained in:
parent
5ae6b66c22
commit
22ec186a63
@ -8,6 +8,7 @@
|
||||
|
||||
#include "gfxContext.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/StaticPrefs_mathml.h"
|
||||
#include "nsCSSValue.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsPresContext.h"
|
||||
@ -145,15 +146,17 @@ void nsMathMLmoFrame::ProcessTextData() {
|
||||
mFlags |= allFlags & NS_MATHML_OPERATOR_ACCENT;
|
||||
mFlags |= allFlags & NS_MATHML_OPERATOR_MOVABLELIMITS;
|
||||
|
||||
// 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) || // −
|
||||
(ch == 0x2264) || // ≤
|
||||
(ch == 0x2265) || // ≥
|
||||
(ch == 0x00D7)) { // ×
|
||||
mFlags |= NS_MATHML_OPERATOR_CENTERED;
|
||||
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) || // −
|
||||
(ch == 0x2264) || // ≤
|
||||
(ch == 0x2265) || // ≥
|
||||
(ch == 0x00D7)) { // ×
|
||||
mFlags |= NS_MATHML_OPERATOR_CENTERED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9548,6 +9548,13 @@
|
||||
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
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Prefs starting with "media."
|
||||
#---------------------------------------------------------------------------
|
||||
|
@ -0,0 +1,5 @@
|
||||
# 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]
|
@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>No vertical adjustment for basic binary operators</title>
|
||||
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
|
||||
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1890531" />
|
||||
<meta name="assert" content="Verify vertical alignement of basic binary operators is not adjusted to align their centers with the math axis.">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/mathml/support/fonts.js"></script>
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: operators;
|
||||
/* AxisHeight == 0, so the math axis matches the baseline */
|
||||
src: url("/fonts/math/operators.woff");
|
||||
}
|
||||
math {
|
||||
font: 25px operators;
|
||||
}
|
||||
</style>
|
||||
<math>
|
||||
<mn id="ref">↯</mn>
|
||||
<mo>+</mo><mo>=</mo><mo>*</mo><mo>−</mo><mo>≤</mo><mo>≥</mo><mo>×</mo>
|
||||
</math>
|
||||
<script>
|
||||
promise_test(async () => {
|
||||
await new Promise(r => { window.addEventListener("DOMContentLoaded", r) });
|
||||
await loadAllFonts();
|
||||
function centerOf(element) {
|
||||
const box = element.getBoundingClientRect();
|
||||
return (box.top + box.bottom) / 2;
|
||||
}
|
||||
const ref = centerOf(document.getElementById("ref"));
|
||||
const epsilon = 1;
|
||||
Array.from(document.getElementsByTagName("mo")).forEach(mo => {
|
||||
assert_approx_equals(centerOf(mo), ref, epsilon,
|
||||
`Position of "${mo.textContent}"`);
|
||||
});
|
||||
}, "Vertical alignment of basic binary operators is not adjusted.");
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user