OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 * | 18 * |
19 */ | 19 */ |
20 | 20 |
21 #ifndef QualifiedName_h | 21 #ifndef QualifiedName_h |
22 #define QualifiedName_h | 22 #define QualifiedName_h |
23 | 23 |
24 #include "core/CoreExport.h" | 24 #include "core/CoreExport.h" |
| 25 #include "wtf/Allocator.h" |
25 #include "wtf/HashTableDeletedValueType.h" | 26 #include "wtf/HashTableDeletedValueType.h" |
26 #include "wtf/HashTraits.h" | 27 #include "wtf/HashTraits.h" |
27 #include "wtf/RefCounted.h" | 28 #include "wtf/RefCounted.h" |
28 #include "wtf/text/AtomicString.h" | 29 #include "wtf/text/AtomicString.h" |
29 | 30 |
30 namespace blink { | 31 namespace blink { |
31 | 32 |
32 struct QualifiedNameComponents { | 33 struct QualifiedNameComponents { |
| 34 DISALLOW_ALLOCATION(); |
33 StringImpl* m_prefix; | 35 StringImpl* m_prefix; |
34 StringImpl* m_localName; | 36 StringImpl* m_localName; |
35 StringImpl* m_namespace; | 37 StringImpl* m_namespace; |
36 }; | 38 }; |
37 | 39 |
38 // This struct is used to pass data between QualifiedName and the QNameTranslato
r. | 40 // This struct is used to pass data between QualifiedName and the QNameTranslato
r. |
39 // For hashing and equality only the QualifiedNameComponents fields are used. | 41 // For hashing and equality only the QualifiedNameComponents fields are used. |
40 struct QualifiedNameData { | 42 struct QualifiedNameData { |
| 43 DISALLOW_ALLOCATION(); |
41 QualifiedNameComponents m_components; | 44 QualifiedNameComponents m_components; |
42 bool m_isStatic; | 45 bool m_isStatic; |
43 }; | 46 }; |
44 | 47 |
45 class CORE_EXPORT QualifiedName { | 48 class CORE_EXPORT QualifiedName { |
46 WTF_MAKE_FAST_ALLOCATED(QualifiedName); | 49 WTF_MAKE_FAST_ALLOCATED(QualifiedName); |
47 public: | 50 public: |
48 class QualifiedNameImpl : public RefCounted<QualifiedNameImpl> { | 51 class QualifiedNameImpl : public RefCounted<QualifiedNameImpl> { |
49 public: | 52 public: |
50 static PassRefPtr<QualifiedNameImpl> create(const AtomicString& prefix,
const AtomicString& localName, const AtomicString& namespaceURI, bool isStatic) | 53 static PassRefPtr<QualifiedNameImpl> create(const AtomicString& prefix,
const AtomicString& localName, const AtomicString& namespaceURI, bool isStatic) |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 inline bool operator!=(const AtomicString& a, const QualifiedName& q) { return a
!= q.localName(); } | 149 inline bool operator!=(const AtomicString& a, const QualifiedName& q) { return a
!= q.localName(); } |
147 inline bool operator==(const QualifiedName& q, const AtomicString& a) { return a
== q.localName(); } | 150 inline bool operator==(const QualifiedName& q, const AtomicString& a) { return a
== q.localName(); } |
148 inline bool operator!=(const QualifiedName& q, const AtomicString& a) { return a
!= q.localName(); } | 151 inline bool operator!=(const QualifiedName& q, const AtomicString& a) { return a
!= q.localName(); } |
149 | 152 |
150 inline unsigned hashComponents(const QualifiedNameComponents& buf) | 153 inline unsigned hashComponents(const QualifiedNameComponents& buf) |
151 { | 154 { |
152 return StringHasher::hashMemory<sizeof(QualifiedNameComponents)>(&buf); | 155 return StringHasher::hashMemory<sizeof(QualifiedNameComponents)>(&buf); |
153 } | 156 } |
154 | 157 |
155 struct QualifiedNameHash { | 158 struct QualifiedNameHash { |
| 159 STATIC_ONLY(QualifiedNameHash); |
156 static unsigned hash(const QualifiedName& name) { return hash(name.impl());
} | 160 static unsigned hash(const QualifiedName& name) { return hash(name.impl());
} |
157 | 161 |
158 static unsigned hash(const QualifiedName::QualifiedNameImpl* name) | 162 static unsigned hash(const QualifiedName::QualifiedNameImpl* name) |
159 { | 163 { |
160 if (!name->m_existingHash) | 164 if (!name->m_existingHash) |
161 name->m_existingHash = name->computeHash(); | 165 name->m_existingHash = name->computeHash(); |
162 return name->m_existingHash; | 166 return name->m_existingHash; |
163 } | 167 } |
164 | 168 |
165 static bool equal(const QualifiedName& a, const QualifiedName& b) { return a
== b; } | 169 static bool equal(const QualifiedName& a, const QualifiedName& b) { return a
== b; } |
(...skipping 10 matching lines...) Expand all Loading... |
176 typedef blink::QualifiedNameHash Hash; | 180 typedef blink::QualifiedNameHash Hash; |
177 }; | 181 }; |
178 | 182 |
179 template<> struct HashTraits<blink::QualifiedName> : SimpleClassHashTraits<blink
::QualifiedName> { | 183 template<> struct HashTraits<blink::QualifiedName> : SimpleClassHashTraits<blink
::QualifiedName> { |
180 static const bool emptyValueIsZero = false; | 184 static const bool emptyValueIsZero = false; |
181 static blink::QualifiedName emptyValue() { return blink::QualifiedName::null
(); } | 185 static blink::QualifiedName emptyValue() { return blink::QualifiedName::null
(); } |
182 }; | 186 }; |
183 } | 187 } |
184 | 188 |
185 #endif | 189 #endif |
OLD | NEW |