diff --git a/components/style/values/generics/text.rs b/components/style/values/generics/text.rs index 7dae932faac..509491c8624 100644 --- a/components/style/values/generics/text.rs +++ b/components/style/values/generics/text.rs @@ -61,6 +61,14 @@ impl Spacing { } } +#[cfg(feature = "gecko")] +fn line_height_moz_block_height_enabled(context: &ParserContext) -> bool { + use crate::gecko_bindings::structs; + context.in_ua_sheet() || unsafe { + structs::StaticPrefs_sVarCache_layout_css_line_height_moz_block_height_content_enabled + } +} + /// A generic value for the `line-height` property. #[derive( Animate, @@ -73,6 +81,7 @@ impl Spacing { SpecifiedValueInfo, ToAnimatedValue, ToCss, + Parse, )] #[repr(C, u8)] pub enum GenericLineHeight { @@ -80,6 +89,7 @@ pub enum GenericLineHeight { Normal, /// `-moz-block-height` #[cfg(feature = "gecko")] + #[parse(condition = "line_height_moz_block_height_enabled")] MozBlockHeight, /// `` Number(N), diff --git a/components/style/values/specified/text.rs b/components/style/values/specified/text.rs index 33bda52aa9d..1c2f8499af5 100644 --- a/components/style/values/specified/text.rs +++ b/components/style/values/specified/text.rs @@ -73,33 +73,6 @@ impl Parse for WordSpacing { } } -impl Parse for LineHeight { - fn parse<'i, 't>( - context: &ParserContext, - input: &mut Parser<'i, 't>, - ) -> Result> { - if let Ok(number) = input.try(|i| NonNegativeNumber::parse(context, i)) { - return Ok(GenericLineHeight::Number(number)); - } - if let Ok(nlp) = input.try(|i| NonNegativeLengthPercentage::parse(context, i)) { - return Ok(GenericLineHeight::Length(nlp)); - } - let location = input.current_source_location(); - let ident = input.expect_ident()?; - match ident { - ref ident if ident.eq_ignore_ascii_case("normal") => Ok(GenericLineHeight::Normal), - #[cfg(feature = "gecko")] - ref ident if ident.eq_ignore_ascii_case("-moz-block-height") => { - Ok(GenericLineHeight::MozBlockHeight) - }, - ident => { - Err(location - .new_custom_error(SelectorParseErrorKind::UnexpectedIdent(ident.clone()))) - }, - } - } -} - impl ToComputedValue for LineHeight { type ComputedValue = ComputedLineHeight;