mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue