diff options
-rw-r--r-- | components/style/properties/longhand/column.mako.rs | 8 | ||||
-rw-r--r-- | components/style/properties/shorthand/column.mako.rs | 68 |
2 files changed, 75 insertions, 1 deletions
diff --git a/components/style/properties/longhand/column.mako.rs b/components/style/properties/longhand/column.mako.rs index c8493300847..e94f0be457b 100644 --- a/components/style/properties/longhand/column.mako.rs +++ b/components/style/properties/longhand/column.mako.rs @@ -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)} diff --git a/components/style/properties/shorthand/column.mako.rs b/components/style/properties/shorthand/column.mako.rs index e8ccf00bf47..037154e4afe 100644 --- a/components/style/properties/shorthand/column.mako.rs +++ b/components/style/properties/shorthand/column.mako.rs @@ -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> |