aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXidorn Quan <me@upsuper.org>2017-11-07 15:40:43 -0800
committerXidorn Quan <me@upsuper.org>2017-11-12 10:59:55 -0800
commit79ea63945851531dbf457f234bb239cc731fbb6e (patch)
treee3a592e2fcdbd5b42c3c9b61eb7c22e6afd76224
parentdfbf632fd67c05edef94bd15426a68852a9ac79b (diff)
downloadservo-79ea63945851531dbf457f234bb239cc731fbb6e.tar.gz
servo-79ea63945851531dbf457f234bb239cc731fbb6e.zip
Add general impl in gecko_properties for TransformOrigin value and add -moz-window-transform-origin.
-rw-r--r--components/style/properties/gecko.mako.rs81
-rw-r--r--components/style/properties/longhand/box.mako.rs1
-rw-r--r--components/style/properties/longhand/ui.mako.rs10
3 files changed, 62 insertions, 30 deletions
diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs
index 406ec3df7cc..6cd1b509b06 100644
--- a/components/style/properties/gecko.mako.rs
+++ b/components/style/properties/gecko.mako.rs
@@ -1324,6 +1324,55 @@ pub fn clone_transform_from_list(
}
</%def>
+<%def name="impl_transform_origin(ident, gecko_ffi_name)">
+ #[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);
+ // transform-origin supports the third value for depth, while
+ // -moz-window-transform-origin doesn't. The following code is
+ // for handling this difference. Rust (incorrectly) generates
+ // an unsuppressible warning, but we know it's safe here.
+ // See rust-lang/rust#45850. Also if we can have more knowledge
+ // about the type here, we may want to check that the length is
+ // exactly either 2 or 3 in compile time.
+ if self.gecko.${gecko_ffi_name}.len() == 3 {
+ self.gecko.${gecko_ffi_name}[2].set(v.depth);
+ }
+ }
+
+ #[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 self.gecko.${gecko_ffi_name}.len() == 3 {
+ self.gecko.${gecko_ffi_name}[2].copy_from(&other.gecko.${gecko_ffi_name}[2]);
+ }
+ }
+
+ #[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"),
+ depth: if self.gecko.${gecko_ffi_name}.len() == 3 {
+ Length::from_gecko_style_coord(&self.gecko.${gecko_ffi_name}[2])
+ .expect("clone for Length failed")
+ } else {
+ Length::new(0.)
+ },
+ }
+ }
+</%def>
+
<%def name="impl_logical(name, **kwargs)">
${helpers.logical_setter(name)}
</%def>
@@ -1477,6 +1526,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,
}
@@ -3047,7 +3097,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}">
@@ -3460,35 +3510,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 9d0ddf1cdf0..f5f9d0753cd 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 46412047e3e..98093882e17 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"