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

Side by Side Diff: Source/core/css/parser/BisonCSSParser-in.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/parser/BisonCSSParser.h ('k') | Source/core/rendering/shapes/Shape.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) 2003 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. 9 * Copyright (C) 2012 Intel Corporation. All rights reserved.
10 * 10 *
(...skipping 5286 matching lines...) Expand 10 before | Expand all | Expand 10 after
5297 5297
5298 if (argumentNumber < 3) 5298 if (argumentNumber < 3)
5299 return 0; 5299 return 0;
5300 return shape; 5300 return shape;
5301 } 5301 }
5302 5302
5303 PassRefPtr<CSSBasicShape> BisonCSSParser::parseBasicShapeEllipse(CSSParserValueL ist* args) 5303 PassRefPtr<CSSBasicShape> BisonCSSParser::parseBasicShapeEllipse(CSSParserValueL ist* args)
5304 { 5304 {
5305 ASSERT(args); 5305 ASSERT(args);
5306 5306
5307 // ellipse(radiusX)
5308 // ellipse(radiusX at <position>
5309 // ellipse(radiusX radiusY)
5310 // ellipse(radiusX radiusY at <position>
5311 // ellipse(at <position>)
5312 // where position defines centerX and centerY using a CSS <position> data ty pe.
5313 RefPtr<CSSBasicShapeEllipse> shape = CSSBasicShapeEllipse::create();
5314
5315 for (CSSParserValue* argument = args->current(); argument; argument = args-> next()) {
5316 // The call to parseFillPosition below should consume all of the
5317 // arguments except the first three. Thus, an index greater than two
5318 // indicates an invalid production.
5319 if (args->currentIndex() > 2)
5320 return 0;
5321
5322 if (args->currentIndex() < 2 && argument->id != CSSValueAt) {
5323 if (RefPtr<CSSPrimitiveValue> radius = parseShapeRadius(argument)) {
5324 if (!shape->radiusX())
5325 shape->setRadiusX(radius);
5326 else
5327 shape->setRadiusY(radius);
5328 continue;
5329 }
5330
5331 return 0;
5332 }
5333
5334 if (argument->id != CSSValueAt)
5335 return 0;
5336 RefPtr<CSSValue> centerX;
5337 RefPtr<CSSValue> centerY;
5338 args->next(); // set list to start of position center
5339 parseFillPosition(args, centerX, centerY);
5340 if (!centerX || !centerY)
5341 return 0;
5342
5343 ASSERT(centerX->isPrimitiveValue());
5344 ASSERT(centerY->isPrimitiveValue());
5345 shape->setCenterX(toCSSPrimitiveValue(centerX.get()));
5346 shape->setCenterY(toCSSPrimitiveValue(centerY.get()));
5347 }
5348
5349 return shape;
5350 }
5351
5352 PassRefPtr<CSSBasicShape> BisonCSSParser::parseDeprecatedBasicShapeEllipse(CSSPa rserValueList* args)
5353 {
5354 ASSERT(args);
5355
5307 // ellipse(centerX, centerY, radiusX, radiusY) 5356 // ellipse(centerX, centerY, radiusX, radiusY)
5308 if (args->size() != 7) 5357 if (args->size() != 7)
5309 return 0; 5358 return 0;
5310 5359
5311 RefPtr<CSSBasicShapeEllipse> shape = CSSBasicShapeEllipse::create(); 5360 RefPtr<CSSDeprecatedBasicShapeEllipse> shape = CSSDeprecatedBasicShapeEllips e::create();
5312 unsigned argumentNumber = 0; 5361 unsigned argumentNumber = 0;
5313 CSSParserValue* argument = args->current(); 5362 CSSParserValue* argument = args->current();
5314 while (argument) { 5363 while (argument) {
5315 Units unitFlags = FLength | FPercent; 5364 Units unitFlags = FLength | FPercent;
5316 if (argumentNumber > 1) { 5365 if (argumentNumber > 1) {
5317 // Arguments radiusX and radiusY cannot be negative. 5366 // Arguments radiusX and radiusY cannot be negative.
5318 unitFlags = unitFlags | FNonNeg; 5367 unitFlags = unitFlags | FNonNeg;
5319 } 5368 }
5320 if (!validUnit(argument, unitFlags)) 5369 if (!validUnit(argument, unitFlags))
5321 return 0; 5370 return 0;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
5501 5550
5502 RefPtr<CSSBasicShape> shape; 5551 RefPtr<CSSBasicShape> shape;
5503 if (equalIgnoringCase(value->function->name, "rectangle(")) 5552 if (equalIgnoringCase(value->function->name, "rectangle("))
5504 shape = parseBasicShapeRectangle(args); 5553 shape = parseBasicShapeRectangle(args);
5505 else if (equalIgnoringCase(value->function->name, "circle(")) 5554 else if (equalIgnoringCase(value->function->name, "circle("))
5506 if (isDeprecatedBasicShape(args)) 5555 if (isDeprecatedBasicShape(args))
5507 shape = parseDeprecatedBasicShapeCircle(args); 5556 shape = parseDeprecatedBasicShapeCircle(args);
5508 else 5557 else
5509 shape = parseBasicShapeCircle(args); 5558 shape = parseBasicShapeCircle(args);
5510 else if (equalIgnoringCase(value->function->name, "ellipse(")) 5559 else if (equalIgnoringCase(value->function->name, "ellipse("))
5511 shape = parseBasicShapeEllipse(args); 5560 if (isDeprecatedBasicShape(args))
5561 shape = parseDeprecatedBasicShapeEllipse(args);
5562 else
5563 shape = parseBasicShapeEllipse(args);
5512 else if (equalIgnoringCase(value->function->name, "polygon(")) 5564 else if (equalIgnoringCase(value->function->name, "polygon("))
5513 shape = parseBasicShapePolygon(args); 5565 shape = parseBasicShapePolygon(args);
5514 else if (equalIgnoringCase(value->function->name, "inset-rectangle(")) 5566 else if (equalIgnoringCase(value->function->name, "inset-rectangle("))
5515 shape = parseBasicShapeInsetRectangle(args); 5567 shape = parseBasicShapeInsetRectangle(args);
5516 5568
5517 if (!shape) 5569 if (!shape)
5518 return 0; 5570 return 0;
5519 5571
5520 m_valueList->next(); 5572 m_valueList->next();
5521 return cssValuePool().createValue(shape.release()); 5573 return cssValuePool().createValue(shape.release());
(...skipping 4950 matching lines...) Expand 10 before | Expand all | Expand 10 after
10472 { 10524 {
10473 // The tokenizer checks for the construct of an+b. 10525 // The tokenizer checks for the construct of an+b.
10474 // However, since the {ident} rule precedes the {nth} rule, some of those 10526 // However, since the {ident} rule precedes the {nth} rule, some of those
10475 // tokens are identified as string literal. Furthermore we need to accept 10527 // tokens are identified as string literal. Furthermore we need to accept
10476 // "odd" and "even" which does not match to an+b. 10528 // "odd" and "even" which does not match to an+b.
10477 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 10529 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
10478 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 10530 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
10479 } 10531 }
10480 10532
10481 } 10533 }
OLDNEW
« no previous file with comments | « Source/core/css/parser/BisonCSSParser.h ('k') | Source/core/rendering/shapes/Shape.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698