style: Make LengthPercentage not copy.

This is needed to support min() / max() / clamp(), etc.

Differential Revision: https://phabricator.services.mozilla.com/D57249
This commit is contained in:
Emilio Cobos Álvarez 2019-12-15 20:15:29 +01:00
parent a541046147
commit 789ddd9dc1
5 changed files with 58 additions and 49 deletions

View file

@ -1373,7 +1373,11 @@ impl ComputedTranslate {
LengthPercentage::zero(),
Length::zero(),
),
Translate::Translate(tx, ty, tz) => (tx, ty, tz),
Translate::Translate(ref tx, ref ty, ref tz) => (
tx.clone(),
ty.clone(),
tz.clone(),
),
}
}
}

View file

@ -76,7 +76,7 @@ impl ToComputedValue for specified::Length {
/// https://drafts.csswg.org/css-values-4/#typedef-length-percentage
#[allow(missing_docs)]
#[derive(
Clone, Copy, Debug, Deserialize, MallocSizeOf, Serialize, ToAnimatedZero, ToResolvedValue,
Clone, Debug, Deserialize, MallocSizeOf, Serialize, ToAnimatedZero, ToResolvedValue,
)]
#[repr(C)]
pub struct LengthPercentage {
@ -543,14 +543,14 @@ impl ToAnimatedValue for NonNegativeLengthPercentage {
impl From<NonNegativeLength> for NonNegativeLengthPercentage {
#[inline]
fn from(length: NonNegativeLength) -> Self {
LengthPercentage::new(length.0, None).into()
NonNegative(LengthPercentage::new(length.0, None))
}
}
impl From<LengthPercentage> for NonNegativeLengthPercentage {
#[inline]
fn from(lp: LengthPercentage) -> Self {
NonNegative::<LengthPercentage>(lp)
NonNegative(lp)
}
}