mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Prefer Servo-specific ToCss for all types
This commit is contained in:
parent
5dbc8d02c9
commit
6061985898
44 changed files with 149 additions and 161 deletions
|
@ -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<T> Default for ShapeSource<T> {
|
|||
|
||||
impl<T: ToCss> ToCss for ShapeSource<T> {
|
||||
fn to_css<W>(&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)) => {
|
||||
|
|
|
@ -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<W>(&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<W>(&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<LengthOrPercentage>,
|
||||
}
|
||||
|
||||
impl ::cssparser::ToCss for ColorStop {
|
||||
impl ToCss for ColorStop {
|
||||
fn to_css<W>(&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<W>(&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<W>(&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<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
match *self {
|
||||
LengthOrPercentageOrKeyword::LengthOrPercentage(ref first_len, second_len) => {
|
||||
|
|
|
@ -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<LengthOrPercentageOrAuto> for Option<CalcLengthOrPercentage> {
|
|||
}
|
||||
}
|
||||
|
||||
impl ::cssparser::ToCss for CalcLengthOrPercentage {
|
||||
impl ToCss for CalcLengthOrPercentage {
|
||||
fn to_css<W>(&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<W>(&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<W>(&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<W>(&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<W>(&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<W>(&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<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
match *self {
|
||||
LengthOrNumber::Length(len) => len.to_css(dest),
|
||||
|
|
|
@ -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<LengthOrPercentage>);
|
||||
|
@ -139,7 +141,7 @@ impl ToComputedValue for specified::BorderRadiusSize {
|
|||
}
|
||||
}
|
||||
|
||||
impl ::cssparser::ToCss for BorderRadiusSize {
|
||||
impl ToCss for BorderRadiusSize {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
try!(self.0.width.to_css(dest));
|
||||
try!(dest.write_str("/"));
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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<W>(&self, dest: &mut W) -> ::std::fmt::Result
|
||||
where W: ::std::fmt::Write {
|
||||
match *self {
|
||||
|
|
|
@ -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<T> Default for ShapeSource<T> {
|
|||
|
||||
impl<T: ToCss> ToCss for ShapeSource<T> {
|
||||
fn to_css<W>(&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)) => {
|
||||
|
|
|
@ -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<W>(&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)
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
use values::LocalToCss;
|
||||
match *self {
|
||||
UrlOrNone::Url(ref url, _) => {
|
||||
url.to_css(dest)
|
||||
|
|
|
@ -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};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue