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 "wtf/text/AtomicString.h" | 28 #include "core/css/parser/CSSParserString.h" |
29 #include "wtf/text/WTFString.h" | |
30 | 29 |
31 namespace blink { | 30 namespace blink { |
32 | 31 |
33 class QualifiedName; | 32 class QualifiedName; |
34 class CSSParserTokenRange; | 33 class CSSParserTokenRange; |
35 | 34 |
36 struct CSSParserString { | |
37 void init(const LChar* characters, unsigned length) | |
38 { | |
39 m_data.characters8 = characters; | |
40 m_length = length; | |
41 m_is8Bit = true; | |
42 } | |
43 | |
44 void init(const UChar* characters, unsigned length) | |
45 { | |
46 m_data.characters16 = characters; | |
47 m_length = length; | |
48 m_is8Bit = false; | |
49 } | |
50 | |
51 void initRaw(const void* charactersRaw, unsigned length, bool is8Bit) | |
52 { | |
53 m_data.charactersRaw = charactersRaw; | |
54 m_length = length; | |
55 m_is8Bit = is8Bit; | |
56 } | |
57 | |
58 void init(const String& string) | |
59 { | |
60 m_length = string.length(); | |
61 if (string.isNull()) { | |
62 m_data.characters8 = 0; | |
63 m_is8Bit = true; | |
64 return; | |
65 } | |
66 if (string.is8Bit()) { | |
67 m_data.characters8 = const_cast<LChar*>(string.characters8()); | |
68 m_is8Bit = true; | |
69 } else { | |
70 m_data.characters16 = const_cast<UChar*>(string.characters16()); | |
71 m_is8Bit = false; | |
72 } | |
73 } | |
74 | |
75 bool is8Bit() const { return m_is8Bit; } | |
76 const LChar* characters8() const { ASSERT(is8Bit()); return m_data.character
s8; } | |
77 const UChar* characters16() const { ASSERT(!is8Bit()); return m_data.charact
ers16; } | |
78 | |
79 unsigned length() const { return m_length; } | |
80 | |
81 UChar operator[](unsigned i) const | |
82 { | |
83 ASSERT_WITH_SECURITY_IMPLICATION(i < m_length); | |
84 if (is8Bit()) | |
85 return m_data.characters8[i]; | |
86 return m_data.characters16[i]; | |
87 } | |
88 | |
89 bool equalIgnoringCase(const char* str) const | |
90 { | |
91 bool match = is8Bit() ? WTF::equalIgnoringCase(str, characters8(), lengt
h()) : WTF::equalIgnoringCase(str, characters16(), length()); | |
92 if (!match) | |
93 return false; | |
94 ASSERT(strlen(str) >= length()); | |
95 return str[length()] == '\0'; | |
96 } | |
97 | |
98 operator String() const { return is8Bit() ? String(m_data.characters8, m_len
gth) : StringImpl::create8BitIfPossible(m_data.characters16, m_length); } | |
99 operator AtomicString() const { return is8Bit() ? AtomicString(m_data.charac
ters8, m_length) : AtomicString(m_data.characters16, m_length); } | |
100 | |
101 union { | |
102 const LChar* characters8; | |
103 const UChar* characters16; | |
104 const void* charactersRaw; | |
105 } m_data; | |
106 unsigned m_length; | |
107 bool m_is8Bit; | |
108 }; | |
109 | |
110 struct CSSParserFunction; | 35 struct CSSParserFunction; |
111 class CSSParserValueList; | 36 class CSSParserValueList; |
112 | 37 |
113 struct CSSParserValue { | 38 struct CSSParserValue { |
114 CSSValueID id; | 39 CSSValueID id; |
115 bool isInt; | 40 bool isInt; |
116 union { | 41 union { |
117 double fValue; | 42 double fValue; |
118 int iValue; | 43 int iValue; |
119 CSSParserString string; | 44 CSSParserString string; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 { | 198 { |
274 id = CSSValueInvalid; | 199 id = CSSValueInvalid; |
275 this->valueList = valueList.leakPtr(); | 200 this->valueList = valueList.leakPtr(); |
276 unit = ValueList; | 201 unit = ValueList; |
277 isInt = false; | 202 isInt = false; |
278 } | 203 } |
279 | 204 |
280 } | 205 } |
281 | 206 |
282 #endif | 207 #endif |
OLD | NEW |