Changeset 161551 in webkit
- Timestamp:
- Jan 9, 2014, 2:20:39 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r161549 r161551 1 2014-01-09 Antti Koivisto <antti@apple.com> 2 3 Switch HTMLTableRowsCollection from Traversal<> to iterators 4 https://bugs.webkit.org/show_bug.cgi?id=126684 5 6 Reviewed by Andreas Kling. 7 8 This is the last remaining client of Traversal<> outside the iterator implementation. 9 10 * dom/ElementChildIterator.h: 11 (WebCore::ElementChildIteratorAdapter<ElementType>::find): 12 (WebCore::ElementChildConstIteratorAdapter<ElementType>::find): 13 14 Add find with the same semantics as ElementDescendantIterator::find. 15 16 * html/HTMLTableRowsCollection.cpp: 17 (WebCore::HTMLTableRowsCollection::rowAfter): 18 (WebCore::HTMLTableRowsCollection::lastRow): 19 1 20 2014-01-08 Carlos Garcia Campos <cgarcia@igalia.com> 2 21 -
trunk/Source/WebCore/dom/ElementChildIterator.h
r161196 r161551 51 51 public: 52 52 ElementChildIteratorAdapter(ContainerNode& parent); 53 53 54 ElementChildIterator<ElementType> begin(); 54 55 ElementChildIterator<ElementType> end(); 56 ElementChildIterator<ElementType> find(Element&); 57 55 58 ElementType* first(); 56 59 ElementType* last(); … … 64 67 public: 65 68 ElementChildConstIteratorAdapter(const ContainerNode& parent); 69 66 70 ElementChildConstIterator<ElementType> begin() const; 67 71 ElementChildConstIterator<ElementType> end() const; 72 ElementChildConstIterator<ElementType> find(const Element&) const; 73 68 74 const ElementType* first() const; 69 75 const ElementType* last() const; … … 148 154 } 149 155 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)); 164 } 165 150 166 // ElementChildConstIteratorAdapter 151 167 … … 180 196 } 181 197 198 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)); 206 } 207 182 208 // Standalone functions 183 209 -
trunk/Source/WebCore/html/HTMLTableRowsCollection.cpp
r158758 r161551 30 30 #include "HTMLTableRowsCollection.h" 31 31 32 #include "Element Traversal.h"32 #include "ElementIterator.h" 33 33 #include "HTMLNames.h" 34 34 #include "HTMLTableElement.h" … … 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 if (auto row = Traversal<HTMLTableRowElement>::nextSibling(previous)) 74 return row; 73 auto rows = childrenOfType<HTMLTableRowElement>(*previous->parentNode()); 74 auto row = rows.find(*previous); 75 if (++row != rows.end()) 76 return &*row; 75 77 } 76 78 77 Element* child = 0;79 Element* child = nullptr; 78 80 79 81 // If still looking at head sections, find the first row in the next head section. … … 84 86 for (; child; child = ElementTraversal::nextSibling(child)) { 85 87 if (child->hasTagName(theadTag)) { 86 if (auto row = Traversal<HTMLTableRowElement>::firstChild(child))88 if (auto row = childrenOfType<HTMLTableRowElement>(*child).first()) 87 89 return row; 88 90 } … … 100 102 return toHTMLTableRowElement(child); 101 103 if (child->hasTagName(tbodyTag)) { 102 if (auto row = Traversal<HTMLTableRowElement>::firstChild(child))104 if (auto row = childrenOfType<HTMLTableRowElement>(*child).first()) 103 105 return row; 104 106 } … … 112 114 for (; child; child = ElementTraversal::nextSibling(child)) { 113 115 if (child->hasTagName(tfootTag)) { 114 if (auto row = Traversal<HTMLTableRowElement>::firstChild(child))116 if (auto row = childrenOfType<HTMLTableRowElement>(*child).first()) 115 117 return row; 116 118 } 117 119 } 118 120 119 return 0;121 return nullptr; 120 122 } 121 123 … … 124 126 for (auto child = ElementTraversal::lastChild(table); child; child = ElementTraversal::previousSibling(child)) { 125 127 if (child->hasTagName(tfootTag)) { 126 if (auto row = Traversal<HTMLTableRowElement>::lastChild(child))128 if (auto row = childrenOfType<HTMLTableRowElement>(*child).last()) 127 129 return row; 128 130 } … … 133 135 return toHTMLTableRowElement(child); 134 136 if (child->hasTagName(tbodyTag)) { 135 if (auto row = Traversal<HTMLTableRowElement>::lastChild(child))137 if (auto row = childrenOfType<HTMLTableRowElement>(*child).last()) 136 138 return row; 137 139 } … … 140 142 for (auto child = ElementTraversal::lastChild(table); child; child = ElementTraversal::previousSibling(child)) { 141 143 if (child->hasTagName(theadTag)) { 142 if (auto row = Traversal<HTMLTableRowElement>::lastChild(child))144 if (auto row = childrenOfType<HTMLTableRowElement>(*child).last()) 143 145 return row; 144 146 } 145 147 } 146 148 147 return 0;149 return nullptr; 148 150 } 149 151
Note:
See TracChangeset
for help on using the changeset viewer.