style: Rename -moz-math-script-level to math-depth.

This renames the internal -moz-math-script-level property in order to
prepare for full math-depth support. Currently, the property is guarded
under a disabled-by-default flag, so there should be no observable
behavior change.

Differential Revision: https://phabricator.services.mozilla.com/D91285
This commit is contained in:
Frederic Wang 2020-09-26 03:04:56 +00:00 committed by Emilio Cobos Álvarez
parent 4a625be8ad
commit 4dfcf583cf
8 changed files with 27 additions and 26 deletions

View file

@ -811,20 +811,20 @@ impl ToComputedValue for specified::MozScriptMinSize {
}
}
/// The computed value of the -moz-script-level property.
pub type MozScriptLevel = i8;
/// The computed value of the math-depth property.
pub type MathDepth = i8;
#[cfg(feature = "gecko")]
impl ToComputedValue for specified::MozScriptLevel {
type ComputedValue = MozScriptLevel;
impl ToComputedValue for specified::MathDepth {
type ComputedValue = MathDepth;
fn to_computed_value(&self, cx: &Context) -> i8 {
use crate::properties::longhands::math_style::SpecifiedValue as MathStyleValue;
use std::{cmp, i8};
let int = match *self {
specified::MozScriptLevel::Auto => {
let parent = cx.builder.get_parent_font().clone__moz_script_level() as i32;
specified::MathDepth::Auto => {
let parent = cx.builder.get_parent_font().clone_math_depth() as i32;
let style = cx.builder.get_parent_font().clone_math_style();
if style == MathStyleValue::Compact {
parent + 1
@ -832,17 +832,17 @@ impl ToComputedValue for specified::MozScriptLevel {
parent
}
},
specified::MozScriptLevel::Relative(rel) => {
let parent = cx.builder.get_parent_font().clone__moz_script_level();
specified::MathDepth::Relative(rel) => {
let parent = cx.builder.get_parent_font().clone_math_depth();
parent as i32 + rel
},
specified::MozScriptLevel::MozAbsolute(abs) => abs,
specified::MathDepth::MozAbsolute(abs) => abs,
};
cmp::min(int, i8::MAX as i32) as i8
}
fn from_computed_value(other: &i8) -> Self {
specified::MozScriptLevel::MozAbsolute(*other as i32)
specified::MathDepth::MozAbsolute(*other as i32)
}
}

View file

@ -59,7 +59,7 @@ pub use self::font::{FontFeatureSettings, FontVariantLigatures, FontVariantNumer
pub use self::font::{FontSize, FontSizeAdjust, FontStretch, FontSynthesis};
pub use self::font::{FontVariantAlternates, FontWeight};
pub use self::font::{FontVariantEastAsian, FontVariationSettings};
pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XLang, XTextZoom};
pub use self::font::{MathDepth, MozScriptMinSize, MozScriptSizeMultiplier, XLang, XTextZoom};
pub use self::image::{Gradient, Image, LineDirection, MozImageRect};
pub use self::length::{CSSPixelLength, ExtremumLength, NonNegativeLength};
pub use self::length::{Length, LengthOrNumber, LengthPercentage, NonNegativeLengthOrNumber};

View file

@ -2311,7 +2311,7 @@ impl Parse for MozScriptMinSize {
///
/// The main effect of scriptlevel is to control the font size.
/// https://www.w3.org/TR/MathML3/chapter3.html#presm.scriptlevel
pub enum MozScriptLevel {
pub enum MathDepth {
/// Change `font-size` relatively.
Relative(i32),
/// Change `font-size` absolutely.
@ -2325,17 +2325,17 @@ pub enum MozScriptLevel {
Auto,
}
impl Parse for MozScriptLevel {
impl Parse for MathDepth {
fn parse<'i, 't>(
_: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<MozScriptLevel, ParseError<'i>> {
) -> Result<MathDepth, ParseError<'i>> {
// We don't bother to handle calc here.
if let Ok(i) = input.try_parse(|i| i.expect_integer()) {
return Ok(MozScriptLevel::Relative(i));
return Ok(MathDepth::Relative(i));
}
input.expect_ident_matching("auto")?;
Ok(MozScriptLevel::Auto)
Ok(MathDepth::Auto)
}
}

View file

@ -53,7 +53,7 @@ pub use self::font::{FontFeatureSettings, FontVariantLigatures, FontVariantNumer
pub use self::font::{FontSize, FontSizeAdjust, FontSizeKeyword, FontStretch, FontSynthesis};
pub use self::font::{FontVariantAlternates, FontWeight};
pub use self::font::{FontVariantEastAsian, FontVariationSettings};
pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XLang, XTextZoom};
pub use self::font::{MathDepth, MozScriptMinSize, MozScriptSizeMultiplier, XLang, XTextZoom};
pub use self::image::{EndingShape as GradientEndingShape, Gradient};
pub use self::image::{Image, MozImageRect};
pub use self::length::{AbsoluteLength, CalcLengthPercentage, CharacterWidth};