OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
10 * disclaimer. | 10 * disclaimer. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 bool CSSBasicShapeRectangle::hasVariableReference() const | 100 bool CSSBasicShapeRectangle::hasVariableReference() const |
101 { | 101 { |
102 return m_x->hasVariableReference() | 102 return m_x->hasVariableReference() |
103 || m_y->hasVariableReference() | 103 || m_y->hasVariableReference() |
104 || m_width->hasVariableReference() | 104 || m_width->hasVariableReference() |
105 || m_height->hasVariableReference() | 105 || m_height->hasVariableReference() |
106 || (m_radiusX.get() && m_radiusX->hasVariableReference()) | 106 || (m_radiusX.get() && m_radiusX->hasVariableReference()) |
107 || (m_radiusY.get() && m_radiusY->hasVariableReference()); | 107 || (m_radiusY.get() && m_radiusY->hasVariableReference()); |
108 } | 108 } |
109 | 109 |
110 static String buildCircleString(const String& x, const String& y, const String& radius) | 110 static String buildCircleString(const String& radius, const String& centerX, con st String& centerY, const String& box) |
111 { | 111 { |
112 return "circle(" + x + ", " + y + ", " + radius + ')'; | 112 char opening[] = "circle("; |
113 char at[] = "at"; | |
114 char separator[] = " "; | |
115 StringBuilder result; | |
116 // Compute the required capacity in advance to reduce allocations. | |
117 result.reserveCapacity((sizeof(opening) - 1) + (3 * (sizeof(separator) - 1)) + 1 + radius.length() + sizeof(at) + centerX.length() + centerY.length()); | |
bemjb
2013/12/07 00:05:32
It looks like you didn't pull the latest patch: I'
| |
118 result.append(opening); | |
119 if (!radius.isNull()) | |
120 result.append(radius); | |
121 | |
122 if (!centerX.isNull() || !centerY.isNull()) { | |
123 if (!radius.isNull()) | |
124 result.append(separator); | |
125 result.append(at); | |
126 result.append(separator); | |
127 result.append(centerX); | |
128 result.append(separator); | |
129 result.append(centerY); | |
130 } | |
131 result.append(")"); | |
132 if (box.length()) { | |
133 result.append(separator); | |
134 result.append(box); | |
135 } | |
136 return result.toString(); | |
113 } | 137 } |
114 | 138 |
115 String CSSBasicShapeCircle::cssText() const | 139 String CSSBasicShapeCircle::cssText() const |
116 { | 140 { |
117 return buildCircleString(m_centerX->cssText(), m_centerY->cssText(), m_radiu s->cssText()); | 141 return buildCircleString(m_radius ? m_radius->cssText() : String(), |
142 m_centerX ? m_centerX->cssText() : String(), | |
143 m_centerY ? m_centerY->cssText() : String(), | |
144 m_box ? m_box->cssText() : String()); | |
118 } | 145 } |
119 | 146 |
120 bool CSSBasicShapeCircle::equals(const CSSBasicShape& shape) const | 147 bool CSSBasicShapeCircle::equals(const CSSBasicShape& shape) const |
121 { | 148 { |
122 if (shape.type() != CSSBasicShapeCircleType) | 149 if (shape.type() != CSSBasicShapeCircleType) |
123 return false; | 150 return false; |
124 | 151 |
125 const CSSBasicShapeCircle& other = static_cast<const CSSBasicShapeCircle&>(s hape); | 152 const CSSBasicShapeCircle& other = static_cast<const CSSBasicShapeCircle&>(s hape); |
126 return compareCSSValuePtr(m_centerX, other.m_centerX) | 153 return compareCSSValuePtr(m_centerX, other.m_centerX) |
127 && compareCSSValuePtr(m_centerY, other.m_centerY) | 154 && compareCSSValuePtr(m_centerY, other.m_centerY) |
155 && compareCSSValuePtr(m_radius, other.m_radius) | |
156 && compareCSSValuePtr(m_box, other.m_box); | |
157 } | |
158 | |
159 String CSSBasicShapeCircle::serializeResolvingVariables(const HashMap<AtomicStri ng, String>& variables) const | |
160 { | |
161 return buildCircleString(m_radius.get() ? m_radius->serializeResolvingVariab les(variables) : String(), | |
162 m_centerX.get() ? m_centerX->serializeResolvingVariables(variables) : St ring(), | |
163 m_centerY.get() ? m_centerY->serializeResolvingVariables(variables) : St ring(), | |
164 m_box.get() ? m_box->serializeResolvingVariables(variables) : String()); | |
165 } | |
166 | |
167 bool CSSBasicShapeCircle::hasVariableReference() const | |
168 { | |
169 return (m_centerX && m_centerX->hasVariableReference()) | |
170 || (m_centerY && m_centerY->hasVariableReference()) | |
171 || (m_radius && m_radius->hasVariableReference()); | |
172 } | |
173 | |
174 static String buildDeprecatedCircleString(const String& x, const String& y, cons t String& radius) | |
175 { | |
176 return "circle(" + x + ", " + y + ", " + radius + ')'; | |
177 } | |
178 | |
179 String CSSDeprecatedBasicShapeCircle::cssText() const | |
180 { | |
181 return buildDeprecatedCircleString(m_centerX->cssText(), m_centerY->cssText( ), m_radius->cssText()); | |
182 } | |
183 | |
184 bool CSSDeprecatedBasicShapeCircle::equals(const CSSBasicShape& shape) const | |
185 { | |
186 if (shape.type() != CSSDeprecatedBasicShapeCircleType) | |
187 return false; | |
188 | |
189 const CSSDeprecatedBasicShapeCircle& other = static_cast<const CSSDeprecated BasicShapeCircle&>(shape); | |
190 return compareCSSValuePtr(m_centerX, other.m_centerX) | |
191 && compareCSSValuePtr(m_centerY, other.m_centerY) | |
128 && compareCSSValuePtr(m_radius, other.m_radius); | 192 && compareCSSValuePtr(m_radius, other.m_radius); |
129 } | 193 } |
130 | 194 |
131 String CSSBasicShapeCircle::serializeResolvingVariables(const HashMap<AtomicStri ng, String>& variables) const | 195 String CSSDeprecatedBasicShapeCircle::serializeResolvingVariables(const HashMap< AtomicString, String>& variables) const |
132 { | 196 { |
133 return buildCircleString(m_centerX->serializeResolvingVariables(variables), | 197 return buildDeprecatedCircleString(m_centerX->serializeResolvingVariables(va riables), |
134 m_centerY->serializeResolvingVariables(variables), | 198 m_centerY->serializeResolvingVariables(variables), |
135 m_radius->serializeResolvingVariables(variables)); | 199 m_radius->serializeResolvingVariables(variables)); |
136 } | 200 } |
137 | 201 |
138 bool CSSBasicShapeCircle::hasVariableReference() const | 202 bool CSSDeprecatedBasicShapeCircle::hasVariableReference() const |
139 { | 203 { |
140 return m_centerX->hasVariableReference() | 204 return m_centerX->hasVariableReference() |
141 || m_centerY->hasVariableReference() | 205 || m_centerY->hasVariableReference() |
142 || m_radius->hasVariableReference(); | 206 || m_radius->hasVariableReference(); |
143 } | 207 } |
144 | 208 |
145 static String buildEllipseString(const String& x, const String& y, const String& radiusX, const String& radiusY) | 209 static String buildEllipseString(const String& radiusX, const String& radiusY, c onst String& centerX, const String& centerY, const String& box) |
146 { | 210 { |
147 return "ellipse(" + x + ", " + y + ", " + radiusX + ", " + radiusY + ')'; | 211 char opening[] = "ellipse("; |
212 char at[] = "at"; | |
213 char separator[] = " "; | |
214 StringBuilder result; | |
215 result.appendLiteral(opening); | |
216 bool needsSeparator = false; | |
217 if (!radiusX.isNull()) { | |
218 result.append(radiusX); | |
219 needsSeparator = true; | |
220 } | |
221 if (!radiusY.isNull()) { | |
222 if (needsSeparator) | |
223 result.appendLiteral(separator); | |
224 result.append(radiusY); | |
225 needsSeparator = true; | |
226 } | |
227 | |
228 if (!centerX.isNull() || !centerY.isNull()) { | |
229 if (needsSeparator) | |
230 result.appendLiteral(separator); | |
231 result.appendLiteral(at); | |
232 result.appendLiteral(separator); | |
233 result.append(centerX); | |
234 result.appendLiteral(separator); | |
235 result.append(centerY); | |
236 } | |
237 result.append(")"); | |
238 if (box.length()) { | |
239 result.appendLiteral(separator); | |
240 result.append(box); | |
241 } | |
242 return result.toString(); | |
148 } | 243 } |
149 | 244 |
150 String CSSBasicShapeEllipse::cssText() const | 245 String CSSBasicShapeEllipse::cssText() const |
151 { | 246 { |
152 return buildEllipseString(m_centerX->cssText(), m_centerY->cssText(), m_radi usX->cssText(), m_radiusY->cssText()); | 247 return buildEllipseString(m_radiusX ? m_radiusX->cssText() : String(), |
248 m_radiusY ? m_radiusY->cssText() : String(), | |
249 m_centerX ? m_centerX->cssText() : String(), | |
250 m_centerY ? m_centerY->cssText() : String(), | |
251 m_box ? m_box->cssText() : String()); | |
153 } | 252 } |
154 | 253 |
155 bool CSSBasicShapeEllipse::equals(const CSSBasicShape& shape) const | 254 bool CSSBasicShapeEllipse::equals(const CSSBasicShape& shape) const |
156 { | 255 { |
157 if (shape.type() != CSSBasicShapeEllipseType) | 256 if (shape.type() != CSSBasicShapeEllipseType) |
158 return false; | 257 return false; |
159 | 258 |
160 const CSSBasicShapeEllipse& other = static_cast<const CSSBasicShapeEllipse&> (shape); | 259 const CSSBasicShapeEllipse& other = static_cast<const CSSBasicShapeEllipse&> (shape); |
161 return compareCSSValuePtr(m_centerX, other.m_centerX) | 260 return compareCSSValuePtr(m_centerX, other.m_centerX) |
162 && compareCSSValuePtr(m_centerY, other.m_centerY) | 261 && compareCSSValuePtr(m_centerY, other.m_centerY) |
163 && compareCSSValuePtr(m_radiusX, other.m_radiusX) | 262 && compareCSSValuePtr(m_radiusX, other.m_radiusX) |
263 && compareCSSValuePtr(m_radiusY, other.m_radiusY) | |
264 && compareCSSValuePtr(m_box, other.m_box); | |
265 } | |
266 | |
267 String CSSBasicShapeEllipse::serializeResolvingVariables(const HashMap<AtomicStr ing, String>& variables) const | |
268 { | |
269 return buildEllipseString(m_radiusX.get() ? m_radiusX->serializeResolvingVar iables(variables) : String(), | |
270 m_radiusY.get() ? m_radiusY->serializeResolvingVariables(variables) : St ring(), | |
271 m_centerX.get() ? m_centerX->serializeResolvingVariables(variables) : St ring(), | |
272 m_centerY.get() ? m_centerY->serializeResolvingVariables(variables) : St ring(), | |
273 m_box.get() ? m_box->serializeResolvingVariables(variables) : String()); | |
274 } | |
275 | |
276 bool CSSBasicShapeEllipse::hasVariableReference() const | |
277 { | |
278 return (m_centerX && m_centerX->hasVariableReference()) | |
279 || (m_centerY && m_centerY->hasVariableReference()) | |
280 || (m_radiusX && m_radiusX->hasVariableReference()) | |
281 || (m_radiusY && m_radiusY->hasVariableReference()); | |
282 } | |
283 | |
284 static String buildDeprecatedEllipseString(const String& x, const String& y, con st String& radiusX, const String& radiusY) | |
285 { | |
286 return "ellipse(" + x + ", " + y + ", " + radiusX + ", " + radiusY + ')'; | |
287 } | |
288 | |
289 String CSSDeprecatedBasicShapeEllipse::cssText() const | |
290 { | |
291 return buildDeprecatedEllipseString(m_centerX->cssText(), m_centerY->cssText (), m_radiusX->cssText(), m_radiusY->cssText()); | |
292 } | |
293 | |
294 bool CSSDeprecatedBasicShapeEllipse::equals(const CSSBasicShape& shape) const | |
295 { | |
296 if (shape.type() != CSSDeprecatedBasicShapeEllipseType) | |
297 return false; | |
298 | |
299 const CSSDeprecatedBasicShapeEllipse& other = static_cast<const CSSDeprecate dBasicShapeEllipse&>(shape); | |
300 return compareCSSValuePtr(m_centerX, other.m_centerX) | |
301 && compareCSSValuePtr(m_centerY, other.m_centerY) | |
302 && compareCSSValuePtr(m_radiusX, other.m_radiusX) | |
164 && compareCSSValuePtr(m_radiusY, other.m_radiusY); | 303 && compareCSSValuePtr(m_radiusY, other.m_radiusY); |
165 } | 304 } |
166 | 305 |
167 String CSSBasicShapeEllipse::serializeResolvingVariables(const HashMap<AtomicStr ing, String>& variables) const | 306 String CSSDeprecatedBasicShapeEllipse::serializeResolvingVariables(const HashMap <AtomicString, String>& variables) const |
168 { | 307 { |
169 return buildEllipseString(m_centerX->serializeResolvingVariables(variables), | 308 return buildDeprecatedEllipseString(m_centerX->serializeResolvingVariables(v ariables), |
170 m_centerY->serializeResolvingVariables(variables), | 309 m_centerY->serializeResolvingVariables(variables), |
171 m_radiusX->serializeResolvingVariables(variables), | 310 m_radiusX->serializeResolvingVariables(variables), |
172 m_radiusY->serializeResolvingVariables(variables)); | 311 m_radiusY->serializeResolvingVariables(variables)); |
173 } | 312 } |
174 | 313 |
175 bool CSSBasicShapeEllipse::hasVariableReference() const | 314 bool CSSDeprecatedBasicShapeEllipse::hasVariableReference() const |
176 { | 315 { |
177 return m_centerX->hasVariableReference() | 316 return m_centerX->hasVariableReference() |
178 || m_centerY->hasVariableReference() | 317 || m_centerY->hasVariableReference() |
179 || m_radiusX->hasVariableReference() | 318 || m_radiusX->hasVariableReference() |
180 || m_radiusY->hasVariableReference(); | 319 || m_radiusY->hasVariableReference(); |
181 } | 320 } |
182 | 321 |
183 static String buildPolygonString(const WindRule& windRule, const Vector<String>& points) | 322 static String buildPolygonString(const WindRule& windRule, const Vector<String>& points) |
184 { | 323 { |
185 ASSERT(!(points.size() % 2)); | 324 ASSERT(!(points.size() % 2)); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 return m_top->hasVariableReference() | 463 return m_top->hasVariableReference() |
325 || m_right->hasVariableReference() | 464 || m_right->hasVariableReference() |
326 || m_bottom->hasVariableReference() | 465 || m_bottom->hasVariableReference() |
327 || m_left->hasVariableReference() | 466 || m_left->hasVariableReference() |
328 || (m_radiusX.get() && m_radiusX->hasVariableReference()) | 467 || (m_radiusX.get() && m_radiusX->hasVariableReference()) |
329 || (m_radiusY.get() && m_radiusY->hasVariableReference()); | 468 || (m_radiusY.get() && m_radiusY->hasVariableReference()); |
330 } | 469 } |
331 | 470 |
332 } // namespace WebCore | 471 } // namespace WebCore |
333 | 472 |
OLD | NEW |