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

Side by Side Diff: Source/core/html/HTMLCollection.h

Issue 224303004: Stop passing the root node to node lists traversal functions (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/html/CollectionIndexCache.h ('k') | Source/core/html/HTMLCollection.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All r ights reserved. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All r ights reserved.
5 * Copyright (C) 2014 Samsung Electronics. All rights reserved. 5 * Copyright (C) 2014 Samsung Electronics. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 void namedPropertyEnumerator(Vector<String>& names, ExceptionState&); 52 void namedPropertyEnumerator(Vector<String>& names, ExceptionState&);
53 53
54 // Non-DOM API 54 // Non-DOM API
55 void namedItems(const AtomicString& name, Vector<RefPtr<Element> >&) const; 55 void namedItems(const AtomicString& name, Vector<RefPtr<Element> >&) const;
56 bool isEmpty() const { return m_collectionIndexCache.isEmpty(*this); } 56 bool isEmpty() const { return m_collectionIndexCache.isEmpty(*this); }
57 bool hasExactlyOneItem() const { return m_collectionIndexCache.hasExactlyOne Node(*this); } 57 bool hasExactlyOneItem() const { return m_collectionIndexCache.hasExactlyOne Node(*this); }
58 58
59 // CollectionIndexCache API. 59 // CollectionIndexCache API.
60 bool canTraverseBackward() const { return !overridesItemAfter(); } 60 bool canTraverseBackward() const { return !overridesItemAfter(); }
61 Element* itemBefore(const Element* previousItem) const; 61 Element* itemBefore(const Element* previousItem) const;
62 Element* traverseToFirstElement(const ContainerNode& root) const; 62 Element* traverseToFirstElement() const;
63 Element* traverseForwardToOffset(unsigned offset, Element& currentElement, u nsigned& currentOffset, const ContainerNode& root) const; 63 Element* traverseForwardToOffset(unsigned offset, Element& currentElement, u nsigned& currentOffset) const;
64 64
65 protected: 65 protected:
66 HTMLCollection(ContainerNode& base, CollectionType, ItemAfterOverrideType); 66 HTMLCollection(ContainerNode& base, CollectionType, ItemAfterOverrideType);
67 67
68 class NamedItemCache { 68 class NamedItemCache {
69 public: 69 public:
70 Vector<Element*>* getElementsById(const AtomicString& id) const { return m_idCache.get(id.impl()); } 70 Vector<Element*>* getElementsById(const AtomicString& id) const { return m_idCache.get(id.impl()); }
71 Vector<Element*>* getElementsByName(const AtomicString& name) const { re turn m_nameCache.get(name.impl()); } 71 Vector<Element*>* getElementsByName(const AtomicString& name) const { re turn m_nameCache.get(name.impl()); }
72 void addElementWithId(const AtomicString& id, Element* element) { addEle mentToMap(m_idCache, id, element); } 72 void addElementWithId(const AtomicString& id, Element* element) { addEle mentToMap(m_idCache, id, element); }
73 void addElementWithName(const AtomicString& name, Element* element) { ad dElementToMap(m_nameCache, name, element); } 73 void addElementWithName(const AtomicString& name, Element* element) { ad dElementToMap(m_nameCache, name, element); }
(...skipping 27 matching lines...) Expand all
101 m_namedItemCache = adoptPtr(new NamedItemCache); 101 m_namedItemCache = adoptPtr(new NamedItemCache);
102 return *m_namedItemCache; 102 return *m_namedItemCache;
103 } 103 }
104 NamedItemCache& namedItemCache() const 104 NamedItemCache& namedItemCache() const
105 { 105 {
106 ASSERT(m_namedItemCache); 106 ASSERT(m_namedItemCache);
107 return *m_namedItemCache; 107 return *m_namedItemCache;
108 } 108 }
109 109
110 private: 110 private:
111 Element* traverseNextElement(Element& previous, const ContainerNode& root) c onst; 111 Element* traverseNextElement(Element& previous) const;
112 112
113 void invalidateIdNameCacheMaps(Document* oldDocument = 0) const 113 void invalidateIdNameCacheMaps(Document* oldDocument = 0) const
114 { 114 {
115 if (!hasValidIdNameCache()) 115 if (!hasValidIdNameCache())
116 return; 116 return;
117 117
118 // Make sure we decrement the NodeListWithIdNameCache count from 118 // Make sure we decrement the NodeListWithIdNameCache count from
119 // the old document instead of the new one in the case the collection 119 // the old document instead of the new one in the case the collection
120 // is moved to a new document. 120 // is moved to a new document.
121 unregisterIdNameCacheFromDocument(oldDocument ? *oldDocument : document( )); 121 unregisterIdNameCacheFromDocument(oldDocument ? *oldDocument : document( ));
(...skipping 11 matching lines...) Expand all
133 const unsigned m_shouldOnlyIncludeDirectChildren : 1; 133 const unsigned m_shouldOnlyIncludeDirectChildren : 1;
134 mutable OwnPtr<NamedItemCache> m_namedItemCache; 134 mutable OwnPtr<NamedItemCache> m_namedItemCache;
135 mutable CollectionIndexCache<HTMLCollection, Element> m_collectionIndexCache ; 135 mutable CollectionIndexCache<HTMLCollection, Element> m_collectionIndexCache ;
136 136
137 friend class LiveNodeListBase; 137 friend class LiveNodeListBase;
138 }; 138 };
139 139
140 } // namespace 140 } // namespace
141 141
142 #endif 142 #endif
OLDNEW
« 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