diff --git a/components/style/attr.rs b/components/style/attr.rs index 1d0d555d509..92ab7700fb8 100644 --- a/components/style/attr.rs +++ b/components/style/attr.rs @@ -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() { diff --git a/tests/unit/style/attr.rs b/tests/unit/style/attr.rs index 261d6d8f98b..9bcfa2be522 100644 --- a/tests/unit/style/attr.rs +++ b/tests/unit/style/attr.rs @@ -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)), diff --git a/tests/wpt/metadata/html/rendering/dimension-attributes.html.ini b/tests/wpt/metadata/html/rendering/dimension-attributes.html.ini index b0a5e5d8414..6583da6a4c8 100644 --- a/tests/wpt/metadata/html/rendering/dimension-attributes.html.ini +++ b/tests/wpt/metadata/html/rendering/dimension-attributes.html.ini @@ -2552,21 +2552,12 @@ [ mapping to height] expected: FAIL - [
mapping to width] - expected: FAIL - [ mapping to marginTop] expected: FAIL [ mapping to marginRight] expected: FAIL - [ mapping to width] - expected: FAIL - - [