Auto merge of #18159 - upsuper:write-to-css, r=nox

Replace write! with to_css and write_str in some ToCss impls

Some of this is necessary for fixing things like [bug 1370779](https://bugzilla.mozilla.org/show_bug.cgi?id=1370779) because otherwise we would still not be using the new numeric serialization algorithm from cssparser crate.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18159)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-08-21 04:14:08 -05:00 committed by GitHub
commit 6a1b0d0526
11 changed files with 58 additions and 42 deletions

View file

@ -32,7 +32,7 @@ use string_cache::Atom;
use style_traits::{CSSPixel, DevicePixel};
use style_traits::{ToCss, ParseError, StyleParseError};
use style_traits::viewport::ViewportConstraints;
use values::{CSSFloat, specified, CustomIdent};
use values::{CSSFloat, specified, CustomIdent, serialize_dimension};
use values::computed::{self, ToComputedValue};
/// The `Device` in Gecko wraps a pres context, has a default values computed,
@ -287,9 +287,9 @@ impl ToCss for Resolution {
where W: fmt::Write,
{
match *self {
Resolution::Dpi(v) => write!(dest, "{}dpi", v),
Resolution::Dppx(v) => write!(dest, "{}dppx", v),
Resolution::Dpcm(v) => write!(dest, "{}dpcm", v),
Resolution::Dpi(v) => serialize_dimension(v, "dpi", dest),
Resolution::Dppx(v) => serialize_dimension(v, "dppx", dest),
Resolution::Dpcm(v) => serialize_dimension(v, "dpcm", dest),
}
}
}
@ -386,8 +386,8 @@ impl MediaExpressionValue {
{
match *self {
MediaExpressionValue::Length(ref l) => l.to_css(dest),
MediaExpressionValue::Integer(v) => write!(dest, "{}", v),
MediaExpressionValue::Float(v) => write!(dest, "{}", v),
MediaExpressionValue::Integer(v) => v.to_css(dest),
MediaExpressionValue::Float(v) => v.to_css(dest),
MediaExpressionValue::BoolInteger(v) => {
dest.write_str(if v { "1" } else { "0" })
},