diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 2eb82fc3184..9a2ab2135fc 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -398,6 +398,11 @@ impl ${style_struct.gecko_struct_name} { self.${on_set}(); % endif } + + #[allow(non_snake_case)] + pub fn reset_${ident}(&mut self, other: &Self) { + self.copy_${ident}_from(other) + } <%def name="impl_coord_copy(ident, gecko_ffi_name)"> @@ -405,6 +410,11 @@ impl ${style_struct.gecko_struct_name} { pub fn copy_${ident}_from(&mut self, other: &Self) { self.gecko.${gecko_ffi_name}.copy_from(&other.gecko.${gecko_ffi_name}); } + + #[allow(non_snake_case)] + pub fn reset_${ident}(&mut self, other: &Self) { + self.copy_${ident}_from(other) + } <%! @@ -482,6 +492,11 @@ def set_gecko_property(ffi_name, expr): let color = ${get_gecko_property(gecko_ffi_name, self_param = "other")}; ${set_gecko_property(gecko_ffi_name, "color")}; } + + #[allow(non_snake_case)] + pub fn reset_${ident}(&mut self, other: &Self) { + self.copy_${ident}_from(other) + } <%def name="impl_color_clone(ident, gecko_ffi_name)"> @@ -610,6 +625,11 @@ def set_gecko_property(ffi_name, expr): } } + #[allow(non_snake_case)] + pub fn reset_${ident}(&mut self, other: &Self) { + self.copy_${ident}_from(other) + } + #[allow(non_snake_case)] pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { use values::generics::{SVGPaint, SVGPaintKind}; @@ -673,12 +693,20 @@ def set_gecko_property(ffi_name, expr): // // In practice, this means that we may have an incorrect value here, but // we'll adjust that properly in the style fixup phase. + // + // FIXME(emilio): We could clean this up a bit special-casing the reset_ + // function below. self.gecko.${gecko_ffi_name} = other.gecko.${inherit_from}; % else: self.gecko.${gecko_ffi_name} = other.gecko.${gecko_ffi_name}; % endif } + #[allow(non_snake_case)] + 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 { @@ -696,6 +724,10 @@ def set_gecko_property(ffi_name, expr): pub fn copy_${ident}_from(&mut self, other: &Self) { self.gecko.${gecko_ffi_name}.data_at_mut(${index}).copy_from(&other.gecko.${gecko_ffi_name}.data_at(${index})); } + #[allow(non_snake_case)] + 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 { @@ -715,6 +747,10 @@ def set_gecko_property(ffi_name, expr): pub fn copy_${ident}_from(&mut self, other: &Self) { self.gecko.${gecko_ffi_name}.copy_from(&other.gecko.${gecko_ffi_name}); } + #[allow(non_snake_case)] + 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 { @@ -752,6 +788,11 @@ def set_gecko_property(ffi_name, expr): % endfor ${ caller.body() } } + + #[allow(non_snake_case)] + pub fn reset_${ident}(&mut self, other: &Self) { + self.copy_${ident}_from(other) + } <%def name="impl_corner_style_coord(ident, gecko_ffi_name, x_index, y_index, need_clone)"> @@ -767,6 +808,10 @@ def set_gecko_property(ffi_name, expr): self.gecko.${gecko_ffi_name}.data_at_mut(${y_index}) .copy_from(&other.gecko.${gecko_ffi_name}.data_at(${y_index})); } + #[allow(non_snake_case)] + 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 { @@ -811,6 +856,10 @@ def set_gecko_property(ffi_name, expr): self.gecko.${gecko_ffi_name}.set(&other.gecko.${gecko_ffi_name}); } } + #[allow(non_snake_case)] + 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; @@ -989,6 +1038,10 @@ impl ${style_struct.gecko_struct_name} { pub fn copy_${longhand.ident}_from(&mut self, _: &Self) { warn!("stylo: Unimplemented property setter: ${longhand.name}"); } + #[allow(non_snake_case)] + 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 { @@ -1164,6 +1217,11 @@ fn static_assert() { } } + #[allow(non_snake_case)] + pub fn reset__moz_border_${side.ident}_colors(&mut self, other: &Self) { + self.copy__moz_border_${side.ident}_colors_from(other) + } + #[allow(non_snake_case)] pub fn clone__moz_border_${side.ident}_colors(&self) -> longhands::_moz_border_${side.ident}_colors::computed_value::T { @@ -1215,6 +1273,10 @@ fn static_assert() { } } + pub fn reset_border_image_source(&mut self, other: &Self) { + self.copy_border_image_source_from(other) + } + pub fn clone_border_image_source(&self) -> longhands::border_image_source::computed_value::T { use values::None_; @@ -1250,6 +1312,10 @@ fn static_assert() { self.gecko.mBorderImageRepeatV = other.gecko.mBorderImageRepeatV; } + pub fn reset_border_image_repeat(&mut self, other: &Self) { + self.copy_border_image_repeat_from(other) + } + pub fn clone_border_image_repeat(&self) -> longhands::border_image_repeat::computed_value::T { use properties::longhands::border_image_repeat::computed_value::RepeatKeyword; use gecko_bindings::structs; @@ -1352,6 +1418,10 @@ fn static_assert() { } } + pub fn reset_z_index(&mut self, other: &Self) { + self.copy_z_index_from(other) + } + pub fn clone_z_index(&self) -> longhands::z_index::computed_value::T { return match self.gecko.mZIndex.as_value() { CoordDataValue::Integer(n) => Either::First(n), @@ -1426,6 +1496,10 @@ fn static_assert() { self.gecko.${value.gecko}.mLineName.assign(&*other.gecko.${value.gecko}.mLineName); } + pub fn reset_${value.name}(&mut self, other: &Self) { + self.copy_${value.name}_from(other) + } + pub fn clone_${value.name}(&self) -> longhands::${value.name}::computed_value::T { use gecko_bindings::structs::{nsStyleGridLine_kMinLine, nsStyleGridLine_kMaxLine}; use string_cache::Atom; @@ -1464,6 +1538,10 @@ fn static_assert() { self.gecko.mGridAuto${kind.title()}Max.copy_from(&other.gecko.mGridAuto${kind.title()}Max); } + pub fn reset_grid_auto_${kind}(&mut self, other: &Self) { + self.copy_grid_auto_${kind}_from(other) + } + pub fn clone_grid_auto_${kind}(&self) -> longhands::grid_auto_${kind}::computed_value::T { ::values::generics::grid::TrackSize::from_gecko_style_coords(&self.gecko.mGridAuto${kind.title()}Min, &self.gecko.mGridAuto${kind.title()}Max) @@ -1601,6 +1679,10 @@ fn static_assert() { &other.gecko.mGridTemplate${kind.title()}); } } + + pub fn reset_grid_template_${kind}(&mut self, other: &Self) { + self.copy_grid_template_${kind}_from(other) + } % endfor ${impl_simple_type_with_conversion("grid_auto_flow")} @@ -1640,6 +1722,10 @@ fn static_assert() { pub fn copy_grid_template_areas_from(&mut self, other: &Self) { unsafe { self.gecko.mGridTemplateAreas.set(&other.gecko.mGridTemplateAreas) } } + + pub fn reset_grid_template_areas(&mut self, other: &Self) { + self.copy_grid_template_areas_from(other) + } <% skip_outline_longhands = " ".join("outline-style outline-width".split() + @@ -1674,6 +1760,11 @@ fn static_assert() { self.gecko.mOutlineStyle = other.gecko.mOutlineStyle; } + #[allow(non_snake_case)] + pub fn reset_outline_style(&mut self, other: &Self) { + self.copy_outline_style_from(other) + } + #[allow(non_snake_case)] pub fn clone_outline_style(&self) -> longhands::outline_style::computed_value::T { // FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts @@ -1737,7 +1828,7 @@ fn static_assert() { }; } - pub fn copy_font_feature_settings_from(&mut self, other: &Self ) { + pub fn copy_font_feature_settings_from(&mut self, other: &Self) { let current_settings = &mut self.gecko.mFont.fontFeatureSettings; let feature_settings = &other.gecko.mFont.fontFeatureSettings; let settings_length = feature_settings.len() as u32; @@ -1751,6 +1842,10 @@ fn static_assert() { } } + pub fn reset_font_feature_settings(&mut self, other: &Self) { + self.copy_font_feature_settings_from(other) + } + pub fn clone_font_feature_settings(&self) -> longhands::font_feature_settings::computed_value::T { use values::generics::{FontSettings, FontSettingTag, FontSettingTagInt} ; @@ -1802,6 +1897,10 @@ fn static_assert() { } } + pub fn reset_font_variation_settings(&mut self, other: &Self) { + self.copy_font_variation_settings_from(other) + } + pub fn fixup_none_generic(&mut self, device: &Device) { unsafe { bindings::Gecko_nsStyleFont_FixupNoneGeneric(&mut self.gecko, device.pres_context()) @@ -1845,6 +1944,10 @@ fn static_assert() { self.gecko.mGenericID = other.gecko.mGenericID; } + pub fn reset_font_family(&mut self, other: &Self) { + self.copy_font_family_from(other) + } + pub fn clone_font_family(&self) -> longhands::font_family::computed_value::T { use properties::longhands::font_family::computed_value::{FontFamily, FamilyName}; use gecko_bindings::structs::FontFamilyType; @@ -2082,6 +2185,10 @@ fn static_assert() { self.gecko.mFont.sizeAdjust = other.gecko.mFont.sizeAdjust; } + pub fn reset_font_size_adjust(&mut self, other: &Self) { + self.copy_font_size_adjust_from(other) + } + pub fn clone_font_size_adjust(&self) -> longhands::font_size_adjust::computed_value::T { use properties::longhands::font_size_adjust::computed_value::T; T::from_gecko_adjust(self.gecko.mFont.sizeAdjust) @@ -2103,6 +2210,11 @@ fn static_assert() { } } + #[allow(non_snake_case)] + pub fn reset__x_lang(&mut self, other: &Self) { + self.copy__x_lang_from(other) + } + <% impl_simple_type_with_conversion("font_language_override", "mFont.languageOverride") %> pub fn set_font_variant_alternates(&mut self, v: longhands::font_variant_alternates::computed_value::T) { @@ -2161,6 +2273,10 @@ fn static_assert() { } } + pub fn reset_font_variant_alternates(&mut self, other: &Self) { + self.copy_font_variant_alternates_from(other) + } + pub fn clone_font_variant_alternates(&self) -> longhands::font_variant_alternates::computed_value::T { use Atom; % for value in "normal swash stylistic ornaments annotation styleset character_variant historical".split(): @@ -2248,6 +2364,11 @@ fn static_assert() { gecko.m${gecko_ffi_name} = other.gecko.m${type.capitalize()}s[index].m${gecko_ffi_name}; } } + + #[allow(non_snake_case)] + pub fn reset_${type}_${ident}(&mut self, other: &Self) { + self.copy_${type}_${ident}_from(other) + } <%def name="impl_animation_or_transition_count(type, ident, gecko_ffi_name)"> @@ -2437,6 +2558,10 @@ fn static_assert() { self.gecko.mOriginalDisplay = other.gecko.mDisplay; } + pub fn reset_display(&mut self, other: &Self) { + self.copy_display_from(other) + } + <%call expr="impl_keyword_clone('display', 'mDisplay', display_keyword)"> <% overflow_x = data.longhands_by_name["overflow-x"] %> @@ -2557,6 +2682,10 @@ fn static_assert() { } } + pub fn reset_scroll_snap_coordinate(&mut self, other: &Self) { + self.copy_scroll_snap_coordinate_from(other) + } + pub fn clone_scroll_snap_coordinate(&self) -> longhands::scroll_snap_coordinate::computed_value::T { let vec = self.gecko.mScrollSnapCoordinate.iter().map(|f| f.into()).collect(); longhands::scroll_snap_coordinate::computed_value::T(vec) @@ -2680,6 +2809,10 @@ fn static_assert() { unsafe { self.gecko.mSpecifiedTransform.set(&other.gecko.mSpecifiedTransform); } } + pub fn reset_transform(&mut self, other: &Self) { + self.copy_transform_from(other) + } + <%def name="computed_operation_arm(name, keyword, items)"> <% # %s is substituted with the call to GetArrayItem. @@ -2869,6 +3002,11 @@ fn static_assert() { } } } + + pub fn reset_transition_property(&mut self, other: &Self) { + self.copy_transition_property_from(other) + } + ${impl_transition_count('property', 'Property')} pub fn animations_equals(&self, other: &Self) -> bool { @@ -2916,6 +3054,11 @@ fn static_assert() { animation.mName.assign(&*other.gecko.mAnimations[index].mName); } } + + pub fn reset_animation_name(&mut self, other: &Self) { + self.copy_animation_name_from(other) + } + ${impl_animation_count('name', 'Name')} ${impl_animation_time_value('delay', 'Delay')} @@ -2979,6 +3122,10 @@ fn static_assert() { self.gecko.mPerspectiveOrigin[1].copy_from(&other.gecko.mPerspectiveOrigin[1]); } + pub fn reset_perspective_origin(&mut self, other: &Self) { + self.copy_perspective_origin_from(other) + } + pub fn clone_perspective_origin(&self) -> longhands::perspective_origin::computed_value::T { use properties::longhands::perspective_origin::computed_value::T; use values::computed::LengthOrPercentage; @@ -3002,6 +3149,10 @@ fn static_assert() { self.gecko.mTransformOrigin[2].copy_from(&other.gecko.mTransformOrigin[2]); } + pub fn reset_transform_origin(&mut self, other: &Self) { + self.copy_transform_origin_from(other) + } + pub fn clone_transform_origin(&self) -> longhands::transform_origin::computed_value::T { use properties::longhands::transform_origin::computed_value::T; use values::computed::LengthOrPercentage; @@ -3101,6 +3252,10 @@ fn static_assert() { } } + pub fn reset_will_change(&mut self, other: &Self) { + self.copy_will_change_from(other) + } + pub fn clone_will_change(&self) -> longhands::will_change::computed_value::T { use properties::longhands::will_change::computed_value::T; use gecko_bindings::structs::nsIAtom; @@ -3234,6 +3389,10 @@ fn static_assert() { } self.gecko.${layers_field_name}.${field_name}Count = count; } + + pub fn reset_${shorthand}_${name}(&mut self, other: &Self) { + self.copy_${shorthand}_${name}_from(other) + } <%def name="impl_simple_image_array_property(name, shorthand, layer_field_name, field_name, struct_name)"> @@ -3384,6 +3543,10 @@ fn static_assert() { self.gecko.${image_layers_field}.mPosition${orientation.upper()}Count = count; } + pub fn reset_${shorthand}_position_${orientation}(&mut self, other: &Self) { + self.copy_${shorthand}_position_${orientation}_from(other) + } + pub fn clone_${shorthand}_position_${orientation}(&self) -> longhands::${shorthand}_position_${orientation}::computed_value::T { longhands::${shorthand}_position_${orientation}::computed_value::T( @@ -3495,7 +3658,6 @@ fn static_assert() { ) } - pub fn copy_${shorthand}_image_from(&mut self, other: &Self) { use gecko_bindings::structs::nsStyleImageLayers_LayerType as LayerType; unsafe { @@ -3515,6 +3677,10 @@ fn static_assert() { } } + pub fn reset_${shorthand}_image(&mut self, other: &Self) { + self.copy_${shorthand}_image_from(other) + } + #[allow(unused_variables)] pub fn set_${shorthand}_image(&mut self, images: I) where I: IntoIterator, @@ -3630,6 +3796,10 @@ fn static_assert() { unsafe { Gecko_CopyListStyleImageFrom(&mut self.gecko, &other.gecko); } } + pub fn reset_list_style_image(&mut self, other: &Self) { + self.copy_list_style_image_from(other) + } + pub fn clone_list_style_image(&self) -> longhands::list_style_image::computed_value::T { use values::specified::url::SpecifiedUrl; use values::{Either, None_}; @@ -3667,6 +3837,10 @@ fn static_assert() { } } + pub fn reset_list_style_type(&mut self, other: &Self) { + self.copy_list_style_type_from(other) + } + pub fn set_quotes(&mut self, other: longhands::quotes::computed_value::T) { use gecko_bindings::bindings::Gecko_NewStyleQuoteValues; use gecko_bindings::sugar::refptr::UniqueRefPtr; @@ -3687,6 +3861,10 @@ fn static_assert() { unsafe { self.gecko.mQuotes.set(&other.gecko.mQuotes); } } + pub fn reset_quotes(&mut self, other: &Self) { + self.copy_quotes_from(other) + } + pub fn clone_quotes(&self) -> longhands::quotes::computed_value::T { unsafe { let ref gecko_quote_values = *self.gecko.mQuotes.mRawPtr; @@ -3786,6 +3964,10 @@ fn static_assert() { self.gecko.mBoxShadow.copy_from(&other.gecko.mBoxShadow); } + pub fn reset_box_shadow(&mut self, other: &Self) { + self.copy_box_shadow_from(other) + } + pub fn clone_box_shadow(&self) -> longhands::box_shadow::computed_value::T { let buf = self.gecko.mBoxShadow.iter().map(|v| v.to_box_shadow()).collect(); longhands::box_shadow::computed_value::T(buf) @@ -3846,6 +4028,10 @@ fn static_assert() { self.gecko.mClipFlags = other.gecko.mClipFlags; } + pub fn reset_clip(&mut self, other: &Self) { + self.copy_clip_from(other) + } + pub fn clone_clip(&self) -> longhands::clip::computed_value::T { use gecko_bindings::structs::NS_STYLE_CLIP_AUTO; use gecko_bindings::structs::NS_STYLE_CLIP_BOTTOM_AUTO; @@ -3975,6 +4161,10 @@ fn static_assert() { } } + pub fn reset_filter(&mut self, other: &Self) { + self.copy_filter_from(other) + } + pub fn clone_filter(&self) -> longhands::filter::computed_value::T { use values::generics::effects::Filter; use values::specified::url::SpecifiedUrl; @@ -4058,6 +4248,10 @@ fn static_assert() { bindings::Gecko_CopyImageOrientationFrom(&mut self.gecko, &other.gecko); } } + + pub fn reset_image_orientation(&mut self, other: &Self) { + self.copy_image_orientation_from(other) + } <%self:impl_trait style_struct_name="InheritedTable" @@ -4073,6 +4267,10 @@ fn static_assert() { self.gecko.mBorderSpacingRow = other.gecko.mBorderSpacingRow; } + pub fn reset_border_spacing(&mut self, other: &Self) { + self.copy_border_spacing_from(other) + } + pub fn clone_border_spacing(&self) -> longhands::border_spacing::computed_value::T { longhands::border_spacing::computed_value::T { horizontal: Au(self.gecko.mBorderSpacingCol), @@ -4107,6 +4305,10 @@ fn static_assert() { self.gecko.mTextShadow.copy_from(&other.gecko.mTextShadow); } + pub fn reset_text_shadow(&mut self, other: &Self) { + self.copy_text_shadow_from(other) + } + pub fn clone_text_shadow(&self) -> longhands::text_shadow::computed_value::T { let buf = self.gecko.mTextShadow.iter().map(|v| v.to_simple_shadow()).collect(); longhands::text_shadow::computed_value::T(buf) @@ -4233,6 +4435,10 @@ fn static_assert() { self.gecko.mTextEmphasisStyle = other.gecko.mTextEmphasisStyle; } + pub fn reset_text_emphasis_style(&mut self, other: &Self) { + self.copy_text_emphasis_style_from(other) + } + pub fn clone_text_emphasis_style(&self) -> longhands::text_emphasis_style::computed_value::T { use properties::longhands::text_emphasis_style::computed_value::{T, KeywordValue}; use properties::longhands::text_emphasis_style::ShapeKeyword; @@ -4308,6 +4514,7 @@ fn static_assert() { clear_if_string(&mut self.gecko.mTextOverflow.mLeft); clear_if_string(&mut self.gecko.mTextOverflow.mRight); } + pub fn set_text_overflow(&mut self, v: longhands::text_overflow::computed_value::T) { use gecko_bindings::structs::nsStyleTextOverflowSide; use properties::longhands::text_overflow::Side; @@ -4345,6 +4552,10 @@ fn static_assert() { self.gecko.mTextOverflow.mLogicalDirections = other.gecko.mTextOverflow.mLogicalDirections; } + pub fn reset_text_overflow(&mut self, other: &Self) { + self.copy_text_overflow_from(other) + } + pub fn clone_text_overflow(&self) -> longhands::text_overflow::computed_value::T { use gecko_bindings::structs::nsStyleTextOverflowSide; use properties::longhands::text_overflow::Side; @@ -4388,6 +4599,10 @@ fn static_assert() { self.gecko.mInitialLetterSink = other.gecko.mInitialLetterSink; } + pub fn reset_initial_letter(&mut self, other: &Self) { + self.copy_initial_letter_from(other) + } + pub fn clone_initial_letter(&self) -> longhands::initial_letter::computed_value::T { use values::generics::text::InitialLetter; @@ -4525,6 +4740,10 @@ fn static_assert() { Gecko_CopyShapeSourceFrom(&mut self.gecko.${gecko_ffi_name}, &other.gecko.${gecko_ffi_name}); } } + + pub fn reset_${ident}(&mut self, other: &Self) { + self.copy_${ident}_from(other) + } <% skip_svg_longhands = """ @@ -4592,6 +4811,10 @@ clip-path } } + pub fn reset_stroke_dasharray(&mut self, other: &Self) { + self.copy_stroke_dasharray_from(other) + } + pub fn clone_stroke_dasharray(&self) -> longhands::stroke_dasharray::computed_value::T { use values::computed::LengthOrPercentage; @@ -4682,6 +4905,11 @@ clip-path bindings::Gecko_nsStyleSVG_CopyContextProperties(&mut self.gecko, &other.gecko); } } + + #[allow(non_snake_case)] + pub fn reset__moz_context_properties(&mut self, other: &Self) { + self.copy__moz_context_properties_from(other) + } <%self:impl_trait style_struct_name="Color" @@ -4785,6 +5013,10 @@ clip-path } } + pub fn reset_cursor(&mut self, other: &Self) { + self.copy_cursor_from(other) + } + pub fn clone_cursor(&self) -> longhands::cursor::computed_value::T { use properties::longhands::cursor::computed_value::{Keyword, Image}; use style_traits::cursor::Cursor; @@ -5012,6 +5244,10 @@ clip-path } } + pub fn reset_content(&mut self, other: &Self) { + self.copy_content_from(other) + } + % for counter_property in ["Increment", "Reset"]: pub fn set_counter_${counter_property.lower()}(&mut self, v: longhands::counter_increment::computed_value::T) { unsafe { @@ -5030,6 +5266,10 @@ clip-path } } + pub fn reset_counter_${counter_property.lower()}(&mut self, other: &Self) { + self.copy_counter_${counter_property.lower()}_from(other) + } + pub fn clone_counter_${counter_property.lower()}(&self) -> longhands::counter_increment::computed_value::T { use values::CustomIdent; use gecko_string_cache::Atom; diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index 442b9894f4f..4e285bf3092 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -917,6 +917,15 @@ } + + /// Copy the appropriate physical property from another struct for ${name} + /// given a writing mode. + pub fn reset_${to_rust_ident(name)}(&mut self, + other: &Self, + wm: WritingMode) { + 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. diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index e7771a2819c..0e11d2ac0ad 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -1709,6 +1709,13 @@ pub mod style_structs { pub fn copy_${longhand.ident}_from(&mut self, other: &Self) { self.${longhand.ident} = other.${longhand.ident}.clone(); } + + /// Reset ${longhand.name} from the initial struct. + #[allow(non_snake_case)] + #[inline] + 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)] @@ -2627,19 +2634,14 @@ impl<'a> StyleBuilder<'a> { pub fn reset_${property.ident}(&mut self) { let reset_struct = self.reset_style.get_${property.style_struct.name_lower}(); - % if property.ident == "justify_items": - // TODO(emilio): Generalise this! - self.${property.style_struct.ident}.mutate() - .reset_${property.ident}(reset_struct) - % else: - self.${property.style_struct.ident}.mutate() - .copy_${property.ident}_from( - reset_struct, - % if property.logical: - self.writing_mode, - % endif - ); - % endif + + self.${property.style_struct.ident}.mutate() + .reset_${property.ident}( + reset_struct, + % if property.logical: + self.writing_mode, + % endif + ); } % if not property.is_vector: