mirror of
https://github.com/servo/servo.git
synced 2025-06-27 10:33:39 +01:00
Implement column-rule shorthand for stylo
This commit is contained in:
parent
a067c46e96
commit
ea507aa1d3
2 changed files with 75 additions and 1 deletions
|
@ -273,6 +273,11 @@ ${helpers.single_keyword("column-fill", "auto balance",
|
|||
Au::from_px(3) // medium
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_initial_specified_value() -> SpecifiedValue {
|
||||
BorderWidth::Medium
|
||||
}
|
||||
|
||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
BorderWidth::parse(context, input)
|
||||
}
|
||||
|
@ -289,8 +294,9 @@ ${helpers.predefined_type("-moz-column-rule-color", "CSSColor",
|
|||
${helpers.single_keyword("column-span", "none all",
|
||||
products="none", animatable=False)}
|
||||
|
||||
${helpers.single_keyword("column-rule-style",
|
||||
${helpers.single_keyword("-moz-column-rule-style",
|
||||
"none hidden dotted dashed solid double groove ridge inset outset",
|
||||
products="gecko",
|
||||
gecko_ffi_name="mColumnRuleStyle",
|
||||
gecko_constant_prefix="NS_STYLE_BORDER_STYLE",
|
||||
animatable=False)}
|
||||
|
|
|
@ -57,3 +57,71 @@
|
|||
}
|
||||
}
|
||||
</%helpers:shorthand>
|
||||
|
||||
// https://drafts.csswg.org/css-multicol/#column-rule
|
||||
<%helpers:shorthand name="-moz-column-rule" products="gecko"
|
||||
sub_properties="-moz-column-rule-width -moz-column-rule-style -moz-column-rule-color">
|
||||
use properties::longhands::{_moz_column_rule_width, _moz_column_rule_style};
|
||||
use properties::longhands::_moz_column_rule_color;
|
||||
|
||||
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
||||
% for name in "width style color".split():
|
||||
let mut column_rule_${name} = None;
|
||||
% endfor
|
||||
let mut any = false;
|
||||
|
||||
loop {
|
||||
% for name in "width style color".split():
|
||||
if column_rule_${name}.is_none() {
|
||||
if let Ok(value) = input.try(|input|
|
||||
_moz_column_rule_${name}::parse(context, input)) {
|
||||
column_rule_${name} = Some(value);
|
||||
any = true;
|
||||
continue
|
||||
}
|
||||
}
|
||||
% endfor
|
||||
|
||||
break
|
||||
}
|
||||
if any {
|
||||
Ok(Longhands {
|
||||
% for name in "width style".split():
|
||||
_moz_column_rule_${name}: column_rule_${name}
|
||||
.or(Some(_moz_column_rule_${name}::get_initial_specified_value())),
|
||||
% endfor
|
||||
_moz_column_rule_color: column_rule_color,
|
||||
})
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
let mut need_space = false;
|
||||
try!(self._moz_column_rule_width.to_css(dest));
|
||||
|
||||
if let DeclaredValue::Value(ref width) = *self._moz_column_rule_width {
|
||||
try!(width.to_css(dest));
|
||||
need_space = true;
|
||||
}
|
||||
|
||||
if let DeclaredValue::Value(ref style) = *self._moz_column_rule_style {
|
||||
if need_space {
|
||||
try!(write!(dest, " "));
|
||||
}
|
||||
try!(style.to_css(dest));
|
||||
need_space = true;
|
||||
}
|
||||
|
||||
if let DeclaredValue::Value(ref color) = *self._moz_column_rule_color {
|
||||
if need_space {
|
||||
try!(write!(dest, " "));
|
||||
}
|
||||
try!(color.to_css(dest));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
</%helpers:shorthand>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue