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

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

Issue 896773002: [svg2] Make 'x' and 'y' presentation attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: cleanup Created 5 years, 10 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 */ 18 */
19 19
20 #include "config.h" 20 #include "config.h"
21 #include "core/rendering/svg/SVGPathData.h" 21 #include "core/rendering/svg/SVGPathData.h"
22 #include "core/rendering/RenderObject.h"
fs 2015/02/04 13:24:53 These should go the list/block of includes below.
Erik Dahlström (inactive) 2015/02/05 16:09:01 Done.
23 #include "core/rendering/style/SVGRenderStyle.h"
22 24
23 #include "core/SVGNames.h" 25 #include "core/SVGNames.h"
24 #include "core/svg/SVGCircleElement.h" 26 #include "core/svg/SVGCircleElement.h"
25 #include "core/svg/SVGEllipseElement.h" 27 #include "core/svg/SVGEllipseElement.h"
26 #include "core/svg/SVGLineElement.h" 28 #include "core/svg/SVGLineElement.h"
27 #include "core/svg/SVGPathElement.h" 29 #include "core/svg/SVGPathElement.h"
28 #include "core/svg/SVGPathUtilities.h" 30 #include "core/svg/SVGPathUtilities.h"
29 #include "core/svg/SVGPolygonElement.h" 31 #include "core/svg/SVGPolygonElement.h"
30 #include "core/svg/SVGPolylineElement.h" 32 #include "core/svg/SVGPolylineElement.h"
31 #include "core/svg/SVGRectElement.h" 33 #include "core/svg/SVGRectElement.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 97
96 static void updatePathFromPolygonElement(SVGElement* element, Path& path) 98 static void updatePathFromPolygonElement(SVGElement* element, Path& path)
97 { 99 {
98 updatePathFromPolylineElement(element, path); 100 updatePathFromPolylineElement(element, path);
99 path.closeSubpath(); 101 path.closeSubpath();
100 } 102 }
101 103
102 static void updatePathFromRectElement(SVGElement* element, Path& path) 104 static void updatePathFromRectElement(SVGElement* element, Path& path)
103 { 105 {
104 SVGRectElement* rect = toSVGRectElement(element); 106 SVGRectElement* rect = toSVGRectElement(element);
107 RenderObject* renderer = rect->renderer();
108 if (!renderer)
fs 2015/02/04 13:24:53 For <rect>s, I believe there's only one way to rea
Erik Dahlström (inactive) 2015/02/05 16:09:02 Done.
109 return;
105 110
106 SVGLengthContext lengthContext(element); 111 SVGLengthContext lengthContext(element);
107 float width = rect->width()->currentValue()->value(lengthContext); 112 float width = rect->width()->currentValue()->value(lengthContext);
108 if (width < 0) 113 if (width < 0)
109 return; 114 return;
110 float height = rect->height()->currentValue()->value(lengthContext); 115 float height = rect->height()->currentValue()->value(lengthContext);
111 if (height < 0) 116 if (height < 0)
112 return; 117 return;
113 if (!width && !height) 118 if (!width && !height)
114 return; 119 return;
115 float x = rect->x()->currentValue()->value(lengthContext); 120
116 float y = rect->y()->currentValue()->value(lengthContext); 121 const SVGRenderStyle& style = renderer->style()->svgStyle();
122 float x = lengthContext.valueForLength(style.x(), LengthModeWidth);
123 float y = lengthContext.valueForLength(style.y(), LengthModeHeight);
117 float rx = rect->rx()->currentValue()->value(lengthContext); 124 float rx = rect->rx()->currentValue()->value(lengthContext);
118 float ry = rect->ry()->currentValue()->value(lengthContext); 125 float ry = rect->ry()->currentValue()->value(lengthContext);
119 bool hasRx = rx > 0; 126 bool hasRx = rx > 0;
120 bool hasRy = ry > 0; 127 bool hasRy = ry > 0;
121 if (hasRx || hasRy) { 128 if (hasRx || hasRy) {
122 if (!hasRx) 129 if (!hasRx)
123 rx = ry; 130 rx = ry;
124 else if (!hasRy) 131 else if (!hasRy)
125 ry = rx; 132 ry = rx;
126 133
(...skipping 20 matching lines...) Expand all
147 map->set(polygonTag.localName().impl(), updatePathFromPolygonElement); 154 map->set(polygonTag.localName().impl(), updatePathFromPolygonElement);
148 map->set(polylineTag.localName().impl(), updatePathFromPolylineElement); 155 map->set(polylineTag.localName().impl(), updatePathFromPolylineElement);
149 map->set(rectTag.localName().impl(), updatePathFromRectElement); 156 map->set(rectTag.localName().impl(), updatePathFromRectElement);
150 } 157 }
151 158
152 if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im pl())) 159 if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im pl()))
153 (*pathUpdateFunction)(element, path); 160 (*pathUpdateFunction)(element, path);
154 } 161 }
155 162
156 } // namespace blink 163 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698