Commit 09f7ee79 authored by ch.dumez@samsung.com's avatar ch.dumez@samsung.com

Rename CollectionIndexCache API to not use 'Element'

Rename CollectionIndexCache API to not use 'Element':
- traverseToFirstElement() -> traverseToFirst()
- traverseToLastElement() -> traverseToLast()

Using Element is confusing because some CollectionIndexCache users like
ChildNodeList deal with pure Nodes. The Node type is a template parameter
of the CollectionIndexCache class so the API should be seem to be Element
specific.

R=rob.buis@samsung.com

Review URL: https://codereview.chromium.org/469913002

git-svn-id: svn://svn.chromium.org/blink/trunk@180371 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e12d3f7b
......@@ -53,8 +53,8 @@ public:
// CollectionIndexCache API.
bool canTraverseBackward() const { return true; }
Node* traverseToFirstElement() const { return rootNode().firstChild(); }
Node* traverseToLastElement() const { return rootNode().lastChild(); }
Node* traverseToFirst() const { return rootNode().firstChild(); }
Node* traverseToLast() const { return rootNode().lastChild(); }
Node* traverseForwardToOffset(unsigned offset, Node& currentNode, unsigned& currentOffset) const;
Node* traverseBackwardToOffset(unsigned offset, Node& currentNode, unsigned& currentOffset) const;
......
......@@ -64,12 +64,12 @@ Element* LiveNodeList::item(unsigned offset) const
return m_collectionIndexCache.nodeAt(*this, offset);
}
Element* LiveNodeList::traverseToFirstElement() const
Element* LiveNodeList::traverseToFirst() const
{
return ElementTraversal::firstWithin(rootNode(), IsMatch(*this));
}
Element* LiveNodeList::traverseToLastElement() const
Element* LiveNodeList::traverseToLast() const
{
return ElementTraversal::lastWithin(rootNode(), IsMatch(*this));
}
......
......@@ -50,8 +50,8 @@ public:
// Collection IndexCache API.
bool canTraverseBackward() const { return true; }
Element* traverseToFirstElement() const;
Element* traverseToLastElement() const;
Element* traverseToFirst() const;
Element* traverseToLast() const;
Element* traverseForwardToOffset(unsigned offset, Element& currentNode, unsigned& currentOffset) const;
Element* traverseBackwardToOffset(unsigned offset, Element& currentNode, unsigned& currentOffset) const;
......
......@@ -138,7 +138,7 @@ inline NodeType* CollectionIndexCache<Collection, NodeType>::nodeAt(const Collec
// No valid cache yet, let's find the first matching element.
ASSERT(!isCachedNodeCountValid());
NodeType* firstNode = collection.traverseToFirstElement();
NodeType* firstNode = collection.traverseToFirst();
if (!firstNode) {
// The collection is empty.
setCachedNodeCount(0);
......@@ -158,7 +158,7 @@ inline NodeType* CollectionIndexCache<Collection, NodeType>::nodeBeforeCachedNod
// 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.traverseToFirstElement();
NodeType* firstNode = collection.traverseToFirst();
ASSERT(firstNode);
setCachedNode(firstNode, 0);
return index ? nodeAfterCachedNode(collection, index) : firstNode;
......@@ -182,7 +182,7 @@ inline NodeType* CollectionIndexCache<Collection, NodeType>::nodeAfterCachedNode
// 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.traverseToLastElement();
NodeType* lastItem = collection.traverseToLast();
ASSERT(lastItem);
setCachedNode(lastItem, cachedNodeCount() - 1);
if (index < cachedNodeCount() - 1)
......
......@@ -328,7 +328,7 @@ static inline bool nameShouldBeVisibleInDocumentAll(const HTMLElement& element)
|| element.hasTagName(selectTag);
}
Element* HTMLCollection::traverseToFirstElement() const
Element* HTMLCollection::traverseToFirst() const
{
switch (type()) {
case HTMLTagCollectionType:
......@@ -344,7 +344,7 @@ Element* HTMLCollection::traverseToFirstElement() const
}
}
Element* HTMLCollection::traverseToLastElement() const
Element* HTMLCollection::traverseToLast() const
{
ASSERT(canTraverseBackward());
if (shouldOnlyIncludeDirectChildren())
......
......@@ -59,8 +59,8 @@ public:
// CollectionIndexCache API.
bool canTraverseBackward() const { return !overridesItemAfter(); }
Element* traverseToFirstElement() const;
Element* traverseToLastElement() const;
Element* traverseToFirst() const;
Element* traverseToLast() const;
Element* traverseForwardToOffset(unsigned offset, Element& currentElement, unsigned& currentOffset) const;
Element* traverseBackwardToOffset(unsigned offset, Element& currentElement, unsigned& currentOffset) const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment