Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: Source/core/css/CSSValueIDHelper.cpp

Issue 171383002: A thread-safe Media Query Parser (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Another attempt to fix Android build issues Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698