OLD | NEW |
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 virtual Element* virtualItemAfter(Element*) const; | 110 virtual Element* virtualItemAfter(Element*) const; |
111 bool shouldOnlyIncludeDirectChildren() const { return m_shouldOnlyIncludeDir
ectChildren; } | 111 bool shouldOnlyIncludeDirectChildren() const { return m_shouldOnlyIncludeDir
ectChildren; } |
112 virtual void supportedPropertyNames(Vector<String>& names); | 112 virtual void supportedPropertyNames(Vector<String>& names); |
113 | 113 |
114 virtual void updateIdNameCache() const; | 114 virtual void updateIdNameCache() const; |
115 bool hasValidIdNameCache() const { return m_namedItemCache; } | 115 bool hasValidIdNameCache() const { return m_namedItemCache; } |
116 | 116 |
117 void setNamedItemCache(PassOwnPtrWillBeRawPtr<NamedItemCache> cache) const | 117 void setNamedItemCache(PassOwnPtrWillBeRawPtr<NamedItemCache> cache) const |
118 { | 118 { |
119 ASSERT(!m_namedItemCache); | 119 ASSERT(!m_namedItemCache); |
120 document().registerNodeListWithIdNameCache(this); | 120 // Do not repeat registration for the same invalidation type. |
| 121 if (invalidationType() != InvalidateOnIdNameAttrChange) |
| 122 document().registerNodeListWithIdNameCache(this); |
121 m_namedItemCache = std::move(cache); | 123 m_namedItemCache = std::move(cache); |
122 } | 124 } |
123 | 125 |
124 NamedItemCache& namedItemCache() const | 126 NamedItemCache& namedItemCache() const |
125 { | 127 { |
126 ASSERT(m_namedItemCache); | 128 ASSERT(m_namedItemCache); |
127 return *m_namedItemCache; | 129 return *m_namedItemCache; |
128 } | 130 } |
129 | 131 |
130 private: | 132 private: |
131 void invalidateIdNameCacheMaps(Document* oldDocument = 0) const | 133 void invalidateIdNameCacheMaps(Document* oldDocument = 0) const |
132 { | 134 { |
133 if (!hasValidIdNameCache()) | 135 if (!hasValidIdNameCache()) |
134 return; | 136 return; |
135 | 137 |
136 // Make sure we decrement the NodeListWithIdNameCache count from | 138 // Make sure we decrement the NodeListWithIdNameCache count from |
137 // the old document instead of the new one in the case the collection | 139 // the old document instead of the new one in the case the collection |
138 // is moved to a new document. | 140 // is moved to a new document. |
139 unregisterIdNameCacheFromDocument(oldDocument ? *oldDocument : document(
)); | 141 unregisterIdNameCacheFromDocument(oldDocument ? *oldDocument : document(
)); |
140 | 142 |
141 m_namedItemCache.clear(); | 143 m_namedItemCache.clear(); |
142 } | 144 } |
143 | 145 |
144 void unregisterIdNameCacheFromDocument(Document& document) const | 146 void unregisterIdNameCacheFromDocument(Document& document) const |
145 { | 147 { |
146 ASSERT(hasValidIdNameCache()); | 148 ASSERT(hasValidIdNameCache()); |
147 document.unregisterNodeListWithIdNameCache(this); | 149 // Do not repeat unregistration for the same invalidation type. |
| 150 if (invalidationType() != InvalidateOnIdNameAttrChange) |
| 151 document.unregisterNodeListWithIdNameCache(this); |
148 } | 152 } |
149 | 153 |
150 const unsigned m_overridesItemAfter : 1; | 154 const unsigned m_overridesItemAfter : 1; |
151 const unsigned m_shouldOnlyIncludeDirectChildren : 1; | 155 const unsigned m_shouldOnlyIncludeDirectChildren : 1; |
152 mutable OwnPtrWillBeMember<NamedItemCache> m_namedItemCache; | 156 mutable OwnPtrWillBeMember<NamedItemCache> m_namedItemCache; |
153 mutable CollectionItemsCache<HTMLCollection, Element> m_collectionItemsCache
; | 157 mutable CollectionItemsCache<HTMLCollection, Element> m_collectionItemsCache
; |
154 }; | 158 }; |
155 | 159 |
156 DEFINE_TYPE_CASTS(HTMLCollection, LiveNodeListBase, collection, isHTMLCollection
Type(collection->type()), isHTMLCollectionType(collection.type())); | 160 DEFINE_TYPE_CASTS(HTMLCollection, LiveNodeListBase, collection, isHTMLCollection
Type(collection->type()), isHTMLCollectionType(collection.type())); |
157 | 161 |
158 inline void HTMLCollection::invalidateCacheForAttribute(const QualifiedName* att
rName) const | 162 inline void HTMLCollection::invalidateCacheForAttribute(const QualifiedName* att
rName) const |
159 { | 163 { |
160 if (!attrName || shouldInvalidateTypeOnAttributeChange(invalidationType(), *
attrName)) | 164 if (!attrName || shouldInvalidateTypeOnAttributeChange(invalidationType(), *
attrName)) |
161 invalidateCache(); | 165 invalidateCache(); |
162 else if (*attrName == HTMLNames::idAttr || *attrName == HTMLNames::nameAttr) | 166 else if (*attrName == HTMLNames::idAttr || *attrName == HTMLNames::nameAttr) |
163 invalidateIdNameCacheMaps(); | 167 invalidateIdNameCacheMaps(); |
164 } | 168 } |
165 | 169 |
166 } // namespace blink | 170 } // namespace blink |
167 | 171 |
168 #endif // HTMLCollection_h | 172 #endif // HTMLCollection_h |
OLD | NEW |