style: Add support for 'flex-basis:content' in the style system.

Bug: 1105111
Reviewed-by: xidorn
MozReview-Commit-ID: 5WhgHJJ0mDB
This commit is contained in:
Emilio Cobos Álvarez 2018-03-28 23:40:01 -07:00
parent 3532f64b32
commit 744809a8b2
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
13 changed files with 197 additions and 142 deletions

View file

@ -427,10 +427,10 @@ impl LengthOrPercentage {
pub fn clamp_to_non_negative(self) -> Self {
match self {
LengthOrPercentage::Length(length) => {
LengthOrPercentage::Length(Length::new(length.px().max(0.)))
LengthOrPercentage::Length(length.clamp_to_non_negative())
},
LengthOrPercentage::Percentage(percentage) => {
LengthOrPercentage::Percentage(Percentage(percentage.0.max(0.)))
LengthOrPercentage::Percentage(percentage.clamp_to_non_negative())
},
_ => self
}
@ -511,6 +511,31 @@ impl LengthOrPercentageOrAuto {
}
}
/// A wrapper of LengthOrPercentageOrAuto, whose value must be >= 0.
pub type NonNegativeLengthOrPercentageOrAuto = NonNegative<LengthOrPercentageOrAuto>;
impl NonNegativeLengthOrPercentageOrAuto {
/// `auto`
#[inline]
pub fn auto() -> Self {
NonNegative(LengthOrPercentageOrAuto::Auto)
}
}
impl ToAnimatedValue for NonNegativeLengthOrPercentageOrAuto {
type AnimatedValue = LengthOrPercentageOrAuto;
#[inline]
fn to_animated_value(self) -> Self::AnimatedValue {
self.0
}
#[inline]
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
NonNegative(animated.clamp_to_non_negative())
}
}
impl LengthOrPercentageOrAuto {
/// Returns true if the computed value is absolute 0 or 0%.
///
@ -524,6 +549,15 @@ impl LengthOrPercentageOrAuto {
Calc(_) | Auto => false
}
}
fn clamp_to_non_negative(self) -> Self {
use self::LengthOrPercentageOrAuto::*;
match self {
Length(l) => Length(l.clamp_to_non_negative()),
Percentage(p) => Percentage(p.clamp_to_non_negative()),
_ => self,
}
}
}
impl ToComputedValue for specified::LengthOrPercentageOrAuto {
@ -737,6 +771,11 @@ impl CSSPixelLength {
self.0
}
#[inline]
fn clamp_to_non_negative(self) -> Self {
Self::new(self.px().max(0.))
}
/// Return the length with app_unit i32 type.
#[inline]
pub fn to_i32_au(&self) -> i32 {