Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make use of Servo-specific ToCss everywhere! #14089

Merged
merged 3 commits into from Nov 7, 2016
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prefer Servo-specific ToCss for all types

  • Loading branch information
wafflespeanut committed Nov 7, 2016
commit 606198589803fd22f2bcc37a69ff9c5ef2223490
@@ -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};

@@ -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]
@@ -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),
@@ -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;
@@ -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;
@@ -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;


@@ -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;
@@ -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:
@@ -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};
@@ -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>

<%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 {
@@ -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};

@@ -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<W>(&self, dest: &mut W) -> ::std::fmt::Result
where W: ::std::fmt::Write {
match *self {
@@ -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 {
@@ -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<W>(&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>

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

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.