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

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

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 | « no previous file | Source/core/css/parser/CSSParserToken.cpp » ('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 #ifndef CSSParserToken_h 5 #ifndef CSSParserToken_h
6 #define CSSParserToken_h 6 #define CSSParserToken_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "core/css/CSSPrimitiveValue.h" 9 #include "core/css/CSSPrimitiveValue.h"
10 #include "core/css/parser/CSSParserValues.h" 10 #include "core/css/parser/CSSParserValues.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 CSSParserToken(HashTokenType, CSSParserString); 81 CSSParserToken(HashTokenType, CSSParserString);
82 82
83 // Converts NumberToken to DimensionToken. 83 // Converts NumberToken to DimensionToken.
84 void convertToDimensionWithUnit(CSSParserString); 84 void convertToDimensionWithUnit(CSSParserString);
85 85
86 // Converts NumberToken to PercentageToken. 86 // Converts NumberToken to PercentageToken.
87 void convertToPercentage(); 87 void convertToPercentage();
88 88
89 CSSParserTokenType type() const { return static_cast<CSSParserTokenType>(m_t ype); } 89 CSSParserTokenType type() const { return static_cast<CSSParserTokenType>(m_t ype); }
90 CSSParserString value() const { return m_value; } 90 CSSParserString value() const
91 bool valueEqualsIgnoringCase(const char* str) const { return m_value.equalIg noringCase(str); } 91 {
92 CSSParserString ret;
93 ret.initRaw(m_valueDataCharRaw, m_valueLength, m_valueIs8Bit);
94 return ret;
95 }
96 bool valueEqualsIgnoringCase(const char* str) const { return value().equalIg noringCase(str); }
92 97
93 UChar delimiter() const; 98 UChar delimiter() const;
94 NumericSign numericSign() const; 99 NumericSign numericSign() const;
95 NumericValueType numericValueType() const; 100 NumericValueType numericValueType() const;
96 double numericValue() const; 101 double numericValue() const;
97 HashTokenType hashTokenType() const { ASSERT(m_type == HashToken); return m_ hashTokenType; } 102 HashTokenType hashTokenType() const { ASSERT(m_type == HashToken); return m_ hashTokenType; }
98 BlockType blockType() const { return static_cast<BlockType>(m_blockType); } 103 BlockType blockType() const { return static_cast<BlockType>(m_blockType); }
99 CSSPrimitiveValue::UnitType unitType() const { return static_cast<CSSPrimiti veValue::UnitType>(m_unit); } 104 CSSPrimitiveValue::UnitType unitType() const { return static_cast<CSSPrimiti veValue::UnitType>(m_unit); }
100 UChar32 unicodeRangeStart() const { ASSERT(m_type == UnicodeRangeToken); ret urn m_unicodeRange.start; } 105 UChar32 unicodeRangeStart() const { ASSERT(m_type == UnicodeRangeToken); ret urn m_unicodeRange.start; }
101 UChar32 unicodeRangeEnd() const { ASSERT(m_type == UnicodeRangeToken); retur n m_unicodeRange.end; } 106 UChar32 unicodeRangeEnd() const { ASSERT(m_type == UnicodeRangeToken); retur n m_unicodeRange.end; }
102 107
103 CSSPropertyID parseAsUnresolvedCSSPropertyID() const; 108 CSSPropertyID parseAsUnresolvedCSSPropertyID() const;
104 109
105 void serialize(StringBuilder&) const; 110 void serialize(StringBuilder&) const;
106 111
107 private: 112 private:
113 void initValueFromCSSParserString(const CSSParserString& value)
114 {
115 m_valueLength = value.m_length;
116 m_valueIs8Bit = value.m_is8Bit;
117 m_valueDataCharRaw = value.m_data.charactersRaw;
118 }
108 unsigned m_type : 6; // CSSParserTokenType 119 unsigned m_type : 6; // CSSParserTokenType
109 unsigned m_blockType : 2; // BlockType 120 unsigned m_blockType : 2; // BlockType
110 unsigned m_numericValueType : 1; // NumericValueType 121 unsigned m_numericValueType : 1; // NumericValueType
111 unsigned m_numericSign : 2; // NumericSign 122 unsigned m_numericSign : 2; // NumericSign
112 unsigned m_unit : 7; // CSSPrimitiveValue::UnitType 123 unsigned m_unit : 7; // CSSPrimitiveValue::UnitType
113 124
114 CSSParserString m_value; // FIXME: Pack this better? 125 // m_value... is an unpacked CSSParserString so that we can pack it
126 // tightly with the rest of this object for a smaller object size.
127 bool m_valueIs8Bit : 1;
128 unsigned m_valueLength;
129 const void* m_valueDataCharRaw; // Either LChar* or UChar*.
115 130
116 union { 131 union {
117 UChar m_delimiter; 132 UChar m_delimiter;
118 HashTokenType m_hashTokenType; 133 HashTokenType m_hashTokenType;
119 double m_numericValue; 134 double m_numericValue;
120 135
121 struct { 136 struct {
122 UChar32 start; 137 UChar32 start;
123 UChar32 end; 138 UChar32 end;
124 } m_unicodeRange; 139 } m_unicodeRange;
125 }; 140 };
126 }; 141 };
127 142
128 } // namespace blink 143 } // namespace blink
129 144
130 namespace WTF { 145 namespace WTF {
131 template <> 146 template <>
132 struct IsTriviallyMoveAssignable<blink::CSSParserToken> { 147 struct IsTriviallyMoveAssignable<blink::CSSParserToken> {
133 static const bool value = true; 148 static const bool value = true;
134 }; 149 };
135 } 150 }
136 151
137 #endif // CSSSParserToken_h 152 #endif // CSSSParserToken_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/css/parser/CSSParserToken.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698