OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2011, 2012 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 return row->parentNode() && toElement(row->parentNode())->hasLocalName(tbody
Tag); | 48 return row->parentNode() && toElement(row->parentNode())->hasLocalName(tbody
Tag); |
49 } | 49 } |
50 | 50 |
51 static bool isInFoot(Element* row) | 51 static bool isInFoot(Element* row) |
52 { | 52 { |
53 return row->parentNode() && toElement(row->parentNode())->hasLocalName(tfoot
Tag); | 53 return row->parentNode() && toElement(row->parentNode())->hasLocalName(tfoot
Tag); |
54 } | 54 } |
55 | 55 |
56 static inline HTMLTableRowElement* findTableRowElementInChildren(Element& curren
t) | 56 static inline HTMLTableRowElement* findTableRowElementInChildren(Element& curren
t) |
57 { | 57 { |
58 for (Element* child = ElementTraversal::firstWithin(current); child; child =
ElementTraversal::nextSibling(*child)) { | 58 return Traversal<HTMLTableRowElement>::firstChild(current); |
59 if (isHTMLTableRowElement(child)) | |
60 return toHTMLTableRowElement(child); | |
61 } | |
62 return 0; | |
63 } | 59 } |
64 | 60 |
65 HTMLTableRowElement* HTMLTableRowsCollection::rowAfter(HTMLTableElement& table,
HTMLTableRowElement* previous) | 61 HTMLTableRowElement* HTMLTableRowsCollection::rowAfter(HTMLTableElement& table,
HTMLTableRowElement* previous) |
66 { | 62 { |
67 Element* child = 0; | 63 Element* child = 0; |
68 | 64 |
69 // Start by looking for the next row in this section. | 65 // Start by looking for the next row in this section. |
70 // Continue only if there is none. | 66 // Continue only if there is none. |
71 if (previous && previous->parentNode() != table) { | 67 if (previous && previous->parentNode() != table) { |
72 for (child = ElementTraversal::nextSibling(*previous); child; child = El
ementTraversal::nextSibling(*child)) { | 68 if (HTMLTableRowElement* row = Traversal<HTMLTableRowElement>::nextSibli
ng(*previous)) |
73 if (isHTMLTableRowElement(child)) | 69 return row; |
74 return toHTMLTableRowElement(child); | |
75 } | |
76 } | 70 } |
77 | 71 |
78 // If still looking at head sections, find the first row in the next head se
ction. | 72 // If still looking at head sections, find the first row in the next head se
ction. |
79 if (!previous) | 73 if (!previous) |
80 child = ElementTraversal::firstWithin(table); | 74 child = ElementTraversal::firstWithin(table); |
81 else if (isInHead(previous)) | 75 else if (isInHead(previous)) |
82 child = ElementTraversal::nextSibling(*previous->parentNode()); | 76 child = ElementTraversal::nextSibling(*previous->parentNode()); |
83 for (; child; child = ElementTraversal::nextSibling(*child)) { | 77 for (; child; child = ElementTraversal::nextSibling(*child)) { |
84 if (child->hasTagName(theadTag)) { | 78 if (child->hasTagName(theadTag)) { |
85 if (HTMLTableRowElement* row = findTableRowElementInChildren(*child)
) | 79 if (HTMLTableRowElement* row = findTableRowElementInChildren(*child)
) |
(...skipping 29 matching lines...) Expand all Loading... |
115 } | 109 } |
116 } | 110 } |
117 | 111 |
118 return 0; | 112 return 0; |
119 } | 113 } |
120 | 114 |
121 HTMLTableRowElement* HTMLTableRowsCollection::lastRow(HTMLTableElement& table) | 115 HTMLTableRowElement* HTMLTableRowsCollection::lastRow(HTMLTableElement& table) |
122 { | 116 { |
123 for (Node* child = table.lastChild(); child; child = child->previousSibling(
)) { | 117 for (Node* child = table.lastChild(); child; child = child->previousSibling(
)) { |
124 if (child->hasTagName(tfootTag)) { | 118 if (child->hasTagName(tfootTag)) { |
125 for (Node* grandchild = child->lastChild(); grandchild; grandchild =
grandchild->previousSibling()) { | 119 if (HTMLTableRowElement* lastRow = Traversal<HTMLTableRowElement>::l
astChild(*child)) |
126 if (isHTMLTableRowElement(grandchild)) | 120 return lastRow; |
127 return toHTMLTableRowElement(grandchild); | |
128 } | |
129 } | 121 } |
130 } | 122 } |
131 | 123 |
132 for (Node* child = table.lastChild(); child; child = child->previousSibling(
)) { | 124 for (Node* child = table.lastChild(); child; child = child->previousSibling(
)) { |
133 if (isHTMLTableRowElement(child)) | 125 if (isHTMLTableRowElement(child)) |
134 return toHTMLTableRowElement(child); | 126 return toHTMLTableRowElement(child); |
135 if (child->hasTagName(tbodyTag)) { | 127 if (child->hasTagName(tbodyTag)) { |
136 for (Node* grandchild = child->lastChild(); grandchild; grandchild =
grandchild->previousSibling()) { | 128 if (HTMLTableRowElement* lastRow = Traversal<HTMLTableRowElement>::l
astChild(*child)) |
137 if (isHTMLTableRowElement(grandchild)) | 129 return lastRow; |
138 return toHTMLTableRowElement(grandchild); | |
139 } | |
140 } | 130 } |
141 } | 131 } |
142 | 132 |
143 for (Node* child = table.lastChild(); child; child = child->previousSibling(
)) { | 133 for (Node* child = table.lastChild(); child; child = child->previousSibling(
)) { |
144 if (child->hasTagName(theadTag)) { | 134 if (child->hasTagName(theadTag)) { |
145 for (Node* grandchild = child->lastChild(); grandchild; grandchild =
grandchild->previousSibling()) { | 135 if (HTMLTableRowElement* lastRow = Traversal<HTMLTableRowElement>::l
astChild(*child)) |
146 if (isHTMLTableRowElement(grandchild)) | 136 return lastRow; |
147 return toHTMLTableRowElement(grandchild); | |
148 } | |
149 } | 137 } |
150 } | 138 } |
151 | 139 |
152 return 0; | 140 return 0; |
153 } | 141 } |
154 | 142 |
155 // Must call get() on the table in case that argument is compiled before derefer
encing the | 143 // Must call get() on the table in case that argument is compiled before derefer
encing the |
156 // table to get at the collection cache. Order of argument evaluation is undefin
ed and can | 144 // table to get at the collection cache. Order of argument evaluation is undefin
ed and can |
157 // differ between compilers. | 145 // differ between compilers. |
158 HTMLTableRowsCollection::HTMLTableRowsCollection(ContainerNode* table) | 146 HTMLTableRowsCollection::HTMLTableRowsCollection(ContainerNode* table) |
159 : HTMLCollection(table, TableRows, OverridesItemAfter) | 147 : HTMLCollection(table, TableRows, OverridesItemAfter) |
160 { | 148 { |
161 ASSERT(isHTMLTableElement(table)); | 149 ASSERT(isHTMLTableElement(table)); |
162 } | 150 } |
163 | 151 |
164 PassRefPtr<HTMLTableRowsCollection> HTMLTableRowsCollection::create(ContainerNod
e* table, CollectionType) | 152 PassRefPtr<HTMLTableRowsCollection> HTMLTableRowsCollection::create(ContainerNod
e* table, CollectionType) |
165 { | 153 { |
166 return adoptRef(new HTMLTableRowsCollection(table)); | 154 return adoptRef(new HTMLTableRowsCollection(table)); |
167 } | 155 } |
168 | 156 |
169 Element* HTMLTableRowsCollection::virtualItemAfter(Element* previous) const | 157 Element* HTMLTableRowsCollection::virtualItemAfter(Element* previous) const |
170 { | 158 { |
171 return rowAfter(toHTMLTableElement(ownerNode()), toHTMLTableRowElement(previ
ous)); | 159 return rowAfter(toHTMLTableElement(ownerNode()), toHTMLTableRowElement(previ
ous)); |
172 } | 160 } |
173 | 161 |
174 } | 162 } |
OLD | NEW |