Bug 1500260 - Fix various tidy issues and Servo build. r=emilio
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 19 Oct 2018 00:46:28 +0200
changeset 490350 9b412ade97d9c655a7599a5ea1cc95b9179c63a4
parent 490349 4fb710869a7746539cbaae952ec26af4286ceb2d
child 490351 b7142afba71297a36d86eb651a795b33223c2fb6
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersemilio
bugs1500260
milestone64.0a1
Bug 1500260 - Fix various tidy issues and Servo build. r=emilio
servo/components/style/gecko/arc_types.rs
servo/components/style/gecko/url.rs
servo/components/style/gecko/values.rs
servo/components/style/properties/longhands/border.mako.rs
servo/components/style/servo/url.rs
servo/components/style/stylesheets/supports_rule.rs
servo/components/style/values/computed/angle.rs
servo/components/style/values/computed/length.rs
servo/components/style/values/specified/angle.rs
servo/components/style/values/specified/length.rs
servo/tests/unit/style/properties/serialization.rs
--- a/servo/components/style/gecko/arc_types.rs
+++ b/servo/components/style/gecko/arc_types.rs
@@ -18,22 +18,22 @@ use gecko_bindings::bindings::RawServoMe
 use gecko_bindings::bindings::RawServoMozDocumentRule;
 use gecko_bindings::bindings::RawServoNamespaceRule;
 use gecko_bindings::bindings::RawServoPageRule;
 use gecko_bindings::bindings::RawServoRuleNode;
 use gecko_bindings::bindings::RawServoRuleNodeStrong;
 use gecko_bindings::bindings::RawServoSupportsRule;
 use gecko_bindings::bindings::ServoCssRules;
 use gecko_bindings::structs::RawServoAnimationValue;
+use gecko_bindings::structs::RawServoCssUrlData;
 use gecko_bindings::structs::RawServoDeclarationBlock;
 use gecko_bindings::structs::RawServoFontFaceRule;
 use gecko_bindings::structs::RawServoMediaList;
 use gecko_bindings::structs::RawServoStyleRule;
 use gecko_bindings::structs::RawServoStyleSheetContents;
-use gecko_bindings::structs::RawServoCssUrlData;
 use gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI, Strong};
 use media_queries::MediaList;
 use properties::{ComputedValues, PropertyDeclarationBlock};
 use properties::animated_properties::AnimationValue;
 use rule_tree::StrongRuleNode;
 use servo_arc::{Arc, ArcBorrow};
 use shared_lock::Locked;
 use std::{mem, ptr};
--- a/servo/components/style/gecko/url.rs
+++ b/servo/components/style/gecko/url.rs
@@ -1,19 +1,19 @@
 /* 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 http://mozilla.org/MPL/2.0/. */
 
 //! Common handling for the specified value CSS url() values.
 
 use cssparser::Parser;
 use gecko_bindings::bindings;
-use gecko_bindings::structs::root::nsStyleImageRequest;
 use gecko_bindings::structs::root::mozilla::CORSMode;
 use gecko_bindings::structs::root::mozilla::css::URLValue;
+use gecko_bindings::structs::root::nsStyleImageRequest;
 use gecko_bindings::sugar::ownership::{HasArcFFI, FFIArcHelpers};
 use gecko_bindings::sugar::refptr::RefPtr;
 use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
 use nsstring::nsCString;
 use parser::{Parse, ParserContext};
 use servo_arc::Arc;
 use std::fmt::{self, Write};
 use style_traits::{CssWriter, ParseError, ToCss};
