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