#ifndef TagNodeList_h
#define TagNodeList_h
#include "Element.h"
#include "LiveNodeList.h"
#include <wtf/text/AtomicString.h>
namespace WebCore {
class TagNodeList final : public CachedLiveNodeList<TagNodeList> {
public:
static PassRef<TagNodeList> create(ContainerNode& rootNode, const AtomicString& namespaceURI, const AtomicString& localName)
{
ASSERT(namespaceURI != starAtom);
return adoptRef(*new TagNodeList(rootNode, namespaceURI, localName));
}
static PassRef<TagNodeList> create(ContainerNode& rootNode, const AtomicString& localName)
{
return adoptRef(*new TagNodeList(rootNode, starAtom, localName));
}
virtual ~TagNodeList();
virtual bool nodeMatches(Element*) const override;
virtual bool isRootedAtDocument() const override { return false; }
protected:
TagNodeList(ContainerNode& rootNode, const AtomicString& namespaceURI, const AtomicString& localName);
AtomicString m_namespaceURI;
AtomicString m_localName;
};
inline bool TagNodeList::nodeMatches(Element* element) const
{
if (m_localName != starAtom && m_localName != element->localName())
return false;
return m_namespaceURI == starAtom || m_namespaceURI == element->namespaceURI();
}
class HTMLTagNodeList final : public CachedLiveNodeList<HTMLTagNodeList> {
public:
static PassRef<HTMLTagNodeList> create(ContainerNode& rootNode, const AtomicString& localName)
{
return adoptRef(*new HTMLTagNodeList(rootNode, localName));
}
virtual ~HTMLTagNodeList();
virtual bool nodeMatches(Element*) const override;
virtual bool isRootedAtDocument() const override { return false; }
private:
HTMLTagNodeList(ContainerNode& rootNode, const AtomicString& localName);
AtomicString m_localName;
AtomicString m_loweredLocalName;
};
inline bool HTMLTagNodeList::nodeMatches(Element* element) const
{
if (m_localName == starAtom)
return true;
const AtomicString& localName = element->isHTMLElement() ? m_loweredLocalName : m_localName;
return localName == element->localName();
}
}
#endif // TagNodeList_h