diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-11-22 23:51:21 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-22 23:51:21 -0800 |
commit | a2babd6db8bd8fdfa30f5fbb66b734e679960285 (patch) | |
tree | bd73a8aee99258a2ec4ae7f3f45ee662099e7fe9 | |
parent | 9790ab0a0de37a3d968619cb3fea0ed41b9210a4 (diff) | |
parent | c8c7240dc21d4e9d8998deecbe504ea4046bf02f (diff) | |
download | servo-a2babd6db8bd8fdfa30f5fbb66b734e679960285.tar.gz servo-a2babd6db8bd8fdfa30f5fbb66b734e679960285.zip |
Auto merge of #14316 - canaltinova:stylo-properties, r=emilio
Implement parsing/serialization and/or gecko glue for some properties
<!-- Please describe your changes on the following line: -->
The PR covers implementation and/or gecko glue for these properties:
1. Implemented parsing/serialization and gecko glue for column-rule-width, column-rule-color and column-span longhand properties (column-span is not implemented in gecko yet but I wanted to complete column properties :) )
2. Implemented parsing/serialization and gecko glue for text-emphasis-color longhand and text-emphasis shorthand properties.
3. Implemented gecko glue for column-gap and order properties
I implemented column-rule-width and column-rule-color properties with `-moz-` prefixes, but I can remove them if it's not right.
I coudn't test them in full stylo build yet (LLVM messed up my current clang). But I'll test them soon.
r? @Manishearth or @emilio
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
<!-- Either: -->
- [X] These changes do not require tests
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14316)
<!-- Reviewable:end -->
5 files changed, 130 insertions, 4 deletions
diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 120498e2a82..482829d3b52 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -814,7 +814,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, @@ -864,6 +864,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')} + </%self:impl_trait> <% skip_outline_longhands = " ".join("outline-style outline-width".split() + @@ -2306,7 +2316,7 @@ clip-path </%self:impl_trait> <%self:impl_trait style_struct_name="Column" - skip_longhands="column-width column-count"> + 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 { @@ -2330,6 +2340,18 @@ 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')"></%call> + + <% impl_app_units("_moz_column_rule_width", "mColumnRuleWidth", need_clone=True, + round_to_pixels=True) %> </%self:impl_trait> <%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..3df4d8e2526 100644 --- a/components/style/properties/longhand/column.mako.rs +++ b/components/style/properties/longhand/column.mako.rs @@ -169,7 +169,7 @@ </%helpers:longhand> // 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; @@ -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<SpecifiedValue, ()> { + BorderWidth::parse(input) + } +</%helpers:longhand> + +// 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)} 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", } </%helpers:longhand> +// 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/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 {} 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 @@ } } </%helpers:shorthand> + +// 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<Longhands, ()> { + 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<W>(&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(()) + } + } +</%helpers:shorthand> |