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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLCollection.h

Issue 2258033002: Replace ASSERT()s with DCHECK*() in core/html/*.{cpp,h}. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace ASSERT()s with DCHECK*() in core/html/*.{cpp,h}. Created 4 years, 4 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 * 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 bool overridesItemAfter() const { return m_overridesItemAfter; } 107 bool overridesItemAfter() const { return m_overridesItemAfter; }
108 virtual Element* virtualItemAfter(Element*) const; 108 virtual Element* virtualItemAfter(Element*) const;
109 bool shouldOnlyIncludeDirectChildren() const { return m_shouldOnlyIncludeDir ectChildren; } 109 bool shouldOnlyIncludeDirectChildren() const { return m_shouldOnlyIncludeDir ectChildren; }
110 virtual void supportedPropertyNames(Vector<String>& names); 110 virtual void supportedPropertyNames(Vector<String>& names);
111 111
112 virtual void updateIdNameCache() const; 112 virtual void updateIdNameCache() const;
113 bool hasValidIdNameCache() const { return m_namedItemCache; } 113 bool hasValidIdNameCache() const { return m_namedItemCache; }
114 114
115 void setNamedItemCache(NamedItemCache* cache) const 115 void setNamedItemCache(NamedItemCache* cache) const
116 { 116 {
117 ASSERT(!m_namedItemCache); 117 DCHECK(!m_namedItemCache);
118 // Do not repeat registration for the same invalidation type. 118 // Do not repeat registration for the same invalidation type.
119 if (invalidationType() != InvalidateOnIdNameAttrChange) 119 if (invalidationType() != InvalidateOnIdNameAttrChange)
120 document().registerNodeListWithIdNameCache(this); 120 document().registerNodeListWithIdNameCache(this);
121 m_namedItemCache = std::move(cache); 121 m_namedItemCache = std::move(cache);
122 } 122 }
123 123
124 NamedItemCache& namedItemCache() const 124 NamedItemCache& namedItemCache() const
125 { 125 {
126 ASSERT(m_namedItemCache); 126 DCHECK(m_namedItemCache);
127 return *m_namedItemCache; 127 return *m_namedItemCache;
128 } 128 }
129 129
130 private: 130 private:
131 void invalidateIdNameCacheMaps(Document* oldDocument = 0) const 131 void invalidateIdNameCacheMaps(Document* oldDocument = 0) const
132 { 132 {
133 if (!hasValidIdNameCache()) 133 if (!hasValidIdNameCache())
134 return; 134 return;
135 135
136 // Make sure we decrement the NodeListWithIdNameCache count from 136 // Make sure we decrement the NodeListWithIdNameCache count from
137 // the old document instead of the new one in the case the collection 137 // the old document instead of the new one in the case the collection
138 // is moved to a new document. 138 // is moved to a new document.
139 unregisterIdNameCacheFromDocument(oldDocument ? *oldDocument : document( )); 139 unregisterIdNameCacheFromDocument(oldDocument ? *oldDocument : document( ));
140 140
141 m_namedItemCache.clear(); 141 m_namedItemCache.clear();
142 } 142 }
143 143
144 void unregisterIdNameCacheFromDocument(Document& document) const 144 void unregisterIdNameCacheFromDocument(Document& document) const
145 { 145 {
146 ASSERT(hasValidIdNameCache()); 146 DCHECK(hasValidIdNameCache());
147 // Do not repeat unregistration for the same invalidation type. 147 // Do not repeat unregistration for the same invalidation type.
148 if (invalidationType() != InvalidateOnIdNameAttrChange) 148 if (invalidationType() != InvalidateOnIdNameAttrChange)
149 document.unregisterNodeListWithIdNameCache(this); 149 document.unregisterNodeListWithIdNameCache(this);
150 } 150 }
151 151
152 const unsigned m_overridesItemAfter : 1; 152 const unsigned m_overridesItemAfter : 1;
153 const unsigned m_shouldOnlyIncludeDirectChildren : 1; 153 const unsigned m_shouldOnlyIncludeDirectChildren : 1;
154 mutable Member<NamedItemCache> m_namedItemCache; 154 mutable Member<NamedItemCache> m_namedItemCache;
155 mutable CollectionItemsCache<HTMLCollection, Element> m_collectionItemsCache ; 155 mutable CollectionItemsCache<HTMLCollection, Element> m_collectionItemsCache ;
156 }; 156 };
157 157
158 DEFINE_TYPE_CASTS(HTMLCollection, LiveNodeListBase, collection, isHTMLCollection Type(collection->type()), isHTMLCollectionType(collection.type())); 158 DEFINE_TYPE_CASTS(HTMLCollection, LiveNodeListBase, collection, isHTMLCollection Type(collection->type()), isHTMLCollectionType(collection.type()));
159 159
160 inline void HTMLCollection::invalidateCacheForAttribute(const QualifiedName* att rName) const 160 inline void HTMLCollection::invalidateCacheForAttribute(const QualifiedName* att rName) const
161 { 161 {
162 if (!attrName || shouldInvalidateTypeOnAttributeChange(invalidationType(), * attrName)) 162 if (!attrName || shouldInvalidateTypeOnAttributeChange(invalidationType(), * attrName))
163 invalidateCache(); 163 invalidateCache();
164 else if (*attrName == HTMLNames::idAttr || *attrName == HTMLNames::nameAttr) 164 else if (*attrName == HTMLNames::idAttr || *attrName == HTMLNames::nameAttr)
165 invalidateIdNameCacheMaps(); 165 invalidateIdNameCacheMaps();
166 } 166 }
167 167
168 } // namespace blink 168 } // namespace blink
169 169
170 #endif // HTMLCollection_h 170 #endif // HTMLCollection_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLButtonElement.cpp ('k') | third_party/WebKit/Source/core/html/HTMLCollection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698