From 680f8368ef98952537a0ad4a685f16c4b5be7862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 17 Sep 2017 01:10:19 +0200 Subject: [PATCH] style: No more need_clone. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Emilio Cobos Álvarez --- components/style/properties/data.py | 7 +- components/style/properties/gecko.mako.rs | 208 ++++++++---------- components/style/properties/helpers.mako.rs | 24 +- .../style/properties/longhand/box.mako.rs | 10 +- .../style/properties/longhand/color.mako.rs | 3 +- .../style/properties/longhand/column.mako.rs | 1 - .../style/properties/longhand/font.mako.rs | 10 +- .../longhand/inherited_text.mako.rs | 6 +- .../style/properties/longhand/outline.mako.rs | 1 - .../style/properties/longhand/text.mako.rs | 2 - .../style/properties/properties.mako.rs | 15 +- 11 files changed, 119 insertions(+), 168 deletions(-) diff --git a/components/style/properties/data.py b/components/style/properties/data.py index e3f37e23570..528119cff26 100644 --- a/components/style/properties/data.py +++ b/components/style/properties/data.py @@ -153,7 +153,7 @@ def arg_to_bool(arg): class Longhand(object): def __init__(self, style_struct, name, spec=None, animation_value_type=None, derived_from=None, keyword=None, predefined_type=None, custom_cascade=False, experimental=False, internal=False, - need_clone=False, need_index=False, gecko_ffi_name=None, + need_index=False, gecko_ffi_name=None, allowed_in_keyframe_block=True, cast_type='u8', logical=False, alias=None, extra_prefixes=None, boxed=False, flags=None, allowed_in_page_rule=False, allow_quirks=False, ignored_when_colors_disabled=False, @@ -209,11 +209,6 @@ class Longhand(object): self.animatable = False self.transitionable = False self.animation_type = None - # NB: Animate implies clone because a property animation requires a - # copy of the computed value. - # - # See components/style/helpers/animated_properties.mako.rs. - self.need_clone = need_clone or self.animatable class Shorthand(object): diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 0b5f2972c20..c28307b5d68 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -527,77 +527,65 @@ def set_gecko_property(ffi_name, expr): } -<%def name="impl_keyword(ident, gecko_ffi_name, keyword, need_clone, cast_type='u8', **kwargs)"> +<%def name="impl_keyword(ident, gecko_ffi_name, keyword, cast_type='u8', **kwargs)"> <%call expr="impl_keyword_setter(ident, gecko_ffi_name, keyword, cast_type, **kwargs)"> <%call expr="impl_simple_copy(ident, gecko_ffi_name, **kwargs)"> -%if need_clone: <%call expr="impl_keyword_clone(ident, gecko_ffi_name, keyword, cast_type)"> -% endif -<%def name="impl_simple(ident, gecko_ffi_name, need_clone=False)"> +<%def name="impl_simple(ident, gecko_ffi_name)"> <%call expr="impl_simple_setter(ident, gecko_ffi_name)"> <%call expr="impl_simple_copy(ident, gecko_ffi_name)"> -% if need_clone: - <%call expr="impl_simple_clone(ident, gecko_ffi_name)"> -% endif +<%call expr="impl_simple_clone(ident, gecko_ffi_name)"> -<%def name="impl_absolute_length(ident, gecko_ffi_name, need_clone=False)"> +<%def name="impl_absolute_length(ident, gecko_ffi_name)"> #[allow(non_snake_case)] pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { ${set_gecko_property(gecko_ffi_name, "v.to_i32_au()")} } <%call expr="impl_simple_copy(ident, gecko_ffi_name)"> - % if need_clone: - #[allow(non_snake_case)] - pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { - Au(self.gecko.${gecko_ffi_name}).into() - } - % endif + #[allow(non_snake_case)] + pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { + Au(self.gecko.${gecko_ffi_name}).into() + } -<%def name="impl_position(ident, gecko_ffi_name, need_clone=False)"> +<%def name="impl_position(ident, gecko_ffi_name)"> #[allow(non_snake_case)] pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { ${set_gecko_property("%s.mXPosition" % gecko_ffi_name, "v.horizontal.into()")} ${set_gecko_property("%s.mYPosition" % gecko_ffi_name, "v.vertical.into()")} } <%call expr="impl_simple_copy(ident, gecko_ffi_name)"> - % if need_clone: - #[allow(non_snake_case)] - pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { - longhands::${ident}::computed_value::T { - horizontal: self.gecko.${gecko_ffi_name}.mXPosition.into(), - vertical: self.gecko.${gecko_ffi_name}.mYPosition.into(), - } + #[allow(non_snake_case)] + pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { + longhands::${ident}::computed_value::T { + horizontal: self.gecko.${gecko_ffi_name}.mXPosition.into(), + vertical: self.gecko.${gecko_ffi_name}.mYPosition.into(), } - % endif + } -<%def name="impl_color(ident, gecko_ffi_name, need_clone=False)"> +<%def name="impl_color(ident, gecko_ffi_name)"> <%call expr="impl_color_setter(ident, gecko_ffi_name)"> <%call expr="impl_color_copy(ident, gecko_ffi_name)"> -% if need_clone: - <%call expr="impl_color_clone(ident, gecko_ffi_name)"> -% endif +<%call expr="impl_color_clone(ident, gecko_ffi_name)"> -<%def name="impl_rgba_color(ident, gecko_ffi_name, need_clone=False)"> +<%def name="impl_rgba_color(ident, gecko_ffi_name)"> #[allow(non_snake_case)] pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { ${set_gecko_property(gecko_ffi_name, "convert_rgba_to_nscolor(&v)")} } <%call expr="impl_simple_copy(ident, gecko_ffi_name)"> - % if need_clone: - #[allow(non_snake_case)] - pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { - convert_nscolor_to_rgba(${get_gecko_property(gecko_ffi_name)}) - } - % endif + #[allow(non_snake_case)] + pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { + convert_nscolor_to_rgba(${get_gecko_property(gecko_ffi_name)}) + } -<%def name="impl_svg_length(ident, gecko_ffi_name, need_clone=False)"> +<%def name="impl_svg_length(ident, gecko_ffi_name)"> // When context-value is used on an SVG length, the corresponding flag is // set on mContextFlags, and the length field is set to the initial value. @@ -663,7 +651,7 @@ def set_gecko_property(ffi_name, expr): } -<%def name="impl_svg_opacity(ident, gecko_ffi_name, need_clone=False)"> +<%def name="impl_svg_opacity(ident, gecko_ffi_name)"> <% source_prefix = ident.split("_")[0].upper() + "_OPACITY_SOURCE" %> pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { @@ -724,7 +712,7 @@ def set_gecko_property(ffi_name, expr): } -<%def name="impl_svg_paint(ident, gecko_ffi_name, need_clone=False)"> +<%def name="impl_svg_paint(ident, gecko_ffi_name)"> #[allow(non_snake_case)] pub fn set_${ident}(&mut self, mut v: longhands::${ident}::computed_value::T) { use values::generics::svg::SVGPaintKind; @@ -826,7 +814,7 @@ def set_gecko_property(ffi_name, expr): } -<%def name="impl_non_negative_length(ident, gecko_ffi_name, need_clone, inherit_from=None, +<%def name="impl_non_negative_length(ident, gecko_ffi_name, inherit_from=None, round_to_pixels=False)"> #[allow(non_snake_case)] pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { @@ -868,15 +856,13 @@ def set_gecko_property(ffi_name, expr): self.copy_${ident}_from(other) } -%if need_clone: #[allow(non_snake_case)] pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { Au(self.gecko.${gecko_ffi_name}).into() } -% endif -<%def name="impl_split_style_coord(ident, gecko_ffi_name, index, need_clone=False)"> +<%def name="impl_split_style_coord(ident, gecko_ffi_name, index)"> #[allow(non_snake_case)] pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { v.to_gecko_style_coord(&mut self.gecko.${gecko_ffi_name}.data_at_mut(${index})); @@ -889,17 +875,16 @@ def set_gecko_property(ffi_name, expr): pub fn reset_${ident}(&mut self, other: &Self) { self.copy_${ident}_from(other) } - % if need_clone: - #[allow(non_snake_case)] - pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { - use properties::longhands::${ident}::computed_value::T; - T::from_gecko_style_coord(&self.gecko.${gecko_ffi_name}.data_at(${index})) - .expect("clone for ${ident} failed") - } - % endif + + #[allow(non_snake_case)] + pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { + use properties::longhands::${ident}::computed_value::T; + T::from_gecko_style_coord(&self.gecko.${gecko_ffi_name}.data_at(${index})) + .expect("clone for ${ident} failed") + } -<%def name="impl_style_coord(ident, gecko_ffi_name, need_clone=False)"> +<%def name="impl_style_coord(ident, gecko_ffi_name)"> #[allow(non_snake_case)] pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { v.to_gecko_style_coord(&mut self.gecko.${gecko_ffi_name}); @@ -912,14 +897,13 @@ def set_gecko_property(ffi_name, expr): pub fn reset_${ident}(&mut self, other: &Self) { self.copy_${ident}_from(other) } - % if need_clone: - #[allow(non_snake_case)] - pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { - use properties::longhands::${ident}::computed_value::T; - T::from_gecko_style_coord(&self.gecko.${gecko_ffi_name}) - .expect("clone for ${ident} failed") - } - % endif + + #[allow(non_snake_case)] + pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { + use properties::longhands::${ident}::computed_value::T; + T::from_gecko_style_coord(&self.gecko.${gecko_ffi_name}) + .expect("clone for ${ident} failed") + } <%def name="impl_style_sides(ident)"> @@ -956,7 +940,7 @@ def set_gecko_property(ffi_name, expr): } -<%def name="impl_corner_style_coord(ident, gecko_ffi_name, x_index, y_index, need_clone)"> +<%def name="impl_corner_style_coord(ident, gecko_ffi_name, x_index, y_index)"> #[allow(non_snake_case)] pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { v.0.width.to_gecko_style_coord(&mut self.gecko.${gecko_ffi_name}.data_at_mut(${x_index})); @@ -973,22 +957,21 @@ def set_gecko_property(ffi_name, expr): pub fn reset_${ident}(&mut self, other: &Self) { self.copy_${ident}_from(other) } - % if need_clone: - #[allow(non_snake_case)] - pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { - use values::computed::border::BorderCornerRadius; - let width = GeckoStyleCoordConvertible::from_gecko_style_coord( - &self.gecko.${gecko_ffi_name}.data_at(${x_index})) - .expect("Failed to clone ${ident}"); - let height = GeckoStyleCoordConvertible::from_gecko_style_coord( - &self.gecko.${gecko_ffi_name}.data_at(${y_index})) - .expect("Failed to clone ${ident}"); - BorderCornerRadius::new(width, height) - } - % endif + + #[allow(non_snake_case)] + pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { + use values::computed::border::BorderCornerRadius; + let width = GeckoStyleCoordConvertible::from_gecko_style_coord( + &self.gecko.${gecko_ffi_name}.data_at(${x_index})) + .expect("Failed to clone ${ident}"); + let height = GeckoStyleCoordConvertible::from_gecko_style_coord( + &self.gecko.${gecko_ffi_name}.data_at(${y_index})) + .expect("Failed to clone ${ident}"); + BorderCornerRadius::new(width, height) + } -<%def name="impl_css_url(ident, gecko_ffi_name, need_clone=False)"> +<%def name="impl_css_url(ident, gecko_ffi_name)"> #[allow(non_snake_case)] pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { use gecko_bindings::sugar::refptr::RefPtr; @@ -1021,26 +1004,26 @@ def set_gecko_property(ffi_name, expr): pub fn reset_${ident}(&mut self, other: &Self) { self.copy_${ident}_from(other) } - % if need_clone: - pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { - use values::specified::url::SpecifiedUrl; - use values::None_; - if self.gecko.${gecko_ffi_name}.mRawPtr.is_null() { - Either::Second(None_) - } else { - unsafe { - let ref gecko_url_value = *self.gecko.${gecko_ffi_name}.mRawPtr; - Either::First(SpecifiedUrl::from_url_value_data(&gecko_url_value._base) - .expect("${gecko_ffi_name} could not convert to SpecifiedUrl")) - } + #[allow(non_snake_case)] + pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { + use values::specified::url::SpecifiedUrl; + use values::None_; + + if self.gecko.${gecko_ffi_name}.mRawPtr.is_null() { + Either::Second(None_) + } else { + unsafe { + let ref gecko_url_value = *self.gecko.${gecko_ffi_name}.mRawPtr; + Either::First(SpecifiedUrl::from_url_value_data(&gecko_url_value._base) + .expect("${gecko_ffi_name} could not convert to SpecifiedUrl")) } } - % endif + } -<%def name="impl_logical(name, need_clone=False, **kwargs)"> - ${helpers.logical_setter(name, need_clone)} +<%def name="impl_logical(name, **kwargs)"> + ${helpers.logical_setter(name)} <%def name="impl_style_struct(style_struct)"> @@ -1200,8 +1183,7 @@ impl Clone for ${style_struct.gecko_struct_name} { } def longhand_method(longhand): - args = dict(ident=longhand.ident, gecko_ffi_name=longhand.gecko_ffi_name, - need_clone=longhand.need_clone) + args = dict(ident=longhand.ident, gecko_ffi_name=longhand.gecko_ffi_name) # get the method and pass additional keyword or type-specific arguments if longhand.logical: @@ -1272,12 +1254,10 @@ impl ${style_struct.gecko_struct_name} { pub fn reset_${longhand.ident}(&mut self, other: &Self) { self.copy_${longhand.ident}_from(other) } - % if longhand.need_clone: #[allow(non_snake_case)] pub fn clone_${longhand.ident}(&self) -> longhands::${longhand.ident}::computed_value::T { unimplemented!() } - % endif % if longhand.need_index: pub fn ${longhand.ident}_count(&self) -> usize { 0 } pub fn ${longhand.ident}_at(&self, _index: usize) @@ -1366,8 +1346,7 @@ fn static_assert() { <% impl_keyword("border_%s_style" % side.ident, "mBorderStyle[%s]" % side.index, border_style_keyword, - on_set="update_border_%s" % side.ident, - need_clone=True) %> + on_set="update_border_%s" % side.ident) %> // This is needed because the initial mComputedBorder value is set to zero. // @@ -1399,12 +1378,11 @@ fn static_assert() { self.gecko.mComputedBorder.${side.ident} = self.gecko.mBorder.${side.ident}; } - <% impl_color("border_%s_color" % side.ident, "(mBorderColor)[%s]" % side.index, need_clone=True) %> + <% impl_color("border_%s_color" % side.ident, "(mBorderColor)[%s]" % side.index) %> <% impl_non_negative_length("border_%s_width" % side.ident, "mComputedBorder.%s" % side.ident, inherit_from="mBorder.%s" % side.ident, - need_clone=True, round_to_pixels=True) %> pub fn border_${side.ident}_has_nonzero_width(&self) -> bool { @@ -1481,8 +1459,7 @@ fn static_assert() { <% impl_corner_style_coord("border_%s_radius" % corner.ident, "mBorderRadius", corner.x_index, - corner.y_index, - need_clone=True) %> + corner.y_index) %> % endfor pub fn set_border_image_source(&mut self, image: longhands::border_image_source::computed_value::T) { @@ -1601,8 +1578,7 @@ fn static_assert() { % for side in SIDES: <% impl_split_style_coord("margin_%s" % side.ident, "mMargin", - side.index, - need_clone=True) %> + side.index) %> % endfor @@ -1613,8 +1589,7 @@ fn static_assert() { % for side in SIDES: <% impl_split_style_coord("padding_%s" % side.ident, "mPadding", - side.index, - need_clone=True) %> + side.index) %> % endfor @@ -1627,8 +1602,7 @@ fn static_assert() { % for side in SIDES: <% impl_split_style_coord("%s" % side.ident, "mOffset", - side.index, - need_clone=True) %> + side.index) %> % endfor pub fn set_z_index(&mut self, v: longhands::z_index::computed_value::T) { @@ -2128,14 +2102,13 @@ fn static_assert() { <% impl_non_negative_length("outline_width", "mActualOutlineWidth", inherit_from="mOutlineWidth", - need_clone=True, round_to_pixels=True) %> + round_to_pixels=True) %> % for corner in CORNERS: <% impl_corner_style_coord("_moz_outline_radius_%s" % corner.ident.replace("_", ""), "mOutlineRadius", corner.x_index, - corner.y_index, - need_clone=True) %> + corner.y_index) %> % endfor pub fn outline_has_nonzero_width(&self) -> bool { @@ -2971,8 +2944,8 @@ fn static_assert() { } % endfor - ${impl_style_coord("scroll_snap_points_x", "mScrollSnapPointsX", True)} - ${impl_style_coord("scroll_snap_points_y", "mScrollSnapPointsY", True)} + ${impl_style_coord("scroll_snap_points_x", "mScrollSnapPointsX")} + ${impl_style_coord("scroll_snap_points_y", "mScrollSnapPointsY")} pub fn set_scroll_snap_coordinate(&mut self, v: I) where I: IntoIterator, @@ -3430,7 +3403,7 @@ fn static_assert() { <% scroll_snap_type_keyword = Keyword("scroll-snap-type", "none mandatory proximity") %> - ${impl_keyword('scroll_snap_type_y', 'mScrollSnapTypeY', scroll_snap_type_keyword, need_clone=True)} + ${impl_keyword('scroll_snap_type_y', 'mScrollSnapTypeY', scroll_snap_type_keyword)} pub fn set_perspective_origin(&mut self, v: longhands::perspective_origin::computed_value::T) { self.gecko.mPerspectiveOrigin[0].set(v.horizontal); @@ -3752,8 +3725,7 @@ fn static_assert() { } } - pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T - { + pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { use properties::longhands::${ident}::single_value::computed_value::T as Keyword; % if keyword.needs_cast(): @@ -4634,8 +4606,7 @@ fn static_assert() { <% text_align_keyword = Keyword("text-align", "start end left right center justify -moz-center -moz-left -moz-right char", gecko_strip_moz_prefix=False) %> - ${impl_keyword('text_align', 'mTextAlign', text_align_keyword, need_clone=False)} - ${impl_keyword_clone('text_align', 'mTextAlign', text_align_keyword)} + ${impl_keyword('text_align', 'mTextAlign', text_align_keyword)} pub fn set_text_shadow(&mut self, v: I) where I: IntoIterator, @@ -4814,9 +4785,8 @@ fn static_assert() { }) } - <%call expr="impl_non_negative_length('_webkit_text_stroke_width', - 'mWebkitTextStrokeWidth', - need_clone=True)"> + ${impl_non_negative_length('_webkit_text_stroke_width', + 'mWebkitTextStrokeWidth')} #[allow(non_snake_case)] pub fn set__moz_tab_size(&mut self, v: longhands::_moz_tab_size::computed_value::T) { @@ -5446,7 +5416,7 @@ clip-path longhands::cursor::computed_value::T { images, keyword } } - <%call expr="impl_color('caret_color', 'mCaretColor', need_clone=True)"> + <%call expr="impl_color('caret_color', 'mCaretColor')"> <%self:impl_trait style_struct_name="Column" @@ -5477,7 +5447,7 @@ clip-path } } - <% impl_non_negative_length("column_rule_width", "mColumnRuleWidth", need_clone=True, + <% impl_non_negative_length("column_rule_width", "mColumnRuleWidth", round_to_pixels=True) %> diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index e764fcd3d74..95d60898c0b 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -882,7 +882,7 @@ % endif -<%def name="logical_setter(name, need_clone=False)"> +<%def name="logical_setter(name)"> /// Set the appropriate physical property for ${name} given a writing mode. pub fn set_${to_rust_ident(name)}(&mut self, v: longhands::${to_rust_ident(name)}::computed_value::T, @@ -914,18 +914,16 @@ self.copy_${to_rust_ident(name)}_from(other, wm) } - % if need_clone: - /// Get the computed value for the appropriate physical property for - /// ${name} given a writing mode. - pub fn clone_${to_rust_ident(name)}(&self, wm: WritingMode) - -> longhands::${to_rust_ident(name)}::computed_value::T { - <%self:logical_setter_helper name="${name}"> - <%def name="inner(physical_ident)"> - self.clone_${physical_ident}() - - - } - % endif + /// Get the computed value for the appropriate physical property for + /// ${name} given a writing mode. + pub fn clone_${to_rust_ident(name)}(&self, wm: WritingMode) + -> longhands::${to_rust_ident(name)}::computed_value::T { + <%self:logical_setter_helper name="${name}"> + <%def name="inner(physical_ident)"> + self.clone_${physical_ident}() + + + } <%def name="alias_to_nscsspropertyid(alias)"> diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index b2801276ed5..20eea91d83d 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -14,7 +14,6 @@ // We allow "display" to apply to placeholders because we need to make the // placeholder pseudo-element an inline-block in the UA stylesheet in Gecko. <%helpers:longhand name="display" - need_clone="True" animation_value_type="discrete" custom_cascade="${product == 'servo'}" flags="APPLIES_TO_PLACEHOLDER" @@ -196,7 +195,7 @@ ${helpers.single_keyword("-moz-top-layer", "none top", gecko_constant_prefix="NS_STYLE_TOP_LAYER", - gecko_ffi_name="mTopLayer", need_clone=True, + gecko_ffi_name="mTopLayer", products="gecko", animation_value_type="none", internal=True, spec="Internal (not web-exposed)")} @@ -360,7 +359,7 @@ ${helpers.single_keyword("overflow-clip-box", "padding-box content-box", // FIXME(pcwalton, #2742): Implement scrolling for `scroll` and `auto`. ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", - need_clone=True, animation_value_type="discrete", + animation_value_type="discrete", extra_gecko_values="-moz-hidden-unscrollable", custom_consts=overflow_custom_consts, gecko_constant_prefix="NS_STYLE_OVERFLOW", @@ -368,7 +367,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", spec="https://drafts.csswg.org/css-overflow/#propdef-overflow-x")} // FIXME(pcwalton, #2742): Implement scrolling for `scroll` and `auto`. -<%helpers:longhand name="overflow-y" need_clone="True" animation_value_type="discrete" +<%helpers:longhand name="overflow-y" animation_value_type="discrete" flags="APPLIES_TO_PLACEHOLDER", spec="https://drafts.csswg.org/css-overflow/#propdef-overflow-y"> pub use super::overflow_x::{SpecifiedValue, parse, get_initial_value, computed_value}; @@ -587,7 +586,6 @@ ${helpers.single_keyword("animation-direction", ${helpers.single_keyword("animation-play-state", "running paused", - need_clone=True, need_index=True, animation_value_type="none", vector=True, @@ -1652,7 +1650,7 @@ ${helpers.predefined_type("transform-origin", // FIXME: `size` and `content` values are not implemented and `strict` is implemented // like `content`(layout style paint) in gecko. We should implement `size` and `content`, // also update the glue once they are implemented in gecko. -<%helpers:longhand name="contain" animation_value_type="discrete" products="gecko" need_clone="True" +<%helpers:longhand name="contain" animation_value_type="discrete" products="gecko" flags="FIXPOS_CB" spec="https://drafts.csswg.org/css-contain/#contain-property"> use std::fmt; diff --git a/components/style/properties/longhand/color.mako.rs b/components/style/properties/longhand/color.mako.rs index bf5b78dca47..b9722fc8fc9 100644 --- a/components/style/properties/longhand/color.mako.rs +++ b/components/style/properties/longhand/color.mako.rs @@ -15,8 +15,7 @@ ${helpers.predefined_type( animation_value_type="AnimatedRGBA", flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", ignored_when_colors_disabled="True", - spec="https://drafts.csswg.org/css-color/#color", - need_clone="True" + spec="https://drafts.csswg.org/css-color/#color" )} // FIXME(#15973): Add servo support for system colors diff --git a/components/style/properties/longhand/column.mako.rs b/components/style/properties/longhand/column.mako.rs index ddce1a518a8..1d938a256d8 100644 --- a/components/style/properties/longhand/column.mako.rs +++ b/components/style/properties/longhand/column.mako.rs @@ -56,7 +56,6 @@ ${helpers.predefined_type( products="gecko", animation_value_type="AnimatedColor", extra_prefixes="moz", - need_clone=True, ignored_when_colors_disabled=True, spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule-color", )} diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs index e7edbb1c0c1..3890332abad 100644 --- a/components/style/properties/longhand/font.mako.rs +++ b/components/style/properties/longhand/font.mako.rs @@ -429,7 +429,7 @@ ${helpers.single_keyword_system("font-variant-caps", flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", animation_value_type="discrete")} -<%helpers:longhand name="font-weight" need_clone="True" animation_value_type="ComputedValue" +<%helpers:longhand name="font-weight" animation_value_type="ComputedValue" flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER" spec="https://drafts.csswg.org/css-fonts/#propdef-font-weight"> use properties::longhands::system_font::SystemFont; @@ -596,7 +596,7 @@ ${helpers.single_keyword_system("font-variant-caps", } -<%helpers:longhand name="font-size" need_clone="True" animation_value_type="NonNegativeLength" +<%helpers:longhand name="font-size" animation_value_type="NonNegativeLength" flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER" allow_quirks="True" spec="https://drafts.csswg.org/css-fonts/#propdef-font-size"> use app_units::Au; @@ -2276,7 +2276,7 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control- <%helpers:longhand name="-moz-script-level" products="gecko" animation_value_type="none" predefined_type="Integer" gecko_ffi_name="mScriptLevel" spec="Internal (not web-exposed)" - internal="True" need_clone="True"> + internal="True"> use std::fmt; use style_traits::ToCss; @@ -2356,8 +2356,7 @@ ${helpers.single_keyword("-moz-math-display", gecko_ffi_name="mMathDisplay", products="gecko", spec="Internal (not web-exposed)", - animation_value_type="none", - need_clone="True")} + animation_value_type="none")} ${helpers.single_keyword("-moz-math-variant", """none normal bold italic bold-italic script bold-script @@ -2369,7 +2368,6 @@ ${helpers.single_keyword("-moz-math-variant", products="gecko", spec="Internal (not web-exposed)", animation_value_type="none", - need_clone="True", needs_conversion=True)} <%helpers:longhand name="-moz-script-min-size" products="gecko" animation_value_type="none" diff --git a/components/style/properties/longhand/inherited_text.mako.rs b/components/style/properties/longhand/inherited_text.mako.rs index 55a8d792733..5a93dba2c40 100644 --- a/components/style/properties/longhand/inherited_text.mako.rs +++ b/components/style/properties/longhand/inherited_text.mako.rs @@ -279,7 +279,7 @@ ${helpers.predefined_type("word-spacing", <%helpers:longhand name="-servo-text-decorations-in-effect" derived_from="display text-decoration" - need_clone="True" products="servo" + products="servo" animation_value_type="none" spec="Nonstandard (Internal property used by Servo)"> use std::fmt; @@ -685,7 +685,6 @@ ${helpers.predefined_type( initial_specified_value="specified::Color::currentcolor()", products="gecko", animation_value_type="AnimatedColor", - need_clone=True, ignored_when_colors_disabled=True, spec="https://drafts.csswg.org/css-text-decor/#propdef-text-emphasis-color", )} @@ -705,7 +704,6 @@ ${helpers.predefined_type( "computed_value::T::currentcolor()", products="gecko", animation_value_type="AnimatedColor", - need_clone=True, ignored_when_colors_disabled=True, flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", spec="https://compat.spec.whatwg.org/#the-webkit-text-fill-color", @@ -718,7 +716,7 @@ ${helpers.predefined_type( initial_specified_value="specified::Color::currentcolor()", products="gecko", animation_value_type="AnimatedColor", - need_clone=True, ignored_when_colors_disabled=True, + ignored_when_colors_disabled=True, flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-color", )} diff --git a/components/style/properties/longhand/outline.mako.rs b/components/style/properties/longhand/outline.mako.rs index ee7dcf604d0..8f0359ffdb5 100644 --- a/components/style/properties/longhand/outline.mako.rs +++ b/components/style/properties/longhand/outline.mako.rs @@ -16,7 +16,6 @@ ${helpers.predefined_type( "computed_value::T::currentcolor()", initial_specified_value="specified::Color::currentcolor()", animation_value_type="AnimatedColor", - need_clone=True, ignored_when_colors_disabled=True, spec="https://drafts.csswg.org/css-ui/#propdef-outline-color", )} diff --git a/components/style/properties/longhand/text.mako.rs b/components/style/properties/longhand/text.mako.rs index 242ddde4988..586519333d6 100644 --- a/components/style/properties/longhand/text.mako.rs +++ b/components/style/properties/longhand/text.mako.rs @@ -138,12 +138,10 @@ ${helpers.single_keyword("unicode-bidi", "normal embed isolate bidi-override isolate-override plaintext", animation_value_type="discrete", - need_clone="True", spec="https://drafts.csswg.org/css-writing-modes/#propdef-unicode-bidi")} <%helpers:longhand name="text-decoration-line" custom_cascade="${product == 'servo'}" - need_clone=True animation_value_type="discrete" flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-line"> diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 6935650fa0d..2536b49a3c8 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -1797,14 +1797,13 @@ pub mod style_structs { pub fn reset_${longhand.ident}(&mut self, other: &Self) { self.copy_${longhand.ident}_from(other) } - % if longhand.need_clone: - /// Get the computed value for ${longhand.name}. - #[allow(non_snake_case)] - #[inline] - pub fn clone_${longhand.ident}(&self) -> longhands::${longhand.ident}::computed_value::T { - self.${longhand.ident}.clone() - } - % endif + + /// Get the computed value for ${longhand.name}. + #[allow(non_snake_case)] + #[inline] + pub fn clone_${longhand.ident}(&self) -> longhands::${longhand.ident}::computed_value::T { + self.${longhand.ident}.clone() + } % endif % if longhand.need_index: /// If this longhand is indexed, get the number of elements.