mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Change ToCss to take a CssWriter<W>
This more concrete wrapper type can write a prefix the very first time something is written to it. This allows removing plenty of useless monomorphisations caused by the former W/SequenceWriter<W> pair of types.
This commit is contained in:
parent
3672856efa
commit
cd8f96cc9e
89 changed files with 873 additions and 533 deletions
|
@ -11,8 +11,8 @@ use gecko_bindings::structs;
|
|||
use parser::{Parse, ParserContext};
|
||||
use selectors::parser::SelectorParseErrorKind;
|
||||
#[allow(unused_imports)] use std::ascii::AsciiExt;
|
||||
use std::fmt;
|
||||
use style_traits::{ToCss, ParseError, StyleParseErrorKind};
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
|
||||
bitflags! {
|
||||
/// Constants shared by multiple CSS Box Alignment properties
|
||||
|
@ -71,7 +71,10 @@ bitflags! {
|
|||
}
|
||||
|
||||
impl ToCss for AlignFlags {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
let s = match *self & !AlignFlags::FLAG_BITS {
|
||||
AlignFlags::AUTO => "auto",
|
||||
AlignFlags::NORMAL => "normal",
|
||||
|
@ -209,7 +212,10 @@ impl AlignJustifyContent {
|
|||
}
|
||||
|
||||
impl ToCss for AlignJustifyContent {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
self.primary().to_css(dest)?;
|
||||
match self.fallback() {
|
||||
AlignFlags::AUTO => {}
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
use cssparser::{Parser, Token};
|
||||
use parser::{ParserContext, Parse};
|
||||
#[allow(unused_imports)] use std::ascii::AsciiExt;
|
||||
use std::fmt;
|
||||
use style_traits::{ToCss, ParseError};
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, ToCss};
|
||||
use values::CSSFloat;
|
||||
use values::computed::{Context, ToComputedValue};
|
||||
use values::computed::angle::Angle as ComputedAngle;
|
||||
|
@ -27,7 +27,10 @@ pub struct Angle {
|
|||
}
|
||||
|
||||
impl ToCss for Angle {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
if self.was_calc {
|
||||
dest.write_str("calc(")?;
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
use cssparser::Parser;
|
||||
use parser::{Parse, ParserContext};
|
||||
use std::borrow::Cow;
|
||||
use std::fmt;
|
||||
use style_traits::{ToCss, ParseError, StyleParseErrorKind};
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
use values::computed::Percentage;
|
||||
use values::generics::basic_shape::{Circle as GenericCircle};
|
||||
use values::generics::basic_shape::{ClippingShape as GenericClippingShape, Ellipse as GenericEllipse};
|
||||
|
@ -171,7 +171,10 @@ impl Circle {
|
|||
}
|
||||
|
||||
impl ToCss for Circle {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
dest.write_str("circle(")?;
|
||||
if GenericShapeRadius::ClosestSide != self.radius {
|
||||
self.radius.to_css(dest)?;
|
||||
|
@ -213,7 +216,10 @@ impl Ellipse {
|
|||
}
|
||||
|
||||
impl ToCss for Ellipse {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
dest.write_str("ellipse(")?;
|
||||
if self.semiaxis_x != ShapeRadius::default() || self.semiaxis_y != ShapeRadius::default() {
|
||||
self.semiaxis_x.to_css(dest)?;
|
||||
|
@ -248,8 +254,12 @@ impl Parse for ShapeRadius {
|
|||
/// are converted to percentages where possible. Only the two or four
|
||||
/// value forms are used. In case of two keyword-percentage pairs,
|
||||
/// the keywords are folded into the percentages
|
||||
fn serialize_basicshape_position<W>(position: &Position, dest: &mut W) -> fmt::Result
|
||||
where W: fmt::Write
|
||||
fn serialize_basicshape_position<W>(
|
||||
position: &Position,
|
||||
dest: &mut CssWriter<W>,
|
||||
) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
fn to_keyword_and_lop<S>(component: &PositionComponent<S>) -> (S, Cow<LengthOrPercentage>)
|
||||
where S: Copy + Side
|
||||
|
@ -289,8 +299,11 @@ fn serialize_basicshape_position<W>(position: &Position, dest: &mut W) -> fmt::R
|
|||
}
|
||||
}
|
||||
|
||||
fn write_pair<A, B, W>(a: &A, b: &B, dest: &mut W) -> fmt::Result
|
||||
where A: ToCss, B: ToCss, W: fmt::Write
|
||||
fn write_pair<A, B, W>(a: &A, b: &B, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
A: ToCss,
|
||||
B: ToCss,
|
||||
W: Write,
|
||||
{
|
||||
a.to_css(dest)?;
|
||||
dest.write_str(" ")?;
|
||||
|
|
|
@ -8,8 +8,8 @@ use Atom;
|
|||
use cssparser::Parser;
|
||||
use parser::{Parse, ParserContext};
|
||||
use selectors::parser::SelectorParseErrorKind;
|
||||
use std::fmt;
|
||||
use style_traits::{ParseError, ToCss, StyleParseErrorKind};
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
use values::CustomIdent;
|
||||
use values::KeyframesName;
|
||||
use values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount;
|
||||
|
@ -289,9 +289,9 @@ impl AnimationName {
|
|||
}
|
||||
|
||||
impl ToCss for AnimationName {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: fmt::Write,
|
||||
W: Write,
|
||||
{
|
||||
match self.0 {
|
||||
Some(ref name) => name.to_css(dest),
|
||||
|
@ -407,7 +407,10 @@ impl TouchAction {
|
|||
}
|
||||
|
||||
impl ToCss for TouchAction {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
match *self {
|
||||
TouchAction::TOUCH_ACTION_NONE => dest.write_str("none"),
|
||||
TouchAction::TOUCH_ACTION_AUTO => dest.write_str("auto"),
|
||||
|
@ -497,7 +500,10 @@ bitflags! {
|
|||
}
|
||||
|
||||
impl ToCss for Contain {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
if self.is_empty() {
|
||||
return dest.write_str("none")
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
use cssparser::{Parser, Token, NumberOrPercentage, AngleOrNumber};
|
||||
use parser::ParserContext;
|
||||
#[allow(unused_imports)] use std::ascii::AsciiExt;
|
||||
use std::fmt;
|
||||
use style_traits::{ToCss, ParseError, StyleParseErrorKind};
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
use style_traits::values::specified::AllowedNumericType;
|
||||
use values::{CSSInteger, CSSFloat};
|
||||
use values::computed;
|
||||
|
@ -89,7 +89,10 @@ impl ToCss for CalcLengthOrPercentage {
|
|||
///
|
||||
/// FIXME(emilio): Should this simplify away zeros?
|
||||
#[allow(unused_assignments)]
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
use num_traits::Zero;
|
||||
|
||||
let mut first_value = true;
|
||||
|
|
|
@ -12,9 +12,9 @@ use itoa;
|
|||
use parser::{ParserContext, Parse};
|
||||
#[cfg(feature = "gecko")]
|
||||
use properties::longhands::system_colors::SystemColor;
|
||||
use std::fmt;
|
||||
use std::io::Write;
|
||||
use style_traits::{ToCss, ParseError, StyleParseErrorKind, ValueParseErrorKind};
|
||||
use std::fmt::{self, Write};
|
||||
use std::io::Write as IoWrite;
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss, ValueParseErrorKind};
|
||||
use super::AllowQuirks;
|
||||
use values::computed::{Color as ComputedColor, Context, ToComputedValue};
|
||||
use values::specified::calc::CalcNode;
|
||||
|
@ -187,7 +187,10 @@ impl Parse for Color {
|
|||
}
|
||||
|
||||
impl ToCss for Color {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
match *self {
|
||||
Color::CurrentColor => CSSParserColor::CurrentColor.to_css(dest),
|
||||
Color::Numeric { authored: Some(ref authored), .. } => dest.write_str(authored),
|
||||
|
|
|
@ -16,8 +16,8 @@ use parser::{Parse, ParserContext};
|
|||
use properties::longhands::system_font::SystemFont;
|
||||
#[allow(unused_imports)]
|
||||
use std::ascii::AsciiExt;
|
||||
use std::fmt;
|
||||
use style_traits::{ToCss, StyleParseErrorKind, ParseError};
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
use values::CustomIdent;
|
||||
use values::computed::{font as computed, Context, Length, NonNegativeLength, ToComputedValue};
|
||||
use values::computed::font::{SingleFontFamily, FontFamilyList, FamilyName};
|
||||
|
@ -144,7 +144,10 @@ pub enum FontSize {
|
|||
}
|
||||
|
||||
impl ToCss for FontSize {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
match *self {
|
||||
FontSize::Length(ref lop) => lop.to_css(dest),
|
||||
FontSize::Keyword(info) => info.kw.to_css(dest),
|
||||
|
@ -243,7 +246,10 @@ impl MallocSizeOf for FontFamily {
|
|||
}
|
||||
|
||||
impl ToCss for FontFamily {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
match *self {
|
||||
FontFamily::Values(ref v) => {
|
||||
let mut iter = v.iter();
|
||||
|
@ -408,7 +414,10 @@ impl Default for KeywordSize {
|
|||
}
|
||||
|
||||
impl ToCss for KeywordSize {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
dest.write_str(match *self {
|
||||
KeywordSize::XXSmall => "xx-small",
|
||||
KeywordSize::XSmall => "x-small",
|
||||
|
@ -824,7 +833,10 @@ impl VariantAlternatesList {
|
|||
}
|
||||
|
||||
impl ToCss for VariantAlternatesList {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
if self.0.is_empty() {
|
||||
return dest.write_str("normal");
|
||||
}
|
||||
|
@ -1031,7 +1043,10 @@ impl VariantEastAsian {
|
|||
}
|
||||
|
||||
impl ToCss for VariantEastAsian {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
if self.is_empty() {
|
||||
return dest.write_str("normal")
|
||||
}
|
||||
|
@ -1265,7 +1280,10 @@ impl VariantLigatures {
|
|||
}
|
||||
|
||||
impl ToCss for VariantLigatures {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
if self.is_empty() {
|
||||
return dest.write_str("normal")
|
||||
}
|
||||
|
@ -1506,7 +1524,10 @@ impl VariantNumeric {
|
|||
}
|
||||
|
||||
impl ToCss for VariantNumeric {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
if self.is_empty() {
|
||||
return dest.write_str("normal")
|
||||
}
|
||||
|
@ -1801,7 +1822,10 @@ impl Parse for FontSynthesis {
|
|||
}
|
||||
|
||||
impl ToCss for FontSynthesis {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
if self.weight && self.style {
|
||||
dest.write_str("weight style")
|
||||
} else if self.style {
|
||||
|
@ -1953,7 +1977,10 @@ impl Parse for XTextZoom {
|
|||
}
|
||||
|
||||
impl ToCss for XTextZoom {
|
||||
fn to_css<W>(&self, _: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, _: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -1981,7 +2008,10 @@ impl Parse for XLang {
|
|||
}
|
||||
|
||||
impl ToCss for XLang {
|
||||
fn to_css<W>(&self, _: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, _: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ use selectors::parser::SelectorParseErrorKind;
|
|||
use servo_url::ServoUrl;
|
||||
use std::cmp::Ordering;
|
||||
use std::f32::consts::PI;
|
||||
use std::fmt;
|
||||
use style_traits::{ToCss, ParseError, StyleParseErrorKind};
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
use values::{Either, None_};
|
||||
#[cfg(feature = "gecko")]
|
||||
use values::computed::{Context, Position as ComputedPosition, ToComputedValue};
|
||||
|
@ -659,8 +659,13 @@ impl GenericsLineDirection for LineDirection {
|
|||
}
|
||||
}
|
||||
|
||||
fn to_css<W>(&self, dest: &mut W, compat_mode: CompatMode) -> fmt::Result
|
||||
where W: fmt::Write
|
||||
fn to_css<W>(
|
||||
&self,
|
||||
dest: &mut CssWriter<W>,
|
||||
compat_mode: CompatMode,
|
||||
) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
match *self {
|
||||
LineDirection::Angle(angle) => {
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
use cssparser::Parser;
|
||||
use parser::{Parse, ParserContext};
|
||||
use std::f64::consts::PI;
|
||||
use std::fmt;
|
||||
use style_traits::{ParseError, StyleParseErrorKind, ToCss};
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
use values::computed;
|
||||
use values::computed::{Context, Orientation, ToComputedValue};
|
||||
use values::specified::Angle;
|
||||
|
@ -25,7 +25,10 @@ pub struct ImageOrientation {
|
|||
}
|
||||
|
||||
impl ToCss for ImageOrientation {
|
||||
fn to_css<W: fmt::Write>(&self, dest: &mut W) -> fmt::Result {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
if let Some(angle) = self.angle {
|
||||
angle.to_css(dest)?;
|
||||
if self.flipped {
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
use cssparser::{Parser, Token};
|
||||
use parser::{Parse, ParserContext};
|
||||
use std::fmt;
|
||||
use style_traits::{ParseError, StyleParseErrorKind, ToCss};
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
use values::{Either, None_};
|
||||
#[cfg(feature = "gecko")]
|
||||
use values::CustomIdent;
|
||||
|
@ -114,7 +114,10 @@ impl Parse for ListStyleImage {
|
|||
pub struct Quotes(pub Box<[(Box<str>, Box<str>)]>);
|
||||
|
||||
impl ToCss for Quotes {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
let mut iter = self.0.iter();
|
||||
|
||||
match iter.next() {
|
||||
|
|
|
@ -13,8 +13,8 @@ use parser::{ParserContext, Parse};
|
|||
use self::url::SpecifiedUrl;
|
||||
#[allow(unused_imports)] use std::ascii::AsciiExt;
|
||||
use std::f32;
|
||||
use std::fmt;
|
||||
use style_traits::{ToCss, ParseError, StyleParseErrorKind};
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
use style_traits::values::specified::AllowedNumericType;
|
||||
use super::{Auto, CSSFloat, CSSInteger, Either, None_};
|
||||
use super::computed::{Context, ToComputedValue};
|
||||
|
@ -250,8 +250,9 @@ impl ToComputedValue for Number {
|
|||
}
|
||||
|
||||
impl ToCss for Number {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
|
||||
where W: fmt::Write,
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
if self.calc_clamping_mode.is_some() {
|
||||
dest.write_str("calc(")?;
|
||||
|
@ -476,8 +477,9 @@ impl ToComputedValue for Integer {
|
|||
}
|
||||
|
||||
impl ToCss for Integer {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
|
||||
where W: fmt::Write,
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
if self.was_calc {
|
||||
dest.write_str("calc(")?;
|
||||
|
@ -560,7 +562,10 @@ pub struct ClipRect {
|
|||
|
||||
|
||||
impl ToCss for ClipRect {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
dest.write_str("rect(")?;
|
||||
|
||||
if let Some(ref top) = self.top {
|
||||
|
@ -805,7 +810,10 @@ impl Attr {
|
|||
}
|
||||
|
||||
impl ToCss for Attr {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
dest.write_str("attr(")?;
|
||||
if let Some(ref ns) = self.namespace {
|
||||
serialize_identifier(&ns.0.to_string(), dest)?;
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
use cssparser::{Parser, Token};
|
||||
use parser::{Parse, ParserContext};
|
||||
#[allow(unused_imports)] use std::ascii::AsciiExt;
|
||||
use std::fmt;
|
||||
use style_traits::{ParseError, ToCss};
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, ToCss};
|
||||
use style_traits::values::specified::AllowedNumericType;
|
||||
use values::{CSSFloat, serialize_percentage};
|
||||
use values::computed::{Context, ToComputedValue};
|
||||
|
@ -29,8 +29,9 @@ pub struct Percentage {
|
|||
|
||||
|
||||
impl ToCss for Percentage {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
|
||||
where W: fmt::Write,
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
if self.calc_clamping_mode.is_some() {
|
||||
dest.write_str("calc(")?;
|
||||
|
|
|
@ -11,10 +11,10 @@ use cssparser::Parser;
|
|||
use hash::FnvHashMap;
|
||||
use parser::{Parse, ParserContext};
|
||||
use selectors::parser::SelectorParseErrorKind;
|
||||
use std::fmt;
|
||||
use std::fmt::{self, Write};
|
||||
use std::ops::Range;
|
||||
use str::HTML_SPACE_CHARACTERS;
|
||||
use style_traits::{ToCss, StyleParseErrorKind, ParseError};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
use values::{Either, None_};
|
||||
use values::computed::{CalcLengthOrPercentage, LengthOrPercentage as ComputedLengthOrPercentage};
|
||||
use values::computed::{Context, Percentage, ToComputedValue};
|
||||
|
@ -142,7 +142,10 @@ impl Position {
|
|||
}
|
||||
|
||||
impl ToCss for Position {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
match (&self.horizontal, &self.vertical) {
|
||||
(x_pos @ &PositionComponent::Side(_, Some(_)), &PositionComponent::Length(ref y_lop)) => {
|
||||
x_pos.to_css(dest)?;
|
||||
|
@ -369,7 +372,10 @@ impl LegacyPosition {
|
|||
}
|
||||
|
||||
impl ToCss for LegacyPosition {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
self.horizontal.to_css(dest)?;
|
||||
dest.write_str(" ")?;
|
||||
self.vertical.to_css(dest)
|
||||
|
@ -409,7 +415,10 @@ impl GridAutoFlow {
|
|||
}
|
||||
|
||||
impl ToCss for GridAutoFlow {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
self.autoflow.to_css(dest)?;
|
||||
|
||||
if self.dense { dest.write_str(" dense")?; }
|
||||
|
@ -584,7 +593,10 @@ impl TemplateAreas {
|
|||
}
|
||||
|
||||
impl ToCss for TemplateAreas {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
for (i, string) in self.strings.iter().enumerate() {
|
||||
if i != 0 {
|
||||
dest.write_str(" ")?;
|
||||
|
|
|
@ -6,8 +6,9 @@
|
|||
|
||||
use cssparser::Parser;
|
||||
use parser::{Parse, ParserContext};
|
||||
use std::fmt;
|
||||
use style_traits::{CommaWithSpace, ParseError, Separator, StyleParseErrorKind, ToCss};
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CommaWithSpace, CssWriter, ParseError, Separator};
|
||||
use style_traits::{StyleParseErrorKind, ToCss};
|
||||
use values::CustomIdent;
|
||||
use values::generics::svg as generic;
|
||||
use values::specified::{LengthOrPercentage, NonNegativeLengthOrPercentage, NonNegativeNumber};
|
||||
|
@ -237,7 +238,10 @@ impl Parse for SVGPaintOrder {
|
|||
}
|
||||
|
||||
impl ToCss for SVGPaintOrder {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
if self.0 == 0 {
|
||||
return dest.write_str("normal")
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
use cssparser::Parser;
|
||||
use parser::{Parse, ParserContext};
|
||||
use std::fmt;
|
||||
use style_traits::{ToCss, StyleParseErrorKind, ParseError};
|
||||
use style_traits::{CssWriter, ToCss, StyleParseErrorKind, ParseError};
|
||||
|
||||
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue)]
|
||||
/// span. for `<col span>` pres attr
|
||||
|
@ -21,7 +21,7 @@ impl Parse for XSpan {
|
|||
}
|
||||
|
||||
impl ToCss for XSpan {
|
||||
fn to_css<W>(&self, _: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, _: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ use cssparser::{Parser, Token};
|
|||
use parser::{Parse, ParserContext};
|
||||
use selectors::parser::SelectorParseErrorKind;
|
||||
#[allow(unused_imports)] use std::ascii::AsciiExt;
|
||||
use std::fmt;
|
||||
use style_traits::{ParseError, StyleParseErrorKind, ToCss};
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
use values::computed::{Context, ToComputedValue};
|
||||
use values::computed::text::LineHeight as ComputedLineHeight;
|
||||
use values::computed::text::TextOverflow as ComputedTextOverflow;
|
||||
|
@ -440,7 +440,10 @@ impl Parse for TextAlign {
|
|||
}
|
||||
|
||||
impl ToCss for TextAlign {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
match *self {
|
||||
TextAlign::Keyword(key) => key.to_css(dest),
|
||||
#[cfg(feature = "gecko")]
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
use cssparser::{Parser, Token};
|
||||
use parser::{ParserContext, Parse};
|
||||
#[allow(unused_imports)] use std::ascii::AsciiExt;
|
||||
use std::fmt;
|
||||
use style_traits::{ToCss, ParseError, StyleParseErrorKind};
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
use style_traits::values::specified::AllowedNumericType;
|
||||
use values::CSSFloat;
|
||||
use values::computed::{Context, ToComputedValue};
|
||||
|
@ -133,9 +133,9 @@ impl Parse for Time {
|
|||
}
|
||||
|
||||
impl ToCss for Time {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: fmt::Write,
|
||||
W: Write,
|
||||
{
|
||||
if self.was_calc {
|
||||
dest.write_str("calc(")?;
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
use cssparser::Parser;
|
||||
use parser::{Parse, ParserContext};
|
||||
use std::fmt;
|
||||
use style_traits::{ParseError, StyleParseErrorKind, ToCss};
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
|
||||
/// Specified value of `-moz-force-broken-image-icon`
|
||||
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue)]
|
||||
|
@ -36,7 +36,10 @@ impl Parse for MozForceBrokenImageIcon {
|
|||
}
|
||||
|
||||
impl ToCss for MozForceBrokenImageIcon {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
dest.write_str(if self.0 { "1" } else { "0" })
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue