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

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

Issue 130753004: Move isNameCacheValid member from LiveNodeListBase to HTMLCollection (Closed) Base URL: svn://svn.chromium.org/blink/trunk
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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/dom/LiveNodeList.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 * (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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 LiveNodeListBase(Node* ownerNode, NodeListRootType rootType, NodeListInvalid ationType invalidationType, 51 LiveNodeListBase(Node* ownerNode, NodeListRootType rootType, NodeListInvalid ationType invalidationType,
52 bool shouldOnlyIncludeDirectChildren, CollectionType collectionType, Ite mAfterOverrideType itemAfterOverrideType) 52 bool shouldOnlyIncludeDirectChildren, CollectionType collectionType, Ite mAfterOverrideType itemAfterOverrideType)
53 : m_ownerNode(ownerNode) 53 : m_ownerNode(ownerNode)
54 , m_cachedItem(0) 54 , m_cachedItem(0)
55 , m_isLengthCacheValid(false) 55 , m_isLengthCacheValid(false)
56 , m_isItemCacheValid(false) 56 , m_isItemCacheValid(false)
57 , m_rootType(rootType) 57 , m_rootType(rootType)
58 , m_invalidationType(invalidationType) 58 , m_invalidationType(invalidationType)
59 , m_shouldOnlyIncludeDirectChildren(shouldOnlyIncludeDirectChildren) 59 , m_shouldOnlyIncludeDirectChildren(shouldOnlyIncludeDirectChildren)
60 , m_isNameCacheValid(false)
61 , m_collectionType(collectionType) 60 , m_collectionType(collectionType)
62 , m_overridesItemAfter(itemAfterOverrideType == OverridesItemAfter) 61 , m_overridesItemAfter(itemAfterOverrideType == OverridesItemAfter)
63 { 62 {
64 ASSERT(m_rootType == static_cast<unsigned>(rootType)); 63 ASSERT(m_rootType == static_cast<unsigned>(rootType));
65 ASSERT(m_invalidationType == static_cast<unsigned>(invalidationType)); 64 ASSERT(m_invalidationType == static_cast<unsigned>(invalidationType));
66 ASSERT(m_collectionType == static_cast<unsigned>(collectionType)); 65 ASSERT(m_collectionType == static_cast<unsigned>(collectionType));
67 ASSERT(!m_overridesItemAfter || !isLiveNodeListType(collectionType)); 66 ASSERT(!m_overridesItemAfter || !isLiveNodeListType(collectionType));
68 67
69 if (collectionType != ChildNodeListType) 68 if (collectionType != ChildNodeListType)
70 document().registerNodeList(this); 69 document().registerNodeList(this);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 113 }
115 ALWAYS_INLINE void setItemCache(Node* item, unsigned offset) const 114 ALWAYS_INLINE void setItemCache(Node* item, unsigned offset) const
116 { 115 {
117 ASSERT(item); 116 ASSERT(item);
118 m_cachedItem = item; 117 m_cachedItem = item;
119 m_cachedItemOffset = offset; 118 m_cachedItemOffset = offset;
120 m_isItemCacheValid = true; 119 m_isItemCacheValid = true;
121 } 120 }
122 121
123 ALWAYS_INLINE NodeListRootType rootType() const { return static_cast<NodeLis tRootType>(m_rootType); } 122 ALWAYS_INLINE NodeListRootType rootType() const { return static_cast<NodeLis tRootType>(m_rootType); }
124
125 bool hasNameCache() const { return m_isNameCacheValid; }
126 void setHasNameCache() const { m_isNameCacheValid = true; }
127
128 bool shouldOnlyIncludeDirectChildren() const { return m_shouldOnlyIncludeDir ectChildren; } 123 bool shouldOnlyIncludeDirectChildren() const { return m_shouldOnlyIncludeDir ectChildren; }
129 124
130 private: 125 private:
131 Node* itemBeforeOrAfterCachedItem(unsigned offset, ContainerNode* root) cons t; 126 Node* itemBeforeOrAfterCachedItem(unsigned offset, ContainerNode* root) cons t;
132 bool isLastItemCloserThanLastOrCachedItem(unsigned offset) const; 127 bool isLastItemCloserThanLastOrCachedItem(unsigned offset) const;
133 bool isFirstItemCloserThanCachedItem(unsigned offset) const; 128 bool isFirstItemCloserThanCachedItem(unsigned offset) const;
134 Node* iterateForPreviousNode(Node* current) const; 129 Node* iterateForPreviousNode(Node* current) const;
135 Node* itemBefore(Node* previousItem) const; 130 Node* itemBefore(Node* previousItem) const;
136 void invalidateIdNameCacheMaps() const; 131 void invalidateIdNameCacheMaps() const;
137 132
138 RefPtr<Node> m_ownerNode; 133 RefPtr<Node> m_ownerNode;
139 mutable Node* m_cachedItem; 134 mutable Node* m_cachedItem;
140 mutable unsigned m_cachedLength; 135 mutable unsigned m_cachedLength;
141 mutable unsigned m_cachedItemOffset; 136 mutable unsigned m_cachedItemOffset;
142 mutable unsigned m_isLengthCacheValid : 1; 137 mutable unsigned m_isLengthCacheValid : 1;
143 mutable unsigned m_isItemCacheValid : 1; 138 mutable unsigned m_isItemCacheValid : 1;
144 const unsigned m_rootType : 2; 139 const unsigned m_rootType : 2;
145 const unsigned m_invalidationType : 4; 140 const unsigned m_invalidationType : 4;
146 const unsigned m_shouldOnlyIncludeDirectChildren : 1; 141 const unsigned m_shouldOnlyIncludeDirectChildren : 1;
142 const unsigned m_collectionType : 5;
147 143
148 // From HTMLCollection 144 // From HTMLCollection
149 mutable unsigned m_isNameCacheValid : 1;
150 const unsigned m_collectionType : 5;
151 const unsigned m_overridesItemAfter : 1; 145 const unsigned m_overridesItemAfter : 1;
152 }; 146 };
153 147
154 ALWAYS_INLINE bool LiveNodeListBase::shouldInvalidateTypeOnAttributeChange(NodeL istInvalidationType type, const QualifiedName& attrName) 148 ALWAYS_INLINE bool LiveNodeListBase::shouldInvalidateTypeOnAttributeChange(NodeL istInvalidationType type, const QualifiedName& attrName)
155 { 149 {
156 switch (type) { 150 switch (type) {
157 case InvalidateOnClassAttrChange: 151 case InvalidateOnClassAttrChange:
158 return attrName == HTMLNames::classAttr; 152 return attrName == HTMLNames::classAttr;
159 case InvalidateOnNameAttrChange: 153 case InvalidateOnNameAttrChange:
160 return attrName == HTMLNames::nameAttr; 154 return attrName == HTMLNames::nameAttr;
(...skipping 30 matching lines...) Expand all
191 Node* traverseToFirstElement(ContainerNode& root) const; 185 Node* traverseToFirstElement(ContainerNode& root) const;
192 Node* traverseForwardToOffset(unsigned offset, Node& currentNode, unsigned& currentOffset, ContainerNode* root) const; 186 Node* traverseForwardToOffset(unsigned offset, Node& currentNode, unsigned& currentOffset, ContainerNode* root) const;
193 187
194 private: 188 private:
195 virtual bool isLiveNodeList() const OVERRIDE FINAL { return true; } 189 virtual bool isLiveNodeList() const OVERRIDE FINAL { return true; }
196 }; 190 };
197 191
198 } // namespace WebCore 192 } // namespace WebCore
199 193
200 #endif // LiveNodeList_h 194 #endif // LiveNodeList_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/LiveNodeList.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698