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

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

Issue 966923003: Make SVGLengthMode an enum class (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/layout/svg/LayoutSVGRect.cpp ('k') | Source/core/svg/LinearGradientAttributes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 path.addEllipse(FloatRect(circle->cx()->currentValue()->value(lengthCont ext) - r, circle->cy()->currentValue()->value(lengthContext) - r, r * 2, r * 2)) ; 48 path.addEllipse(FloatRect(circle->cx()->currentValue()->value(lengthCont ext) - r, circle->cy()->currentValue()->value(lengthContext) - r, r * 2, r * 2)) ;
49 } 49 }
50 50
51 static void updatePathFromEllipseElement(SVGElement* element, Path& path) 51 static void updatePathFromEllipseElement(SVGElement* element, Path& path)
52 { 52 {
53 SVGEllipseElement* ellipse = toSVGEllipseElement(element); 53 SVGEllipseElement* ellipse = toSVGEllipseElement(element);
54 ASSERT(ellipse->renderer()); 54 ASSERT(ellipse->renderer());
55 55
56 SVGLengthContext lengthContext(element); 56 SVGLengthContext lengthContext(element);
57 const LayoutStyle& style = ellipse->renderer()->styleRef(); 57 const LayoutStyle& style = ellipse->renderer()->styleRef();
58 float rx = lengthContext.valueForLength(style.svgStyle().rx(), style, Length ModeWidth); 58 float rx = lengthContext.valueForLength(style.svgStyle().rx(), style, SVGLen gthMode::Width);
59 if (rx < 0) 59 if (rx < 0)
60 return; 60 return;
61 float ry = lengthContext.valueForLength(style.svgStyle().ry(), style, Length ModeHeight); 61 float ry = lengthContext.valueForLength(style.svgStyle().ry(), style, SVGLen gthMode::Height);
62 if (ry < 0) 62 if (ry < 0)
63 return; 63 return;
64 if (!rx && !ry) 64 if (!rx && !ry)
65 return; 65 return;
66 66
67 path.addEllipse(FloatRect(ellipse->cx()->currentValue()->value(lengthContext ) - rx, ellipse->cy()->currentValue()->value(lengthContext) - ry, rx * 2, ry * 2 )); 67 path.addEllipse(FloatRect(ellipse->cx()->currentValue()->value(lengthContext ) - rx, ellipse->cy()->currentValue()->value(lengthContext) - ry, rx * 2, ry * 2 ));
68 } 68 }
69 69
70 static void updatePathFromLineElement(SVGElement* element, Path& path) 70 static void updatePathFromLineElement(SVGElement* element, Path& path)
71 { 71 {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 float width = rect->width()->currentValue()->value(lengthContext); 112 float width = rect->width()->currentValue()->value(lengthContext);
113 if (width < 0) 113 if (width < 0)
114 return; 114 return;
115 float height = rect->height()->currentValue()->value(lengthContext); 115 float height = rect->height()->currentValue()->value(lengthContext);
116 if (height < 0) 116 if (height < 0)
117 return; 117 return;
118 if (!width && !height) 118 if (!width && !height)
119 return; 119 return;
120 120
121 const LayoutStyle& style = rect->renderer()->styleRef(); 121 const LayoutStyle& style = rect->renderer()->styleRef();
122 float x = lengthContext.valueForLength(style.svgStyle().x(), style, LengthMo deWidth); 122 float x = lengthContext.valueForLength(style.svgStyle().x(), style, SVGLengt hMode::Width);
123 float y = lengthContext.valueForLength(style.svgStyle().y(), style, LengthMo deHeight); 123 float y = lengthContext.valueForLength(style.svgStyle().y(), style, SVGLengt hMode::Height);
124 float rx = lengthContext.valueForLength(style.svgStyle().rx(), style, Length ModeWidth); 124 float rx = lengthContext.valueForLength(style.svgStyle().rx(), style, SVGLen gthMode::Width);
125 float ry = lengthContext.valueForLength(style.svgStyle().ry(), style, Length ModeHeight); 125 float ry = lengthContext.valueForLength(style.svgStyle().ry(), style, SVGLen gthMode::Height);
126 bool hasRx = rx > 0; 126 bool hasRx = rx > 0;
127 bool hasRy = ry > 0; 127 bool hasRy = ry > 0;
128 if (hasRx || hasRy) { 128 if (hasRx || hasRy) {
129 if (!hasRx) 129 if (!hasRx)
130 rx = ry; 130 rx = ry;
131 else if (!hasRy) 131 else if (!hasRy)
132 ry = rx; 132 ry = rx;
133 133
134 path.addRoundedRect(FloatRect(x, y, width, height), FloatSize(rx, ry)); 134 path.addRoundedRect(FloatRect(x, y, width, height), FloatSize(rx, ry));
135 return; 135 return;
(...skipping 18 matching lines...) Expand all
154 map->set(polygonTag.localName().impl(), updatePathFromPolygonElement); 154 map->set(polygonTag.localName().impl(), updatePathFromPolygonElement);
155 map->set(polylineTag.localName().impl(), updatePathFromPolylineElement); 155 map->set(polylineTag.localName().impl(), updatePathFromPolylineElement);
156 map->set(rectTag.localName().impl(), updatePathFromRectElement); 156 map->set(rectTag.localName().impl(), updatePathFromRectElement);
157 } 157 }
158 158
159 if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im pl())) 159 if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im pl()))
160 (*pathUpdateFunction)(element, path); 160 (*pathUpdateFunction)(element, path);
161 } 161 }
162 162
163 } // namespace blink 163 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/svg/LayoutSVGRect.cpp ('k') | Source/core/svg/LinearGradientAttributes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698