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 22 matching lines...) Expand all Loading... |
33 #include "core/svg/SVGRectElement.h" | 33 #include "core/svg/SVGRectElement.h" |
34 #include "platform/graphics/Path.h" | 34 #include "platform/graphics/Path.h" |
35 #include "wtf/HashMap.h" | 35 #include "wtf/HashMap.h" |
36 | 36 |
37 namespace blink { | 37 namespace blink { |
38 | 38 |
39 using namespace SVGNames; | 39 using namespace SVGNames; |
40 | 40 |
41 static void updatePathFromCircleElement(SVGElement* element, Path& path) | 41 static void updatePathFromCircleElement(SVGElement* element, Path& path) |
42 { | 42 { |
43 SVGCircleElement* circle = toSVGCircleElement(element); | 43 ASSERT(element->layoutObject()); |
44 | 44 |
45 SVGLengthContext lengthContext(element); | 45 SVGLengthContext lengthContext(element); |
46 float r = circle->r()->currentValue()->value(lengthContext); | 46 const LayoutStyle& style = element->layoutObject()->styleRef(); |
47 if (r > 0) | 47 float r = lengthContext.valueForLength(style.svgStyle().r(), style, SVGLengt
hMode::Other); |
48 path.addEllipse(FloatRect(circle->cx()->currentValue()->value(lengthCont
ext) - r, circle->cy()->currentValue()->value(lengthContext) - r, r * 2, r * 2))
; | 48 if (r > 0) { |
| 49 path.addEllipse(FloatRect( |
| 50 lengthContext.valueForLength(style.svgStyle().cx(), style, SVGLength
Mode::Width) - r, |
| 51 lengthContext.valueForLength(style.svgStyle().cy(), style, SVGLength
Mode::Height) - r, |
| 52 r * 2, r * 2)); |
| 53 } |
49 } | 54 } |
50 | 55 |
51 static void updatePathFromEllipseElement(SVGElement* element, Path& path) | 56 static void updatePathFromEllipseElement(SVGElement* element, Path& path) |
52 { | 57 { |
53 SVGEllipseElement* ellipse = toSVGEllipseElement(element); | 58 ASSERT(element->layoutObject()); |
54 ASSERT(ellipse->layoutObject()); | |
55 | 59 |
56 SVGLengthContext lengthContext(element); | 60 SVGLengthContext lengthContext(element); |
57 const LayoutStyle& style = ellipse->layoutObject()->styleRef(); | 61 const LayoutStyle& style = element->layoutObject()->styleRef(); |
58 float rx = lengthContext.valueForLength(style.svgStyle().rx(), style, SVGLen
gthMode::Width); | 62 float rx = lengthContext.valueForLength(style.svgStyle().rx(), style, SVGLen
gthMode::Width); |
59 if (rx < 0) | 63 if (rx < 0) |
60 return; | 64 return; |
61 float ry = lengthContext.valueForLength(style.svgStyle().ry(), style, SVGLen
gthMode::Height); | 65 float ry = lengthContext.valueForLength(style.svgStyle().ry(), style, SVGLen
gthMode::Height); |
62 if (ry < 0) | 66 if (ry < 0) |
63 return; | 67 return; |
64 if (!rx && !ry) | 68 if (!rx && !ry) |
65 return; | 69 return; |
66 | 70 |
67 path.addEllipse(FloatRect(ellipse->cx()->currentValue()->value(lengthContext
) - rx, ellipse->cy()->currentValue()->value(lengthContext) - ry, rx * 2, ry * 2
)); | 71 path.addEllipse(FloatRect( |
| 72 lengthContext.valueForLength(style.svgStyle().cx(), style, SVGLengthMode
::Width) - rx, |
| 73 lengthContext.valueForLength(style.svgStyle().cy(), style, SVGLengthMode
::Height) - ry, |
| 74 rx * 2, ry * 2)); |
68 } | 75 } |
69 | 76 |
70 static void updatePathFromLineElement(SVGElement* element, Path& path) | 77 static void updatePathFromLineElement(SVGElement* element, Path& path) |
71 { | 78 { |
72 SVGLineElement* line = toSVGLineElement(element); | 79 SVGLineElement* line = toSVGLineElement(element); |
73 | 80 |
74 SVGLengthContext lengthContext(element); | 81 SVGLengthContext lengthContext(element); |
75 path.moveTo(FloatPoint(line->x1()->currentValue()->value(lengthContext), lin
e->y1()->currentValue()->value(lengthContext))); | 82 path.moveTo(FloatPoint(line->x1()->currentValue()->value(lengthContext), lin
e->y1()->currentValue()->value(lengthContext))); |
76 path.addLineTo(FloatPoint(line->x2()->currentValue()->value(lengthContext),
line->y2()->currentValue()->value(lengthContext))); | 83 path.addLineTo(FloatPoint(line->x2()->currentValue()->value(lengthContext),
line->y2()->currentValue()->value(lengthContext))); |
77 } | 84 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 map->set(polygonTag.localName().impl(), updatePathFromPolygonElement); | 161 map->set(polygonTag.localName().impl(), updatePathFromPolygonElement); |
155 map->set(polylineTag.localName().impl(), updatePathFromPolylineElement); | 162 map->set(polylineTag.localName().impl(), updatePathFromPolylineElement); |
156 map->set(rectTag.localName().impl(), updatePathFromRectElement); | 163 map->set(rectTag.localName().impl(), updatePathFromRectElement); |
157 } | 164 } |
158 | 165 |
159 if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im
pl())) | 166 if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im
pl())) |
160 (*pathUpdateFunction)(element, path); | 167 (*pathUpdateFunction)(element, path); |
161 } | 168 } |
162 | 169 |
163 } // namespace blink | 170 } // namespace blink |
OLD | NEW |