OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2010, 2012. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010, 2012. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 namespace blink { | 29 namespace blink { |
30 | 30 |
31 bool buildPathFromString(const String& d, Path& result) | 31 bool buildPathFromString(const String& d, Path& result) |
32 { | 32 { |
33 if (d.isEmpty()) | 33 if (d.isEmpty()) |
34 return true; | 34 return true; |
35 | 35 |
36 SVGPathBuilder builder(result); | 36 SVGPathBuilder builder(result); |
37 SVGPathStringSource source(d); | 37 SVGPathStringSource source(d); |
38 SVGPathParser parser(&source, &builder); | 38 return SVGPathParser::parsePath(source, builder); |
39 return parser.parsePathDataFromSource(); | |
40 } | 39 } |
41 | 40 |
42 bool buildPathFromByteStream(const SVGPathByteStream& stream, Path& result) | 41 bool buildPathFromByteStream(const SVGPathByteStream& stream, Path& result) |
43 { | 42 { |
44 if (stream.isEmpty()) | 43 if (stream.isEmpty()) |
45 return true; | 44 return true; |
46 | 45 |
47 SVGPathBuilder builder(result); | 46 SVGPathBuilder builder(result); |
48 SVGPathByteStreamSource source(stream); | 47 SVGPathByteStreamSource source(stream); |
49 SVGPathParser parser(&source, &builder); | 48 return SVGPathParser::parsePath(source, builder); |
50 return parser.parsePathDataFromSource(); | |
51 } | 49 } |
52 | 50 |
53 String buildStringFromByteStream(const SVGPathByteStream& stream) | 51 String buildStringFromByteStream(const SVGPathByteStream& stream) |
54 { | 52 { |
55 if (stream.isEmpty()) | 53 if (stream.isEmpty()) |
56 return String(); | 54 return String(); |
57 | 55 |
58 SVGPathStringBuilder builder; | 56 SVGPathStringBuilder builder; |
59 SVGPathByteStreamSource source(stream); | 57 SVGPathByteStreamSource source(stream); |
60 SVGPathParser parser(&source, &builder); | 58 SVGPathParser::parsePath(source, builder); |
61 parser.parsePathDataFromSource(); | |
62 return builder.result(); | 59 return builder.result(); |
63 } | 60 } |
64 | 61 |
65 SVGParsingError buildByteStreamFromString(const String& d, SVGPathByteStream& re
sult) | 62 SVGParsingError buildByteStreamFromString(const String& d, SVGPathByteStream& re
sult) |
66 { | 63 { |
67 result.clear(); | 64 result.clear(); |
68 if (d.isEmpty()) | 65 if (d.isEmpty()) |
69 return SVGParseStatus::NoError; | 66 return SVGParseStatus::NoError; |
70 | 67 |
71 // The string length is typically a minor overestimate of eventual byte stre
am size, so it avoids us a lot of reallocs. | 68 // The string length is typically a minor overestimate of eventual byte stre
am size, so it avoids us a lot of reallocs. |
72 result.reserveInitialCapacity(d.length()); | 69 result.reserveInitialCapacity(d.length()); |
73 | 70 |
74 SVGPathByteStreamBuilder builder(result); | 71 SVGPathByteStreamBuilder builder(result); |
75 SVGPathStringSource source(d); | 72 SVGPathStringSource source(d); |
76 SVGPathParser parser(&source, &builder); | 73 SVGPathParser::parsePath(source, builder); |
77 parser.parsePathDataFromSource(); | |
78 result.shrinkToFit(); | 74 result.shrinkToFit(); |
79 return source.parseError(); | 75 return source.parseError(); |
80 } | 76 } |
81 | 77 |
82 } // namespace blink | 78 } // namespace blink |
OLD | NEW |