OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/css/parser/MediaQueryToken.h" | 6 #include "core/css/parser/MediaQueryToken.h" |
7 | 7 |
8 #include "wtf/HashMap.h" | 8 #include "wtf/HashMap.h" |
9 #include "wtf/text/StringHash.h" | 9 #include "wtf/text/StringHash.h" |
10 #include <limits.h> | 10 #include <limits.h> |
11 | 11 |
12 namespace WebCore { | 12 namespace WebCore { |
13 | 13 |
14 | 14 |
15 MediaQueryToken::MediaQueryToken(MediaQueryTokenType type) | 15 MediaQueryToken::MediaQueryToken(MediaQueryTokenType type, BlockType blockType) |
16 : m_type(type) | 16 : m_type(type) |
17 , m_delimiter(0) | 17 , m_delimiter(0) |
18 , m_numericValue(0) | 18 , m_numericValue(0) |
19 , m_unit(CSSPrimitiveValue::CSS_UNKNOWN) | 19 , m_unit(CSSPrimitiveValue::CSS_UNKNOWN) |
| 20 , m_blockType(blockType) |
20 { | 21 { |
21 } | 22 } |
22 | 23 |
23 // Just a helper used for Delimiter tokens. | 24 // Just a helper used for Delimiter tokens. |
24 MediaQueryToken::MediaQueryToken(MediaQueryTokenType type, UChar c) | 25 MediaQueryToken::MediaQueryToken(MediaQueryTokenType type, UChar c) |
25 : m_type(type) | 26 : m_type(type) |
26 , m_delimiter(c) | 27 , m_delimiter(c) |
27 , m_numericValue(0) | 28 , m_numericValue(0) |
28 , m_unit(CSSPrimitiveValue::CSS_UNKNOWN) | 29 , m_unit(CSSPrimitiveValue::CSS_UNKNOWN) |
| 30 , m_blockType(NotBlock) |
29 { | 31 { |
30 ASSERT(m_type == DelimiterToken); | 32 ASSERT(m_type == DelimiterToken); |
31 } | 33 } |
32 | 34 |
33 MediaQueryToken::MediaQueryToken(MediaQueryTokenType type, String value) | 35 MediaQueryToken::MediaQueryToken(MediaQueryTokenType type, String value, BlockTy
pe blockType) |
34 : m_type(type) | 36 : m_type(type) |
35 , m_value(value) | 37 , m_value(value) |
36 , m_delimiter(0) | 38 , m_delimiter(0) |
37 , m_numericValue(0) | 39 , m_numericValue(0) |
38 , m_unit(CSSPrimitiveValue::CSS_UNKNOWN) | 40 , m_unit(CSSPrimitiveValue::CSS_UNKNOWN) |
| 41 , m_blockType(blockType) |
39 { | 42 { |
40 } | 43 } |
41 | 44 |
42 MediaQueryToken::MediaQueryToken(MediaQueryTokenType type, double numericValue,
NumericValueType numericValueType) | 45 MediaQueryToken::MediaQueryToken(MediaQueryTokenType type, double numericValue,
NumericValueType numericValueType) |
43 : m_type(type) | 46 : m_type(type) |
44 , m_delimiter(0) | 47 , m_delimiter(0) |
45 , m_numericValueType(numericValueType) | 48 , m_numericValueType(numericValueType) |
46 , m_numericValue(numericValue) | 49 , m_numericValue(numericValue) |
47 , m_unit(CSSPrimitiveValue::CSS_NUMBER) | 50 , m_unit(CSSPrimitiveValue::CSS_NUMBER) |
| 51 , m_blockType(NotBlock) |
48 { | 52 { |
49 ASSERT(type == NumberToken); | 53 ASSERT(type == NumberToken); |
50 } | 54 } |
51 | 55 |
52 void MediaQueryToken::convertToDimensionWithUnit(String unit) | 56 void MediaQueryToken::convertToDimensionWithUnit(String unit) |
53 { | 57 { |
54 ASSERT(m_type == NumberToken); | 58 ASSERT(m_type == NumberToken); |
55 m_type = DimensionToken; | 59 m_type = DimensionToken; |
56 m_unit = CSSPrimitiveValue::fromName(unit); | 60 m_unit = CSSPrimitiveValue::fromName(unit); |
57 } | 61 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 sprintf(buffer, "%d%s", static_cast<int>(m_numericValue), unitBuffer
); | 100 sprintf(buffer, "%d%s", static_cast<int>(m_numericValue), unitBuffer
); |
97 else | 101 else |
98 sprintf(buffer, "%f%s", m_numericValue, unitBuffer); | 102 sprintf(buffer, "%f%s", m_numericValue, unitBuffer); |
99 | 103 |
100 return String(buffer, strlen(buffer)); | 104 return String(buffer, strlen(buffer)); |
101 } | 105 } |
102 return String(); | 106 return String(); |
103 } | 107 } |
104 | 108 |
105 } // namespace WebCore | 109 } // namespace WebCore |
OLD | NEW |