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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 SVGLengthContext lengthContext(element); | 65 SVGLengthContext lengthContext(element); |
| 66 path.moveTo(FloatPoint(line->x1()->currentValue()->value(lengthContext), lin e->y1()->currentValue()->value(lengthContext))); | 66 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))); | 67 path.addLineTo(FloatPoint(line->x2()->currentValue()->value(lengthContext), line->y2()->currentValue()->value(lengthContext))); |
| 68 } | 68 } |
| 69 | 69 |
| 70 static void updatePathFromPathElement(SVGElement* element, Path& path) | 70 static void updatePathFromPathElement(SVGElement* element, Path& path) |
| 71 { | 71 { |
| 72 buildPathFromByteStream(toSVGPathElement(element)->pathByteStream(), path); | 72 buildPathFromByteStream(toSVGPathElement(element)->pathByteStream(), path); |
| 73 } | 73 } |
| 74 | 74 |
| 75 static void updatePathFromPolylineElement(SVGElement* element, Path& path) | |
| 76 { | |
| 77 RefPtr<SVGPointList> points = toSVGPolyElement(element)->points()->currentVa lue(); | |
| 78 if (points->isEmpty()) | |
| 79 return; | |
| 80 | |
| 81 SVGPointList::ConstIterator it = points->begin(); | |
| 82 SVGPointList::ConstIterator itEnd = points->end(); | |
| 83 ASSERT(it != itEnd); | |
| 84 path.moveTo(it->value()); | |
| 85 ++it; | |
| 86 | |
| 87 for (; it != itEnd; ++it) | |
| 88 path.addLineTo(it->value()); | |
|
haraken
2014/01/17 11:50:18
In the previous code, we didn't call addLineTo for
kouhei (in TOK)
2014/01/20 01:10:26
We are not calling addLineTo for the first element
| |
| 89 } | |
| 90 | |
| 75 static void updatePathFromPolygonElement(SVGElement* element, Path& path) | 91 static void updatePathFromPolygonElement(SVGElement* element, Path& path) |
| 76 { | 92 { |
| 77 SVGPointList& points = toSVGPolygonElement(element)->pointsCurrentValue(); | 93 updatePathFromPolylineElement(element, path); |
|
haraken
2014/01/17 11:50:18
What's the advantage of introducing this static me
kouhei (in TOK)
2014/01/20 01:10:26
This is for <polygon> element. The above is for <p
| |
| 78 if (points.isEmpty()) | |
| 79 return; | |
| 80 | |
| 81 path.moveTo(points.first()); | |
| 82 | |
| 83 unsigned size = points.size(); | |
| 84 for (unsigned i = 1; i < size; ++i) | |
| 85 path.addLineTo(points.at(i)); | |
| 86 | |
| 87 path.closeSubpath(); | 94 path.closeSubpath(); |
| 88 } | 95 } |
| 89 | 96 |
| 90 static void updatePathFromPolylineElement(SVGElement* element, Path& path) | |
| 91 { | |
| 92 SVGPointList& points = toSVGPolylineElement(element)->pointsCurrentValue(); | |
| 93 if (points.isEmpty()) | |
| 94 return; | |
| 95 | |
| 96 path.moveTo(points.first()); | |
| 97 | |
| 98 unsigned size = points.size(); | |
| 99 for (unsigned i = 1; i < size; ++i) | |
| 100 path.addLineTo(points.at(i)); | |
| 101 } | |
| 102 | |
| 103 static void updatePathFromRectElement(SVGElement* element, Path& path) | 97 static void updatePathFromRectElement(SVGElement* element, Path& path) |
| 104 { | 98 { |
| 105 SVGRectElement* rect = toSVGRectElement(element); | 99 SVGRectElement* rect = toSVGRectElement(element); |
| 106 | 100 |
| 107 SVGLengthContext lengthContext(element); | 101 SVGLengthContext lengthContext(element); |
| 108 float width = rect->width()->currentValue()->value(lengthContext); | 102 float width = rect->width()->currentValue()->value(lengthContext); |
| 109 if (width <= 0) | 103 if (width <= 0) |
| 110 return; | 104 return; |
| 111 float height = rect->height()->currentValue()->value(lengthContext); | 105 float height = rect->height()->currentValue()->value(lengthContext); |
| 112 if (height <= 0) | 106 if (height <= 0) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 map->set(SVGNames::polygonTag.localName().impl(), updatePathFromPolygonE lement); | 140 map->set(SVGNames::polygonTag.localName().impl(), updatePathFromPolygonE lement); |
| 147 map->set(SVGNames::polylineTag.localName().impl(), updatePathFromPolylin eElement); | 141 map->set(SVGNames::polylineTag.localName().impl(), updatePathFromPolylin eElement); |
| 148 map->set(SVGNames::rectTag.localName().impl(), updatePathFromRectElement ); | 142 map->set(SVGNames::rectTag.localName().impl(), updatePathFromRectElement ); |
| 149 } | 143 } |
| 150 | 144 |
| 151 if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im pl())) | 145 if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im pl())) |
| 152 (*pathUpdateFunction)(element, path); | 146 (*pathUpdateFunction)(element, path); |
| 153 } | 147 } |
| 154 | 148 |
| 155 } // namespace WebCore | 149 } // namespace WebCore |
| OLD | NEW |