Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Side by Side Diff: Source/core/rendering/svg/SVGPathData.cpp

Issue 112003003: [SVG] SVGLength{,List} migration to new SVG property impl. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebaselined Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 21 matching lines...) Expand all
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 static void updatePathFromCircleElement(SVGElement* element, Path& path) 37 static void updatePathFromCircleElement(SVGElement* element, Path& path)
38 { 38 {
39 SVGCircleElement* circle = toSVGCircleElement(element); 39 SVGCircleElement* circle = toSVGCircleElement(element);
40 40
41 SVGLengthContext lengthContext(element); 41 SVGLengthContext lengthContext(element);
42 float r = circle->rCurrentValue().value(lengthContext); 42 float r = circle->r()->currentValue()->value(lengthContext);
43 if (r > 0) 43 if (r > 0)
44 path.addEllipse(FloatRect(circle->cxCurrentValue().value(lengthContext) - r, circle->cyCurrentValue().value(lengthContext) - r, r * 2, r * 2)); 44 path.addEllipse(FloatRect(circle->cx()->currentValue()->value(lengthCont ext) - r, circle->cy()->currentValue()->value(lengthContext) - r, r * 2, r * 2)) ;
45 } 45 }
46 46
47 static void updatePathFromEllipseElement(SVGElement* element, Path& path) 47 static void updatePathFromEllipseElement(SVGElement* element, Path& path)
48 { 48 {
49 SVGEllipseElement* ellipse = toSVGEllipseElement(element); 49 SVGEllipseElement* ellipse = toSVGEllipseElement(element);
50 50
51 SVGLengthContext lengthContext(element); 51 SVGLengthContext lengthContext(element);
52 float rx = ellipse->rxCurrentValue().value(lengthContext); 52 float rx = ellipse->rx()->currentValue()->value(lengthContext);
53 if (rx <= 0) 53 if (rx <= 0)
54 return; 54 return;
55 float ry = ellipse->ryCurrentValue().value(lengthContext); 55 float ry = ellipse->ry()->currentValue()->value(lengthContext);
56 if (ry <= 0) 56 if (ry <= 0)
57 return; 57 return;
58 path.addEllipse(FloatRect(ellipse->cxCurrentValue().value(lengthContext) - r x, ellipse->cyCurrentValue().value(lengthContext) - ry, rx * 2, ry * 2)); 58 path.addEllipse(FloatRect(ellipse->cx()->currentValue()->value(lengthContext ) - rx, ellipse->cy()->currentValue()->value(lengthContext) - ry, rx * 2, ry * 2 ));
59 } 59 }
60 60
61 static void updatePathFromLineElement(SVGElement* element, Path& path) 61 static void updatePathFromLineElement(SVGElement* element, Path& path)
62 { 62 {
63 SVGLineElement* line = toSVGLineElement(element); 63 SVGLineElement* line = toSVGLineElement(element);
64 64
65 SVGLengthContext lengthContext(element); 65 SVGLengthContext lengthContext(element);
66 path.moveTo(FloatPoint(line->x1CurrentValue().value(lengthContext), line->y1 CurrentValue().value(lengthContext))); 66 path.moveTo(FloatPoint(line->x1()->currentValue()->value(lengthContext), lin e->y1()->currentValue()->value(lengthContext)));
67 path.addLineTo(FloatPoint(line->x2CurrentValue().value(lengthContext), line- >y2CurrentValue().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 updatePathFromPolygonElement(SVGElement* element, Path& path) 75 static void updatePathFromPolygonElement(SVGElement* element, Path& path)
76 { 76 {
77 SVGPointList& points = toSVGPolygonElement(element)->pointsCurrentValue(); 77 SVGPointList& points = toSVGPolygonElement(element)->pointsCurrentValue();
(...skipping 20 matching lines...) Expand all
98 unsigned size = points.size(); 98 unsigned size = points.size();
99 for (unsigned i = 1; i < size; ++i) 99 for (unsigned i = 1; i < size; ++i)
100 path.addLineTo(points.at(i)); 100 path.addLineTo(points.at(i));
101 } 101 }
102 102
103 static void updatePathFromRectElement(SVGElement* element, Path& path) 103 static void updatePathFromRectElement(SVGElement* element, Path& path)
104 { 104 {
105 SVGRectElement* rect = toSVGRectElement(element); 105 SVGRectElement* rect = toSVGRectElement(element);
106 106
107 SVGLengthContext lengthContext(element); 107 SVGLengthContext lengthContext(element);
108 float width = rect->widthCurrentValue().value(lengthContext); 108 float width = rect->width()->currentValue()->value(lengthContext);
109 if (width <= 0) 109 if (width <= 0)
110 return; 110 return;
111 float height = rect->heightCurrentValue().value(lengthContext); 111 float height = rect->height()->currentValue()->value(lengthContext);
112 if (height <= 0) 112 if (height <= 0)
113 return; 113 return;
114 float x = rect->xCurrentValue().value(lengthContext); 114 float x = rect->x()->currentValue()->value(lengthContext);
115 float y = rect->yCurrentValue().value(lengthContext); 115 float y = rect->y()->currentValue()->value(lengthContext);
116 bool hasRx = rect->rxCurrentValue().value(lengthContext) > 0; 116 bool hasRx = rect->rx()->currentValue()->value(lengthContext) > 0;
117 bool hasRy = rect->ryCurrentValue().value(lengthContext) > 0; 117 bool hasRy = rect->ry()->currentValue()->value(lengthContext) > 0;
118 if (hasRx || hasRy) { 118 if (hasRx || hasRy) {
119 float rx = rect->rxCurrentValue().value(lengthContext); 119 float rx = rect->rx()->currentValue()->value(lengthContext);
120 float ry = rect->ryCurrentValue().value(lengthContext); 120 float ry = rect->ry()->currentValue()->value(lengthContext);
121 if (!hasRx) 121 if (!hasRx)
122 rx = ry; 122 rx = ry;
123 else if (!hasRy) 123 else if (!hasRy)
124 ry = rx; 124 ry = rx;
125 125
126 path.addRoundedRect(FloatRect(x, y, width, height), FloatSize(rx, ry)); 126 path.addRoundedRect(FloatRect(x, y, width, height), FloatSize(rx, ry));
127 return; 127 return;
128 } 128 }
129 129
130 path.addRect(FloatRect(x, y, width, height)); 130 path.addRect(FloatRect(x, y, width, height));
(...skipping 15 matching lines...) Expand all
146 map->set(SVGNames::polygonTag.localName().impl(), updatePathFromPolygonE lement); 146 map->set(SVGNames::polygonTag.localName().impl(), updatePathFromPolygonE lement);
147 map->set(SVGNames::polylineTag.localName().impl(), updatePathFromPolylin eElement); 147 map->set(SVGNames::polylineTag.localName().impl(), updatePathFromPolylin eElement);
148 map->set(SVGNames::rectTag.localName().impl(), updatePathFromRectElement ); 148 map->set(SVGNames::rectTag.localName().impl(), updatePathFromRectElement );
149 } 149 }
150 150
151 if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im pl())) 151 if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im pl()))
152 (*pathUpdateFunction)(element, path); 152 (*pathUpdateFunction)(element, path);
153 } 153 }
154 154
155 } // namespace WebCore 155 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698