OLD | NEW |
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 5139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5150 argument = args->next(); | 5150 argument = args->next(); |
5151 } | 5151 } |
5152 argumentNumber++; | 5152 argumentNumber++; |
5153 } | 5153 } |
5154 | 5154 |
5155 if (argumentNumber < 4) | 5155 if (argumentNumber < 4) |
5156 return 0; | 5156 return 0; |
5157 return shape; | 5157 return shape; |
5158 } | 5158 } |
5159 | 5159 |
| 5160 PassRefPtr<CSSPrimitiveValue> CSSParser::parseShapeRadius(CSSParserValue* value) |
| 5161 { |
| 5162 if (value->id == CSSValueClosestSide || value->id == CSSValueFarthestSide) |
| 5163 return cssValuePool().createIdentifierValue(value->id); |
| 5164 |
| 5165 if (!validUnit(value, FLength | FPercent | FNonNeg)) |
| 5166 return 0; |
| 5167 |
| 5168 return createPrimitiveNumericValue(value); |
| 5169 } |
| 5170 |
5160 PassRefPtr<CSSBasicShape> CSSParser::parseBasicShapeCircle(CSSParserValueList* a
rgs) | 5171 PassRefPtr<CSSBasicShape> CSSParser::parseBasicShapeCircle(CSSParserValueList* a
rgs) |
5161 { | 5172 { |
5162 ASSERT(args); | 5173 ASSERT(args); |
5163 | 5174 |
| 5175 // circle(radius) |
| 5176 // circle(radius at <position> |
| 5177 // circle(at <position>) |
| 5178 // where position defines centerX and centerY using a CSS <position> data ty
pe. |
| 5179 RefPtr<CSSBasicShapeCircle> shape = CSSBasicShapeCircle::create(); |
| 5180 |
| 5181 for (CSSParserValue* argument = args->current(); argument; argument = args->
next()) { |
| 5182 // The call to parseFillPosition below should consume all of the |
| 5183 // arguments except the first two. Thus, and index greater than one |
| 5184 // indicates an invalid production. |
| 5185 if (args->currentIndex() > 1) |
| 5186 return 0; |
| 5187 |
| 5188 if (!args->currentIndex() && argument->id != CSSValueAt) { |
| 5189 if (RefPtr<CSSPrimitiveValue> radius = parseShapeRadius(argument)) { |
| 5190 shape->setRadius(radius); |
| 5191 continue; |
| 5192 } |
| 5193 |
| 5194 return 0; |
| 5195 } |
| 5196 |
| 5197 if (argument->id == CSSValueAt) { |
| 5198 RefPtr<CSSValue> centerX; |
| 5199 RefPtr<CSSValue> centerY; |
| 5200 args->next(); // set list to start of position center |
| 5201 parseFillPosition(args, centerX, centerY); |
| 5202 if (centerX && centerY) { |
| 5203 ASSERT(centerX->isPrimitiveValue()); |
| 5204 ASSERT(centerY->isPrimitiveValue()); |
| 5205 shape->setCenterX(toCSSPrimitiveValue(centerX.get())); |
| 5206 shape->setCenterY(toCSSPrimitiveValue(centerY.get())); |
| 5207 } else { |
| 5208 return 0; |
| 5209 } |
| 5210 } else { |
| 5211 return 0; |
| 5212 } |
| 5213 } |
| 5214 |
| 5215 return shape; |
| 5216 } |
| 5217 |
| 5218 PassRefPtr<CSSBasicShape> CSSParser::parseDeprecatedBasicShapeCircle(CSSParserVa
lueList* args) |
| 5219 { |
| 5220 ASSERT(args); |
| 5221 |
5164 // circle(centerX, centerY, radius) | 5222 // circle(centerX, centerY, radius) |
5165 if (args->size() != 5) | 5223 if (args->size() != 5) |
5166 return 0; | 5224 return 0; |
5167 | 5225 |
5168 RefPtr<CSSBasicShapeCircle> shape = CSSBasicShapeCircle::create(); | 5226 RefPtr<CSSDeprecatedBasicShapeCircle> shape = CSSDeprecatedBasicShapeCircle:
:create(); |
5169 | 5227 |
5170 unsigned argumentNumber = 0; | 5228 unsigned argumentNumber = 0; |
5171 CSSParserValue* argument = args->current(); | 5229 CSSParserValue* argument = args->current(); |
5172 while (argument) { | 5230 while (argument) { |
5173 Units unitFlags = FLength | FPercent; | 5231 Units unitFlags = FLength | FPercent; |
5174 if (argumentNumber == 2) { | 5232 if (argumentNumber == 2) { |
5175 // Argument radius cannot be negative. | 5233 // Argument radius cannot be negative. |
5176 unitFlags = unitFlags | FNonNeg; | 5234 unitFlags = unitFlags | FNonNeg; |
5177 } | 5235 } |
5178 | 5236 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5317 case CSSValueBorderBox: | 5375 case CSSValueBorderBox: |
5318 case CSSValueMarginBox: | 5376 case CSSValueMarginBox: |
5319 return true; | 5377 return true; |
5320 default: | 5378 default: |
5321 break; | 5379 break; |
5322 } | 5380 } |
5323 | 5381 |
5324 return false; | 5382 return false; |
5325 } | 5383 } |
5326 | 5384 |
| 5385 // FIXME This function is temporary to allow for an orderly transition between |
| 5386 // the new CSS Shapes circle and ellipse syntax. It will be removed when the |
| 5387 // old syntax is removed. |
| 5388 static bool isDeprecatedBasicShape(CSSParserValueList* args) |
| 5389 { |
| 5390 for (unsigned i = args->currentIndex(); i < args->size(); ++i) { |
| 5391 CSSParserValue* value = args->valueAt(i); |
| 5392 if (isComma(value)) |
| 5393 return true; |
| 5394 } |
| 5395 |
| 5396 return false; |
| 5397 } |
| 5398 |
5327 PassRefPtr<CSSValue> CSSParser::parseShapeProperty(CSSPropertyID propId) | 5399 PassRefPtr<CSSValue> CSSParser::parseShapeProperty(CSSPropertyID propId) |
5328 { | 5400 { |
5329 if (!RuntimeEnabledFeatures::cssShapesEnabled()) | 5401 if (!RuntimeEnabledFeatures::cssShapesEnabled()) |
5330 return 0; | 5402 return 0; |
5331 | 5403 |
5332 CSSParserValue* value = m_valueList->current(); | 5404 CSSParserValue* value = m_valueList->current(); |
5333 CSSValueID valueId = value->id; | 5405 CSSValueID valueId = value->id; |
5334 RefPtr<CSSPrimitiveValue> boxValue; | 5406 RefPtr<CSSPrimitiveValue> boxValue; |
5335 RefPtr<CSSPrimitiveValue> shapeValue; | 5407 RefPtr<CSSPrimitiveValue> shapeValue; |
5336 | 5408 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5389 ASSERT(value->unit == CSSParserValue::Function); | 5461 ASSERT(value->unit == CSSParserValue::Function); |
5390 CSSParserValueList* args = value->function->args.get(); | 5462 CSSParserValueList* args = value->function->args.get(); |
5391 | 5463 |
5392 if (!args) | 5464 if (!args) |
5393 return 0; | 5465 return 0; |
5394 | 5466 |
5395 RefPtr<CSSBasicShape> shape; | 5467 RefPtr<CSSBasicShape> shape; |
5396 if (equalIgnoringCase(value->function->name, "rectangle(")) | 5468 if (equalIgnoringCase(value->function->name, "rectangle(")) |
5397 shape = parseBasicShapeRectangle(args); | 5469 shape = parseBasicShapeRectangle(args); |
5398 else if (equalIgnoringCase(value->function->name, "circle(")) | 5470 else if (equalIgnoringCase(value->function->name, "circle(")) |
5399 shape = parseBasicShapeCircle(args); | 5471 if (isDeprecatedBasicShape(args)) |
| 5472 shape = parseDeprecatedBasicShapeCircle(args); |
| 5473 else |
| 5474 shape = parseBasicShapeCircle(args); |
5400 else if (equalIgnoringCase(value->function->name, "ellipse(")) | 5475 else if (equalIgnoringCase(value->function->name, "ellipse(")) |
5401 shape = parseBasicShapeEllipse(args); | 5476 shape = parseBasicShapeEllipse(args); |
5402 else if (equalIgnoringCase(value->function->name, "polygon(")) | 5477 else if (equalIgnoringCase(value->function->name, "polygon(")) |
5403 shape = parseBasicShapePolygon(args); | 5478 shape = parseBasicShapePolygon(args); |
5404 else if (equalIgnoringCase(value->function->name, "inset-rectangle(")) | 5479 else if (equalIgnoringCase(value->function->name, "inset-rectangle(")) |
5405 shape = parseBasicShapeInsetRectangle(args); | 5480 shape = parseBasicShapeInsetRectangle(args); |
5406 | 5481 |
5407 if (!shape) | 5482 if (!shape) |
5408 return 0; | 5483 return 0; |
5409 | 5484 |
(...skipping 5107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10517 { | 10592 { |
10518 // The tokenizer checks for the construct of an+b. | 10593 // The tokenizer checks for the construct of an+b. |
10519 // However, since the {ident} rule precedes the {nth} rule, some of those | 10594 // However, since the {ident} rule precedes the {nth} rule, some of those |
10520 // tokens are identified as string literal. Furthermore we need to accept | 10595 // tokens are identified as string literal. Furthermore we need to accept |
10521 // "odd" and "even" which does not match to an+b. | 10596 // "odd" and "even" which does not match to an+b. |
10522 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") | 10597 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") |
10523 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); | 10598 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); |
10524 } | 10599 } |
10525 | 10600 |
10526 } | 10601 } |
OLD | NEW |