Bug 1521392 - Fix servo build and rustfmt recent changes.
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sun, 20 Jan 2019 15:38:14 +0100
changeset 454623 fd43da99e9da96a448df3c0a21ed1e9e16482bcc
parent 454622 70857e6af679bed8ffcf7f4c9ae248bc26424c15
child 454624 fccd92c0fb3d0b56028fccbe8e184e96ea5e3b9e
push id35405
push userdvarga@mozilla.com
push dateSun, 20 Jan 2019 21:36:32 +0000
treeherdermozilla-central@666abafd77b1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1521392
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1521392 - Fix servo build and rustfmt recent changes.
servo/components/style/gecko/conversions.rs
servo/components/style/logical_geometry.rs
servo/components/style/values/animated/length.rs
servo/components/style/values/animated/svg.rs
servo/components/style/values/computed/length.rs
servo/components/style/values/generics/ui.rs
servo/components/style/values/specified/ui.rs
--- a/servo/components/style/gecko/conversions.rs
+++ b/servo/components/style/gecko/conversions.rs
@@ -31,19 +31,17 @@ use crate::values::generics::rect::Rect;
 use crate::values::generics::NonNegative;
 use app_units::Au;
 use std::f32::consts::PI;
 use style_traits::values::specified::AllowedNumericType;
 
 impl From<LengthPercentage> for nsStyleCoord_CalcValue {
     fn from(other: LengthPercentage) -> nsStyleCoord_CalcValue {
         debug_assert!(
-            other.was_calc ||
-                !other.has_percentage ||
-                other.unclamped_length() == Length::zero()
+            other.was_calc || !other.has_percentage || other.unclamped_length() == Length::zero()
         );
         nsStyleCoord_CalcValue {
             mLength: other.unclamped_length().to_i32_au(),
             mPercent: other.percentage(),
             mHasPercent: other.has_percentage,
         }
     }
 }
--- a/servo/components/style/logical_geometry.rs
+++ b/servo/components/style/logical_geometry.rs
@@ -167,56 +167,65 @@ impl WritingMode {
         match (self.is_vertical(), self.is_vertical_lr()) {
             (false, _) => PhysicalSide::Bottom,
             (true, true) => PhysicalSide::Right,
             (true, false) => PhysicalSide::Left,
         }
     }
 
     #[inline]
