mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Replace write! with to_css and write_str in some ToCss impls
This commit is contained in:
parent
c1b196b7cb
commit
7e92c15e00
11 changed files with 58 additions and 42 deletions
|
@ -36,6 +36,22 @@ define_keyword_type!(None_, "none");
|
|||
define_keyword_type!(Auto, "auto");
|
||||
define_keyword_type!(Normal, "normal");
|
||||
|
||||
/// Serialize a normalized value into percentage.
|
||||
pub fn serialize_percentage<W>(value: CSSFloat, dest: &mut W)
|
||||
-> fmt::Result where W: fmt::Write
|
||||
{
|
||||
(value * 100.).to_css(dest)?;
|
||||
dest.write_str("%")
|
||||
}
|
||||
|
||||
/// Serialize a value with given unit into dest.
|
||||
pub fn serialize_dimension<W>(value: CSSFloat, unit: &str, dest: &mut W)
|
||||
-> fmt::Result where W: fmt::Write
|
||||
{
|
||||
value.to_css(dest)?;
|
||||
dest.write_str(unit)
|
||||
}
|
||||
|
||||
/// Convenience void type to disable some properties and values through types.
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, HeapSizeOf, Serialize))]
|
||||
#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue, ToCss)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue