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

Side by Side Diff: Source/core/css/parser/BisonCSSParser-in.cpp

Issue 149363002: Web Animations API: Implement step-middle and steps(x, middle) timing functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove bool argument from parseAnimationTimingFunctionValue Created 6 years, 10 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/css/parser/BisonCSSParserTest.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 4306 matching lines...) Expand 10 before | Expand all | Expand 10 after
4317 if (!isComma(v)) 4317 if (!isComma(v))
4318 return false; 4318 return false;
4319 args->next(); 4319 args->next();
4320 return true; 4320 return true;
4321 } 4321 }
4322 4322
4323 PassRefPtr<CSSValue> BisonCSSParser::parseAnimationTimingFunction() 4323 PassRefPtr<CSSValue> BisonCSSParser::parseAnimationTimingFunction()
4324 { 4324 {
4325 CSSParserValue* value = m_valueList->current(); 4325 CSSParserValue* value = m_valueList->current();
4326 if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id == CSSValueEaseIn || value->id == CSSValueEaseOut 4326 if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id == CSSValueEaseIn || value->id == CSSValueEaseOut
4327 || value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || v alue->id == CSSValueStepEnd) 4327 || value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || v alue->id == CSSValueStepEnd
4328 || (value->id == CSSValueStepMiddle && RuntimeEnabledFeatures::webAnimat ionsAPIEnabled()))
4328 return cssValuePool().createIdentifierValue(value->id); 4329 return cssValuePool().createIdentifierValue(value->id);
4329 4330
4330 // We must be a function. 4331 // We must be a function.
4331 if (value->unit != CSSParserValue::Function) 4332 if (value->unit != CSSParserValue::Function)
4332 return 0; 4333 return 0;
4333 4334
4334 CSSParserValueList* args = value->function->args.get(); 4335 CSSParserValueList* args = value->function->args.get();
4335 4336
4336 if (equalIgnoringCase(value->function->name, "steps(")) { 4337 if (equalIgnoringCase(value->function->name, "steps(")) {
4337 // For steps, 1 or 2 params must be specified (comma-separated) 4338 // For steps, 1 or 2 params must be specified (comma-separated)
4338 if (!args || (args->size() != 1 && args->size() != 3)) 4339 if (!args || (args->size() != 1 && args->size() != 3))
4339 return 0; 4340 return 0;
4340 4341
4341 // There are two values. 4342 // There are two values.
4342 int numSteps; 4343 int numSteps;
4343 bool stepAtStart = false; 4344 StepsTimingFunction::StepAtPosition stepAtPosition = StepsTimingFunction ::StepAtEnd;
4344 4345
4345 CSSParserValue* v = args->current(); 4346 CSSParserValue* v = args->current();
4346 if (!validUnit(v, FInteger)) 4347 if (!validUnit(v, FInteger))
4347 return 0; 4348 return 0;
4348 numSteps = clampToInteger(v->fValue); 4349 numSteps = clampToInteger(v->fValue);
4349 if (numSteps < 1) 4350 if (numSteps < 1)
4350 return 0; 4351 return 0;
4351 v = args->next(); 4352 v = args->next();
4352 4353
4353 if (v) { 4354 if (v) {
4354 // There is a comma so we need to parse the second value 4355 // There is a comma so we need to parse the second value
4355 if (!isComma(v)) 4356 if (!isComma(v))
4356 return 0; 4357 return 0;
4357 v = args->next(); 4358 v = args->next();
4358 if (v->id != CSSValueStart && v->id != CSSValueEnd) 4359 switch (v->id) {
4360 case CSSValueMiddle:
4361 if (RuntimeEnabledFeatures::webAnimationsAPIEnabled())
4362 stepAtPosition = StepsTimingFunction::StepAtMiddle;
4363 else
4364 return 0;
alancutter (OOO until 2018) 2014/02/19 03:17:45 Avoiding else branches by returning earlier is pre
rjwright 2014/02/24 11:17:46 Done.
4365 break;
4366 case CSSValueStart:
4367 stepAtPosition = StepsTimingFunction::StepAtStart;
4368 break;
4369 case CSSValueEnd:
4370 stepAtPosition = StepsTimingFunction::StepAtEnd;
4371 break;
4372 default:
4359 return 0; 4373 return 0;
4360 stepAtStart = v->id == CSSValueStart; 4374 }
4361 } 4375 }
4362 4376
4363 return CSSStepsTimingFunctionValue::create(numSteps, stepAtStart); 4377 return CSSStepsTimingFunctionValue::create(numSteps, stepAtPosition);
4364 } 4378 }
4365 4379
4366 if (equalIgnoringCase(value->function->name, "cubic-bezier(")) { 4380 if (equalIgnoringCase(value->function->name, "cubic-bezier(")) {
4367 // For cubic bezier, 4 values must be specified. 4381 // For cubic bezier, 4 values must be specified.
4368 if (!args || args->size() != 7) 4382 if (!args || args->size() != 7)
4369 return 0; 4383 return 0;
4370 4384
4371 // There are two points specified. The x values must be between 0 and 1 but the y values can exceed this range. 4385 // There are two points specified. The x values must be between 0 and 1 but the y values can exceed this range.
4372 double x1, y1, x2, y2; 4386 double x1, y1, x2, y2;
4373 4387
(...skipping 5849 matching lines...) Expand 10 before | Expand all | Expand 10 after
10223 { 10237 {
10224 // The tokenizer checks for the construct of an+b. 10238 // The tokenizer checks for the construct of an+b.
10225 // However, since the {ident} rule precedes the {nth} rule, some of those 10239 // However, since the {ident} rule precedes the {nth} rule, some of those
10226 // tokens are identified as string literal. Furthermore we need to accept 10240 // tokens are identified as string literal. Furthermore we need to accept
10227 // "odd" and "even" which does not match to an+b. 10241 // "odd" and "even" which does not match to an+b.
10228 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 10242 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
10229 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 10243 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
10230 } 10244 }
10231 10245
10232 } 10246 }
OLDNEW
« no previous file with comments | « Source/core/css/parser/BisonCSSParser.h ('k') | Source/core/css/parser/BisonCSSParserTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698