#include "config.h"
#ifdef SKIP_STATIC_CONSTRUCTORS_ON_GCC
#define WEBCORE_QUALIFIEDNAME_HIDE_GLOBALS 1
#else
#define QNAME_DEFAULT_CONSTRUCTOR
#endif
#include "QualifiedName.h"
#include "QualifiedNameCache.h"
#include "ThreadGlobalData.h"
#include <wtf/Assertions.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/StaticConstructors.h>
namespace WebCore {
QualifiedName::QualifiedName(const AtomicString& p, const AtomicString& l, const AtomicString& n)
: m_impl(threadGlobalData().qualifiedNameCache().getOrCreate(QualifiedNameComponents { p.impl(), l.impl(), n.isEmpty() ? nullptr : n.impl() }))
{
}
QualifiedName::QualifiedNameImpl::~QualifiedNameImpl()
{
threadGlobalData().qualifiedNameCache().remove(*this);
}
DEFINE_GLOBAL(QualifiedName, anyName, nullAtom(), starAtom(), starAtom())
void QualifiedName::init()
{
static bool initialized = false;
if (initialized)
return;
AtomicString::init();
new (NotNull, (void*)&anyName) QualifiedName(nullAtom(), starAtom(), starAtom());
initialized = true;
}
const QualifiedName& nullQName()
{
static NeverDestroyed<QualifiedName> nullName(nullAtom(), nullAtom(), nullAtom());
return nullName;
}
const AtomicString& QualifiedName::localNameUpper() const
{
if (!m_impl->m_localNameUpper)
m_impl->m_localNameUpper = m_impl->m_localName.convertToASCIIUppercase();
return m_impl->m_localNameUpper;
}
unsigned QualifiedName::QualifiedNameImpl::computeHash() const
{
QualifiedNameComponents components = { m_prefix.impl(), m_localName.impl(), m_namespace.impl() };
return hashComponents(components);
}
void createQualifiedName(void* targetAddress, StringImpl* name, const AtomicString& nameNamespace)
{
new (NotNull, reinterpret_cast<void*>(targetAddress)) QualifiedName(nullAtom(), AtomicString(name), nameNamespace);
}
void createQualifiedName(void* targetAddress, StringImpl* name)
{
new (NotNull, reinterpret_cast<void*>(targetAddress)) QualifiedName(nullAtom(), AtomicString(name), nullAtom());
}
}