HTMLNameCollection.cpp [plain text]
#include "config.h"
#include "HTMLNameCollection.h"
#include "Element.h"
#include "HTMLAppletElement.h"
#include "HTMLEmbedElement.h"
#include "HTMLFormElement.h"
#include "HTMLIFrameElement.h"
#include "HTMLImageElement.h"
#include "HTMLNames.h"
#include "HTMLObjectElement.h"
#include "NodeRareData.h"
#include "NodeTraversal.h"
#include <wtf/IsoMallocInlines.h>
namespace WebCore {
using namespace HTMLNames;
WTF_MAKE_ISO_ALLOCATED_IMPL(WindowNameCollection);
WTF_MAKE_ISO_ALLOCATED_IMPL(DocumentNameCollection);
bool WindowNameCollection::elementMatchesIfNameAttributeMatch(const Element& element)
{
return is<HTMLAppletElement>(element)
|| is<HTMLEmbedElement>(element)
|| is<HTMLFormElement>(element)
|| is<HTMLImageElement>(element)
|| is<HTMLObjectElement>(element);
}
bool WindowNameCollection::elementMatches(const Element& element, const AtomStringImpl* name)
{
return (elementMatchesIfNameAttributeMatch(element) && element.getNameAttribute().impl() == name)
|| element.getIdAttribute() == name;
}
static inline bool isObjectElementForDocumentNameCollection(const Element& element)
{
return is<HTMLObjectElement>(element) && downcast<HTMLObjectElement>(element).isExposed();
}
bool DocumentNameCollection::elementMatchesIfIdAttributeMatch(const Element& element)
{
return isObjectElementForDocumentNameCollection(element)
|| is<HTMLAppletElement>(element)
|| (is<HTMLImageElement>(element) && element.hasName() && !element.getNameAttribute().isEmpty());
}
bool DocumentNameCollection::elementMatchesIfNameAttributeMatch(const Element& element)
{
return isObjectElementForDocumentNameCollection(element)
|| is<HTMLAppletElement>(element)
|| is<HTMLEmbedElement>(element)
|| is<HTMLFormElement>(element)
|| is<HTMLIFrameElement>(element)
|| is<HTMLImageElement>(element);
}
bool DocumentNameCollection::elementMatches(const Element& element, const AtomStringImpl* name)
{
return (elementMatchesIfNameAttributeMatch(element) && element.getNameAttribute().impl() == name)
|| (elementMatchesIfIdAttributeMatch(element) && element.getIdAttribute().impl() == name);
}
}