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

Side by Side Diff: Source/core/css/parser/MediaQueryToken.cpp

Issue 225293006: Moved MQ parsing block tracking to tokenizer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Debug build fix Created 6 years, 8 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 unified diff | Download patch
OLDNEW
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)
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_blockToken(NotBlockToken)
20 { 21 {
21 } 22 }
22 23
24 MediaQueryToken::MediaQueryToken(MediaQueryTokenType type, BlockToken blockToken )
25 : m_type(type)
26 , m_delimiter(0)
27 , m_numericValue(0)
28 , m_unit(CSSPrimitiveValue::CSS_UNKNOWN)
29 , m_blockToken(blockToken)
30 {
31 }
32
23 // Just a helper used for Delimiter tokens. 33 // Just a helper used for Delimiter tokens.
24 MediaQueryToken::MediaQueryToken(MediaQueryTokenType type, UChar c) 34 MediaQueryToken::MediaQueryToken(MediaQueryTokenType type, UChar c)
25 : m_type(type) 35 : m_type(type)
26 , m_delimiter(c) 36 , m_delimiter(c)
27 , m_numericValue(0) 37 , m_numericValue(0)
28 , m_unit(CSSPrimitiveValue::CSS_UNKNOWN) 38 , m_unit(CSSPrimitiveValue::CSS_UNKNOWN)
39 , m_blockToken(NotBlockToken)
29 { 40 {
30 ASSERT(m_type == DelimiterToken); 41 ASSERT(m_type == DelimiterToken);
31 } 42 }
32 43
33 MediaQueryToken::MediaQueryToken(MediaQueryTokenType type, String value) 44 MediaQueryToken::MediaQueryToken(MediaQueryTokenType type, String value)
34 : m_type(type) 45 : m_type(type)
35 , m_value(value) 46 , m_value(value)
36 , m_delimiter(0) 47 , m_delimiter(0)
37 , m_numericValue(0) 48 , m_numericValue(0)
38 , m_unit(CSSPrimitiveValue::CSS_UNKNOWN) 49 , m_unit(CSSPrimitiveValue::CSS_UNKNOWN)
50 , m_blockToken(NotBlockToken)
39 { 51 {
40 } 52 }
41 53
54 MediaQueryToken::MediaQueryToken(MediaQueryTokenType type, String value, BlockTo ken blockToken)
55 : m_type(type)
56 , m_value(value)
57 , m_delimiter(0)
58 , m_numericValue(0)
59 , m_unit(CSSPrimitiveValue::CSS_UNKNOWN)
60 , m_blockToken(blockToken)
61 {
62 }
63
64
42 MediaQueryToken::MediaQueryToken(MediaQueryTokenType type, double numericValue, NumericValueType numericValueType) 65 MediaQueryToken::MediaQueryToken(MediaQueryTokenType type, double numericValue, NumericValueType numericValueType)
43 : m_type(type) 66 : m_type(type)
44 , m_delimiter(0) 67 , m_delimiter(0)
45 , m_numericValueType(numericValueType) 68 , m_numericValueType(numericValueType)
46 , m_numericValue(numericValue) 69 , m_numericValue(numericValue)
47 , m_unit(CSSPrimitiveValue::CSS_NUMBER) 70 , m_unit(CSSPrimitiveValue::CSS_NUMBER)
71 , m_blockToken(NotBlockToken)
48 { 72 {
49 ASSERT(type == NumberToken); 73 ASSERT(type == NumberToken);
50 } 74 }
51 75
52 void MediaQueryToken::convertToDimensionWithUnit(String unit) 76 void MediaQueryToken::convertToDimensionWithUnit(String unit)
53 { 77 {
54 ASSERT(m_type == NumberToken); 78 ASSERT(m_type == NumberToken);
55 m_type = DimensionToken; 79 m_type = DimensionToken;
56 m_unit = CSSPrimitiveValue::fromName(unit); 80 m_unit = CSSPrimitiveValue::fromName(unit);
57 } 81 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 sprintf(buffer, "%d%s", static_cast<int>(m_numericValue), unitBuffer ); 120 sprintf(buffer, "%d%s", static_cast<int>(m_numericValue), unitBuffer );
97 else 121 else
98 sprintf(buffer, "%f%s", m_numericValue, unitBuffer); 122 sprintf(buffer, "%f%s", m_numericValue, unitBuffer);
99 123
100 return String(buffer, strlen(buffer)); 124 return String(buffer, strlen(buffer));
101 } 125 }
102 return String(); 126 return String();
103 } 127 }
104 128
105 } // namespace WebCore 129 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698