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

Unified 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, 12 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/parser/BisonCSSParser-in.cpp
diff --git a/Source/core/css/parser/BisonCSSParser-in.cpp b/Source/core/css/parser/BisonCSSParser-in.cpp
index 242ca77496414ba6278903db53cd6baeba083fb4..4b4b3f39576463563009d2b12908e15063bd6ec4 100644
--- a/Source/core/css/parser/BisonCSSParser-in.cpp
+++ b/Source/core/css/parser/BisonCSSParser-in.cpp
@@ -5304,11 +5304,60 @@ PassRefPtr<CSSBasicShape> BisonCSSParser::parseBasicShapeEllipse(CSSParserValueL
{
ASSERT(args);
+ // ellipse(radiusX)
+ // ellipse(radiusX at <position>
+ // ellipse(radiusX radiusY)
+ // ellipse(radiusX radiusY at <position>
+ // ellipse(at <position>)
+ // where position defines centerX and centerY using a CSS <position> data type.
+ RefPtr<CSSBasicShapeEllipse> shape = CSSBasicShapeEllipse::create();
+
+ for (CSSParserValue* argument = args->current(); argument; argument = args->next()) {
+ // The call to parseFillPosition below should consume all of the
+ // arguments except the first three. Thus, an index greater than two
+ // indicates an invalid production.
+ if (args->currentIndex() > 2)
+ return 0;
+
+ if (args->currentIndex() < 2 && argument->id != CSSValueAt) {
+ if (RefPtr<CSSPrimitiveValue> radius = parseShapeRadius(argument)) {
+ if (!shape->radiusX())
+ shape->setRadiusX(radius);
+ else
+ shape->setRadiusY(radius);
+ continue;
+ }
+
+ return 0;
+ }
+
+ if (argument->id != CSSValueAt)
+ return 0;
+ RefPtr<CSSValue> centerX;
+ RefPtr<CSSValue> centerY;
+ args->next(); // set list to start of position center
+ parseFillPosition(args, centerX, centerY);
+ if (!centerX || !centerY)
+ return 0;
+
+ ASSERT(centerX->isPrimitiveValue());
+ ASSERT(centerY->isPrimitiveValue());
+ shape->setCenterX(toCSSPrimitiveValue(centerX.get()));
+ shape->setCenterY(toCSSPrimitiveValue(centerY.get()));
+ }
+
+ return shape;
+}
+
+PassRefPtr<CSSBasicShape> BisonCSSParser::parseDeprecatedBasicShapeEllipse(CSSParserValueList* args)
+{
+ ASSERT(args);
+
// ellipse(centerX, centerY, radiusX, radiusY)
if (args->size() != 7)
return 0;
- RefPtr<CSSBasicShapeEllipse> shape = CSSBasicShapeEllipse::create();
+ RefPtr<CSSDeprecatedBasicShapeEllipse> shape = CSSDeprecatedBasicShapeEllipse::create();
unsigned argumentNumber = 0;
CSSParserValue* argument = args->current();
while (argument) {
@@ -5508,7 +5557,10 @@ PassRefPtr<CSSPrimitiveValue> BisonCSSParser::parseBasicShape()
else
shape = parseBasicShapeCircle(args);
else if (equalIgnoringCase(value->function->name, "ellipse("))
- shape = parseBasicShapeEllipse(args);
+ if (isDeprecatedBasicShape(args))
+ shape = parseDeprecatedBasicShapeEllipse(args);
+ else
+ shape = parseBasicShapeEllipse(args);
else if (equalIgnoringCase(value->function->name, "polygon("))
shape = parseBasicShapePolygon(args);
else if (equalIgnoringCase(value->function->name, "inset-rectangle("))
« 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