@@ -230,17 +230,17 @@ impl ToComputedValue for SpecifiedImageU
     fn from_computed_value(computed: &Self::ComputedValue) -> Self {
         computed.0.clone()
     }
 }
 
 fn serialize_computed_url<W>(
     url_value: &URLValue,
     dest: &mut CssWriter<W>,
-    get_url: unsafe extern "C" fn(*const URLValue, *mut nsCString) -> (),
+    get_url: unsafe extern "C" fn(*const URLValue, *mut nsCString),
 ) -> fmt::Result
 where
     W: Write,
 {
     dest.write_str("url(")?;
     unsafe {
         let mut string = nsCString::new();
         get_url(url_value, &mut string);
--- a/servo/components/style/gecko/values.rs
+++ b/servo/components/style/gecko/values.rs
@@ -22,19 +22,19 @@ use values::computed::{LengthOrPercentag
 use values::computed::{MaxLength as ComputedMaxLength, MozLength as ComputedMozLength, Percentage};
 use values::computed::{NonNegativeLength, NonNegativeLengthOrPercentage, NonNegativeNumber};
 use values::computed::FlexBasis as ComputedFlexBasis;
 use values::computed::basic_shape::ShapeRadius as ComputedShapeRadius;
 use values::generics::{CounterStyleOrNone, NonNegative};
 use values::generics::basic_shape::ShapeRadius;
 use values::generics::box_::Perspective;
 use values::generics::flex::FlexBasis;
-use values::generics::length::{MaxLength, MozLength};
 use values::generics::gecko::ScrollSnapPoint;
 use values::generics::grid::{TrackBreadth, TrackKeyword};
+use values::generics::length::{MaxLength, MozLength};
 
 /// A trait that defines an interface to convert from and to `nsStyleCoord`s.
 pub trait GeckoStyleCoordConvertible: Sized {
     /// Convert this to a `nsStyleCoord`.
     fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T);
     /// Given a `nsStyleCoord`, try to get a value of this type..
     fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self>;
 }
--- a/servo/components/style/properties/longhands/border.mako.rs
+++ b/servo/components/style/properties/longhands/border.mako.rs
@@ -106,16 +106,17 @@
     "border-image-source",
     "ImageLayer",
     initial_value="Either::First(None_)",
     initial_specified_value="Either::First(None_)",
     spec="https://drafts.csswg.org/css-backgrounds/#the-background-image",
     vector=False,
     animation_value_type="discrete",
     flags="APPLIES_TO_FIRST_LETTER",
+    boxed=product == "servo",
 )}
 
 ${helpers.predefined_type(
     "border-image-outset",
     "LengthOrNumberRect",
     parse_method="parse_non_negative",
     initial_value="computed::LengthOrNumberRect::all(computed::LengthOrNumber::zero())",
     initial_specified_value="specified::LengthOrNumberRect::all(specified::LengthOrNumber::zero())",
--- a/servo/components/style/servo/url.rs
+++ b/servo/components/style/servo/url.rs
@@ -18,16 +18,19 @@ use values::computed::{Context, ToComput
 /// A CSS url() value for servo.
 ///
 /// Servo eagerly resolves SpecifiedUrls, which it can then take advantage of
 /// when computing values. In contrast, Gecko uses a different URL backend, so
 /// eagerly resolving with rust-url would be duplicated work.
 ///
 /// However, this approach is still not necessarily optimal: See
 /// <https://bugzilla.mozilla.org/show_bug.cgi?id=1347435#c6>
+///
+/// TODO(emilio): This should be shrunk by making CssUrl a wrapper type of an
+/// arc, and keep the serialization in that Arc. See gecko/url.rs for example.
 #[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize, SpecifiedValueInfo)]
 pub struct CssUrl {
     /// The original URI. This might be optional since we may insert computed
     /// values of images into the cascade directly, and we don't bother to
     /// convert their serialization.
     ///
     /// Refcounted since cloning this should be cheap and data: uris can be
     /// really large.
--- a/servo/components/style/stylesheets/supports_rule.rs
+++ b/servo/components/style/stylesheets/supports_rule.rs
@@ -6,19 +6,18 @@
 
 use cssparser::{Delimiter, Parser, SourceLocation, Token};
 use cssparser::{ParseError as CssParseError, ParserInput};
 use cssparser::parse_important;
 #[cfg(feature = "gecko")]
 use malloc_size_of::{MallocSizeOfOps, MallocUnconditionalShallowSizeOf};
 use parser::ParserContext;
 use properties::{PropertyDeclaration, PropertyId, SourcePropertyDeclaration};
-use selectors::parser::SelectorParseErrorKind;
 use selector_parser::{SelectorImpl, SelectorParser};
-use selectors::parser::Selector;
+use selectors::parser::{Selector, SelectorParseErrorKind};
 use servo_arc::Arc;
 use shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked};
 use shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
 use std::ffi::{CStr, CString};
 use std::fmt::{self, Write};
 use std::str;
 use str::CssStringWriter;
 use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
@@ -345,23 +344,24 @@ impl RawSelector {
         let mut input = Parser::new(&mut input);
         input.parse_entirely(|input| -> Result<(), CssParseError<()>> {
             let parser = SelectorParser {
                 namespaces,
                 stylesheet_origin: context.stylesheet_origin,
                 url_data: Some(context.url_data),
             };
 
+            #[allow(unused_variables)]
             let selector = Selector::<SelectorImpl>::parse(&parser, input)
                 .map_err(|_| input.new_custom_error(()))?;
 
             #[cfg(feature = "gecko")]
             {
+                use selector_parser::PseudoElement;
                 use selectors::parser::Component;
-                use selector_parser::PseudoElement;
 
                 let has_any_unknown_webkit_pseudo =
                     selector.has_pseudo_element() &&
                     selector.iter_raw_match_order().any(|component| {
                         matches!(
                             *component,
                             Component::PseudoElement(PseudoElement::UnknownWebkit(..))
                         )
--- a/servo/components/style/values/computed/angle.rs
+++ b/servo/components/style/values/computed/angle.rs
@@ -1,18 +1,18 @@
 /* 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 http://mozilla.org/MPL/2.0/. */
 
 //! Computed angles.
 
 use num_traits::Zero;
-use std::fmt::{self, Write};
 use std::{f32, f64};
 use std::f64::consts::PI;
+use std::fmt::{self, Write};
 use std::ops::Add;
 use style_traits::{CssWriter, ToCss};
 use values::CSSFloat;
 use values::distance::{ComputeSquaredDistance, SquaredDistance};
 
 /// A computed angle in degrees.
 #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
 #[derive(Animate, Clone, Copy, Debug, MallocSizeOf, PartialEq, PartialOrd, ToAnimatedZero)]
--- a/servo/components/style/values/computed/length.rs
+++ b/servo/components/style/values/computed/length.rs
@@ -9,18 +9,18 @@ use ordered_float::NotNan;
 use std::fmt::{self, Write};
 use std::ops::{Add, Neg};
 use style_traits::{CssWriter, ToCss};
 use style_traits::values::specified::AllowedNumericType;
 use super::{Context, Number, Percentage, ToComputedValue};
 use values::{specified, Auto, CSSFloat, Either, Normal};
 use values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero};
 use values::distance::{ComputeSquaredDistance, SquaredDistance};
+use values::generics::NonNegative;
 use values::generics::length::{MaxLength as GenericMaxLength, MozLength as GenericMozLength};
-use values::generics::NonNegative;
 use values::specified::length::{AbsoluteLength, FontBaseSize, FontRelativeLength};
 use values::specified::length::ViewportPercentageLength;
 
 pub use super::image::Image;
 pub use values::specified::url::UrlOrNone;
 pub use values::specified::{Angle, BorderStyle, Time};
 
 impl ToComputedValue for specified::NoCalcLength {
--- a/servo/components/style/values/specified/angle.rs
+++ b/servo/components/style/values/specified/angle.rs
@@ -1,25 +1,26 @@
 /* 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 http://mozilla.org/MPL/2.0/. */
 
 //! Specified angles.
 
 use cssparser::{Parser, Token};
 use parser::{Parse, ParserContext};
+use std::f32::consts::PI;
 use std::fmt::{self, Write};
-use std::f32::consts::PI;
 use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, ToCss};
 use values::CSSFloat;
 use values::computed::{Context, ToComputedValue};
 use values::computed::angle::Angle as ComputedAngle;
 use values::specified::calc::CalcNode;
 
 /// A specified angle dimension.
+#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
 #[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, PartialOrd, ToCss)]
 pub enum AngleDimension {
     /// An angle with degree unit.
     #[css(dimension)]
     Deg(CSSFloat),
     /// An angle with gradian unit.
     #[css(dimension)]
     Grad(CSSFloat),
--- a/servo/components/style/values/specified/length.rs
+++ b/servo/components/style/values/specified/length.rs
@@ -13,18 +13,18 @@ use font_metrics::FontMetricsQueryResult
 use parser::{Parse, ParserContext};
 use std::cmp;
 use std::ops::{Add, Mul};
 use style_traits::{ParseError, SpecifiedValueInfo, StyleParseErrorKind};
 use style_traits::values::specified::AllowedNumericType;
 use super::{AllowQuirks, Number, Percentage, ToComputedValue};
 use values::{Auto, CSSFloat, Either, Normal};
 use values::computed::{self, CSSPixelLength, Context, ExtremumLength};
+use values::generics::NonNegative;
 use values::generics::length::{MaxLength as GenericMaxLength, MozLength as GenericMozLength};
-use values::generics::NonNegative;
 use values::specified::calc::CalcNode;
 
 pub use values::specified::calc::CalcLengthOrPercentage;
 pub use super::image::{ColorStop, EndingShape as GradientEndingShape, Gradient};
 pub use super::image::{GradientKind, Image};
 
 /// Number of app units per pixel
 pub const AU_PER_PX: CSSFloat = 60.;
--- a/servo/tests/unit/style/properties/serialization.rs
+++ b/servo/tests/unit/style/properties/serialization.rs
@@ -606,70 +606,16 @@ mod shorthand_serialization {
                 background-position-x: center;\
                 background-position-y: 20px;";
             let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
             let serialization = block.to_css_string();
             assert_eq!(serialization, "background-position: center 20px;");
         }
     }
 
-    mod transform {
-        pub use super::*;
-        use style::values::generics::transform::TransformOperation;
-        use style::values::specified::{Angle, Number};
-        use style::values::specified::transform::TransformOperation as SpecifiedOperation;
-
-        #[test]
-        fn should_serialize_none_correctly() {
-            use style::properties::longhands::transform;
-
-            assert_roundtrip_with_context!(transform::parse, "none");
-        }
-
-        #[inline(always)]
-        fn validate_serialization(op: &SpecifiedOperation, expected_string: &'static str) {
-            let css_string = op.to_css_string();
-            assert_eq!(css_string, expected_string);
-        }
-
-        #[test]
-        fn transform_scale() {
-            validate_serialization(&TransformOperation::Scale(Number::new(1.3), None), "scale(1.3)");
-            validate_serialization(
-                &TransformOperation::Scale(Number::new(2.0), Some(Number::new(2.0))),
-                "scale(2, 2)");
-            validate_serialization(&TransformOperation::ScaleX(Number::new(42.0)), "scaleX(42)");
-            validate_serialization(&TransformOperation::ScaleY(Number::new(0.3)), "scaleY(0.3)");
-            validate_serialization(&TransformOperation::ScaleZ(Number::new(1.0)), "scaleZ(1)");
-            validate_serialization(
-                &TransformOperation::Scale3D(Number::new(4.0), Number::new(5.0), Number::new(6.0)),
-                "scale3d(4, 5, 6)");
-        }
-
-        #[test]
-        fn transform_skew() {
-            validate_serialization(
-                &TransformOperation::Skew(Angle::from_degrees(42.3, false), None),
-                "skew(42.3deg)");
-            validate_serialization(
-                &TransformOperation::Skew(Angle::from_gradians(-50.0, false), Some(Angle::from_turns(0.73, false))),
-                "skew(-50grad, 0.73turn)");
-            validate_serialization(
-                &TransformOperation::SkewX(Angle::from_radians(0.31, false)), "skewX(0.31rad)");
-        }
-
-        #[test]
-        fn transform_rotate() {
-            validate_serialization(
-                &TransformOperation::Rotate(Angle::from_turns(35.0, false)),
-                "rotate(35turn)"
-            )
-        }
-    }
-
     mod quotes {
         pub use super::*;
 
         #[test]
         fn should_serialize_none_correctly() {
             use style::properties::longhands::quotes;
 
             assert_roundtrip_with_context!(quotes::parse, "none");