diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 69feaa2f1e5..5aabb5c5367 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -3302,9 +3302,13 @@ impl ComputedValues { pub fn computed_value_to_string(&self, property: PropertyDeclarationId) -> String { match property { PropertyDeclarationId::Longhand(id) => { + let context = resolved::Context { + style: self, + }; let mut s = String::new(); - self.get_resolved_value( + self.computed_or_resolved_value( id, + Some(&context), &mut s ).unwrap(); s diff --git a/components/style/values/computed/text.rs b/components/style/values/computed/text.rs index ba395c1c366..951626d536c 100644 --- a/components/style/values/computed/text.rs +++ b/components/style/values/computed/text.rs @@ -119,12 +119,20 @@ impl ToResolvedValue for LineHeight { fn to_resolved_value(self, context: &ResolvedContext) -> Self::ResolvedValue { // Resolve to an absolute based on font size. - if matches!(self, Self::Normal | Self::MozBlockHeight) { - return self; + #[cfg(feature = "gecko")] { + if matches!(self, Self::Normal | Self::MozBlockHeight) { + return self; + } + let wm = context.style.writing_mode; + let vertical = wm.is_vertical() && !wm.is_sideways(); + return Self::Length(context.device.calc_line_height(&self, vertical, context.style.get_font(), Some(context.element_info.element))); + } + 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 } - let wm = context.style.writing_mode; - let vertical = wm.is_vertical() && !wm.is_sideways(); - Self::Length(context.device.calc_line_height(&self, vertical, context.style.get_font(), Some(context.element_info.element))) } #[inline] diff --git a/components/style/values/resolved/mod.rs b/components/style/values/resolved/mod.rs index 4bd4be22d2a..49fb222d459 100644 --- a/components/style/values/resolved/mod.rs +++ b/components/style/values/resolved/mod.rs @@ -5,6 +5,7 @@ //! Resolved values. These are almost always computed values, but in some cases //! there are used values. +#[cfg(feature = "gecko")] use crate::media_queries::Device; use crate::properties::ComputedValues; use crate::ArcSlice; @@ -18,9 +19,9 @@ mod counters; use crate::values::computed; /// Element-specific information needed to resolve property values. +#[cfg(feature = "gecko")] pub struct ResolvedElementInfo<'a> { /// Element we're resolving line-height against. - #[cfg(feature = "gecko")] pub element: crate::gecko::wrapper::GeckoElement<'a>, } @@ -30,8 +31,10 @@ pub struct Context<'a> { pub style: &'a ComputedValues, /// The device / document we're resolving style for. Useful to do font metrics stuff needed for /// line-height. + #[cfg(feature = "gecko")] pub device: &'a Device, /// The element-specific information to resolve the value. + #[cfg(feature = "gecko")] pub element_info: ResolvedElementInfo<'a>, }