style: Remove refcount for StyleBasicShape
This is due to
Bug 1404243 Part 3.
MozReview-Commit-ID: DKymebmAYLX
--- a/servo/components/style/gecko/conversions.rs
+++ b/servo/components/style/gecko/conversions.rs
@@ -618,17 +618,17 @@ pub mod basic_shape {
StyleShapeSourceType::URL => {
unsafe {
let other_url = &(**other.__bindgen_anon_1.mURL.as_ref());
let url = SpecifiedUrl::from_url_value_data(&other_url._base).unwrap();
ShapeSource::Url(url)
}
},
StyleShapeSourceType::Shape => {
- let other_shape = unsafe { &(**other.__bindgen_anon_1.mBasicShape.as_ref()) };
+ let other_shape = unsafe { &*other.mBasicShape.mPtr };
let shape = other_shape.into();
let reference_box = if other.mReferenceBox == StyleGeometryBox::NoBox {
None
} else {
Some(other.mReferenceBox.into())
};
ShapeSource::Shape(shape, reference_box)
}
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -4941,27 +4941,23 @@ fn static_assert() {
}
}
ShapeSource::None => {} // don't change the type
ShapeSource::Box(reference) => {
${ident}.mReferenceBox = reference.into();
${ident}.mType = StyleShapeSourceType::Box;
}
ShapeSource::Shape(servo_shape, maybe_box) => {
- ${ident}.mReferenceBox = maybe_box.map(Into::into)
- .unwrap_or(StyleGeometryBox::NoBox);
- ${ident}.mType = StyleShapeSourceType::Shape;
-
- fn init_shape(${ident}: &mut StyleShapeSource, ty: StyleBasicShapeType) -> &mut StyleBasicShape {
+ fn init_shape(${ident}: &mut StyleShapeSource, basic_shape_type: StyleBasicShapeType)
+ -> &mut StyleBasicShape {
unsafe {
- // We have to be very careful to avoid a copy here!
- let ref mut union = ${ident}.__bindgen_anon_1;
- let shape: &mut *mut StyleBasicShape = union.mBasicShape.as_mut();
- *shape = Gecko_NewBasicShape(ty);
- &mut **shape
+ // Create StyleBasicShape in StyleShapeSource. mReferenceBox and mType
+ // will be set manually later.
+ Gecko_NewBasicShape(${ident}, basic_shape_type);
+ &mut *${ident}.mBasicShape.mPtr
}
}
match servo_shape {
BasicShape::Inset(inset) => {
let shape = init_shape(${ident}, StyleBasicShapeType::Inset);
unsafe { shape.mCoordinates.set_len(4) };
// set_len() can't call constructors, so the coordinates
@@ -5013,16 +5009,20 @@ fn static_assert() {
}
shape.mFillRule = if poly.fill == FillRule::EvenOdd {
StyleFillRule::Evenodd
} else {
StyleFillRule::Nonzero
};
}
}
+
+ ${ident}.mReferenceBox = maybe_box.map(Into::into)
+ .unwrap_or(StyleGeometryBox::NoBox);
+ ${ident}.mType = StyleShapeSourceType::Shape;
}
}
}
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
(&self.gecko.${gecko_ffi_name}).into()
}