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 CSSParserString_h | 21 #ifndef CSSParserString_h |
22 #define CSSParserString_h | 22 #define CSSParserString_h |
23 | 23 |
24 #include "wtf/Allocator.h" | 24 #include "wtf/Allocator.h" |
25 #include "wtf/text/AtomicString.h" | 25 #include "wtf/text/AtomicString.h" |
26 #include "wtf/text/StringView.h" | |
27 #include "wtf/text/WTFString.h" | 26 #include "wtf/text/WTFString.h" |
28 | 27 |
29 namespace blink { | 28 namespace blink { |
30 | 29 |
31 struct CSSParserString { | 30 struct CSSParserString { |
32 STACK_ALLOCATED(); | 31 STACK_ALLOCATED(); |
33 void init(const LChar* characters, unsigned length) | 32 void init(const LChar* characters, unsigned length) |
34 { | 33 { |
35 m_data.characters8 = characters; | 34 m_data.characters8 = characters; |
36 m_length = length; | 35 m_length = length; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 82 } |
84 | 83 |
85 template<unsigned matchLength> | 84 template<unsigned matchLength> |
86 bool equalIgnoringASCIICase(const char (&match)[matchLength]) const | 85 bool equalIgnoringASCIICase(const char (&match)[matchLength]) const |
87 { | 86 { |
88 if (matchLength - 1 != length()) | 87 if (matchLength - 1 != length()) |
89 return false; | 88 return false; |
90 return is8Bit() ? WTF::equalIgnoringASCIICase(characters8(), match, leng
th()) : WTF::equalIgnoringASCIICase(characters16(), match, length()); | 89 return is8Bit() ? WTF::equalIgnoringASCIICase(characters8(), match, leng
th()) : WTF::equalIgnoringASCIICase(characters16(), match, length()); |
91 } | 90 } |
92 | 91 |
93 // TODO(esprehn): Remove both of these implicit operators, they're very expe
nsive. | |
94 operator String() const { return is8Bit() ? String(m_data.characters8, m_len
gth) : StringImpl::create8BitIfPossible(m_data.characters16, m_length); } | 92 operator String() const { return is8Bit() ? String(m_data.characters8, m_len
gth) : StringImpl::create8BitIfPossible(m_data.characters16, m_length); } |
95 operator AtomicString() const { return is8Bit() ? AtomicString(m_data.charac
ters8, m_length) : AtomicString(m_data.characters16, m_length); } | 93 operator AtomicString() const { return is8Bit() ? AtomicString(m_data.charac
ters8, m_length) : AtomicString(m_data.characters16, m_length); } |
96 | 94 |
97 operator StringView() const { return is8Bit() ? StringView(m_data.characters
8, m_length) : StringView(m_data.characters16, m_length); } | |
98 | |
99 union { | 95 union { |
100 const LChar* characters8; | 96 const LChar* characters8; |
101 const UChar* characters16; | 97 const UChar* characters16; |
102 const void* charactersRaw; | 98 const void* charactersRaw; |
103 } m_data; | 99 } m_data; |
104 unsigned m_length; | 100 unsigned m_length; |
105 bool m_is8Bit; | 101 bool m_is8Bit; |
106 }; | 102 }; |
107 | 103 |
108 } // namespace blink | 104 } // namespace blink |
109 | 105 |
110 #endif | 106 #endif |
OLD | NEW |