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

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

Issue 1851003002: Throw TypeError if easing string is invalid. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 8 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 "core/SVGNames.h" 8 #include "core/SVGNames.h"
8 #include "core/css/CSSValueList.h" 9 #include "core/css/CSSValueList.h"
9 #include "core/css/parser/CSSParser.h" 10 #include "core/css/parser/CSSParser.h"
10 #include "core/css/resolver/CSSToStyleMap.h" 11 #include "core/css/resolver/CSSToStyleMap.h"
11 #include "core/frame/Deprecation.h" 12 #include "core/frame/Deprecation.h"
12 #include "core/svg/SVGElement.h" 13 #include "core/svg/SVGElement.h"
13 #include "core/svg/animation/SVGSMILElement.h" 14 #include "core/svg/animation/SVGSMILElement.h"
14 #include "wtf/text/StringBuilder.h" 15 #include "wtf/text/StringBuilder.h"
15 16
16 namespace blink { 17 namespace blink {
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 String unprefixedProperty = removeSVGPrefix(property); 195 String unprefixedProperty = removeSVGPrefix(property);
195 QualifiedName attributeName = svgAttributeName(unprefixedProperty); 196 QualifiedName attributeName = svgAttributeName(unprefixedProperty);
196 const AttributeNameMap& supportedAttributes = getSupportedAttributes(); 197 const AttributeNameMap& supportedAttributes = getSupportedAttributes();
197 auto iter = supportedAttributes.find(attributeName); 198 auto iter = supportedAttributes.find(attributeName);
198 if (iter == supportedAttributes.end() || !svgElement.propertyFromAttribute(* iter->value)) 199 if (iter == supportedAttributes.end() || !svgElement.propertyFromAttribute(* iter->value))
199 return nullptr; 200 return nullptr;
200 201
201 return iter->value; 202 return iter->value;
202 } 203 }
203 204
204 PassRefPtr<TimingFunction> AnimationInputHelpers::parseTimingFunction(const Stri ng& string) 205 PassRefPtr<TimingFunction> AnimationInputHelpers::parseTimingFunction(const Stri ng& string, ExceptionState& exceptionState)
205 { 206 {
206 if (string.isEmpty()) 207 if (string.isEmpty()) {
208 exceptionState.throwTypeError("Easing may not be the empty string");
207 return nullptr; 209 return nullptr;
210 }
208 211
209 CSSValue* value = CSSParser::parseSingleValue(CSSPropertyTransitionTimingFun ction, string); 212 CSSValue* value = CSSParser::parseSingleValue(CSSPropertyTransitionTimingFun ction, string);
210 if (!value || !value->isValueList()) { 213 if (!value || !value->isValueList()) {
211 ASSERT(!value || value->isCSSWideKeyword()); 214 ASSERT(!value || value->isCSSWideKeyword());
215 exceptionState.throwTypeError("'" + string + "' is not a valid value for easing");
212 return nullptr; 216 return nullptr;
213 } 217 }
214 CSSValueList* valueList = toCSSValueList(value); 218 CSSValueList* valueList = toCSSValueList(value);
215 if (valueList->length() > 1) 219 if (valueList->length() > 1) {
220 exceptionState.throwTypeError("Easing may not be set to a list of values ");
216 return nullptr; 221 return nullptr;
222 }
217 return CSSToStyleMap::mapAnimationTimingFunction(*valueList->item(0), true); 223 return CSSToStyleMap::mapAnimationTimingFunction(*valueList->item(0), true);
218 } 224 }
219 225
220 } // namespace blink 226 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698