From 4dfcf583cf14553cb59d0a43dd35c186d1c38028 Mon Sep 17 00:00:00 2001 From: Frederic Wang Date: Sat, 26 Sep 2020 03:04:56 +0000 Subject: [PATCH] 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 --- components/style/properties/cascade.rs | 4 ++-- components/style/properties/data.py | 2 +- .../style/properties/longhands/font.mako.rs | 9 +++++---- .../style/properties/properties.mako.rs | 4 ++-- components/style/values/computed/font.rs | 20 +++++++++---------- components/style/values/computed/mod.rs | 2 +- components/style/values/specified/font.rs | 10 +++++----- components/style/values/specified/mod.rs | 2 +- 8 files changed, 27 insertions(+), 26 deletions(-) diff --git a/components/style/properties/cascade.rs b/components/style/properties/cascade.rs index e161e2690d2..0a84f7e894d 100644 --- a/components/style/properties/cascade.rs +++ b/components/style/properties/cascade.rs @@ -963,7 +963,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> { fn handle_mathml_scriptlevel_if_needed(&mut self) { 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::MozScriptSizeMultiplier) { return; @@ -980,7 +980,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> { let parent_font = builder.get_parent_font().gecko(); let delta = - font.mScriptLevel.saturating_sub(parent_font.mScriptLevel); + font.mMathDepth.saturating_sub(parent_font.mMathDepth); if delta == 0 { return; diff --git a/components/style/properties/data.py b/components/style/properties/data.py index 6f53a344602..6589627027b 100644 --- a/components/style/properties/data.py +++ b/components/style/properties/data.py @@ -360,7 +360,7 @@ class Longhand(object): "MasonryAutoFlow", "MozForceBrokenImageIcon", "MozListReversed", - "MozScriptLevel", + "MathDepth", "MozScriptMinSize", "MozScriptSizeMultiplier", "TextDecorationSkipInk", diff --git a/components/style/properties/longhands/font.mako.rs b/components/style/properties/longhands/font.mako.rs index 32c034c7508..1fb52a01c77 100644 --- a/components/style/properties/longhands/font.mako.rs +++ b/components/style/properties/longhands/font.mako.rs @@ -228,14 +228,15 @@ ${helpers.predefined_type( )} ${helpers.predefined_type( - "-moz-script-level", - "MozScriptLevel", + "math-depth", + "MathDepth", "0", engines="gecko", + gecko_pref="layout.css.math-depth.enabled", + has_effect_on_gecko_scrollbars=False, animation_value_type="none", enabled_in="ua", - gecko_ffi_name="mScriptLevel", - spec="Internal (not web-exposed)", + spec="https://mathml-refresh.github.io/mathml-core/#the-math-script-level-property", )} ${helpers.single_keyword( diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 0198d7cdb9b..1278ce9c5bb 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -1342,8 +1342,8 @@ impl LonghandId { // preferences properly, see bug 1165538. LonghandId::MozMinFontSizeRatio | - // Needed to do font-size for MathML. :( - LonghandId::MozScriptLevel | + // font-size depends on math-depth's computed value. + LonghandId::MathDepth | % endif // Needed to compute the first available font, in order to diff --git a/components/style/values/computed/font.rs b/components/style/values/computed/font.rs index de97ea03303..a04a74abf4f 100644 --- a/components/style/values/computed/font.rs +++ b/components/style/values/computed/font.rs @@ -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) } } diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index aa13ff89d7c..4d9d553bdb9 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -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}; diff --git a/components/style/values/specified/font.rs b/components/style/values/specified/font.rs index 05862f6aba7..825c05da0ce 100644 --- a/components/style/values/specified/font.rs +++ b/components/style/values/specified/font.rs @@ -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> { + ) -> Result> { // 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) } } diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 8ddca48d599..d6d763686e7 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -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};