diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index 23749d6a8b7..986badf5bdc 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -1085,7 +1085,7 @@ impl NoCalcLength { #[inline] pub fn to_computed_pixel_length_without_context(&self) -> Result { match *self { - NoCalcLength::Absolute(len) => Ok(CSSPixelLength::new(len.to_px()).finite().px()), + Self::Absolute(len) => Ok(CSSPixelLength::new(len.to_px()).finite().px()), _ => Err(()), } } @@ -1344,6 +1344,14 @@ impl Length { pub fn from_px(px_value: CSSFloat) -> Length { Length::NoCalc(NoCalcLength::from_px(px_value)) } + + /// Get a px value without context. + pub fn to_computed_pixel_length_without_context(&self) -> Result { + match *self { + Self::NoCalc(ref l) => l.to_computed_pixel_length_without_context(), + Self::Calc(ref l) => l.to_computed_pixel_length_without_context(), + } + } } impl Parse for Length {