| 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 ASSERT(ellipse->layoutObject()); |
| 55 | 55 |
| 56 SVGLengthContext lengthContext(element); | 56 SVGLengthContext lengthContext(element); |
| 57 const LayoutStyle& style = ellipse->renderer()->styleRef(); | 57 const LayoutStyle& style = ellipse->layoutObject()->styleRef(); |
| 58 float rx = lengthContext.valueForLength(style.svgStyle().rx(), style, SVGLen
gthMode::Width); | 58 float rx = lengthContext.valueForLength(style.svgStyle().rx(), style, SVGLen
gthMode::Width); |
| 59 if (rx < 0) | 59 if (rx < 0) |
| 60 return; | 60 return; |
| 61 float ry = lengthContext.valueForLength(style.svgStyle().ry(), style, SVGLen
gthMode::Height); | 61 float ry = lengthContext.valueForLength(style.svgStyle().ry(), style, SVGLen
gthMode::Height); |
| 62 if (ry < 0) | 62 if (ry < 0) |
| 63 return; | 63 return; |
| 64 if (!rx && !ry) | 64 if (!rx && !ry) |
| 65 return; | 65 return; |
| 66 | 66 |
| 67 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
)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 static void updatePathFromPolygonElement(SVGElement* element, Path& path) | 100 static void updatePathFromPolygonElement(SVGElement* element, Path& path) |
| 101 { | 101 { |
| 102 updatePathFromPolylineElement(element, path); | 102 updatePathFromPolylineElement(element, path); |
| 103 path.closeSubpath(); | 103 path.closeSubpath(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 static void updatePathFromRectElement(SVGElement* element, Path& path) | 106 static void updatePathFromRectElement(SVGElement* element, Path& path) |
| 107 { | 107 { |
| 108 SVGRectElement* rect = toSVGRectElement(element); | 108 SVGRectElement* rect = toSVGRectElement(element); |
| 109 ASSERT(rect->renderer()); | 109 ASSERT(rect->layoutObject()); |
| 110 | 110 |
| 111 SVGLengthContext lengthContext(element); | 111 SVGLengthContext lengthContext(element); |
| 112 float width = rect->width()->currentValue()->value(lengthContext); | 112 float width = rect->width()->currentValue()->value(lengthContext); |
| 113 if (width < 0) | 113 if (width < 0) |
| 114 return; | 114 return; |
| 115 float height = rect->height()->currentValue()->value(lengthContext); | 115 float height = rect->height()->currentValue()->value(lengthContext); |
| 116 if (height < 0) | 116 if (height < 0) |
| 117 return; | 117 return; |
| 118 if (!width && !height) | 118 if (!width && !height) |
| 119 return; | 119 return; |
| 120 | 120 |
| 121 const LayoutStyle& style = rect->renderer()->styleRef(); | 121 const LayoutStyle& style = rect->layoutObject()->styleRef(); |
| 122 float x = lengthContext.valueForLength(style.svgStyle().x(), style, SVGLengt
hMode::Width); | 122 float x = lengthContext.valueForLength(style.svgStyle().x(), style, SVGLengt
hMode::Width); |
| 123 float y = lengthContext.valueForLength(style.svgStyle().y(), style, SVGLengt
hMode::Height); | 123 float y = lengthContext.valueForLength(style.svgStyle().y(), style, SVGLengt
hMode::Height); |
| 124 float rx = lengthContext.valueForLength(style.svgStyle().rx(), style, SVGLen
gthMode::Width); | 124 float rx = lengthContext.valueForLength(style.svgStyle().rx(), style, SVGLen
gthMode::Width); |
| 125 float ry = lengthContext.valueForLength(style.svgStyle().ry(), style, SVGLen
gthMode::Height); | 125 float ry = lengthContext.valueForLength(style.svgStyle().ry(), style, SVGLen
gthMode::Height); |
| 126 bool hasRx = rx > 0; | 126 bool hasRx = rx > 0; |
| 127 bool hasRy = ry > 0; | 127 bool hasRy = ry > 0; |
| 128 if (hasRx || hasRy) { | 128 if (hasRx || hasRy) { |
| 129 if (!hasRx) | 129 if (!hasRx) |
| 130 rx = ry; | 130 rx = ry; |
| 131 else if (!hasRy) | 131 else if (!hasRy) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 154 map->set(polygonTag.localName().impl(), updatePathFromPolygonElement); | 154 map->set(polygonTag.localName().impl(), updatePathFromPolygonElement); |
| 155 map->set(polylineTag.localName().impl(), updatePathFromPolylineElement); | 155 map->set(polylineTag.localName().impl(), updatePathFromPolylineElement); |
| 156 map->set(rectTag.localName().impl(), updatePathFromRectElement); | 156 map->set(rectTag.localName().impl(), updatePathFromRectElement); |
| 157 } | 157 } |
| 158 | 158 |
| 159 if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im
pl())) | 159 if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im
pl())) |
| 160 (*pathUpdateFunction)(element, path); | 160 (*pathUpdateFunction)(element, path); |
| 161 } | 161 } |
| 162 | 162 |
| 163 } // namespace blink | 163 } // namespace blink |
| OLD | NEW |