First pass at implementing the Flex Layout Algorithm

https://drafts.csswg.org/css-flexbox/#layout-algorithm
This commit is contained in:
Simon Sapin 2020-06-06 00:07:49 +02:00
parent 080f5bb763
commit 01905923db
6 changed files with 1381 additions and 19 deletions

View file

@ -307,6 +307,12 @@ impl ToCss for CSSPixelLength {
}
}
impl std::iter::Sum for CSSPixelLength {
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.fold(Length::zero(), Add::add)
}
}
impl Add for CSSPixelLength {
type Output = Self;
@ -323,6 +329,15 @@ impl AddAssign for CSSPixelLength {
}
}
impl Div for CSSPixelLength {
type Output = CSSFloat;
#[inline]
fn div(self, other: Self) -> CSSFloat {
self.px() / other.px()
}
}
impl Div<CSSFloat> for CSSPixelLength {
type Output = Self;