Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / dom / LiveNodeList.h
index b9128e4..04c6d5b 100644 (file)
 
 #include "core/dom/LiveNodeListBase.h"
 #include "core/dom/NodeList.h"
-#include "core/html/CollectionIndexCache.h"
+#include "core/html/CollectionItemsCache.h"
 #include "core/html/CollectionType.h"
+#include "platform/heap/Handle.h"
 #include "wtf/PassRefPtr.h"
 
-namespace WebCore {
+namespace blink {
 
 class Element;
 
 class LiveNodeList : public NodeList, public LiveNodeListBase {
+    WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(LiveNodeList);
 public:
     LiveNodeList(ContainerNode& ownerNode, CollectionType collectionType, NodeListInvalidationType invalidationType, NodeListRootType rootType = NodeListIsRootedAtNode)
-        : LiveNodeListBase(ownerNode, rootType, invalidationType,
-        collectionType)
-    { }
+        : LiveNodeListBase(ownerNode, rootType, invalidationType, collectionType) { }
 
-    virtual unsigned length() const OVERRIDE FINAL { return m_collectionIndexCache.nodeCount(*this); }
-    virtual Node* item(unsigned offset) const OVERRIDE FINAL { return m_collectionIndexCache.nodeAt(*this, offset); }
+    virtual unsigned length() const OVERRIDE FINAL;
+    virtual Element* item(unsigned offset) const OVERRIDE FINAL;
     virtual bool elementMatches(const Element&) const = 0;
 
-    virtual void invalidateCache(Document* oldDocument) const OVERRIDE FINAL;
-    bool shouldOnlyIncludeDirectChildren() const { return false; }
+    virtual void invalidateCache(Document* oldDocument = 0) const OVERRIDE FINAL;
+    void invalidateCacheForAttribute(const QualifiedName*) const;
 
     // Collection IndexCache API.
     bool canTraverseBackward() const { return true; }
-    Element* itemBefore(const Element* previousItem) const;
-    Element* traverseToFirstElement(const ContainerNode& root) const;
-    Element* traverseForwardToOffset(unsigned offset, Element& currentNode, unsigned& currentOffset, const ContainerNode& root) const;
+    Element* traverseToFirst() const;
+    Element* traverseToLast() const;
+    Element* traverseForwardToOffset(unsigned offset, Element& currentNode, unsigned& currentOffset) const;
+    Element* traverseBackwardToOffset(unsigned offset, Element& currentNode, unsigned& currentOffset) const;
+
+    virtual void trace(Visitor*) OVERRIDE;
 
 private:
     virtual Node* virtualOwnerNode() const OVERRIDE FINAL;
 
-    mutable CollectionIndexCache<LiveNodeList, Element> m_collectionIndexCache;
+    mutable CollectionItemsCache<LiveNodeList, Element> m_collectionItemsCache;
 };
 
-} // namespace WebCore
+DEFINE_TYPE_CASTS(LiveNodeList, LiveNodeListBase, list, isLiveNodeListType(list->type()), isLiveNodeListType(list.type()));
+
+inline void LiveNodeList::invalidateCacheForAttribute(const QualifiedName* attrName) const
+{
+    if (!attrName || shouldInvalidateTypeOnAttributeChange(invalidationType(), *attrName))
+        invalidateCache();
+}
+
+} // namespace blink
 
 #endif // LiveNodeList_h