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:
Anthony Ramine 2018-01-22 19:58:01 +01:00
parent 3672856efa
commit cd8f96cc9e
89 changed files with 873 additions and 533 deletions

View file

@ -4,11 +4,11 @@
//! Helper types for the `@viewport` rule.
use {CSSPixel, PinchZoomFactor, ParseError, ToCss};
use {CSSPixel, CssWriter, ParseError, PinchZoomFactor, ToCss};
use cssparser::Parser;
use euclid::TypedSize2D;
#[allow(unused_imports)] use std::ascii::AsciiExt;
use std::fmt;
use std::fmt::{self, Write};
define_css_keyword_enum!(UserZoom:
"zoom" => Zoom,
@ -42,8 +42,9 @@ pub struct ViewportConstraints {
}
impl ToCss for ViewportConstraints {
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("@viewport { width: ")?;
self.size.width.to_css(dest)?;
@ -86,7 +87,7 @@ pub enum Zoom {
}
impl ToCss for Zoom {
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,
{
match *self {