OLD | NEW |
| (Empty) |
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 #include "config.h" | |
6 #include "core/css/parser/MediaQueryToken.h" | |
7 | |
8 #include "wtf/HashMap.h" | |
9 #include "wtf/text/StringHash.h" | |
10 | |
11 namespace WebCore { | |
12 | |
13 | |
14 MediaQueryToken::MediaQueryToken(MediaQueryTokenType type) | |
15 : m_type(type) | |
16 , m_delimiter(0) | |
17 , m_unit(CSSPrimitiveValue::CSS_UNKNOWN) | |
18 { | |
19 } | |
20 | |
21 // Just a helper used for Delimiter tokens. | |
22 MediaQueryToken::MediaQueryToken(MediaQueryTokenType type, UChar c) | |
23 : m_type(type) | |
24 , m_delimiter(c) | |
25 , m_unit(CSSPrimitiveValue::CSS_UNKNOWN) | |
26 { | |
27 ASSERT(m_type == DelimiterToken); | |
28 } | |
29 | |
30 MediaQueryToken::MediaQueryToken(MediaQueryTokenType type, String value) | |
31 : m_type(type) | |
32 , m_value(value) | |
33 , m_delimiter(0) | |
34 , m_unit(CSSPrimitiveValue::CSS_UNKNOWN) | |
35 { | |
36 } | |
37 | |
38 MediaQueryToken::MediaQueryToken(MediaQueryTokenType type, double numericValue,
NumericValueType numericValueType) | |
39 : m_type(type) | |
40 , m_delimiter(0) | |
41 , m_numericValueType(numericValueType) | |
42 , m_numericValue(numericValue) | |
43 , m_unit(CSSPrimitiveValue::CSS_NUMBER) | |
44 { | |
45 ASSERT(type == NumberToken); | |
46 } | |
47 | |
48 void MediaQueryToken::convertToDimensionWithUnit(String unit) | |
49 { | |
50 ASSERT(m_type == NumberToken); | |
51 m_type = DimensionToken; | |
52 m_unit = CSSPrimitiveValue::getUnitTable().get(unit.lower()); | |
53 } | |
54 | |
55 void MediaQueryToken::convertToPercentage() | |
56 { | |
57 ASSERT(m_type == NumberToken); | |
58 m_type = PercentageToken; | |
59 m_unit = CSSPrimitiveValue::CSS_PERCENTAGE; | |
60 } | |
61 | |
62 } // namespace WebCore | |
OLD | NEW |