mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Remove uses of write!
in components/style_traits
This commit is contained in:
parent
38043a71de
commit
37722838c6
2 changed files with 30 additions and 13 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
use app_units::Au;
|
||||
use cssparser::{BasicParseError, ParseError, Parser, Token, UnicodeRange, serialize_string};
|
||||
use cssparser::ToCss as CssparserToCss;
|
||||
use std::fmt::{self, Write};
|
||||
|
||||
/// Serialises a value according to its CSS representation.
|
||||
|
@ -326,7 +327,8 @@ impl<T> ToCss for Box<T> where T: ?Sized + ToCss {
|
|||
|
||||
impl ToCss for Au {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: Write {
|
||||
write!(dest, "{}px", self.to_f64_px())
|
||||
self.to_f64_px().to_css(dest)?;
|
||||
dest.write_str("px")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,19 +45,31 @@ impl ToCss for ViewportConstraints {
|
|||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
|
||||
where W: fmt::Write
|
||||
{
|
||||
write!(dest, "@viewport {{")?;
|
||||
write!(dest, " width: {}px;", self.size.width)?;
|
||||
write!(dest, " height: {}px;", self.size.height)?;
|
||||
write!(dest, " zoom: {};", self.initial_zoom.get())?;
|
||||
dest.write_str("@viewport { width: ")?;
|
||||
self.size.width.to_css(dest)?;
|
||||
|
||||
dest.write_str("px; height: ")?;
|
||||
self.size.height.to_css(dest)?;
|
||||
|
||||
dest.write_str("px; zoom: ")?;
|
||||
self.initial_zoom.get().to_css(dest)?;
|
||||
|
||||
if let Some(min_zoom) = self.min_zoom {
|
||||
write!(dest, " min-zoom: {};", min_zoom.get())?;
|
||||
dest.write_str("; min-zoom: ")?;
|
||||
min_zoom.get().to_css(dest)?;
|
||||
}
|
||||
|
||||
if let Some(max_zoom) = self.max_zoom {
|
||||
write!(dest, " max-zoom: {};", max_zoom.get())?;
|
||||
dest.write_str("; max-zoom: ")?;
|
||||
max_zoom.get().to_css(dest)?;
|
||||
}
|
||||
write!(dest, " user-zoom: ")?; self.user_zoom.to_css(dest)?;
|
||||
write!(dest, "; orientation: ")?; self.orientation.to_css(dest)?;
|
||||
write!(dest, "; }}")
|
||||
|
||||
dest.write_str("; user-zoom: ")?;
|
||||
self.user_zoom.to_css(dest)?;
|
||||
|
||||
dest.write_str("; orientation: ")?;
|
||||
self.orientation.to_css(dest)?;
|
||||
dest.write_str("; }")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,9 +90,12 @@ impl ToCss for Zoom {
|
|||
where W: fmt::Write,
|
||||
{
|
||||
match *self {
|
||||
Zoom::Number(number) => write!(dest, "{}", number),
|
||||
Zoom::Percentage(percentage) => write!(dest, "{}%", percentage * 100.),
|
||||
Zoom::Auto => write!(dest, "auto")
|
||||
Zoom::Number(number) => number.to_css(dest),
|
||||
Zoom::Auto => dest.write_str("auto"),
|
||||
Zoom::Percentage(percentage) => {
|
||||
(percentage * 100.).to_css(dest)?;
|
||||
dest.write_char('%')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue