#ifndef TagCollection_h
#define TagCollection_h
#include "core/dom/Element.h"
#include "core/html/HTMLCollection.h"
#include "wtf/text/AtomicString.h"
namespace WebCore {
class TagCollection : public HTMLCollection {
public:
static PassRefPtr<TagCollection> create(ContainerNode& rootNode, const AtomicString& namespaceURI, const AtomicString& localName)
{
ASSERT(namespaceURI != starAtom);
return adoptRef(new TagCollection(rootNode, TagCollectionType, namespaceURI, localName));
}
static PassRefPtr<TagCollection> create(ContainerNode& rootNode, CollectionType type, const AtomicString& localName)
{
ASSERT_UNUSED(type, type == TagCollectionType);
return adoptRef(new TagCollection(rootNode, TagCollectionType, starAtom, localName));
}
virtual ~TagCollection();
bool elementMatches(const Element&) const;
protected:
TagCollection(ContainerNode& rootNode, CollectionType, const AtomicString& namespaceURI, const AtomicString& localName);
AtomicString m_namespaceURI;
AtomicString m_localName;
};
class HTMLTagCollection FINAL : public TagCollection {
public:
static PassRefPtr<HTMLTagCollection> create(ContainerNode& rootNode, CollectionType type, const AtomicString& localName)
{
ASSERT_UNUSED(type, type == HTMLTagCollectionType);
return adoptRef(new HTMLTagCollection(rootNode, localName));
}
bool elementMatches(const Element&) const;
private:
HTMLTagCollection(ContainerNode& rootNode, const AtomicString& localName);
AtomicString m_loweredLocalName;
};
inline bool HTMLTagCollection::elementMatches(const Element& testElement) const
{
if (m_localName != starAtom) {
const AtomicString& localName = testElement.isHTMLElement() ? m_loweredLocalName : m_localName;
if (localName != testElement.localName())
return false;
}
ASSERT(m_namespaceURI == starAtom);
return true;
}
}
#endif