Changeset 161583 in webkit
- Timestamp:
- Jan 9, 2014, 2:10:22 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r161577 r161583 1 2014-01-09 Antti Koivisto <antti@apple.com> 2 3 Replace ElementIteratorAdapter find() with beginAt() 4 https://bugs.webkit.org/show_bug.cgi?id=126714 5 6 Reviewed by Andreas Kling. 7 8 ElementIteratorAdapter find() would return iterator for the argument element if it was 9 of correct type and in the right subtree. This is not really what you would expect from find() 10 so replace it with a simple beginAt() iterator construction function. 11 12 * dom/DocumentOrderedMap.cpp: 13 (WebCore::DocumentOrderedMap::getAllElementsById): 14 * dom/ElementChildIterator.h: 15 (WebCore::ElementChildIteratorAdapter<ElementType>::beginAt): 16 (WebCore::ElementChildConstIteratorAdapter<ElementType>::beginAt): 17 * dom/ElementDescendantIterator.h: 18 (WebCore::ElementDescendantIteratorAdapter<ElementType>::beginAt): 19 (WebCore::ElementDescendantConstIteratorAdapter<ElementType>::beginAt): 20 * html/HTMLFormElement.cpp: 21 (WebCore::HTMLFormElement::formElementIndex): 22 * html/HTMLTableRowsCollection.cpp: 23 (WebCore::HTMLTableRowsCollection::rowAfter): 24 1 25 2014-01-09 Brian Burg <bburg@apple.com> 2 26 -
trunk/Source/WebCore/dom/DocumentOrderedMap.cpp
r161572 r161583 212 212 entry.orderedList.reserveCapacity(entry.count); 213 213 auto elementDescandents = descendantsOfType<Element>(*scope.rootNode()); 214 auto it = entry.element ? elementDescandents. find(*entry.element) : elementDescandents.begin();214 auto it = entry.element ? elementDescandents.beginAt(*entry.element) : elementDescandents.begin(); 215 215 auto end = elementDescandents.end(); 216 216 for (; it != end; ++it) { -
trunk/Source/WebCore/dom/ElementChildIterator.h
r161551 r161583 54 54 ElementChildIterator<ElementType> begin(); 55 55 ElementChildIterator<ElementType> end(); 56 ElementChildIterator<ElementType> find(Element&);56 ElementChildIterator<ElementType> beginAt(ElementType&); 57 57 58 58 ElementType* first(); … … 70 70 ElementChildConstIterator<ElementType> begin() const; 71 71 ElementChildConstIterator<ElementType> end() const; 72 ElementChildConstIterator<ElementType> find(const Element&) const;72 ElementChildConstIterator<ElementType> beginAt(const ElementType&) const; 73 73 74 74 const ElementType* first() const; … … 155 155 156 156 template <typename ElementType> 157 inline ElementChildIterator<ElementType> ElementChildIteratorAdapter<ElementType>::find(Element& child) 158 { 159 if (!isElementOfType<const ElementType>(child)) 160 return end(); 161 if (child.parentNode() != &m_parent) 162 return end(); 163 return ElementChildIterator<ElementType>(m_parent, static_cast<ElementType*>(&child)); 157 inline ElementChildIterator<ElementType> ElementChildIteratorAdapter<ElementType>::beginAt(ElementType& child) 158 { 159 ASSERT(child.parentNode() == &m_parent); 160 return ElementChildIterator<ElementType>(m_parent, &child); 164 161 } 165 162 … … 197 194 198 195 template <typename ElementType> 199 inline ElementChildConstIterator<ElementType> ElementChildConstIteratorAdapter<ElementType>::find(const Element& child) const 200 { 201 if (!isElementOfType<const ElementType>(child)) 202 return end(); 203 if (child.parentNode() != &m_parent) 204 return end(); 205 return ElementChildConstIterator<ElementType>(m_parent, static_cast<const ElementType*>(&child)); 196 inline ElementChildConstIterator<ElementType> ElementChildConstIteratorAdapter<ElementType>::beginAt(const ElementType& child) const 197 { 198 ASSERT(child.parentNode() == &m_parent); 199 return ElementChildConstIterator<ElementType>(m_parent, &child); 206 200 } 207 201 -
trunk/Source/WebCore/dom/ElementDescendantIterator.h
r161196 r161583 53 53 ElementDescendantIterator<ElementType> begin(); 54 54 ElementDescendantIterator<ElementType> end(); 55 ElementDescendantIterator<ElementType> find(Element&);55 ElementDescendantIterator<ElementType> beginAt(ElementType&); 56 56 ElementDescendantIterator<ElementType> from(Element&); 57 57 … … 69 69 ElementDescendantConstIterator<ElementType> begin() const; 70 70 ElementDescendantConstIterator<ElementType> end() const; 71 ElementDescendantConstIterator<ElementType> find(const Element&) const;71 ElementDescendantConstIterator<ElementType> beginAt(const ElementType&) const; 72 72 ElementDescendantConstIterator<ElementType> from(const Element&) const; 73 73 … … 144 144 145 145 template <typename ElementType> 146 inline ElementDescendantIterator<ElementType> ElementDescendantIteratorAdapter<ElementType>::find(Element& descendant) 147 { 148 if (!isElementOfType<const ElementType>(descendant)) 149 return end(); 150 if (!descendant.isDescendantOf(&m_root)) 151 return end(); 146 inline ElementDescendantIterator<ElementType> ElementDescendantIteratorAdapter<ElementType>::beginAt(ElementType& descendant) 147 { 148 ASSERT(descendant.isDescendantOf(&m_root)); 152 149 return ElementDescendantIterator<ElementType>(m_root, static_cast<ElementType*>(&descendant)); 153 150 } … … 196 193 197 194 template <typename ElementType> 198 inline ElementDescendantConstIterator<ElementType> ElementDescendantConstIteratorAdapter<ElementType>::find(const Element& descendant) const 199 { 200 if (!isElementOfType<const ElementType>(descendant)) 201 return end(); 202 if (!descendant.isDescendantOf(&m_root)) 203 return end(); 204 return ElementDescendantConstIterator<ElementType>(m_root, static_cast<const ElementType*>(&descendant)); 195 inline ElementDescendantConstIterator<ElementType> ElementDescendantConstIteratorAdapter<ElementType>::beginAt(const ElementType& descendant) const 196 { 197 ASSERT(descendant.isDescendantOf(&m_root)); 198 return ElementDescendantConstIterator<ElementType>(m_root, &descendant); 205 199 } 206 200 -
trunk/Source/WebCore/html/HTMLFormElement.cpp
r161166 r161583 505 505 ++m_associatedElementsAfterIndex; 506 506 507 if (!associatedHTMLElement.isDescendantOf(this)) 508 return currentAssociatedElementsAfterIndex; 509 507 510 // Check for the special case where this element is the very last thing in 508 511 // the form's tree of children; we don't want to walk the entire tree in that … … 510 513 // that says "add this form element to the end of the array". 511 514 auto descendants = descendantsOfType<HTMLElement>(*this); 512 auto it = descendants. find(associatedHTMLElement);515 auto it = descendants.beginAt(associatedHTMLElement); 513 516 auto end = descendants.end(); 514 if ( it == end ||++it == end)517 if (++it == end) 515 518 return currentAssociatedElementsAfterIndex; 516 519 -
trunk/Source/WebCore/html/HTMLTableRowsCollection.cpp
r161551 r161583 71 71 // Start by looking for the next row in this section. Continue only if there is none. 72 72 if (previous && previous->parentNode() != table) { 73 auto rows = childrenOfType<HTMLTableRowElement>(*previous->parentNode());74 auto row = rows.find(*previous);75 if (++row != rows.end())73 auto childRows = childrenOfType<HTMLTableRowElement>(*previous->parentNode()); 74 auto row = childRows.beginAt(*previous); 75 if (++row != childRows.end()) 76 76 return &*row; 77 77 }
Note:
See TracChangeset
for help on using the changeset viewer.