style: No more need_clone.

Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
Emilio Cobos Álvarez 2017-09-17 01:10:19 +02:00
parent 3868760379
commit 680f8368ef
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
11 changed files with 119 additions and 168 deletions

View file

@ -153,7 +153,7 @@ def arg_to_bool(arg):
class Longhand(object): class Longhand(object):
def __init__(self, style_struct, name, spec=None, animation_value_type=None, derived_from=None, keyword=None, 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, 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', allowed_in_keyframe_block=True, cast_type='u8',
logical=False, alias=None, extra_prefixes=None, boxed=False, logical=False, alias=None, extra_prefixes=None, boxed=False,
flags=None, allowed_in_page_rule=False, allow_quirks=False, ignored_when_colors_disabled=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.animatable = False
self.transitionable = False self.transitionable = False
self.animation_type = None 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): class Shorthand(object):

View file

@ -527,77 +527,65 @@ def set_gecko_property(ffi_name, expr):
} }
</%def> </%def>
<%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> <%call expr="impl_keyword_setter(ident, gecko_ffi_name, keyword, cast_type, **kwargs)"></%call>
<%call expr="impl_simple_copy(ident, gecko_ffi_name, **kwargs)"></%call> <%call expr="impl_simple_copy(ident, gecko_ffi_name, **kwargs)"></%call>
%if need_clone:
<%call expr="impl_keyword_clone(ident, gecko_ffi_name, keyword, cast_type)"></%call> <%call expr="impl_keyword_clone(ident, gecko_ffi_name, keyword, cast_type)"></%call>
% endif
</%def> </%def>
<%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> <%call expr="impl_simple_setter(ident, gecko_ffi_name)"></%call>
<%call expr="impl_simple_copy(ident, gecko_ffi_name)"></%call> <%call expr="impl_simple_copy(ident, gecko_ffi_name)"></%call>
% if need_clone: <%call expr="impl_simple_clone(ident, gecko_ffi_name)"></%call>
<%call expr="impl_simple_clone(ident, gecko_ffi_name)"></%call>
% endif
</%def> </%def>
<%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)] #[allow(non_snake_case)]
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
${set_gecko_property(gecko_ffi_name, "v.to_i32_au()")} ${set_gecko_property(gecko_ffi_name, "v.to_i32_au()")}
} }
<%call expr="impl_simple_copy(ident, gecko_ffi_name)"></%call> <%call expr="impl_simple_copy(ident, gecko_ffi_name)"></%call>
% if need_clone: #[allow(non_snake_case)]
#[allow(non_snake_case)] pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { Au(self.gecko.${gecko_ffi_name}).into()
Au(self.gecko.${gecko_ffi_name}).into() }
}
% endif
</%def> </%def>
<%def name="impl_position(ident, gecko_ffi_name, need_clone=False)"> <%def name="impl_position(ident, gecko_ffi_name)">
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { 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.mXPosition" % gecko_ffi_name, "v.horizontal.into()")}
${set_gecko_property("%s.mYPosition" % gecko_ffi_name, "v.vertical.into()")} ${set_gecko_property("%s.mYPosition" % gecko_ffi_name, "v.vertical.into()")}
} }
<%call expr="impl_simple_copy(ident, gecko_ffi_name)"></%call> <%call expr="impl_simple_copy(ident, gecko_ffi_name)"></%call>
% if need_clone: #[allow(non_snake_case)]
#[allow(non_snake_case)] pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { longhands::${ident}::computed_value::T {
longhands::${ident}::computed_value::T { horizontal: self.gecko.${gecko_ffi_name}.mXPosition.into(),
horizontal: self.gecko.${gecko_ffi_name}.mXPosition.into(), vertical: self.gecko.${gecko_ffi_name}.mYPosition.into(),
vertical: self.gecko.${gecko_ffi_name}.mYPosition.into(),
}
} }
% endif }
</%def> </%def>
<%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> <%call expr="impl_color_setter(ident, gecko_ffi_name)"></%call>
<%call expr="impl_color_copy(ident, gecko_ffi_name)"></%call> <%call expr="impl_color_copy(ident, gecko_ffi_name)"></%call>
% if need_clone: <%call expr="impl_color_clone(ident, gecko_ffi_name)"></%call>
<%call expr="impl_color_clone(ident, gecko_ffi_name)"></%call>
% endif
</%def> </%def>
<%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)] #[allow(non_snake_case)]
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
${set_gecko_property(gecko_ffi_name, "convert_rgba_to_nscolor(&v)")} ${set_gecko_property(gecko_ffi_name, "convert_rgba_to_nscolor(&v)")}
} }
<%call expr="impl_simple_copy(ident, gecko_ffi_name)"></%call> <%call expr="impl_simple_copy(ident, gecko_ffi_name)"></%call>
% if need_clone: #[allow(non_snake_case)]
#[allow(non_snake_case)] pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { convert_nscolor_to_rgba(${get_gecko_property(gecko_ffi_name)})
convert_nscolor_to_rgba(${get_gecko_property(gecko_ffi_name)}) }
}
% endif
</%def> </%def>
<%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 // 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. // 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> </%def>
<%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" %> <% source_prefix = ident.split("_")[0].upper() + "_OPACITY_SOURCE" %>
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
@ -724,7 +712,7 @@ def set_gecko_property(ffi_name, expr):
} }
</%def> </%def>
<%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)] #[allow(non_snake_case)]
pub fn set_${ident}(&mut self, mut v: longhands::${ident}::computed_value::T) { pub fn set_${ident}(&mut self, mut v: longhands::${ident}::computed_value::T) {
use values::generics::svg::SVGPaintKind; use values::generics::svg::SVGPaintKind;
@ -826,7 +814,7 @@ def set_gecko_property(ffi_name, expr):
} }
</%def> </%def>
<%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)"> round_to_pixels=False)">
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { 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) self.copy_${ident}_from(other)
} }
%if need_clone:
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
Au(self.gecko.${gecko_ffi_name}).into() Au(self.gecko.${gecko_ffi_name}).into()
} }
% endif
</%def> </%def>
<%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)] #[allow(non_snake_case)]
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { 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})); 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) { pub fn reset_${ident}(&mut self, other: &Self) {
self.copy_${ident}_from(other) self.copy_${ident}_from(other)
} }
% if need_clone:
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
use properties::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})) T::from_gecko_style_coord(&self.gecko.${gecko_ffi_name}.data_at(${index}))
.expect("clone for ${ident} failed") .expect("clone for ${ident} failed")
} }
% endif
</%def> </%def>
<%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)] #[allow(non_snake_case)]
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
v.to_gecko_style_coord(&mut self.gecko.${gecko_ffi_name}); 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) { pub fn reset_${ident}(&mut self, other: &Self) {
self.copy_${ident}_from(other) self.copy_${ident}_from(other)
} }
% if need_clone:
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
use properties::longhands::${ident}::computed_value::T; use properties::longhands::${ident}::computed_value::T;
T::from_gecko_style_coord(&self.gecko.${gecko_ffi_name}) T::from_gecko_style_coord(&self.gecko.${gecko_ffi_name})
.expect("clone for ${ident} failed") .expect("clone for ${ident} failed")
} }
% endif
</%def> </%def>
<%def name="impl_style_sides(ident)"> <%def name="impl_style_sides(ident)">
@ -956,7 +940,7 @@ def set_gecko_property(ffi_name, expr):
} }
</%def> </%def>
<%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)] #[allow(non_snake_case)]
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { 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})); 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) { pub fn reset_${ident}(&mut self, other: &Self) {
self.copy_${ident}_from(other) self.copy_${ident}_from(other)
} }
% if need_clone:
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
use values::computed::border::BorderCornerRadius; use values::computed::border::BorderCornerRadius;
let width = GeckoStyleCoordConvertible::from_gecko_style_coord( let width = GeckoStyleCoordConvertible::from_gecko_style_coord(
&self.gecko.${gecko_ffi_name}.data_at(${x_index})) &self.gecko.${gecko_ffi_name}.data_at(${x_index}))
.expect("Failed to clone ${ident}"); .expect("Failed to clone ${ident}");
let height = GeckoStyleCoordConvertible::from_gecko_style_coord( let height = GeckoStyleCoordConvertible::from_gecko_style_coord(
&self.gecko.${gecko_ffi_name}.data_at(${y_index})) &self.gecko.${gecko_ffi_name}.data_at(${y_index}))
.expect("Failed to clone ${ident}"); .expect("Failed to clone ${ident}");
BorderCornerRadius::new(width, height) BorderCornerRadius::new(width, height)
} }
% endif
</%def> </%def>
<%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)] #[allow(non_snake_case)]
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
use gecko_bindings::sugar::refptr::RefPtr; 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) { pub fn reset_${ident}(&mut self, other: &Self) {
self.copy_${ident}_from(other) 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() { #[allow(non_snake_case)]
Either::Second(None_) pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
} else { use values::specified::url::SpecifiedUrl;
unsafe { use values::None_;
let ref gecko_url_value = *self.gecko.${gecko_ffi_name}.mRawPtr;
Either::First(SpecifiedUrl::from_url_value_data(&gecko_url_value._base) if self.gecko.${gecko_ffi_name}.mRawPtr.is_null() {
.expect("${gecko_ffi_name} could not convert to SpecifiedUrl")) 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> </%def>
<%def name="impl_logical(name, need_clone=False, **kwargs)"> <%def name="impl_logical(name, **kwargs)">
${helpers.logical_setter(name, need_clone)} ${helpers.logical_setter(name)}
</%def> </%def>
<%def name="impl_style_struct(style_struct)"> <%def name="impl_style_struct(style_struct)">
@ -1200,8 +1183,7 @@ impl Clone for ${style_struct.gecko_struct_name} {
} }
def longhand_method(longhand): def longhand_method(longhand):
args = dict(ident=longhand.ident, gecko_ffi_name=longhand.gecko_ffi_name, args = dict(ident=longhand.ident, gecko_ffi_name=longhand.gecko_ffi_name)
need_clone=longhand.need_clone)
# get the method and pass additional keyword or type-specific arguments # get the method and pass additional keyword or type-specific arguments
if longhand.logical: if longhand.logical:
@ -1272,12 +1254,10 @@ impl ${style_struct.gecko_struct_name} {
pub fn reset_${longhand.ident}(&mut self, other: &Self) { pub fn reset_${longhand.ident}(&mut self, other: &Self) {
self.copy_${longhand.ident}_from(other) self.copy_${longhand.ident}_from(other)
} }
% if longhand.need_clone:
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn clone_${longhand.ident}(&self) -> longhands::${longhand.ident}::computed_value::T { pub fn clone_${longhand.ident}(&self) -> longhands::${longhand.ident}::computed_value::T {
unimplemented!() unimplemented!()
} }
% endif
% if longhand.need_index: % if longhand.need_index:
pub fn ${longhand.ident}_count(&self) -> usize { 0 } pub fn ${longhand.ident}_count(&self) -> usize { 0 }
pub fn ${longhand.ident}_at(&self, _index: usize) pub fn ${longhand.ident}_at(&self, _index: usize)
@ -1366,8 +1346,7 @@ fn static_assert() {
<% impl_keyword("border_%s_style" % side.ident, <% impl_keyword("border_%s_style" % side.ident,
"mBorderStyle[%s]" % side.index, "mBorderStyle[%s]" % side.index,
border_style_keyword, border_style_keyword,
on_set="update_border_%s" % side.ident, on_set="update_border_%s" % side.ident) %>
need_clone=True) %>
// This is needed because the initial mComputedBorder value is set to zero. // 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}; 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, <% impl_non_negative_length("border_%s_width" % side.ident,
"mComputedBorder.%s" % side.ident, "mComputedBorder.%s" % side.ident,
inherit_from="mBorder.%s" % side.ident, inherit_from="mBorder.%s" % side.ident,
need_clone=True,
round_to_pixels=True) %> round_to_pixels=True) %>
pub fn border_${side.ident}_has_nonzero_width(&self) -> bool { 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, <% impl_corner_style_coord("border_%s_radius" % corner.ident,
"mBorderRadius", "mBorderRadius",
corner.x_index, corner.x_index,
corner.y_index, corner.y_index) %>
need_clone=True) %>
% endfor % endfor
pub fn set_border_image_source(&mut self, image: longhands::border_image_source::computed_value::T) { 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: % for side in SIDES:
<% impl_split_style_coord("margin_%s" % side.ident, <% impl_split_style_coord("margin_%s" % side.ident,
"mMargin", "mMargin",
side.index, side.index) %>
need_clone=True) %>
% endfor % endfor
</%self:impl_trait> </%self:impl_trait>
@ -1613,8 +1589,7 @@ fn static_assert() {
% for side in SIDES: % for side in SIDES:
<% impl_split_style_coord("padding_%s" % side.ident, <% impl_split_style_coord("padding_%s" % side.ident,
"mPadding", "mPadding",
side.index, side.index) %>
need_clone=True) %>
% endfor % endfor
</%self:impl_trait> </%self:impl_trait>
@ -1627,8 +1602,7 @@ fn static_assert() {
% for side in SIDES: % for side in SIDES:
<% impl_split_style_coord("%s" % side.ident, <% impl_split_style_coord("%s" % side.ident,
"mOffset", "mOffset",
side.index, side.index) %>
need_clone=True) %>
% endfor % endfor
pub fn set_z_index(&mut self, v: longhands::z_index::computed_value::T) { 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", <% impl_non_negative_length("outline_width", "mActualOutlineWidth",
inherit_from="mOutlineWidth", inherit_from="mOutlineWidth",
need_clone=True, round_to_pixels=True) %> round_to_pixels=True) %>
% for corner in CORNERS: % for corner in CORNERS:
<% impl_corner_style_coord("_moz_outline_radius_%s" % corner.ident.replace("_", ""), <% impl_corner_style_coord("_moz_outline_radius_%s" % corner.ident.replace("_", ""),
"mOutlineRadius", "mOutlineRadius",
corner.x_index, corner.x_index,
corner.y_index, corner.y_index) %>
need_clone=True) %>
% endfor % endfor
pub fn outline_has_nonzero_width(&self) -> bool { pub fn outline_has_nonzero_width(&self) -> bool {
@ -2971,8 +2944,8 @@ fn static_assert() {
} }
% endfor % endfor
${impl_style_coord("scroll_snap_points_x", "mScrollSnapPointsX", True)} ${impl_style_coord("scroll_snap_points_x", "mScrollSnapPointsX")}
${impl_style_coord("scroll_snap_points_y", "mScrollSnapPointsY", True)} ${impl_style_coord("scroll_snap_points_y", "mScrollSnapPointsY")}
pub fn set_scroll_snap_coordinate<I>(&mut self, v: I) pub fn set_scroll_snap_coordinate<I>(&mut self, v: I)
where I: IntoIterator<Item = longhands::scroll_snap_coordinate::computed_value::single_value::T>, where I: IntoIterator<Item = longhands::scroll_snap_coordinate::computed_value::single_value::T>,
@ -3430,7 +3403,7 @@ fn static_assert() {
<% scroll_snap_type_keyword = Keyword("scroll-snap-type", "none mandatory proximity") %> <% 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) { pub fn set_perspective_origin(&mut self, v: longhands::perspective_origin::computed_value::T) {
self.gecko.mPerspectiveOrigin[0].set(v.horizontal); 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; use properties::longhands::${ident}::single_value::computed_value::T as Keyword;
% if keyword.needs_cast(): % if keyword.needs_cast():
@ -4634,8 +4606,7 @@ fn static_assert() {
<% text_align_keyword = Keyword("text-align", <% text_align_keyword = Keyword("text-align",
"start end left right center justify -moz-center -moz-left -moz-right char", "start end left right center justify -moz-center -moz-left -moz-right char",
gecko_strip_moz_prefix=False) %> gecko_strip_moz_prefix=False) %>
${impl_keyword('text_align', 'mTextAlign', text_align_keyword, need_clone=False)} ${impl_keyword('text_align', 'mTextAlign', text_align_keyword)}
${impl_keyword_clone('text_align', 'mTextAlign', text_align_keyword)}
pub fn set_text_shadow<I>(&mut self, v: I) pub fn set_text_shadow<I>(&mut self, v: I)
where I: IntoIterator<Item = SimpleShadow>, where I: IntoIterator<Item = SimpleShadow>,
@ -4814,9 +4785,8 @@ fn static_assert() {
}) })
} }
<%call expr="impl_non_negative_length('_webkit_text_stroke_width', ${impl_non_negative_length('_webkit_text_stroke_width',
'mWebkitTextStrokeWidth', 'mWebkitTextStrokeWidth')}
need_clone=True)"></%call>
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn set__moz_tab_size(&mut self, v: longhands::_moz_tab_size::computed_value::T) { 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 } longhands::cursor::computed_value::T { images, keyword }
} }
<%call expr="impl_color('caret_color', 'mCaretColor', need_clone=True)"></%call> <%call expr="impl_color('caret_color', 'mCaretColor')"></%call>
</%self:impl_trait> </%self:impl_trait>
<%self:impl_trait style_struct_name="Column" <%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) %> round_to_pixels=True) %>
</%self:impl_trait> </%self:impl_trait>

View file

@ -882,7 +882,7 @@
% endif % endif
</%def> </%def>
<%def name="logical_setter(name, need_clone=False)"> <%def name="logical_setter(name)">
/// Set the appropriate physical property for ${name} given a writing mode. /// Set the appropriate physical property for ${name} given a writing mode.
pub fn set_${to_rust_ident(name)}(&mut self, pub fn set_${to_rust_ident(name)}(&mut self,
v: longhands::${to_rust_ident(name)}::computed_value::T, v: longhands::${to_rust_ident(name)}::computed_value::T,
@ -914,18 +914,16 @@
self.copy_${to_rust_ident(name)}_from(other, wm) self.copy_${to_rust_ident(name)}_from(other, wm)
} }
% if need_clone: /// Get the computed value for the appropriate physical property for
/// Get the computed value for the appropriate physical property for /// ${name} given a writing mode.
/// ${name} given a writing mode. pub fn clone_${to_rust_ident(name)}(&self, wm: WritingMode)
pub fn clone_${to_rust_ident(name)}(&self, wm: WritingMode) -> longhands::${to_rust_ident(name)}::computed_value::T {
-> longhands::${to_rust_ident(name)}::computed_value::T { <%self:logical_setter_helper name="${name}">
<%self:logical_setter_helper name="${name}"> <%def name="inner(physical_ident)">
<%def name="inner(physical_ident)"> self.clone_${physical_ident}()
self.clone_${physical_ident}() </%def>
</%def> </%self:logical_setter_helper>
</%self:logical_setter_helper> }
}
% endif
</%def> </%def>
<%def name="alias_to_nscsspropertyid(alias)"> <%def name="alias_to_nscsspropertyid(alias)">

