OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2011. 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 if (r > 0) | 43 if (r > 0) |
44 path.addEllipse(FloatRect(circle->cx()->currentValue()->value(lengthCont ext) - r, circle->cy()->currentValue()->value(lengthContext) - r, r * 2, r * 2)) ; | 44 path.addEllipse(FloatRect(circle->cx()->currentValue()->value(lengthCont ext) - r, circle->cy()->currentValue()->value(lengthContext) - r, r * 2, r * 2)) ; |
45 } | 45 } |
46 | 46 |
47 static void updatePathFromEllipseElement(SVGElement* element, Path& path) | 47 static void updatePathFromEllipseElement(SVGElement* element, Path& path) |
48 { | 48 { |
49 SVGEllipseElement* ellipse = toSVGEllipseElement(element); | 49 SVGEllipseElement* ellipse = toSVGEllipseElement(element); |
50 | 50 |
51 SVGLengthContext lengthContext(element); | 51 SVGLengthContext lengthContext(element); |
52 float rx = ellipse->rx()->currentValue()->value(lengthContext); | 52 float rx = ellipse->rx()->currentValue()->value(lengthContext); |
53 if (rx <= 0) | 53 if (rx < 0) |
54 return; | 54 return; |
55 float ry = ellipse->ry()->currentValue()->value(lengthContext); | 55 float ry = ellipse->ry()->currentValue()->value(lengthContext); |
56 if (ry <= 0) | 56 if (ry < 0) |
57 return; | 57 return; |
58 if (!(rx || ry)) | |
pdr.
2014/03/26 00:55:41
It took me a minute to understand this codechange.
| |
59 return; | |
60 | |
58 path.addEllipse(FloatRect(ellipse->cx()->currentValue()->value(lengthContext ) - rx, ellipse->cy()->currentValue()->value(lengthContext) - ry, rx * 2, ry * 2 )); | 61 path.addEllipse(FloatRect(ellipse->cx()->currentValue()->value(lengthContext ) - rx, ellipse->cy()->currentValue()->value(lengthContext) - ry, rx * 2, ry * 2 )); |
59 } | 62 } |
60 | 63 |
61 static void updatePathFromLineElement(SVGElement* element, Path& path) | 64 static void updatePathFromLineElement(SVGElement* element, Path& path) |
62 { | 65 { |
63 SVGLineElement* line = toSVGLineElement(element); | 66 SVGLineElement* line = toSVGLineElement(element); |
64 | 67 |
65 SVGLengthContext lengthContext(element); | 68 SVGLengthContext lengthContext(element); |
66 path.moveTo(FloatPoint(line->x1()->currentValue()->value(lengthContext), lin e->y1()->currentValue()->value(lengthContext))); | 69 path.moveTo(FloatPoint(line->x1()->currentValue()->value(lengthContext), lin e->y1()->currentValue()->value(lengthContext))); |
67 path.addLineTo(FloatPoint(line->x2()->currentValue()->value(lengthContext), line->y2()->currentValue()->value(lengthContext))); | 70 path.addLineTo(FloatPoint(line->x2()->currentValue()->value(lengthContext), line->y2()->currentValue()->value(lengthContext))); |
(...skipping 25 matching lines...) Expand all Loading... | |
93 updatePathFromPolylineElement(element, path); | 96 updatePathFromPolylineElement(element, path); |
94 path.closeSubpath(); | 97 path.closeSubpath(); |
95 } | 98 } |
96 | 99 |
97 static void updatePathFromRectElement(SVGElement* element, Path& path) | 100 static void updatePathFromRectElement(SVGElement* element, Path& path) |
98 { | 101 { |
99 SVGRectElement* rect = toSVGRectElement(element); | 102 SVGRectElement* rect = toSVGRectElement(element); |
100 | 103 |
101 SVGLengthContext lengthContext(element); | 104 SVGLengthContext lengthContext(element); |
102 float width = rect->width()->currentValue()->value(lengthContext); | 105 float width = rect->width()->currentValue()->value(lengthContext); |
103 if (width <= 0) | 106 if (width < 0) |
104 return; | 107 return; |
105 float height = rect->height()->currentValue()->value(lengthContext); | 108 float height = rect->height()->currentValue()->value(lengthContext); |
106 if (height <= 0) | 109 if (height < 0) |
110 return; | |
111 if (!(width || height)) | |
pdr.
2014/03/26 00:55:41
Similarly here, can you fold the negation into the
| |
107 return; | 112 return; |
108 float x = rect->x()->currentValue()->value(lengthContext); | 113 float x = rect->x()->currentValue()->value(lengthContext); |
109 float y = rect->y()->currentValue()->value(lengthContext); | 114 float y = rect->y()->currentValue()->value(lengthContext); |
110 float rx = rect->rx()->currentValue()->value(lengthContext); | 115 float rx = rect->rx()->currentValue()->value(lengthContext); |
111 float ry = rect->ry()->currentValue()->value(lengthContext); | 116 float ry = rect->ry()->currentValue()->value(lengthContext); |
112 bool hasRx = rx > 0; | 117 bool hasRx = rx > 0; |
113 bool hasRy = ry > 0; | 118 bool hasRy = ry > 0; |
114 if (hasRx || hasRy) { | 119 if (hasRx || hasRy) { |
115 if (!hasRx) | 120 if (!hasRx) |
116 rx = ry; | 121 rx = ry; |
(...skipping 23 matching lines...) Expand all Loading... | |
140 map->set(SVGNames::polygonTag.localName().impl(), updatePathFromPolygonE lement); | 145 map->set(SVGNames::polygonTag.localName().impl(), updatePathFromPolygonE lement); |
141 map->set(SVGNames::polylineTag.localName().impl(), updatePathFromPolylin eElement); | 146 map->set(SVGNames::polylineTag.localName().impl(), updatePathFromPolylin eElement); |
142 map->set(SVGNames::rectTag.localName().impl(), updatePathFromRectElement ); | 147 map->set(SVGNames::rectTag.localName().impl(), updatePathFromRectElement ); |
143 } | 148 } |
144 | 149 |
145 if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im pl())) | 150 if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im pl())) |
146 (*pathUpdateFunction)(element, path); | 151 (*pathUpdateFunction)(element, path); |
147 } | 152 } |
148 | 153 |
149 } // namespace WebCore | 154 } // namespace WebCore |
OLD | NEW |