Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(614)

Side by Side Diff: Source/core/dom/QualifiedName.h

Issue 136063002: Use a RefPtr to store implementation in QualifiedName (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/dom/QualifiedName.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 : m_existingHash(0) 60 : m_existingHash(0)
61 , m_prefix(prefix) 61 , m_prefix(prefix)
62 , m_localName(localName) 62 , m_localName(localName)
63 , m_namespace(namespaceURI) 63 , m_namespace(namespaceURI)
64 { 64 {
65 ASSERT(!namespaceURI.isEmpty() || namespaceURI.isNull()); 65 ASSERT(!namespaceURI.isEmpty() || namespaceURI.isNull());
66 } 66 }
67 }; 67 };
68 68
69 QualifiedName(const AtomicString& prefix, const AtomicString& localName, con st AtomicString& namespaceURI); 69 QualifiedName(const AtomicString& prefix, const AtomicString& localName, con st AtomicString& namespaceURI);
70 QualifiedName(WTF::HashTableDeletedValueType) : m_impl(hashTableDeletedValue ()) { }
71 bool isHashTableDeletedValue() const { return m_impl == hashTableDeletedValu e(); }
72 ~QualifiedName(); 70 ~QualifiedName();
73 #ifdef QNAME_DEFAULT_CONSTRUCTOR 71 #ifdef QNAME_DEFAULT_CONSTRUCTOR
74 QualifiedName() : m_impl(0) { } 72 QualifiedName() { }
75 #endif 73 #endif
76 74
77 QualifiedName(const QualifiedName& other) : m_impl(other.m_impl) { ref(); } 75 QualifiedName(const QualifiedName& other) : m_impl(other.m_impl) { }
78 const QualifiedName& operator=(const QualifiedName& other) { other.ref(); de ref(); m_impl = other.m_impl; return *this; } 76 const QualifiedName& operator=(const QualifiedName& other) { m_impl = other. m_impl; return *this; }
77
78 // Hash table deleted values, which are only constructed and never copied or destroyed.
79 QualifiedName(WTF::HashTableDeletedValueType) : m_impl(WTF::HashTableDeleted Value) { }
80 bool isHashTableDeletedValue() const { return m_impl.isHashTableDeletedValue (); }
79 81
80 bool operator==(const QualifiedName& other) const { return m_impl == other.m _impl; } 82 bool operator==(const QualifiedName& other) const { return m_impl == other.m _impl; }
81 bool operator!=(const QualifiedName& other) const { return !(*this == other) ; } 83 bool operator!=(const QualifiedName& other) const { return !(*this == other) ; }
82 84
83 bool matches(const QualifiedName& other) const { return m_impl == other.m_im pl || (localName() == other.localName() && namespaceURI() == other.namespaceURI( )); } 85 bool matches(const QualifiedName& other) const { return m_impl == other.m_im pl || (localName() == other.localName() && namespaceURI() == other.namespaceURI( )); }
84 86
85 bool matchesPossiblyIgnoringCase(const QualifiedName& other, bool shouldIgno reCase) const { return m_impl == other.m_impl || (equalPossiblyIgnoringCase(loca lName(), other.localName(), shouldIgnoreCase) && namespaceURI() == other.namespa ceURI()); } 87 bool matchesPossiblyIgnoringCase(const QualifiedName& other, bool shouldIgno reCase) const { return m_impl == other.m_impl || (equalPossiblyIgnoringCase(loca lName(), other.localName(), shouldIgnoreCase) && namespaceURI() == other.namespa ceURI()); }
86 88
87 bool hasPrefix() const { return m_impl->m_prefix != nullAtom; } 89 bool hasPrefix() const { return m_impl->m_prefix != nullAtom; }
88 void setPrefix(const AtomicString& prefix) { *this = QualifiedName(prefix, l ocalName(), namespaceURI()); } 90 void setPrefix(const AtomicString& prefix) { *this = QualifiedName(prefix, l ocalName(), namespaceURI()); }
89 91
90 const AtomicString& prefix() const { return m_impl->m_prefix; } 92 const AtomicString& prefix() const { return m_impl->m_prefix; }
91 const AtomicString& localName() const { return m_impl->m_localName; } 93 const AtomicString& localName() const { return m_impl->m_localName; }
92 const AtomicString& namespaceURI() const { return m_impl->m_namespace; } 94 const AtomicString& namespaceURI() const { return m_impl->m_namespace; }
93 95
94 // Uppercased localName, cached for efficiency 96 // Uppercased localName, cached for efficiency
95 const AtomicString& localNameUpper() const; 97 const AtomicString& localNameUpper() const;
96 98
97 String toString() const; 99 String toString() const;
98 100
99 QualifiedNameImpl* impl() const { return m_impl; } 101 QualifiedNameImpl* impl() const { return m_impl.get(); }
100 102
101 // Init routine for globals 103 // Init routine for globals
102 static void init(); 104 static void init();
103 105
104 private: 106 private:
105 void ref() const { m_impl->ref(); } 107 RefPtr<QualifiedNameImpl> m_impl;
106 void deref();
107
108 static QualifiedNameImpl* hashTableDeletedValue() { return RefPtr<QualifiedN ameImpl>::hashTableDeletedValue(); }
109
110 QualifiedNameImpl* m_impl;
111 }; 108 };
112 109
113 #ifndef WEBCORE_QUALIFIEDNAME_HIDE_GLOBALS 110 #ifndef WEBCORE_QUALIFIEDNAME_HIDE_GLOBALS
114 extern const QualifiedName anyName; 111 extern const QualifiedName anyName;
115 inline const QualifiedName& anyQName() { return anyName; } 112 inline const QualifiedName& anyQName() { return anyName; }
116 #endif 113 #endif
117 114
118 const QualifiedName& nullQName(); 115 const QualifiedName& nullQName();
119 116
120 inline bool operator==(const AtomicString& a, const QualifiedName& q) { return a == q.localName(); } 117 inline bool operator==(const AtomicString& a, const QualifiedName& q) { return a == q.localName(); }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 typedef WebCore::QualifiedNameHash Hash; 153 typedef WebCore::QualifiedNameHash Hash;
157 }; 154 };
158 155
159 template<> struct HashTraits<WebCore::QualifiedName> : SimpleClassHashTraits <WebCore::QualifiedName> { 156 template<> struct HashTraits<WebCore::QualifiedName> : SimpleClassHashTraits <WebCore::QualifiedName> {
160 static const bool emptyValueIsZero = false; 157 static const bool emptyValueIsZero = false;
161 static WebCore::QualifiedName emptyValue() { return WebCore::nullQName() ; } 158 static WebCore::QualifiedName emptyValue() { return WebCore::nullQName() ; }
162 }; 159 };
163 } 160 }
164 161
165 #endif 162 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/QualifiedName.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698