Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / css / parser / CSSTokenizer.h
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 CSSTokenizer_h
6 #define CSSTokenizer_h
7
8 #include "core/css/parser/CSSParserToken.h"
9 #include "core/html/parser/InputStreamPreprocessor.h"
10 #include "wtf/text/WTFString.h"
11
12 #include <climits>
13
14 namespace blink {
15
16 class CSSTokenizerInputStream;
17
18 class CSSTokenizer {
19     WTF_MAKE_NONCOPYABLE(CSSTokenizer);
20     WTF_MAKE_FAST_ALLOCATED;
21 public:
22     static void tokenize(String, Vector<CSSParserToken>&);
23 private:
24     CSSTokenizer(CSSTokenizerInputStream&);
25
26     CSSParserToken nextToken();
27
28     UChar consume();
29     void consume(unsigned);
30     void reconsume(UChar);
31
32     CSSParserToken consumeNumericToken();
33     CSSParserToken consumeIdentLikeToken();
34     CSSParserToken consumeNumber();
35     CSSParserToken consumeStringTokenUntil(UChar);
36     CSSParserToken consumeUnicodeRange();
37     CSSParserToken consumeUrlToken();
38
39     void consumeBadUrlRemnants();
40     void consumeUntilNonWhitespace();
41     void consumeSingleWhitespaceIfNext();
42     bool consumeUntilCommentEndFound();
43
44     bool consumeIfNext(UChar);
45     String consumeName();
46     UChar consumeEscape();
47
48     bool nextTwoCharsAreValidEscape();
49     bool nextCharsAreNumber(UChar);
50     bool nextCharsAreNumber();
51     bool nextCharsAreIdentifier(UChar);
52     bool nextCharsAreIdentifier();
53     CSSParserToken blockStart(CSSParserTokenType);
54     CSSParserToken blockStart(CSSParserTokenType blockType, CSSParserTokenType, String);
55     CSSParserToken blockEnd(CSSParserTokenType, CSSParserTokenType startType);
56
57     typedef CSSParserToken (CSSTokenizer::*CodePoint)(UChar);
58
59     static const CodePoint codePoints[];
60     Vector<CSSParserTokenType> m_blockStack;
61
62     CSSParserToken whiteSpace(UChar);
63     CSSParserToken leftParenthesis(UChar);
64     CSSParserToken rightParenthesis(UChar);
65     CSSParserToken leftBracket(UChar);
66     CSSParserToken rightBracket(UChar);
67     CSSParserToken leftBrace(UChar);
68     CSSParserToken rightBrace(UChar);
69     CSSParserToken plusOrFullStop(UChar);
70     CSSParserToken comma(UChar);
71     CSSParserToken hyphenMinus(UChar);
72     CSSParserToken asterisk(UChar);
73     CSSParserToken solidus(UChar);
74     CSSParserToken colon(UChar);
75     CSSParserToken semiColon(UChar);
76     CSSParserToken hash(UChar);
77     CSSParserToken reverseSolidus(UChar);
78     CSSParserToken asciiDigit(UChar);
79     CSSParserToken letterU(UChar);
80     CSSParserToken nameStart(UChar);
81     CSSParserToken stringStart(UChar);
82     CSSParserToken endOfFile(UChar);
83
84     CSSTokenizerInputStream& m_input;
85 };
86
87
88
89 } // namespace blink
90
91 #endif // CSSTokenizer_h