OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // | |
abarth-chromium
2014/03/01 07:28:25
ditto
| |
3 // Use of this source code is governed by a BSD-style license that can be | |
4 // found in the LICENSE file. | |
5 | |
6 #include "config.h" | |
7 #include "core/css/CSSValueIDHelper.h" | |
8 | |
9 #include "core/css/CSSParserValues.h" | |
10 #include "core/css/HashTools.h" | |
11 | |
12 namespace WebCore { | |
13 | |
14 template <typename CharacterType> | |
15 static CSSValueID cssValueKeywordID(const CharacterType* valueKeyword, unsigned length) | |
16 { | |
17 char buffer[maxCSSValueKeywordLength + 1]; // 1 for null character | |
18 | |
19 for (unsigned i = 0; i != length; ++i) { | |
20 CharacterType c = valueKeyword[i]; | |
21 if (!c || c >= 0x7F) | |
22 return CSSValueInvalid; // illegal character | |
23 buffer[i] = WTF::toASCIILower(c); | |
24 } | |
25 buffer[length] = '\0'; | |
26 | |
27 const Value* hashTableEntry = findValue(buffer, length); | |
28 return hashTableEntry ? static_cast<CSSValueID>(hashTableEntry->id) : CSSVal ueInvalid; | |
29 } | |
30 | |
31 CSSValueID cssValueKeywordID(const CSSParserString& string) | |
32 { | |
33 unsigned length = string.length(); | |
34 if (!length) | |
35 return CSSValueInvalid; | |
36 if (length > maxCSSValueKeywordLength) | |
37 return CSSValueInvalid; | |
38 | |
39 return string.is8Bit() ? cssValueKeywordID(string.characters8(), length) : c ssValueKeywordID(string.characters16(), length); | |
40 } | |
41 | |
42 } | |
OLD | NEW |