From 61431b7fd61604da9a54b9dd6714438f6485bf7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= Date: Mon, 21 Nov 2016 23:04:43 +0300 Subject: [PATCH 1/3] Implement parsing/serialization of column-rule-width, column-rule-color and column-span --- components/style/properties/gecko.mako.rs | 5 ++- .../style/properties/longhand/column.mako.rs | 36 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index a82dcd4a4e0..20fa243d3f4 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -2244,7 +2244,7 @@ clip-path <%self:impl_trait style_struct_name="Column" - skip_longhands="column-width column-count"> + skip_longhands="column-width column-count -moz-column-rule-width"> pub fn set_column_width(&mut self, v: longhands::column_width::computed_value::T) { match v.0 { @@ -2268,6 +2268,9 @@ clip-path } ${impl_simple_copy('column_count', 'mColumnCount')} + + <% impl_app_units("_moz_column_rule_width", "mColumnRuleWidth", need_clone=True, + round_to_pixels=True) %> <%self:impl_trait style_struct_name="Counters" diff --git a/components/style/properties/longhand/column.mako.rs b/components/style/properties/longhand/column.mako.rs index 88272435972..6f6ca6da816 100644 --- a/components/style/properties/longhand/column.mako.rs +++ b/components/style/properties/longhand/column.mako.rs @@ -252,3 +252,39 @@ ${helpers.single_keyword("column-fill", "auto balance", products="gecko", animatable=False)} + +// https://drafts.csswg.org/css-multicol-1/#propdef-column-rule-width +<%helpers:longhand name="-moz-column-rule-width" products="gecko" animatable="True"> + use app_units::Au; + use std::fmt; + use style_traits::ToCss; + use values::HasViewportPercentage; + use values::specified::BorderWidth; + + pub mod computed_value { + use app_units::Au; + pub type T = Au; + } + + pub type SpecifiedValue = BorderWidth; + + #[inline] + pub fn get_initial_value() -> computed_value::T { + Au::from_px(3) // medium + } + + pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result { + BorderWidth::parse(input) + } + + +// https://drafts.csswg.org/css-multicol-1/#crc +${helpers.predefined_type("-moz-column-rule-color", "CSSColor", + "::cssparser::Color::CurrentColor", + products="gecko", gecko_ffi_name="mColumnRuleColor", + animatable=True, complex_color=True, need_clone=True)} + +// It's not implemented in servo or gecko yet. +// https://drafts.csswg.org/css-multicol-1/#column-span +${helpers.single_keyword("column-span", "none all", + products="none", animatable=False)} From 852fdca1c5c849ba9b3fd389cfba3bddb5e5fba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= Date: Mon, 21 Nov 2016 23:05:59 +0300 Subject: [PATCH 2/3] Implement parsing/serialization of text-emphasis-color and text-emphasis --- .../longhand/inherited_text.mako.rs | 11 ++++ .../shorthand/inherited_text.mako.rs | 57 +++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/components/style/properties/longhand/inherited_text.mako.rs b/components/style/properties/longhand/inherited_text.mako.rs index d08d5b1dd0c..7ac54b04222 100644 --- a/components/style/properties/longhand/inherited_text.mako.rs +++ b/components/style/properties/longhand/inherited_text.mako.rs @@ -866,6 +866,11 @@ ${helpers.single_keyword("text-align-last", computed_value::T::None } + #[inline] + pub fn get_initial_specified_value() -> SpecifiedValue { + SpecifiedValue::None + } + impl ToComputedValue for SpecifiedValue { type ComputedValue = computed_value::T; @@ -985,6 +990,12 @@ ${helpers.single_keyword("text-align-last", } +// https://drafts.csswg.org/css-text-decor-3/#text-emphasis-color-property +${helpers.predefined_type("text-emphasis-color", "CSSColor", + "::cssparser::Color::CurrentColor", + products="gecko",animatable=True, + complex_color=True, need_clone=True)} + // TODO(pcwalton): `full-width` ${helpers.single_keyword("text-transform", "none capitalize uppercase lowercase", diff --git a/components/style/properties/shorthand/inherited_text.mako.rs b/components/style/properties/shorthand/inherited_text.mako.rs index 64ef03b1138..570c41e5e30 100644 --- a/components/style/properties/shorthand/inherited_text.mako.rs +++ b/components/style/properties/shorthand/inherited_text.mako.rs @@ -21,3 +21,60 @@ } } + +// https://drafts.csswg.org/css-text-decor-3/#text-emphasis-property +<%helpers:shorthand name="text-emphasis" products="gecko" sub_properties="text-emphasis-color + text-emphasis-style"> + use properties::longhands::{text_emphasis_color, text_emphasis_style}; + + pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result { + let mut color = None; + let mut style = None; + + loop { + if color.is_none() { + if let Ok(value) = input.try(|input| text_emphasis_color::parse(context, input)) { + color = Some(value); + continue + } + } + if style.is_none() { + if let Ok(value) = input.try(|input| text_emphasis_style::parse(context, input)) { + style = Some(value); + continue + } + } + break + } + if color.is_some() || style.is_some() { + if style.is_none() { + style = Some(text_emphasis_style::get_initial_specified_value()); + } + + Ok(Longhands { + text_emphasis_color: color, + text_emphasis_style: style, + }) + } else { + Err(()) + } + } + + impl<'a> LonghandsToSerialize<'a> { + fn to_css_declared(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { + let mut style_present = false; + if let DeclaredValue::Value(ref value) = *self.text_emphasis_style { + style_present = true; + try!(value.to_css(dest)); + } + + if let DeclaredValue::Value(ref color) = *self.text_emphasis_color { + if style_present { + try!(write!(dest, " ")); + } + try!(color.to_css(dest)); + } + Ok(()) + } + } + From c8c7240dc21d4e9d8998deecbe504ea4046bf02f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= Date: Tue, 22 Nov 2016 01:01:15 +0300 Subject: [PATCH 3/3] Implement gecko glue for column-gap and order properties --- components/style/properties/gecko.mako.rs | 23 +++++++++++++++++-- .../style/properties/longhand/column.mako.rs | 2 +- .../properties/longhand/position.mako.rs | 2 +- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 20fa243d3f4..c84de932be1 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -810,7 +810,7 @@ fn static_assert() { <% skip_position_longhands = " ".join(x.ident for x in SIDES) %> <%self:impl_trait style_struct_name="Position" - skip_longhands="${skip_position_longhands} z-index box-sizing"> + skip_longhands="${skip_position_longhands} z-index box-sizing order"> % for side in SIDES: <% impl_split_style_coord("%s" % side.ident, @@ -860,6 +860,16 @@ fn static_assert() { } ${impl_simple_copy('box_sizing', 'mBoxSizing')} + pub fn set_order(&mut self, v: longhands::order::computed_value::T) { + self.gecko.mOrder = v; + } + + pub fn clone_order(&self) -> longhands::order::computed_value::T { + self.gecko.mOrder + } + + ${impl_simple_copy('order', 'mOrder')} + <% skip_outline_longhands = " ".join("outline-style outline-width".split() + @@ -2244,7 +2254,7 @@ clip-path <%self:impl_trait style_struct_name="Column" - skip_longhands="column-width column-count -moz-column-rule-width"> + skip_longhands="column-width column-count column-gap -moz-column-rule-width"> pub fn set_column_width(&mut self, v: longhands::column_width::computed_value::T) { match v.0 { @@ -2269,6 +2279,15 @@ clip-path ${impl_simple_copy('column_count', 'mColumnCount')} + pub fn set_column_gap(&mut self, v: longhands::column_gap::computed_value::T) { + match v.0 { + Some(len) => self.gecko.mColumnGap.set(len), + None => self.gecko.mColumnGap.set_value(CoordDataValue::Normal), + } + } + + <%call expr="impl_coord_copy('column_gap', 'mColumnGap')"> + <% impl_app_units("_moz_column_rule_width", "mColumnRuleWidth", need_clone=True, round_to_pixels=True) %> diff --git a/components/style/properties/longhand/column.mako.rs b/components/style/properties/longhand/column.mako.rs index 6f6ca6da816..3df4d8e2526 100644 --- a/components/style/properties/longhand/column.mako.rs +++ b/components/style/properties/longhand/column.mako.rs @@ -169,7 +169,7 @@ // FIXME: This prop should be animatable. -<%helpers:longhand name="column-gap" experimental="True" products="servo" animatable="False"> +<%helpers:longhand name="column-gap" experimental="True" animatable="False"> use std::fmt; use style_traits::ToCss; use values::HasViewportPercentage; diff --git a/components/style/properties/longhand/position.mako.rs b/components/style/properties/longhand/position.mako.rs index 716c4f81ac8..a0279093116 100644 --- a/components/style/properties/longhand/position.mako.rs +++ b/components/style/properties/longhand/position.mako.rs @@ -107,7 +107,7 @@ ${helpers.single_keyword("align-self", "auto stretch flex-start flex-end center animatable=False)} // https://drafts.csswg.org/css-flexbox/#propdef-order -<%helpers:longhand name="order" products="servo" animatable="True"> +<%helpers:longhand name="order" animatable="True"> use values::computed::ComputedValueAsSpecified; impl ComputedValueAsSpecified for SpecifiedValue {}