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

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

Issue 2324963003: Store custom properties specified in element.animate() (Closed)
Patch Set: Rebased Created 4 years, 2 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 | « no previous file | third_party/WebKit/Source/core/animation/AnimationInputHelpersTest.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 // 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"
11 #include "core/css/parser/CSSVariableParser.h"
11 #include "core/css/resolver/CSSToStyleMap.h" 12 #include "core/css/resolver/CSSToStyleMap.h"
12 #include "core/frame/Deprecation.h" 13 #include "core/frame/Deprecation.h"
13 #include "core/svg/SVGElement.h" 14 #include "core/svg/SVGElement.h"
14 #include "core/svg/animation/SVGSMILElement.h" 15 #include "core/svg/animation/SVGSMILElement.h"
15 #include "wtf/text/StringBuilder.h" 16 #include "wtf/text/StringBuilder.h"
16 17
17 namespace blink { 18 namespace blink {
18 19
19 const char kSVGPrefix[] = "svg-"; 20 const char kSVGPrefix[] = "svg-";
20 const unsigned kSVGPrefixLength = sizeof(kSVGPrefix) - 1; 21 const unsigned kSVGPrefixLength = sizeof(kSVGPrefix) - 1;
21 22
22 static bool isSVGPrefixed(const String& property) 23 static bool isSVGPrefixed(const String& property)
23 { 24 {
24 return property.startsWith(kSVGPrefix); 25 return property.startsWith(kSVGPrefix);
25 } 26 }
26 27
27 static String removeSVGPrefix(const String& property) 28 static String removeSVGPrefix(const String& property)
28 { 29 {
29 DCHECK(isSVGPrefixed(property)); 30 DCHECK(isSVGPrefixed(property));
30 return property.substring(kSVGPrefixLength); 31 return property.substring(kSVGPrefixLength);
31 } 32 }
32 33
33 CSSPropertyID AnimationInputHelpers::keyframeAttributeToCSSProperty(const String & property, const Document& document) 34 CSSPropertyID AnimationInputHelpers::keyframeAttributeToCSSProperty(const String & property, const Document& document)
34 { 35 {
35 // TODO(crbug.com/644148): Allow custom properties that begin with "--". 36 if (CSSVariableParser::isValidVariableName(property))
37 return CSSPropertyVariable;
36 38
37 // Disallow prefixed properties. 39 // Disallow prefixed properties.
38 if (property[0] == '-' || isASCIIUpper(property[0])) 40 if (property[0] == '-')
41 return CSSPropertyInvalid;
42 if (isASCIIUpper(property[0]))
39 return CSSPropertyInvalid; 43 return CSSPropertyInvalid;
40 if (property == "cssFloat") 44 if (property == "cssFloat")
41 return CSSPropertyFloat; 45 return CSSPropertyFloat;
42 46
43 StringBuilder builder; 47 StringBuilder builder;
44 for (size_t i = 0; i < property.length(); ++i) { 48 for (size_t i = 0; i < property.length(); ++i) {
45 // Disallow hyphenated properties. 49 // Disallow hyphenated properties.
46 if (property[i] == '-') { 50 if (property[i] == '-') {
47 if (cssPropertyID(property) != CSSPropertyInvalid) 51 if (cssPropertyID(property) != CSSPropertyInvalid)
48 Deprecation::countDeprecation(document, UseCounter::WebAnimation HyphenatedProperty); 52 Deprecation::countDeprecation(document, UseCounter::WebAnimation HyphenatedProperty);
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 } 243 }
240 const CSSValueList* valueList = toCSSValueList(value); 244 const CSSValueList* valueList = toCSSValueList(value);
241 if (valueList->length() > 1) { 245 if (valueList->length() > 1) {
242 exceptionState.throwTypeError("Easing may not be set to a list of values "); 246 exceptionState.throwTypeError("Easing may not be set to a list of values ");
243 return nullptr; 247 return nullptr;
244 } 248 }
245 return CSSToStyleMap::mapAnimationTimingFunction(valueList->item(0), true); 249 return CSSToStyleMap::mapAnimationTimingFunction(valueList->item(0), true);
246 } 250 }
247 251
248 } // namespace blink 252 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/animation/AnimationInputHelpersTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698