#include "config.h"
#include "TagNodeList.h"
#include "Element.h"
#include "NodeRareData.h"
#include <wtf/Assertions.h>
namespace WebCore {
TagNodeList::TagNodeList(PassRefPtr<Node> rootNode, CollectionType type, const AtomicString& namespaceURI, const AtomicString& localName)
: LiveNodeList(rootNode, type, DoNotInvalidateOnAttributeChanges)
, m_namespaceURI(namespaceURI)
, m_localName(localName)
{
ASSERT(m_namespaceURI.isNull() || !m_namespaceURI.isEmpty());
}
TagNodeList::~TagNodeList()
{
if (m_namespaceURI == starAtom)
ownerNode()->nodeLists()->removeCacheWithAtomicName(this, type(), m_localName);
else
ownerNode()->nodeLists()->removeCacheWithQualifiedName(this, m_namespaceURI, m_localName);
}
bool TagNodeList::nodeMatches(Element* testNode) const
{
if (m_localName != starAtom && m_localName != testNode->localName())
return false;
return m_namespaceURI == starAtom || m_namespaceURI == testNode->namespaceURI();
}
HTMLTagNodeList::HTMLTagNodeList(PassRefPtr<Node> rootNode, const AtomicString& localName)
: TagNodeList(rootNode, HTMLTagNodeListType, starAtom, localName)
, m_loweredLocalName(localName.lower())
{
}
bool HTMLTagNodeList::nodeMatches(Element* testNode) const
{
return nodeMatchesInlined(testNode);
}
}