-    fn physical_sides_to_corner(block_side: PhysicalSide, inline_side: PhysicalSide) -> PhysicalCorner {
+    fn physical_sides_to_corner(
+        block_side: PhysicalSide,
+        inline_side: PhysicalSide,
+    ) -> PhysicalCorner {
         match (block_side, inline_side) {
-            (PhysicalSide::Top, PhysicalSide::Left) |
-            (PhysicalSide::Left, PhysicalSide::Top) => PhysicalCorner::TopLeft,
-            (PhysicalSide::Top, PhysicalSide::Right) |
-            (PhysicalSide::Right, PhysicalSide::Top) => PhysicalCorner::TopRight,
+            (PhysicalSide::Top, PhysicalSide::Left) | (PhysicalSide::Left, PhysicalSide::Top) => {
+                PhysicalCorner::TopLeft
+            },
+            (PhysicalSide::Top, PhysicalSide::Right) | (PhysicalSide::Right, PhysicalSide::Top) => {
+                PhysicalCorner::TopRight
+            },
             (PhysicalSide::Bottom, PhysicalSide::Right) |
             (PhysicalSide::Right, PhysicalSide::Bottom) => PhysicalCorner::BottomRight,
             (PhysicalSide::Bottom, PhysicalSide::Left) |
             (PhysicalSide::Left, PhysicalSide::Bottom) => PhysicalCorner::BottomLeft,
-            _ => unreachable!("block and inline sides must be orthogonal")
+            _ => unreachable!("block and inline sides must be orthogonal"),
         }
     }
 
     #[inline]
     pub fn start_start_physical_corner(&self) -> PhysicalCorner {
         WritingMode::physical_sides_to_corner(
             self.block_start_physical_side(),
-            self.inline_start_physical_side())
+            self.inline_start_physical_side(),
+        )
     }
 
     #[inline]
     pub fn start_end_physical_corner(&self) -> PhysicalCorner {
         WritingMode::physical_sides_to_corner(
             self.block_start_physical_side(),
-            self.inline_end_physical_side())
+            self.inline_end_physical_side(),
+        )
     }
 
     #[inline]
     pub fn end_start_physical_corner(&self) -> PhysicalCorner {
         WritingMode::physical_sides_to_corner(
             self.block_end_physical_side(),
-            self.inline_start_physical_side())
+            self.inline_start_physical_side(),
+        )
     }
 
     #[inline]
     pub fn end_end_physical_corner(&self) -> PhysicalCorner {
         WritingMode::physical_sides_to_corner(
             self.block_end_physical_side(),
-            self.inline_end_physical_side())
+            self.inline_end_physical_side(),
+        )
     }
 
     #[inline]
     pub fn block_flow_direction(&self) -> BlockFlowDirection {
         match (self.is_vertical(), self.is_vertical_lr()) {
             (false, _) => BlockFlowDirection::TopToBottom,
             (true, true) => BlockFlowDirection::LeftToRight,
             (true, false) => BlockFlowDirection::RightToLeft,
--- a/servo/components/style/values/animated/length.rs
+++ b/servo/components/style/values/animated/length.rs
@@ -21,23 +21,20 @@ impl Animate for LengthPercentage {
             let this = this.unwrap_or_default();
             let other = other.unwrap_or_default();
             Ok(Some(this.animate(&other, procedure)?))
         };
 
         let length = self
             .unclamped_length()
             .animate(&other.unclamped_length(), procedure)?;
-        let percentage = animate_percentage_half(
-            self.specified_percentage(),
-            other.specified_percentage(),
-        )?;
-        let is_calc = self.was_calc ||
-            other.was_calc ||
-            self.has_percentage != other.has_percentage;
+        let percentage =
+            animate_percentage_half(self.specified_percentage(), other.specified_percentage())?;
+        let is_calc =
+            self.was_calc || other.was_calc || self.has_percentage != other.has_percentage;
         Ok(Self::with_clamping_mode(
             length,
             percentage,
             self.clamping_mode,
             is_calc,
         ))
     }
 }
--- a/servo/components/style/values/animated/svg.rs
+++ b/servo/components/style/values/animated/svg.rs
@@ -27,26 +27,24 @@ impl ToAnimatedZero for IntermediateSVGP
 }
 
 // FIXME: We need to handle calc here properly, see
 // https://bugzilla.mozilla.org/show_bug.cgi?id=1386967
 fn to_number_or_percentage(
     value: &SvgLengthPercentageOrNumber<LengthPercentage, Number>,
 ) -> Result<NumberOrPercentage, ()> {
     Ok(match *value {
-        SvgLengthPercentageOrNumber::LengthPercentage(ref l) => {
-            match l.specified_percentage() {
-                Some(p) => {
-                    if l.unclamped_length().px() != 0. {
-                        return Err(());
-                    }
-                    NumberOrPercentage::Percentage(p)
-                },
-                None => NumberOrPercentage::Number(l.length().px()),
-            }
+        SvgLengthPercentageOrNumber::LengthPercentage(ref l) => match l.specified_percentage() {
+            Some(p) => {
+                if l.unclamped_length().px() != 0. {
+                    return Err(());
+                }
+                NumberOrPercentage::Percentage(p)
+            },
+            None => NumberOrPercentage::Number(l.length().px()),
         },
         SvgLengthPercentageOrNumber::Number(ref n) => NumberOrPercentage::Number(*n),
     })
 }
 
 impl Animate for SvgLengthPercentageOrNumber<LengthPercentage, Number> {
     #[inline]
     fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
--- a/servo/components/style/values/computed/length.rs
+++ b/servo/components/style/values/computed/length.rs
@@ -97,30 +97,32 @@ pub struct LengthPercentage {
 // representation of LengthPercentage with Gecko. The issue here is that Gecko
 // uses CalcValue to represent position components, so they always come back as
 // was_calc == true, and we mess up in the transitions code.
 //
 // This was a pre-existing bug, though arguably so only in pretty obscure cases
 // like calc(0px + 5%) and such.
 impl PartialEq for LengthPercentage {
     fn eq(&self, other: &Self) -> bool {
-        self.length == other.length && self.percentage == other.percentage &&
+        self.length == other.length &&
+            self.percentage == other.percentage &&
             self.has_percentage == other.has_percentage
     }
 }
 
 impl ComputeSquaredDistance for LengthPercentage {
     #[inline]
     fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
         // FIXME(nox): This looks incorrect to me, to add a distance between lengths
         // with a distance between percentages.
         Ok(self
             .unclamped_length()
             .compute_squared_distance(&other.unclamped_length())? +
-            self.percentage.compute_squared_distance(&other.percentage)?)
+            self.percentage
+                .compute_squared_distance(&other.percentage)?)
     }
 }
 
 impl LengthPercentage {
     /// Returns a new `LengthPercentage`.
     #[inline]
     pub fn new(length: Length, percentage: Option<Percentage>) -> Self {
         Self::with_clamping_mode(
@@ -211,17 +213,18 @@ impl LengthPercentage {
         self.maybe_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.
     pub fn maybe_to_pixel_length(&self, container_len: Option<Au>) -> Option<Length> {
         if self.has_percentage {
-            let length = self.unclamped_length().px() + container_len?.scale_by(self.percentage.0).to_f32_px();
+            let length = self.unclamped_length().px() +
+                container_len?.scale_by(self.percentage.0).to_f32_px();
             return Some(Length::new(self.clamping_mode.clamp(length)));
         }
         Some(self.length())
     }
 }
 
 impl ToCss for LengthPercentage {
     fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
@@ -426,18 +429,17 @@ impl ToComputedValue for specified::Leng
     }
 
     fn from_computed_value(computed: &LengthPercentage) -> Self {
         let length = computed.unclamped_length();
         if let Some(p) = computed.as_percentage() {
             return specified::LengthPercentage::Percentage(p);
         }
 
-        if !computed.has_percentage  &&
-            computed.clamping_mode.clamp(length.px()) == length.px() {
+        if !computed.has_percentage && computed.clamping_mode.clamp(length.px()) == length.px() {
             return specified::LengthPercentage::Length(ToComputedValue::from_computed_value(
                 &length,
             ));
         }
 
         specified::LengthPercentage::Calc(Box::new(ToComputedValue::from_computed_value(computed)))
     }
 }
--- a/servo/components/style/values/generics/ui.rs
+++ b/servo/components/style/values/generics/ui.rs
@@ -1,17 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
 
 //! Generic values for UI properties.
 
 use std::fmt::{self, Write};
+use style_traits::{CssWriter, ToCss};
 use values::specified::ui::CursorKind;
-use style_traits::{CssWriter, ToCss};
 
 /// A generic value for the `cursor` property.
 ///
 /// https://drafts.csswg.org/css-ui/#cursor
 #[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue)]
 pub struct Cursor<Image> {
     /// The parsed images for the cursor.
     pub images: Box<[Image]>,
--- a/servo/components/style/values/specified/ui.rs
+++ b/servo/components/style/values/specified/ui.rs
@@ -158,16 +158,17 @@ pub enum UserSelect {
 ///
 /// https://drafts.csswg.org/css-ui-4/#propdef-cursor
 #[allow(missing_docs)]
 #[derive(
     Clone,
     Copy,
     Debug,
     Eq,
+    FromPrimitive,
     MallocSizeOf,
     Parse,
     PartialEq,
     SpecifiedValueInfo,
     ToComputedValue,
     ToCss,
 )]
 #[repr(u8)]
@@ -203,13 +204,17 @@ pub enum CursorKind {
     NeswResize,
     NwseResize,
     ColResize,
     RowResize,
     AllScroll,
     ZoomIn,
     ZoomOut,
     Auto,
+    #[cfg(feature = "gecko")]
     MozGrab,
+    #[cfg(feature = "gecko")]
     MozGrabbing,
+    #[cfg(feature = "gecko")]
     MozZoomIn,
+    #[cfg(feature = "gecko")]
     MozZoomOut,
 }