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

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

Issue 19781008: Introduce toSVGRectElement(), use it (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 5 months 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
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 path.moveTo(points.first()); 105 path.moveTo(points.first());
106 106
107 unsigned size = points.size(); 107 unsigned size = points.size();
108 for (unsigned i = 1; i < size; ++i) 108 for (unsigned i = 1; i < size; ++i)
109 path.addLineTo(points.at(i)); 109 path.addLineTo(points.at(i));
110 } 110 }
111 111
112 static void updatePathFromRectElement(SVGElement* element, Path& path) 112 static void updatePathFromRectElement(SVGElement* element, Path& path)
113 { 113 {
114 ASSERT(element->hasTagName(SVGNames::rectTag)); 114 SVGRectElement* rect = toSVGRectElement(element);
115 SVGRectElement* rect = static_cast<SVGRectElement*>(element);
116 115
117 SVGLengthContext lengthContext(element); 116 SVGLengthContext lengthContext(element);
118 float width = rect->widthCurrentValue().value(lengthContext); 117 float width = rect->widthCurrentValue().value(lengthContext);
119 if (width <= 0) 118 if (width <= 0)
120 return; 119 return;
121 float height = rect->heightCurrentValue().value(lengthContext); 120 float height = rect->heightCurrentValue().value(lengthContext);
122 if (height <= 0) 121 if (height <= 0)
123 return; 122 return;
124 float x = rect->xCurrentValue().value(lengthContext); 123 float x = rect->xCurrentValue().value(lengthContext);
125 float y = rect->yCurrentValue().value(lengthContext); 124 float y = rect->yCurrentValue().value(lengthContext);
(...skipping 30 matching lines...) Expand all
156 map->set(SVGNames::polygonTag.localName().impl(), updatePathFromPolygonE lement); 155 map->set(SVGNames::polygonTag.localName().impl(), updatePathFromPolygonE lement);
157 map->set(SVGNames::polylineTag.localName().impl(), updatePathFromPolylin eElement); 156 map->set(SVGNames::polylineTag.localName().impl(), updatePathFromPolylin eElement);
158 map->set(SVGNames::rectTag.localName().impl(), updatePathFromRectElement ); 157 map->set(SVGNames::rectTag.localName().impl(), updatePathFromRectElement );
159 } 158 }
160 159
161 if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im pl())) 160 if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im pl()))
162 (*pathUpdateFunction)(element, path); 161 (*pathUpdateFunction)(element, path);
163 } 162 }
164 163
165 } // namespace WebCore 164 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/svg/RenderSVGRect.cpp ('k') | Source/core/rendering/svg/SVGRenderTreeAsText.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698