No bug - Fix tidy issues and Servo build, and fix unit test bustage. r=me
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sun, 29 Apr 2018 03:02:21 +0200
changeset 416229 d10c828a7c3eb914687fe8bb6df31ceecc38df21
parent 416198 afbec7f03bd8ced52be05199cb45ff844e456a75
child 416230 95f8c87c1d97ae309e795c09d5aff376c695156c
push id33920
push usertoros@mozilla.com
push dateMon, 30 Apr 2018 09:50:56 +0000
treeherdermozilla-central@f01311ae4951 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
milestone61.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
No bug - Fix tidy issues and Servo build, and fix unit test bustage. r=me MozReview-Commit-ID: 7MFLnVZmZUg
servo/components/layout/display_list/builder.rs
servo/components/servo_arc/lib.rs
servo/components/style/properties/longhand/font.mako.rs
servo/components/style/servo/url.rs
servo/components/style/values/generics/image.rs
servo/components/style/values/mod.rs
servo/components/style/values/specified/box.rs
servo/components/style/values/specified/font.rs
servo/components/style_derive/specified_value_info.rs
servo/components/style_traits/Cargo.toml
servo/components/style_traits/lib.rs
servo/components/style_traits/specified_value_info.rs
servo/tests/unit/style/properties/serialization.rs
servo/tests/unit/style/rule_tree/bench.rs
--- a/servo/components/layout/display_list/builder.rs
+++ b/servo/components/layout/display_list/builder.rs
@@ -61,19 +61,19 @@ use style::computed_values::pointer_even
 use style::computed_values::position::T as StylePosition;
 use style::computed_values::visibility::T as Visibility;
 use style::logical_geometry::{LogicalMargin, LogicalPoint, LogicalRect};
 use style::properties::{ComputedValues, style_structs};
 use style::servo::restyle_damage::ServoRestyleDamage;
 use style::values::{Either, RGBA};
 use style::values::computed::Gradient;
 use style::values::computed::effects::SimpleShadow;
-use style::values::computed::pointing::Cursor;
 use style::values::generics::background::BackgroundSize;
 use style::values::generics::image::{GradientKind, Image, PaintWorklet};
+use style::values::generics::pointing::Cursor;
 use style_traits::CSSPixel;
 use style_traits::ToCss;
 use style_traits::cursor::CursorKind;
 use table_cell::CollapsedBordersForCell;
 use webrender_api::{self, BorderRadius, BorderSide, BoxShadowClipMode, ColorF, ExternalScrollId};
 use webrender_api::{FilterOp, GlyphInstance, ImageRendering, LayoutRect, LayoutSize};
 use webrender_api::{LayoutTransform, LayoutVector2D, LineStyle, NormalBorder, ScrollPolicy};
 use webrender_api::{ScrollSensitivity, StickyOffsetBounds};
