[SVG] Fix polyline/polygon point parsing

This was evident in the 'shapes-polygon-01-t' SVG.

Change-Id: I4900b9e3626b924291c569a6611fb3b280e3219c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/282397
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Tyler Denniston <tdenniston@google.com>
This commit is contained in:
Tyler Denniston 2020-04-08 17:36:11 -04:00 committed by Skia Commit-Bot
parent d532bdbc86
commit b96bb97f09

View File

@ -537,23 +537,41 @@ bool SkSVGAttributeParser::parseSpreadMethod(SkSVGSpreadMethod* spread) {
bool SkSVGAttributeParser::parsePoints(SkSVGPointsType* points) {
SkTDArray<SkPoint> pts;
// comma-wsp:
// (wsp+ comma? wsp*) | (comma wsp*)
const auto parseCommaWsp = [this]() -> bool {
const bool wsp = this->parseWSToken();
const bool comma = this->parseExpectedStringToken(",");
return wsp || comma;
};
// Skip initial wsp.
// list-of-points:
// wsp* coordinate-pairs? wsp*
this->advanceWhile(is_ws);
bool parsedValue = false;
for (;;) {
this->parseWSToken();
// Adjacent coordinate-pairs separated by comma-wsp.
// coordinate-pairs:
// coordinate-pair
// | coordinate-pair comma-wsp coordinate-pairs
if (parsedValue && !parseCommaWsp()) {
break;
}
SkScalar x, y;
if (!this->parseScalarToken(&x)) {
break;
}
// comma-wsp:
// (wsp+ comma? wsp*) | (comma wsp*)
bool wsp = this->parseWSToken();
bool comma = this->parseExpectedStringToken(",");
if (!(wsp || comma)) {
// Coordinate values separated by comma-wsp or '-'.
// coordinate-pair:
// coordinate comma-wsp coordinate
// | coordinate negative-coordinate
if (!parseCommaWsp() && !this->parseEOSToken() && *fCurPos != '-') {
break;
}
this->parseWSToken();
if (!this->parseScalarToken(&y)) {
break;