View file

@ -14,7 +14,6 @@
// We allow "display" to apply to placeholders because we need to make the // 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. // placeholder pseudo-element an inline-block in the UA stylesheet in Gecko.
<%helpers:longhand name="display" <%helpers:longhand name="display"
need_clone="True"
animation_value_type="discrete" animation_value_type="discrete"
custom_cascade="${product == 'servo'}" custom_cascade="${product == 'servo'}"
flags="APPLIES_TO_PLACEHOLDER" flags="APPLIES_TO_PLACEHOLDER"
@ -196,7 +195,7 @@
${helpers.single_keyword("-moz-top-layer", "none top", ${helpers.single_keyword("-moz-top-layer", "none top",
gecko_constant_prefix="NS_STYLE_TOP_LAYER", 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, products="gecko", animation_value_type="none", internal=True,
spec="Internal (not web-exposed)")} 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`. // FIXME(pcwalton, #2742): Implement scrolling for `scroll` and `auto`.
${helpers.single_keyword("overflow-x", "visible hidden scroll 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", extra_gecko_values="-moz-hidden-unscrollable",
custom_consts=overflow_custom_consts, custom_consts=overflow_custom_consts,
gecko_constant_prefix="NS_STYLE_OVERFLOW", 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")} spec="https://drafts.csswg.org/css-overflow/#propdef-overflow-x")}
// FIXME(pcwalton, #2742): Implement scrolling for `scroll` and `auto`. // 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", flags="APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-overflow/#propdef-overflow-y"> spec="https://drafts.csswg.org/css-overflow/#propdef-overflow-y">
pub use super::overflow_x::{SpecifiedValue, parse, get_initial_value, computed_value}; 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", ${helpers.single_keyword("animation-play-state",
"running paused", "running paused",
need_clone=True,
need_index=True, need_index=True,
animation_value_type="none", animation_value_type="none",
vector=True, vector=True,
@ -1652,7 +1650,7 @@ ${helpers.predefined_type("transform-origin",
// FIXME: `size` and `content` values are not implemented and `strict` is implemented // 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`, // like `content`(layout style paint) in gecko. We should implement `size` and `content`,
// also update the glue once they are implemented in gecko. // 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" flags="FIXPOS_CB"
spec="https://drafts.csswg.org/css-contain/#contain-property"> spec="https://drafts.csswg.org/css-contain/#contain-property">
use std::fmt; use std::fmt;

View file

@ -15,8 +15,7 @@ ${helpers.predefined_type(
animation_value_type="AnimatedRGBA", animation_value_type="AnimatedRGBA",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
ignored_when_colors_disabled="True", ignored_when_colors_disabled="True",
spec="https://drafts.csswg.org/css-color/#color", spec="https://drafts.csswg.org/css-color/#color"
need_clone="True"
)} )}
// FIXME(#15973): Add servo support for system colors // FIXME(#15973): Add servo support for system colors

View file

@ -56,7 +56,6 @@ ${helpers.predefined_type(
products="gecko", products="gecko",
animation_value_type="AnimatedColor", animation_value_type="AnimatedColor",
extra_prefixes="moz", extra_prefixes="moz",
need_clone=True,
ignored_when_colors_disabled=True, ignored_when_colors_disabled=True,
spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule-color", spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule-color",
)} )}

View file

@ -429,7 +429,7 @@ ${helpers.single_keyword_system("font-variant-caps",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
animation_value_type="discrete")} 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" flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-fonts/#propdef-font-weight"> spec="https://drafts.csswg.org/css-fonts/#propdef-font-weight">
use properties::longhands::system_font::SystemFont; use properties::longhands::system_font::SystemFont;
@ -596,7 +596,7 @@ ${helpers.single_keyword_system("font-variant-caps",
} }
</%helpers:longhand> </%helpers:longhand>
<%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" 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"> allow_quirks="True" spec="https://drafts.csswg.org/css-fonts/#propdef-font-size">
use app_units::Au; 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" <%helpers:longhand name="-moz-script-level" products="gecko" animation_value_type="none"
predefined_type="Integer" gecko_ffi_name="mScriptLevel" predefined_type="Integer" gecko_ffi_name="mScriptLevel"
spec="Internal (not web-exposed)" spec="Internal (not web-exposed)"
internal="True" need_clone="True"> internal="True">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
@ -2356,8 +2356,7 @@ ${helpers.single_keyword("-moz-math-display",
gecko_ffi_name="mMathDisplay", gecko_ffi_name="mMathDisplay",
products="gecko", products="gecko",
spec="Internal (not web-exposed)", spec="Internal (not web-exposed)",
animation_value_type="none", animation_value_type="none")}
need_clone="True")}
${helpers.single_keyword("-moz-math-variant", ${helpers.single_keyword("-moz-math-variant",
"""none normal bold italic bold-italic script bold-script """none normal bold italic bold-italic script bold-script
@ -2369,7 +2368,6 @@ ${helpers.single_keyword("-moz-math-variant",
products="gecko", products="gecko",
spec="Internal (not web-exposed)", spec="Internal (not web-exposed)",
animation_value_type="none", animation_value_type="none",
need_clone="True",
needs_conversion=True)} needs_conversion=True)}
<%helpers:longhand name="-moz-script-min-size" products="gecko" animation_value_type="none" <%helpers:longhand name="-moz-script-min-size" products="gecko" animation_value_type="none"

View file

@ -279,7 +279,7 @@ ${helpers.predefined_type("word-spacing",
<%helpers:longhand name="-servo-text-decorations-in-effect" <%helpers:longhand name="-servo-text-decorations-in-effect"
derived_from="display text-decoration" derived_from="display text-decoration"
need_clone="True" products="servo" products="servo"
animation_value_type="none" animation_value_type="none"
spec="Nonstandard (Internal property used by Servo)"> spec="Nonstandard (Internal property used by Servo)">
use std::fmt; use std::fmt;
@ -685,7 +685,6 @@ ${helpers.predefined_type(
initial_specified_value="specified::Color::currentcolor()", initial_specified_value="specified::Color::currentcolor()",
products="gecko", products="gecko",
animation_value_type="AnimatedColor", animation_value_type="AnimatedColor",
need_clone=True,
ignored_when_colors_disabled=True, ignored_when_colors_disabled=True,
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-emphasis-color", spec="https://drafts.csswg.org/css-text-decor/#propdef-text-emphasis-color",
)} )}
@ -705,7 +704,6 @@ ${helpers.predefined_type(
"computed_value::T::currentcolor()", "computed_value::T::currentcolor()",
products="gecko", products="gecko",
animation_value_type="AnimatedColor", 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", flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://compat.spec.whatwg.org/#the-webkit-text-fill-color", spec="https://compat.spec.whatwg.org/#the-webkit-text-fill-color",
@ -718,7 +716,7 @@ ${helpers.predefined_type(
initial_specified_value="specified::Color::currentcolor()", initial_specified_value="specified::Color::currentcolor()",
products="gecko", products="gecko",
animation_value_type="AnimatedColor", 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", flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-color", spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-color",
)} )}

View file

@ -16,7 +16,6 @@ ${helpers.predefined_type(
"computed_value::T::currentcolor()", "computed_value::T::currentcolor()",
initial_specified_value="specified::Color::currentcolor()", initial_specified_value="specified::Color::currentcolor()",
animation_value_type="AnimatedColor", animation_value_type="AnimatedColor",
need_clone=True,
ignored_when_colors_disabled=True, ignored_when_colors_disabled=True,
spec="https://drafts.csswg.org/css-ui/#propdef-outline-color", spec="https://drafts.csswg.org/css-ui/#propdef-outline-color",
)} )}

View file

@ -138,12 +138,10 @@
${helpers.single_keyword("unicode-bidi", ${helpers.single_keyword("unicode-bidi",
"normal embed isolate bidi-override isolate-override plaintext", "normal embed isolate bidi-override isolate-override plaintext",
animation_value_type="discrete", animation_value_type="discrete",
need_clone="True",
spec="https://drafts.csswg.org/css-writing-modes/#propdef-unicode-bidi")} spec="https://drafts.csswg.org/css-writing-modes/#propdef-unicode-bidi")}
<%helpers:longhand name="text-decoration-line" <%helpers:longhand name="text-decoration-line"
custom_cascade="${product == 'servo'}" custom_cascade="${product == 'servo'}"
need_clone=True
animation_value_type="discrete" animation_value_type="discrete"
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-line"> spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-line">

View file

@ -1797,14 +1797,13 @@ pub mod style_structs {
pub fn reset_${longhand.ident}(&mut self, other: &Self) { pub fn reset_${longhand.ident}(&mut self, other: &Self) {
self.copy_${longhand.ident}_from(other) self.copy_${longhand.ident}_from(other)
} }
% if longhand.need_clone:
/// Get the computed value for ${longhand.name}. /// Get the computed value for ${longhand.name}.
#[allow(non_snake_case)] #[allow(non_snake_case)]
#[inline] #[inline]
pub fn clone_${longhand.ident}(&self) -> longhands::${longhand.ident}::computed_value::T { pub fn clone_${longhand.ident}(&self) -> longhands::${longhand.ident}::computed_value::T {
self.${longhand.ident}.clone() self.${longhand.ident}.clone()
} }
% endif
% endif % endif
% if longhand.need_index: % if longhand.need_index:
/// If this longhand is indexed, get the number of elements. /// If this longhand is indexed, get the number of elements.