Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Prefer Servo-specific ToCss for all types
  • Loading branch information
wafflespeanut committed Nov 7, 2016
1 parent 5dbc8d0 commit 6061985
Show file tree
Hide file tree
Showing 44 changed files with 149 additions and 161 deletions.
2 changes: 1 addition & 1 deletion components/layout/query.rs
Expand Up @@ -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};

Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/cssstyledeclaration.rs
Expand Up @@ -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;
Expand All @@ -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]
Expand Down
3 changes: 1 addition & 2 deletions components/script/dom/mediaquerylist.rs
Expand Up @@ -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;
Expand All @@ -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),
Expand Down
3 changes: 2 additions & 1 deletion components/style/custom_properties.rs
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion components/style/lib.rs
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions components/style/media_queries.rs
Expand Up @@ -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;


Expand Down
3 changes: 2 additions & 1 deletion components/style/properties/declaration_block.rs
Expand Up @@ -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;
Expand Down
8 changes: 5 additions & 3 deletions components/style/properties/helpers.mako.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)},
Expand Down Expand Up @@ -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))]
Expand Down Expand Up @@ -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:
Expand Down
Expand Up @@ -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;
Expand All @@ -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};
Expand Down
9 changes: 4 additions & 5 deletions components/style/properties/longhand/background.mako.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -88,9 +87,8 @@ ${helpers.predefined_type("background-color", "CSSColor",
</%helpers:vector_longhand>

<%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;

Expand Down Expand Up @@ -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 {
Expand Down
17 changes: 6 additions & 11 deletions components/style/properties/longhand/border.mako.rs
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {}
Expand Down Expand Up @@ -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};

Expand Down Expand Up @@ -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};

Expand Down
30 changes: 15 additions & 15 deletions components/style/properties/longhand/box.mako.rs
Expand Up @@ -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))]
Expand All @@ -41,7 +42,7 @@
% endfor
}

impl ::cssparser::ToCss for T {
impl ToCss for T {
fn to_css<W>(&self, dest: &mut W) -> ::std::fmt::Result
where W: ::std::fmt::Write {
match *self {
Expand Down Expand Up @@ -148,16 +149,16 @@ ${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",
"baseline sub super top text-top middle bottom text-bottom",
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 {
Expand Down Expand Up @@ -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)]
Expand All @@ -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<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
match *self {
% for keyword in vertical_align_keywords:
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -842,9 +843,8 @@ ${helpers.keyword_list("animation-fill-mode",
</%helpers:longhand>

<%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;

Expand Down

0 comments on commit 6061985

Please sign in to comment.