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. 4 5 #ifndef AnimationHelpers_h 6 #define AnimationHelpers_h 7 8 #include "core/css/parser/BisonCSSParser.h" 9 #include "wtf/text/StringBuilder.h" 10 11 namespace WebCore { 12 13 static inline CSSPropertyID camelCaseCSSPropertyNameToID(const String& propertyName) 14 { 15 if (propertyName.find('-') != kNotFound) 16 return CSSPropertyInvalid; 17 18 StringBuilder builder; 19 size_t position = 0; 20 size_t end; 21 while ((end = propertyName.find(isASCIIUpper, position)) != kNotFound) { 22 builder.append(propertyName.substring(position, end - position) + "-" + toASCIILower((propertyName)[end])); 23 position = end + 1; 24 } 25 builder.append(propertyName.substring(position)); 26 // Doesn't handle prefixed properties. 27 CSSPropertyID id = cssPropertyID(builder.toString()); 28 return id; 29 } 30 31 } // namespace WebCore 32 33 #endif // AnimationHelpers_h 34