mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Simplify/remove a couple other length operations
Differential Revision: https://phabricator.services.mozilla.com/D172430
This commit is contained in:
parent
52f1a680d5
commit
9509f84bc0
1 changed files with 5 additions and 34 deletions
|
@ -631,16 +631,7 @@ impl AbsoluteLength {
|
||||||
where
|
where
|
||||||
O: Fn(f32, f32) -> f32,
|
O: Fn(f32, f32) -> f32,
|
||||||
{
|
{
|
||||||
Ok(match (self, other) {
|
Ok(Self::Px(op(self.to_px(), other.to_px())))
|
||||||
(AbsoluteLength::Px(x), AbsoluteLength::Px(y)) => AbsoluteLength::Px(op(*x, *y)),
|
|
||||||
(AbsoluteLength::In(x), AbsoluteLength::In(y)) => AbsoluteLength::In(op(*x, *y)),
|
|
||||||
(AbsoluteLength::Cm(x), AbsoluteLength::Cm(y)) => AbsoluteLength::Cm(op(*x, *y)),
|
|
||||||
(AbsoluteLength::Mm(x), AbsoluteLength::Mm(y)) => AbsoluteLength::Mm(op(*x, *y)),
|
|
||||||
(AbsoluteLength::Q(x), AbsoluteLength::Q(y)) => AbsoluteLength::Q(op(*x, *y)),
|
|
||||||
(AbsoluteLength::Pt(x), AbsoluteLength::Pt(y)) => AbsoluteLength::Pt(op(*x, *y)),
|
|
||||||
(AbsoluteLength::Pc(x), AbsoluteLength::Pc(y)) => AbsoluteLength::Pc(op(*x, *y)),
|
|
||||||
_ => AbsoluteLength::Px(op(self.to_px(), other.to_px())),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -652,7 +643,7 @@ impl ToComputedValue for AbsoluteLength {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
|
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
|
||||||
AbsoluteLength::Px(computed.px())
|
Self::Px(computed.px())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -663,19 +654,11 @@ impl PartialOrd for AbsoluteLength {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Mul<CSSFloat> for AbsoluteLength {
|
impl Mul<CSSFloat> for AbsoluteLength {
|
||||||
type Output = AbsoluteLength;
|
type Output = Self;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn mul(self, scalar: CSSFloat) -> AbsoluteLength {
|
fn mul(self, scalar: CSSFloat) -> Self {
|
||||||
match self {
|
Self::Px(self.to_px() * scalar)
|
||||||
AbsoluteLength::Px(v) => AbsoluteLength::Px(v * scalar),
|
|
||||||
AbsoluteLength::In(v) => AbsoluteLength::In(v * scalar),
|
|
||||||
AbsoluteLength::Cm(v) => AbsoluteLength::Cm(v * scalar),
|
|
||||||
AbsoluteLength::Mm(v) => AbsoluteLength::Mm(v * scalar),
|
|
||||||
AbsoluteLength::Q(v) => AbsoluteLength::Q(v * scalar),
|
|
||||||
AbsoluteLength::Pt(v) => AbsoluteLength::Pt(v * scalar),
|
|
||||||
AbsoluteLength::Pc(v) => AbsoluteLength::Pc(v * scalar),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1146,18 +1129,6 @@ impl From<NoCalcLength> for Length {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Mul<CSSFloat> for Length {
|
|
||||||
type Output = Length;
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn mul(self, scalar: CSSFloat) -> Length {
|
|
||||||
match self {
|
|
||||||
Length::NoCalc(inner) => Length::NoCalc(inner * scalar),
|
|
||||||
Length::Calc(..) => panic!("Can't multiply Calc!"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PartialOrd for FontRelativeLength {
|
impl PartialOrd for FontRelativeLength {
|
||||||
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
|
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
|
||||||
use self::FontRelativeLength::*;
|
use self::FontRelativeLength::*;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue