| 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 16 matching lines...) Expand all Loading... |
| 27 #include "core/svg/SVGPathElement.h" | 27 #include "core/svg/SVGPathElement.h" |
| 28 #include "core/svg/SVGPathUtilities.h" | 28 #include "core/svg/SVGPathUtilities.h" |
| 29 #include "core/svg/SVGPolygonElement.h" | 29 #include "core/svg/SVGPolygonElement.h" |
| 30 #include "core/svg/SVGPolylineElement.h" | 30 #include "core/svg/SVGPolylineElement.h" |
| 31 #include "core/svg/SVGRectElement.h" | 31 #include "core/svg/SVGRectElement.h" |
| 32 #include "platform/graphics/Path.h" | 32 #include "platform/graphics/Path.h" |
| 33 #include "wtf/HashMap.h" | 33 #include "wtf/HashMap.h" |
| 34 | 34 |
| 35 namespace WebCore { | 35 namespace WebCore { |
| 36 | 36 |
| 37 using namespace SVGNames; |
| 38 |
| 37 static void updatePathFromCircleElement(SVGElement* element, Path& path) | 39 static void updatePathFromCircleElement(SVGElement* element, Path& path) |
| 38 { | 40 { |
| 39 SVGCircleElement* circle = toSVGCircleElement(element); | 41 SVGCircleElement* circle = toSVGCircleElement(element); |
| 40 | 42 |
| 41 SVGLengthContext lengthContext(element); | 43 SVGLengthContext lengthContext(element); |
| 42 float r = circle->r()->currentValue()->value(lengthContext); | 44 float r = circle->r()->currentValue()->value(lengthContext); |
| 43 if (r > 0) | 45 if (r > 0) |
| 44 path.addEllipse(FloatRect(circle->cx()->currentValue()->value(lengthCont
ext) - r, circle->cy()->currentValue()->value(lengthContext) - r, r * 2, r * 2))
; | 46 path.addEllipse(FloatRect(circle->cx()->currentValue()->value(lengthCont
ext) - r, circle->cy()->currentValue()->value(lengthContext) - r, r * 2, r * 2))
; |
| 45 } | 47 } |
| 46 | 48 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 133 |
| 132 void updatePathFromGraphicsElement(SVGElement* element, Path& path) | 134 void updatePathFromGraphicsElement(SVGElement* element, Path& path) |
| 133 { | 135 { |
| 134 ASSERT(element); | 136 ASSERT(element); |
| 135 ASSERT(path.isEmpty()); | 137 ASSERT(path.isEmpty()); |
| 136 | 138 |
| 137 typedef void (*PathUpdateFunction)(SVGElement*, Path&); | 139 typedef void (*PathUpdateFunction)(SVGElement*, Path&); |
| 138 static HashMap<StringImpl*, PathUpdateFunction>* map = 0; | 140 static HashMap<StringImpl*, PathUpdateFunction>* map = 0; |
| 139 if (!map) { | 141 if (!map) { |
| 140 map = new HashMap<StringImpl*, PathUpdateFunction>; | 142 map = new HashMap<StringImpl*, PathUpdateFunction>; |
| 141 map->set(SVGNames::circleTag.localName().impl(), updatePathFromCircleEle
ment); | 143 map->set(circleTag.localName().impl(), updatePathFromCircleElement); |
| 142 map->set(SVGNames::ellipseTag.localName().impl(), updatePathFromEllipseE
lement); | 144 map->set(ellipseTag.localName().impl(), updatePathFromEllipseElement); |
| 143 map->set(SVGNames::lineTag.localName().impl(), updatePathFromLineElement
); | 145 map->set(lineTag.localName().impl(), updatePathFromLineElement); |
| 144 map->set(SVGNames::pathTag.localName().impl(), updatePathFromPathElement
); | 146 map->set(pathTag.localName().impl(), updatePathFromPathElement); |
| 145 map->set(SVGNames::polygonTag.localName().impl(), updatePathFromPolygonE
lement); | 147 map->set(polygonTag.localName().impl(), updatePathFromPolygonElement); |
| 146 map->set(SVGNames::polylineTag.localName().impl(), updatePathFromPolylin
eElement); | 148 map->set(polylineTag.localName().impl(), updatePathFromPolylineElement); |
| 147 map->set(SVGNames::rectTag.localName().impl(), updatePathFromRectElement
); | 149 map->set(rectTag.localName().impl(), updatePathFromRectElement); |
| 148 } | 150 } |
| 149 | 151 |
| 150 if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im
pl())) | 152 if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im
pl())) |
| 151 (*pathUpdateFunction)(element, path); | 153 (*pathUpdateFunction)(element, path); |
| 152 } | 154 } |
| 153 | 155 |
| 154 } // namespace WebCore | 156 } // namespace WebCore |
| OLD | NEW |