Commit 0ca81d5b authored by fs's avatar fs Committed by Commit bot

SVGPathUtilities tidying

Rename buildSVGPathByteStreamFromString to buildByteStreamFromString to
be more consistent with other functions (buildStringFromByteStream and
buildPathFromByteStream). Also drop the PathParsingMode argument, since
it's always UnalteredParsing (and it's unlikely we'll need to build
normalized byte streams ATM.)

Make buildStringFromByteStream return the resulting String instead of
using an out-parameter. Tidies up call-sites and makes for slightly
smaller code.

BUG=467592

Review URL: https://codereview.chromium.org/1469323002

Cr-Commit-Position: refs/heads/master@{#361338}
parent 4ec0dffe
......@@ -366,9 +366,8 @@ static TextStream& operator<<(TextStream& ts, const LayoutSVGShape& shape)
} else if (isSVGPolyElement(*svgElement)) {
writeNameAndQuotedValue(ts, "points", toSVGPolyElement(*svgElement).points()->currentValue()->valueAsString());
} else if (isSVGPathElement(*svgElement)) {
String pathString;
// FIXME: We should switch to UnalteredParsing here - this will affect the path dumping output of dozens of tests.
buildStringFromByteStream(toSVGPathElement(*svgElement).pathByteStream(), pathString, NormalizedParsing);
String pathString = buildStringFromByteStream(toSVGPathElement(*svgElement).pathByteStream(), NormalizedParsing);
writeNameAndQuotedValue(ts, "data", pathString);
} else {
ASSERT_NOT_REACHED();
......
......@@ -122,14 +122,12 @@ const SVGPathByteStream& SVGPath::byteStream() const
String SVGPath::valueAsString() const
{
String string;
buildStringFromByteStream(byteStream(), string, UnalteredParsing);
return string;
return buildStringFromByteStream(byteStream(), UnalteredParsing);
}
void SVGPath::setValueAsString(const String& string, ExceptionState& exceptionState)
{
if (!buildSVGPathByteStreamFromString(string, ensureByteStream(), UnalteredParsing))
if (!buildByteStreamFromString(string, ensureByteStream()))
exceptionState.throwDOMException(SyntaxError, "Problem parsing path \"" + string + "\"");
byteStreamChanged();
}
......
......@@ -53,20 +53,19 @@ bool buildPathFromByteStream(const SVGPathByteStream& stream, Path& result)
return parser.parsePathDataFromSource(NormalizedParsing);
}
bool buildStringFromByteStream(const SVGPathByteStream& stream, String& result, PathParsingMode parsingMode)
String buildStringFromByteStream(const SVGPathByteStream& stream, PathParsingMode parsingMode)
{
if (stream.isEmpty())
return true;
return String();
SVGPathStringBuilder builder;
SVGPathByteStreamSource source(stream);
SVGPathParser parser(&source, &builder);
bool ok = parser.parsePathDataFromSource(parsingMode);
result = builder.result();
return ok;
parser.parsePathDataFromSource(parsingMode);
return builder.result();
}
bool buildSVGPathByteStreamFromString(const String& d, SVGPathByteStream& result, PathParsingMode parsingMode)
bool buildByteStreamFromString(const String& d, SVGPathByteStream& result)
{
result.clear();
if (d.isEmpty())
......@@ -78,7 +77,7 @@ bool buildSVGPathByteStreamFromString(const String& d, SVGPathByteStream& result
SVGPathByteStreamBuilder builder(result);
SVGPathStringSource source(d);
SVGPathParser parser(&source, &builder);
bool ok = parser.parsePathDataFromSource(parsingMode);
bool ok = parser.parsePathDataFromSource(UnalteredParsing);
result.shrinkToFit();
return ok;
}
......
......@@ -35,10 +35,10 @@ bool CORE_EXPORT buildPathFromString(const String&, Path&);
bool buildPathFromByteStream(const SVGPathByteStream&, Path&);
// String -> SVGPathByteStream
bool buildSVGPathByteStreamFromString(const String&, SVGPathByteStream&, PathParsingMode);
bool buildByteStreamFromString(const String&, SVGPathByteStream&);
// SVGPathByteStream -> String
bool buildStringFromByteStream(const SVGPathByteStream&, String&, PathParsingMode);
String buildStringFromByteStream(const SVGPathByteStream&, PathParsingMode);
unsigned getSVGPathSegAtLengthFromSVGPathByteStream(const SVGPathByteStream&, float length);
float getTotalLengthOfSVGPathByteStream(const SVGPathByteStream&);
......
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