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

Side by Side Diff: Source/core/dom/LiveNodeList.h

Issue 141683004: Use more const references in HTMLCollection / LiveNodeList (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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 unified diff | Download patch
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 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2006, 2007 Apple Inc. 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 { 113 {
114 ASSERT(item); 114 ASSERT(item);
115 m_cachedItem = item; 115 m_cachedItem = item;
116 m_cachedItemOffset = offset; 116 m_cachedItemOffset = offset;
117 } 117 }
118 118
119 ALWAYS_INLINE NodeListRootType rootType() const { return static_cast<NodeLis tRootType>(m_rootType); } 119 ALWAYS_INLINE NodeListRootType rootType() const { return static_cast<NodeLis tRootType>(m_rootType); }
120 bool shouldOnlyIncludeDirectChildren() const { return m_shouldOnlyIncludeDir ectChildren; } 120 bool shouldOnlyIncludeDirectChildren() const { return m_shouldOnlyIncludeDir ectChildren; }
121 121
122 private: 122 private:
123 Node* itemBeforeOrAfterCachedItem(unsigned offset, ContainerNode* root) cons t; 123 Node* itemBeforeOrAfterCachedItem(unsigned offset, const ContainerNode& root ) const;
124 bool isLastItemCloserThanLastOrCachedItem(unsigned offset) const; 124 bool isLastItemCloserThanLastOrCachedItem(unsigned offset) const;
125 bool isFirstItemCloserThanCachedItem(unsigned offset) const; 125 bool isFirstItemCloserThanCachedItem(unsigned offset) const;
126 Node* iterateForPreviousNode(Node* current) const; 126 Node* iterateForPreviousNode(Node* current) const;
127 Node* itemBefore(Node* previousItem) const; 127 Node* itemBefore(const Node* previousItem) const;
128 void invalidateIdNameCacheMaps() const; 128 void invalidateIdNameCacheMaps() const;
129 129
130 RefPtr<Node> m_ownerNode; 130 RefPtr<Node> m_ownerNode;
131 mutable Node* m_cachedItem; 131 mutable Node* m_cachedItem;
132 mutable unsigned m_cachedLength; 132 mutable unsigned m_cachedLength;
133 mutable unsigned m_cachedItemOffset; 133 mutable unsigned m_cachedItemOffset;
134 mutable unsigned m_isLengthCacheValid : 1; 134 mutable unsigned m_isLengthCacheValid : 1;
135 const unsigned m_rootType : 2; 135 const unsigned m_rootType : 2;
136 const unsigned m_invalidationType : 4; 136 const unsigned m_invalidationType : 4;
137 const unsigned m_shouldOnlyIncludeDirectChildren : 1; 137 const unsigned m_shouldOnlyIncludeDirectChildren : 1;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 class LiveNodeList : public NodeList, public LiveNodeListBase { 169 class LiveNodeList : public NodeList, public LiveNodeListBase {
170 public: 170 public:
171 LiveNodeList(PassRefPtr<Node> ownerNode, CollectionType collectionType, Node ListInvalidationType invalidationType, NodeListRootType rootType = NodeListIsRoo tedAtNode) 171 LiveNodeList(PassRefPtr<Node> ownerNode, CollectionType collectionType, Node ListInvalidationType invalidationType, NodeListRootType rootType = NodeListIsRoo tedAtNode)
172 : LiveNodeListBase(ownerNode.get(), rootType, invalidationType, collecti onType == ChildNodeListType, 172 : LiveNodeListBase(ownerNode.get(), rootType, invalidationType, collecti onType == ChildNodeListType,
173 collectionType, DoesNotOverrideItemAfter) 173 collectionType, DoesNotOverrideItemAfter)
174 { } 174 { }
175 175
176 virtual unsigned length() const OVERRIDE FINAL { return LiveNodeListBase::le ngth(); } 176 virtual unsigned length() const OVERRIDE FINAL { return LiveNodeListBase::le ngth(); }
177 virtual Node* item(unsigned offset) const OVERRIDE FINAL { return LiveNodeLi stBase::item(offset); } 177 virtual Node* item(unsigned offset) const OVERRIDE FINAL { return LiveNodeLi stBase::item(offset); }
178 virtual Node* namedItem(const AtomicString&) const OVERRIDE FINAL; 178 virtual Node* namedItem(const AtomicString&) const OVERRIDE FINAL;
179 virtual bool nodeMatches(Element*) const = 0; 179 virtual bool nodeMatches(const Element&) const = 0;
180 // Avoid ambiguity since both NodeList and LiveNodeListBase have an ownerNod e() method. 180 // Avoid ambiguity since both NodeList and LiveNodeListBase have an ownerNod e() method.
181 using LiveNodeListBase::ownerNode; 181 using LiveNodeListBase::ownerNode;
182 182
183 Node* traverseToFirstElement(ContainerNode& root) const; 183 Node* traverseToFirstElement(const ContainerNode& root) const;
184 Node* traverseForwardToOffset(unsigned offset, Node& currentNode, unsigned& currentOffset, ContainerNode* root) const; 184 Node* traverseForwardToOffset(unsigned offset, Node& currentNode, unsigned& currentOffset, const ContainerNode& root) const;
185 185
186 private: 186 private:
187 virtual bool isLiveNodeList() const OVERRIDE FINAL { return true; } 187 virtual bool isLiveNodeList() const OVERRIDE FINAL { return true; }
188 }; 188 };
189 189
190 } // namespace WebCore 190 } // namespace WebCore
191 191
192 #endif // LiveNodeList_h 192 #endif // LiveNodeList_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698