mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Auto merge of #26104 - tipowol:fix-23704, r=paulrouget
Update parse_length to match spec <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23704 - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
commit
95da6dbd6d
4 changed files with 4 additions and 171 deletions
|
@ -539,28 +539,18 @@ pub fn parse_length(mut value: &str) -> LengthOrPercentageOrAuto {
|
|||
value = value.trim_start_matches(HTML_SPACE_CHARACTERS);
|
||||
|
||||
// Step 4
|
||||
if value.is_empty() {
|
||||
return LengthOrPercentageOrAuto::Auto;
|
||||
}
|
||||
|
||||
// Step 5
|
||||
if value.starts_with('+') {
|
||||
value = &value[1..]
|
||||
}
|
||||
|
||||
// Steps 6 & 7
|
||||
match value.chars().nth(0) {
|
||||
Some('0'..='9') => {},
|
||||
_ => return LengthOrPercentageOrAuto::Auto,
|
||||
}
|
||||
|
||||
// Steps 8 to 13
|
||||
// Steps 5 to 8
|
||||
// We trim the string length to the minimum of:
|
||||
// 1. the end of the string
|
||||
// 2. the first occurence of a '%' (U+0025 PERCENT SIGN)
|
||||
// 3. the second occurrence of a '.' (U+002E FULL STOP)
|
||||
// 4. the occurrence of a character that is neither a digit nor '%' nor '.'
|
||||
// Note: Step 10 is directly subsumed by FromStr::from_str
|
||||
// Note: Step 7.4 is directly subsumed by FromStr::from_str
|
||||
let mut end_index = value.len();
|
||||
let (mut found_full_stop, mut found_percent) = (false, false);
|
||||
for (i, ch) in value.chars().enumerate() {
|
||||
|
|
|
@ -66,7 +66,8 @@ pub fn test_parse_length() {
|
|||
|
||||
check("0", LengthOrPercentageOrAuto::Length(Au::from_px(0)));
|
||||
check("0.000%", LengthOrPercentageOrAuto::Percentage(0.0));
|
||||
check("+5.82%", LengthOrPercentageOrAuto::Percentage(0.0582));
|
||||
check("+5.82%", LengthOrPercentageOrAuto::Auto);
|
||||
check("5.82%", LengthOrPercentageOrAuto::Percentage(0.0582));
|
||||
check(
|
||||
"5.82",
|
||||
LengthOrPercentageOrAuto::Length(Au::from_f64_px(5.82)),
|
||||
|
|
|
@ -2552,21 +2552,12 @@
|
|||
[<td height="20.25E2"> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
[<hr width=" +200.25in "> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<object vspace="20.25e2"> mapping to marginTop]
|
||||
expected: FAIL
|
||||
|
||||
[<marquee hspace="20.25e2"> mapping to marginRight]
|
||||
expected: FAIL
|
||||
|
||||
[<td width=" +200.25% "> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<iframe width="+200"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<object hspace="20.25e2"> mapping to marginRight]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -2579,30 +2570,12 @@
|
|||
[<input width="20.25e2"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<td width=" +200.25in "> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<iframe height=" +200.25in "> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
[<img hspace="20.25E2"> mapping to marginLeft]
|
||||
expected: FAIL
|
||||
|
||||
[<marquee vspace="20.25E2"> mapping to marginTop]
|
||||
expected: FAIL
|
||||
|
||||
[<img width="+200%"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<img height=" +200in "> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
[<table width=" +200.25% "> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<iframe width=" +200.25%abc"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<embed vspace="20.25E2"> mapping to marginTop]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -2618,24 +2591,12 @@
|
|||
[<embed hspace="20.25e2"> mapping to marginRight]
|
||||
expected: FAIL
|
||||
|
||||
[<td width=" +200.25%abc"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<embed height="20.25e2"> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
[<td width="+200"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<hr width="+200"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<marquee hspace="20.25e2"> mapping to marginLeft]
|
||||
expected: FAIL
|
||||
|
||||
[<img height="+0%"> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
[<input vspace="20.25E2"> mapping to marginTop]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -2648,12 +2609,6 @@
|
|||
[<input hspace="20.25e2"> mapping to marginLeft]
|
||||
expected: FAIL
|
||||
|
||||
[<iframe height="+200"> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
[<iframe height=" +200in "> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
[<table height="20.25E2"> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -2675,21 +2630,9 @@
|
|||
[<img vspace="20.25E2"> mapping to marginBottom]
|
||||
expected: FAIL
|
||||
|
||||
[<iframe width=" +200in "> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<iframe width="+200%"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<td width=" +200in "> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<tr height="20.25E2"> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
[<img height=" +200.25%abc"> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
[<marquee width="20.25E2"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -2699,120 +2642,51 @@
|
|||
[<input vspace="20.25E2"> mapping to marginBottom]
|
||||
expected: FAIL
|
||||
|
||||
[<table width=" +200in "> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<marquee vspace="20.25e2"> mapping to marginBottom]
|
||||
expected: FAIL
|
||||
|
||||
[<img vspace="20.25E2"> mapping to marginTop]
|
||||
expected: FAIL
|
||||
|
||||
[<table width=" +200.25in "> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<img width=" +200.25% "> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<embed hspace="20.25e2"> mapping to marginLeft]
|
||||
expected: FAIL
|
||||
|
||||
[<hr width=" +200.25%abc"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<embed hspace="20.25E2"> mapping to marginRight]
|
||||
expected: FAIL
|
||||
|
||||
[<hr width="+0%"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<img width="+0%"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<iframe height=" +200.25%abc"> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
[<img width="+200"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<input width="20.25E2"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<marquee height="20.25e2"> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
[<hr width="+0"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<object hspace="20.25E2"> mapping to marginLeft]
|
||||
expected: FAIL
|
||||
|
||||
[<img width="+0"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<iframe width="+0"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<img hspace="20.25e2"> mapping to marginRight]
|
||||
expected: FAIL
|
||||
|
||||
[<input hspace="20.25e2"> mapping to marginRight]
|
||||
expected: FAIL
|
||||
|
||||
[<iframe height="+200%"> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
[<hr width=" +200in "> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<img height="+200"> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
[<img height="+0"> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
[<embed hspace="20.25E2"> mapping to marginLeft]
|
||||
expected: FAIL
|
||||
|
||||
[<img width=" +200.25in "> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<table width="+200%"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<object vspace="20.25E2"> mapping to marginBottom]
|
||||
expected: FAIL
|
||||
|
||||
[<img height=" +200.25% "> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
[<table width=" +200.25%abc"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<object height="20.25e2"> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
[<iframe width=" +200.25% "> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<table width="+200"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<embed width="20.25e2"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<embed vspace="20.25E2"> mapping to marginBottom]
|
||||
expected: FAIL
|
||||
|
||||
[<iframe width=" +200.25in "> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<embed vspace="20.25e2"> mapping to marginBottom]
|
||||
expected: FAIL
|
||||
|
||||
[<iframe height="+0%"> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
[<video width="20.25E2"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -2822,57 +2696,33 @@
|
|||
[<video height="20.25e2"> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
[<hr width="+200%"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<tr height="20.25e2"> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
[<img width=" +200.25%abc"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<input hspace="20.25E2"> mapping to marginRight]
|
||||
expected: FAIL
|
||||
|
||||
[<iframe height="+0"> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
[<video width="20.25e2"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<marquee width="20.25e2"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<hr width=" +200.25% "> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<marquee hspace="20.25E2"> mapping to marginRight]
|
||||
expected: FAIL
|
||||
|
||||
[<col width="20.25e2"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<iframe height=" +200.25% "> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
[<embed width="20.25E2"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<iframe width="+0%"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<input vspace="20.25e2"> mapping to marginBottom]
|
||||
expected: FAIL
|
||||
|
||||
[<input hspace="20.25E2"> mapping to marginLeft]
|
||||
expected: FAIL
|
||||
|
||||
[<img height="+200%"> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
[<td width="+200%"> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<marquee vspace="20.25e2"> mapping to marginTop]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -2882,9 +2732,6 @@
|
|||
[<object hspace="20.25e2"> mapping to marginLeft]
|
||||
expected: FAIL
|
||||
|
||||
[<img height=" +200.25in "> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
[<input vspace="20.25e2"> mapping to marginTop]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -2900,9 +2747,6 @@
|
|||
[<marquee hspace="20.25E2"> mapping to marginLeft]
|
||||
expected: FAIL
|
||||
|
||||
[<img width=" +200in "> mapping to width]
|
||||
expected: FAIL
|
||||
|
||||
[<object height="20.25E2"> mapping to height]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
[width.html]
|
||||
expected: FAIL
|
Loading…
Add table
Add a link
Reference in a new issue