From 7dfcbb582a22f33f3c7381b93a7c168bdeae6600 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Fri, 3 Nov 2017 16:33:23 +1100 Subject: [PATCH] Add general impl in gecko_properties for TransformOrigin value and add -moz-window-transform-origin. --- components/style/properties/gecko.mako.rs | 76 +++++++++++-------- .../style/properties/longhand/box.mako.rs | 1 + .../style/properties/longhand/ui.mako.rs | 10 +++ 3 files changed, 57 insertions(+), 30 deletions(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 912ff57b6260..e362f324da2c 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -1323,6 +1323,50 @@ pub fn clone_transform_from_list( } +<%def name="impl_transform_origin(ident, gecko_ffi_name)"> + <% has_depth = ident == "transform" %> + + #[allow(non_snake_case)] + pub fn set_${ident}(&mut self, v: values::computed::TransformOrigin) { + self.gecko.${gecko_ffi_name}[0].set(v.horizontal); + self.gecko.${gecko_ffi_name}[1].set(v.vertical); + % if has_depth: + self.gecko.${gecko_ffi_name}[2].set(v.depth); + % endif + } + + #[allow(non_snake_case)] + pub fn copy_${ident}_from(&mut self, other: &Self) { + self.gecko.${gecko_ffi_name}[0].copy_from(&other.gecko.${gecko_ffi_name}[0]); + self.gecko.${gecko_ffi_name}[1].copy_from(&other.gecko.${gecko_ffi_name}[1]); + % if has_depth: + self.gecko.${gecko_ffi_name}[2].copy_from(&other.gecko.${gecko_ffi_name}[2]); + % endif + } + + #[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) -> values::computed::TransformOrigin { + use values::computed::{Length, LengthOrPercentage, TransformOrigin}; + TransformOrigin { + horizontal: LengthOrPercentage::from_gecko_style_coord(&self.gecko.${gecko_ffi_name}[0]) + .expect("clone for LengthOrPercentage failed"), + vertical: LengthOrPercentage::from_gecko_style_coord(&self.gecko.${gecko_ffi_name}[1]) + .expect("clone for LengthOrPercentage failed"), + % if has_depth: + depth: Length::from_gecko_style_coord(&self.gecko.${gecko_ffi_name}[2]) + .expect("clone for Length failed"), + % else: + depth: Length::new(0.) + % endif + } + } + + <%def name="impl_logical(name, **kwargs)"> ${helpers.logical_setter(name)} @@ -1476,6 +1520,7 @@ impl Clone for ${style_struct.gecko_struct_name} { "SVGPaint": impl_svg_paint, "SVGWidth": impl_svg_length, "Transform": impl_transform, + "TransformOrigin": impl_transform_origin, "UrlOrNone": impl_css_url, } @@ -3046,7 +3091,7 @@ fn static_assert() { page-break-before page-break-after scroll-snap-points-x scroll-snap-points-y scroll-snap-type-x scroll-snap-type-y scroll-snap-coordinate - perspective-origin transform-origin -moz-binding will-change + perspective-origin -moz-binding will-change shape-outside contain touch-action""" %> <%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}"> @@ -3459,35 +3504,6 @@ fn static_assert() { } } - pub fn set_transform_origin(&mut self, v: longhands::transform_origin::computed_value::T) { - self.gecko.mTransformOrigin[0].set(v.horizontal); - self.gecko.mTransformOrigin[1].set(v.vertical); - self.gecko.mTransformOrigin[2].set(v.depth); - } - - pub fn copy_transform_origin_from(&mut self, other: &Self) { - self.gecko.mTransformOrigin[0].copy_from(&other.gecko.mTransformOrigin[0]); - self.gecko.mTransformOrigin[1].copy_from(&other.gecko.mTransformOrigin[1]); - 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::{Length, LengthOrPercentage}; - T { - horizontal: LengthOrPercentage::from_gecko_style_coord(&self.gecko.mTransformOrigin[0]) - .expect("clone for LengthOrPercentage failed"), - vertical: LengthOrPercentage::from_gecko_style_coord(&self.gecko.mTransformOrigin[1]) - .expect("clone for LengthOrPercentage failed"), - depth: Length::from_gecko_style_coord(&self.gecko.mTransformOrigin[2]) - .expect("clone for Length failed"), - } - } - pub fn set_will_change(&mut self, v: longhands::will_change::computed_value::T) { use gecko_bindings::bindings::{Gecko_AppendWillChange, Gecko_ClearWillChange}; use gecko_bindings::structs::NS_STYLE_WILL_CHANGE_OPACITY; diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index 9d0ddf1cdf0e..f5f9d0753cdc 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -684,6 +684,7 @@ ${helpers.predefined_type("transform-origin", "computed::TransformOrigin::initial_value()", animation_value_type="ComputedValue", extra_prefixes="moz webkit", + gecko_ffi_name="mTransformOrigin", boxed=True, spec="https://drafts.csswg.org/css-transforms/#transform-origin-property")} diff --git a/components/style/properties/longhand/ui.mako.rs b/components/style/properties/longhand/ui.mako.rs index 46412047e3e7..98093882e175 100644 --- a/components/style/properties/longhand/ui.mako.rs +++ b/components/style/properties/longhand/ui.mako.rs @@ -53,6 +53,16 @@ ${helpers.predefined_type("-moz-window-transform", "Transform", internal=True, spec="None (Nonstandard internal property)")} +${helpers.predefined_type("-moz-window-transform-origin", + "TransformOrigin", + "computed::TransformOrigin::initial_value()", + animation_value_type="ComputedValue", + gecko_ffi_name="mWindowTransformOrigin", + products="gecko", + boxed=True, + internal=True, + spec="None (Nonstandard internal property)")} + <%helpers:longhand name="-moz-force-broken-image-icon" products="gecko" animation_value_type="discrete"