style: Use ScriptPercentScaleDown and ScriptScriptPercentScaleDown constants

The math-depth implementation is refined to take into account the
ScriptPercentScaleDown and ScriptScriptPercentScaleDown constants (if the
parent's first valid font has a MATH table) in order to calculate the
scale factor between math-deth 0 and 1, and between 0 and 2 respectively.

Behavior is unchanged if the legacy scriptsizemultiplier attribute is
specified or if no MATH table is available.

The preference layout.css.math-depth.enabled remains disabled in nightly
until the remaining bit (support for font-size: math) is implemented in
bug 1667090.

Differential Revision: https://phabricator.services.mozilla.com/D91604
This commit is contained in:
Frederic Wang 2022-08-30 10:16:33 +00:00 committed by Martin Robinson
parent 12a2c88605
commit f196c19106
2 changed files with 83 additions and 3 deletions

View file

@ -22,6 +22,12 @@ pub struct FontMetrics {
pub ic_width: Option<Length>,
/// The ascent of the font (a value is always available for this).
pub ascent: Length,
/// Script scale down factor for math-depth 1.
/// https://w3c.github.io/mathml-core/#dfn-scriptpercentscaledown
pub script_percent_scale_down: Option<f32>,
/// Script scale down factor for math-depth 2.
/// https://w3c.github.io/mathml-core/#dfn-scriptscriptpercentscaledown
pub script_script_percent_scale_down: Option<f32>,
}
impl Default for FontMetrics {
@ -32,6 +38,8 @@ impl Default for FontMetrics {
cap_height: None,
ic_width: None,
ascent: Length::new(0.0),
script_percent_scale_down: None,
script_script_percent_scale_down: None,
}
}
}