diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/dom/QualifiedName.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/dom/QualifiedName.h')
-rw-r--r-- | Source/WebCore/dom/QualifiedName.h | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/Source/WebCore/dom/QualifiedName.h b/Source/WebCore/dom/QualifiedName.h index c64ac2dd1..ce03e9ad6 100644 --- a/Source/WebCore/dom/QualifiedName.h +++ b/Source/WebCore/dom/QualifiedName.h @@ -18,8 +18,7 @@ * */ -#ifndef QualifiedName_h -#define QualifiedName_h +#pragma once #include <wtf/Forward.h> #include <wtf/HashTraits.h> @@ -39,12 +38,12 @@ class QualifiedName { public: class QualifiedNameImpl : public RefCounted<QualifiedNameImpl> { public: - static PassRefPtr<QualifiedNameImpl> create(const AtomicString& prefix, const AtomicString& localName, const AtomicString& namespaceURI) + static Ref<QualifiedNameImpl> create(const AtomicString& prefix, const AtomicString& localName, const AtomicString& namespaceURI) { - return adoptRef(new QualifiedNameImpl(prefix, localName, namespaceURI)); + return adoptRef(*new QualifiedNameImpl(prefix, localName, namespaceURI)); } - ~QualifiedNameImpl(); + WEBCORE_EXPORT ~QualifiedNameImpl(); unsigned computeHash() const; @@ -54,10 +53,10 @@ public: const AtomicString m_namespace; mutable AtomicString m_localNameUpper; -#if ENABLE(CSS_SELECTOR_JIT) +#if ENABLE(JIT) static ptrdiff_t localNameMemoryOffset() { return OBJECT_OFFSETOF(QualifiedNameImpl, m_localName); } static ptrdiff_t namespaceMemoryOffset() { return OBJECT_OFFSETOF(QualifiedNameImpl, m_namespace); } -#endif // ENABLE(CSS_SELECTOR_JIT) +#endif // ENABLE(JIT) private: QualifiedNameImpl(const AtomicString& prefix, const AtomicString& localName, const AtomicString& namespaceURI) @@ -70,24 +69,18 @@ public: } }; - QualifiedName(const AtomicString& prefix, const AtomicString& localName, const AtomicString& namespaceURI); - explicit QualifiedName(WTF::HashTableDeletedValueType) : m_impl(hashTableDeletedValue()) { } - bool isHashTableDeletedValue() const { return m_impl == hashTableDeletedValue(); } - ~QualifiedName(); + WEBCORE_EXPORT QualifiedName(const AtomicString& prefix, const AtomicString& localName, const AtomicString& namespaceURI); + explicit QualifiedName(WTF::HashTableDeletedValueType) : m_impl(WTF::HashTableDeletedValue) { } + bool isHashTableDeletedValue() const { return m_impl.isHashTableDeletedValue(); } #ifdef QNAME_DEFAULT_CONSTRUCTOR - QualifiedName() : m_impl(0) { } + QualifiedName() { } #endif - QualifiedName(const QualifiedName& other) : m_impl(other.m_impl) { ref(); } - const QualifiedName& operator=(const QualifiedName& other) { other.ref(); deref(); m_impl = other.m_impl; return *this; } - bool operator==(const QualifiedName& other) const { return m_impl == other.m_impl; } bool operator!=(const QualifiedName& other) const { return !(*this == other); } bool matches(const QualifiedName& other) const { return m_impl == other.m_impl || (localName() == other.localName() && namespaceURI() == other.namespaceURI()); } - bool matchesIgnoringCaseForLocalName(const QualifiedName& other, bool shouldIgnoreCase) const { return m_impl == other.m_impl || (equalPossiblyIgnoringCase(localName(), other.localName(), shouldIgnoreCase) && namespaceURI() == other.namespaceURI()); } - bool hasPrefix() const { return m_impl->m_prefix != nullAtom; } void setPrefix(const AtomicString& prefix) { *this = QualifiedName(prefix, localName(), namespaceURI()); } @@ -100,21 +93,18 @@ public: String toString() const; - QualifiedNameImpl* impl() const { return m_impl; } -#if ENABLE(CSS_SELECTOR_JIT) + QualifiedNameImpl* impl() const { return m_impl.get(); } +#if ENABLE(JIT) static ptrdiff_t implMemoryOffset() { return OBJECT_OFFSETOF(QualifiedName, m_impl); } -#endif // ENABLE(CSS_SELECTOR_JIT) +#endif // ENABLE(JIT) // Init routine for globals static void init(); private: - void ref() const { m_impl->ref(); } - void deref(); - static QualifiedNameImpl* hashTableDeletedValue() { return RefPtr<QualifiedNameImpl>::hashTableDeletedValue(); } - QualifiedNameImpl* m_impl; + RefPtr<QualifiedNameImpl> m_impl; }; #ifndef WEBCORE_QUALIFIEDNAME_HIDE_GLOBALS @@ -153,8 +143,16 @@ struct QualifiedNameHash { void createQualifiedName(void* targetAddress, StringImpl* name); void createQualifiedName(void* targetAddress, StringImpl* name, const AtomicString& nameNamespace); +inline String QualifiedName::toString() const +{ + if (!hasPrefix()) + return localName(); + + return prefix().string() + ':' + localName().string(); } +} // namespace WebCore + namespace WTF { template<typename T> struct DefaultHash; @@ -167,6 +165,5 @@ namespace WTF { static const bool emptyValueIsZero = false; static WebCore::QualifiedName emptyValue() { return WebCore::nullQName(); } }; -} -#endif +} // namespace WTF |