mirror of
https://github.com/servo/servo.git
synced 2025-08-10 16:05:43 +01: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)
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue