mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Impl ToCss on LonghandsToSerialize directly
This commit is contained in:
parent
f327b2fc73
commit
4bc0fbeeb1
13 changed files with 52 additions and 61 deletions
|
@ -554,15 +554,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
|
||||
where W: fmt::Write,
|
||||
{
|
||||
self.to_css_declared(dest)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Parse the given shorthand and fill the result into the
|
||||
/// `declarations` vector.
|
||||
pub fn parse(context: &ParserContext,
|
||||
|
@ -635,8 +626,8 @@
|
|||
})
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
super::serialize_four_sides(
|
||||
dest,
|
||||
self.${to_rust_ident(sub_property_pattern % 'top')},
|
||||
|
|
|
@ -127,8 +127,8 @@
|
|||
})
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
let len = self.background_image.0.len();
|
||||
// There should be at least one declared value
|
||||
if len == 0 {
|
||||
|
@ -224,8 +224,8 @@
|
|||
})
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
let len = self.background_position_x.0.len();
|
||||
if len == 0 || len != self.background_position_y.0.len() {
|
||||
return Ok(());
|
||||
|
|
|
@ -29,8 +29,8 @@ ${helpers.four_sides_shorthand("border-style", "border-%s-style",
|
|||
})
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
% for side in ["top", "right", "bottom", "left"]:
|
||||
let ${side} = self.border_${side}_width.clone();
|
||||
% endfor
|
||||
|
@ -108,8 +108,8 @@ pub fn parse_border(context: &ParserContext, input: &mut Parser)
|
|||
})
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
super::serialize_directional_border(
|
||||
dest,
|
||||
self.border_${to_rust_ident(side)}_width,
|
||||
|
@ -139,8 +139,8 @@ pub fn parse_border(context: &ParserContext, input: &mut Parser)
|
|||
})
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
let all_equal = {
|
||||
% for side in PHYSICAL_SIDES:
|
||||
let border_${side}_width = self.border_${side}_width;
|
||||
|
@ -198,8 +198,8 @@ pub fn parse_border(context: &ParserContext, input: &mut Parser)
|
|||
// TODO: I do not understand how border radius works with respect to the slashes /,
|
||||
// so putting a default generic impl for now
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
try!(self.border_top_left_radius.to_css(dest));
|
||||
try!(write!(dest, " "));
|
||||
|
||||
|
@ -289,8 +289,8 @@ pub fn parse_border(context: &ParserContext, input: &mut Parser)
|
|||
})
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
self.border_image_source.to_css(dest)?;
|
||||
dest.write_str(" ")?;
|
||||
self.border_image_slice.to_css(dest)?;
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
})
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
if *self.overflow_x == self.overflow_y.0 {
|
||||
self.overflow_x.to_css(dest)
|
||||
} else {
|
||||
|
@ -115,8 +115,8 @@ macro_rules! try_parse_one {
|
|||
})
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
let len = self.transition_property.0.len();
|
||||
// There should be at least one declared value
|
||||
if len == 0 {
|
||||
|
@ -257,8 +257,8 @@ macro_rules! try_parse_one {
|
|||
})
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
let len = self.animation_name.0.len();
|
||||
// There should be at least one declared value
|
||||
if len == 0 {
|
||||
|
@ -307,10 +307,10 @@ macro_rules! try_parse_one {
|
|||
})
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
// Serializes into the single keyword value if both scroll-snap-type and scroll-snap-type-y are same.
|
||||
// Otherwise into an empty string. This is done to match Gecko's behaviour.
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
if self.scroll_snap_type_x == self.scroll_snap_type_y {
|
||||
self.scroll_snap_type_x.to_css(dest)
|
||||
} else {
|
||||
|
|
|
@ -49,8 +49,8 @@
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
try!(self.column_width.to_css(dest));
|
||||
try!(write!(dest, " "));
|
||||
|
||||
|
@ -96,8 +96,8 @@
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
self.column_rule_width.to_css(dest)?;
|
||||
dest.write_str(" ")?;
|
||||
self.column_rule_style.to_css(dest)?;
|
||||
|
|
|
@ -95,8 +95,8 @@
|
|||
}
|
||||
|
||||
// This may be a bit off, unsure, possibly needs changes
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
self.font_style.to_css(dest)?;
|
||||
dest.write_str(" ")?;
|
||||
self.font_variant.to_css(dest)?;
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
})
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
if self.marker_start == self.marker_mid && self.marker_mid == self.marker_end {
|
||||
self.marker_start.to_css(dest)
|
||||
} else {
|
||||
|
|
|
@ -38,8 +38,8 @@
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
self.text_emphasis_style.to_css(dest)?;
|
||||
dest.write_str(" ")?;
|
||||
self.text_emphasis_color.to_css(dest)
|
||||
|
@ -86,8 +86,8 @@
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
self._webkit_text_stroke_width.to_css(dest)?;
|
||||
dest.write_str(" ")?;
|
||||
self._webkit_text_stroke_color.to_css(dest)
|
||||
|
|
|
@ -96,8 +96,8 @@
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
self.list_style_position.to_css(dest)?;
|
||||
dest.write_str(" ")?;
|
||||
self.list_style_image.to_css(dest)?;
|
||||
|
|
|
@ -120,8 +120,8 @@
|
|||
})
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
use properties::longhands::mask_origin::single_value::computed_value::T as Origin;
|
||||
use properties::longhands::mask_clip::single_value::computed_value::T as Clip;
|
||||
|
||||
|
@ -217,8 +217,8 @@
|
|||
})
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
let len = self.mask_position_x.0.len();
|
||||
if len == 0 || self.mask_position_y.0.len() != len {
|
||||
return Ok(());
|
||||
|
|
|
@ -51,8 +51,8 @@
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
try!(self.outline_width.to_css(dest));
|
||||
try!(write!(dest, " "));
|
||||
try!(self.outline_style.to_css(dest));
|
||||
|
@ -81,8 +81,8 @@
|
|||
}
|
||||
|
||||
// TODO: Border radius for the radius shorthand is not implemented correctly yet
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
try!(self._moz_outline_radius_topleft.to_css(dest));
|
||||
try!(write!(dest, " "));
|
||||
|
||||
|
|
|
@ -37,8 +37,8 @@
|
|||
}
|
||||
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
self.flex_direction.to_css(dest)?;
|
||||
dest.write_str(" ")?;
|
||||
self.flex_wrap.to_css(dest)
|
||||
|
@ -97,8 +97,8 @@
|
|||
})
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
try!(self.flex_grow.to_css(dest));
|
||||
try!(write!(dest, " "));
|
||||
|
||||
|
|
|
@ -46,8 +46,8 @@
|
|||
})
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
self.text_decoration_line.to_css(dest)?;
|
||||
dest.write_str(" ")?;
|
||||
self.text_decoration_style.to_css(dest)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue