Chromium Code Reviews| Index: Source/core/html/HTMLCollection.h |
| diff --git a/Source/core/html/HTMLCollection.h b/Source/core/html/HTMLCollection.h |
| index 0b1601da4db92e05041f1c58827c0c1201decc90..35ad3f8a72a8e9a7b55a9b75d98a09c5c8fff085 100644 |
| --- a/Source/core/html/HTMLCollection.h |
| +++ b/Source/core/html/HTMLCollection.h |
| @@ -67,12 +67,18 @@ protected: |
| class NamedItemCache { |
| public: |
| + static PassOwnPtr<NamedItemCache> create() |
| + { |
| + return adoptPtr(new NamedItemCache); |
| + } |
| + |
| Vector<Element*>* getElementsById(const AtomicString& id) const { return m_idCache.get(id.impl()); } |
| Vector<Element*>* getElementsByName(const AtomicString& name) const { return m_nameCache.get(name.impl()); } |
| void addElementWithId(const AtomicString& id, Element* element) { addElementToMap(m_idCache, id, element); } |
| void addElementWithName(const AtomicString& name, Element* element) { addElementToMap(m_nameCache, name, element); } |
| private: |
| + NamedItemCache() { } |
|
eseidel
2014/04/08 02:12:55
Best to put all functions in the .cpp file when po
Inactive
2014/04/08 02:21:08
Done.
|
| typedef HashMap<StringImpl*, OwnPtr<Vector<Element*> > > StringToElementsMap; |
| static void addElementToMap(StringToElementsMap& map, const AtomicString& key, Element* element) |
| { |
| @@ -94,13 +100,13 @@ protected: |
| virtual void updateIdNameCache() const; |
| bool hasValidIdNameCache() const { return m_namedItemCache; } |
| - NamedItemCache& createNamedItemCache() const |
| + void setNamedItemCache(PassOwnPtr<NamedItemCache> cache) const |
| { |
| ASSERT(!m_namedItemCache); |
| document().incrementNodeListWithIdNameCacheCount(); |
| - m_namedItemCache = adoptPtr(new NamedItemCache); |
| - return *m_namedItemCache; |
| + m_namedItemCache = cache; |
| } |
| + |
| NamedItemCache& namedItemCache() const |
| { |
| ASSERT(m_namedItemCache); |