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

Side by Side Diff: Source/core/css/CSSBasicShapes.cpp

Issue 103413006: Implement parsing of the new ellipse shape syntax. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase after CSSParser rename Created 6 years, 11 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/css/CSSBasicShapes.h ('k') | Source/core/css/parser/BisonCSSParser.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) 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 return buildCircleString(m_radius.get() ? m_radius->serializeResolvingVariab les(variables) : String(), 166 return buildCircleString(m_radius.get() ? m_radius->serializeResolvingVariab les(variables) : String(),
167 m_centerX.get() ? m_centerX->serializeResolvingVariables(variables) : St ring(), 167 m_centerX.get() ? m_centerX->serializeResolvingVariables(variables) : St ring(),
168 m_centerY.get() ? m_centerY->serializeResolvingVariables(variables) : St ring(), 168 m_centerY.get() ? m_centerY->serializeResolvingVariables(variables) : St ring(),
169 m_layoutBox.get() ? m_layoutBox->serializeResolvingVariables(variables) : String()); 169 m_layoutBox.get() ? m_layoutBox->serializeResolvingVariables(variables) : String());
170 } 170 }
171 171
172 bool CSSBasicShapeCircle::hasVariableReference() const 172 bool CSSBasicShapeCircle::hasVariableReference() const
173 { 173 {
174 return (m_centerX && m_centerX->hasVariableReference()) 174 return (m_centerX && m_centerX->hasVariableReference())
175 || (m_centerY && m_centerY->hasVariableReference()) 175 || (m_centerY && m_centerY->hasVariableReference())
176 || (m_radius && m_radius->hasVariableReference()); 176 || (m_radius && m_radius->hasVariableReference())
177 || (m_layoutBox && m_layoutBox->hasVariableReference());
177 } 178 }
178 179
179 static String buildDeprecatedCircleString(const String& x, const String& y, cons t String& radius) 180 static String buildDeprecatedCircleString(const String& x, const String& y, cons t String& radius)
180 { 181 {
181 return "circle(" + x + ", " + y + ", " + radius + ')'; 182 return "circle(" + x + ", " + y + ", " + radius + ')';
182 } 183 }
183 184
184 String CSSDeprecatedBasicShapeCircle::cssText() const 185 String CSSDeprecatedBasicShapeCircle::cssText() const
185 { 186 {
186 return buildDeprecatedCircleString(m_centerX->cssText(), m_centerY->cssText( ), m_radius->cssText()); 187 return buildDeprecatedCircleString(m_centerX->cssText(), m_centerY->cssText( ), m_radius->cssText());
(...skipping 18 matching lines...) Expand all
205 } 206 }
206 207
207 bool CSSDeprecatedBasicShapeCircle::hasVariableReference() const 208 bool CSSDeprecatedBasicShapeCircle::hasVariableReference() const
208 { 209 {
209 return m_centerX->hasVariableReference() 210 return m_centerX->hasVariableReference()
210 || m_centerY->hasVariableReference() 211 || m_centerY->hasVariableReference()
211 || m_radius->hasVariableReference() 212 || m_radius->hasVariableReference()
212 || (m_layoutBox && m_layoutBox->hasVariableReference()); 213 || (m_layoutBox && m_layoutBox->hasVariableReference());
213 } 214 }
214 215
215 static String buildEllipseString(const String& x, const String& y, const String& radiusX, const String& radiusY, const String& layoutBox) 216 static String buildEllipseString(const String& radiusX, const String& radiusY, c onst String& centerX, const String& centerY, const String& box)
216 { 217 {
218 char at[] = "at";
219 char separator[] = " ";
217 StringBuilder result; 220 StringBuilder result;
218 const char separator[] = ", ";
219 result.appendLiteral("ellipse("); 221 result.appendLiteral("ellipse(");
220 result.append(x); 222 bool needsSeparator = false;
221 result.appendLiteral(separator); 223 if (!radiusX.isNull()) {
222 result.append(y); 224 result.append(radiusX);
223 result.appendLiteral(separator); 225 needsSeparator = true;
224 result.append(radiusX);
225 result.appendLiteral(separator);
226 result.append(radiusY);
227 if (!layoutBox.isEmpty()) {
228 result.append(' ');
229 result.append(layoutBox);
230 } 226 }
231 result.append(')'); 227 if (!radiusY.isNull()) {
228 if (needsSeparator)
229 result.appendLiteral(separator);
230 result.append(radiusY);
231 needsSeparator = true;
232 }
233
234 if (!centerX.isNull() || !centerY.isNull()) {
235 if (needsSeparator)
236 result.appendLiteral(separator);
237 result.appendLiteral(at);
238 result.appendLiteral(separator);
239 result.append(centerX);
240 result.appendLiteral(separator);
241 result.append(centerY);
242 }
243 result.append(")");
244 if (box.length()) {
245 result.appendLiteral(separator);
246 result.append(box);
247 }
232 return result.toString(); 248 return result.toString();
233 } 249 }
234 250
235 String CSSBasicShapeEllipse::cssText() const 251 String CSSBasicShapeEllipse::cssText() const
236 { 252 {
237 return buildEllipseString(m_centerX->cssText(), 253 return buildEllipseString(m_radiusX ? m_radiusX->cssText() : String(),
238 m_centerY->cssText(), m_radiusX->cssText(), 254 m_radiusY ? m_radiusY->cssText() : String(),
239 m_radiusY->cssText(), 255 m_centerX ? m_centerX->cssText() : String(),
256 m_centerY ? m_centerY->cssText() : String(),
240 m_layoutBox ? m_layoutBox->cssText() : String()); 257 m_layoutBox ? m_layoutBox->cssText() : String());
241 } 258 }
242 259
243 bool CSSBasicShapeEllipse::equals(const CSSBasicShape& shape) const 260 bool CSSBasicShapeEllipse::equals(const CSSBasicShape& shape) const
244 { 261 {
245 if (shape.type() != CSSBasicShapeEllipseType) 262 if (shape.type() != CSSBasicShapeEllipseType)
246 return false; 263 return false;
247 264
248 const CSSBasicShapeEllipse& other = static_cast<const CSSBasicShapeEllipse&> (shape); 265 const CSSBasicShapeEllipse& other = static_cast<const CSSBasicShapeEllipse&> (shape);
249 return compareCSSValuePtr(m_centerX, other.m_centerX) 266 return compareCSSValuePtr(m_centerX, other.m_centerX)
250 && compareCSSValuePtr(m_centerY, other.m_centerY) 267 && compareCSSValuePtr(m_centerY, other.m_centerY)
251 && compareCSSValuePtr(m_radiusX, other.m_radiusX) 268 && compareCSSValuePtr(m_radiusX, other.m_radiusX)
252 && compareCSSValuePtr(m_radiusY, other.m_radiusY) 269 && compareCSSValuePtr(m_radiusY, other.m_radiusY)
253 && compareCSSValuePtr(m_layoutBox, other.m_layoutBox); 270 && compareCSSValuePtr(m_layoutBox, other.m_layoutBox);
254 } 271 }
255 272
256 String CSSBasicShapeEllipse::serializeResolvingVariables(const HashMap<AtomicStr ing, String>& variables) const 273 String CSSBasicShapeEllipse::serializeResolvingVariables(const HashMap<AtomicStr ing, String>& variables) const
257 { 274 {
258 return buildEllipseString(m_centerX->serializeResolvingVariables(variables), 275 return buildEllipseString(m_radiusX.get() ? m_radiusX->serializeResolvingVar iables(variables) : String(),
259 m_centerY->serializeResolvingVariables(variables), 276 m_radiusY.get() ? m_radiusY->serializeResolvingVariables(variables) : St ring(),
260 m_radiusX->serializeResolvingVariables(variables), 277 m_centerX.get() ? m_centerX->serializeResolvingVariables(variables) : St ring(),
261 m_radiusY->serializeResolvingVariables(variables), 278 m_centerY.get() ? m_centerY->serializeResolvingVariables(variables) : St ring(),
262 m_layoutBox ? m_layoutBox->serializeResolvingVariables(variables) : Stri ng()); 279 m_layoutBox.get() ? m_layoutBox->serializeResolvingVariables(variables) : String());
263 } 280 }
264 281
265 bool CSSBasicShapeEllipse::hasVariableReference() const 282 bool CSSBasicShapeEllipse::hasVariableReference() const
266 { 283 {
284 return (m_centerX && m_centerX->hasVariableReference())
285 || (m_centerY && m_centerY->hasVariableReference())
286 || (m_radiusX && m_radiusX->hasVariableReference())
287 || (m_radiusY && m_radiusY->hasVariableReference())
288 || (m_layoutBox && m_layoutBox->hasVariableReference());
289 }
290
291 static String buildDeprecatedEllipseString(const String& x, const String& y, con st String& radiusX, const String& radiusY)
292 {
293 return "ellipse(" + x + ", " + y + ", " + radiusX + ", " + radiusY + ')';
294 }
295
296 String CSSDeprecatedBasicShapeEllipse::cssText() const
297 {
298 return buildDeprecatedEllipseString(m_centerX->cssText(), m_centerY->cssText (), m_radiusX->cssText(), m_radiusY->cssText());
299 }
300
301 bool CSSDeprecatedBasicShapeEllipse::equals(const CSSBasicShape& shape) const
302 {
303 if (shape.type() != CSSDeprecatedBasicShapeEllipseType)
304 return false;
305
306 const CSSDeprecatedBasicShapeEllipse& other = static_cast<const CSSDeprecate dBasicShapeEllipse&>(shape);
307 return compareCSSValuePtr(m_centerX, other.m_centerX)
308 && compareCSSValuePtr(m_centerY, other.m_centerY)
309 && compareCSSValuePtr(m_radiusX, other.m_radiusX)
310 && compareCSSValuePtr(m_radiusY, other.m_radiusY);
311 }
312
313 String CSSDeprecatedBasicShapeEllipse::serializeResolvingVariables(const HashMap <AtomicString, String>& variables) const
314 {
315 return buildDeprecatedEllipseString(m_centerX->serializeResolvingVariables(v ariables),
316 m_centerY->serializeResolvingVariables(variables),
317 m_radiusX->serializeResolvingVariables(variables),
318 m_radiusY->serializeResolvingVariables(variables));
319 }
320
321 bool CSSDeprecatedBasicShapeEllipse::hasVariableReference() const
322 {
267 return m_centerX->hasVariableReference() 323 return m_centerX->hasVariableReference()
268 || m_centerY->hasVariableReference() 324 || m_centerY->hasVariableReference()
269 || m_radiusX->hasVariableReference() 325 || m_radiusX->hasVariableReference()
270 || m_radiusY->hasVariableReference() 326 || m_radiusY->hasVariableReference()
271 || (m_layoutBox && m_layoutBox->hasVariableReference()); 327 || (m_layoutBox && m_layoutBox->hasVariableReference());
272 } 328 }
273 329
274 static String buildPolygonString(const WindRule& windRule, const Vector<String>& points, const String& layoutBox) 330 static String buildPolygonString(const WindRule& windRule, const Vector<String>& points, const String& layoutBox)
275 { 331 {
276 ASSERT(!(points.size() % 2)); 332 ASSERT(!(points.size() % 2));
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 || m_right->hasVariableReference() 495 || m_right->hasVariableReference()
440 || m_bottom->hasVariableReference() 496 || m_bottom->hasVariableReference()
441 || m_left->hasVariableReference() 497 || m_left->hasVariableReference()
442 || (m_radiusX.get() && m_radiusX->hasVariableReference()) 498 || (m_radiusX.get() && m_radiusX->hasVariableReference())
443 || (m_radiusY.get() && m_radiusY->hasVariableReference()) 499 || (m_radiusY.get() && m_radiusY->hasVariableReference())
444 || (m_layoutBox && m_layoutBox->hasVariableReference()); 500 || (m_layoutBox && m_layoutBox->hasVariableReference());
445 } 501 }
446 502
447 } // namespace WebCore 503 } // namespace WebCore
448 504
OLDNEW
« no previous file with comments | « Source/core/css/CSSBasicShapes.h ('k') | Source/core/css/parser/BisonCSSParser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698