mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
style: Implement the border-{block,inline}-{color,style,width} shorthands.
Bug: 1520236 Reviewed-by: emilio
This commit is contained in:
parent
424eb94c7f
commit
50babf81f8
1 changed files with 44 additions and 0 deletions
|
@ -356,6 +356,50 @@ pub fn parse_border<'i, 't>(
|
||||||
}
|
}
|
||||||
</%helpers:shorthand>
|
</%helpers:shorthand>
|
||||||
|
|
||||||
|
% for axis in ["block", "inline"]:
|
||||||
|
% for prop in ["width", "style", "color"]:
|
||||||
|
<%
|
||||||
|
spec = "https://drafts.csswg.org/css-logical/#propdef-border-%s-%s" % (axis, prop)
|
||||||
|
%>
|
||||||
|
<%helpers:shorthand
|
||||||
|
name="border-${axis}-${prop}"
|
||||||
|
sub_properties="${' '.join(
|
||||||
|
'border-%s-%s-%s' % (axis, side, prop)
|
||||||
|
for side in ['start', 'end']
|
||||||
|
)}"
|
||||||
|
spec="${spec}">
|
||||||
|
|
||||||
|
use crate::properties::longhands::border_${axis}_start_${prop};
|
||||||
|
pub fn parse_value<'i, 't>(
|
||||||
|
context: &ParserContext,
|
||||||
|
input: &mut Parser<'i, 't>,
|
||||||
|
) -> Result<Longhands, ParseError<'i>> {
|
||||||
|
let start_value = border_${axis}_start_${prop}::parse(context, input)?;
|
||||||
|
let end_value =
|
||||||
|
input.try(|input| border_${axis}_start_${prop}::parse(context, input)).unwrap_or_else(|_| start_value.clone());
|
||||||
|
|
||||||
|
Ok(expanded! {
|
||||||
|
border_${axis}_start_${prop}: start_value,
|
||||||
|
border_${axis}_end_${prop}: end_value,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||||
|
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
|
||||||
|
self.border_${axis}_start_${prop}.to_css(dest)?;
|
||||||
|
|
||||||
|
if self.border_${axis}_end_${prop} != self.border_${axis}_start_${prop} {
|
||||||
|
dest.write_str(" ")?;
|
||||||
|
self.border_${axis}_end_${prop}.to_css(dest)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</%helpers:shorthand>
|
||||||
|
% endfor
|
||||||
|
% endfor
|
||||||
|
|
||||||
% for axis in ["block", "inline"]:
|
% for axis in ["block", "inline"]:
|
||||||
<%
|
<%
|
||||||
spec = "https://drafts.csswg.org/css-logical/#propdef-border-%s" % (axis)
|
spec = "https://drafts.csswg.org/css-logical/#propdef-border-%s" % (axis)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue