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

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

Issue 136833002: Remove redundant m_isItemCacheValid flag from LiveNodeListBase (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: No change 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
« 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 enum ItemAfterOverrideType { 46 enum ItemAfterOverrideType {
47 OverridesItemAfter, 47 OverridesItemAfter,
48 DoesNotOverrideItemAfter, 48 DoesNotOverrideItemAfter,
49 }; 49 };
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)
57 , m_rootType(rootType) 56 , m_rootType(rootType)
58 , m_invalidationType(invalidationType) 57 , m_invalidationType(invalidationType)
59 , m_shouldOnlyIncludeDirectChildren(shouldOnlyIncludeDirectChildren) 58 , m_shouldOnlyIncludeDirectChildren(shouldOnlyIncludeDirectChildren)
60 , m_collectionType(collectionType) 59 , m_collectionType(collectionType)
61 , m_overridesItemAfter(itemAfterOverrideType == OverridesItemAfter) 60 , m_overridesItemAfter(itemAfterOverrideType == OverridesItemAfter)
62 { 61 {
63 ASSERT(m_rootType == static_cast<unsigned>(rootType)); 62 ASSERT(m_rootType == static_cast<unsigned>(rootType));
64 ASSERT(m_invalidationType == static_cast<unsigned>(invalidationType)); 63 ASSERT(m_invalidationType == static_cast<unsigned>(invalidationType));
65 ASSERT(m_collectionType == static_cast<unsigned>(collectionType)); 64 ASSERT(m_collectionType == static_cast<unsigned>(collectionType));
66 ASSERT(!m_overridesItemAfter || !isLiveNodeListType(collectionType)); 65 ASSERT(!m_overridesItemAfter || !isLiveNodeListType(collectionType));
(...skipping 26 matching lines...) Expand all
93 virtual void invalidateCache() const; 92 virtual void invalidateCache() const;
94 93
95 static bool shouldInvalidateTypeOnAttributeChange(NodeListInvalidationType, const QualifiedName&); 94 static bool shouldInvalidateTypeOnAttributeChange(NodeListInvalidationType, const QualifiedName&);
96 95
97 protected: 96 protected:
98 Document& document() const { return m_ownerNode->document(); } 97 Document& document() const { return m_ownerNode->document(); }
99 Node& rootNode() const; 98 Node& rootNode() const;
100 ContainerNode* rootContainerNode() const; 99 ContainerNode* rootContainerNode() const;
101 bool overridesItemAfter() const { return m_overridesItemAfter; } 100 bool overridesItemAfter() const { return m_overridesItemAfter; }
102 101
103 ALWAYS_INLINE bool isItemCacheValid() const { return m_isItemCacheValid; }
104 ALWAYS_INLINE Node* cachedItem() const { return m_cachedItem; } 102 ALWAYS_INLINE Node* cachedItem() const { return m_cachedItem; }
105 ALWAYS_INLINE unsigned cachedItemOffset() const { return m_cachedItemOffset; } 103 ALWAYS_INLINE unsigned cachedItemOffset() const { ASSERT(cachedItem()); retu rn m_cachedItemOffset; }
106 104
107 ALWAYS_INLINE bool isLengthCacheValid() const { return m_isLengthCacheValid; } 105 ALWAYS_INLINE bool isLengthCacheValid() const { return m_isLengthCacheValid; }
108 ALWAYS_INLINE unsigned cachedLength() const { return m_cachedLength; } 106 ALWAYS_INLINE unsigned cachedLength() const { return m_cachedLength; }
109 ALWAYS_INLINE void setLengthCache(unsigned length) const 107 ALWAYS_INLINE void setLengthCache(unsigned length) const
110 { 108 {
111 m_cachedLength = length; 109 m_cachedLength = length;
112 m_isLengthCacheValid = true; 110 m_isLengthCacheValid = true;
113 } 111 }
114 ALWAYS_INLINE void setItemCache(Node* item, unsigned offset) const 112 ALWAYS_INLINE void setItemCache(Node* item, unsigned offset) const
115 { 113 {
116 ASSERT(item); 114 ASSERT(item);
117 m_cachedItem = item; 115 m_cachedItem = item;
118 m_cachedItemOffset = offset; 116 m_cachedItemOffset = offset;
119 m_isItemCacheValid = true;
120 } 117 }
121 118
122 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); }
123 bool shouldOnlyIncludeDirectChildren() const { return m_shouldOnlyIncludeDir ectChildren; } 120 bool shouldOnlyIncludeDirectChildren() const { return m_shouldOnlyIncludeDir ectChildren; }
124 121
125 private: 122 private:
126 Node* itemBeforeOrAfterCachedItem(unsigned offset, ContainerNode* root) cons t; 123 Node* itemBeforeOrAfterCachedItem(unsigned offset, ContainerNode* root) cons t;
127 bool isLastItemCloserThanLastOrCachedItem(unsigned offset) const; 124 bool isLastItemCloserThanLastOrCachedItem(unsigned offset) const;
128 bool isFirstItemCloserThanCachedItem(unsigned offset) const; 125 bool isFirstItemCloserThanCachedItem(unsigned offset) const;
129 Node* iterateForPreviousNode(Node* current) const; 126 Node* iterateForPreviousNode(Node* current) const;
130 Node* itemBefore(Node* previousItem) const; 127 Node* itemBefore(Node* previousItem) const;
131 void invalidateIdNameCacheMaps() const; 128 void invalidateIdNameCacheMaps() const;
132 129
133 RefPtr<Node> m_ownerNode; 130 RefPtr<Node> m_ownerNode;
134 mutable Node* m_cachedItem; 131 mutable Node* m_cachedItem;
135 mutable unsigned m_cachedLength; 132 mutable unsigned m_cachedLength;
136 mutable unsigned m_cachedItemOffset; 133 mutable unsigned m_cachedItemOffset;
137 mutable unsigned m_isLengthCacheValid : 1; 134 mutable unsigned m_isLengthCacheValid : 1;
138 mutable unsigned m_isItemCacheValid : 1;
139 const unsigned m_rootType : 2; 135 const unsigned m_rootType : 2;
140 const unsigned m_invalidationType : 4; 136 const unsigned m_invalidationType : 4;
141 const unsigned m_shouldOnlyIncludeDirectChildren : 1; 137 const unsigned m_shouldOnlyIncludeDirectChildren : 1;
142 const unsigned m_collectionType : 5; 138 const unsigned m_collectionType : 5;
143 139
144 // From HTMLCollection 140 // From HTMLCollection
145 const unsigned m_overridesItemAfter : 1; 141 const unsigned m_overridesItemAfter : 1;
146 }; 142 };
147 143
148 ALWAYS_INLINE bool LiveNodeListBase::shouldInvalidateTypeOnAttributeChange(NodeL istInvalidationType type, const QualifiedName& attrName) 144 ALWAYS_INLINE bool LiveNodeListBase::shouldInvalidateTypeOnAttributeChange(NodeL istInvalidationType type, const QualifiedName& attrName)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 Node* traverseToFirstElement(ContainerNode& root) const; 183 Node* traverseToFirstElement(ContainerNode& root) const;
188 Node* traverseForwardToOffset(unsigned offset, Node& currentNode, unsigned& currentOffset, ContainerNode* root) const; 184 Node* traverseForwardToOffset(unsigned offset, Node& currentNode, unsigned& currentOffset, ContainerNode* root) const;
189 185
190 private: 186 private:
191 virtual bool isLiveNodeList() const OVERRIDE FINAL { return true; } 187 virtual bool isLiveNodeList() const OVERRIDE FINAL { return true; }
192 }; 188 };
193 189
194 } // namespace WebCore 190 } // namespace WebCore
195 191
196 #endif // LiveNodeList_h 192 #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