diff --git a/components/layout/query.rs b/components/layout/query.rs index f313010118cf..706a8fb3855b 100644 --- a/components/layout/query.rs +++ b/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/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs index c7b607b8ae27..6af36d4614ce 100644 --- a/components/script/dom/cssstyledeclaration.rs +++ b/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/components/script/dom/mediaquerylist.rs b/components/script/dom/mediaquerylist.rs index 3c6215b883f9..b5007d9fe837 100644 --- a/components/script/dom/mediaquerylist.rs +++ b/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/components/style/custom_properties.rs b/components/style/custom_properties.rs index 9ced8a671681..0f12f841420e 100644 --- a/components/style/custom_properties.rs +++ b/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/components/style/lib.rs b/components/style/lib.rs index a398760bd68e..c6010def3743 100644 --- a/components/style/lib.rs +++ b/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/components/style/media_queries.rs b/components/style/media_queries.rs index b8df4c0cf61f..30609403925b 100644 --- a/components/style/media_queries.rs +++ b/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/components/style/properties/declaration_block.rs b/components/style/properties/declaration_block.rs index 25d48a1cb558..5ba7f52db14e 100644 --- a/components/style/properties/declaration_block.rs +++ b/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/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index 89ef5229882b..fe7bac7efe9a 100644 --- a/components/style/properties/helpers.mako.rs +++ b/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/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index fdd3db944b37..8b8e3c0b92f9 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/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/components/style/properties/longhand/background.mako.rs b/components/style/properties/longhand/background.mako.rs index 4c0bee3dfe64..cb814a0adea5 100644 --- a/components/style/properties/longhand/background.mako.rs +++ b/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/components/style/properties/longhand/border.mako.rs b/components/style/properties/longhand/border.mako.rs index 73795afd844c..b0b8d0701ad0 100644 --- a/components/style/properties/longhand/border.mako.rs +++ b/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/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index b1e19239c9f1..fb843144c363 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/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/components/style/properties/longhand/column.mako.rs b/components/style/properties/longhand/column.mako.rs index 6c82cee77f97..88272435972a 100644 --- a/components/style/properties/longhand/column.mako.rs +++ b/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/components/style/properties/longhand/counters.mako.rs b/components/style/properties/longhand/counters.mako.rs index d20c3f8aab03..521cb20cd4a5 100644 --- a/components/style/properties/longhand/counters.mako.rs +++ b/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/components/style/properties/longhand/effects.mako.rs b/components/style/properties/longhand/effects.mako.rs index d9a70f4b574c..5949bc48704e 100644 --- a/components/style/properties/longhand/effects.mako.rs +++ b/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/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs index bcd34d4c4e28..01d8621661c6 100644 --- a/components/style/properties/longhand/font.mako.rs +++ b/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/components/style/properties/longhand/inherited_box.mako.rs b/components/style/properties/longhand/inherited_box.mako.rs index d03b38cf6f0a..15b65ee418df 100644 --- a/components/style/properties/longhand/inherited_box.mako.rs +++ b/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/components/style/properties/longhand/inherited_table.mako.rs b/components/style/properties/longhand/inherited_table.mako.rs index 18e6bd76e93a..a8b3e6f89135 100644 --- a/components/style/properties/longhand/inherited_table.mako.rs +++ b/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/components/style/properties/longhand/inherited_text.mako.rs b/components/style/properties/longhand/inherited_text.mako.rs index e775c3d588d6..e622dabe2b93 100644 --- a/components/style/properties/longhand/inherited_text.mako.rs +++ b/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/components/style/properties/longhand/list.mako.rs b/components/style/properties/longhand/list.mako.rs index b8afa7e92494..f237e4b0e034 100644 --- a/components/style/properties/longhand/list.mako.rs +++ b/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/components/style/properties/longhand/outline.mako.rs b/components/style/properties/longhand/outline.mako.rs index 2d55e1592c53..5f4c12a0772d 100644 --- a/components/style/properties/longhand/outline.mako.rs +++ b/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/components/style/properties/longhand/pointing.mako.rs b/components/style/properties/longhand/pointing.mako.rs index 2214b69038d9..f140b32336e3 100644 --- a/components/style/properties/longhand/pointing.mako.rs +++ b/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/components/style/properties/longhand/position.mako.rs b/components/style/properties/longhand/position.mako.rs index c249ea51bed8..a3166ea82388 100644 --- a/components/style/properties/longhand/position.mako.rs +++ b/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/components/style/properties/longhand/svg.mako.rs b/components/style/properties/longhand/svg.mako.rs index cd7409cc1c7b..9d6667a8d979 100644 --- a/components/style/properties/longhand/svg.mako.rs +++ b/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/components/style/properties/longhand/text.mako.rs b/components/style/properties/longhand/text.mako.rs index b983877cb30c..d10850400fac 100644 --- a/components/style/properties/longhand/text.mako.rs +++ b/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/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 9ae5a2f8e46c..ca72c0c38aa1 100644 --- a/components/style/properties/properties.mako.rs +++ b/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/components/style/properties/shorthand/serialize.mako.rs b/components/style/properties/shorthand/serialize.mako.rs index 4fa05dedc45d..e061796b80da 100644 --- a/components/style/properties/shorthand/serialize.mako.rs +++ b/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/components/style/values/computed/basic_shape.rs b/components/style/values/computed/basic_shape.rs index f9dd1f6609d4..d27fe94545b7 100644 --- a/components/style/values/computed/basic_shape.rs +++ b/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/components/style/values/computed/image.rs b/components/style/values/computed/image.rs index d92ed0689dc7..4b825d1fbdd7 100644 --- a/components/style/values/computed/image.rs +++ b/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/components/style/values/computed/length.rs b/components/style/values/computed/length.rs index 204c6071ce83..5d3044c3ac7e 100644 --- a/components/style/values/computed/length.rs +++ b/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/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index 6307c8b06a53..c73fcd73e83c 100644 --- a/components/style/values/computed/mod.rs +++ b/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/components/style/values/computed/position.rs b/components/style/values/computed/position.rs index 635b03944b87..d2a561639f42 100644 --- a/components/style/values/computed/position.rs +++ b/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/components/style/values/mod.rs b/components/style/values/mod.rs index 79be8f7bd50b..46d7b304d0b3 100644 --- a/components/style/values/mod.rs +++ b/components/style/values/mod.rs @@ -7,7 +7,6 @@ //! [values]: https://drafts.csswg.org/css-values/ pub use cssparser::RGBA; -pub use style_traits::ToCss as LocalToCss; macro_rules! define_numbered_css_keyword_enum { ($name: ident: $( $css: expr => $variant: ident = $value: expr ),+,) => { @@ -30,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 { diff --git a/components/style/values/specified/basic_shape.rs b/components/style/values/specified/basic_shape.rs index ad100a33b6a8..6f5bdb039531 100644 --- a/components/style/values/specified/basic_shape.rs +++ b/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/components/style/values/specified/image.rs b/components/style/values/specified/image.rs index 3625d5394ca0..f6a64ba3c3b7 100644 --- a/components/style/values/specified/image.rs +++ b/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/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index bcd320da425c..a0ed172cab14 100644 --- a/components/style/values/specified/length.rs +++ b/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/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 84ad99c6112a..92a8532f52d9 100644 --- a/components/style/values/specified/mod.rs +++ b/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/components/style/values/specified/position.rs b/components/style/values/specified/position.rs index bdd6e183ee96..c856a002214d 100644 --- a/components/style/values/specified/position.rs +++ b/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/components/style/viewport.rs b/components/style/viewport.rs index 6ae1a72fcbd1..b08109c4af51 100644 --- a/components/style/viewport.rs +++ b/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/components/style_traits/cursor.rs b/components/style_traits/cursor.rs index d667b1c3d733..8c1d35463f8d 100644 --- a/components/style_traits/cursor.rs +++ b/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/components/style_traits/values.rs b/components/style_traits/values.rs index 5982b8695e8e..9e8d6b2a9365 100644 --- a/components/style_traits/values.rs +++ b/components/style_traits/values.rs @@ -49,6 +49,13 @@ macro_rules! impl_to_css_for_predefined_type { }; } +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 ),+,) => { @@ -97,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 { diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index 173cd20bbed8..2b08e61aaa2c 100644 --- a/ports/cef/Cargo.lock +++ b/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/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 69621115f228..c3c9b856dd46 100644 --- a/ports/geckolib/glue.rs +++ b/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/ports/geckolib/lib.rs b/ports/geckolib/lib.rs index 39e89f0742f6..23a03fa8b7f1 100644 --- a/ports/geckolib/lib.rs +++ b/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)]