mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +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
|
@ -4,6 +4,19 @@
|
|||
|
||||
use app_units::Au;
|
||||
use style::attr::{AttrValue, LengthOrPercentageOrAuto, parse_length};
|
||||
use style::values::computed::CalcLengthOrPercentage;
|
||||
|
||||
#[test]
|
||||
fn test_length_calc() {
|
||||
let calc = CalcLengthOrPercentage { length: Au(10), percentage: Some(0.2) };
|
||||
assert_eq!(calc.to_computed(Some(Au(10))), Some(Au(12)));
|
||||
assert_eq!(calc.to_computed(Some(Au(0))), Some(Au(10)));
|
||||
assert_eq!(calc.to_computed(None), None);
|
||||
|
||||
let calc = CalcLengthOrPercentage { length: Au(10), percentage: None };
|
||||
assert_eq!(calc.to_computed(Some(Au(0))), Some(Au(10)));
|
||||
assert_eq!(calc.to_computed(None), Some(Au(10)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_double() {
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
[calc-height-block-1.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[calc-max-height-block-1.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[calc-min-height-block-1.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
Loading…
Add table
Add a link
Reference in a new issue