Changeset 158587 in webkit


Ignore:
Timestamp:
Nov 4, 2013, 1:31:27 PM (11 years ago)
Author:
Antti Koivisto
Message:

Make LiveNodeListBase use Elements instead of Nodes
https://bugs.webkit.org/show_bug.cgi?id=123745

Reviewed by Anders Carlsson.

  • WebCore.exp.in:
  • dom/Element.cpp:

(WebCore::Element::firstElementChild):
(WebCore::Element::lastElementChild):

Switch to correct calls. ElementTraversal::previous and previousChild are no longer equivalent.

  • dom/ElementTraversal.h:

(WebCore::::lastWithinTemplate):
(WebCore::::previousTemplate):

Fix ElementTraversal::lastWithin and previous. They had no real clients and didn't work correctly.
With LiveNodeListBase starting to use these they get excellent test coverage.

  • dom/LiveNodeList.cpp:

(WebCore::LiveNodeListBase::invalidateCache):

  • dom/LiveNodeList.h:

(WebCore::LiveNodeListBase::LiveNodeListBase):
(WebCore::LiveNodeListBase::isElementCacheValid):
(WebCore::LiveNodeListBase::cachedElement):
(WebCore::LiveNodeListBase::cachedElementOffset):
(WebCore::LiveNodeListBase::setCachedElement):

Make the cache Element based.
Switch to Elements in all helpers.
Rename item -> element for clarity.

  • dom/NodeIterator.cpp:

(WebCore::NodeIterator::NodePointer::moveToPrevious):
(WebCore::NodeIterator::updateForNodeRemoval):

This code expected the old inconsistent NodeTraversal::previous behavior where the traversal includes
the root as the last item. Drop the stayWithin parameter and handle the one case where it is needed here.

  • dom/NodeTraversal.cpp:

(WebCore::NodeTraversal::last):
(WebCore::NodeTraversal::deepLastChild):

  • dom/NodeTraversal.h:


Support ElementTraversal::previous/lastWithin.

(WebCore::NodeTraversal::previous):

This was slightly wrong too.

  • html/HTMLCollection.cpp:

(WebCore::previousElement):
(WebCore::lastElement):
(WebCore::LiveNodeListBase::iterateForPreviousElement):
(WebCore::LiveNodeListBase::itemBefore):
(WebCore::LiveNodeListBase::isLastItemCloserThanLastOrCachedItem):
(WebCore::LiveNodeListBase::isFirstItemCloserThanCachedItem):
(WebCore::LiveNodeListBase::setCachedElement):
(WebCore::LiveNodeListBase::item):
(WebCore::LiveNodeListBase::elementBeforeOrAfterCachedElement):

  • html/HTMLCollection.h:

(WebCore::HTMLCollection::isEmpty):
(WebCore::HTMLCollection::hasExactlyOneItem):

Location:
trunk/Source/WebCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r158586 r158587  
     12013-11-04  Antti Koivisto  <antti@apple.com>
     2
     3        Make LiveNodeListBase use Elements instead of Nodes
     4        https://bugs.webkit.org/show_bug.cgi?id=123745
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * WebCore.exp.in:
     9        * dom/Element.cpp:
     10        (WebCore::Element::firstElementChild):
     11        (WebCore::Element::lastElementChild):
     12       
     13            Switch to correct calls. ElementTraversal::previous and previousChild are no longer equivalent.
     14
     15        * dom/ElementTraversal.h:
     16        (WebCore::::lastWithinTemplate):
     17        (WebCore::::previousTemplate):
     18       
     19            Fix ElementTraversal::lastWithin and previous. They had no real clients and didn't work correctly.
     20            With LiveNodeListBase starting to use these they get excellent test coverage.
     21
     22        * dom/LiveNodeList.cpp:
     23        (WebCore::LiveNodeListBase::invalidateCache):
     24        * dom/LiveNodeList.h:
     25        (WebCore::LiveNodeListBase::LiveNodeListBase):
     26        (WebCore::LiveNodeListBase::isElementCacheValid):
     27        (WebCore::LiveNodeListBase::cachedElement):
     28        (WebCore::LiveNodeListBase::cachedElementOffset):
     29        (WebCore::LiveNodeListBase::setCachedElement):
     30       
     31            Make the cache Element based.
     32            Switch to Elements in all helpers.
     33            Rename item -> element for clarity.
     34
     35        * dom/NodeIterator.cpp:
     36        (WebCore::NodeIterator::NodePointer::moveToPrevious):
     37        (WebCore::NodeIterator::updateForNodeRemoval):
     38       
     39            This code expected the old inconsistent NodeTraversal::previous behavior where the traversal includes
     40            the root as the last item. Drop the stayWithin parameter and handle the one case where it is needed here.
     41
     42        * dom/NodeTraversal.cpp:
     43        (WebCore::NodeTraversal::last):
     44        (WebCore::NodeTraversal::deepLastChild):
     45        * dom/NodeTraversal.h:
     46       
     47            Support ElementTraversal::previous/lastWithin.
     48
     49        (WebCore::NodeTraversal::previous):
     50       
     51            This was slightly wrong too.
     52
     53        * html/HTMLCollection.cpp:
     54        (WebCore::previousElement):
     55        (WebCore::lastElement):
     56        (WebCore::LiveNodeListBase::iterateForPreviousElement):
     57        (WebCore::LiveNodeListBase::itemBefore):
     58        (WebCore::LiveNodeListBase::isLastItemCloserThanLastOrCachedItem):
     59        (WebCore::LiveNodeListBase::isFirstItemCloserThanCachedItem):
     60        (WebCore::LiveNodeListBase::setCachedElement):
     61        (WebCore::LiveNodeListBase::item):
     62        (WebCore::LiveNodeListBase::elementBeforeOrAfterCachedElement):
     63        * html/HTMLCollection.h:
     64        (WebCore::HTMLCollection::isEmpty):
     65        (WebCore::HTMLCollection::hasExactlyOneItem):
     66
    1672013-11-04  Michael Saboff  <msaboff@apple.com>
    268
  • trunk/Source/WebCore/WebCore.exp.in

    r158521 r158587  
    285285__ZN7WebCore13JSHTMLElement6s_infoE
    286286__ZN7WebCore13KeyboardEventC1ERKNS_21PlatformKeyboardEventEPNS_9DOMWindowE
     287__ZN7WebCore13NodeTraversal13deepLastChildEPNS_4NodeE
    287288__ZN7WebCore13NodeTraversal19nextAncestorSiblingEPKNS_4NodeE
    288 __ZN7WebCore13NodeTraversal8previousEPKNS_4NodeES3_
    289289__ZN7WebCore13PageThrottler22reportInterestingEventEv
    290290__ZN7WebCore13PageThrottlerD1Ev
  • trunk/Source/WebCore/dom/Element.cpp

    r158569 r158587  
    24762476Element* Element::firstElementChild() const
    24772477{
    2478     return ElementTraversal::firstWithin(this);
     2478    return ElementTraversal::firstChild(this);
    24792479}
    24802480
    24812481Element* Element::lastElementChild() const
    24822482{
    2483     return ElementTraversal::lastWithin(this);
     2483    return ElementTraversal::lastChild(this);
    24842484}
    24852485
  • trunk/Source/WebCore/dom/ElementTraversal.h

    r157375 r158587  
    4040    static ElementType* lastChild(const ContainerNode*);
    4141
    42     // First or last ElementType descendant of the node. For Elements this is always the same as first/last child.
     42    // First or last ElementType descendant of the node. For Elements firstWithin is always the same as first child.
    4343    static ElementType* firstWithin(const Node*);
    4444    static ElementType* firstWithin(const ContainerNode*);
     
    107107inline Element* Traversal<Element>::lastWithinTemplate(CurrentType* current)
    108108{
    109     return lastChildTemplate(current);
     109    Node* node = NodeTraversal::last(current);
     110    while (node && !node->isElementNode())
     111        node = NodeTraversal::previous(node, current);
     112    return static_cast<Element*>(node);
    110113}
    111114
     
    136139    Node* node = NodeTraversal::previous(current);
    137140    while (node && !node->isElementNode())
    138         node = NodeTraversal::previousSkippingChildren(node);
     141        node = NodeTraversal::previous(node);
    139142    return static_cast<Element*>(node);
    140143}
     
    146149    Node* node = NodeTraversal::previous(current, stayWithin);
    147150    while (node && !node->isElementNode())
    148         node = NodeTraversal::previousSkippingChildren(node, stayWithin);
     151        node = NodeTraversal::previous(node, stayWithin);
    149152    return static_cast<Element*>(node);
    150153}
  • trunk/Source/WebCore/dom/LiveNodeList.cpp

    r158569 r158587  
    3939void LiveNodeListBase::invalidateCache() const
    4040{
    41     m_cachedItem = 0;
     41    m_cachedElement = nullptr;
    4242    m_isLengthCacheValid = false;
    43     m_isItemCacheValid = false;
     43    m_isElementCacheValid = false;
    4444    m_isNameCacheValid = false;
    4545    m_isItemRefElementsCacheValid = false;
  • trunk/Source/WebCore/dom/LiveNodeList.h

    r158540 r158587  
    5252        bool shouldOnlyIncludeDirectChildren, CollectionType collectionType, ItemAfterOverrideType itemAfterOverrideType)
    5353        : m_ownerNode(ownerNode)
    54         , m_cachedItem(0)
     54        , m_cachedElement(nullptr)
    5555        , m_isLengthCacheValid(false)
    56         , m_isItemCacheValid(false)
     56        , m_isElementCacheValid(false)
    5757        , m_rootType(rootType)
    5858        , m_invalidationType(invalidationType)
     
    102102    bool overridesItemAfter() const { return m_overridesItemAfter; }
    103103
    104     ALWAYS_INLINE bool isItemCacheValid() const { return m_isItemCacheValid; }
    105     ALWAYS_INLINE Node* cachedItem() const { return m_cachedItem; }
    106     ALWAYS_INLINE unsigned cachedItemOffset() const { return m_cachedItemOffset; }
     104    ALWAYS_INLINE bool isElementCacheValid() const { return m_isElementCacheValid; }
     105    ALWAYS_INLINE Element* cachedElement() const { return m_cachedElement; }
     106    ALWAYS_INLINE unsigned cachedElementOffset() const { return m_cachedElementOffset; }
    107107
    108108    ALWAYS_INLINE bool isLengthCacheValid() const { return m_isLengthCacheValid; }
     
    113113        m_isLengthCacheValid = true;
    114114    }
    115     ALWAYS_INLINE void setItemCache(Node* item, unsigned offset) const
     115    ALWAYS_INLINE void setCachedElement(Element& element, unsigned offset) const
    116116    {
    117         ASSERT(item);
    118         m_cachedItem = item;
    119         m_cachedItemOffset = offset;
    120         m_isItemCacheValid = true;
     117        m_cachedElement = &element;
     118        m_cachedElementOffset = offset;
     119        m_isElementCacheValid = true;
    121120    }
    122     void setItemCache(Node* item, unsigned offset, unsigned elementsArrayOffset) const;
     121    void setCachedElement(Element&, unsigned offset, unsigned elementsArrayOffset) const;
    123122
    124123    ALWAYS_INLINE bool isItemRefElementsCacheValid() const { return m_isItemRefElementsCacheValid; }
     
    133132
    134133private:
    135     Node* itemBeforeOrAfterCachedItem(unsigned offset, ContainerNode* root) const;
     134    Element* elementBeforeOrAfterCachedElement(unsigned offset, ContainerNode* root) const;
    136135    Element* traverseLiveNodeListFirstElement(ContainerNode* root) const;
    137136    Element* traverseLiveNodeListForwardToOffset(unsigned offset, Element* currentElement, unsigned& currentOffset, ContainerNode* root) const;
    138137    bool isLastItemCloserThanLastOrCachedItem(unsigned offset) const;
    139138    bool isFirstItemCloserThanCachedItem(unsigned offset) const;
    140     Node* iterateForPreviousNode(Node* current) const;
    141     Node* itemBefore(Node* previousItem) const;
     139    Element* iterateForPreviousElement(Element* current) const;
     140    Element* itemBefore(Element* previousItem) const;
    142141
    143142    Ref<ContainerNode> m_ownerNode;
    144     mutable Node* m_cachedItem;
     143    mutable Element* m_cachedElement;
    145144    mutable unsigned m_cachedLength;
    146     mutable unsigned m_cachedItemOffset;
     145    mutable unsigned m_cachedElementOffset;
    147146    mutable unsigned m_isLengthCacheValid : 1;
    148     mutable unsigned m_isItemCacheValid : 1;
     147    mutable unsigned m_isElementCacheValid : 1;
    149148    const unsigned m_rootType : 2;
    150149    const unsigned m_invalidationType : 4;
  • trunk/Source/WebCore/dom/NodeIterator.cpp

    r158569 r158587  
    6767        return true;
    6868    }
    69     node = NodeTraversal::previous(node.get(), root);
     69    if (node == root) {
     70        node = nullptr;
     71        return false;
     72    }
     73    node = NodeTraversal::previous(node.get());
    7074    return node;
    7175}
     
    180184                referenceNode.node = node;
    181185        } else {
    182             node = NodeTraversal::previous(removedNode, root());
     186            node = NodeTraversal::previous(removedNode);
    183187            if (node) {
    184188                // Move out from under the node being removed if the reference node is
     
    186190                if (willRemoveReferenceNodeAncestor) {
    187191                    while (node && node->isDescendantOf(removedNode))
    188                         node = NodeTraversal::previous(node, root());
     192                        node = NodeTraversal::previous(node);
    189193                }
    190194                if (node) {
     
    198202        }
    199203    } else {
    200         Node* node = NodeTraversal::previous(removedNode, root());
     204        Node* node = NodeTraversal::previous(removedNode);
    201205        if (node) {
    202206            // Move out from under the node being removed if the reference node is
     
    204208            if (willRemoveReferenceNodeAncestor) {
    205209                while (node && node->isDescendantOf(removedNode))
    206                     node = NodeTraversal::previous(node, root());
     210                    node = NodeTraversal::previous(node);
    207211            }
    208212            if (node)
     
    215219            if (willRemoveReferenceNodeAncestor) {
    216220                while (node && node->isDescendantOf(removedNode))
    217                     node = NodeTraversal::previous(node, root());
     221                    node = NodeTraversal::previous(node);
    218222            }
    219223            if (node)
  • trunk/Source/WebCore/dom/NodeTraversal.cpp

    r158569 r158587  
    104104}
    105105
    106 Node* previous(const Node* current, const Node* stayWithin)
     106Node* last(const ContainerNode* current)
    107107{
    108     if (current == stayWithin)
    109         return 0;
    110     if (current->previousSibling()) {
    111         Node* previous = current->previousSibling();
    112         while (previous->lastChild())
    113             previous = previous->lastChild();
    114         return previous;
    115     }
    116     return current->parentNode();
     108    Node* node = current->lastChild();
     109    if (!node)
     110        return nullptr;
     111    while (node->lastChild())
     112        node = node->lastChild();
     113    return node;
     114}
     115
     116Node* deepLastChild(Node* node)
     117{
     118    while (node->lastChild())
     119        node = node->lastChild();
     120    return node;
    117121}
    118122
  • trunk/Source/WebCore/dom/NodeTraversal.h

    r154240 r158587  
    2626#define NodeTraversal_h
    2727
    28 #include "Node.h"
     28#include "ContainerNode.h"
    2929#include "Text.h"
    3030
     
    5050
    5151// Does a reverse pre-order traversal to find the node that comes before the current one in document order
     52Node* last(const ContainerNode*);
    5253Node* previous(const Node*, const Node* stayWithin = 0);
    5354
     
    7374Node* nextAncestorSibling(const Node*);
    7475Node* nextAncestorSibling(const Node*, const Node* stayWithin);
     76Node* deepLastChild(Node*);
    7577
    7678template <class NodeType>
     
    125127inline Node* next(const Text* current, const Node* stayWithin) { return traverseNextSkippingChildrenTemplate(current, stayWithin); }
    126128
     129inline Node* previous(const Node* current, const Node* stayWithin)
     130{
     131    if (Node* previous = current->previousSibling())
     132        return deepLastChild(previous);
     133    if (current->parentNode() == stayWithin)
     134        return nullptr;
     135    return current->parentNode();
     136}
     137
    127138}
    128139}
  • trunk/Source/WebCore/html/HTMLCollection.cpp

    r158540 r158587  
    252252}
    253253
    254 static Node* previousNode(Node& base, Node* previous, bool onlyIncludeDirectChildren)
    255 {
    256     return onlyIncludeDirectChildren ? previous->previousSibling() : NodeTraversal::previous(previous, &base);
    257 }
    258 
    259 static Node* lastNode(Node& rootNode, bool onlyIncludeDirectChildren)
    260 {
    261     return onlyIncludeDirectChildren ? rootNode.lastChild() : rootNode.lastDescendant();
    262 }
    263 
    264 ALWAYS_INLINE Node* LiveNodeListBase::iterateForPreviousNode(Node* current) const
     254static Element* previousElement(ContainerNode& base, Element* previous, bool onlyIncludeDirectChildren)
     255{
     256    return onlyIncludeDirectChildren ? ElementTraversal::previousSibling(previous) : ElementTraversal::previous(previous, &base);
     257}
     258
     259static Element* lastElement(ContainerNode& rootNode, bool onlyIncludeDirectChildren)
     260{
     261    return onlyIncludeDirectChildren ? ElementTraversal::lastChild(&rootNode) : ElementTraversal::lastWithin(&rootNode);
     262}
     263
     264ALWAYS_INLINE Element* LiveNodeListBase::iterateForPreviousElement(Element* current) const
    265265{
    266266    bool onlyIncludeDirectChildren = shouldOnlyIncludeDirectChildren();
    267267    CollectionType collectionType = type();
    268     Node& rootNode = this->rootNode();
    269     for (; current; current = previousNode(rootNode, current, onlyIncludeDirectChildren)) {
     268    ContainerNode& rootNode = this->rootNode();
     269    for (; current; current = previousElement(rootNode, current, onlyIncludeDirectChildren)) {
    270270        if (isNodeList(collectionType)) {
    271             if (current->isElementNode() && isMatchingElement(static_cast<const LiveNodeList*>(this), toElement(current)))
    272                 return toElement(current);
     271            if (isMatchingElement(static_cast<const LiveNodeList*>(this), current))
     272                return current;
    273273        } else {
    274             if (current->isElementNode() && isMatchingElement(static_cast<const HTMLCollection*>(this), toElement(current)))
    275                 return toElement(current);
     274            if (isMatchingElement(static_cast<const HTMLCollection*>(this), current))
     275                return current;
    276276        }
    277277    }
     
    279279}
    280280
    281 ALWAYS_INLINE Node* LiveNodeListBase::itemBefore(Node* previous) const
    282 {
    283     Node* current;
     281ALWAYS_INLINE Element* LiveNodeListBase::itemBefore(Element* previous) const
     282{
     283    Element* current;
    284284    if (LIKELY(!!previous)) // Without this LIKELY, length() and item() can be 10% slower.
    285         current = previousNode(rootNode(), previous, shouldOnlyIncludeDirectChildren());
     285        current = previousElement(rootNode(), previous, shouldOnlyIncludeDirectChildren());
    286286    else
    287         current = lastNode(rootNode(), shouldOnlyIncludeDirectChildren());
    288 
    289     return iterateForPreviousNode(current);
     287        current = lastElement(rootNode(), shouldOnlyIncludeDirectChildren());
     288
     289    return iterateForPreviousElement(current);
    290290}
    291291
     
    345345    ASSERT(isLengthCacheValid());
    346346    unsigned distanceFromLastItem = cachedLength() - offset;
    347     if (!isItemCacheValid())
     347    if (!isElementCacheValid())
    348348        return distanceFromLastItem < offset;
    349349
    350     return cachedItemOffset() < offset && distanceFromLastItem < offset - cachedItemOffset();
     350    return cachedElementOffset() < offset && distanceFromLastItem < offset - cachedElementOffset();
    351351}
    352352   
    353353bool ALWAYS_INLINE LiveNodeListBase::isFirstItemCloserThanCachedItem(unsigned offset) const
    354354{
    355     ASSERT(isItemCacheValid());
    356     if (cachedItemOffset() < offset)
     355    ASSERT(isElementCacheValid());
     356    if (cachedElementOffset() < offset)
    357357        return false;
    358358
    359     unsigned distanceFromCachedItem = cachedItemOffset() - offset;
     359    unsigned distanceFromCachedItem = cachedElementOffset() - offset;
    360360    return offset < distanceFromCachedItem;
    361361}
    362362
    363 ALWAYS_INLINE void LiveNodeListBase::setItemCache(Node* item, unsigned offset, unsigned elementsArrayOffset) const
    364 {
    365     setItemCache(item, offset);
    366     if (overridesItemAfter()) {
    367         ASSERT_WITH_SECURITY_IMPLICATION(item->isElementNode());
     363ALWAYS_INLINE void LiveNodeListBase::setCachedElement(Element& element, unsigned offset, unsigned elementsArrayOffset) const
     364{
     365    setCachedElement(element, offset);
     366    if (overridesItemAfter())
    368367        static_cast<const HTMLCollection*>(this)->m_cachedElementsArrayOffset = elementsArrayOffset;
    369     } else
    370         ASSERT(!elementsArrayOffset);
     368
     369    ASSERT(overridesItemAfter() || !elementsArrayOffset);
    371370}
    372371
     
    385384Node* LiveNodeListBase::item(unsigned offset) const
    386385{
    387     if (isItemCacheValid() && cachedItemOffset() == offset)
    388         return cachedItem();
     386    if (isElementCacheValid() && cachedElementOffset() == offset)
     387        return cachedElement();
    389388
    390389    if (isLengthCacheValid() && cachedLength() <= offset)
     
    394393
    395394    if (isLengthCacheValid() && !overridesItemAfter() && isLastItemCloserThanLastOrCachedItem(offset)) {
    396         Node* lastItem = itemBefore(0);
     395        Element* lastItem = itemBefore(0);
    397396        ASSERT(lastItem);
    398         setItemCache(lastItem, cachedLength() - 1, 0);
    399     } else if (!isItemCacheValid() || isFirstItemCloserThanCachedItem(offset) || (overridesItemAfter() && offset < cachedItemOffset())) {
     397        setCachedElement(*lastItem, cachedLength() - 1, 0);
     398    } else if (!isElementCacheValid() || isFirstItemCloserThanCachedItem(offset) || (overridesItemAfter() && offset < cachedElementOffset())) {
    400399        unsigned offsetInArray = 0;
    401         Node* firstItem;
     400        Element* firstItem;
    402401        if (isNodeList(type()))
    403402            firstItem = traverseLiveNodeListFirstElement(&root);
     
    409408            return 0;
    410409        }
    411         setItemCache(firstItem, 0, offsetInArray);
    412         ASSERT(!cachedItemOffset());
    413     }
    414 
    415     if (cachedItemOffset() == offset)
    416         return cachedItem();
    417 
    418     return itemBeforeOrAfterCachedItem(offset, &root);
    419 }
    420 
    421 inline Node* LiveNodeListBase::itemBeforeOrAfterCachedItem(unsigned offset, ContainerNode* root) const
    422 {
    423     unsigned currentOffset = cachedItemOffset();
    424     Node* currentItem = cachedItem();
     410        setCachedElement(*firstItem, 0, offsetInArray);
     411        ASSERT(!cachedElementOffset());
     412    }
     413
     414    if (cachedElementOffset() == offset)
     415        return cachedElement();
     416
     417    return elementBeforeOrAfterCachedElement(offset, &root);
     418}
     419
     420inline Element* LiveNodeListBase::elementBeforeOrAfterCachedElement(unsigned offset, ContainerNode* root) const
     421{
     422    unsigned currentOffset = cachedElementOffset();
     423    Element* currentItem = cachedElement();
    425424    ASSERT(currentItem);
    426425    ASSERT(currentOffset != offset);
    427426
    428     if (offset < cachedItemOffset()) {
     427    if (offset < cachedElementOffset()) {
    429428        ASSERT(!overridesItemAfter());
    430429        while ((currentItem = itemBefore(currentItem))) {
     
    432431            currentOffset--;
    433432            if (currentOffset == offset) {
    434                 setItemCache(currentItem, currentOffset, 0);
     433                setCachedElement(*currentItem, currentOffset, 0);
    435434                return currentItem;
    436435            }
     
    442441    unsigned offsetInArray = 0;
    443442    if (isNodeList(type()))
    444         currentItem = traverseLiveNodeListForwardToOffset(offset, toElement(currentItem), currentOffset, root);
     443        currentItem = traverseLiveNodeListForwardToOffset(offset, currentItem, currentOffset, root);
    445444    else
    446         currentItem = static_cast<const HTMLCollection*>(this)->traverseForwardToOffset(offset, toElement(currentItem), currentOffset, offsetInArray, root);
     445        currentItem = static_cast<const HTMLCollection*>(this)->traverseForwardToOffset(offset, currentItem, currentOffset, offsetInArray, root);
    447446
    448447    if (!currentItem) {
     
    451450        return 0;
    452451    }
    453     setItemCache(currentItem, currentOffset, offsetInArray);
     452    setCachedElement(*currentItem, currentOffset, offsetInArray);
    454453    return currentItem;
    455454}
  • trunk/Source/WebCore/html/HTMLCollection.h

    r158540 r158587  
    4949        if (isLengthCacheValid())
    5050            return !cachedLength();
    51         if (isItemCacheValid())
    52             return !cachedItem();
     51        if (isElementCacheValid())
     52            return !cachedElement();
    5353        return !item(0);
    5454    }
     
    5757        if (isLengthCacheValid())
    5858            return cachedLength() == 1;
    59         if (isItemCacheValid())
    60             return cachedItem() && !cachedItemOffset() && !item(1);
     59        if (isElementCacheValid())
     60            return cachedElement() && !cachedElementOffset() && !item(1);
    6161        return item(0) && !item(1);
    6262    }
Note: See TracChangeset for help on using the changeset viewer.