From fec42507219151ab30585dc07687bd9821453ab8 Mon Sep 17 00:00:00 2001 From: Ravi Shankar Date: Sun, 6 Nov 2016 23:26:08 -0600 Subject: [PATCH] servo: Merge #14089 - Make use of Servo-specific ToCss everywhere! (from Wafflespeanut:tocss); r=SimonSapin This will allow types to be generic over our local `ToCss` --- - [ ] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes do not require tests because it's a refactor Source-Repo: https://github.com/servo/servo Source-Revision: f48b3fe2197a59b29bc711fb1b5496cbb97bd330 --- servo/components/layout/query.rs | 2 +- .../script/dom/cssstyledeclaration.rs | 2 +- servo/components/script/dom/mediaquerylist.rs | 3 +- servo/components/servo/Cargo.lock | 1 + servo/components/style/custom_properties.rs | 3 +- servo/components/style/lib.rs | 2 +- servo/components/style/media_queries.rs | 4 +- .../style/properties/declaration_block.rs | 3 +- .../style/properties/helpers.mako.rs | 8 ++- .../helpers/animated_properties.mako.rs | 3 +- .../properties/longhand/background.mako.rs | 9 ++- .../style/properties/longhand/border.mako.rs | 17 ++---- .../style/properties/longhand/box.mako.rs | 30 +++++----- .../style/properties/longhand/column.mako.rs | 8 +-- .../properties/longhand/counters.mako.rs | 6 +- .../style/properties/longhand/effects.mako.rs | 30 ++++------ .../style/properties/longhand/font.mako.rs | 20 +++---- .../properties/longhand/inherited_box.mako.rs | 2 +- .../longhand/inherited_table.mako.rs | 6 +- .../longhand/inherited_text.mako.rs | 26 ++++----- .../style/properties/longhand/list.mako.rs | 6 +- .../style/properties/longhand/outline.mako.rs | 3 +- .../properties/longhand/pointing.mako.rs | 2 +- .../properties/longhand/position.mako.rs | 2 +- .../style/properties/longhand/svg.mako.rs | 10 ++-- .../style/properties/longhand/text.mako.rs | 8 +-- .../style/properties/properties.mako.rs | 7 +-- .../properties/shorthand/serialize.mako.rs | 2 +- .../style/values/computed/basic_shape.rs | 3 +- .../components/style/values/computed/image.rs | 18 +++--- .../style/values/computed/length.rs | 17 +++--- servo/components/style/values/computed/mod.rs | 4 +- .../style/values/computed/position.rs | 2 +- servo/components/style/values/mod.rs | 39 +------------ .../style/values/specified/basic_shape.rs | 4 +- .../style/values/specified/image.rs | 4 +- .../style/values/specified/length.rs | 5 +- .../components/style/values/specified/mod.rs | 4 +- .../style/values/specified/position.rs | 3 +- servo/components/style/viewport.rs | 3 +- servo/components/style_traits/Cargo.toml | 1 + servo/components/style_traits/cursor.rs | 2 +- servo/components/style_traits/lib.rs | 2 + servo/components/style_traits/values.rs | 57 ++++++++++++++++++- servo/ports/cef/Cargo.lock | 1 + servo/ports/geckolib/Cargo.lock | 1 + servo/ports/geckolib/glue.rs | 3 +- servo/ports/geckolib/lib.rs | 1 + servo/tests/unit/style/parsing/basic_shape.rs | 17 +++--- servo/tests/unit/style/parsing/font.rs | 3 +- servo/tests/unit/style/parsing/image.rs | 1 + servo/tests/unit/style/parsing/mod.rs | 8 +-- servo/tests/unit/style/parsing/position.rs | 1 + servo/tests/unit/style/parsing/selectors.rs | 2 +- .../unit/style/properties/serialization.rs | 2 +- servo/tests/unit/stylo/lib.rs | 1 + 56 files changed, 221 insertions(+), 213 deletions(-) diff --git a/servo/components/layout/query.rs b/servo/components/layout/query.rs index f313010118cf..706a8fb3855b 100644 --- a/servo/components/layout/query.rs +++ b/servo/components/layout/query.rs @@ -34,7 +34,7 @@ use style::properties::longhands::{display, position}; use style::properties::style_structs; use style::selector_impl::PseudoElement; use style::selector_matching::Stylist; -use style::values::LocalToCss; +use style_traits::ToCss; use style_traits::cursor::Cursor; use wrapper::{LayoutNodeHelpers, LayoutNodeLayoutData}; diff --git a/servo/components/script/dom/cssstyledeclaration.rs b/servo/components/script/dom/cssstyledeclaration.rs index c7b607b8ae27..6af36d4614ce 100644 --- a/servo/components/script/dom/cssstyledeclaration.rs +++ b/servo/components/script/dom/cssstyledeclaration.rs @@ -2,7 +2,6 @@ * 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 cssparser::ToCss; use dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::{self, CSSStyleDeclarationMethods}; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; @@ -20,6 +19,7 @@ use style::parser::ParserContextExtraData; use style::properties::{Shorthand, Importance, PropertyDeclarationBlock}; use style::properties::{is_supported_property, parse_one_declaration, parse_style_attribute}; use style::selector_impl::PseudoElement; +use style_traits::ToCss; // http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface #[dom_struct] diff --git a/servo/components/script/dom/mediaquerylist.rs b/servo/components/script/dom/mediaquerylist.rs index 3c6215b883f9..b5007d9fe837 100644 --- a/servo/components/script/dom/mediaquerylist.rs +++ b/servo/components/script/dom/mediaquerylist.rs @@ -2,7 +2,6 @@ * 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 cssparser::ToCss; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::Bindings::EventListenerBinding::EventListener; @@ -22,7 +21,7 @@ use std::cell::Cell; use std::rc::Rc; use style; use style::media_queries::{Device, MediaType}; -use style_traits::{PagePx, ViewportPx}; +use style_traits::{PagePx, ToCss, ViewportPx}; pub enum MediaQueryListMatchState { Same(bool), diff --git a/servo/components/servo/Cargo.lock b/servo/components/servo/Cargo.lock index d6773b54cc00..df9ff55045bf 100644 --- a/servo/components/servo/Cargo.lock +++ b/servo/components/servo/Cargo.lock @@ -2429,6 +2429,7 @@ dependencies = [ "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/servo/components/style/custom_properties.rs b/servo/components/style/custom_properties.rs index 9ced8a671681..0f12f841420e 100644 --- a/servo/components/style/custom_properties.rs +++ b/servo/components/style/custom_properties.rs @@ -7,13 +7,14 @@ //! [custom]: https://drafts.csswg.org/css-variables/ use Atom; -use cssparser::{Delimiter, Parser, SourcePosition, ToCss, Token, TokenSerializationType}; +use cssparser::{Delimiter, Parser, SourcePosition, Token, TokenSerializationType}; use properties::DeclaredValue; use std::ascii::AsciiExt; use std::borrow::Cow; use std::collections::{HashMap, HashSet}; use std::fmt; use std::sync::Arc; +use style_traits::ToCss; // Does not include the `--` prefix pub type Name = Atom; diff --git a/servo/components/style/lib.rs b/servo/components/style/lib.rs index a398760bd68e..c6010def3743 100644 --- a/servo/components/style/lib.rs +++ b/servo/components/style/lib.rs @@ -132,9 +132,9 @@ pub mod values; pub mod viewport; pub mod workqueue; -use cssparser::ToCss; use std::fmt; use std::sync::Arc; +use style_traits::ToCss; #[cfg(feature = "gecko")] pub use gecko_string_cache as string_cache; #[cfg(feature = "gecko")] pub use gecko_string_cache::Atom; diff --git a/servo/components/style/media_queries.rs b/servo/components/style/media_queries.rs index b8df4c0cf61f..30609403925b 100644 --- a/servo/components/style/media_queries.rs +++ b/servo/components/style/media_queries.rs @@ -8,12 +8,12 @@ use Atom; use app_units::Au; -use cssparser::{Delimiter, Parser, ToCss, Token}; +use cssparser::{Delimiter, Parser, Token}; use euclid::size::{Size2D, TypedSize2D}; use properties::longhands; use serialize_comma_separated_list; use std::fmt::{self, Write}; -use style_traits::ViewportPx; +use style_traits::{ToCss, ViewportPx}; use values::specified; diff --git a/servo/components/style/properties/declaration_block.rs b/servo/components/style/properties/declaration_block.rs index 25d48a1cb558..5ba7f52db14e 100644 --- a/servo/components/style/properties/declaration_block.rs +++ b/servo/components/style/properties/declaration_block.rs @@ -2,13 +2,14 @@ * 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 cssparser::{DeclarationListParser, parse_important, ToCss}; +use cssparser::{DeclarationListParser, parse_important}; use cssparser::{Parser, AtRuleParser, DeclarationParser, Delimiter}; use error_reporting::ParseErrorReporter; use parser::{ParserContext, ParserContextExtraData, log_css_error}; use std::ascii::AsciiExt; use std::boxed::Box as StdBox; use std::fmt; +use style_traits::ToCss; use stylesheets::Origin; use super::*; use url::Url; diff --git a/servo/components/style/properties/helpers.mako.rs b/servo/components/style/properties/helpers.mako.rs index 89ef5229882b..fe7bac7efe9a 100644 --- a/servo/components/style/properties/helpers.mako.rs +++ b/servo/components/style/properties/helpers.mako.rs @@ -54,9 +54,9 @@ <%def name="vector_longhand(name, gecko_only=False, allow_empty=False, **kwargs)"> <%call expr="longhand(name, **kwargs)"> % if product == "gecko" or not gecko_only: - use cssparser::ToCss; use std::fmt; use values::HasViewportPercentage; + use style_traits::ToCss; impl HasViewportPercentage for SpecifiedValue { fn has_viewport_percentage(&self) -> bool { @@ -324,6 +324,7 @@ <%def name="inner_body()"> pub use self::computed_value::T as SpecifiedValue; pub mod computed_value { + use style_traits::ToCss; define_css_keyword_enum! { T: % for value in data.longhands_by_name[name].keyword.values_for(product): "${value}" => ${to_rust_ident(value)}, @@ -370,8 +371,8 @@ use values::NoViewportPercentage; impl NoViewportPercentage for SpecifiedValue {} pub mod computed_value { - use cssparser::ToCss; use std::fmt; + use style_traits::ToCss; #[derive(Debug, Clone, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] @@ -438,10 +439,11 @@ % if shorthand: pub mod ${shorthand.ident} { #[allow(unused_imports)] - use cssparser::{Parser, ToCss}; + use cssparser::Parser; use parser::ParserContext; use properties::{longhands, PropertyDeclaration, DeclaredValue, Shorthand}; use std::fmt; + use style_traits::ToCss; pub struct Longhands { % for sub_property in shorthand.sub_properties: diff --git a/servo/components/style/properties/helpers/animated_properties.mako.rs b/servo/components/style/properties/helpers/animated_properties.mako.rs index fdd3db944b37..8b8e3c0b92f9 100644 --- a/servo/components/style/properties/helpers/animated_properties.mako.rs +++ b/servo/components/style/properties/helpers/animated_properties.mako.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use app_units::Au; -use cssparser::{Color as CSSParserColor, Parser, RGBA, ToCss}; +use cssparser::{Color as CSSParserColor, Parser, RGBA}; use euclid::{Point2D, Size2D}; use properties::PropertyDeclaration; use properties::longhands; @@ -20,6 +20,7 @@ use properties::longhands::visibility::computed_value::T as Visibility; use properties::longhands::z_index::computed_value::T as ZIndex; use std::cmp; use std::fmt; +use style_traits::ToCss; use super::ComputedValues; use values::computed::{Angle, LengthOrPercentageOrAuto, LengthOrPercentageOrNone}; use values::computed::{BorderRadiusSize, LengthOrNone}; diff --git a/servo/components/style/properties/longhand/background.mako.rs b/servo/components/style/properties/longhand/background.mako.rs index 4c0bee3dfe64..cb814a0adea5 100644 --- a/servo/components/style/properties/longhand/background.mako.rs +++ b/servo/components/style/properties/longhand/background.mako.rs @@ -12,10 +12,9 @@ ${helpers.predefined_type("background-color", "CSSColor", <%helpers:vector_longhand name="background-image" animatable="False" has_uncacheable_values="${product == 'gecko'}"> - use cssparser::ToCss; use std::fmt; + use style_traits::ToCss; use values::specified::Image; - use values::LocalToCss; use values::NoViewportPercentage; pub mod computed_value { @@ -88,9 +87,8 @@ ${helpers.predefined_type("background-color", "CSSColor", <%helpers:vector_longhand name="background-position" animatable="True"> - use cssparser::ToCss; use std::fmt; - use values::LocalToCss; + use style_traits::ToCss; use values::HasViewportPercentage; use values::specified::position::Position; @@ -149,9 +147,10 @@ ${helpers.single_keyword("background-origin", animatable=False)} <%helpers:vector_longhand name="background-size" animatable="True"> - use cssparser::{ToCss, Token}; + use cssparser::Token; use std::ascii::AsciiExt; use std::fmt; + use style_traits::ToCss; use values::HasViewportPercentage; pub mod computed_value { diff --git a/servo/components/style/properties/longhand/border.mako.rs b/servo/components/style/properties/longhand/border.mako.rs index 73795afd844c..b0b8d0701ad0 100644 --- a/servo/components/style/properties/longhand/border.mako.rs +++ b/servo/components/style/properties/longhand/border.mako.rs @@ -24,8 +24,8 @@ % for side in ["top", "right", "bottom", "left"]: <%helpers:longhand name="border-${side}-width" animatable="True"> use app_units::Au; - use cssparser::ToCss; use std::fmt; + use style_traits::ToCss; use values::HasViewportPercentage; use values::specified::BorderWidth; @@ -67,9 +67,8 @@ ${helpers.single_keyword("-moz-float-edge", "content-box margin-box", // https://drafts.csswg.org/css-backgrounds-3/#border-image-source <%helpers:longhand name="border-image-source" products="gecko" animatable="False"> - use cssparser::ToCss; use std::fmt; - use values::LocalToCss; + use style_traits::ToCss; use values::NoViewportPercentage; use values::specified::Image; @@ -139,10 +138,9 @@ ${helpers.single_keyword("-moz-float-edge", "content-box margin-box", // https://drafts.csswg.org/css-backgrounds-3/#border-image-outset <%helpers:longhand name="border-image-outset" products="gecko" animatable="False"> - use cssparser::ToCss; use std::fmt; + use style_traits::ToCss; use values::HasViewportPercentage; - use values::LocalToCss; use values::specified::LengthOrNumber; impl HasViewportPercentage for SpecifiedValue { @@ -253,9 +251,8 @@ ${helpers.single_keyword("-moz-float-edge", "content-box margin-box", // https://drafts.csswg.org/css-backgrounds-3/#border-image-repeat <%helpers:longhand name="border-image-repeat" products="gecko" animatable="False"> - use cssparser::ToCss; use std::fmt; - use values::LocalToCss; + use style_traits::ToCss; use values::NoViewportPercentage; impl NoViewportPercentage for SpecifiedValue {} @@ -327,9 +324,8 @@ ${helpers.single_keyword("-moz-float-edge", "content-box margin-box", // https://drafts.csswg.org/css-backgrounds-3/#border-image-width <%helpers:longhand name="border-image-width" products="gecko" animatable="False"> - use cssparser::ToCss; use std::fmt; - use values::LocalToCss; + use style_traits::ToCss; use values::HasViewportPercentage; use values::specified::{LengthOrPercentage, Number}; @@ -523,9 +519,8 @@ ${helpers.single_keyword("-moz-float-edge", "content-box margin-box", // https://drafts.csswg.org/css-backgrounds-3/#border-image-slice <%helpers:longhand name="border-image-slice" products="gecko" animatable="False"> - use cssparser::ToCss; use std::fmt; - use values::LocalToCss; + use style_traits::ToCss; use values::NoViewportPercentage; use values::specified::{Number, Percentage}; diff --git a/servo/components/style/properties/longhand/box.mako.rs b/servo/components/style/properties/longhand/box.mako.rs index b1e19239c9f1..fb843144c363 100644 --- a/servo/components/style/properties/longhand/box.mako.rs +++ b/servo/components/style/properties/longhand/box.mako.rs @@ -27,11 +27,12 @@ %> pub use self::computed_value::T as SpecifiedValue; use values::computed::ComputedValueAsSpecified; - + use style_traits::ToCss; use values::NoViewportPercentage; impl NoViewportPercentage for SpecifiedValue {} pub mod computed_value { + use style_traits::ToCss; #[allow(non_camel_case_types)] #[derive(Clone, Eq, PartialEq, Copy, Hash, RustcEncodable, Debug)] #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] @@ -41,7 +42,7 @@ % endfor } - impl ::cssparser::ToCss for T { + impl ToCss for T { fn to_css(&self, dest: &mut W) -> ::std::fmt::Result where W: ::std::fmt::Write { match *self { @@ -148,8 +149,9 @@ ${helpers.single_keyword("clear", "none left right both", <%helpers:longhand name="vertical-align" animatable="True"> - use cssparser::ToCss; use std::fmt; + use style_traits::ToCss; + use values::HasViewportPercentage; <% vertical_align = data.longhands_by_name["vertical-align"] %> <% vertical_align.keyword = Keyword("vertical-align", @@ -157,7 +159,6 @@ ${helpers.single_keyword("clear", "none left right both", extra_gecko_values="middle-with-baseline") %> <% vertical_align_keywords = vertical_align.keyword.values_for(product) %> - use values::HasViewportPercentage; impl HasViewportPercentage for SpecifiedValue { fn has_viewport_percentage(&self) -> bool { match *self { @@ -204,7 +205,7 @@ ${helpers.single_keyword("clear", "none left right both", pub mod computed_value { use app_units::Au; use std::fmt; - use values::LocalToCss; + use style_traits::ToCss; use values::{CSSFloat, computed}; #[allow(non_camel_case_types)] #[derive(PartialEq, Copy, Clone, Debug)] @@ -215,7 +216,7 @@ ${helpers.single_keyword("clear", "none left right both", % endfor LengthOrPercentage(computed::LengthOrPercentage), } - impl ::cssparser::ToCss for T { + impl ToCss for T { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { match *self { % for keyword in vertical_align_keywords: @@ -282,13 +283,13 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", animatable="False"> use super::overflow_x; - use cssparser::ToCss; use std::fmt; + use style_traits::ToCss; use values::computed::ComputedValueAsSpecified; + use values::NoViewportPercentage; pub use self::computed_value::T as SpecifiedValue; - use values::NoViewportPercentage; impl NoViewportPercentage for SpecifiedValue {} impl ToCss for SpecifiedValue { @@ -327,8 +328,8 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", impl NoViewportPercentage for SpecifiedValue {} pub mod computed_value { - use cssparser::ToCss; use std::fmt; + use style_traits::ToCss; use values::computed::{Context, ToComputedValue}; pub use values::computed::Time as SingleComputedValue; @@ -426,9 +427,9 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", TransitionTimingFunction::Steps(1, StartEnd::End); pub mod computed_value { - use cssparser::ToCss; use euclid::point::Point2D; use std::fmt; + use style_traits::ToCss; use values::computed::ComputedValueAsSpecified; pub use self::TransitionTimingFunction as SingleComputedValue; @@ -581,8 +582,8 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", pub use self::computed_value::T as SpecifiedValue; pub mod computed_value { - use cssparser::ToCss; use std::fmt; + use style_traits::ToCss; // NB: Can't generate the type here because it needs all the longhands // generated beforehand. pub use properties::animated_properties::TransitionProperty; @@ -646,9 +647,9 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", use values::NoViewportPercentage; pub mod computed_value { - use cssparser::ToCss; use std::fmt; use Atom; + use style_traits::ToCss; pub use Atom as SingleComputedValue; @@ -732,8 +733,8 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", use values::NoViewportPercentage; pub mod computed_value { - use cssparser::ToCss; use std::fmt; + use style_traits::ToCss; pub use self::AnimationIterationCount as SingleComputedValue; @@ -842,9 +843,8 @@ ${helpers.keyword_list("animation-fill-mode", <%helpers:longhand products="gecko" name="scroll-snap-points-y" animatable="False"> - use cssparser::ToCss; use std::fmt; - use values::LocalToCss; + use style_traits::ToCss; use values::HasViewportPercentage; use values::specified::LengthOrPercentage; diff --git a/servo/components/style/properties/longhand/column.mako.rs b/servo/components/style/properties/longhand/column.mako.rs index 6c82cee77f97..88272435972a 100644 --- a/servo/components/style/properties/longhand/column.mako.rs +++ b/servo/components/style/properties/longhand/column.mako.rs @@ -8,9 +8,8 @@ // FIXME: This prop should be animatable. <%helpers:longhand name="column-width" experimental="True" animatable="False"> - use cssparser::ToCss; use std::fmt; - use values::LocalToCss; + use style_traits::ToCss; use values::HasViewportPercentage; impl HasViewportPercentage for SpecifiedValue { @@ -91,8 +90,8 @@ // FIXME: This prop should be animatable. <%helpers:longhand name="column-count" experimental="True" animatable="False"> - use cssparser::ToCss; use std::fmt; + use style_traits::ToCss; use values::NoViewportPercentage; impl NoViewportPercentage for SpecifiedValue {} @@ -171,9 +170,8 @@ // FIXME: This prop should be animatable. <%helpers:longhand name="column-gap" experimental="True" products="servo" animatable="False"> - use cssparser::ToCss; use std::fmt; - use values::LocalToCss; + use style_traits::ToCss; use values::HasViewportPercentage; impl HasViewportPercentage for SpecifiedValue { diff --git a/servo/components/style/properties/longhand/counters.mako.rs b/servo/components/style/properties/longhand/counters.mako.rs index d20c3f8aab03..521cb20cd4a5 100644 --- a/servo/components/style/properties/longhand/counters.mako.rs +++ b/servo/components/style/properties/longhand/counters.mako.rs @@ -23,8 +23,9 @@ pub mod computed_value { use super::super::list_style_type; - use cssparser::{self, ToCss}; + use cssparser; use std::fmt; + use style_traits::ToCss; #[derive(Debug, PartialEq, Eq, Clone)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] @@ -175,11 +176,12 @@ <%helpers:longhand name="counter-increment" products="servo" animatable="False"> use std::fmt; + use style_traits::ToCss; use super::content; use values::NoViewportPercentage; use values::computed::ComputedValueAsSpecified; - use cssparser::{ToCss, Token, serialize_identifier}; + use cssparser::{Token, serialize_identifier}; use std::borrow::{Cow, ToOwned}; pub use self::computed_value::T as SpecifiedValue; diff --git a/servo/components/style/properties/longhand/effects.mako.rs b/servo/components/style/properties/longhand/effects.mako.rs index d9a70f4b574c..5949bc48704e 100644 --- a/servo/components/style/properties/longhand/effects.mako.rs +++ b/servo/components/style/properties/longhand/effects.mako.rs @@ -13,10 +13,10 @@ ${helpers.predefined_type("opacity", animatable=True)} <%helpers:vector_longhand name="box-shadow" allow_empty="True" animatable="True"> - use cssparser::{self, ToCss}; + use cssparser; use std::fmt; use parser::Parse; - use values::LocalToCss; + use style_traits::ToCss; use values::HasViewportPercentage; #[derive(Debug, Clone, PartialEq)] @@ -189,9 +189,8 @@ ${helpers.predefined_type("opacity", // FIXME: This prop should be animatable <%helpers:longhand name="clip" products="servo" animatable="False"> - use cssparser::ToCss; use std::fmt; - use values::LocalToCss; + use style_traits::ToCss; use values::HasViewportPercentage; // NB: `top` and `left` are 0 if `auto` per CSS 2.1 11.1.2. @@ -405,11 +404,9 @@ ${helpers.predefined_type("opacity", // FIXME: This prop should be animatable <%helpers:longhand name="filter" animatable="False"> //pub use self::computed_value::T as SpecifiedValue; - use cssparser::ToCss; use std::fmt; - use values::LocalToCss; - use values::CSSFloat; - use values::HasViewportPercentage; + use style_traits::ToCss; + use values::{CSSFloat, HasViewportPercentage}; use values::specified::{Angle, Length}; impl HasViewportPercentage for SpecifiedValue { @@ -675,11 +672,9 @@ ${helpers.predefined_type("opacity", <%helpers:longhand name="transform" products="servo" animatable="True"> use app_units::Au; - use values::CSSFloat; - use values::HasViewportPercentage; - - use cssparser::ToCss; use std::fmt; + use style_traits::ToCss; + use values::{CSSFloat, HasViewportPercentage}; pub mod computed_value { use values::CSSFloat; @@ -1293,13 +1288,11 @@ ${helpers.single_keyword("transform-style", <%helpers:longhand name="transform-origin" products="servo" animatable="True"> use app_units::Au; - use values::LocalToCss; + use std::fmt; + use style_traits::ToCss; use values::HasViewportPercentage; use values::specified::{Length, LengthOrPercentage, Percentage}; - use cssparser::ToCss; - use std::fmt; - pub mod computed_value { use properties::animated_properties::Interpolate; use values::computed::{Length, LengthOrPercentage}; @@ -1408,12 +1401,11 @@ ${helpers.predefined_type("perspective", // FIXME: This prop should be animatable <%helpers:longhand name="perspective-origin" products="servo" animatable="False"> + use std::fmt; + use style_traits::ToCss; use values::HasViewportPercentage; use values::specified::{LengthOrPercentage, Percentage}; - use cssparser::ToCss; - use std::fmt; - pub mod computed_value { use values::computed::LengthOrPercentage; diff --git a/servo/components/style/properties/longhand/font.mako.rs b/servo/components/style/properties/longhand/font.mako.rs index bcd34d4c4e28..01d8621661c6 100644 --- a/servo/components/style/properties/longhand/font.mako.rs +++ b/servo/components/style/properties/longhand/font.mako.rs @@ -18,9 +18,9 @@ impl NoViewportPercentage for SpecifiedValue {} pub mod computed_value { - use cssparser::ToCss; use std::fmt; use Atom; + use style_traits::ToCss; #[derive(Debug, PartialEq, Eq, Clone, Hash)] #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] @@ -137,8 +137,8 @@ ${helpers.single_keyword("font-variant", animatable=False)} <%helpers:longhand name="font-weight" need_clone="True" animatable="True"> - use cssparser::ToCss; use std::fmt; + use style_traits::ToCss; use values::NoViewportPercentage; impl NoViewportPercentage for SpecifiedValue {} @@ -271,10 +271,9 @@ ${helpers.single_keyword("font-variant", <%helpers:longhand name="font-size" need_clone="True" animatable="True"> use app_units::Au; - use cssparser::ToCss; use std::fmt; - use values::FONT_MEDIUM_PX; - use values::HasViewportPercentage; + use style_traits::ToCss; + use values::{FONT_MEDIUM_PX, HasViewportPercentage}; use values::specified::{LengthOrPercentage, Length, Percentage}; impl ToCss for SpecifiedValue { @@ -351,11 +350,10 @@ ${helpers.single_keyword("font-variant", <%helpers:longhand products="gecko" name="font-synthesis" animatable="False"> - use cssparser::ToCss; use std::fmt; - use values::LocalToCss; - use values::computed::ComputedValueAsSpecified; + use style_traits::ToCss; use values::NoViewportPercentage; + use values::computed::ComputedValueAsSpecified; impl ComputedValueAsSpecified for SpecifiedValue {} impl NoViewportPercentage for SpecifiedValue {} @@ -438,8 +436,8 @@ ${helpers.single_keyword("font-variant-position", animatable=False)} <%helpers:longhand name="font-feature-settings" products="none" animatable="False"> - use cssparser::ToCss; use std::fmt; + use style_traits::ToCss; use values::NoViewportPercentage; use values::computed::ComputedValueAsSpecified; pub use self::computed_value::T as SpecifiedValue; @@ -448,9 +446,9 @@ ${helpers.single_keyword("font-variant-position", impl NoViewportPercentage for SpecifiedValue {} pub mod computed_value { - use cssparser::ToCss; use cssparser::Parser; use std::fmt; + use style_traits::ToCss; #[derive(Debug, Clone, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] @@ -555,8 +553,8 @@ ${helpers.single_keyword("font-variant-position", impl NoViewportPercentage for SpecifiedValue {} pub mod computed_value { - use cssparser::ToCss; use std::fmt; + use style_traits::ToCss; impl ToCss for T { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { diff --git a/servo/components/style/properties/longhand/inherited_box.mako.rs b/servo/components/style/properties/longhand/inherited_box.mako.rs index d03b38cf6f0a..15b65ee418df 100644 --- a/servo/components/style/properties/longhand/inherited_box.mako.rs +++ b/servo/components/style/properties/longhand/inherited_box.mako.rs @@ -56,8 +56,8 @@ ${helpers.single_keyword("image-rendering", derived_from="display" products="servo" animatable="False"> - use cssparser::ToCss; use std::fmt; + use style_traits::ToCss; use values::computed::ComputedValueAsSpecified; use values::NoViewportPercentage; diff --git a/servo/components/style/properties/longhand/inherited_table.mako.rs b/servo/components/style/properties/longhand/inherited_table.mako.rs index 18e6bd76e93a..a8b3e6f89135 100644 --- a/servo/components/style/properties/longhand/inherited_table.mako.rs +++ b/servo/components/style/properties/longhand/inherited_table.mako.rs @@ -18,11 +18,9 @@ ${helpers.single_keyword("caption-side", "top bottom", <%helpers:longhand name="border-spacing" animatable="False"> use app_units::Au; - use values::LocalToCss; - use values::HasViewportPercentage; - - use cssparser::ToCss; use std::fmt; + use style_traits::ToCss; + use values::HasViewportPercentage; pub mod computed_value { use app_units::Au; diff --git a/servo/components/style/properties/longhand/inherited_text.mako.rs b/servo/components/style/properties/longhand/inherited_text.mako.rs index e775c3d588d6..e622dabe2b93 100644 --- a/servo/components/style/properties/longhand/inherited_text.mako.rs +++ b/servo/components/style/properties/longhand/inherited_text.mako.rs @@ -7,11 +7,9 @@ <% data.new_style_struct("InheritedText", inherited=True, gecko_name="Text") %> <%helpers:longhand name="line-height" animatable="True"> - use cssparser::ToCss; use std::fmt; - use values::LocalToCss; - use values::CSSFloat; - use values::HasViewportPercentage; + use style_traits::ToCss; + use values::{CSSFloat, HasViewportPercentage}; impl HasViewportPercentage for SpecifiedValue { fn has_viewport_percentage(&self) -> bool { @@ -153,6 +151,7 @@ impl ComputedValueAsSpecified for SpecifiedValue {} impl NoViewportPercentage for SpecifiedValue {} pub mod computed_value { + use style_traits::ToCss; macro_rules! define_text_align { ( $( $name: ident ( $string: expr ) => $discriminant: expr, )+ ) => { define_css_keyword_enum! { T: @@ -209,9 +208,8 @@ // FIXME: This prop should be animatable. <%helpers:longhand name="letter-spacing" animatable="False"> - use cssparser::ToCss; use std::fmt; - use values::LocalToCss; + use style_traits::ToCss; use values::HasViewportPercentage; impl HasViewportPercentage for SpecifiedValue { @@ -290,9 +288,8 @@ <%helpers:longhand name="word-spacing" animatable="False"> - use cssparser::ToCss; use std::fmt; - use values::LocalToCss; + use style_traits::ToCss; use values::HasViewportPercentage; impl HasViewportPercentage for SpecifiedValue { @@ -405,10 +402,10 @@ ${helpers.single_keyword("text-align-last", derived_from="display text-decoration" need_clone="True" products="servo" animatable="False"> - use cssparser::{RGBA, ToCss}; + use cssparser::RGBA; use std::fmt; - - use values:: NoViewportPercentage; + use style_traits::ToCss; + use values::NoViewportPercentage; use values::computed::ComputedValueAsSpecified; impl ComputedValueAsSpecified for SpecifiedValue {} @@ -529,9 +526,9 @@ ${helpers.single_keyword("text-align-last", <%helpers:longhand name="text-shadow" animatable="True"> - use cssparser::{self, ToCss}; + use cssparser; use std::fmt; - use values::LocalToCss; + use style_traits::ToCss; use values::HasViewportPercentage; impl HasViewportPercentage for SpecifiedValue { @@ -739,10 +736,9 @@ ${helpers.single_keyword("text-align-last", <%helpers:longhand name="text-emphasis-style" products="gecko" need_clone="True" animatable="False"> use computed_values::writing_mode::T as writing_mode; - use cssparser::ToCss; use std::fmt; + use style_traits::ToCss; use unicode_segmentation::UnicodeSegmentation; - use values::LocalToCss; use values::NoViewportPercentage; impl NoViewportPercentage for SpecifiedValue {} diff --git a/servo/components/style/properties/longhand/list.mako.rs b/servo/components/style/properties/longhand/list.mako.rs index b8afa7e92494..f237e4b0e034 100644 --- a/servo/components/style/properties/longhand/list.mako.rs +++ b/servo/components/style/properties/longhand/list.mako.rs @@ -31,12 +31,12 @@ ${helpers.predefined_type("list-style-image", "UrlOrNone", "computed_value::T::N animatable="False")} <%helpers:longhand name="quotes" animatable="False"> + use cssparser::Token; use std::borrow::Cow; use std::fmt; - use values::NoViewportPercentage; + use style_traits::ToCss; use values::computed::ComputedValueAsSpecified; - - use cssparser::{ToCss, Token}; + use values::NoViewportPercentage; pub use self::computed_value::T as SpecifiedValue; diff --git a/servo/components/style/properties/longhand/outline.mako.rs b/servo/components/style/properties/longhand/outline.mako.rs index 2d55e1592c53..5f4c12a0772d 100644 --- a/servo/components/style/properties/longhand/outline.mako.rs +++ b/servo/components/style/properties/longhand/outline.mako.rs @@ -29,9 +29,8 @@ ${helpers.predefined_type("outline-color", "CSSColor", "::cssparser::Color::Curr <%helpers:longhand name="outline-width" animatable="True"> use app_units::Au; - use cssparser::ToCss; use std::fmt; - use values::LocalToCss; + use style_traits::ToCss; use values::HasViewportPercentage; impl ToCss for SpecifiedValue { diff --git a/servo/components/style/properties/longhand/pointing.mako.rs b/servo/components/style/properties/longhand/pointing.mako.rs index 2214b69038d9..f140b32336e3 100644 --- a/servo/components/style/properties/longhand/pointing.mako.rs +++ b/servo/components/style/properties/longhand/pointing.mako.rs @@ -15,9 +15,9 @@ impl NoViewportPercentage for SpecifiedValue {} pub mod computed_value { - use cssparser::ToCss; use std::fmt; use style_traits::cursor::Cursor; + use style_traits::ToCss; #[derive(Clone, PartialEq, Eq, Copy, Debug)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] diff --git a/servo/components/style/properties/longhand/position.mako.rs b/servo/components/style/properties/longhand/position.mako.rs index c249ea51bed8..a3166ea82388 100644 --- a/servo/components/style/properties/longhand/position.mako.rs +++ b/servo/components/style/properties/longhand/position.mako.rs @@ -20,8 +20,8 @@ impl NoViewportPercentage for SpecifiedValue {} pub type SpecifiedValue = computed_value::T; pub mod computed_value { - use cssparser::ToCss; use std::fmt; + use style_traits::ToCss; #[derive(PartialEq, Clone, Eq, Copy, Debug)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] diff --git a/servo/components/style/properties/longhand/svg.mako.rs b/servo/components/style/properties/longhand/svg.mako.rs index cd7409cc1c7b..9d6667a8d979 100644 --- a/servo/components/style/properties/longhand/svg.mako.rs +++ b/servo/components/style/properties/longhand/svg.mako.rs @@ -51,9 +51,8 @@ ${helpers.single_keyword("mask-type", "luminance alpha", products="gecko", animatable=False)} <%helpers:longhand name="clip-path" animatable="False" products="gecko"> - use cssparser::ToCss; use std::fmt; - use values::LocalToCss; + use style_traits::ToCss; use values::NoViewportPercentage; use values::specified::basic_shape::{ShapeSource, GeometryBox}; @@ -148,18 +147,17 @@ ${helpers.single_keyword("mask-composite", <%helpers:vector_longhand name="mask-image" products="gecko" animatable="False" has_uncacheable_values="${product == 'gecko'}"> - use cssparser::ToCss; use std::fmt; + use style_traits::ToCss; use url::Url; use values::specified::{Image, UrlExtraData}; - use values::LocalToCss; use values::NoViewportPercentage; pub mod computed_value { - use cssparser::ToCss; use std::fmt; + use style_traits::ToCss; use url::Url; - use values::{computed, LocalToCss}; + use values::computed; #[derive(Debug, Clone, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum T { diff --git a/servo/components/style/properties/longhand/text.mako.rs b/servo/components/style/properties/longhand/text.mako.rs index b983877cb30c..d10850400fac 100644 --- a/servo/components/style/properties/longhand/text.mako.rs +++ b/servo/components/style/properties/longhand/text.mako.rs @@ -16,10 +16,10 @@ ${helpers.single_keyword("text-overflow", "clip ellipsis", animatable=False)} % else: <%helpers:longhand name="text-overflow" animatable="False"> - use cssparser::ToCss; use std::fmt; - use values::computed::ComputedValueAsSpecified; + use style_traits::ToCss; use values::NoViewportPercentage; + use values::computed::ComputedValueAsSpecified; impl ComputedValueAsSpecified for SpecifiedValue {} impl NoViewportPercentage for SpecifiedValue {} @@ -104,10 +104,10 @@ ${helpers.single_keyword("unicode-bidi", custom_cascade="${product == 'servo'}" animatable="False" disable_when_testing="True"> - use cssparser::ToCss; use std::fmt; - use values::computed::ComputedValueAsSpecified; + use style_traits::ToCss; use values::NoViewportPercentage; + use values::computed::ComputedValueAsSpecified; impl ComputedValueAsSpecified for SpecifiedValue {} impl NoViewportPercentage for SpecifiedValue {} diff --git a/servo/components/style/properties/properties.mako.rs b/servo/components/style/properties/properties.mako.rs index 9ae5a2f8e46c..ca72c0c38aa1 100644 --- a/servo/components/style/properties/properties.mako.rs +++ b/servo/components/style/properties/properties.mako.rs @@ -19,7 +19,7 @@ use std::sync::Arc; use Atom; use app_units::Au; #[cfg(feature = "servo")] use cssparser::{Color as CSSParserColor, RGBA}; -use cssparser::{Parser, ToCss, TokenSerializationType}; +use cssparser::{Parser, TokenSerializationType}; use error_reporting::ParseErrorReporter; use url::Url; #[cfg(feature = "servo")] use euclid::side_offsets::SideOffsets2D; @@ -28,10 +28,9 @@ use computed_values; #[cfg(feature = "servo")] use logical_geometry::{LogicalMargin, PhysicalSide}; use logical_geometry::WritingMode; use parser::{ParserContext, ParserContextExtraData}; +use style_traits::ToCss; use stylesheets::Origin; -#[cfg(feature = "servo")] use values::LocalToCss; -use values::HasViewportPercentage; -use values::computed; +use values::{HasViewportPercentage, computed}; use cascade_info::CascadeInfo; use rule_tree::StrongRuleNode; #[cfg(feature = "servo")] use values::specified::BorderStyle; diff --git a/servo/components/style/properties/shorthand/serialize.mako.rs b/servo/components/style/properties/shorthand/serialize.mako.rs index 4fa05dedc45d..e061796b80da 100644 --- a/servo/components/style/properties/shorthand/serialize.mako.rs +++ b/servo/components/style/properties/shorthand/serialize.mako.rs @@ -2,8 +2,8 @@ * 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 cssparser::ToCss; use properties::{AppendableValue, DeclaredValue, PropertyDeclaration, Shorthand}; +use style_traits::ToCss; use values::specified::{BorderStyle, CSSColor}; use std::fmt; diff --git a/servo/components/style/values/computed/basic_shape.rs b/servo/components/style/values/computed/basic_shape.rs index f9dd1f6609d4..d27fe94545b7 100644 --- a/servo/components/style/values/computed/basic_shape.rs +++ b/servo/components/style/values/computed/basic_shape.rs @@ -7,9 +7,9 @@ //! //! [basic-shape]: https://drafts.csswg.org/css-shapes/#typedef-basic-shape -use cssparser::ToCss; use properties::shorthands::serialize_four_sides; use std::fmt; +use style_traits::ToCss; use url::Url; use values::computed::{BorderRadiusSize, LengthOrPercentage}; use values::computed::UrlExtraData; @@ -34,7 +34,6 @@ impl Default for ShapeSource { impl ToCss for ShapeSource { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { - use values::LocalToCss; match *self { ShapeSource::Url(ref url, _) => url.to_css(dest), ShapeSource::Shape(ref shape, Some(ref reference)) => { diff --git a/servo/components/style/values/computed/image.rs b/servo/components/style/values/computed/image.rs index d92ed0689dc7..4b825d1fbdd7 100644 --- a/servo/components/style/values/computed/image.rs +++ b/servo/components/style/values/computed/image.rs @@ -9,12 +9,11 @@ use cssparser::Color as CSSColor; use std::fmt; +use style_traits::ToCss; use url::Url; -use values::LocalToCss; use values::computed::{Context, Length, LengthOrPercentage, ToComputedValue}; use values::computed::position::Position; -use values::specified; -use values::specified::{AngleOrCorner, SizeKeyword, UrlExtraData}; +use values::specified::{self, AngleOrCorner, SizeKeyword, UrlExtraData}; impl ToComputedValue for specified::Image { @@ -73,9 +72,8 @@ impl fmt::Debug for Image { } } -impl ::cssparser::ToCss for Image { +impl ToCss for Image { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { - use values::LocalToCss; match *self { Image::Url(ref url, _) => { url.to_css(dest) @@ -98,7 +96,7 @@ pub struct Gradient { pub gradient_kind: GradientKind, } -impl ::cssparser::ToCss for Gradient { +impl ToCss for Gradient { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { if self.repeating { try!(dest.write_str("repeating-")); @@ -224,7 +222,7 @@ pub struct ColorStop { pub position: Option, } -impl ::cssparser::ToCss for ColorStop { +impl ToCss for ColorStop { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { try!(self.color.to_css(dest)); if let Some(position) = self.position { @@ -279,7 +277,7 @@ pub enum EndingShape { Ellipse(LengthOrPercentageOrKeyword), } -impl ::cssparser::ToCss for EndingShape { +impl ToCss for EndingShape { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { match *self { EndingShape::Circle(ref length) => { @@ -344,7 +342,7 @@ pub enum LengthOrKeyword { Keyword(SizeKeyword), } -impl ::cssparser::ToCss for LengthOrKeyword { +impl ToCss for LengthOrKeyword { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { match *self { LengthOrKeyword::Length(ref length) => length.to_css(dest), @@ -402,7 +400,7 @@ pub enum LengthOrPercentageOrKeyword { Keyword(SizeKeyword), } -impl ::cssparser::ToCss for LengthOrPercentageOrKeyword { +impl ToCss for LengthOrPercentageOrKeyword { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { match *self { LengthOrPercentageOrKeyword::LengthOrPercentage(ref first_len, second_len) => { diff --git a/servo/components/style/values/computed/length.rs b/servo/components/style/values/computed/length.rs index 204c6071ce83..5d3044c3ac7e 100644 --- a/servo/components/style/values/computed/length.rs +++ b/servo/components/style/values/computed/length.rs @@ -5,8 +5,9 @@ use app_units::Au; use ordered_float::NotNaN; use std::fmt; +use style_traits::ToCss; use super::{Number, ToComputedValue, Context}; -use values::{CSSFloat, LocalToCss, specified}; +use values::{CSSFloat, specified}; pub use cssparser::Color as CSSColor; pub use super::image::{EndingShape as GradientShape, Gradient, GradientKind, Image}; @@ -79,7 +80,7 @@ impl From for Option { } } -impl ::cssparser::ToCss for CalcLengthOrPercentage { +impl ToCss for CalcLengthOrPercentage { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { match (self.length, self.percentage) { (None, Some(p)) => write!(dest, "{}%", p * 100.), @@ -192,7 +193,7 @@ impl ToComputedValue for specified::LengthOrPercentage { } } -impl ::cssparser::ToCss for LengthOrPercentage { +impl ToCss for LengthOrPercentage { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { match *self { LengthOrPercentage::Length(length) => length.to_css(dest), @@ -279,7 +280,7 @@ impl ToComputedValue for specified::LengthOrPercentageOrAuto { } } -impl ::cssparser::ToCss for LengthOrPercentageOrAuto { +impl ToCss for LengthOrPercentageOrAuto { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { match *self { LengthOrPercentageOrAuto::Length(length) => length.to_css(dest), @@ -364,7 +365,7 @@ impl ToComputedValue for specified::LengthOrPercentageOrAutoOrContent { } } -impl ::cssparser::ToCss for LengthOrPercentageOrAutoOrContent { +impl ToCss for LengthOrPercentageOrAutoOrContent { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { match *self { LengthOrPercentageOrAutoOrContent::Length(length) => length.to_css(dest), @@ -439,7 +440,7 @@ impl ToComputedValue for specified::LengthOrPercentageOrNone { } } -impl ::cssparser::ToCss for LengthOrPercentageOrNone { +impl ToCss for LengthOrPercentageOrNone { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { match *self { LengthOrPercentageOrNone::Length(length) => length.to_css(dest), @@ -498,7 +499,7 @@ impl ToComputedValue for specified::LengthOrNone { } } -impl ::cssparser::ToCss for LengthOrNone { +impl ToCss for LengthOrNone { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { match *self { LengthOrNone::Length(length) => length.to_css(dest), @@ -546,7 +547,7 @@ impl ToComputedValue for specified::LengthOrNumber { } } -impl ::cssparser::ToCss for LengthOrNumber { +impl ToCss for LengthOrNumber { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { match *self { LengthOrNumber::Length(len) => len.to_css(dest), diff --git a/servo/components/style/values/computed/mod.rs b/servo/components/style/values/computed/mod.rs index 6307c8b06a53..c73fcd73e83c 100644 --- a/servo/components/style/values/computed/mod.rs +++ b/servo/components/style/values/computed/mod.rs @@ -6,6 +6,7 @@ use app_units::Au; use euclid::size::Size2D; use properties::ComputedValues; use std::fmt; +use style_traits::ToCss; use super::{CSSFloat, specified}; pub use cssparser::Color as CSSColor; @@ -111,6 +112,7 @@ impl ToComputedValue for specified::Length { } } + #[derive(Debug, PartialEq, Clone, Copy)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct BorderRadiusSize(pub Size2D); @@ -139,7 +141,7 @@ impl ToComputedValue for specified::BorderRadiusSize { } } -impl ::cssparser::ToCss for BorderRadiusSize { +impl ToCss for BorderRadiusSize { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { try!(self.0.width.to_css(dest)); try!(dest.write_str("/")); diff --git a/servo/components/style/values/computed/position.rs b/servo/components/style/values/computed/position.rs index 635b03944b87..d2a561639f42 100644 --- a/servo/components/style/values/computed/position.rs +++ b/servo/components/style/values/computed/position.rs @@ -7,8 +7,8 @@ //! //! [position]: https://drafts.csswg.org/css-backgrounds-3/#position -use cssparser::ToCss; use std::fmt; +use style_traits::ToCss; use values::computed::LengthOrPercentage; #[derive(Debug, Clone, PartialEq, Copy)] diff --git a/servo/components/style/values/mod.rs b/servo/components/style/values/mod.rs index e926685f11b5..46d7b304d0b3 100644 --- a/servo/components/style/values/mod.rs +++ b/servo/components/style/values/mod.rs @@ -8,11 +8,6 @@ pub use cssparser::RGBA; -use app_units::Au; -use cssparser::CssStringWriter; -use std::fmt::{self, Write}; -use url::Url; - macro_rules! define_numbered_css_keyword_enum { ($name: ident: $( $css: expr => $variant: ident = $value: expr ),+,) => { define_numbered_css_keyword_enum!($name: $( $css => $variant = $value ),+); @@ -34,7 +29,7 @@ macro_rules! define_numbered_css_keyword_enum { } } - impl ::cssparser::ToCss for $name { + impl ToCss for $name { fn to_css(&self, dest: &mut W) -> ::std::fmt::Result where W: ::std::fmt::Write { match *self { @@ -48,38 +43,6 @@ macro_rules! define_numbered_css_keyword_enum { pub mod computed; pub mod specified; -/// The real ToCss trait can't be implemented for types in crates that don't -/// depend on each other. -pub trait LocalToCss { - /// Serialize `self` in CSS syntax, writing to `dest`. - fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write; - - /// Serialize `self` in CSS syntax and return a string. - /// - /// (This is a convenience wrapper for `to_css` and probably should not be overridden.) - #[inline] - fn to_css_string(&self) -> String { - let mut s = String::new(); - self.to_css(&mut s).unwrap(); - s - } -} - -impl LocalToCss for Au { - fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { - write!(dest, "{}px", self.to_f64_px()) - } -} - -impl LocalToCss for Url { - fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { - try!(dest.write_str("url(\"")); - try!(write!(CssStringWriter::new(dest), "{}", self)); - try!(dest.write_str("\")")); - Ok(()) - } -} - pub type CSSFloat = f32; pub const FONT_MEDIUM_PX: i32 = 16; diff --git a/servo/components/style/values/specified/basic_shape.rs b/servo/components/style/values/specified/basic_shape.rs index ad100a33b6a8..6f5bdb039531 100644 --- a/servo/components/style/values/specified/basic_shape.rs +++ b/servo/components/style/values/specified/basic_shape.rs @@ -7,10 +7,11 @@ //! //! [basic-shape]: https://drafts.csswg.org/css-shapes/#typedef-basic-shape -use cssparser::{Parser, ToCss}; +use cssparser::Parser; use parser::{Parse, ParserContext}; use properties::shorthands::{parse_four_sides, serialize_four_sides}; use std::fmt; +use style_traits::ToCss; use url::Url; use values::computed::{ComputedValueAsSpecified, Context, ToComputedValue}; use values::computed::basic_shape as computed_basic_shape; @@ -39,7 +40,6 @@ impl Default for ShapeSource { impl ToCss for ShapeSource { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { - use values::LocalToCss; match *self { ShapeSource::Url(ref url, _) => url.to_css(dest), ShapeSource::Shape(ref shape, Some(ref reference)) => { diff --git a/servo/components/style/values/specified/image.rs b/servo/components/style/values/specified/image.rs index 3625d5394ca0..f6a64ba3c3b7 100644 --- a/servo/components/style/values/specified/image.rs +++ b/servo/components/style/values/specified/image.rs @@ -7,10 +7,11 @@ //! //! [image]: https://drafts.csswg.org/css-images/#image-values -use cssparser::{Parser, ToCss}; +use cssparser::Parser; use parser::{Parse, ParserContext}; use std::f32::consts::PI; use std::fmt; +use style_traits::ToCss; use url::Url; use values::computed::ComputedValueAsSpecified; use values::specified::{Angle, CSSColor, Length, LengthOrPercentage, UrlExtraData}; @@ -27,7 +28,6 @@ pub enum Image { impl ToCss for Image { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { - use values::LocalToCss; match *self { Image::Url(ref url, ref _extra_data) => { url.to_css(dest) diff --git a/servo/components/style/values/specified/length.rs b/servo/components/style/values/specified/length.rs index bcd320da425c..a0ed172cab14 100644 --- a/servo/components/style/values/specified/length.rs +++ b/servo/components/style/values/specified/length.rs @@ -3,16 +3,17 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use app_units::Au; -use cssparser::{Parser, ToCss, Token}; +use cssparser::{Parser, Token}; use euclid::size::Size2D; use parser::Parse; use std::ascii::AsciiExt; use std::cmp; use std::fmt; use std::ops::Mul; +use style_traits::ToCss; use style_traits::values::specified::AllowedNumericType; use super::{Angle, Number, SimplifiedValueNode, SimplifiedSumNode, Time}; -use values::{CSSFloat, FONT_MEDIUM_PX, HasViewportPercentage, LocalToCss, computed}; +use values::{CSSFloat, FONT_MEDIUM_PX, HasViewportPercentage, computed}; pub use super::image::{AngleOrCorner, ColorStop, EndingShape as GradientEndingShape, Gradient}; pub use super::image::{GradientKind, HorizontalDirection, Image, LengthOrKeyword, LengthOrPercentageOrKeyword}; diff --git a/servo/components/style/values/specified/mod.rs b/servo/components/style/values/specified/mod.rs index 84ad99c6112a..92a8532f52d9 100644 --- a/servo/components/style/values/specified/mod.rs +++ b/servo/components/style/values/specified/mod.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use app_units::Au; -use cssparser::{self, Parser, ToCss, Token}; +use cssparser::{self, Parser, Token}; use euclid::size::Size2D; #[cfg(feature = "gecko")] use gecko_bindings::sugar::refptr::{GeckoArcPrincipal, GeckoArcURI}; @@ -14,6 +14,7 @@ use std::ascii::AsciiExt; use std::f32::consts::PI; use std::fmt; use std::ops::Mul; +use style_traits::ToCss; use super::{CSSFloat, HasViewportPercentage, NoViewportPercentage}; use super::computed::{ComputedValueAsSpecified, Context, ToComputedValue}; use url::Url; @@ -555,7 +556,6 @@ impl NoViewportPercentage for UrlOrNone {} impl ToCss for UrlOrNone { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { - use values::LocalToCss; match *self { UrlOrNone::Url(ref url, _) => { url.to_css(dest) diff --git a/servo/components/style/values/specified/position.rs b/servo/components/style/values/specified/position.rs index bdd6e183ee96..c856a002214d 100644 --- a/servo/components/style/values/specified/position.rs +++ b/servo/components/style/values/specified/position.rs @@ -7,9 +7,10 @@ //! //! [position]: https://drafts.csswg.org/css-backgrounds-3/#position -use cssparser::{Parser, ToCss, Token}; +use cssparser::{Parser, Token}; use parser::Parse; use std::fmt; +use style_traits::ToCss; use values::HasViewportPercentage; use values::computed::{CalcLengthOrPercentage, Context}; use values::computed::{LengthOrPercentage as ComputedLengthOrPercentage, ToComputedValue}; diff --git a/servo/components/style/viewport.rs b/servo/components/style/viewport.rs index 6ae1a72fcbd1..b08109c4af51 100644 --- a/servo/components/style/viewport.rs +++ b/servo/components/style/viewport.rs @@ -9,7 +9,6 @@ use app_units::Au; use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser, parse_important}; -use cssparser::ToCss; use euclid::scale_factor::ScaleFactor; use euclid::size::{Size2D, TypedSize2D}; use media_queries::Device; @@ -20,7 +19,7 @@ use std::borrow::Cow; use std::fmt; use std::iter::Enumerate; use std::str::Chars; -use style_traits::ViewportPx; +use style_traits::{ToCss, ViewportPx}; use style_traits::viewport::{Orientation, UserZoom, ViewportConstraints, Zoom}; use stylesheets::{Stylesheet, Origin}; use values::computed::{Context, ToComputedValue}; diff --git a/servo/components/style_traits/Cargo.toml b/servo/components/style_traits/Cargo.toml index af4c93143819..07bc967e664a 100644 --- a/servo/components/style_traits/Cargo.toml +++ b/servo/components/style_traits/Cargo.toml @@ -22,3 +22,4 @@ heapsize_derive = {version = "0.1", optional = true} rustc-serialize = "0.3" serde = {version = "0.8", optional = true} serde_derive = {version = "0.8", optional = true} +url = "1.2" diff --git a/servo/components/style_traits/cursor.rs b/servo/components/style_traits/cursor.rs index d667b1c3d733..8c1d35463f8d 100644 --- a/servo/components/style_traits/cursor.rs +++ b/servo/components/style_traits/cursor.rs @@ -4,7 +4,7 @@ //! A list of common mouse cursors per CSS3-UI ยง 8.1.1. -use cssparser::ToCss; +use super::ToCss; macro_rules! define_cursor { ($( $css: expr => $variant: ident = $value: expr, )+) => { diff --git a/servo/components/style_traits/lib.rs b/servo/components/style_traits/lib.rs index bd060abf1397..4ddb4e6a8468 100644 --- a/servo/components/style_traits/lib.rs +++ b/servo/components/style_traits/lib.rs @@ -23,6 +23,7 @@ extern crate euclid; extern crate rustc_serialize; #[cfg(feature = "servo")] extern crate serde; #[cfg(feature = "servo")] #[macro_use] extern crate serde_derive; +extern crate url; /// Opaque type stored in type-unsafe work queues for parallel layout. /// Must be transmutable to and from TNode. @@ -61,3 +62,4 @@ pub mod cursor; pub mod values; pub mod viewport; +pub use values::ToCss; diff --git a/servo/components/style_traits/values.rs b/servo/components/style_traits/values.rs index 747c1481bd1b..9e8d6b2a9365 100644 --- a/servo/components/style_traits/values.rs +++ b/servo/components/style_traits/values.rs @@ -2,6 +2,60 @@ * 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 app_units::Au; +use cssparser::CssStringWriter; +use std::fmt::{self, Write}; +use url::Url; + +/// The real ToCss trait can't be implemented for types in crates that don't +/// depend on each other. +pub trait ToCss { + /// Serialize `self` in CSS syntax, writing to `dest`. + fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write; + + /// Serialize `self` in CSS syntax and return a string. + /// + /// (This is a convenience wrapper for `to_css` and probably should not be overridden.) + #[inline] + fn to_css_string(&self) -> String { + let mut s = String::new(); + self.to_css(&mut s).unwrap(); + s + } +} + +impl ToCss for Au { + fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { + write!(dest, "{}px", self.to_f64_px()) + } +} + +impl ToCss for Url { + fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { + try!(dest.write_str("url(\"")); + try!(write!(CssStringWriter::new(dest), "{}", self)); + try!(dest.write_str("\")")); + Ok(()) + } +} + +macro_rules! impl_to_css_for_predefined_type { + ($name: ty) => { + impl<'a> ToCss for $name { + fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { + ::cssparser::ToCss::to_css(self, dest) + } + } + }; +} + +impl_to_css_for_predefined_type!(f32); +impl_to_css_for_predefined_type!(i32); +impl_to_css_for_predefined_type!(u32); +impl_to_css_for_predefined_type!(::cssparser::Token<'a>); +impl_to_css_for_predefined_type!(::cssparser::RGBA); +impl_to_css_for_predefined_type!(::cssparser::Color); + #[macro_export] macro_rules! define_css_keyword_enum { ($name: ident: $( $css: expr => $variant: ident ),+,) => { @@ -50,7 +104,7 @@ macro_rules! __define_css_keyword_enum__actual { } } - impl ::cssparser::ToCss for $name { + impl ToCss for $name { fn to_css(&self, dest: &mut W) -> ::std::fmt::Result where W: ::std::fmt::Write { match *self { @@ -61,7 +115,6 @@ macro_rules! __define_css_keyword_enum__actual { } } - pub mod specified { use app_units::Au; diff --git a/servo/ports/cef/Cargo.lock b/servo/ports/cef/Cargo.lock index a878f114b7b3..b5e3f64ca713 100644 --- a/servo/ports/cef/Cargo.lock +++ b/servo/ports/cef/Cargo.lock @@ -2294,6 +2294,7 @@ dependencies = [ "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/servo/ports/geckolib/Cargo.lock b/servo/ports/geckolib/Cargo.lock index b2a72c417485..2970dba3b3ff 100644 --- a/servo/ports/geckolib/Cargo.lock +++ b/servo/ports/geckolib/Cargo.lock @@ -373,6 +373,7 @@ dependencies = [ "cssparser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/servo/ports/geckolib/glue.rs b/servo/ports/geckolib/glue.rs index 69621115f228..c3c9b856dd46 100644 --- a/servo/ports/geckolib/glue.rs +++ b/servo/ports/geckolib/glue.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use app_units::Au; -use cssparser::{Parser, ToCss}; +use cssparser::Parser; use env_logger; use euclid::Size2D; use parking_lot::RwLock; @@ -46,6 +46,7 @@ use style::sequential; use style::string_cache::Atom; use style::stylesheets::{Origin, Stylesheet}; use style::timer::Timer; +use style_traits::ToCss; use url::Url; /* diff --git a/servo/ports/geckolib/lib.rs b/servo/ports/geckolib/lib.rs index 39e89f0742f6..23a03fa8b7f1 100644 --- a/servo/ports/geckolib/lib.rs +++ b/servo/ports/geckolib/lib.rs @@ -12,6 +12,7 @@ extern crate euclid; extern crate libc; #[macro_use] extern crate log; extern crate parking_lot; +extern crate style_traits; extern crate url; #[allow(non_snake_case)] diff --git a/servo/tests/unit/style/parsing/basic_shape.rs b/servo/tests/unit/style/parsing/basic_shape.rs index da829e7c29d0..6363e7772cac 100644 --- a/servo/tests/unit/style/parsing/basic_shape.rs +++ b/servo/tests/unit/style/parsing/basic_shape.rs @@ -5,6 +5,7 @@ use parsing::parse; use style::parser::Parse; use style::values::specified::basic_shape::*; +use style_traits::ToCss; // Ensure that basic-shape sub-functions parse as both basic shapes // and their individual components @@ -21,14 +22,14 @@ macro_rules! assert_border_radius_values { let input = parse(BorderRadius::parse, $input) .expect(&format!("Failed parsing {} as border radius", $input)); - assert_eq!(::cssparser::ToCss::to_css_string(&input.top_left.0.width), $tlw); - assert_eq!(::cssparser::ToCss::to_css_string(&input.top_right.0.width), $trw); - assert_eq!(::cssparser::ToCss::to_css_string(&input.bottom_right.0.width), $brw); - assert_eq!(::cssparser::ToCss::to_css_string(&input.bottom_left.0.width), $blw); - assert_eq!(::cssparser::ToCss::to_css_string(&input.top_left.0.height), $tlh); - assert_eq!(::cssparser::ToCss::to_css_string(&input.top_right.0.height), $trh); - assert_eq!(::cssparser::ToCss::to_css_string(&input.bottom_right.0.height), $brh); - assert_eq!(::cssparser::ToCss::to_css_string(&input.bottom_left.0.height), $blh); + assert_eq!(::style_traits::ToCss::to_css_string(&input.top_left.0.width), $tlw); + assert_eq!(::style_traits::ToCss::to_css_string(&input.top_right.0.width), $trw); + assert_eq!(::style_traits::ToCss::to_css_string(&input.bottom_right.0.width), $brw); + assert_eq!(::style_traits::ToCss::to_css_string(&input.bottom_left.0.width), $blw); + assert_eq!(::style_traits::ToCss::to_css_string(&input.top_left.0.height), $tlh); + assert_eq!(::style_traits::ToCss::to_css_string(&input.top_right.0.height), $trh); + assert_eq!(::style_traits::ToCss::to_css_string(&input.bottom_right.0.height), $brh); + assert_eq!(::style_traits::ToCss::to_css_string(&input.bottom_left.0.height), $blh); } } diff --git a/servo/tests/unit/style/parsing/font.rs b/servo/tests/unit/style/parsing/font.rs index 1873314dc89b..178a43f6e9b6 100644 --- a/servo/tests/unit/style/parsing/font.rs +++ b/servo/tests/unit/style/parsing/font.rs @@ -9,6 +9,7 @@ use style::properties::longhands::font_feature_settings; use style::properties::longhands::font_feature_settings::computed_value; use style::properties::longhands::font_feature_settings::computed_value::FeatureTagValue; use style::stylesheets::Origin; +use style_traits::ToCss; use url::Url; #[test] @@ -100,7 +101,7 @@ fn font_language_override_should_parse_properly() { #[test] #[should_panic] fn font_language_override_should_fail_on_empty_str() { - use style::properties::longhands::font_language_override::{self, SpecifiedValue}; + use style::properties::longhands::font_language_override; parse_longhand!(font_language_override, ""); } diff --git a/servo/tests/unit/style/parsing/image.rs b/servo/tests/unit/style/parsing/image.rs index 23679196fc5c..d6d8651381e9 100644 --- a/servo/tests/unit/style/parsing/image.rs +++ b/servo/tests/unit/style/parsing/image.rs @@ -7,6 +7,7 @@ use media_queries::CSSErrorReporterTest; use style::parser::ParserContext; use style::stylesheets::Origin; use style::values::specified::image::*; +use style_traits::ToCss; use url::Url; #[test] diff --git a/servo/tests/unit/style/parsing/mod.rs b/servo/tests/unit/style/parsing/mod.rs index 80c6cfff68d9..f2fed25b7fd2 100644 --- a/servo/tests/unit/style/parsing/mod.rs +++ b/servo/tests/unit/style/parsing/mod.rs @@ -21,12 +21,12 @@ macro_rules! assert_roundtrip { ($fun:expr, $input:expr, $output:expr) => { let parsed = $crate::parsing::parse($fun, $input) .expect(&format!("Failed to parse {}", $input)); - let serialized = ::cssparser::ToCss::to_css_string(&parsed); + let serialized = ToCss::to_css_string(&parsed); assert_eq!(serialized, $output); let re_parsed = $crate::parsing::parse($fun, &serialized) .expect(&format!("Failed to parse serialization {}", $input)); - let re_serialized = ::cssparser::ToCss::to_css_string(&re_parsed); + let re_serialized = ToCss::to_css_string(&re_parsed); assert_eq!(serialized, re_serialized); } } @@ -41,13 +41,13 @@ macro_rules! assert_roundtrip_with_context { let mut parser = Parser::new($input); let parsed = $fun(&context, &mut parser) .expect(&format!("Failed to parse {}", $input)); - let serialized = ::cssparser::ToCss::to_css_string(&parsed); + let serialized = ToCss::to_css_string(&parsed); assert_eq!(serialized, $output); let mut parser = Parser::new(&serialized); let re_parsed = $fun(&context, &mut parser) .expect(&format!("Failed to parse {}", $input)); - let re_serialized = ::cssparser::ToCss::to_css_string(&re_parsed); + let re_serialized = ToCss::to_css_string(&re_parsed); assert_eq!(serialized, re_serialized); } } diff --git a/servo/tests/unit/style/parsing/position.rs b/servo/tests/unit/style/parsing/position.rs index f82a09da0d34..17a9e92679d7 100644 --- a/servo/tests/unit/style/parsing/position.rs +++ b/servo/tests/unit/style/parsing/position.rs @@ -4,6 +4,7 @@ use parsing::parse; use style::values::specified::position::*; +use style_traits::ToCss; #[test] fn test_position() { diff --git a/servo/tests/unit/style/parsing/selectors.rs b/servo/tests/unit/style/parsing/selectors.rs index abd1a3b5e9af..f7cb562c274d 100644 --- a/servo/tests/unit/style/parsing/selectors.rs +++ b/servo/tests/unit/style/parsing/selectors.rs @@ -2,7 +2,7 @@ * 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 cssparser::Parser; +use cssparser::{Parser, ToCss}; use selectors::parser::{Selector, ParserContext, parse_selector_list}; use style::selector_impl::TheSelectorImpl; diff --git a/servo/tests/unit/style/properties/serialization.rs b/servo/tests/unit/style/properties/serialization.rs index 20c4d1eba073..3b920059b62f 100644 --- a/servo/tests/unit/style/properties/serialization.rs +++ b/servo/tests/unit/style/properties/serialization.rs @@ -2,7 +2,6 @@ * 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/. */ -pub use cssparser::ToCss; pub use std::sync::Arc; pub use style::computed_values::display::T::inline_block; pub use style::properties::{DeclaredValue, PropertyDeclaration, PropertyDeclarationBlock, Importance}; @@ -11,6 +10,7 @@ pub use style::values::specified::{LengthOrPercentage, LengthOrPercentageOrAuto, pub use style::properties::longhands::outline_color::computed_value::T as ComputedColor; pub use style::values::RGBA; pub use style::values::specified::UrlExtraData; +pub use style_traits::ToCss; pub use url::Url; #[test] diff --git a/servo/tests/unit/stylo/lib.rs b/servo/tests/unit/stylo/lib.rs index 8690c17f5177..03df4957b9aa 100644 --- a/servo/tests/unit/stylo/lib.rs +++ b/servo/tests/unit/stylo/lib.rs @@ -11,6 +11,7 @@ extern crate libc; #[macro_use] extern crate log; extern crate parking_lot; extern crate style; +extern crate style_traits; extern crate url; mod sanity_checks;