Skip to content

Commit

Permalink
style: Unpack StyleMotion and use cbindgen for OffsetPath.
Browse files Browse the repository at this point in the history
Unpack StyleMotion and move its members into nsStyleDisplay, use
cbindgen to generate StyleOffsetPath.

Differential Revision: https://phabricator.services.mozilla.com/D31164
  • Loading branch information
BorisChiou authored and emilio committed May 29, 2019
1 parent 8ee516b commit d80a5d9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 35 deletions.
36 changes: 1 addition & 35 deletions components/style/properties/gecko.mako.rs
Expand Up @@ -2205,8 +2205,7 @@ fn static_assert() {
transition-timing-function transition-property
transform-style scroll-snap-points-x
scroll-snap-points-y scroll-snap-coordinate
-moz-binding offset-path shape-outside
-webkit-line-clamp""" %>
-moz-binding shape-outside -webkit-line-clamp""" %>
<%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}">
#[inline]
pub fn set_display(&mut self, v: longhands::display::computed_value::T) {
Expand Down Expand Up @@ -2513,39 +2512,6 @@ fn static_assert() {

<% impl_shape_source("shape_outside", "mShapeOutside") %>

pub fn set_offset_path(&mut self, v: longhands::offset_path::computed_value::T) {
use crate::gecko_bindings::bindings::{Gecko_NewStyleMotion, Gecko_SetStyleMotion};
use crate::gecko_bindings::structs::StyleShapeSourceType;
use crate::values::generics::basic_shape::FillRule;
use crate::values::specified::OffsetPath;

let motion = unsafe { Gecko_NewStyleMotion().as_mut().unwrap() };
match v {
OffsetPath::None => motion.mOffsetPath.mType = StyleShapeSourceType::None,
OffsetPath::Path(p) => {
set_style_svg_path(&mut motion.mOffsetPath, p, FillRule::Nonzero)
},
}
unsafe { Gecko_SetStyleMotion(&mut self.gecko.mMotion, motion) };
}

pub fn clone_offset_path(&self) -> longhands::offset_path::computed_value::T {
use crate::values::specified::OffsetPath;
match unsafe { self.gecko.mMotion.mPtr.as_ref() } {
None => OffsetPath::none(),
Some(v) => (&v.mOffsetPath).into()
}
}

pub fn copy_offset_path_from(&mut self, other: &Self) {
use crate::gecko_bindings::bindings::Gecko_CopyStyleMotions;
unsafe { Gecko_CopyStyleMotions(&mut self.gecko.mMotion, other.gecko.mMotion.mPtr) };
}

pub fn reset_offset_path(&mut self, other: &Self) {
self.copy_offset_path_from(other);
}

#[allow(non_snake_case)]
pub fn set__webkit_line_clamp(&mut self, v: longhands::_webkit_line_clamp::computed_value::T) {
self.gecko.mLineClamp = match v {
Expand Down
2 changes: 2 additions & 0 deletions components/style/values/specified/motion.rs
Expand Up @@ -12,6 +12,7 @@ use style_traits::{ParseError, StyleParseErrorKind};
/// The offset-path value.
///
/// https://drafts.fxtf.org/motion-1/#offset-path-property
/// cbindgen:derive-tagged-enum-copy-constructor=true
#[derive(
Animate,
Clone,
Expand All @@ -26,6 +27,7 @@ use style_traits::{ParseError, StyleParseErrorKind};
ToResolvedValue,
ToShmem,
)]
#[repr(C, u8)]
pub enum OffsetPath {
// We could merge SVGPathData into ShapeSource, so we could reuse them. However,
// we don't want to support other value for offset-path, so use SVGPathData only for now.
Expand Down

0 comments on commit d80a5d9

Please sign in to comment.