From c87668fcd5442529f651c706cd9e056315debf15 Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Tue, 7 Aug 2018 07:56:01 +0000 Subject: [PATCH] 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 --- components/style/gecko/conversions.rs | 6 +++--- components/style/properties/gecko.mako.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/style/gecko/conversions.rs b/components/style/gecko/conversions.rs index 14fee693a03..3b1f31a1b08 100644 --- a/components/style/gecko/conversions.rs +++ b/components/style/gecko/conversions.rs @@ -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) }, diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 312f43878ae..bb4e02ab4d2 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -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 {