#include "core/dom/ElementTraversal.h"
#include "core/dom/NodeRareData.h"
#include "core/html/DocumentNameCollection.h"
+#include "core/html/HTMLDataListOptionsCollection.h"
#include "core/html/HTMLElement.h"
#include "core/html/HTMLObjectElement.h"
#include "core/html/HTMLOptionElement.h"
+#include "core/html/HTMLOptionsCollection.h"
#include "core/html/HTMLTagCollection.h"
#include "core/html/WindowNameCollection.h"
#include "wtf/HashSet.h"
, m_overridesItemAfter(itemAfterOverrideType == OverridesItemAfter)
, m_shouldOnlyIncludeDirectChildren(shouldTypeOnlyIncludeDirectChildren(type))
{
- ScriptWrappable::init(this);
}
PassRefPtrWillBeRawPtr<HTMLCollection> HTMLCollection::create(ContainerNode& base, CollectionType type)
void HTMLCollection::invalidateCache(Document* oldDocument) const
{
- m_collectionIndexCache.invalidate();
+ m_collectionItemsCache.invalidate();
invalidateIdNameCacheMaps(oldDocument);
}
unsigned HTMLCollection::length() const
{
- return m_collectionIndexCache.nodeCount(*this);
+ return m_collectionItemsCache.nodeCount(*this);
}
Element* HTMLCollection::item(unsigned offset) const
{
- return m_collectionIndexCache.nodeAt(*this, offset);
+ return m_collectionItemsCache.nodeAt(*this, offset);
}
static inline bool isMatchingHTMLElement(const HTMLCollection& htmlCollection, const HTMLElement& element)
return element.hasTagName(scriptTag);
case DocForms:
return element.hasTagName(formTag);
+ case DocumentNamedItems:
+ return toDocumentNameCollection(htmlCollection).elementMatches(element);
case TableTBodies:
return element.hasTagName(tbodyTag);
case TRCells:
case TSectionRows:
return element.hasTagName(trTag);
case SelectOptions:
- return element.hasTagName(optionTag);
+ return toHTMLOptionsCollection(htmlCollection).elementMatches(element);
case SelectedOptions:
return isHTMLOptionElement(element) && toHTMLOptionElement(element).selected();
case DataListOptions:
- if (isHTMLOptionElement(element)) {
- const HTMLOptionElement& option = toHTMLOptionElement(element);
- if (!option.isDisabledFormControl() && !option.value().isEmpty())
- return true;
- }
- return false;
+ return toHTMLDataListOptionsCollection(htmlCollection).elementMatches(element);
case MapAreas:
return element.hasTagName(areaTag);
case DocApplets:
case DocAll:
case NodeChildren:
case FormControls:
- case DocumentNamedItems:
case TableRows:
case WindowNamedItems:
case NameNodeListType:
return toTagCollection(*this).elementMatches(element);
case HTMLTagCollectionType:
return toHTMLTagCollection(*this).elementMatches(element);
- case DocumentNamedItems:
- return toDocumentNameCollection(*this).elementMatches(element);
case WindowNamedItems:
return toWindowNameCollection(*this).elementMatches(element);
default:
|| element.hasTagName(selectTag);
}
-Element* HTMLCollection::traverseToFirstElement() const
+Element* HTMLCollection::traverseToFirst() const
{
switch (type()) {
case HTMLTagCollectionType:
}
}
-Element* HTMLCollection::traverseToLastElement() const
+Element* HTMLCollection::traverseToLast() const
{
ASSERT(canTraverseBackward());
if (shouldOnlyIncludeDirectChildren())
void HTMLCollection::trace(Visitor* visitor)
{
visitor->trace(m_namedItemCache);
- visitor->trace(m_collectionIndexCache);
+ visitor->trace(m_collectionItemsCache);
LiveNodeListBase::trace(visitor);
}