mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Simplify generation of need_clone methods in servo
This commit is contained in:
parent
bc4e670c5a
commit
07da4e4ea2
2 changed files with 19 additions and 79 deletions
|
@ -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};
|
pub use properties::longhands::transition_duration::{get_initial_value, parse, parse_one};
|
||||||
</%helpers:longhand>
|
</%helpers:longhand>
|
||||||
|
|
||||||
<%helpers:longhand name="animation-name" animatable="False">
|
<%helpers:longhand name="animation-name"
|
||||||
|
animatable="False">
|
||||||
use values::computed::ComputedValueAsSpecified;
|
use values::computed::ComputedValueAsSpecified;
|
||||||
|
|
||||||
pub mod computed_value {
|
pub mod computed_value {
|
||||||
|
@ -645,13 +646,15 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
|
||||||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||||
</%helpers:longhand>
|
</%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::computed_value;
|
||||||
pub use super::transition_duration::{parse, get_initial_value};
|
pub use super::transition_duration::{parse, get_initial_value};
|
||||||
pub use super::transition_duration::SpecifiedValue;
|
pub use super::transition_duration::SpecifiedValue;
|
||||||
</%helpers:longhand>
|
</%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::computed_value;
|
||||||
pub use super::transition_timing_function::{parse, get_initial_value};
|
pub use super::transition_timing_function::{parse, get_initial_value};
|
||||||
pub use super::transition_timing_function::SpecifiedValue;
|
pub use super::transition_timing_function::SpecifiedValue;
|
||||||
|
@ -739,7 +742,8 @@ ${helpers.keyword_list("animation-fill-mode",
|
||||||
"none forwards backwards both",
|
"none forwards backwards both",
|
||||||
animatable=False)}
|
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::computed_value;
|
||||||
pub use super::transition_duration::{parse, get_initial_value};
|
pub use super::transition_duration::{parse, get_initial_value};
|
||||||
pub use super::transition_duration::SpecifiedValue;
|
pub use super::transition_duration::SpecifiedValue;
|
||||||
|
|
|
@ -1126,65 +1126,33 @@ pub mod style_structs {
|
||||||
|
|
||||||
impl super::style_struct_traits::${style_struct.trait_name} for ${style_struct.servo_struct_name} {
|
impl super::style_struct_traits::${style_struct.trait_name} for ${style_struct.servo_struct_name} {
|
||||||
% for longhand in style_struct.longhands:
|
% for longhand in style_struct.longhands:
|
||||||
|
#[inline]
|
||||||
fn set_${longhand.ident}(&mut self, v: longhands::${longhand.ident}::computed_value::T) {
|
fn set_${longhand.ident}(&mut self, v: longhands::${longhand.ident}::computed_value::T) {
|
||||||
self.${longhand.ident} = v;
|
self.${longhand.ident} = v;
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
fn copy_${longhand.ident}_from(&mut self, other: &Self) {
|
fn copy_${longhand.ident}_from(&mut self, other: &Self) {
|
||||||
self.${longhand.ident} = other.${longhand.ident}.clone();
|
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
|
% endfor
|
||||||
% if style_struct.trait_name == "Border":
|
% if style_struct.trait_name == "Border":
|
||||||
% for side in ["top", "right", "bottom", "left"]:
|
% for side in ["top", "right", "bottom", "left"]:
|
||||||
fn clone_border_${side}_style(&self) -> longhands::border_${side}_style::computed_value::T {
|
fn border_${side}_has_nonzero_width(&self) -> bool {
|
||||||
self.border_${side}_style.clone()
|
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
|
% endfor
|
||||||
% elif style_struct.trait_name == "Box":
|
% 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]
|
#[inline]
|
||||||
fn transition_count(&self) -> usize {
|
fn transition_count(&self) -> usize {
|
||||||
self.transition_property.0.len()
|
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":
|
% 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) {
|
fn compute_font_hash(&mut self) {
|
||||||
// Corresponds to the fields in `gfx::font_template::FontTemplateDescriptor`.
|
// Corresponds to the fields in `gfx::font_template::FontTemplateDescriptor`.
|
||||||
let mut hasher: FnvHasher = Default::default();
|
let mut hasher: FnvHasher = Default::default();
|
||||||
|
@ -1193,43 +1161,11 @@ pub mod style_structs {
|
||||||
self.font_family.hash(&mut hasher);
|
self.font_family.hash(&mut hasher);
|
||||||
self.hash = hasher.finish()
|
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":
|
% elif style_struct.trait_name == "Outline":
|
||||||
#[inline]
|
|
||||||
fn clone_outline_style(&self) -> longhands::outline_style::computed_value::T {
|
|
||||||
self.outline_style.clone()
|
|
||||||
}
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn outline_has_nonzero_width(&self) -> bool {
|
fn outline_has_nonzero_width(&self) -> bool {
|
||||||
self.outline_width != ::app_units::Au(0)
|
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":
|
% elif style_struct.trait_name == "Text":
|
||||||
<% text_decoration_field = 'text_decoration' if product == 'servo' else 'text_decoration_line' %>
|
<% text_decoration_field = 'text_decoration' if product == 'servo' else 'text_decoration_line' %>
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue