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

@ -963,7 +963,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
fn handle_mathml_scriptlevel_if_needed(&mut self) { fn handle_mathml_scriptlevel_if_needed(&mut self) {
use crate::values::generics::NonNegative; use crate::values::generics::NonNegative;
if !self.seen.contains(LonghandId::MozScriptLevel) && if !self.seen.contains(LonghandId::MathDepth) &&
!self.seen.contains(LonghandId::MozScriptMinSize) && !self.seen.contains(LonghandId::MozScriptMinSize) &&
!self.seen.contains(LonghandId::MozScriptSizeMultiplier) { !self.seen.contains(LonghandId::MozScriptSizeMultiplier) {
return; return;
@ -980,7 +980,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
let parent_font = builder.get_parent_font().gecko(); let parent_font = builder.get_parent_font().gecko();
let delta = let delta =
font.mScriptLevel.saturating_sub(parent_font.mScriptLevel); font.mMathDepth.saturating_sub(parent_font.mMathDepth);
if delta == 0 { if delta == 0 {
return; return;

View file

@ -360,7 +360,7 @@ class Longhand(object):
"MasonryAutoFlow", "MasonryAutoFlow",
"MozForceBrokenImageIcon", "MozForceBrokenImageIcon",
"MozListReversed", "MozListReversed",
"MozScriptLevel", "MathDepth",
"MozScriptMinSize", "MozScriptMinSize",
"MozScriptSizeMultiplier", "MozScriptSizeMultiplier",
"TextDecorationSkipInk", "TextDecorationSkipInk",

View file

@ -228,14 +228,15 @@ ${helpers.predefined_type(
)} )}
${helpers.predefined_type( ${helpers.predefined_type(
"-moz-script-level", "math-depth",
"MozScriptLevel", "MathDepth",
"0", "0",
engines="gecko", engines="gecko",
gecko_pref="layout.css.math-depth.enabled",
has_effect_on_gecko_scrollbars=False,
animation_value_type="none", animation_value_type="none",
enabled_in="ua", enabled_in="ua",
gecko_ffi_name="mScriptLevel", spec="https://mathml-refresh.github.io/mathml-core/#the-math-script-level-property",
spec="Internal (not web-exposed)",
)} )}
${helpers.single_keyword( ${helpers.single_keyword(

View file

@ -1342,8 +1342,8 @@ impl LonghandId {
// preferences properly, see bug 1165538. // preferences properly, see bug 1165538.
LonghandId::MozMinFontSizeRatio | LonghandId::MozMinFontSizeRatio |
// Needed to do font-size for MathML. :( // font-size depends on math-depth's computed value.
LonghandId::MozScriptLevel | LonghandId::MathDepth |
% endif % endif
// Needed to compute the first available font, in order to // Needed to compute the first available font, in order to

View file

@ -811,20 +811,20 @@ impl ToComputedValue for specified::MozScriptMinSize {
} }
} }
/// The computed value of the -moz-script-level property. /// The computed value of the math-depth property.
pub type MozScriptLevel = i8; pub type MathDepth = i8;
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
impl ToComputedValue for specified::MozScriptLevel { impl ToComputedValue for specified::MathDepth {
type ComputedValue = MozScriptLevel; type ComputedValue = MathDepth;
fn to_computed_value(&self, cx: &Context) -> i8 { fn to_computed_value(&self, cx: &Context) -> i8 {
use crate::properties::longhands::math_style::SpecifiedValue as MathStyleValue; use crate::properties::longhands::math_style::SpecifiedValue as MathStyleValue;
use std::{cmp, i8}; use std::{cmp, i8};
let int = match *self { let int = match *self {
specified::MozScriptLevel::Auto => { specified::MathDepth::Auto => {
let parent = cx.builder.get_parent_font().clone__moz_script_level() as i32; let parent = cx.builder.get_parent_font().clone_math_depth() as i32;
let style = cx.builder.get_parent_font().clone_math_style(); let style = cx.builder.get_parent_font().clone_math_style();
if style == MathStyleValue::Compact { if style == MathStyleValue::Compact {
parent + 1 parent + 1
@ -832,17 +832,17 @@ impl ToComputedValue for specified::MozScriptLevel {
parent parent
} }
}, },
specified::MozScriptLevel::Relative(rel) => { specified::MathDepth::Relative(rel) => {
let parent = cx.builder.get_parent_font().clone__moz_script_level(); let parent = cx.builder.get_parent_font().clone_math_depth();
parent as i32 + rel parent as i32 + rel
}, },
specified::MozScriptLevel::MozAbsolute(abs) => abs, specified::MathDepth::MozAbsolute(abs) => abs,
}; };
cmp::min(int, i8::MAX as i32) as i8 cmp::min(int, i8::MAX as i32) as i8
} }
fn from_computed_value(other: &i8) -> Self { 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::{FontSize, FontSizeAdjust, FontStretch, FontSynthesis};
pub use self::font::{FontVariantAlternates, FontWeight}; pub use self::font::{FontVariantAlternates, FontWeight};
pub use self::font::{FontVariantEastAsian, FontVariationSettings}; 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::image::{Gradient, Image, LineDirection, MozImageRect};
pub use self::length::{CSSPixelLength, ExtremumLength, NonNegativeLength}; pub use self::length::{CSSPixelLength, ExtremumLength, NonNegativeLength};
pub use self::length::{Length, LengthOrNumber, LengthPercentage, NonNegativeLengthOrNumber}; 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. /// The main effect of scriptlevel is to control the font size.
/// https://www.w3.org/TR/MathML3/chapter3.html#presm.scriptlevel /// https://www.w3.org/TR/MathML3/chapter3.html#presm.scriptlevel
pub enum MozScriptLevel { pub enum MathDepth {
/// Change `font-size` relatively. /// Change `font-size` relatively.
Relative(i32), Relative(i32),
/// Change `font-size` absolutely. /// Change `font-size` absolutely.
@ -2325,17 +2325,17 @@ pub enum MozScriptLevel {
Auto, Auto,
} }
impl Parse for MozScriptLevel { impl Parse for MathDepth {
fn parse<'i, 't>( fn parse<'i, 't>(
_: &ParserContext, _: &ParserContext,
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<MozScriptLevel, ParseError<'i>> { ) -> Result<MathDepth, ParseError<'i>> {
// We don't bother to handle calc here. // We don't bother to handle calc here.
if let Ok(i) = input.try_parse(|i| i.expect_integer()) { 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")?; 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::{FontSize, FontSizeAdjust, FontSizeKeyword, FontStretch, FontSynthesis};
pub use self::font::{FontVariantAlternates, FontWeight}; pub use self::font::{FontVariantAlternates, FontWeight};
pub use self::font::{FontVariantEastAsian, FontVariationSettings}; 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::{EndingShape as GradientEndingShape, Gradient};
pub use self::image::{Image, MozImageRect}; pub use self::image::{Image, MozImageRect};
pub use self::length::{AbsoluteLength, CalcLengthPercentage, CharacterWidth}; pub use self::length::{AbsoluteLength, CalcLengthPercentage, CharacterWidth};