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
3 // found in the LICENSE file.
6 #include "core/animation/AnimationInputHelpers.h"
8 #include "core/css/CSSValueList.h"
9 #include "core/css/parser/CSSParser.h"
10 #include "core/css/resolver/CSSToStyleMap.h"
11 #include "wtf/text/StringBuilder.h"
15 CSSPropertyID
AnimationInputHelpers::keyframeAttributeToCSSPropertyID(const String
& propertyName
)
17 // Disallow prefixed properties.
18 if (propertyName
[0] == '-' || isASCIIUpper(propertyName
[0]))
19 return CSSPropertyInvalid
;
20 if (propertyName
== "cssFloat")
21 return CSSPropertyFloat
;
22 StringBuilder builder
;
23 for (size_t i
= 0; i
< propertyName
.length(); ++i
) {
24 if (isASCIIUpper(propertyName
[i
]))
26 builder
.append(propertyName
[i
]);
28 return cssPropertyID(builder
.toString());
31 PassRefPtr
<TimingFunction
> AnimationInputHelpers::parseTimingFunction(const String
& string
)
36 RefPtrWillBeRawPtr
<CSSValue
> value
= CSSParser::parseSingleValue(CSSPropertyTransitionTimingFunction
, string
);
37 if (!value
|| !value
->isValueList()) {
38 ASSERT(!value
|| value
->isCSSWideKeyword());
41 CSSValueList
* valueList
= toCSSValueList(value
.get());
42 if (valueList
->length() > 1)
44 return CSSToStyleMap::mapAnimationTimingFunction(valueList
->item(0), true);