mirror of
https://github.com/servo/servo.git
synced 2025-06-28 19:13:41 +01:00
style: Use alias for StylePathCommand.
So we could drop transmute in svg_path related functions. Differential Revision: https://phabricator.services.mozilla.com/D10140
This commit is contained in:
parent
c7027e2676
commit
b81bbb85b4
2 changed files with 2 additions and 13 deletions
|
@ -701,18 +701,11 @@ pub mod basic_shape {
|
||||||
|
|
||||||
/// Generate a SVGPathData from StyleShapeSource if possible.
|
/// Generate a SVGPathData from StyleShapeSource if possible.
|
||||||
fn to_svg_path(&self) -> Option<SVGPathData> {
|
fn to_svg_path(&self) -> Option<SVGPathData> {
|
||||||
use gecko_bindings::structs::StylePathCommand;
|
|
||||||
use values::specified::svg_path::PathCommand;
|
use values::specified::svg_path::PathCommand;
|
||||||
match self.mType {
|
match self.mType {
|
||||||
StyleShapeSourceType::Path => {
|
StyleShapeSourceType::Path => {
|
||||||
let gecko_path = unsafe { &*self.__bindgen_anon_1.mSVGPath.as_ref().mPtr };
|
let gecko_path = unsafe { &*self.__bindgen_anon_1.mSVGPath.as_ref().mPtr };
|
||||||
let result: Vec<PathCommand> = gecko_path
|
let result: Vec<PathCommand> = gecko_path.mPath.iter().cloned().collect();
|
||||||
.mPath
|
|
||||||
.iter()
|
|
||||||
.map(|gecko: &StylePathCommand| {
|
|
||||||
// unsafe: cbindgen ensures the representation is the same.
|
|
||||||
unsafe { ::std::mem::transmute(*gecko) }
|
|
||||||
}).collect();
|
|
||||||
Some(SVGPathData::new(result.into_boxed_slice()))
|
Some(SVGPathData::new(result.into_boxed_slice()))
|
||||||
},
|
},
|
||||||
_ => None,
|
_ => None,
|
||||||
|
|
|
@ -4947,11 +4947,7 @@ fn set_style_svg_path(
|
||||||
&mut shape_source.__bindgen_anon_1.mSVGPath.as_mut().mPtr.as_mut().unwrap()
|
&mut shape_source.__bindgen_anon_1.mSVGPath.as_mut().mPtr.as_mut().unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
let iter = servo_path.commands().iter().map(|command| {
|
gecko_path.mPath.assign_from_iter_pod(servo_path.commands().iter().cloned());
|
||||||
// unsafe: cbindgen ensures the representation is the same.
|
|
||||||
unsafe { transmute(*command) }
|
|
||||||
});
|
|
||||||
gecko_path.mPath.assign_from_iter_pod(iter);
|
|
||||||
|
|
||||||
// Setup fill-rule.
|
// Setup fill-rule.
|
||||||
gecko_path.mFillRule = fill;
|
gecko_path.mFillRule = fill;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue