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

Unified Diff: Source/core/css/parser/MediaQueryTokenizer.cpp

Issue 209503003: Convert MediaQueryTokenizer's codepoints array to be static data (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Dynamic file name in comment 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/parser/MediaQueryTokenizer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/parser/MediaQueryTokenizer.cpp
diff --git a/Source/core/css/parser/MediaQueryTokenizer.cpp b/Source/core/css/parser/MediaQueryTokenizer.cpp
index fb3a61e229ca278e8b7d98cb60cdc9314827780f..ead42f1b28dccc99c18c871a827e71167994c05e 100644
--- a/Source/core/css/parser/MediaQueryTokenizer.cpp
+++ b/Source/core/css/parser/MediaQueryTokenizer.cpp
@@ -5,54 +5,16 @@
#include "config.h"
#include "core/css/parser/MediaQueryTokenizer.h"
+namespace WebCore {
+#include "MediaQueryTokenizerCodepoints.cpp"
+}
+
#include "core/css/parser/MediaQueryInputStream.h"
#include "core/html/parser/HTMLParserIdioms.h"
#include "wtf/unicode/CharacterNames.h"
namespace WebCore {
-const unsigned codePointsNumber = SCHAR_MAX + 1;
-
-class MediaQueryTokenizer::CodePoints {
-public:
- MediaQueryTokenizer::CodePoint codePoints[codePointsNumber];
-
- // FIXME: Move the codePoint array to be a static one, generated by build scripts
- CodePoints()
- {
- memset(codePoints, 0, codePointsNumber);
- codePoints['\n'] = &MediaQueryTokenizer::whiteSpace;
- codePoints['\r'] = &MediaQueryTokenizer::whiteSpace;
- codePoints['\t'] = &MediaQueryTokenizer::whiteSpace;
- codePoints[' '] = &MediaQueryTokenizer::whiteSpace;
- codePoints['\f'] = &MediaQueryTokenizer::whiteSpace;
- codePoints['('] = &MediaQueryTokenizer::leftParenthesis;
- codePoints[')'] = &MediaQueryTokenizer::rightParenthesis;
- codePoints['+'] = &MediaQueryTokenizer::plusOrFullStop;
- codePoints['.'] = &MediaQueryTokenizer::plusOrFullStop;
- codePoints[','] = &MediaQueryTokenizer::comma;
- codePoints['-'] = &MediaQueryTokenizer::hyphenMinus;
- codePoints['/'] = &MediaQueryTokenizer::solidus;
- codePoints[':'] = &MediaQueryTokenizer::colon;
- codePoints[';'] = &MediaQueryTokenizer::semiColon;
- codePoints['\\'] = &MediaQueryTokenizer::reverseSolidus;
- for (unsigned char digit = '0'; digit <= '9'; ++digit)
- codePoints[digit] = &MediaQueryTokenizer::asciiDigit;
- for (unsigned char alpha = 'a'; alpha <= 'z'; ++alpha)
- codePoints[alpha] = &MediaQueryTokenizer::nameStart;
- for (unsigned char alpha = 'A'; alpha <= 'Z'; ++alpha)
- codePoints[alpha] = &MediaQueryTokenizer::nameStart;
- codePoints['_'] = &MediaQueryTokenizer::nameStart;
- codePoints[kEndOfFileMarker] = &MediaQueryTokenizer::endOfFile;
- }
-};
-
-MediaQueryTokenizer::CodePoints* MediaQueryTokenizer::codePoints()
-{
- static CodePoints codePoints;
- return &codePoints;
-}
-
// http://dev.w3.org/csswg/css-syntax/#name-start-code-point
static bool isNameStart(UChar c)
{
@@ -216,7 +178,7 @@ MediaQueryToken MediaQueryTokenizer::nextToken()
if (isASCII(cc)) {
ASSERT_WITH_SECURITY_IMPLICATION(cc < codePointsNumber);
- codePointFunc = codePoints()->codePoints[cc];
+ codePointFunc = codePoints[cc];
} else {
codePointFunc = &MediaQueryTokenizer::nameStart;
}
« no previous file with comments | « Source/core/css/parser/MediaQueryTokenizer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698