Commit 6f02e862 authored by Anders Hartvoll Ruud's avatar Anders Hartvoll Ruud Committed by Commit Bot

[css-properties-values-api] List syntaxes should accept one or more items.

Currently we accept zero items, which is wrong.

R=futhark@chromium.org

Bug: 641877
Change-Id: I8acdc4c5c7ba54a71a478e7eed79223271e1e92d
Reviewed-on: https://chromium-review.googlesource.com/c/1290889Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Commit-Queue: Anders Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601128}
parent 4e0374ec
This is a testharness.js-based test.
Found 130 tests; 129 PASS, 1 FAIL, 0 TIMEOUT, 0 NOTRUN.
Found 133 tests; 132 PASS, 1 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS syntax:'*', initialValue:'a' is valid
PASS syntax:' * ', initialValue:'b' is valid
PASS syntax:'<length>', initialValue:'2px' is valid
......@@ -22,6 +22,7 @@ PASS syntax:'<length>', initialValue:'calc(2px*4 + 10px)' is valid
PASS syntax:'<length>', initialValue:'7.1e-4cm' is valid
PASS syntax:'<length>', initialValue:'calc(7in - 12px)' is valid
PASS syntax:'<length>+', initialValue:'2px 7px calc(8px)' is valid
PASS syntax:'<length>#', initialValue:'2px, 7px, calc(8px)' is valid
PASS syntax:'<percentage>', initialValue:'-9.3e3%' is valid
PASS syntax:'<length-percentage>', initialValue:'-54%' is valid
PASS syntax:'<length-percentage>', initialValue:'0' is valid
......@@ -117,6 +118,8 @@ PASS syntax:'<length>', initialValue:'calc(4px + 3em)' is invalid
PASS syntax:'<length>', initialValue:'calc(4px + calc(8 * 2em))' is invalid
PASS syntax:'<length>+', initialValue:'calc(2ex + 16px)' is invalid
PASS syntax:'<length>+', initialValue:'10px calc(20px + 4rem)' is invalid
PASS syntax:'<length>+', initialValue:'' is invalid
PASS syntax:'<length>#', initialValue:'' is invalid
PASS syntax:'<percentage> | <length>+', initialValue:'calc(100vh - 10px) 30px' is invalid
PASS syntax:'<length>', initialValue:'10px;' is invalid
PASS syntax:'<length-percentage>', initialValue:'calc(2px + 10% + 7ex)' is invalid
......
......@@ -46,6 +46,7 @@ assert_valid("<length>", "calc(2px*4 + 10px)");
assert_valid("<length>", "7.1e-4cm");
assert_valid("<length>", "calc(7in - 12px)");
assert_valid("<length>+", "2px 7px calc(8px)");
assert_valid("<length>#", "2px, 7px, calc(8px)");
assert_valid("<percentage>", "-9.3e3%");
assert_valid("<length-percentage>", "-54%");
assert_valid("<length-percentage>", "0");
......@@ -151,6 +152,8 @@ assert_invalid("<length>", "calc(4px + 3em)");
assert_invalid("<length>", "calc(4px + calc(8 * 2em))");
assert_invalid("<length>+", "calc(2ex + 16px)");
assert_invalid("<length>+", "10px calc(20px + 4rem)");
assert_invalid("<length>+", "");
assert_invalid("<length>#", "");
assert_invalid("<percentage> | <length>+", "calc(100vh - 10px) 30px");
assert_invalid("<length>", "10px;");
assert_invalid("<length-percentage>", "calc(2px + 10% + 7ex)");
......
......@@ -210,7 +210,7 @@ const CSSValue* ConsumeSyntaxComponent(const CSSSyntaxComponent& syntax,
return nullptr;
list->Append(*value);
}
return list;
return list->length() ? list : nullptr;
}
if (syntax.GetRepeat() == CSSSyntaxRepeat::kCommaSeparated) {
CSSValueList* list = CSSValueList::CreateCommaSeparated();
......@@ -220,7 +220,7 @@ const CSSValue* ConsumeSyntaxComponent(const CSSSyntaxComponent& syntax,
return nullptr;
list->Append(*value);
} while (CSSPropertyParserHelpers::ConsumeCommaIncludingWhitespace(range));
return list;
return list->length() ? list : nullptr;
}
const CSSValue* result = ConsumeSingleType(syntax, range, context);
if (!range.AtEnd())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment