Skip to content

Commit

Permalink
stylo: Implement object-position
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: 6mr4ktfeEGT
  • Loading branch information
Manishearth committed Feb 9, 2017
1 parent 3266b5b commit 8b7bb97
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
29 changes: 21 additions & 8 deletions components/style/properties/gecko.mako.rs
Expand Up @@ -342,6 +342,25 @@ def set_gecko_property(ffi_name, expr):
% endif
</%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)">
<%call expr="impl_color_setter(ident, gecko_ffi_name, complex_color)"></%call>
<%call expr="impl_color_copy(ident, gecko_ffi_name, complex_color)"></%call>
Expand Down Expand Up @@ -516,6 +535,7 @@ impl Debug for ${style_struct.gecko_struct_name} {
predefined_types = {
"length::LengthOrAuto": impl_style_coord,
"Length": impl_absolute_length,
"Position": impl_position,
"LengthOrPercentage": impl_style_coord,
"LengthOrPercentageOrAuto": impl_style_coord,
"LengthOrPercentageOrNone": impl_style_coord,
Expand Down Expand Up @@ -1183,7 +1203,7 @@ fn static_assert() {
animation-iteration-count animation-timing-function
-moz-binding page-break-before page-break-after
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""" %>
<%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}">

Expand Down Expand Up @@ -1355,13 +1375,6 @@ fn static_assert() {

${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) {
unsafe { self.gecko.mScrollSnapCoordinate.set_len_pod(v.0.len() as u32); }
for (gecko, servo) in self.gecko.mScrollSnapCoordinate
Expand Down
8 changes: 8 additions & 0 deletions components/style/properties/longhand/position.mako.rs
Expand Up @@ -210,6 +210,14 @@ ${helpers.single_keyword("object-fit", "fill contain cover none scale-down",
products="gecko", animatable=False,
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"] %>

% for longhand in grid_longhands:
Expand Down

0 comments on commit 8b7bb97

Please sign in to comment.