Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / core / animation / AnimationInputHelpers.cpp
blob22687ac7a71bcc065a6f17eef7ddbc25d58b7a55
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.
5 #include "config.h"
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"
13 namespace blink {
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]))
25 builder.append('-');
26 builder.append(propertyName[i]);
28 return cssPropertyID(builder.toString());
31 PassRefPtr<TimingFunction> AnimationInputHelpers::parseTimingFunction(const String& string)
33 if (string.isEmpty())
34 return nullptr;
36 RefPtrWillBeRawPtr<CSSValue> value = CSSParser::parseSingleValue(CSSPropertyTransitionTimingFunction, string);
37 if (!value || !value->isValueList()) {
38 ASSERT(!value || value->isCSSWideKeyword());
39 return nullptr;
41 CSSValueList* valueList = toCSSValueList(value.get());
42 if (valueList->length() > 1)
43 return nullptr;
44 return CSSToStyleMap::mapAnimationTimingFunction(valueList->item(0), true);
47 } // namespace blink