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

Unified Diff: third_party/WebKit/Source/core/html/CollectionIndexCache.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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/CollectionIndexCache.h
diff --git a/third_party/WebKit/Source/core/html/CollectionIndexCache.h b/third_party/WebKit/Source/core/html/CollectionIndexCache.h
index a75e3671ff1c82f597a4ca63c98f45c3e6663ed3..635bc53d602100a56cc37781a5da4e9b0ffdfded 100644
--- a/third_party/WebKit/Source/core/html/CollectionIndexCache.h
+++ b/third_party/WebKit/Source/core/html/CollectionIndexCache.h
@@ -69,10 +69,14 @@ public:
protected:
ALWAYS_INLINE NodeType* cachedNode() const { return m_currentNode; }
- ALWAYS_INLINE unsigned cachedNodeIndex() const { ASSERT(cachedNode()); return m_cachedNodeIndex; }
+ ALWAYS_INLINE unsigned cachedNodeIndex() const
+ {
+ DCHECK(cachedNode());
+ return m_cachedNodeIndex;
+ }
ALWAYS_INLINE void setCachedNode(NodeType* node, unsigned index)
{
- ASSERT(node);
+ DCHECK(node);
m_currentNode = node;
m_cachedNodeIndex = index;
}
@@ -118,7 +122,7 @@ inline unsigned CollectionIndexCache<Collection, NodeType>::nodeCount(const Coll
return cachedNodeCount();
nodeAt(collection, UINT_MAX);
- ASSERT(isCachedNodeCountValid());
+ DCHECK(isCachedNodeCountValid());
return cachedNodeCount();
}
@@ -138,7 +142,7 @@ inline NodeType* CollectionIndexCache<Collection, NodeType>::nodeAt(const Collec
}
// No valid cache yet, let's find the first matching element.
- ASSERT(!isCachedNodeCountValid());
+ DCHECK(!isCachedNodeCountValid());
NodeType* firstNode = collection.traverseToFirst();
if (!firstNode) {
// The collection is empty.
@@ -152,23 +156,23 @@ inline NodeType* CollectionIndexCache<Collection, NodeType>::nodeAt(const Collec
template <typename Collection, typename NodeType>
inline NodeType* CollectionIndexCache<Collection, NodeType>::nodeBeforeCachedNode(const Collection& collection, unsigned index)
{
- ASSERT(cachedNode()); // Cache should be valid.
+ DCHECK(cachedNode()); // Cache should be valid.
unsigned currentIndex = cachedNodeIndex();
- ASSERT(currentIndex > index);
+ DCHECK_GT(currentIndex, index);
// Determine if we should traverse from the beginning of the collection instead of the cached node.
bool firstIsCloser = index < currentIndex - index;
if (firstIsCloser || !collection.canTraverseBackward()) {
NodeType* firstNode = collection.traverseToFirst();
- ASSERT(firstNode);
+ DCHECK(firstNode);
setCachedNode(firstNode, 0);
return index ? nodeAfterCachedNode(collection, index) : firstNode;
}
// Backward traversal from the cached node to the requested index.
- ASSERT(collection.canTraverseBackward());
+ DCHECK(collection.canTraverseBackward());
NodeType* currentNode = collection.traverseBackwardToOffset(index, *cachedNode(), currentIndex);
- ASSERT(currentNode);
+ DCHECK(currentNode);
setCachedNode(currentNode, currentIndex);
return currentNode;
}
@@ -176,15 +180,15 @@ inline NodeType* CollectionIndexCache<Collection, NodeType>::nodeBeforeCachedNod
template <typename Collection, typename NodeType>
inline NodeType* CollectionIndexCache<Collection, NodeType>::nodeAfterCachedNode(const Collection& collection, unsigned index)
{
- ASSERT(cachedNode()); // Cache should be valid.
+ DCHECK(cachedNode()); // Cache should be valid.
unsigned currentIndex = cachedNodeIndex();
- ASSERT(currentIndex < index);
+ DCHECK_LT(currentIndex, index);
// Determine if we should traverse from the end of the collection instead of the cached node.
bool lastIsCloser = isCachedNodeCountValid() && cachedNodeCount() - index < index - currentIndex;
if (lastIsCloser && collection.canTraverseBackward()) {
NodeType* lastItem = collection.traverseToLast();
- ASSERT(lastItem);
+ DCHECK(lastItem);
setCachedNode(lastItem, cachedNodeCount() - 1);
if (index < cachedNodeCount() - 1)
return nodeBeforeCachedNode(collection, index);
« no previous file with comments | « third_party/WebKit/Source/core/html/ClassList.cpp ('k') | third_party/WebKit/Source/core/html/CollectionItemsCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698