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 30 matching lines...) Expand all Loading... | |
| 41 union { | 41 union { |
| 42 double fValue; | 42 double fValue; |
| 43 int iValue; | 43 int iValue; |
| 44 CSSParserString string; | 44 CSSParserString string; |
| 45 CSSParserFunction* function; | 45 CSSParserFunction* function; |
| 46 CSSParserValueList* valueList; | 46 CSSParserValueList* valueList; |
| 47 struct { | 47 struct { |
| 48 UChar32 start; | 48 UChar32 start; |
| 49 UChar32 end; | 49 UChar32 end; |
| 50 } m_unicodeRange; | 50 } m_unicodeRange; |
| 51 CSSVariableData* variableData; | |
|
alancutter (OOO until 2018)
2015/06/26 06:56:07
We want to remove CSSParserValues eventually and o
| |
| 51 }; | 52 }; |
| 52 enum { | 53 enum { |
| 53 Operator = 0x100000, | 54 Operator = 0x100000, |
| 54 Function = 0x100001, | 55 Function = 0x100001, |
| 55 ValueList = 0x100002, | 56 ValueList = 0x100002, |
| 56 HexColor = 0x100004, | 57 HexColor = 0x100004, |
| 57 // Represents a dimension by a list of two values, a CSS_NUMBER and an C SS_IDENT | 58 // Represents a dimension by a list of two values, a CSS_NUMBER and an C SS_IDENT |
| 58 DimensionList = 0x100006, | 59 DimensionList = 0x100006, |
| 59 // Represents a unicode range by a pair of UChar32 values | 60 // Represents a unicode range by a pair of UChar32 values |
| 60 UnicodeRange = 0x100007, | 61 UnicodeRange = 0x100007, |
| 62 // Reperesents a copy of part of a CSSTokenizer::Scope for defining and resolving variables | |
| 63 VariableValue = 0x100008, | |
| 61 }; | 64 }; |
| 62 int unit; | 65 int unit; |
| 63 | 66 |
| 64 inline void setFromNumber(double value, int unit = CSSPrimitiveValue::CSS_NU MBER); | 67 inline void setFromNumber(double value, int unit = CSSPrimitiveValue::CSS_NU MBER); |
| 65 inline void setFromOperator(UChar); | 68 inline void setFromOperator(UChar); |
| 66 inline void setFromFunction(CSSParserFunction*); | 69 inline void setFromFunction(CSSParserFunction*); |
| 67 inline void setFromValueList(PassOwnPtr<CSSParserValueList>); | 70 inline void setFromValueList(PassOwnPtr<CSSParserValueList>); |
| 68 }; | 71 }; |
| 69 | 72 |
| 70 class CORE_EXPORT CSSParserValueList { | 73 class CORE_EXPORT CSSParserValueList { |
| 71 WTF_MAKE_FAST_ALLOCATED(CSSParserValueList); | 74 WTF_MAKE_FAST_ALLOCATED(CSSParserValueList); |
| 72 public: | 75 public: |
| 73 CSSParserValueList() | 76 CSSParserValueList() |
| 74 : m_current(0) | 77 : m_current(0) |
| 75 { | 78 { |
| 76 } | 79 } |
| 77 CSSParserValueList(CSSParserTokenRange, bool& usesRemUnits); | 80 CSSParserValueList(CSSParserTokenRange, bool& usesRemUnits, bool& usesVariab les); |
| 78 ~CSSParserValueList(); | 81 ~CSSParserValueList(); |
| 79 | 82 |
| 80 void addValue(const CSSParserValue&); | 83 void addValue(const CSSParserValue&); |
| 81 | 84 |
| 82 unsigned size() const { return m_values.size(); } | 85 unsigned size() const { return m_values.size(); } |
| 83 unsigned currentIndex() { return m_current; } | 86 unsigned currentIndex() { return m_current; } |
| 84 CSSParserValue* current() { return m_current < m_values.size() ? &m_values[m _current] : 0; } | 87 CSSParserValue* current() { return m_current < m_values.size() ? &m_values[m _current] : 0; } |
| 85 CSSParserValue* next() { ++m_current; return current(); } | 88 CSSParserValue* next() { ++m_current; return current(); } |
| 86 CSSParserValue* previous() | 89 CSSParserValue* previous() |
| 87 { | 90 { |
| 88 if (!m_current) | 91 if (!m_current) |
| 89 return 0; | 92 return 0; |
| 90 --m_current; | 93 --m_current; |
| 91 return current(); | 94 return current(); |
| 92 } | 95 } |
| 93 void setCurrentIndex(unsigned index) | 96 void setCurrentIndex(unsigned index) |
| 94 { | 97 { |
| 95 ASSERT(index < m_values.size()); | 98 ASSERT(index < m_values.size()); |
| 96 if (index < m_values.size()) | 99 if (index < m_values.size()) |
| 97 m_current = index; | 100 m_current = index; |
| 98 } | 101 } |
| 99 | 102 |
| 100 CSSParserValue* valueAt(unsigned i) { return i < m_values.size() ? &m_values [i] : 0; } | 103 CSSParserValue* valueAt(unsigned i) { return i < m_values.size() ? &m_values [i] : 0; } |
| 101 | 104 |
| 102 void clearAndLeakValues() { m_values.clear(); m_current = 0;} | 105 void clearAndLeakValues() { m_values.clear(); m_current = 0;} |
| 103 void destroyAndClear(); | 106 void destroyAndClear(); |
| 107 private: | |
| 108 void checkForVariableReferencesOrDestroyAndClear(const CSSParserTokenRange& originalRange); | |
| 109 void consumeVariableValue(const CSSParserTokenRange&); | |
| 104 | 110 |
| 105 private: | |
| 106 unsigned m_current; | 111 unsigned m_current; |
| 107 Vector<CSSParserValue, 4> m_values; | 112 Vector<CSSParserValue, 4> m_values; |
| 108 }; | 113 }; |
| 109 | 114 |
| 110 struct CSSParserFunction { | 115 struct CSSParserFunction { |
| 111 WTF_MAKE_FAST_ALLOCATED(CSSParserFunction); | 116 WTF_MAKE_FAST_ALLOCATED(CSSParserFunction); |
| 112 public: | 117 public: |
| 113 CSSValueID id; | 118 CSSValueID id; |
| 114 OwnPtr<CSSParserValueList> args; | 119 OwnPtr<CSSParserValueList> args; |
| 115 }; | 120 }; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 } | 200 } |
| 196 | 201 |
| 197 inline void CSSParserValue::setFromValueList(PassOwnPtr<CSSParserValueList> valu eList) | 202 inline void CSSParserValue::setFromValueList(PassOwnPtr<CSSParserValueList> valu eList) |
| 198 { | 203 { |
| 199 id = CSSValueInvalid; | 204 id = CSSValueInvalid; |
| 200 this->valueList = valueList.leakPtr(); | 205 this->valueList = valueList.leakPtr(); |
| 201 unit = ValueList; | 206 unit = ValueList; |
| 202 isInt = false; | 207 isInt = false; |
| 203 } | 208 } |
| 204 | 209 |
| 205 } | 210 }; |
| 206 | 211 |
| 207 #endif | 212 #endif |
| OLD | NEW |