mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Derive ToComputedValue for Either<A, B>
This commit is contained in:
parent
79ee821bef
commit
6c17bb03ce
1 changed files with 1 additions and 22 deletions
|
@ -52,7 +52,7 @@ impl Parse for Impossible {
|
|||
|
||||
/// A struct representing one of two kinds of values.
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Copy, HasViewportPercentage, PartialEq, ToCss)]
|
||||
#[derive(Clone, Copy, HasViewportPercentage, PartialEq, ToComputedValue, ToCss)]
|
||||
pub enum Either<A, B> {
|
||||
/// The first value.
|
||||
First(A),
|
||||
|
@ -80,27 +80,6 @@ impl<A: Parse, B: Parse> Parse for Either<A, B> {
|
|||
}
|
||||
}
|
||||
|
||||
use self::computed::{Context, ToComputedValue};
|
||||
|
||||
impl<A: ToComputedValue, B: ToComputedValue> ToComputedValue for Either<A, B> {
|
||||
type ComputedValue = Either<A::ComputedValue, B::ComputedValue>;
|
||||
|
||||
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
|
||||
match *self {
|
||||
Either::First(ref a) => Either::First(a.to_computed_value(context)),
|
||||
Either::Second(ref a) => Either::Second(a.to_computed_value(context)),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
|
||||
match *computed {
|
||||
Either::First(ref a) => Either::First(ToComputedValue::from_computed_value(a)),
|
||||
Either::Second(ref a) => Either::Second(ToComputedValue::from_computed_value(a)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-values-4/#custom-idents
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue