Upstream version 11.39.266.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / css / parser / MediaQueryToken.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 MediaQueryToken_h
6 #define MediaQueryToken_h
7
8 #include "core/css/CSSPrimitiveValue.h"
9 #include "wtf/text/WTFString.h"
10
11 namespace blink {
12
13 enum MediaQueryTokenType {
14     IdentToken = 0,
15     FunctionToken,
16     DelimiterToken,
17     NumberToken,
18     PercentageToken,
19     DimensionToken,
20     WhitespaceToken,
21     ColonToken,
22     SemicolonToken,
23     CommaToken,
24     LeftParenthesisToken,
25     RightParenthesisToken,
26     LeftBracketToken,
27     RightBracketToken,
28     LeftBraceToken,
29     RightBraceToken,
30     StringToken,
31     BadStringToken,
32     EOFToken,
33     CommentToken,
34 };
35
36 enum NumericValueType {
37     IntegerValueType,
38     NumberValueType,
39 };
40
41 class MediaQueryToken {
42 public:
43     enum BlockType {
44         NotBlock,
45         BlockStart,
46         BlockEnd,
47     };
48
49     MediaQueryToken(MediaQueryTokenType, BlockType = NotBlock);
50     MediaQueryToken(MediaQueryTokenType, String value, BlockType = NotBlock);
51
52     MediaQueryToken(MediaQueryTokenType, UChar); // for DelimiterToken
53     MediaQueryToken(MediaQueryTokenType, double, NumericValueType); // for NumberToken
54
55     // Converts NumberToken to DimensionToken.
56     void convertToDimensionWithUnit(String);
57
58     // Converts NumberToken to PercentageToken.
59     void convertToPercentage();
60
61     MediaQueryTokenType type() const { return m_type; }
62     String value() const { return m_value; }
63     String textForUnitTests() const;
64
65     UChar delimiter() const;
66     NumericValueType numericValueType() const;
67     double numericValue() const;
68     BlockType blockType() const { return m_blockType; }
69     CSSPrimitiveValue::UnitType unitType() const { return m_unit; }
70
71 private:
72     MediaQueryTokenType m_type;
73     String m_value;
74
75     UChar m_delimiter; // Could be rolled into m_value?
76
77     NumericValueType m_numericValueType;
78     double m_numericValue;
79     CSSPrimitiveValue::UnitType m_unit;
80
81     BlockType m_blockType;
82 };
83
84 typedef Vector<MediaQueryToken>::iterator MediaQueryTokenIterator;
85
86 } // namespace
87
88 #endif // MediaQueryToken_h