| 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, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
| 16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 */ | 19 */ |
| 20 | 20 |
| 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/CSSSelector.h" | 26 #include "core/css/CSSSelector.h" |
| 27 #include "core/css/CSSValueList.h" | 27 #include "core/css/CSSValueList.h" |
| 28 #include "core/css/parser/CSSParserString.h" | 28 #include "core/css/parser/CSSParserString.h" |
| 29 #include "core/css/parser/CSSParserTokenRange.h" |
| 29 | 30 |
| 30 namespace blink { | 31 namespace blink { |
| 31 | 32 |
| 32 class QualifiedName; | 33 class QualifiedName; |
| 33 class CSSParserTokenRange; | |
| 34 | 34 |
| 35 struct CSSParserFunction; | 35 struct CSSParserFunction; |
| 36 struct CSSParserCalcFunction; |
| 36 class CSSParserValueList; | 37 class CSSParserValueList; |
| 37 | 38 |
| 38 struct CSSParserValue { | 39 struct CSSParserValue { |
| 39 CSSValueID id; | 40 CSSValueID id; |
| 40 bool isInt; | 41 bool isInt; |
| 41 union { | 42 union { |
| 42 double fValue; | 43 double fValue; |
| 43 int iValue; | 44 int iValue; |
| 44 CSSParserString string; | 45 CSSParserString string; |
| 45 CSSParserFunction* function; | 46 CSSParserFunction* function; |
| 47 CSSParserCalcFunction* calcFunction; |
| 46 CSSParserValueList* valueList; | 48 CSSParserValueList* valueList; |
| 47 struct { | 49 struct { |
| 48 UChar32 start; | 50 UChar32 start; |
| 49 UChar32 end; | 51 UChar32 end; |
| 50 } m_unicodeRange; | 52 } m_unicodeRange; |
| 51 }; | 53 }; |
| 52 enum { | 54 enum { |
| 53 Operator = 0x100000, | 55 Operator = 0x100000, |
| 54 Function = 0x100001, | 56 Function = 0x100001, |
| 55 ValueList = 0x100002, | 57 CalcFunction = 0x100002, |
| 58 ValueList = 0x100003, |
| 56 HexColor = 0x100004, | 59 HexColor = 0x100004, |
| 57 Identifier = 0x100005, | 60 Identifier = 0x100005, |
| 58 // Represents a dimension by a list of two values, a UnitType::Number an
d an Identifier | 61 // Represents a dimension by a list of two values, a UnitType::Number an
d an Identifier |
| 59 DimensionList = 0x100006, | 62 DimensionList = 0x100006, |
| 60 // Represents a unicode range by a pair of UChar32 values | 63 // Represents a unicode range by a pair of UChar32 values |
| 61 UnicodeRange = 0x100007, | 64 UnicodeRange = 0x100007, |
| 62 }; | 65 }; |
| 63 int m_unit; | 66 int m_unit; |
| 64 CSSPrimitiveValue::UnitType unit() const { return static_cast<CSSPrimitiveVa
lue::UnitType>(m_unit); } | 67 CSSPrimitiveValue::UnitType unit() const { return static_cast<CSSPrimitiveVa
lue::UnitType>(m_unit); } |
| 65 void setUnit(CSSPrimitiveValue::UnitType unit) { m_unit = static_cast<int>(u
nit); } | 68 void setUnit(CSSPrimitiveValue::UnitType unit) { m_unit = static_cast<int>(u
nit); } |
| 66 | 69 |
| 67 inline void setFromNumber(double value, CSSPrimitiveValue::UnitType); | 70 inline void setFromNumber(double value, CSSPrimitiveValue::UnitType); |
| 68 inline void setFromOperator(UChar); | 71 inline void setFromOperator(UChar); |
| 69 inline void setFromFunction(CSSParserFunction*); | |
| 70 inline void setFromValueList(PassOwnPtr<CSSParserValueList>); | 72 inline void setFromValueList(PassOwnPtr<CSSParserValueList>); |
| 71 }; | 73 }; |
| 72 | 74 |
| 73 class CORE_EXPORT CSSParserValueList { | 75 class CORE_EXPORT CSSParserValueList { |
| 74 WTF_MAKE_FAST_ALLOCATED(CSSParserValueList); | 76 WTF_MAKE_FAST_ALLOCATED(CSSParserValueList); |
| 75 public: | 77 public: |
| 76 CSSParserValueList() | 78 CSSParserValueList() |
| 77 : m_current(0) | 79 : m_current(0) |
| 78 { | 80 { |
| 79 } | 81 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 110 Vector<CSSParserValue, 4> m_values; | 112 Vector<CSSParserValue, 4> m_values; |
| 111 }; | 113 }; |
| 112 | 114 |
| 113 struct CSSParserFunction { | 115 struct CSSParserFunction { |
| 114 WTF_MAKE_FAST_ALLOCATED(CSSParserFunction); | 116 WTF_MAKE_FAST_ALLOCATED(CSSParserFunction); |
| 115 public: | 117 public: |
| 116 CSSValueID id; | 118 CSSValueID id; |
| 117 OwnPtr<CSSParserValueList> args; | 119 OwnPtr<CSSParserValueList> args; |
| 118 }; | 120 }; |
| 119 | 121 |
| 122 struct CSSParserCalcFunction { |
| 123 WTF_MAKE_FAST_ALLOCATED(CSSParserCalcFunction); |
| 124 public: |
| 125 CSSParserCalcFunction(CSSParserTokenRange args_) : args(args_) {} |
| 126 CSSParserTokenRange args; |
| 127 }; |
| 128 |
| 120 class CSSParserSelector { | 129 class CSSParserSelector { |
| 121 WTF_MAKE_NONCOPYABLE(CSSParserSelector); WTF_MAKE_FAST_ALLOCATED(CSSParserSe
lector); | 130 WTF_MAKE_NONCOPYABLE(CSSParserSelector); WTF_MAKE_FAST_ALLOCATED(CSSParserSe
lector); |
| 122 public: | 131 public: |
| 123 CSSParserSelector(); | 132 CSSParserSelector(); |
| 124 explicit CSSParserSelector(const QualifiedName&, bool isImplicit = false); | 133 explicit CSSParserSelector(const QualifiedName&, bool isImplicit = false); |
| 125 | 134 |
| 126 static PassOwnPtr<CSSParserSelector> create() { return adoptPtr(new CSSParse
rSelector); } | 135 static PassOwnPtr<CSSParserSelector> create() { return adoptPtr(new CSSParse
rSelector); } |
| 127 static PassOwnPtr<CSSParserSelector> create(const QualifiedName& name, bool
isImplicit = false) { return adoptPtr(new CSSParserSelector(name, isImplicit));
} | 136 static PassOwnPtr<CSSParserSelector> create(const QualifiedName& name, bool
isImplicit = false) { return adoptPtr(new CSSParserSelector(name, isImplicit));
} |
| 128 | 137 |
| 129 ~CSSParserSelector(); | 138 ~CSSParserSelector(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 } | 191 } |
| 183 | 192 |
| 184 inline void CSSParserValue::setFromOperator(UChar c) | 193 inline void CSSParserValue::setFromOperator(UChar c) |
| 185 { | 194 { |
| 186 id = CSSValueInvalid; | 195 id = CSSValueInvalid; |
| 187 m_unit = Operator; | 196 m_unit = Operator; |
| 188 iValue = c; | 197 iValue = c; |
| 189 isInt = false; | 198 isInt = false; |
| 190 } | 199 } |
| 191 | 200 |
| 192 inline void CSSParserValue::setFromFunction(CSSParserFunction* function) | |
| 193 { | |
| 194 id = CSSValueInvalid; | |
| 195 this->function = function; | |
| 196 m_unit = Function; | |
| 197 isInt = false; | |
| 198 } | |
| 199 | |
| 200 inline void CSSParserValue::setFromValueList(PassOwnPtr<CSSParserValueList> valu
eList) | 201 inline void CSSParserValue::setFromValueList(PassOwnPtr<CSSParserValueList> valu
eList) |
| 201 { | 202 { |
| 202 id = CSSValueInvalid; | 203 id = CSSValueInvalid; |
| 203 this->valueList = valueList.leakPtr(); | 204 this->valueList = valueList.leakPtr(); |
| 204 m_unit = ValueList; | 205 m_unit = ValueList; |
| 205 isInt = false; | 206 isInt = false; |
| 206 } | 207 } |
| 207 | 208 |
| 208 } | 209 } |
| 209 | 210 |
| 210 #endif | 211 #endif |
| OLD | NEW |