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

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

Issue 1161963002: Shrinking CSSParserToken for lower CSS parsing memory usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed unused union members. Created 5 years, 6 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
« no previous file with comments | « Source/core/css/parser/CSSParserToken.h ('k') | Source/core/css/parser/CSSParserValues.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/CSSParserToken.h" 6 #include "core/css/parser/CSSParserToken.h"
7 7
8 #include "core/css/CSSMarkup.h" 8 #include "core/css/CSSMarkup.h"
9 #include "core/css/parser/CSSPropertyParser.h" 9 #include "core/css/parser/CSSPropertyParser.h"
10 #include "wtf/HashMap.h" 10 #include "wtf/HashMap.h"
(...skipping 13 matching lines...) Expand all
24 : m_type(type) 24 : m_type(type)
25 , m_blockType(NotBlock) 25 , m_blockType(NotBlock)
26 , m_delimiter(c) 26 , m_delimiter(c)
27 { 27 {
28 ASSERT(m_type == DelimiterToken); 28 ASSERT(m_type == DelimiterToken);
29 } 29 }
30 30
31 CSSParserToken::CSSParserToken(CSSParserTokenType type, CSSParserString value, B lockType blockType) 31 CSSParserToken::CSSParserToken(CSSParserTokenType type, CSSParserString value, B lockType blockType)
32 : m_type(type) 32 : m_type(type)
33 , m_blockType(blockType) 33 , m_blockType(blockType)
34 , m_value(value)
35 { 34 {
35 initValueFromCSSParserString(value);
36 } 36 }
37 37
38 CSSParserToken::CSSParserToken(CSSParserTokenType type, double numericValue, Num ericValueType numericValueType, NumericSign sign) 38 CSSParserToken::CSSParserToken(CSSParserTokenType type, double numericValue, Num ericValueType numericValueType, NumericSign sign)
39 : m_type(type) 39 : m_type(type)
40 , m_blockType(NotBlock) 40 , m_blockType(NotBlock)
41 , m_numericValueType(numericValueType) 41 , m_numericValueType(numericValueType)
42 , m_numericSign(sign) 42 , m_numericSign(sign)
43 , m_unit(CSSPrimitiveValue::CSS_NUMBER) 43 , m_unit(CSSPrimitiveValue::CSS_NUMBER)
44 , m_numericValue(numericValue) 44 , m_numericValue(numericValue)
45 { 45 {
46 ASSERT(type == NumberToken); 46 ASSERT(type == NumberToken);
47 } 47 }
48 48
49 CSSParserToken::CSSParserToken(CSSParserTokenType type, UChar32 start, UChar32 e nd) 49 CSSParserToken::CSSParserToken(CSSParserTokenType type, UChar32 start, UChar32 e nd)
50 : m_type(UnicodeRangeToken) 50 : m_type(UnicodeRangeToken)
51 , m_blockType(NotBlock) 51 , m_blockType(NotBlock)
52 { 52 {
53 ASSERT_UNUSED(type, type == UnicodeRangeToken); 53 ASSERT_UNUSED(type, type == UnicodeRangeToken);
54 m_unicodeRange.start = start; 54 m_unicodeRange.start = start;
55 m_unicodeRange.end = end; 55 m_unicodeRange.end = end;
56 } 56 }
57 57
58 CSSParserToken::CSSParserToken(HashTokenType type, CSSParserString value) 58 CSSParserToken::CSSParserToken(HashTokenType type, CSSParserString value)
59 : m_type(HashToken) 59 : m_type(HashToken)
60 , m_blockType(NotBlock) 60 , m_blockType(NotBlock)
61 , m_value(value)
62 , m_hashTokenType(type) 61 , m_hashTokenType(type)
63 { 62 {
63 initValueFromCSSParserString(value);
64 } 64 }
65 65
66 void CSSParserToken::convertToDimensionWithUnit(CSSParserString unit) 66 void CSSParserToken::convertToDimensionWithUnit(CSSParserString unit)
67 { 67 {
68 ASSERT(m_type == NumberToken); 68 ASSERT(m_type == NumberToken);
69 m_type = DimensionToken; 69 m_type = DimensionToken;
70 m_value = unit; 70 initValueFromCSSParserString(unit);
71 m_unit = CSSPrimitiveValue::fromName(unit); 71 m_unit = CSSPrimitiveValue::fromName(unit);
72 } 72 }
73 73
74 void CSSParserToken::convertToPercentage() 74 void CSSParserToken::convertToPercentage()
75 { 75 {
76 ASSERT(m_type == NumberToken); 76 ASSERT(m_type == NumberToken);
77 m_type = PercentageToken; 77 m_type = PercentageToken;
78 m_unit = CSSPrimitiveValue::CSS_PERCENTAGE; 78 m_unit = CSSPrimitiveValue::CSS_PERCENTAGE;
79 } 79 }
80 80
(...skipping 19 matching lines...) Expand all
100 100
101 double CSSParserToken::numericValue() const 101 double CSSParserToken::numericValue() const
102 { 102 {
103 ASSERT(m_type == NumberToken || m_type == PercentageToken || m_type == Dimen sionToken); 103 ASSERT(m_type == NumberToken || m_type == PercentageToken || m_type == Dimen sionToken);
104 return m_numericValue; 104 return m_numericValue;
105 } 105 }
106 106
107 CSSPropertyID CSSParserToken::parseAsUnresolvedCSSPropertyID() const 107 CSSPropertyID CSSParserToken::parseAsUnresolvedCSSPropertyID() const
108 { 108 {
109 ASSERT(m_type == IdentToken); 109 ASSERT(m_type == IdentToken);
110 return unresolvedCSSPropertyID(m_value); 110 return unresolvedCSSPropertyID(value());
111 } 111 }
112 112
113 void CSSParserToken::serialize(StringBuilder& builder) const 113 void CSSParserToken::serialize(StringBuilder& builder) const
114 { 114 {
115 // This is currently only used for @supports CSSOM. To keep our implementati on 115 // This is currently only used for @supports CSSOM. To keep our implementati on
116 // simple we handle some of the edge cases incorrectly (see comments below). 116 // simple we handle some of the edge cases incorrectly (see comments below).
117 switch (type()) { 117 switch (type()) {
118 case IdentToken: 118 case IdentToken:
119 return serializeIdentifier(value(), builder); 119 return serializeIdentifier(value(), builder);
120 case FunctionToken: 120 case FunctionToken:
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 return builder.append('}'); 193 return builder.append('}');
194 194
195 case EOFToken: 195 case EOFToken:
196 case CommentToken: 196 case CommentToken:
197 ASSERT_NOT_REACHED(); 197 ASSERT_NOT_REACHED();
198 return; 198 return;
199 } 199 }
200 } 200 }
201 201
202 } // namespace blink 202 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/parser/CSSParserToken.h ('k') | Source/core/css/parser/CSSParserValues.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698