aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2017-09-02 19:11:44 +0200
committerSimon Sapin <simon.sapin@exyr.org>2017-09-04 19:01:43 +0200
commit5d06c9959f9c9035d6dd419a87184d96bf033f08 (patch)
tree5a6182c319fdd50a4cb016311b5086b82bd8b471
parentfae2da0f5913a55ae0e5820db25169a52b6e8637 (diff)
downloadservo-5d06c9959f9c9035d6dd419a87184d96bf033f08.tar.gz
servo-5d06c9959f9c9035d6dd419a87184d96bf033f08.zip
Replace some more uses of `write!` in components/style
-rw-r--r--components/style/counter_style/mod.rs5
-rw-r--r--components/style/gecko/media_queries.rs4
-rw-r--r--components/style/gecko/selector_parser.rs6
-rw-r--r--components/style/macros.rs2
-rw-r--r--components/style/media_queries.rs8
-rw-r--r--components/style/properties/longhand/font.mako.rs2
-rw-r--r--components/style/servo/media_queries.rs13
-rw-r--r--components/style/stylesheets/font_feature_values_rule.rs13
-rw-r--r--components/style/stylesheets/keyframes_rule.rs2
-rw-r--r--components/style/stylesheets/viewport_rule.rs2
-rw-r--r--tests/wpt/mozilla/meta/MANIFEST.json2
-rw-r--r--tests/wpt/mozilla/tests/mozilla/calc.html2
12 files changed, 33 insertions, 28 deletions
diff --git a/components/style/counter_style/mod.rs b/components/style/counter_style/mod.rs
index d7ca421b574..094f14a1cdc 100644
--- a/components/style/counter_style/mod.rs
+++ b/components/style/counter_style/mod.rs
@@ -327,7 +327,8 @@ impl ToCss for System {
System::Additive => dest.write_str("additive"),
System::Fixed { first_symbol_value } => {
if let Some(value) = first_symbol_value {
- write!(dest, "fixed {}", value)
+ dest.write_str("fixed ")?;
+ value.to_css(dest)
} else {
dest.write_str("fixed")
}
@@ -455,7 +456,7 @@ where W: fmt::Write {
fn bound_to_css<W>(range: Option<i32>, dest: &mut W) -> fmt::Result where W: fmt::Write {
if let Some(finite) = range {
- write!(dest, "{}", finite)
+ finite.to_css(dest)
} else {
dest.write_str("infinite")
}
diff --git a/components/style/gecko/media_queries.rs b/components/style/gecko/media_queries.rs
index 83935752697..2c0cadce5ed 100644
--- a/components/style/gecko/media_queries.rs
+++ b/components/style/gecko/media_queries.rs
@@ -398,7 +398,9 @@ impl MediaExpressionValue {
dest.write_str(if v { "1" } else { "0" })
},
MediaExpressionValue::IntRatio(a, b) => {
- write!(dest, "{}/{}", a, b)
+ a.to_css(dest)?;
+ dest.write_char('/')?;
+ b.to_css(dest)
},
MediaExpressionValue::Resolution(ref r) => r.to_css(dest),
MediaExpressionValue::Ident(ref ident) => {
diff --git a/components/style/gecko/selector_parser.rs b/components/style/gecko/selector_parser.rs
index 8000c0af5f4..7fdd75f5d5f 100644
--- a/components/style/gecko/selector_parser.rs
+++ b/components/style/gecko/selector_parser.rs
@@ -70,7 +70,7 @@ impl ToCss for NonTSPseudoClass {
match *self {
$(NonTSPseudoClass::$name => concat!(":", $css),)*
$(NonTSPseudoClass::$s_name(ref s) => {
- write!(dest, ":{}(", $s_css)?;
+ dest.write_str(concat!(":", $s_css, "("))?;
{
// FIXME(emilio): Avoid the extra allocation!
let mut css = CssStringWriter::new(dest);
@@ -84,7 +84,9 @@ impl ToCss for NonTSPseudoClass {
$(NonTSPseudoClass::$k_name(ref s) => {
// Don't include the terminating nul.
let value = String::from_utf16(&s[..s.len() - 1]).unwrap();
- return write!(dest, ":{}({})", $k_css, value)
+ dest.write_str(concat!(":", $k_css, "("))?;
+ dest.write_str(&value)?;
+ return dest.write_char(')')
}, )*
NonTSPseudoClass::MozAny(ref selectors) => {
dest.write_str(":-moz-any(")?;
diff --git a/components/style/macros.rs b/components/style/macros.rs
index 12be15a182a..390a7c89538 100644
--- a/components/style/macros.rs
+++ b/components/style/macros.rs
@@ -88,7 +88,7 @@ macro_rules! define_keyword_type {
impl fmt::Debug for $name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, $css)
+ f.write_str($css)
}
}
diff --git a/components/style/media_queries.rs b/components/style/media_queries.rs
index aef18a989fa..dd90a30088c 100644
--- a/components/style/media_queries.rs
+++ b/components/style/media_queries.rs
@@ -96,7 +96,7 @@ impl ToCss for MediaQuery {
{
if let Some(qual) = self.qualifier {
qual.to_css(dest)?;
- write!(dest, " ")?;
+ dest.write_char(' ')?;
}
match self.media_type {
@@ -107,7 +107,7 @@ impl ToCss for MediaQuery {
// Otherwise, we'd serialize media queries like "(min-width:
// 40px)" in "all (min-width: 40px)", which is unexpected.
if self.qualifier.is_some() || self.expressions.is_empty() {
- write!(dest, "all")?;
+ dest.write_str("all")?;
}
},
MediaQueryType::Concrete(MediaType(ref desc)) => desc.to_css(dest)?,
@@ -118,13 +118,13 @@ impl ToCss for MediaQuery {
}
if self.media_type != MediaQueryType::All || self.qualifier.is_some() {
- write!(dest, " and ")?;
+ dest.write_str(" and ")?;
}
self.expressions[0].to_css(dest)?;
for expr in self.expressions.iter().skip(1) {
- write!(dest, " and ")?;
+ dest.write_str(" and ")?;
expr.to_css(dest)?;
}
Ok(())
diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs
index c95ea97c2f7..9ced9950015 100644
--- a/components/style/properties/longhand/font.mako.rs
+++ b/components/style/properties/longhand/font.mako.rs
@@ -273,7 +273,7 @@ macro_rules! impl_gecko_keyword_conversions {
% if product == "gecko":
// We should treat -moz-fixed as monospace
if name == &atom!("-moz-fixed") {
- return write!(dest, "monospace");
+ return dest.write_str("monospace");
}
% endif
diff --git a/components/style/servo/media_queries.rs b/components/style/servo/media_queries.rs
index 437a7332240..43e38554a32 100644
--- a/components/style/servo/media_queries.rs
+++ b/components/style/servo/media_queries.rs
@@ -215,15 +215,14 @@ impl ToCss for Expression {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
where W: fmt::Write,
{
- write!(dest, "(")?;
- let (mm, l) = match self.0 {
- ExpressionKind::Width(Range::Min(ref l)) => ("min-", l),
- ExpressionKind::Width(Range::Max(ref l)) => ("max-", l),
- ExpressionKind::Width(Range::Eq(ref l)) => ("", l),
+ let (s, l) = match self.0 {
+ ExpressionKind::Width(Range::Min(ref l)) => ("(min-width: ", l),
+ ExpressionKind::Width(Range::Max(ref l)) => ("(max-width: ", l),
+ ExpressionKind::Width(Range::Eq(ref l)) => ("(width: ", l),
};
- write!(dest, "{}width: ", mm)?;
+ dest.write_str(s)?;
l.to_css(dest)?;
- write!(dest, ")")
+ dest.write_char(')')
}
}
diff --git a/components/style/stylesheets/font_feature_values_rule.rs b/components/style/stylesheets/font_feature_values_rule.rs
index d27a8ab2118..57fc9ccc786 100644
--- a/components/style/stylesheets/font_feature_values_rule.rs
+++ b/components/style/stylesheets/font_feature_values_rule.rs
@@ -68,7 +68,7 @@ impl Parse for SingleValue {
impl ToCss for SingleValue {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
- write!(dest, "{}", self.0)
+ self.0.to_css(dest)
}
}
@@ -105,9 +105,10 @@ impl Parse for PairValues {
impl ToCss for PairValues {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
- write!(dest, "{}", self.0)?;
+ self.0.to_css(dest)?;
if let Some(second) = self.1 {
- write!(dest, " {}", second)?;
+ dest.write_char(' ')?;
+ second.to_css(dest)?;
}
Ok(())
}
@@ -158,10 +159,10 @@ impl ToCss for VectorValues {
let mut iter = self.0.iter();
let first = iter.next();
if let Some(first) = first {
- write!(dest, "{}", first)?;
+ first.to_css(dest)?;
for value in iter {
- dest.write_str(" ")?;
- write!(dest, "{}", value)?;
+ dest.write_char(' ')?;
+ value.to_css(dest)?;
}
}
Ok(())
diff --git a/components/style/stylesheets/keyframes_rule.rs b/components/style/stylesheets/keyframes_rule.rs
index 6c860003b7e..02fe37bd245 100644
--- a/components/style/stylesheets/keyframes_rule.rs
+++ b/components/style/stylesheets/keyframes_rule.rs
@@ -155,7 +155,7 @@ impl ToCss for KeyframeSelector {
let mut iter = self.0.iter();
iter.next().unwrap().to_css(dest)?;
for percentage in iter {
- write!(dest, ", ")?;
+ dest.write_str(", ")?;
percentage.to_css(dest)?;
}
Ok(())
diff --git a/components/style/stylesheets/viewport_rule.rs b/components/style/stylesheets/viewport_rule.rs
index 98cb8c5b384..22d41f992e0 100644
--- a/components/style/stylesheets/viewport_rule.rs
+++ b/components/style/stylesheets/viewport_rule.rs
@@ -151,7 +151,7 @@ impl ToCss for ViewportLength {
{
match *self {
ViewportLength::Specified(ref length) => length.to_css(dest),
- ViewportLength::ExtendToZoom => write!(dest, "extend-to-zoom"),
+ ViewportLength::ExtendToZoom => dest.write_str("extend-to-zoom"),
}
}
}
diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json
index 9f05336e1b5..aefc972e566 100644
--- a/tests/wpt/mozilla/meta/MANIFEST.json
+++ b/tests/wpt/mozilla/meta/MANIFEST.json
@@ -26524,7 +26524,7 @@
"testharness"
],
"mozilla/calc.html": [
- "5b3ea33205a9f2404bd6976a2c7f6fc451be8e96",
+ "4f65929cacf623da2d3e310a6663d6165a1b0cdc",
"testharness"
],
"mozilla/canvas.initial.reset.2dstate.html": [
diff --git a/tests/wpt/mozilla/tests/mozilla/calc.html b/tests/wpt/mozilla/tests/mozilla/calc.html
index 415f0b1f174..6f2a77a1d4f 100644
--- a/tests/wpt/mozilla/tests/mozilla/calc.html
+++ b/tests/wpt/mozilla/tests/mozilla/calc.html
@@ -42,7 +42,7 @@ var widthTests = [
['calc(10px + 10em - 10px)', 'calc(10em + 0px)', '160px'],
// Fold absolute units
- ['calc(1px + 1pt + 1pc + 1in + 1cm + 1mm)', 'calc(155.91666666666666px)', '155.91666666666666px'],
+ ['calc(96px + 72pt + 6pc + 1in + 2.54cm + 25.4mm)', 'calc(576px)', '576px'],
// Alphabetical order
['calc(0ch + 0px + 0pt + 0pc + 0in + 0cm + 0mm + 0rem + 0em + 0ex + 0% + 0vw + 0vh + 0vmin + 0vmax)',