Navigation Menu

Skip to content

Commit

Permalink
style: Use alias for StylePathCommand.
Browse files Browse the repository at this point in the history
So we could drop transmute in svg_path related functions.

Differential Revision: https://phabricator.services.mozilla.com/D10140
  • Loading branch information
BorisChiou authored and emilio committed Nov 5, 2018
1 parent c7027e2 commit b81bbb8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
9 changes: 1 addition & 8 deletions components/style/gecko/conversions.rs
Expand Up @@ -701,18 +701,11 @@ pub mod basic_shape {

/// Generate a SVGPathData from StyleShapeSource if possible.
fn to_svg_path(&self) -> Option<SVGPathData> {
use gecko_bindings::structs::StylePathCommand;
use values::specified::svg_path::PathCommand;
match self.mType {
StyleShapeSourceType::Path => {
let gecko_path = unsafe { &*self.__bindgen_anon_1.mSVGPath.as_ref().mPtr };
let result: Vec<PathCommand> = gecko_path
.mPath
.iter()
.map(|gecko: &StylePathCommand| {
// unsafe: cbindgen ensures the representation is the same.
unsafe { ::std::mem::transmute(*gecko) }
}).collect();
let result: Vec<PathCommand> = gecko_path.mPath.iter().cloned().collect();
Some(SVGPathData::new(result.into_boxed_slice()))
},
_ => None,
Expand Down
6 changes: 1 addition & 5 deletions components/style/properties/gecko.mako.rs
Expand Up @@ -4947,11 +4947,7 @@ fn set_style_svg_path(
&mut shape_source.__bindgen_anon_1.mSVGPath.as_mut().mPtr.as_mut().unwrap()
};

let iter = servo_path.commands().iter().map(|command| {
// unsafe: cbindgen ensures the representation is the same.
unsafe { transmute(*command) }
});
gecko_path.mPath.assign_from_iter_pod(iter);
gecko_path.mPath.assign_from_iter_pod(servo_path.commands().iter().cloned());

// Setup fill-rule.
gecko_path.mFillRule = fill;
Expand Down

0 comments on commit b81bbb8

Please sign in to comment.