mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
style: Use union to wrap different shape-like types. r=xidorn
1. We will add more shape-like types in the future, so it's better to use union to reduce the memory usage. 2. Those shape-like types are mutual exclusive, so we could use union to wrap them. Differential Revision: https://phabricator.services.mozilla.com/D2746
This commit is contained in:
parent
ad83faa745
commit
c87668fcd5
2 changed files with 5 additions and 5 deletions
|
@ -659,7 +659,7 @@ pub mod basic_shape {
|
|||
StyleShapeSourceType::None => Some(ShapeSource::None),
|
||||
StyleShapeSourceType::Box => Some(ShapeSource::Box(self.mReferenceBox.into())),
|
||||
StyleShapeSourceType::Shape => {
|
||||
let other_shape = unsafe { &*self.mBasicShape.mPtr };
|
||||
let other_shape = unsafe { &*self.__bindgen_anon_1.mBasicShape.as_ref().mPtr };
|
||||
let shape = other_shape.into();
|
||||
let reference_box = if self.mReferenceBox == StyleGeometryBox::NoBox {
|
||||
None
|
||||
|
@ -677,7 +677,7 @@ pub mod basic_shape {
|
|||
fn from(other: &'a StyleShapeSource) -> Self {
|
||||
match other.mType {
|
||||
StyleShapeSourceType::URL => unsafe {
|
||||
let shape_image = &*other.mShapeImage.mPtr;
|
||||
let shape_image = &*other.__bindgen_anon_1.mShapeImage.as_ref().mPtr;
|
||||
let other_url = RefPtr::new(*shape_image.__bindgen_anon_1.mURLValue.as_ref());
|
||||
let url = ComputedUrl::from_url_value(other_url);
|
||||
ShapeSource::ImageOrUrl(url)
|
||||
|
@ -699,7 +699,7 @@ pub mod basic_shape {
|
|||
unreachable!("FloatAreaShape doesn't support URL!");
|
||||
},
|
||||
StyleShapeSourceType::Image => unsafe {
|
||||
let shape_image = &*other.mShapeImage.mPtr;
|
||||
let shape_image = &*other.__bindgen_anon_1.mShapeImage.as_ref().mPtr;
|
||||
let image = shape_image.into_image().expect("Cannot convert to Image");
|
||||
ShapeSource::ImageOrUrl(image)
|
||||
},
|
||||
|
|
|
@ -4960,7 +4960,7 @@ fn static_assert() {
|
|||
ShapeSource::ImageOrUrl(image) => {
|
||||
unsafe {
|
||||
bindings::Gecko_NewShapeImage(${ident});
|
||||
let style_image = &mut *${ident}.mShapeImage.mPtr;
|
||||
let style_image = &mut *${ident}.__bindgen_anon_1.mShapeImage.as_mut().mPtr;
|
||||
style_image.set(image);
|
||||
}
|
||||
}
|
||||
|
@ -4980,7 +4980,7 @@ fn static_assert() {
|
|||
// Create StyleBasicShape in StyleShapeSource. mReferenceBox and mType
|
||||
// will be set manually later.
|
||||
Gecko_NewBasicShape(${ident}, basic_shape_type);
|
||||
&mut *${ident}.mBasicShape.mPtr
|
||||
&mut *${ident}.__bindgen_anon_1.mBasicShape.as_mut().mPtr
|
||||
}
|
||||
}
|
||||
match servo_shape {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue