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

Side by Side Diff: third_party/WebKit/Source/core/animation/AnimationInputHelpers.cpp

Issue 2129783003: Remove linear-function easing TypeError exemption. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/animation/AnimationInputHelpers.h" 5 #include "core/animation/AnimationInputHelpers.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "core/SVGNames.h" 8 #include "core/SVGNames.h"
9 #include "core/css/CSSValueList.h" 9 #include "core/css/CSSValueList.h"
10 #include "core/css/parser/CSSParser.h" 10 #include "core/css/parser/CSSParser.h"
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 PassRefPtr<TimingFunction> AnimationInputHelpers::parseTimingFunction(const Stri ng& string, Document* document, ExceptionState& exceptionState) 206 PassRefPtr<TimingFunction> AnimationInputHelpers::parseTimingFunction(const Stri ng& string, Document* document, ExceptionState& exceptionState)
207 { 207 {
208 if (string.isEmpty()) { 208 if (string.isEmpty()) {
209 exceptionState.throwTypeError("Easing may not be the empty string"); 209 exceptionState.throwTypeError("Easing may not be the empty string");
210 return nullptr; 210 return nullptr;
211 } 211 }
212 212
213 const CSSValue* value = CSSParser::parseSingleValue(CSSPropertyTransitionTim ingFunction, string); 213 const CSSValue* value = CSSParser::parseSingleValue(CSSPropertyTransitionTim ingFunction, string);
214 if (!value || !value->isValueList()) { 214 if (!value || !value->isValueList()) {
215 DCHECK(!value || value->isCSSWideKeyword()); 215 DCHECK(!value || value->isCSSWideKeyword());
216 bool throwTypeError = true;
217 if (document) { 216 if (document) {
218 if (string.startsWith("function")) { 217 if (string.startsWith("function")) {
219 // Due to a bug in old versions of the web-animations-next 218 // Due to a bug in old versions of the web-animations-next
220 // polyfill, in some circumstances the string passed in here 219 // polyfill, in some circumstances the string passed in here
221 // may be a Javascript function instead of the allowed values 220 // may be a Javascript function instead of the allowed values
222 // from the spec 221 // from the spec
223 // (http://w3c.github.io/web-animations/#dom-animationeffecttimi ngreadonly-easing) 222 // (http://w3c.github.io/web-animations/#dom-animationeffecttimi ngreadonly-easing)
224 // This bug was fixed in 223 // This bug was fixed in
225 // https://github.com/web-animations/web-animations-next/pull/42 3 224 // https://github.com/web-animations/web-animations-next/pull/42 3
226 // and we want to track how often it is still being hit. The 225 // and we want to track how often it is still being hit. The
227 // linear case is special because 'linear' is the default value 226 // linear case is special because 'linear' is the default value
228 // for easing. See http://crbug.com/601672 227 // for easing. See http://crbug.com/601672
229 if (string == "function (a){return a}") { 228 if (string == "function (a){return a}") {
230 Deprecation::countDeprecation(*document, UseCounter::WebAnim ationsEasingAsFunctionLinear); 229 UseCounter::count(*document, UseCounter::WebAnimationsEasing AsFunctionLinear);
231 throwTypeError = false;
232 } else { 230 } else {
233 UseCounter::count(*document, UseCounter::WebAnimationsEasing AsFunctionOther); 231 UseCounter::count(*document, UseCounter::WebAnimationsEasing AsFunctionOther);
234 } 232 }
235 } 233 }
236 } 234 }
237
238 // TODO(suzyh): This return clause exists so that the special linear
239 // function case above is exempted from causing TypeErrors. The
240 // throwTypeError bool and this if-statement should be removed after the
241 // M53 branch point in July 2016, so that this case will also throw
242 // TypeErrors from M54 onward.
243 if (!throwTypeError) {
244 return Timing::defaults().timingFunction;
245 }
246
247 exceptionState.throwTypeError("'" + string + "' is not a valid value for easing"); 235 exceptionState.throwTypeError("'" + string + "' is not a valid value for easing");
248 return nullptr; 236 return nullptr;
249 } 237 }
250 const CSSValueList* valueList = toCSSValueList(value); 238 const CSSValueList* valueList = toCSSValueList(value);
251 if (valueList->length() > 1) { 239 if (valueList->length() > 1) {
252 exceptionState.throwTypeError("Easing may not be set to a list of values "); 240 exceptionState.throwTypeError("Easing may not be set to a list of values ");
253 return nullptr; 241 return nullptr;
254 } 242 }
255 return CSSToStyleMap::mapAnimationTimingFunction(valueList->item(0), true); 243 return CSSToStyleMap::mapAnimationTimingFunction(valueList->item(0), true);
256 } 244 }
257 245
258 } // namespace blink 246 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698