mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Add impl GeckoStyleCoordConvertible for Either<A, B>
This commit is contained in:
parent
22aebdf5d4
commit
73eabad1c2
1 changed files with 16 additions and 0 deletions
|
@ -10,6 +10,7 @@ use gecko_bindings::structs::{NS_RADIUS_CLOSEST_SIDE, NS_RADIUS_FARTHEST_SIDE};
|
|||
use gecko_bindings::structs::nsStyleCoord;
|
||||
use gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
|
||||
use std::cmp::max;
|
||||
use values::Either;
|
||||
use values::computed::{LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||
use values::computed::{LengthOrPercentageOrNone, Angle};
|
||||
use values::computed::basic_shape::ShapeRadius;
|
||||
|
@ -31,6 +32,21 @@ pub trait GeckoStyleCoordConvertible : Sized {
|
|||
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self>;
|
||||
}
|
||||
|
||||
impl<A: GeckoStyleCoordConvertible, B: GeckoStyleCoordConvertible> GeckoStyleCoordConvertible for Either<A, B> {
|
||||
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
|
||||
match *self {
|
||||
Either::First(ref v) => v.to_gecko_style_coord(coord),
|
||||
Either::Second(ref v) => v.to_gecko_style_coord(coord),
|
||||
}
|
||||
}
|
||||
|
||||
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
|
||||
A::from_gecko_style_coord(coord)
|
||||
.map(Either::First)
|
||||
.or_else(|| B::from_gecko_style_coord(coord).map(Either::Second))
|
||||
}
|
||||
}
|
||||
|
||||
impl GeckoStyleCoordConvertible for LengthOrPercentage {
|
||||
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
|
||||
let value = match *self {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue