mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
stylo: Implement object-position
MozReview-Commit-ID: 6mr4ktfeEGT
This commit is contained in:
parent
3266b5b31f
commit
8b7bb97aa9
2 changed files with 29 additions and 8 deletions
|
@ -342,6 +342,25 @@ def set_gecko_property(ffi_name, expr):
|
||||||
% endif
|
% endif
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
|
<%def name="impl_position(ident, gecko_ffi_name, need_clone=False)">
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
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.mYPosition" % gecko_ffi_name, "v.vertical.into()")}
|
||||||
|
}
|
||||||
|
<%call expr="impl_simple_copy(ident, gecko_ffi_name)"></%call>
|
||||||
|
% if need_clone:
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
|
||||||
|
use values::computed::Position;
|
||||||
|
Position {
|
||||||
|
horizontal: self.gecko.${gecko_ffi_name}.mXPosition.into(),
|
||||||
|
vertical: self.gecko.${gecko_ffi_name}.mYPosition.into(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
% endif
|
||||||
|
</%def>
|
||||||
|
|
||||||
<%def name="impl_color(ident, gecko_ffi_name, need_clone=False, complex_color=True)">
|
<%def name="impl_color(ident, gecko_ffi_name, need_clone=False, complex_color=True)">
|
||||||
<%call expr="impl_color_setter(ident, gecko_ffi_name, complex_color)"></%call>
|
<%call expr="impl_color_setter(ident, gecko_ffi_name, complex_color)"></%call>
|
||||||
<%call expr="impl_color_copy(ident, gecko_ffi_name, complex_color)"></%call>
|
<%call expr="impl_color_copy(ident, gecko_ffi_name, complex_color)"></%call>
|
||||||
|
@ -516,6 +535,7 @@ impl Debug for ${style_struct.gecko_struct_name} {
|
||||||
predefined_types = {
|
predefined_types = {
|
||||||
"length::LengthOrAuto": impl_style_coord,
|
"length::LengthOrAuto": impl_style_coord,
|
||||||
"Length": impl_absolute_length,
|
"Length": impl_absolute_length,
|
||||||
|
"Position": impl_position,
|
||||||
"LengthOrPercentage": impl_style_coord,
|
"LengthOrPercentage": impl_style_coord,
|
||||||
"LengthOrPercentageOrAuto": impl_style_coord,
|
"LengthOrPercentageOrAuto": impl_style_coord,
|
||||||
"LengthOrPercentageOrNone": impl_style_coord,
|
"LengthOrPercentageOrNone": impl_style_coord,
|
||||||
|
@ -1183,7 +1203,7 @@ fn static_assert() {
|
||||||
animation-iteration-count animation-timing-function
|
animation-iteration-count animation-timing-function
|
||||||
-moz-binding page-break-before page-break-after
|
-moz-binding page-break-before page-break-after
|
||||||
scroll-snap-points-x scroll-snap-points-y transform
|
scroll-snap-points-x scroll-snap-points-y transform
|
||||||
scroll-snap-type-y scroll-snap-destination scroll-snap-coordinate
|
scroll-snap-type-y scroll-snap-coordinate
|
||||||
perspective-origin transform-origin""" %>
|
perspective-origin transform-origin""" %>
|
||||||
<%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}">
|
<%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}">
|
||||||
|
|
||||||
|
@ -1355,13 +1375,6 @@ fn static_assert() {
|
||||||
|
|
||||||
${impl_coord_copy('scroll_snap_points_y', 'mScrollSnapPointsY')}
|
${impl_coord_copy('scroll_snap_points_y', 'mScrollSnapPointsY')}
|
||||||
|
|
||||||
pub fn set_scroll_snap_destination(&mut self, v: longhands::scroll_snap_destination::computed_value::T) {
|
|
||||||
self.gecko.mScrollSnapDestination.mXPosition = v.horizontal.into();
|
|
||||||
self.gecko.mScrollSnapDestination.mYPosition = v.vertical.into();
|
|
||||||
}
|
|
||||||
|
|
||||||
${impl_simple_copy('scroll_snap_destination', 'mScrollSnapDestination')}
|
|
||||||
|
|
||||||
pub fn set_scroll_snap_coordinate(&mut self, v: longhands::scroll_snap_coordinate::computed_value::T) {
|
pub fn set_scroll_snap_coordinate(&mut self, v: longhands::scroll_snap_coordinate::computed_value::T) {
|
||||||
unsafe { self.gecko.mScrollSnapCoordinate.set_len_pod(v.0.len() as u32); }
|
unsafe { self.gecko.mScrollSnapCoordinate.set_len_pod(v.0.len() as u32); }
|
||||||
for (gecko, servo) in self.gecko.mScrollSnapCoordinate
|
for (gecko, servo) in self.gecko.mScrollSnapCoordinate
|
||||||
|
|
|
@ -210,6 +210,14 @@ ${helpers.single_keyword("object-fit", "fill contain cover none scale-down",
|
||||||
products="gecko", animatable=False,
|
products="gecko", animatable=False,
|
||||||
spec="https://drafts.csswg.org/css-images/#propdef-object-fit")}
|
spec="https://drafts.csswg.org/css-images/#propdef-object-fit")}
|
||||||
|
|
||||||
|
${helpers.predefined_type("object-position",
|
||||||
|
"Position",
|
||||||
|
"computed::Position::zero()",
|
||||||
|
products="gecko",
|
||||||
|
boxed="True",
|
||||||
|
spec="https://drafts.csswg.org/css-images-3/#the-object-position",
|
||||||
|
animatable=False)}
|
||||||
|
|
||||||
<% grid_longhands = ["grid-row-start", "grid-row-end", "grid-column-start", "grid-column-end"] %>
|
<% grid_longhands = ["grid-row-start", "grid-row-end", "grid-column-start", "grid-column-end"] %>
|
||||||
|
|
||||||
% for longhand in grid_longhands:
|
% for longhand in grid_longhands:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue