| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 for (Element* child = ElementTraversal::firstWithin(current); child; child =
ElementTraversal::nextSibling(*child)) { |
| 59 if (isHTMLTableRowElement(child)) | 59 if (isHTMLTableRowElement(child)) |
| 60 return toHTMLTableRowElement(child); | 60 return toHTMLTableRowElement(child); |
| 61 } | 61 } |
| 62 return 0; | 62 return 0; |
| 63 } | 63 } |
| 64 | 64 |
| 65 HTMLTableRowElement* HTMLTableRowsCollection::rowAfter(HTMLTableElement* table,
HTMLTableRowElement* previous) | 65 HTMLTableRowElement* HTMLTableRowsCollection::rowAfter(HTMLTableElement& table,
HTMLTableRowElement* previous) |
| 66 { | 66 { |
| 67 Element* child = 0; | 67 Element* child = 0; |
| 68 | 68 |
| 69 // Start by looking for the next row in this section. | 69 // Start by looking for the next row in this section. |
| 70 // Continue only if there is none. | 70 // Continue only if there is none. |
| 71 if (previous && previous->parentNode() != table) { | 71 if (previous && previous->parentNode() != table) { |
| 72 for (child = ElementTraversal::nextSibling(*previous); child; child = El
ementTraversal::nextSibling(*child)) { | 72 for (child = ElementTraversal::nextSibling(*previous); child; child = El
ementTraversal::nextSibling(*child)) { |
| 73 if (isHTMLTableRowElement(child)) | 73 if (isHTMLTableRowElement(child)) |
| 74 return toHTMLTableRowElement(child); | 74 return toHTMLTableRowElement(child); |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| 78 // If still looking at head sections, find the first row in the next head se
ction. | 78 // If still looking at head sections, find the first row in the next head se
ction. |
| 79 if (!previous) | 79 if (!previous) |
| 80 child = ElementTraversal::firstWithin(*table); | 80 child = ElementTraversal::firstWithin(table); |
| 81 else if (isInHead(previous)) | 81 else if (isInHead(previous)) |
| 82 child = ElementTraversal::nextSibling(*previous->parentNode()); | 82 child = ElementTraversal::nextSibling(*previous->parentNode()); |
| 83 for (; child; child = ElementTraversal::nextSibling(*child)) { | 83 for (; child; child = ElementTraversal::nextSibling(*child)) { |
| 84 if (child->hasTagName(theadTag)) { | 84 if (child->hasTagName(theadTag)) { |
| 85 if (HTMLTableRowElement* row = findTableRowElementInChildren(*child)
) | 85 if (HTMLTableRowElement* row = findTableRowElementInChildren(*child)
) |
| 86 return row; | 86 return row; |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 // If still looking at top level and bodies, find the next row in top level
or the first in the next body section. | 90 // If still looking at top level and bodies, find the next row in top level
or the first in the next body section. |
| 91 if (!previous || isInHead(previous)) | 91 if (!previous || isInHead(previous)) |
| 92 child = ElementTraversal::firstWithin(*table); | 92 child = ElementTraversal::firstWithin(table); |
| 93 else if (previous->parentNode() == table) | 93 else if (previous->parentNode() == table) |
| 94 child = ElementTraversal::nextSibling(*previous); | 94 child = ElementTraversal::nextSibling(*previous); |
| 95 else if (isInBody(previous)) | 95 else if (isInBody(previous)) |
| 96 child = ElementTraversal::nextSibling(*previous->parentNode()); | 96 child = ElementTraversal::nextSibling(*previous->parentNode()); |
| 97 for (; child; child = ElementTraversal::nextSibling(*child)) { | 97 for (; child; child = ElementTraversal::nextSibling(*child)) { |
| 98 if (isHTMLTableRowElement(child)) | 98 if (isHTMLTableRowElement(child)) |
| 99 return toHTMLTableRowElement(child); | 99 return toHTMLTableRowElement(child); |
| 100 if (child->hasTagName(tbodyTag)) { | 100 if (child->hasTagName(tbodyTag)) { |
| 101 if (HTMLTableRowElement* row = findTableRowElementInChildren(*child)
) | 101 if (HTMLTableRowElement* row = findTableRowElementInChildren(*child)
) |
| 102 return row; | 102 return row; |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 | 105 |
| 106 // Find the first row in the next foot section. | 106 // Find the first row in the next foot section. |
| 107 if (!previous || !isInFoot(previous)) | 107 if (!previous || !isInFoot(previous)) |
| 108 child = ElementTraversal::firstWithin(*table); | 108 child = ElementTraversal::firstWithin(table); |
| 109 else | 109 else |
| 110 child = ElementTraversal::nextSibling(*previous->parentNode()); | 110 child = ElementTraversal::nextSibling(*previous->parentNode()); |
| 111 for (; child; child = ElementTraversal::nextSibling(*child)) { | 111 for (; child; child = ElementTraversal::nextSibling(*child)) { |
| 112 if (child->hasTagName(tfootTag)) { | 112 if (child->hasTagName(tfootTag)) { |
| 113 if (HTMLTableRowElement* row = findTableRowElementInChildren(*child)
) | 113 if (HTMLTableRowElement* row = findTableRowElementInChildren(*child)
) |
| 114 return row; | 114 return row; |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 return 0; | 118 return 0; |
| 119 } | 119 } |
| 120 | 120 |
| 121 HTMLTableRowElement* HTMLTableRowsCollection::lastRow(HTMLTableElement* table) | 121 HTMLTableRowElement* HTMLTableRowsCollection::lastRow(HTMLTableElement& table) |
| 122 { | 122 { |
| 123 for (Node* child = table->lastChild(); child; child = child->previousSibling
()) { | 123 for (Node* child = table.lastChild(); child; child = child->previousSibling(
)) { |
| 124 if (child->hasTagName(tfootTag)) { | 124 if (child->hasTagName(tfootTag)) { |
| 125 for (Node* grandchild = child->lastChild(); grandchild; grandchild =
grandchild->previousSibling()) { | 125 for (Node* grandchild = child->lastChild(); grandchild; grandchild =
grandchild->previousSibling()) { |
| 126 if (isHTMLTableRowElement(grandchild)) | 126 if (isHTMLTableRowElement(grandchild)) |
| 127 return toHTMLTableRowElement(grandchild); | 127 return toHTMLTableRowElement(grandchild); |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 | 131 |
| 132 for (Node* child = table->lastChild(); child; child = child->previousSibling
()) { | 132 for (Node* child = table.lastChild(); child; child = child->previousSibling(
)) { |
| 133 if (isHTMLTableRowElement(child)) | 133 if (isHTMLTableRowElement(child)) |
| 134 return toHTMLTableRowElement(child); | 134 return toHTMLTableRowElement(child); |
| 135 if (child->hasTagName(tbodyTag)) { | 135 if (child->hasTagName(tbodyTag)) { |
| 136 for (Node* grandchild = child->lastChild(); grandchild; grandchild =
grandchild->previousSibling()) { | 136 for (Node* grandchild = child->lastChild(); grandchild; grandchild =
grandchild->previousSibling()) { |
| 137 if (isHTMLTableRowElement(grandchild)) | 137 if (isHTMLTableRowElement(grandchild)) |
| 138 return toHTMLTableRowElement(grandchild); | 138 return toHTMLTableRowElement(grandchild); |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 | 142 |
| 143 for (Node* child = table->lastChild(); child; child = child->previousSibling
()) { | 143 for (Node* child = table.lastChild(); child; child = child->previousSibling(
)) { |
| 144 if (child->hasTagName(theadTag)) { | 144 if (child->hasTagName(theadTag)) { |
| 145 for (Node* grandchild = child->lastChild(); grandchild; grandchild =
grandchild->previousSibling()) { | 145 for (Node* grandchild = child->lastChild(); grandchild; grandchild =
grandchild->previousSibling()) { |
| 146 if (isHTMLTableRowElement(grandchild)) | 146 if (isHTMLTableRowElement(grandchild)) |
| 147 return toHTMLTableRowElement(grandchild); | 147 return toHTMLTableRowElement(grandchild); |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 | 151 |
| 152 return 0; | 152 return 0; |
| 153 } | 153 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 165 { | 165 { |
| 166 return adoptRef(new HTMLTableRowsCollection(table)); | 166 return adoptRef(new HTMLTableRowsCollection(table)); |
| 167 } | 167 } |
| 168 | 168 |
| 169 Element* HTMLTableRowsCollection::virtualItemAfter(Element* previous) const | 169 Element* HTMLTableRowsCollection::virtualItemAfter(Element* previous) const |
| 170 { | 170 { |
| 171 return rowAfter(toHTMLTableElement(ownerNode()), toHTMLTableRowElement(previ
ous)); | 171 return rowAfter(toHTMLTableElement(ownerNode()), toHTMLTableRowElement(previ
ous)); |
| 172 } | 172 } |
| 173 | 173 |
| 174 } | 174 } |
| OLD | NEW |