mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Add general impl in gecko_properties for TransformOrigin value and add -moz-window-transform-origin.
This commit is contained in:
parent
dfbf632fd6
commit
79ea639458
3 changed files with 62 additions and 30 deletions
|
@ -1324,6 +1324,55 @@ pub fn clone_transform_from_list(
|
||||||
}
|
}
|
||||||
</%def>
|
</%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)">
|
<%def name="impl_logical(name, **kwargs)">
|
||||||
${helpers.logical_setter(name)}
|
${helpers.logical_setter(name)}
|
||||||
</%def>
|
</%def>
|
||||||
|
@ -1477,6 +1526,7 @@ impl Clone for ${style_struct.gecko_struct_name} {
|
||||||
"SVGPaint": impl_svg_paint,
|
"SVGPaint": impl_svg_paint,
|
||||||
"SVGWidth": impl_svg_length,
|
"SVGWidth": impl_svg_length,
|
||||||
"Transform": impl_transform,
|
"Transform": impl_transform,
|
||||||
|
"TransformOrigin": impl_transform_origin,
|
||||||
"UrlOrNone": impl_css_url,
|
"UrlOrNone": impl_css_url,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3047,7 +3097,7 @@ fn static_assert() {
|
||||||
page-break-before page-break-after
|
page-break-before page-break-after
|
||||||
scroll-snap-points-x scroll-snap-points-y
|
scroll-snap-points-x scroll-snap-points-y
|
||||||
scroll-snap-type-x scroll-snap-type-y scroll-snap-coordinate
|
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""" %>
|
shape-outside contain touch-action""" %>
|
||||||
<%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}">
|
<%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) {
|
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::bindings::{Gecko_AppendWillChange, Gecko_ClearWillChange};
|
||||||
use gecko_bindings::structs::NS_STYLE_WILL_CHANGE_OPACITY;
|
use gecko_bindings::structs::NS_STYLE_WILL_CHANGE_OPACITY;
|
||||||
|
|
|
@ -684,6 +684,7 @@ ${helpers.predefined_type("transform-origin",
|
||||||
"computed::TransformOrigin::initial_value()",
|
"computed::TransformOrigin::initial_value()",
|
||||||
animation_value_type="ComputedValue",
|
animation_value_type="ComputedValue",
|
||||||
extra_prefixes="moz webkit",
|
extra_prefixes="moz webkit",
|
||||||
|
gecko_ffi_name="mTransformOrigin",
|
||||||
boxed=True,
|
boxed=True,
|
||||||
spec="https://drafts.csswg.org/css-transforms/#transform-origin-property")}
|
spec="https://drafts.csswg.org/css-transforms/#transform-origin-property")}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,16 @@ ${helpers.predefined_type("-moz-window-transform", "Transform",
|
||||||
internal=True,
|
internal=True,
|
||||||
spec="None (Nonstandard internal property)")}
|
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"
|
<%helpers:longhand name="-moz-force-broken-image-icon"
|
||||||
products="gecko"
|
products="gecko"
|
||||||
animation_value_type="discrete"
|
animation_value_type="discrete"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue