diff options
author | Emilio Cobos Álvarez <me@emiliocobos.me> | 2016-06-30 13:51:41 -0700 |
---|---|---|
committer | Emilio Cobos Álvarez <me@emiliocobos.me> | 2016-07-01 10:03:02 -0700 |
commit | 07da4e4ea24deeb9af76a1a5cf284f51650edc60 (patch) | |
tree | 64ace02ae53979f92c0660661d7c772d9a8b3c8b | |
parent | bc4e670c5ae2d0a5e281d05e03f5c1621219e4d3 (diff) | |
download | servo-07da4e4ea24deeb9af76a1a5cf284f51650edc60.tar.gz servo-07da4e4ea24deeb9af76a1a5cf284f51650edc60.zip |
style: Simplify generation of need_clone methods in servo
-rw-r--r-- | components/style/properties/longhand/box.mako.rs | 12 | ||||
-rw-r--r-- | components/style/properties/properties.mako.rs | 86 |
2 files changed, 19 insertions, 79 deletions
diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index f9f2a4be97c..ecfba4e34d9 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -599,7 +599,8 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", pub use properties::longhands::transition_duration::{get_initial_value, parse, parse_one}; </%helpers:longhand> -<%helpers:longhand name="animation-name" animatable="False"> +<%helpers:longhand name="animation-name" + animatable="False"> use values::computed::ComputedValueAsSpecified; pub mod computed_value { @@ -645,13 +646,15 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", impl ComputedValueAsSpecified for SpecifiedValue {} </%helpers:longhand> -<%helpers:longhand name="animation-duration" animatable="False"> +<%helpers:longhand name="animation-duration" + animatable="False"> pub use super::transition_duration::computed_value; pub use super::transition_duration::{parse, get_initial_value}; pub use super::transition_duration::SpecifiedValue; </%helpers:longhand> -<%helpers:longhand name="animation-timing-function" animatable="False"> +<%helpers:longhand name="animation-timing-function" + animatable="False"> pub use super::transition_timing_function::computed_value; pub use super::transition_timing_function::{parse, get_initial_value}; pub use super::transition_timing_function::SpecifiedValue; @@ -739,7 +742,8 @@ ${helpers.keyword_list("animation-fill-mode", "none forwards backwards both", animatable=False)} -<%helpers:longhand name="animation-delay" animatable="False"> +<%helpers:longhand name="animation-delay" + animatable="False"> pub use super::transition_duration::computed_value; pub use super::transition_duration::{parse, get_initial_value}; pub use super::transition_duration::SpecifiedValue; diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index bfdb6cd378f..0744252cc06 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -1126,65 +1126,33 @@ pub mod style_structs { impl super::style_struct_traits::${style_struct.trait_name} for ${style_struct.servo_struct_name} { % for longhand in style_struct.longhands: + #[inline] fn set_${longhand.ident}(&mut self, v: longhands::${longhand.ident}::computed_value::T) { self.${longhand.ident} = v; } + #[inline] fn copy_${longhand.ident}_from(&mut self, other: &Self) { self.${longhand.ident} = other.${longhand.ident}.clone(); } + % if longhand.need_clone: + #[inline] + fn clone_${longhand.ident}(&self) -> longhands::${longhand.ident}::computed_value::T { + self.${longhand.ident}.clone() + } + % endif % endfor % if style_struct.trait_name == "Border": % for side in ["top", "right", "bottom", "left"]: - fn clone_border_${side}_style(&self) -> longhands::border_${side}_style::computed_value::T { - self.border_${side}_style.clone() - } - fn border_${side}_has_nonzero_width(&self) -> bool { - self.border_${side}_width != ::app_units::Au(0) - } + fn border_${side}_has_nonzero_width(&self) -> bool { + self.border_${side}_width != ::app_units::Au(0) + } % endfor % elif style_struct.trait_name == "Box": #[inline] - fn clone_display(&self) -> longhands::display::computed_value::T { - self.display.clone() - } - #[inline] - fn clone_position(&self) -> longhands::position::computed_value::T { - self.position.clone() - } - #[inline] - fn clone_float(&self) -> longhands::float::computed_value::T { - self.float.clone() - } - #[inline] - fn clone_overflow_x(&self) -> longhands::overflow_x::computed_value::T { - self.overflow_x.clone() - } - #[inline] - fn clone_overflow_y(&self) -> longhands::overflow_y::computed_value::T { - self.overflow_y.clone() - } - #[inline] - fn clone_animation_play_state(&self) -> longhands::animation_play_state::computed_value::T { - self.animation_play_state.clone() - } - #[inline] fn transition_count(&self) -> usize { self.transition_property.0.len() } - % elif style_struct.trait_name == "Color": - #[inline] - fn clone_color(&self) -> longhands::color::computed_value::T { - self.color.clone() - } % elif style_struct.trait_name == "Font": - #[inline] - fn clone_font_size(&self) -> longhands::font_size::computed_value::T { - self.font_size.clone() - } - #[inline] - fn clone_font_weight(&self) -> longhands::font_weight::computed_value::T { - self.font_weight.clone() - } fn compute_font_hash(&mut self) { // Corresponds to the fields in `gfx::font_template::FontTemplateDescriptor`. let mut hasher: FnvHasher = Default::default(); @@ -1193,43 +1161,11 @@ pub mod style_structs { self.font_family.hash(&mut hasher); self.hash = hasher.finish() } - % elif style_struct.trait_name == "InheritedBox": - #[inline] - fn clone_direction(&self) -> longhands::direction::computed_value::T { - self.direction.clone() - } - #[inline] - fn clone_writing_mode(&self) -> longhands::writing_mode::computed_value::T { - self.writing_mode.clone() - } - #[inline] - fn clone_text_orientation(&self) -> longhands::text_orientation::computed_value::T { - self.text_orientation.clone() - } - % elif style_struct.trait_name == "InheritedText" and product == "servo": - #[inline] - fn clone__servo_text_decorations_in_effect(&self) -> - longhands::_servo_text_decorations_in_effect::computed_value::T { - self._servo_text_decorations_in_effect.clone() - } % elif style_struct.trait_name == "Outline": #[inline] - fn clone_outline_style(&self) -> longhands::outline_style::computed_value::T { - self.outline_style.clone() - } - #[inline] fn outline_has_nonzero_width(&self) -> bool { self.outline_width != ::app_units::Au(0) } - % elif style_struct.trait_name == "Position": - #[inline] - fn clone_align_items(&self) -> longhands::align_items::computed_value::T { - self.align_items.clone() - } - #[inline] - fn clone_align_self(&self) -> longhands::align_self::computed_value::T { - self.align_self.clone() - } % elif style_struct.trait_name == "Text": <% text_decoration_field = 'text_decoration' if product == 'servo' else 'text_decoration_line' %> #[inline] |