diff --git a/components/style/values/computed/text.rs b/components/style/values/computed/text.rs index ff4d87fa93e..3db55672705 100644 --- a/components/style/values/computed/text.rs +++ b/components/style/values/computed/text.rs @@ -11,6 +11,7 @@ use crate::values::computed::{Context, NonNegativeLength, NonNegativeNumber, ToC use crate::values::generics::text::InitialLetter as GenericInitialLetter; use crate::values::generics::text::LineHeight as GenericLineHeight; use crate::values::generics::text::{GenericTextDecorationLength, Spacing}; +use crate::values::resolved::{Context as ResolvedContext, ToResolvedValue}; use crate::values::specified::text::{self as specified, TextOverflowSide}; use crate::values::specified::text::{TextEmphasisFillMode, TextEmphasisShapeKeyword}; use crate::values::{CSSFloat, CSSInteger}; @@ -113,6 +114,25 @@ impl ToComputedValue for specified::WordSpacing { /// A computed value for the `line-height` property. pub type LineHeight = GenericLineHeight; +impl ToResolvedValue for LineHeight { + type ResolvedValue = Self; + + fn to_resolved_value(self, context: &ResolvedContext) -> Self::ResolvedValue { + // Resolve to an absolute based on font size. + if let LineHeight::Number(num) = &self { + let size = context.style.get_font().clone_font_size().computed_size(); + LineHeight::Length(NonNegativeLength::new(size.px() * num.0)) + } else { + self + } + } + + #[inline] + fn from_resolved_value(value: Self::ResolvedValue) -> Self { + value + } +} + impl WordSpacing { /// Return the `normal` computed value, which is just zero. #[inline] diff --git a/components/style/values/generics/text.rs b/components/style/values/generics/text.rs index 0062f304701..9b59ff0dc3f 100644 --- a/components/style/values/generics/text.rs +++ b/components/style/values/generics/text.rs @@ -92,7 +92,6 @@ fn line_height_moz_block_height_enabled(context: &ParserContext) -> bool { ToAnimatedValue, ToCss, ToShmem, - ToResolvedValue, Parse, )] #[repr(C, u8)]