Chromium Code Reviews| Index: third_party/WebKit/Source/core/animation/AnimationInputHelpers.cpp |
| diff --git a/third_party/WebKit/Source/core/animation/AnimationInputHelpers.cpp b/third_party/WebKit/Source/core/animation/AnimationInputHelpers.cpp |
| index 21ad87c2d92a3d1c6933c3ad4e8f804440c820c2..6fe748e3f4c3f92d676e6fd23dbe6cdf33f9e44a 100644 |
| --- a/third_party/WebKit/Source/core/animation/AnimationInputHelpers.cpp |
| +++ b/third_party/WebKit/Source/core/animation/AnimationInputHelpers.cpp |
| @@ -4,6 +4,7 @@ |
| #include "core/animation/AnimationInputHelpers.h" |
| +#include "bindings/core/v8/ExceptionState.h" |
| #include "core/SVGNames.h" |
| #include "core/css/CSSValueList.h" |
| #include "core/css/parser/CSSParser.h" |
| @@ -202,14 +203,17 @@ const QualifiedName* AnimationInputHelpers::keyframeAttributeToSVGAttribute(cons |
| return iter->value; |
| } |
| -PassRefPtr<TimingFunction> AnimationInputHelpers::parseTimingFunction(const String& string, Document* document) |
| +PassRefPtr<TimingFunction> AnimationInputHelpers::parseTimingFunction(const String& string, Document* document, ExceptionState& exceptionState) |
| { |
| - if (string.isEmpty()) |
| + if (string.isEmpty()) { |
| + exceptionState.throwTypeError("Easing may not be the empty string"); |
| return nullptr; |
| + } |
| CSSValue* value = CSSParser::parseSingleValue(CSSPropertyTransitionTimingFunction, string); |
| if (!value || !value->isValueList()) { |
| ASSERT(!value || value->isCSSWideKeyword()); |
| + bool throwTypeError = true; |
| if (document) { |
| if (string.startsWith("function")) { |
| // Due to a bug in old versions of the web-animations-next |
| @@ -221,18 +225,32 @@ PassRefPtr<TimingFunction> AnimationInputHelpers::parseTimingFunction(const Stri |
| // https://github.com/web-animations/web-animations-next/pull/423 |
| // and we want to track how often it is still being hit. The |
| // linear case is special because 'linear' is the default value |
| - // for easing. |
| - if (string == "function (a){return a}") |
| - UseCounter::count(*document, UseCounter::WebAnimationsEasingAsFunctionLinear); |
| - else |
| + // for easing. See http://crbug.com/601672 |
| + if (string == "function (a){return a}") { |
| + Deprecation::countDeprecation(*document, UseCounter::WebAnimationsEasingAsFunctionLinear); |
| + throwTypeError = false; |
| + } else { |
| UseCounter::count(*document, UseCounter::WebAnimationsEasingAsFunctionOther); |
| + } |
| } |
| } |
| + if (throwTypeError) { |
| + // TODO(suzyh): This throwTypeError guard and default return value |
| + // exists so that the special linear function case above is exempted |
| + // from causing TypeErrors. The bool and guard should be removed |
| + // after the M53 branch point in July 2016, so that this case will |
| + // also throw TypeErrors from M54 onward. |
| + exceptionState.throwTypeError("'" + string + "' is not a valid value for easing"); |
| + } else { |
| + return Timing::defaults().timingFunction; |
| + } |
| return nullptr; |
|
alancutter (OOO until 2018)
2016/04/13 00:46:38
Nit: Blink style is to arrange this as:
if (throw
suzyh_UTC10 (ex-contributor)
2016/04/13 01:48:09
I was trying to keep the temporary code all togeth
|
| } |
| CSSValueList* valueList = toCSSValueList(value); |
| - if (valueList->length() > 1) |
| + if (valueList->length() > 1) { |
| + exceptionState.throwTypeError("Easing may not be set to a list of values"); |
| return nullptr; |
| + } |
| return CSSToStyleMap::mapAnimationTimingFunction(*valueList->item(0), true); |
| } |