Chromium Code Reviews| Index: Source/core/css/CSSParser-in.cpp |
| diff --git a/Source/core/css/CSSParser-in.cpp b/Source/core/css/CSSParser-in.cpp |
| index 132b74d87b4636fc05205c29bf99b1fae646f71b..ab99d4dd3225e69ae9abf6c904274970323c9ec3 100755 |
| --- a/Source/core/css/CSSParser-in.cpp |
| +++ b/Source/core/css/CSSParser-in.cpp |
| @@ -5157,15 +5157,73 @@ PassRefPtr<CSSBasicShape> CSSParser::parseBasicShapeInsetRectangle(CSSParserValu |
| return shape; |
| } |
| +PassRefPtr<CSSPrimitiveValue> CSSParser::parseShapeRadius(CSSParserValue* value) |
| +{ |
| + if (value->id == CSSValueClosestSide && value->id == CSSValueFarthestSide) |
|
Bem Jones-Bey (adobe)
2013/12/18 21:57:57
This should be ||, not &&.
|
| + return cssValuePool().createIdentifierValue(value->id); |
| + |
| + if (!validUnit(value, FLength | FPercent | FNonNeg)) |
| + return 0; |
| + |
| + return createPrimitiveNumericValue(value); |
| +} |
| + |
| PassRefPtr<CSSBasicShape> CSSParser::parseBasicShapeCircle(CSSParserValueList* args) |
| { |
| ASSERT(args); |
| + // circle(radius) |
| + // circle(radius at <position> |
| + // circle(at <position>) |
| + // where position defines centerX and centerY using a CSS <position> data type. |
| + RefPtr<CSSBasicShapeCircle> shape = CSSBasicShapeCircle::create(); |
| + |
| + for (CSSParserValue* argument = args->current(); argument; argument = args->next()) { |
| + // The call to parseFillPosition below should consume all of the |
| + // arguments except the first two. Thus, and index greater than one |
| + // indicates an invalid production. |
| + if (args->currentIndex() > 1) |
| + return 0; |
| + |
| + if (!args->currentIndex() && argument->id != CSSValueAt) { |
| + if (RefPtr<CSSPrimitiveValue> radius = parseShapeRadius(argument)) { |
| + shape->setRadius(radius); |
| + continue; |
| + } |
| + |
| + return 0; |
| + } |
| + |
| + if (argument->id == CSSValueAt) { |
| + RefPtr<CSSValue> centerX; |
| + RefPtr<CSSValue> centerY; |
| + args->next(); // set list to start of position center |
| + parseFillPosition(args, centerX, centerY); |
| + if (centerX && centerY) { |
| + ASSERT(centerX->isPrimitiveValue()); |
| + ASSERT(centerY->isPrimitiveValue()); |
| + shape->setCenterX(toCSSPrimitiveValue(centerX.get())); |
| + shape->setCenterY(toCSSPrimitiveValue(centerY.get())); |
| + } else { |
| + return 0; |
| + } |
| + } else { |
| + return 0; |
| + } |
| + } |
| + |
| + return shape; |
| +} |
| + |
| +PassRefPtr<CSSBasicShape> CSSParser::parseDeprecatedBasicShapeCircle(CSSParserValueList* args) |
| +{ |
| + ASSERT(args); |
| + |
| // circle(centerX, centerY, radius) |
| if (args->size() != 5) |
| return 0; |
| - RefPtr<CSSBasicShapeCircle> shape = CSSBasicShapeCircle::create(); |
| + RefPtr<CSSDeprecatedBasicShapeCircle> shape = CSSDeprecatedBasicShapeCircle::create(); |
| unsigned argumentNumber = 0; |
| CSSParserValue* argument = args->current(); |
| @@ -5324,6 +5382,20 @@ static bool isBoxValue(CSSValueID valueId) |
| return false; |
| } |
| +// FIXME This function is temporary to allow for an orderly transition between |
| +// the new CSS Shapes circle and ellipse syntax. It will be removed when the |
| +// old syntax is removed. |
| +static bool isDeprecatedBasicShape(CSSParserValueList* args) |
| +{ |
| + for (unsigned i = args->currentIndex(); i < args->size(); ++i) { |
| + CSSParserValue* value = args->valueAt(i); |
| + if (isComma(value)) |
| + return true; |
| + } |
| + |
| + return false; |
| +} |
| + |
| PassRefPtr<CSSValue> CSSParser::parseShapeProperty(CSSPropertyID propId) |
| { |
| if (!RuntimeEnabledFeatures::cssShapesEnabled()) |
| @@ -5396,7 +5468,10 @@ PassRefPtr<CSSPrimitiveValue> CSSParser::parseBasicShape() |
| if (equalIgnoringCase(value->function->name, "rectangle(")) |
| shape = parseBasicShapeRectangle(args); |
| else if (equalIgnoringCase(value->function->name, "circle(")) |
| - shape = parseBasicShapeCircle(args); |
| + if (isDeprecatedBasicShape(args)) |
| + shape = parseDeprecatedBasicShapeCircle(args); |
| + else |
| + shape = parseBasicShapeCircle(args); |
| else if (equalIgnoringCase(value->function->name, "ellipse(")) |
| shape = parseBasicShapeEllipse(args); |
| else if (equalIgnoringCase(value->function->name, "polygon(")) |