Commit 767ab8e3 authored by Edvard Thörnros's avatar Edvard Thörnros Committed by Commit Bot

Allow trailing whitespace at the end of values attribute

We now first strip the path data and then check if it's an
empty string. This allows white space at the end of the
string. This follows the spec.
https://www.w3.org/TR/SVG11/animate.html#ValuesAttribute

Bug: 429301
Change-Id: Ie77731cb0ec17b489b439953e73230650a16bcd9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1768771Reviewed-by: default avatarFredrik Söderquist <fs@opera.com>
Commit-Queue: Edvard Thörnros <edvardt@opera.com>
Auto-Submit: Edvard Thörnros <edvardt@opera.com>
Cr-Commit-Position: refs/heads/master@{#691067}
parent 887f778e
...@@ -54,12 +54,12 @@ bool SVGAnimationElement::ParseValues(const String& value, ...@@ -54,12 +54,12 @@ bool SVGAnimationElement::ParseValues(const String& value,
value.Split(';', true, parse_list); value.Split(';', true, parse_list);
unsigned last = parse_list.size() - 1; unsigned last = parse_list.size() - 1;
for (unsigned i = 0; i <= last; ++i) { for (unsigned i = 0; i <= last; ++i) {
parse_list[i] = parse_list[i].StripWhiteSpace(IsHTMLSpace<UChar>);
if (parse_list[i].IsEmpty()) { if (parse_list[i].IsEmpty()) {
// Tolerate trailing ';' // Tolerate trailing ';'
if (i < last) if (i < last)
goto fail; goto fail;
} else { } else {
parse_list[i] = parse_list[i].StripWhiteSpace(IsHTMLSpace<UChar>);
result.push_back(parse_list[i]); result.push_back(parse_list[i]);
} }
} }
......
<!DOCTYPE html>
<title>Allow trailing empty entry in value list</title>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://svgwg.org/specs/animations/#ValuesAttribute">
<link rel="author" title="Edvard Thörnros" href="mailto:edvardt@opera.com">
<svg viewbox="0 0 100 100">
<path fill="#1EB287">
<animate attributeName="d"
dur="1s"
repeatCount="indefinite"
values="M 0,0 L 50, 0 L 100,100 Z;
M 100,0 L 0, 100 L 50, 0 Z; "/>
</path>
</svg>
<script>
async_test(function(t) {
window.onload = t.step_func(function() {
window.requestAnimationFrame(t.step_func_done(function() {
let path = document.querySelector("path");
assert_not_equals(window.getComputedStyle(path).d, "none");
}));
});
});
</script>
CONSOLE ERROR: line 4: Error: <animate> attribute values: Invalid value, ";;". CONSOLE ERROR: line 4: Error: <animate> attribute values: Invalid value, ";;".
CONSOLE ERROR: line 5: Error: <animate> attribute values: Invalid value, "300;255;180;30;;". CONSOLE ERROR: line 5: Error: <animate> attribute values: Invalid value, "300;255;180;30;;".
CONSOLE ERROR: line 7: Error: <animate> attribute values: Invalid value, "50%;;;;10%". CONSOLE ERROR: line 7: Error: <animate> attribute values: Invalid value, "50%;;;;10%".
CONSOLE ERROR: line 8: Error: <animate> attribute values: Invalid value, "50%; ;10%".
Tests parsing of values attribute. Tests parsing of values attribute.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
......
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