[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:
parent
d532bdbc86
commit
b96bb97f09
@ -537,23 +537,41 @@ bool SkSVGAttributeParser::parseSpreadMethod(SkSVGSpreadMethod* spread) {
|
|||||||
bool SkSVGAttributeParser::parsePoints(SkSVGPointsType* points) {
|
bool SkSVGAttributeParser::parsePoints(SkSVGPointsType* points) {
|
||||||
SkTDArray<SkPoint> pts;
|
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;
|
bool parsedValue = false;
|
||||||
for (;;) {
|
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;
|
SkScalar x, y;
|
||||||
if (!this->parseScalarToken(&x)) {
|
if (!this->parseScalarToken(&x)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// comma-wsp:
|
// Coordinate values separated by comma-wsp or '-'.
|
||||||
// (wsp+ comma? wsp*) | (comma wsp*)
|
// coordinate-pair:
|
||||||
bool wsp = this->parseWSToken();
|
// coordinate comma-wsp coordinate
|
||||||
bool comma = this->parseExpectedStringToken(",");
|
// | coordinate negative-coordinate
|
||||||
if (!(wsp || comma)) {
|
if (!parseCommaWsp() && !this->parseEOSToken() && *fCurPos != '-') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this->parseWSToken();
|
|
||||||
|
|
||||||
if (!this->parseScalarToken(&y)) {
|
if (!this->parseScalarToken(&y)) {
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user