mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Use the owned slice type for basic shape polygon coordinates.
This enables destructors for tagged unions in cbindgen, implemented in: * https://github.com/eqrion/cbindgen/pull/333 Which allow us to properly generate a destructor for the cbindgen-generated StyleBasicShape (which now contains an OwnedSlice). For now, we still use the glue code to go from Box<BasicShape> to UniquePtr<BasicShape>. But that will change in the future when we generate even more stuff and remove all the glue. I could add support for copy-constructor generation to cbindgen for tagged enums, but I'm not sure if it'll end up being needed, and copy-constructing unions in C++ is always very tricky. Differential Revision: https://phabricator.services.mozilla.com/D29769
This commit is contained in:
parent
330bccd659
commit
559235edad
9 changed files with 79 additions and 218 deletions
|
@ -8,12 +8,10 @@
|
|||
|
||||
use crate::counter_style::{Symbol, Symbols};
|
||||
use crate::gecko_bindings::structs::{nsStyleCoord, CounterStylePtr};
|
||||
use crate::gecko_bindings::structs::{StyleGridTrackBreadth, StyleShapeRadius};
|
||||
use crate::gecko_bindings::structs::StyleGridTrackBreadth;
|
||||
use crate::gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
|
||||
use crate::values::computed::basic_shape::ShapeRadius as ComputedShapeRadius;
|
||||
use crate::values::computed::{Angle, Length, LengthPercentage};
|
||||
use crate::values::computed::{Number, NumberOrPercentage, Percentage};
|
||||
use crate::values::generics::basic_shape::ShapeRadius;
|
||||
use crate::values::generics::gecko::ScrollSnapPoint;
|
||||
use crate::values::generics::grid::{TrackBreadth, TrackKeyword};
|
||||
use crate::values::generics::length::LengthPercentageOrAuto;
|
||||
|
@ -192,35 +190,6 @@ impl<L: GeckoStyleCoordConvertible> GeckoStyleCoordConvertible for TrackBreadth<
|
|||
}
|
||||
}
|
||||
|
||||
impl GeckoStyleCoordConvertible for ComputedShapeRadius {
|
||||
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
|
||||
match *self {
|
||||
ShapeRadius::ClosestSide => coord.set_value(CoordDataValue::Enumerated(
|
||||
StyleShapeRadius::ClosestSide as u32,
|
||||
)),
|
||||
ShapeRadius::FarthestSide => coord.set_value(CoordDataValue::Enumerated(
|
||||
StyleShapeRadius::FarthestSide as u32,
|
||||
)),
|
||||
ShapeRadius::Length(lp) => lp.to_gecko_style_coord(coord),
|
||||
}
|
||||
}
|
||||
|
||||
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
|
||||
match coord.as_value() {
|
||||
CoordDataValue::Enumerated(v) => {
|
||||
if v == StyleShapeRadius::ClosestSide as u32 {
|
||||
Some(ShapeRadius::ClosestSide)
|
||||
} else if v == StyleShapeRadius::FarthestSide as u32 {
|
||||
Some(ShapeRadius::FarthestSide)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
},
|
||||
_ => GeckoStyleCoordConvertible::from_gecko_style_coord(coord).map(ShapeRadius::Length),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: GeckoStyleCoordConvertible> GeckoStyleCoordConvertible for Option<T> {
|
||||
fn to_gecko_style_coord<U: CoordDataMut>(&self, coord: &mut U) {
|
||||
if let Some(ref me) = *self {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue