Chromium Code Reviews| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 | 44 |
| 45 SVGLengthContext lengthContext(element); | 45 SVGLengthContext lengthContext(element); |
| 46 float r = circle->r()->currentValue()->value(lengthContext); | 46 float r = circle->r()->currentValue()->value(lengthContext); |
| 47 if (r > 0) | 47 if (r > 0) |
| 48 path.addEllipse(FloatRect(circle->cx()->currentValue()->value(lengthCont ext) - r, circle->cy()->currentValue()->value(lengthContext) - r, r * 2, r * 2)) ; | 48 path.addEllipse(FloatRect(circle->cx()->currentValue()->value(lengthCont ext) - r, circle->cy()->currentValue()->value(lengthContext) - r, r * 2, r * 2)) ; |
| 49 } | 49 } |
| 50 | 50 |
| 51 static void updatePathFromEllipseElement(SVGElement* element, Path& path) | 51 static void updatePathFromEllipseElement(SVGElement* element, Path& path) |
| 52 { | 52 { |
| 53 SVGEllipseElement* ellipse = toSVGEllipseElement(element); | 53 SVGEllipseElement* ellipse = toSVGEllipseElement(element); |
| 54 ASSERT(ellipse->renderer()); | |
| 54 | 55 |
| 55 SVGLengthContext lengthContext(element); | 56 SVGLengthContext lengthContext(element); |
| 56 float rx = ellipse->rx()->currentValue()->value(lengthContext); | 57 const LayoutStyle& style = ellipse->renderer()->styleRef(); |
| 58 float rx = lengthContext.valueForLength(style.svgStyle().rx(), style, Length ModeWidth); | |
| 57 if (rx < 0) | 59 if (rx < 0) |
|
fs
2015/02/26 14:20:58
Shouldn't the negative value be filtered out alrea
Erik Dahlström (inactive)
2015/02/26 16:16:33
Calc may do that indeed, so I think we should keep
| |
| 58 return; | 60 return; |
| 59 float ry = ellipse->ry()->currentValue()->value(lengthContext); | 61 float ry = lengthContext.valueForLength(style.svgStyle().ry(), style, Length ModeHeight); |
| 60 if (ry < 0) | 62 if (ry < 0) |
| 61 return; | 63 return; |
| 62 if (!rx && !ry) | 64 if (!rx && !ry) |
| 63 return; | 65 return; |
| 64 | 66 |
| 65 path.addEllipse(FloatRect(ellipse->cx()->currentValue()->value(lengthContext ) - rx, ellipse->cy()->currentValue()->value(lengthContext) - ry, rx * 2, ry * 2 )); | 67 path.addEllipse(FloatRect(ellipse->cx()->currentValue()->value(lengthContext ) - rx, ellipse->cy()->currentValue()->value(lengthContext) - ry, rx * 2, ry * 2 )); |
| 66 } | 68 } |
| 67 | 69 |
| 68 static void updatePathFromLineElement(SVGElement* element, Path& path) | 70 static void updatePathFromLineElement(SVGElement* element, Path& path) |
| 69 { | 71 { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 return; | 114 return; |
| 113 float height = rect->height()->currentValue()->value(lengthContext); | 115 float height = rect->height()->currentValue()->value(lengthContext); |
| 114 if (height < 0) | 116 if (height < 0) |
| 115 return; | 117 return; |
| 116 if (!width && !height) | 118 if (!width && !height) |
| 117 return; | 119 return; |
| 118 | 120 |
| 119 const LayoutStyle& style = rect->renderer()->styleRef(); | 121 const LayoutStyle& style = rect->renderer()->styleRef(); |
| 120 float x = lengthContext.valueForLength(style.svgStyle().x(), style, LengthMo deWidth); | 122 float x = lengthContext.valueForLength(style.svgStyle().x(), style, LengthMo deWidth); |
| 121 float y = lengthContext.valueForLength(style.svgStyle().y(), style, LengthMo deHeight); | 123 float y = lengthContext.valueForLength(style.svgStyle().y(), style, LengthMo deHeight); |
| 122 float rx = rect->rx()->currentValue()->value(lengthContext); | 124 float rx = lengthContext.valueForLength(style.svgStyle().rx(), style, Length ModeWidth); |
| 123 float ry = rect->ry()->currentValue()->value(lengthContext); | 125 float ry = lengthContext.valueForLength(style.svgStyle().ry(), style, Length ModeHeight); |
| 124 bool hasRx = rx > 0; | 126 bool hasRx = rx > 0; |
| 125 bool hasRy = ry > 0; | 127 bool hasRy = ry > 0; |
| 126 if (hasRx || hasRy) { | 128 if (hasRx || hasRy) { |
| 127 if (!hasRx) | 129 if (!hasRx) |
| 128 rx = ry; | 130 rx = ry; |
| 129 else if (!hasRy) | 131 else if (!hasRy) |
| 130 ry = rx; | 132 ry = rx; |
| 131 | 133 |
| 132 path.addRoundedRect(FloatRect(x, y, width, height), FloatSize(rx, ry)); | 134 path.addRoundedRect(FloatRect(x, y, width, height), FloatSize(rx, ry)); |
| 133 return; | 135 return; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 152 map->set(polygonTag.localName().impl(), updatePathFromPolygonElement); | 154 map->set(polygonTag.localName().impl(), updatePathFromPolygonElement); |
| 153 map->set(polylineTag.localName().impl(), updatePathFromPolylineElement); | 155 map->set(polylineTag.localName().impl(), updatePathFromPolylineElement); |
| 154 map->set(rectTag.localName().impl(), updatePathFromRectElement); | 156 map->set(rectTag.localName().impl(), updatePathFromRectElement); |
| 155 } | 157 } |
| 156 | 158 |
| 157 if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im pl())) | 159 if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im pl())) |
| 158 (*pathUpdateFunction)(element, path); | 160 (*pathUpdateFunction)(element, path); |
| 159 } | 161 } |
| 160 | 162 |
| 161 } // namespace blink | 163 } // namespace blink |
| OLD | NEW |