diff options
-rw-r--r-- | components/style/values/computed/length.rs | 38 | ||||
-rw-r--r-- | components/style/values/specified/calc.rs | 7 |
2 files changed, 27 insertions, 18 deletions
diff --git a/components/style/values/computed/length.rs b/components/style/values/computed/length.rs index 7b3a92bbe51..a0a92c713c2 100644 --- a/components/style/values/computed/length.rs +++ b/components/style/values/computed/length.rs @@ -92,15 +92,12 @@ impl CalcLengthOrPercentage { /// Returns a new `CalcLengthOrPercentage` with a specific clamping mode. #[inline] - pub fn with_clamping_mode(length: Length, - percentage: Option<Percentage>, - clamping_mode: AllowedNumericType) - -> Self { - Self { - clamping_mode: clamping_mode, - length: length, - percentage: percentage, - } + pub fn with_clamping_mode( + length: Length, + percentage: Option<Percentage>, + clamping_mode: AllowedNumericType, + ) -> Self { + Self { clamping_mode, length, percentage, } } /// Returns this `calc()` as a `<length>`. @@ -136,8 +133,9 @@ impl CalcLengthOrPercentage { self.to_pixel_length(container_len).map(Au::from) } - /// If there are special rules for computing percentages in a value (e.g. the height property), - /// they apply whenever a calc() expression contains percentages. + /// If there are special rules for computing percentages in a value (e.g. + /// the height property), they apply whenever a calc() expression contains + /// percentages. pub fn to_pixel_length(&self, container_len: Option<Au>) -> Option<Length> { match (container_len, self.percentage) { (Some(len), Some(percent)) => { @@ -226,9 +224,15 @@ impl ToCss for CalcLengthOrPercentage { impl specified::CalcLengthOrPercentage { /// Compute the value, zooming any absolute units by the zoom function. - fn to_computed_value_with_zoom<F>(&self, context: &Context, zoom_fn: F, - base_size: FontBaseSize) -> CalcLengthOrPercentage - where F: Fn(Length) -> Length { + fn to_computed_value_with_zoom<F>( + &self, + context: &Context, + zoom_fn: F, + base_size: FontBaseSize, + ) -> CalcLengthOrPercentage + where + F: Fn(Length) -> Length, + { use std::f32; let mut length = 0.; @@ -263,7 +267,11 @@ impl specified::CalcLengthOrPercentage { } /// Compute font-size or line-height taking into account text-zoom if necessary. - pub fn to_computed_value_zoomed(&self, context: &Context, base_size: FontBaseSize) -> CalcLengthOrPercentage { + pub fn to_computed_value_zoomed( + &self, + context: &Context, + base_size: FontBaseSize, + ) -> CalcLengthOrPercentage { self.to_computed_value_with_zoom(context, |abs| context.maybe_zoom_text(abs.into()).0, base_size) } diff --git a/components/style/values/specified/calc.rs b/components/style/values/specified/calc.rs index 9b9a78db5e4..4b70f800018 100644 --- a/components/style/values/specified/calc.rs +++ b/components/style/values/specified/calc.rs @@ -64,9 +64,10 @@ pub enum CalcUnit { /// A struct to hold a simplified `<length>` or `<percentage>` expression. /// -/// In some cases, e.g. DOMMatrix, we support calc(), but reject all the relative lengths, and -/// to_computed_pixel_length_without_context() handles this case. Therefore, if you want to add a -/// new field, please make sure this function work properly. +/// In some cases, e.g. DOMMatrix, we support calc(), but reject all the +/// relative lengths, and to_computed_pixel_length_without_context() handles +/// this case. Therefore, if you want to add a new field, please make sure this +/// function work properly. #[derive(Clone, Copy, Debug, Default, MallocSizeOf, PartialEq)] #[allow(missing_docs)] pub struct CalcLengthOrPercentage { |