@@ -2947,21 +2947,21 @@ trait ComputedValuesCursorUtility {
 impl ComputedValuesCursorUtility for ComputedValues {
     /// Gets the cursor to use given the specific ComputedValues.  `default_cursor` specifies
     /// the cursor to use if `cursor` is `auto`. Typically, this will be `PointerCursor`, but for
     /// text display items it may be `TextCursor` or `VerticalTextCursor`.
     #[inline]
     fn get_cursor(&self, default_cursor: CursorKind) -> Option<CursorKind> {
         match (
             self.get_pointing().pointer_events,
-            self.get_pointing().cursor,
+            &self.get_pointing().cursor,
         ) {
             (PointerEvents::None, _) => None,
-            (PointerEvents::Auto, Cursor(CursorKind::Auto)) => Some(default_cursor),
-            (PointerEvents::Auto, Cursor(cursor)) => Some(cursor),
+            (PointerEvents::Auto, &Cursor { keyword: CursorKind::Auto, .. }) => Some(default_cursor),
+            (PointerEvents::Auto, &Cursor { keyword, .. }) => Some(keyword),
         }
     }
 }
 
 /// Adjusts `content_rect` as necessary for the given spread, and blur so that the resulting
 /// bounding rect contains all of a shadow's ink.
 fn shadow_bounds(content_rect: &Rect<Au>, blur: Au, spread: Au) -> Rect<Au> {
     let inflation = spread + blur * BLUR_INFLATION_FACTOR;
--- a/servo/components/servo_arc/lib.rs
+++ b/servo/components/servo_arc/lib.rs
@@ -920,17 +920,17 @@ impl<T: 'static> Arc<T> {
 /// an Arc<T> instance somewhere pinned down until we're done with it.
 ///
 /// However, Gecko hands us refcounted things as pointers to T directly,
 /// so we have to conjure up a temporary Arc on the stack each time. The
 /// same happens for when the object is managed by a RawOffsetArc.
 ///
 /// ArcBorrow lets us deal with borrows of known-refcounted objects
 /// without needing to worry about how they're actually stored.
-#[derive(Eq, Debug, PartialEq)]
+#[derive(Debug, Eq, PartialEq)]
 pub struct ArcBorrow<'a, T: 'a>(&'a T);
 
 impl<'a, T> Copy for ArcBorrow<'a, T> {}
 impl<'a, T> Clone for ArcBorrow<'a, T> {
     #[inline]
     fn clone(&self) -> Self {
         *self
     }
--- a/servo/components/style/properties/longhand/font.mako.rs
+++ b/servo/components/style/properties/longhand/font.mako.rs
@@ -445,17 +445,17 @@ https://drafts.csswg.org/css-fonts-4/#lo
 % else:
     pub mod system_font {
         use cssparser::Parser;
 
         // We don't parse system fonts, but in the interest of not littering
         // a lot of code with `if product == gecko` conditionals, we have a
         // dummy system font module that does nothing
 
-        #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, ToCss)]
+        #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, SpecifiedValueInfo, ToCss)]
         #[cfg_attr(feature = "servo", derive(MallocSizeOf))]
         /// void enum for system font, can never exist
         pub enum SystemFont {}
         impl SystemFont {
             pub fn parse(_: &mut Parser) -> Result<Self, ()> {
                 Err(())
             }
         }
--- a/servo/components/style/servo/url.rs
+++ b/servo/components/style/servo/url.rs
@@ -18,17 +18,17 @@ 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>
-#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
+#[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.
     #[ignore_malloc_size_of = "Arc"]
--- a/servo/components/style/values/generics/image.rs
+++ b/servo/components/style/values/generics/image.rs
@@ -140,16 +140,18 @@ pub struct PaintWorklet {
     /// The name the worklet was registered with.
     pub name: Atom,
     /// The arguments for the worklet.
     /// TODO: store a parsed representation of the arguments.
     #[cfg_attr(feature = "servo", ignore_malloc_size_of = "Arc")]
     pub arguments: Vec<Arc<custom_properties::SpecifiedValue>>,
 }
 
+impl ::style_traits::SpecifiedValueInfo for PaintWorklet { }
+
 impl ToCss for PaintWorklet {
     fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
     where
         W: Write,
     {
         dest.write_str("paint(")?;
         serialize_atom_identifier(&self.name, dest)?;
         for argument in &self.arguments {
--- a/servo/components/style/values/mod.rs
+++ b/servo/components/style/values/mod.rs
@@ -66,17 +66,17 @@ where
     W: Write,
 {
     (value * 100.).to_css(dest)?;
     dest.write_str("%")
 }
 
 /// Convenience void type to disable some properties and values through types.
 #[cfg_attr(feature = "servo", derive(Deserialize, MallocSizeOf, Serialize))]
-#[derive(Clone, Copy, Debug, PartialEq, ToAnimatedValue, ToComputedValue, ToCss)]
+#[derive(Clone, Copy, Debug, PartialEq, SpecifiedValueInfo, ToAnimatedValue, ToComputedValue, ToCss)]
 pub enum Impossible {}
 
 // FIXME(nox): This should be derived but the derive code cannot cope
 // with uninhabited enums.
 impl ComputeSquaredDistance for Impossible {
     #[inline]
     fn compute_squared_distance(&self, _other: &Self) -> Result<SquaredDistance, ()> {
         match *self {}
@@ -157,17 +157,17 @@ impl ToCss for CustomIdent {
     where
         W: Write,
     {
         serialize_atom_identifier(&self.0, dest)
     }
 }
 
 /// <https://drafts.csswg.org/css-animations/#typedef-keyframes-name>
-#[derive(Clone, Debug, MallocSizeOf, ToComputedValue, SpecifiedValueInfo)]
+#[derive(Clone, Debug, MallocSizeOf, SpecifiedValueInfo, ToComputedValue)]
 pub enum KeyframesName {
     /// <custom-ident>
     Ident(CustomIdent),
     /// <string>
     QuotedString(Atom),
 }
 
 impl KeyframesName {
--- a/servo/components/style/values/specified/box.rs
+++ b/servo/components/style/values/specified/box.rs
@@ -517,17 +517,17 @@ pub fn assert_touch_action_matches() {
         NS_STYLE_TOUCH_ACTION_AUTO => TouchAction::TOUCH_ACTION_AUTO,
         NS_STYLE_TOUCH_ACTION_PAN_X => TouchAction::TOUCH_ACTION_PAN_X,
         NS_STYLE_TOUCH_ACTION_PAN_Y => TouchAction::TOUCH_ACTION_PAN_Y,
         NS_STYLE_TOUCH_ACTION_MANIPULATION => TouchAction::TOUCH_ACTION_MANIPULATION,
     }
 }
 
 bitflags! {
-    #[derive(MallocSizeOf, ToComputedValue, SpecifiedValueInfo)]
+    #[derive(MallocSizeOf, SpecifiedValueInfo, ToComputedValue)]
     #[value_info(other_values = "none,strict,layout,style,paint")]
     /// Constants for contain: https://drafts.csswg.org/css-contain/#contain-property
     pub struct Contain: u8 {
         /// `layout` variant, turns on layout containment
         const LAYOUT = 0x01;
         /// `style` variant, turns on style containment
         const STYLE = 0x02;
         /// `paint` variant, turns on paint containment
--- a/servo/components/style/values/specified/font.rs
+++ b/servo/components/style/values/specified/font.rs
@@ -18,18 +18,18 @@ use std::fmt::{self, Write};
 use style_traits::{CssWriter, KeywordsCollectFn, ParseError};
 use style_traits::{SpecifiedValueInfo, StyleParseErrorKind, ToCss};
 use style_traits::values::SequenceWriter;
 use values::CustomIdent;
 use values::computed::{Angle as ComputedAngle, Percentage as ComputedPercentage};
 use values::computed::{font as computed, Context, Length, NonNegativeLength, ToComputedValue};
 use values::computed::font::{FamilyName, FontFamilyList, FontStyleAngle, SingleFontFamily};
 use values::generics::NonNegative;
+use values::generics::font::{KeywordSize, VariationValue};
 use values::generics::font::{self as generics, FeatureTagValue, FontSettings, FontTag};
-use values::generics::font::{KeywordSize, VariationValue};
 use values::specified::{AllowQuirks, Angle, Integer, LengthOrPercentage, NoCalcLength, Number, Percentage};
 use values::specified::length::{FontBaseSize, AU_PER_PT, AU_PER_PX};
 
 // FIXME(emilio): The system font code is copy-pasta, and should be cleaned up.
 macro_rules! system_font_methods {
     ($ty:ident, $field:ident) => {
         system_font_methods!($ty);
 
--- a/servo/components/style_derive/specified_value_info.rs
+++ b/servo/components/style_derive/specified_value_info.rs
@@ -1,15 +1,15 @@
 /* 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/. */
 
 use cg;
 use quote::Tokens;
-use syn::{Data, DeriveInput, Fields, Ident,Type};
+use syn::{Data, DeriveInput, Fields, Ident, Type};
 use to_css::{CssFieldAttrs, CssInputAttrs, CssVariantAttrs};
 
 pub fn derive(mut input: DeriveInput) -> Tokens {
     let css_attrs = cg::parse_input_attrs::<CssInputAttrs>(&input);
     let mut types = vec![];
     let mut values = vec![];
 
     let input_ident = input.ident;
@@ -96,17 +96,17 @@ pub fn derive(mut input: DeriveInput) ->
             | ::style_traits::CssType::#ty
         });
     }
 
     let append_values = if values.is_empty() {
         quote!()
     } else {
         let mut value_list = quote!();
-        value_list.append_separated(values.iter(), quote!(,));
+        value_list.append_separated(values.iter(), quote! { , });
         quote! { _f(&[#value_list]); }
     };
 
     let name = &input.ident;
     let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();
     quote! {
         impl #impl_generics ::style_traits::SpecifiedValueInfo for #name #ty_generics
         #where_clause
--- a/servo/components/style_traits/Cargo.toml
+++ b/servo/components/style_traits/Cargo.toml
@@ -5,23 +5,24 @@ authors = ["The Servo Project Developers
 license = "MPL-2.0"
 publish = false
 
 [lib]
 name = "style_traits"
 path = "lib.rs"
 
 [features]
-servo = ["serde", "servo_atoms", "cssparser/serde", "webrender_api"]
+servo = ["serde", "servo_atoms", "cssparser/serde", "webrender_api", "servo_url"]
 gecko = []
 
 [dependencies]
 app_units = "0.6"
 cssparser = "0.23.0"
 bitflags = "1.0"
 euclid = "0.17"
 malloc_size_of = { path = "../malloc_size_of" }
 malloc_size_of_derive = { path = "../malloc_size_of_derive" }
 selectors = { path = "../selectors" }
 serde = {version = "1.0", optional = true}
 webrender_api = {git = "https://github.com/servo/webrender", optional = true}
 servo_atoms = {path = "../atoms", optional = true}
-servo_arc = {path = "../servo_arc" }
+servo_arc = { path = "../servo_arc" }
+servo_url = { path = "../url", optional = true }
--- a/servo/components/style_traits/lib.rs
+++ b/servo/components/style_traits/lib.rs
@@ -17,16 +17,17 @@ extern crate app_units;
 extern crate euclid;
 extern crate malloc_size_of;
 #[macro_use] extern crate malloc_size_of_derive;
 extern crate selectors;
 #[cfg(feature = "servo")] #[macro_use] extern crate serde;
 #[cfg(feature = "servo")] extern crate webrender_api;
 extern crate servo_arc;
 #[cfg(feature = "servo")] extern crate servo_atoms;
+#[cfg(feature = "servo")] extern crate servo_url;
 
 #[cfg(feature = "servo")] pub use webrender_api::DevicePixel;
 
 use cssparser::{CowRcStr, Token};
 use selectors::parser::SelectorParseErrorKind;
 #[cfg(feature = "servo")] use servo_atoms::Atom;
 
 /// One hardware pixel.
--- a/servo/components/style_traits/specified_value_info.rs
+++ b/servo/components/style_traits/specified_value_info.rs
@@ -1,16 +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 http://mozilla.org/MPL/2.0/. */
 
 //! Value information for devtools.
 
 use servo_arc::Arc;
 use std::ops::Range;
+use std::sync::Arc as StdArc;
 
 /// Type of value that a property supports. This is used by Gecko's
 /// devtools to make sense about value it parses, and types listed
 /// here should match TYPE_* constants in InspectorUtils.webidl.
 ///
 /// XXX This should really be a bitflags rather than a namespace mod,
 /// but currently we cannot use bitflags in const.
 #[allow(non_snake_case)]
@@ -79,16 +80,21 @@ impl SpecifiedValueInfo for f32 {}
 impl SpecifiedValueInfo for i8 {}
 impl SpecifiedValueInfo for i32 {}
 impl SpecifiedValueInfo for u8 {}
 impl SpecifiedValueInfo for u16 {}
 impl SpecifiedValueInfo for u32 {}
 impl SpecifiedValueInfo for str {}
 impl SpecifiedValueInfo for String {}
 
+#[cfg(feature = "servo")]
+impl SpecifiedValueInfo for ::servo_atoms::Atom {}
+#[cfg(feature = "servo")]
+impl SpecifiedValueInfo for ::servo_url::ServoUrl {}
+
 impl<T: SpecifiedValueInfo + ?Sized> SpecifiedValueInfo for Box<T> {
     const SUPPORTED_TYPES: u8 = T::SUPPORTED_TYPES;
     fn collect_completion_keywords(f: KeywordsCollectFn) {
         T::collect_completion_keywords(f);
     }
 }
 
 impl<T: SpecifiedValueInfo> SpecifiedValueInfo for [T] {
@@ -106,16 +112,17 @@ macro_rules! impl_generic_specified_valu
                 $param::collect_completion_keywords(f);
             }
         }
     }
 }
 impl_generic_specified_value_info!(Option<T>);
 impl_generic_specified_value_info!(Vec<T>);
 impl_generic_specified_value_info!(Arc<T>);
+impl_generic_specified_value_info!(StdArc<T>);
 impl_generic_specified_value_info!(Range<Idx>);
 
 impl<T1, T2> SpecifiedValueInfo for (T1, T2)
 where
     T1: SpecifiedValueInfo,
     T2: SpecifiedValueInfo,
 {
     const SUPPORTED_TYPES: u8 = T1::SUPPORTED_TYPES | T2::SUPPORTED_TYPES;
--- a/servo/tests/unit/style/properties/serialization.rs
+++ b/servo/tests/unit/style/properties/serialization.rs
@@ -515,52 +515,16 @@ mod shorthand_serialization {
 
             properties.push(PropertyDeclaration::ListStyleType(style_type));
 
             let serialization = shorthand_properties_to_string(properties);
             assert_eq!(serialization, "list-style: inside url(\"http://servo/test.png\") disc;");
         }
     }
 
-    mod outline {
-        use style::values::specified::outline::OutlineStyle;
-        use super::*;
-
-        #[test]
-        fn outline_should_show_all_properties_when_set() {
-            let mut properties = Vec::new();
-
-            let width = BorderSideWidth::Length(Length::from_px(4f32));
-            let style = OutlineStyle::Other(BorderStyle::Solid);
-            let color = RGBA::new(255, 0, 0, 255).into();
-
-            properties.push(PropertyDeclaration::OutlineWidth(width));
-            properties.push(PropertyDeclaration::OutlineStyle(style));
-            properties.push(PropertyDeclaration::OutlineColor(color));
-
-            let serialization = shorthand_properties_to_string(properties);
-            assert_eq!(serialization, "outline: 4px solid rgb(255, 0, 0);");
-        }
-
-        #[test]
-        fn outline_should_serialize_correctly_when_style_is_auto() {
-            let mut properties = Vec::new();
-
-            let width = BorderSideWidth::Length(Length::from_px(4f32));
-            let style = OutlineStyle::Auto;
-            let color = RGBA::new(255, 0, 0, 255).into();
-            properties.push(PropertyDeclaration::OutlineWidth(width));
-            properties.push(PropertyDeclaration::OutlineStyle(style));
-            properties.push(PropertyDeclaration::OutlineColor(color));
-
-            let serialization = shorthand_properties_to_string(properties);
-            assert_eq!(serialization, "outline: 4px auto rgb(255, 0, 0);");
-        }
-    }
-
     mod background {
         use super::*;
 
         #[test]
         fn background_should_serialize_all_available_properties_when_specified() {
             let block_text = "\
                 background-color: rgb(255, 0, 0); \
                 background-image: url(\"http://servo/test.png\"); \
--- a/servo/tests/unit/style/rule_tree/bench.rs
+++ b/servo/tests/unit/style/rule_tree/bench.rs
@@ -57,33 +57,34 @@ fn parse_rules(css: &str) -> Vec<(StyleS
                                  None,
                                  &ErrorringErrorReporter,
                                  QuirksMode::NoQuirks,
                                  0);
     let guard = s.shared_lock.read();
     let rules = s.contents.rules.read_with(&guard);
     rules.0.iter().filter_map(|rule| {
         match *rule {
-            CssRule::Style(ref style_rule) => Some(style_rule),
+            CssRule::Style(ref style_rule) => Some((
+                StyleSource::from_rule(style_rule.clone()),
+                CascadeLevel::UserNormal,
+            )),
             _ => None,
         }
-    }).cloned().map(StyleSource::Style).map(|s| {
-        (s, CascadeLevel::UserNormal)
     }).collect()
 }
 
 fn test_insertion(rule_tree: &RuleTree, rules: Vec<(StyleSource, CascadeLevel)>) -> StrongRuleNode {
     rule_tree.insert_ordered_rules(rules.into_iter())
 }
 
 fn test_insertion_style_attribute(rule_tree: &RuleTree, rules: &[(StyleSource, CascadeLevel)],
                                   shared_lock: &SharedRwLock)
                                   -> StrongRuleNode {
     let mut rules = rules.to_vec();
-    rules.push((StyleSource::Declarations(Arc::new(shared_lock.wrap(PropertyDeclarationBlock::with_one(
+    rules.push((StyleSource::from_declarations(Arc::new(shared_lock.wrap(PropertyDeclarationBlock::with_one(
         PropertyDeclaration::Display(
             longhands::display::SpecifiedValue::Block),
         Importance::Normal
     )))), CascadeLevel::UserNormal));
     test_insertion(rule_tree, rules)
 }
 
 #[bench]