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

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

Issue 113653006: Remove complexity related to m_cachedElementsArrayOffset from LiveNodeListBase (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/dom/LiveNodeList.cpp » ('j') | Source/core/dom/LiveNodeList.cpp » ('J')
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 ALWAYS_INLINE NodeListInvalidationType invalidationType() const { return sta tic_cast<NodeListInvalidationType>(m_invalidationType); } 84 ALWAYS_INLINE NodeListInvalidationType invalidationType() const { return sta tic_cast<NodeListInvalidationType>(m_invalidationType); }
85 ALWAYS_INLINE CollectionType type() const { return static_cast<CollectionTyp e>(m_collectionType); } 85 ALWAYS_INLINE CollectionType type() const { return static_cast<CollectionTyp e>(m_collectionType); }
86 Node* ownerNode() const { return m_ownerNode.get(); } 86 Node* ownerNode() const { return m_ownerNode.get(); }
87 ALWAYS_INLINE void invalidateCache(const QualifiedName* attrName) const 87 ALWAYS_INLINE void invalidateCache(const QualifiedName* attrName) const
88 { 88 {
89 if (!attrName || shouldInvalidateTypeOnAttributeChange(invalidationType( ), *attrName)) 89 if (!attrName || shouldInvalidateTypeOnAttributeChange(invalidationType( ), *attrName))
90 invalidateCache(); 90 invalidateCache();
91 else if (hasIdNameCache() && (*attrName == HTMLNames::idAttr || *attrNam e == HTMLNames::nameAttr)) 91 else if (hasIdNameCache() && (*attrName == HTMLNames::idAttr || *attrNam e == HTMLNames::nameAttr))
92 invalidateIdNameCacheMaps(); 92 invalidateIdNameCacheMaps();
93 } 93 }
94 void invalidateCache() const; 94 virtual void invalidateCache() const;
95 void invalidateIdNameCacheMaps() const;
96 95
97 static bool shouldInvalidateTypeOnAttributeChange(NodeListInvalidationType, const QualifiedName&); 96 static bool shouldInvalidateTypeOnAttributeChange(NodeListInvalidationType, const QualifiedName&);
98 97
99 protected: 98 protected:
100 Document& document() const { return m_ownerNode->document(); } 99 Document& document() const { return m_ownerNode->document(); }
101 Node& rootNode() const; 100 Node& rootNode() const;
102 ContainerNode* rootContainerNode() const; 101 ContainerNode* rootContainerNode() const;
103 bool overridesItemAfter() const { return m_overridesItemAfter; } 102 bool overridesItemAfter() const { return m_overridesItemAfter; }
104 103
105 ALWAYS_INLINE bool isItemCacheValid() const { return m_isItemCacheValid; } 104 ALWAYS_INLINE bool isItemCacheValid() const { return m_isItemCacheValid; }
106 ALWAYS_INLINE Node* cachedItem() const { return m_cachedItem; } 105 ALWAYS_INLINE Node* cachedItem() const { return m_cachedItem; }
107 ALWAYS_INLINE unsigned cachedItemOffset() const { return m_cachedItemOffset; } 106 ALWAYS_INLINE unsigned cachedItemOffset() const { return m_cachedItemOffset; }
108 107
109 ALWAYS_INLINE bool isLengthCacheValid() const { return m_isLengthCacheValid; } 108 ALWAYS_INLINE bool isLengthCacheValid() const { return m_isLengthCacheValid; }
110 ALWAYS_INLINE unsigned cachedLength() const { return m_cachedLength; } 109 ALWAYS_INLINE unsigned cachedLength() const { return m_cachedLength; }
111 ALWAYS_INLINE void setLengthCache(unsigned length) const 110 ALWAYS_INLINE void setLengthCache(unsigned length) const
112 { 111 {
113 m_cachedLength = length; 112 m_cachedLength = length;
114 m_isLengthCacheValid = true; 113 m_isLengthCacheValid = true;
115 } 114 }
116 ALWAYS_INLINE void setItemCache(Node* item, unsigned offset) const 115 ALWAYS_INLINE void setItemCache(Node* item, unsigned offset) const
117 { 116 {
118 ASSERT(item); 117 ASSERT(item);
119 m_cachedItem = item; 118 m_cachedItem = item;
120 m_cachedItemOffset = offset; 119 m_cachedItemOffset = offset;
121 m_isItemCacheValid = true; 120 m_isItemCacheValid = true;
122 } 121 }
123 void setItemCache(Node* item, unsigned offset, unsigned elementsArrayOffset) const;
124 122
125 ALWAYS_INLINE NodeListRootType rootType() const { return static_cast<NodeLis tRootType>(m_rootType); } 123 ALWAYS_INLINE NodeListRootType rootType() const { return static_cast<NodeLis tRootType>(m_rootType); }
126 124
127 bool hasNameCache() const { return m_isNameCacheValid; } 125 bool hasNameCache() const { return m_isNameCacheValid; }
128 void setHasNameCache() const { m_isNameCacheValid = true; } 126 void setHasNameCache() const { m_isNameCacheValid = true; }
129 127
130 bool shouldOnlyIncludeDirectChildren() const { return m_shouldOnlyIncludeDir ectChildren; } 128 bool shouldOnlyIncludeDirectChildren() const { return m_shouldOnlyIncludeDir ectChildren; }
131 129
132 private: 130 private:
133 Node* itemBeforeOrAfterCachedItem(unsigned offset, ContainerNode* root) cons t; 131 Node* itemBeforeOrAfterCachedItem(unsigned offset, ContainerNode* root) cons t;
134 Node* traverseChildNodeListForwardToOffset(unsigned offset, Node* currentNod e, unsigned& currentOffset) const; 132 Node* traverseChildNodeListForwardToOffset(unsigned offset, Node* currentNod e, unsigned& currentOffset) const;
135 Element* traverseLiveNodeListFirstElement(ContainerNode& root) const; 133 Element* traverseLiveNodeListFirstElement(ContainerNode& root) const;
136 Element* traverseLiveNodeListForwardToOffset(unsigned offset, Element& curre ntElement, unsigned& currentOffset, ContainerNode* root) const; 134 Element* traverseLiveNodeListForwardToOffset(unsigned offset, Element& curre ntElement, unsigned& currentOffset, ContainerNode* root) const;
137 bool isLastItemCloserThanLastOrCachedItem(unsigned offset) const; 135 bool isLastItemCloserThanLastOrCachedItem(unsigned offset) const;
138 bool isFirstItemCloserThanCachedItem(unsigned offset) const; 136 bool isFirstItemCloserThanCachedItem(unsigned offset) const;
139 Node* iterateForPreviousNode(Node* current) const; 137 Node* iterateForPreviousNode(Node* current) const;
140 Node* itemBefore(Node* previousItem) const; 138 Node* itemBefore(Node* previousItem) const;
139 void invalidateIdNameCacheMaps() const;
141 140
142 RefPtr<Node> m_ownerNode; 141 RefPtr<Node> m_ownerNode;
143 mutable Node* m_cachedItem; 142 mutable Node* m_cachedItem;
144 mutable unsigned m_cachedLength; 143 mutable unsigned m_cachedLength;
145 mutable unsigned m_cachedItemOffset; 144 mutable unsigned m_cachedItemOffset;
146 mutable unsigned m_isLengthCacheValid : 1; 145 mutable unsigned m_isLengthCacheValid : 1;
147 mutable unsigned m_isItemCacheValid : 1; 146 mutable unsigned m_isItemCacheValid : 1;
148 const unsigned m_rootType : 2; 147 const unsigned m_rootType : 2;
149 const unsigned m_invalidationType : 4; 148 const unsigned m_invalidationType : 4;
150 const unsigned m_shouldOnlyIncludeDirectChildren : 1; 149 const unsigned m_shouldOnlyIncludeDirectChildren : 1;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 virtual Node* namedItem(const AtomicString&) const OVERRIDE FINAL; 191 virtual Node* namedItem(const AtomicString&) const OVERRIDE FINAL;
193 virtual bool nodeMatches(Element*) const = 0; 192 virtual bool nodeMatches(Element*) const = 0;
194 193
195 private: 194 private:
196 virtual bool isLiveNodeList() const OVERRIDE FINAL { return true; } 195 virtual bool isLiveNodeList() const OVERRIDE FINAL { return true; }
197 }; 196 };
198 197
199 } // namespace WebCore 198 } // namespace WebCore
200 199
201 #endif // LiveNodeList_h 200 #endif // LiveNodeList_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/LiveNodeList.cpp » ('j') | Source/core/dom/LiveNodeList.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698