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

Side by Side Diff: Source/core/layout/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: rebase 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
« no previous file with comments | « Source/core/layout/svg/LayoutSVGRect.cpp ('k') | Source/core/svg/SVGAnimateElement.cpp » ('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
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/layout/svg/SVGPathData.h" 21 #include "core/layout/svg/SVGPathData.h"
22 22
23 #include "core/SVGNames.h" 23 #include "core/SVGNames.h"
24 #include "core/layout/LayoutObject.h"
25 #include "core/layout/style/SVGLayoutStyle.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"
32 #include "platform/graphics/Path.h" 34 #include "platform/graphics/Path.h"
33 #include "wtf/HashMap.h" 35 #include "wtf/HashMap.h"
(...skipping 61 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 ASSERT(rect->renderer());
105 108
106 SVGLengthContext lengthContext(element); 109 SVGLengthContext lengthContext(element);
107 float width = rect->width()->currentValue()->value(lengthContext); 110 float width = rect->width()->currentValue()->value(lengthContext);
108 if (width < 0) 111 if (width < 0)
109 return; 112 return;
110 float height = rect->height()->currentValue()->value(lengthContext); 113 float height = rect->height()->currentValue()->value(lengthContext);
111 if (height < 0) 114 if (height < 0)
112 return; 115 return;
113 if (!width && !height) 116 if (!width && !height)
114 return; 117 return;
115 float x = rect->x()->currentValue()->value(lengthContext); 118
116 float y = rect->y()->currentValue()->value(lengthContext); 119 const SVGLayoutStyle& style = rect->renderer()->style()->svgStyle();
120 float x = lengthContext.valueForLength(style.x(), LengthModeWidth);
121 float y = lengthContext.valueForLength(style.y(), LengthModeHeight);
117 float rx = rect->rx()->currentValue()->value(lengthContext); 122 float rx = rect->rx()->currentValue()->value(lengthContext);
118 float ry = rect->ry()->currentValue()->value(lengthContext); 123 float ry = rect->ry()->currentValue()->value(lengthContext);
119 bool hasRx = rx > 0; 124 bool hasRx = rx > 0;
120 bool hasRy = ry > 0; 125 bool hasRy = ry > 0;
121 if (hasRx || hasRy) { 126 if (hasRx || hasRy) {
122 if (!hasRx) 127 if (!hasRx)
123 rx = ry; 128 rx = ry;
124 else if (!hasRy) 129 else if (!hasRy)
125 ry = rx; 130 ry = rx;
126 131
(...skipping 20 matching lines...) Expand all
147 map->set(polygonTag.localName().impl(), updatePathFromPolygonElement); 152 map->set(polygonTag.localName().impl(), updatePathFromPolygonElement);
148 map->set(polylineTag.localName().impl(), updatePathFromPolylineElement); 153 map->set(polylineTag.localName().impl(), updatePathFromPolylineElement);
149 map->set(rectTag.localName().impl(), updatePathFromRectElement); 154 map->set(rectTag.localName().impl(), updatePathFromRectElement);
150 } 155 }
151 156
152 if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im pl())) 157 if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im pl()))
153 (*pathUpdateFunction)(element, path); 158 (*pathUpdateFunction)(element, path);
154 } 159 }
155 160
156 } // namespace blink 161 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/svg/LayoutSVGRect.cpp ('k') | Source/core/svg/SVGAnimateElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698