OLD | NEW |
(Empty) | |
| 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 #include "config.h" |
| 6 #include "core/css/CSSValueIDHelper.h" |
| 7 |
| 8 #include "core/css/CSSParserValues.h" |
| 9 #include "core/css/HashTools.h" |
| 10 |
| 11 namespace WebCore { |
| 12 |
| 13 template <typename CharacterType> |
| 14 static CSSValueID cssValueKeywordID(const CharacterType* valueKeyword, unsigned
length) |
| 15 { |
| 16 char buffer[maxCSSValueKeywordLength + 1]; // 1 for null character |
| 17 |
| 18 for (unsigned i = 0; i != length; ++i) { |
| 19 CharacterType c = valueKeyword[i]; |
| 20 if (!c || c >= 0x7F) |
| 21 return CSSValueInvalid; // illegal character |
| 22 buffer[i] = WTF::toASCIILower(c); |
| 23 } |
| 24 buffer[length] = '\0'; |
| 25 |
| 26 const Value* hashTableEntry = findValue(buffer, length); |
| 27 return hashTableEntry ? static_cast<CSSValueID>(hashTableEntry->id) : CSSVal
ueInvalid; |
| 28 } |
| 29 |
| 30 CSSValueID cssValueKeywordID(const CSSParserString& string) |
| 31 { |
| 32 unsigned length = string.length(); |
| 33 if (!length) |
| 34 return CSSValueInvalid; |
| 35 if (length > maxCSSValueKeywordLength) |
| 36 return CSSValueInvalid; |
| 37 |
| 38 return string.is8Bit() ? cssValueKeywordID(string.characters8(), length) : c
ssValueKeywordID(string.characters16(), length); |
| 39 } |
| 40 |
| 41 } |
OLD | NEW |