diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-11-30 04:15:19 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-30 04:15:19 -0800 |
commit | b3cdcfaa39a7933a9f87a6881f5d58e5afe94086 (patch) | |
tree | ee6eb3f2497732b2c18a6d559ec5566bde13db06 | |
parent | f159b5cb1028bf4d2f75b0b48055fe19a8032f8e (diff) | |
parent | ea507aa1d331b360df92d17d18c20eca8e58fc6f (diff) | |
download | servo-b3cdcfaa39a7933a9f87a6881f5d58e5afe94086.tar.gz servo-b3cdcfaa39a7933a9f87a6881f5d58e5afe94086.zip |
Auto merge of #14410 - canaltinova:stylo-things, r=Manishearth
Implement 3 more properties for stylo
<!-- Please describe your changes on the following line: -->
Implemented these new properties:
1. Implemented parsing/serialization and stylo glue for `background-blend-mode`.
2. Made `align-items` work for stylo.
3. Implemented parsing/serialization for `-moz-column-rule`.
---
<!-- 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 because it's stylo changes.
<!-- 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/14410)
<!-- Reviewable:end -->
6 files changed, 118 insertions, 7 deletions
diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 86a1bbc9e5f..e0f187cc3cc 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -1571,7 +1571,8 @@ fn static_assert() { <% skip_background_longhands = """background-repeat background-image background-clip background-origin background-attachment - background-size background-position""" %> + background-size background-position + background-blend-mode""" %> <%self:impl_trait style_struct_name="Background" skip_longhands="${skip_background_longhands}" skip_additionals="*"> @@ -1586,6 +1587,29 @@ fn static_assert() { T::local => structs::NS_STYLE_IMAGELAYER_ATTACHMENT_LOCAL as u8, } </%self:simple_image_array_property> + + <%self:simple_image_array_property name="blend_mode" shorthand="background" field_name="mBlendMode"> + use properties::longhands::background_blend_mode::single_value::computed_value::T; + + match servo { + T::normal => structs::NS_STYLE_BLEND_NORMAL as u8, + T::multiply => structs::NS_STYLE_BLEND_MULTIPLY as u8, + T::screen => structs::NS_STYLE_BLEND_SCREEN as u8, + T::overlay => structs::NS_STYLE_BLEND_OVERLAY as u8, + T::darken => structs::NS_STYLE_BLEND_DARKEN as u8, + T::lighten => structs::NS_STYLE_BLEND_LIGHTEN as u8, + T::color_dodge => structs::NS_STYLE_BLEND_COLOR_DODGE as u8, + T::color_burn => structs::NS_STYLE_BLEND_COLOR_BURN as u8, + T::hard_light => structs::NS_STYLE_BLEND_HARD_LIGHT as u8, + T::soft_light => structs::NS_STYLE_BLEND_SOFT_LIGHT as u8, + T::difference => structs::NS_STYLE_BLEND_DIFFERENCE as u8, + T::exclusion => structs::NS_STYLE_BLEND_EXCLUSION as u8, + T::hue => structs::NS_STYLE_BLEND_HUE as u8, + T::saturation => structs::NS_STYLE_BLEND_SATURATION as u8, + T::color => structs::NS_STYLE_BLEND_COLOR as u8, + T::luminosity => structs::NS_STYLE_BLEND_LUMINOSITY as u8, + } + </%self:simple_image_array_property> </%self:impl_trait> <%self:impl_trait style_struct_name="List" diff --git a/components/style/properties/longhand/background.mako.rs b/components/style/properties/longhand/background.mako.rs index 4b2c073fb6c..adc7e44e0a9 100644 --- a/components/style/properties/longhand/background.mako.rs +++ b/components/style/properties/longhand/background.mako.rs @@ -339,3 +339,10 @@ ${helpers.single_keyword("background-origin", })) } </%helpers:vector_longhand> + +// https://drafts.fxtf.org/compositing/#background-blend-mode +${helpers.single_keyword("background-blend-mode", + """normal multiply screen overlay darken lighten color-dodge + color-burn hard-light soft-light difference exclusion hue + saturation color luminosity""", + vector="true", products="gecko", animatable=False)} 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/longhand/position.mako.rs b/components/style/properties/longhand/position.mako.rs index 1600045e609..529dce1e9d0 100644 --- a/components/style/properties/longhand/position.mako.rs +++ b/components/style/properties/longhand/position.mako.rs @@ -86,13 +86,13 @@ ${helpers.single_keyword("justify-content", "flex-start flex-end center space-be products="servo", animatable=False)} -// FIXME(heycam): Disable align-items in geckolib since we don't support the Gecko initial value -// 'normal' yet. -${helpers.single_keyword("align-items", "stretch flex-start flex-end center baseline", +// https://drafts.csswg.org/css-flexbox/#propdef-align-items +// FIXME: This is a workaround for 'normal' value. We don't support the Gecko initial value 'normal' yet. +${helpers.single_keyword("align-items", "stretch flex-start flex-end center baseline" if product == "servo" + else "normal stretch flex-start flex-end center baseline", need_clone=True, gecko_constant_prefix="NS_STYLE_ALIGN", - animatable=False, - products="servo")} + animatable=False)} ${helpers.single_keyword("align-content", "stretch flex-start flex-end center space-between space-around", gecko_constant_prefix="NS_STYLE_ALIGN", @@ -110,8 +110,11 @@ ${helpers.predefined_type("flex-shrink", "Number", needs_context=False, animatable=True)} +// https://drafts.csswg.org/css-align/#align-self-property +// FIXME: We don't support the Gecko value 'normal' yet. ${helpers.single_keyword("align-self", "auto stretch flex-start flex-end center baseline", need_clone=True, + extra_gecko_values="normal", gecko_constant_prefix="NS_STYLE_ALIGN", animatable=False)} diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 508936e873d..06e05fe750a 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -1687,6 +1687,9 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D<Au>, align_items::flex_start => align_self::flex_start, align_items::flex_end => align_self::flex_end, align_items::center => align_self::center, + % if product == "gecko": + align_items::normal => align_self::normal, + % endif }; style.mutate_position().set_align_self(self_align); } 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> |