mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Add to_computed method for CalcLengthOrPercentage
* Add to_computed method to calculate `calc()` value with parent size, if parent container size is `None`, the result will be `None`. * Add from_option method for `MaybeAuto`, to construct from `Option<Au>`. * Update some test case.
This commit is contained in:
parent
5062c4b117
commit
22f99c71b9
8 changed files with 47 additions and 32 deletions
|
@ -53,9 +53,9 @@ impl AxisSize {
|
|||
}
|
||||
}
|
||||
LengthOrPercentageOrAuto::Calc(calc) => {
|
||||
match content_size {
|
||||
Some(size) => AxisSize::Definite(size.scale_by(calc.percentage())),
|
||||
None => AxisSize::Infinite
|
||||
match calc.to_computed(content_size) {
|
||||
Some(length) => AxisSize::Definite(length),
|
||||
None => AxisSize::Infinite,
|
||||
}
|
||||
}
|
||||
LengthOrPercentageOrAuto::Auto => {
|
||||
|
@ -79,10 +79,8 @@ fn from_flex_basis(flex_basis: LengthOrPercentageOrAutoOrContent,
|
|||
MaybeAuto::Specified(size.scale_by(percent)),
|
||||
(LengthOrPercentageOrAutoOrContent::Percentage(_), None) =>
|
||||
MaybeAuto::Auto,
|
||||
(LengthOrPercentageOrAutoOrContent::Calc(calc), Some(size)) =>
|
||||
MaybeAuto::Specified(calc.length() + size.scale_by(calc.percentage())),
|
||||
(LengthOrPercentageOrAutoOrContent::Calc(_), None) =>
|
||||
MaybeAuto::Auto,
|
||||
(LengthOrPercentageOrAutoOrContent::Calc(calc), _) =>
|
||||
MaybeAuto::from_option(calc.to_computed(containing_length)),
|
||||
(LengthOrPercentageOrAutoOrContent::Content, _) =>
|
||||
MaybeAuto::Auto,
|
||||
(LengthOrPercentageOrAutoOrContent::Auto, Some(size)) =>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue