This source file includes following definitions.
- create
- namedItemWithIndex
- namedGetter
#include "config.h"
#include "core/html/HTMLAllCollection.h"
#include "core/dom/Element.h"
#include "core/dom/NamedNodesCollection.h"
namespace WebCore {
PassRefPtr<HTMLAllCollection> HTMLAllCollection::create(ContainerNode& node, CollectionType type)
{
return adoptRef(new HTMLAllCollection(node, type));
}
HTMLAllCollection::HTMLAllCollection(ContainerNode& node, CollectionType type)
: HTMLCollection(node, type, DoesNotOverrideItemAfter)
{
ScriptWrappable::init(this);
}
HTMLAllCollection::~HTMLAllCollection()
{
}
Element* HTMLAllCollection::namedItemWithIndex(const AtomicString& name, unsigned index) const
{
updateIdNameCache();
const NamedItemCache& cache = namedItemCache();
if (Vector<Element*>* elements = cache.getElementsById(name)) {
if (index < elements->size())
return elements->at(index);
index -= elements->size();
}
if (Vector<Element*>* elements = cache.getElementsByName(name)) {
if (index < elements->size())
return elements->at(index);
}
return 0;
}
void HTMLAllCollection::namedGetter(const AtomicString& name, bool& returnValue0Enabled, RefPtr<NodeList>& returnValue0, bool& returnValue1Enabled, RefPtr<Element>& returnValue1)
{
Vector<RefPtr<Element> > namedItems;
this->namedItems(name, namedItems);
if (!namedItems.size())
return;
if (namedItems.size() == 1) {
returnValue1Enabled = true;
returnValue1 = namedItems.at(0);
return;
}
returnValue0Enabled = true;
returnValue0 = NamedNodesCollection::create(namedItems);
}
}