Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserv ed. | 3 * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserv ed. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 #ifndef CSSParserValues_h | 21 #ifndef CSSParserValues_h |
| 22 #define CSSParserValues_h | 22 #define CSSParserValues_h |
| 23 | 23 |
| 24 #include "core/CSSValueKeywords.h" | 24 #include "core/CSSValueKeywords.h" |
| 25 #include "core/css/CSSPrimitiveValue.h" | 25 #include "core/css/CSSPrimitiveValue.h" |
| 26 #include "core/css/CSSValueList.h" | 26 #include "core/css/CSSValueList.h" |
| 27 #include "core/css/parser/CSSParserString.h" | 27 #include "core/css/parser/CSSParserString.h" |
| 28 #include "core/css/parser/CSSParserTokenRange.h" | 28 #include "core/css/parser/CSSParserTokenRange.h" |
| 29 #include "wtf/Allocator.h" | 29 #include "wtf/Allocator.h" |
| 30 | 30 |
| 31 | |
| 31 namespace blink { | 32 namespace blink { |
| 32 | 33 |
| 33 class QualifiedName; | 34 class QualifiedName; |
| 34 | 35 |
| 35 struct CSSParserFunction; | 36 struct CSSParserFunction; |
| 36 struct CSSParserCalcFunction; | 37 struct CSSParserCalcFunction; |
| 37 class CSSParserValueList; | 38 class CSSParserValueList; |
| 38 | 39 |
| 39 struct CSSParserValue { | 40 struct CSSParserValue { |
| 40 ALLOW_ONLY_INLINE_ALLOCATION(); | 41 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 41 CSSValueID id; | 42 CSSValueID id; |
| 42 bool isInt; | 43 bool isInt; |
| 43 union { | 44 union { |
| 44 double fValue; | 45 double fValue; |
| 45 int iValue; | 46 int iValue; |
| 46 CSSParserString string; | 47 CSSParserString string; |
| 47 CSSParserFunction* function; | 48 CSSParserFunction* function; |
| 48 CSSParserCalcFunction* calcFunction; | 49 CSSParserCalcFunction* calcFunction; |
| 49 CSSParserValueList* valueList; | 50 CSSParserValueList* valueList; |
| 50 struct { | 51 struct { |
| 51 UChar32 start; | 52 UChar32 start; |
| 52 UChar32 end; | 53 UChar32 end; |
| 53 } m_unicodeRange; | 54 } m_unicodeRange; |
| 55 CSSVariableData* variableData; | |
| 54 }; | 56 }; |
| 55 enum { | 57 enum { |
| 56 Operator = 0x100000, | 58 Operator = 0x100000, |
| 57 Function = 0x100001, | 59 Function = 0x100001, |
| 58 CalcFunction = 0x100002, | 60 CalcFunction = 0x100002, |
| 59 ValueList = 0x100003, | 61 ValueList = 0x100003, |
| 60 HexColor = 0x100004, | 62 HexColor = 0x100004, |
| 61 Identifier = 0x100005, | 63 Identifier = 0x100005, |
| 62 // Represents a dimension by a list of two values, a UnitType::Number an d an Identifier | 64 // Represents a dimension by a list of two values, a UnitType::Number an d an Identifier |
| 63 DimensionList = 0x100006, | 65 DimensionList = 0x100006, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 { | 102 { |
| 101 ASSERT(index < m_values.size()); | 103 ASSERT(index < m_values.size()); |
| 102 if (index < m_values.size()) | 104 if (index < m_values.size()) |
| 103 m_current = index; | 105 m_current = index; |
| 104 } | 106 } |
| 105 | 107 |
| 106 CSSParserValue* valueAt(unsigned i) { return i < m_values.size() ? &m_values [i] : nullptr; } | 108 CSSParserValue* valueAt(unsigned i) { return i < m_values.size() ? &m_values [i] : nullptr; } |
| 107 | 109 |
| 108 void clearAndLeakValues() { m_values.clear(); m_current = 0;} | 110 void clearAndLeakValues() { m_values.clear(); m_current = 0;} |
| 109 void destroyAndClear(); | 111 void destroyAndClear(); |
| 112 private: | |
| 113 void checkForVariableReferencesOrDestroyAndClear(const CSSParserTokenRange& originalRange); | |
| 114 void consumeVariableValue(const CSSParserTokenRange&); | |
| 110 | 115 |
| 111 private: | |
| 112 unsigned m_current; | 116 unsigned m_current; |
| 113 Vector<CSSParserValue, 4> m_values; | 117 Vector<CSSParserValue, 4> m_values; |
| 114 }; | 118 }; |
| 115 | 119 |
| 116 struct CSSParserFunction { | 120 struct CSSParserFunction { |
| 117 WTF_MAKE_FAST_ALLOCATED(CSSParserFunction); | 121 WTF_MAKE_FAST_ALLOCATED(CSSParserFunction); |
| 118 public: | 122 public: |
| 119 CSSValueID id; | 123 CSSValueID id; |
| 120 OwnPtr<CSSParserValueList> args; | 124 OwnPtr<CSSParserValueList> args; |
| 121 }; | 125 }; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 144 } | 148 } |
| 145 | 149 |
| 146 inline void CSSParserValue::setFromValueList(PassOwnPtr<CSSParserValueList> valu eList) | 150 inline void CSSParserValue::setFromValueList(PassOwnPtr<CSSParserValueList> valu eList) |
| 147 { | 151 { |
| 148 id = CSSValueInvalid; | 152 id = CSSValueInvalid; |
| 149 this->valueList = valueList.leakPtr(); | 153 this->valueList = valueList.leakPtr(); |
| 150 m_unit = ValueList; | 154 m_unit = ValueList; |
| 151 isInt = false; | 155 isInt = false; |
| 152 } | 156 } |
| 153 | 157 |
| 154 } | 158 }; |
|
Timothy Loh
2015/09/30 02:09:28
unrelated
| |
| 155 | 159 |
| 156 #endif | 160 #endif |
| OLD | NEW |