Chromium Code Reviews| 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 #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 Loading... | |
| 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 | |
| 130 union { | |
| 131 const LChar* m_valueDataChar8; | |
|
Timothy Loh
2015/05/29 03:27:46
We don't use the explicitly typed versions here.
| |
| 132 const UChar* m_valueDataChar16; | |
| 133 const void* m_valueDataCharRaw; | |
| 134 }; | |
| 115 | 135 |
| 116 union { | 136 union { |
| 117 UChar m_delimiter; | 137 UChar m_delimiter; |
| 118 HashTokenType m_hashTokenType; | 138 HashTokenType m_hashTokenType; |
| 119 double m_numericValue; | 139 double m_numericValue; |
| 120 | 140 |
| 121 struct { | 141 struct { |
| 122 UChar32 start; | 142 UChar32 start; |
| 123 UChar32 end; | 143 UChar32 end; |
| 124 } m_unicodeRange; | 144 } m_unicodeRange; |
| 125 }; | 145 }; |
| 126 }; | 146 }; |
| 127 | 147 |
| 128 } // namespace blink | 148 } // namespace blink |
| 129 | 149 |
| 130 namespace WTF { | 150 namespace WTF { |
| 131 template <> | 151 template <> |
| 132 struct IsTriviallyMoveAssignable<blink::CSSParserToken> { | 152 struct IsTriviallyMoveAssignable<blink::CSSParserToken> { |
| 133 static const bool value = true; | 153 static const bool value = true; |
| 134 }; | 154 }; |
| 135 } | 155 } |
| 136 | 156 |
| 137 #endif // CSSSParserToken_h | 157 #endif // CSSSParserToken_h |
| OLD | NEW |