Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(561)

Unified Diff: Source/core/html/HTMLCollection.h

Issue 134193005: Move caching out of LiveNodeListBase and into a new CollectionIndexCache class (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/CollectionIndexCache.h ('k') | Source/core/html/HTMLCollection.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLCollection.h
diff --git a/Source/core/html/HTMLCollection.h b/Source/core/html/HTMLCollection.h
index 6cf8122752a482d7174e32e10907c49dffb56064..26aff438926a2c8925f931130e8822e4ed6ec42a 100644
--- a/Source/core/html/HTMLCollection.h
+++ b/Source/core/html/HTMLCollection.h
@@ -38,31 +38,20 @@ public:
virtual void invalidateCache() const OVERRIDE;
// DOM API
+ unsigned length() const { return m_collectionIndexCache.nodeCount(*this); }
+ Node* item(unsigned offset) const { return m_collectionIndexCache.nodeAt(*this, offset); }
virtual Element* namedItem(const AtomicString& name) const;
// Non-DOM API
void namedItems(const AtomicString& name, Vector<RefPtr<Element> >&) const;
- bool isEmpty() const
- {
- if (isLengthCacheValid())
- return !cachedLength();
- if (cachedItem())
- return false;
- return !item(0);
- }
- bool hasExactlyOneItem() const
- {
- if (isLengthCacheValid())
- return cachedLength() == 1;
- if (cachedItem())
- return !cachedItemOffset() && !item(1);
- return item(0) && !item(1);
- }
+ bool isEmpty() const { return m_collectionIndexCache.isEmpty(*this); }
+ bool hasExactlyOneItem() const { return m_collectionIndexCache.hasExactlyOneNode(*this); }
virtual Element* virtualItemAfter(Element*) const;
+ // CollectionIndexCache API.
Element* traverseToFirstElement(const ContainerNode& root) const;
- Element* traverseForwardToOffset(unsigned offset, Element& currentElement, unsigned& currentOffset, const ContainerNode& root) const;
+ Element* traverseForwardToOffset(unsigned offset, Node& currentElement, unsigned& currentOffset, const ContainerNode& root) const;
protected:
HTMLCollection(ContainerNode* base, CollectionType, ItemAfterOverrideType);
@@ -92,6 +81,7 @@ private:
mutable unsigned m_isNameCacheValid : 1;
mutable NodeCacheMap m_idCache;
mutable NodeCacheMap m_nameCache;
+ mutable CollectionIndexCache<HTMLCollection> m_collectionIndexCache;
friend class LiveNodeListBase;
};
« no previous file with comments | « Source/core/html/CollectionIndexCache.h ('k') | Source/core/html/HTMLCollection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698