| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) | 2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) |
| 3 * (C) 1997 Torben Weis (weis@kde.org) | 3 * (C) 1997 Torben Weis (weis@kde.org) |
| 4 * (C) 1998 Waldo Bastian (bastian@kde.org) | 4 * (C) 1998 Waldo Bastian (bastian@kde.org) |
| 5 * (C) 1999 Lars Knoll (knoll@kde.org) | 5 * (C) 1999 Lars Knoll (knoll@kde.org) |
| 6 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 6 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserv
ed. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserv
ed. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 PassRefPtr<HTMLElement> HTMLTableRowElement::insertCell(int index, ExceptionStat
e& exceptionState) | 128 PassRefPtr<HTMLElement> HTMLTableRowElement::insertCell(int index, ExceptionStat
e& exceptionState) |
| 129 { | 129 { |
| 130 RefPtr<HTMLCollection> children = cells(); | 130 RefPtr<HTMLCollection> children = cells(); |
| 131 int numCells = children ? children->length() : 0; | 131 int numCells = children ? children->length() : 0; |
| 132 if (index < -1 || index > numCells) { | 132 if (index < -1 || index > numCells) { |
| 133 exceptionState.throwDOMException(IndexSizeError, "The value provided ("
+ String::number(index) + ") is outside the range [-1, " + String::number(numCel
ls) + "]."); | 133 exceptionState.throwDOMException(IndexSizeError, "The value provided ("
+ String::number(index) + ") is outside the range [-1, " + String::number(numCel
ls) + "]."); |
| 134 return nullptr; | 134 return nullptr; |
| 135 } | 135 } |
| 136 | 136 |
| 137 RefPtr<HTMLTableCellElement> cell = HTMLTableCellElement::create(tdTag, docu
ment()); | 137 RefPtr<HTMLTableCellElement> cell = HTMLTableCellElement::create(tdTag, docu
ment()); |
| 138 if (index < 0 || index >= numCells) | 138 if (numCells == index || index == -1) |
| 139 appendChild(cell, exceptionState); | 139 appendChild(cell, exceptionState); |
| 140 else { | 140 else |
| 141 Node* n; | 141 insertBefore(cell, children->item(index), exceptionState); |
| 142 if (index < 1) | |
| 143 n = firstChild(); | |
| 144 else | |
| 145 n = children->item(index); | |
| 146 insertBefore(cell, n, exceptionState); | |
| 147 } | |
| 148 return cell.release(); | 142 return cell.release(); |
| 149 } | 143 } |
| 150 | 144 |
| 151 void HTMLTableRowElement::deleteCell(int index, ExceptionState& exceptionState) | 145 void HTMLTableRowElement::deleteCell(int index, ExceptionState& exceptionState) |
| 152 { | 146 { |
| 153 RefPtr<HTMLCollection> children = cells(); | 147 RefPtr<HTMLCollection> children = cells(); |
| 154 int numCells = children ? children->length() : 0; | 148 int numCells = children ? children->length() : 0; |
| 155 if (index == -1) | 149 if (index == -1) |
| 156 index = numCells-1; | 150 index = numCells-1; |
| 157 if (index >= 0 && index < numCells) { | 151 if (index >= 0 && index < numCells) { |
| 158 RefPtr<Element> cell = children->item(index); | 152 RefPtr<Element> cell = children->item(index); |
| 159 HTMLElement::removeChild(cell.get(), exceptionState); | 153 HTMLElement::removeChild(cell.get(), exceptionState); |
| 160 } else { | 154 } else { |
| 161 exceptionState.throwDOMException(IndexSizeError, "The value provided ("
+ String::number(index) + ") is outside the range [0, " + String::number(numCell
s) + ")."); | 155 exceptionState.throwDOMException(IndexSizeError, "The value provided ("
+ String::number(index) + ") is outside the range [0, " + String::number(numCell
s) + ")."); |
| 162 } | 156 } |
| 163 } | 157 } |
| 164 | 158 |
| 165 PassRefPtr<HTMLCollection> HTMLTableRowElement::cells() | 159 PassRefPtr<HTMLCollection> HTMLTableRowElement::cells() |
| 166 { | 160 { |
| 167 return ensureCachedHTMLCollection(TRCells); | 161 return ensureCachedHTMLCollection(TRCells); |
| 168 } | 162 } |
| 169 | 163 |
| 170 } | 164 } |
| OLD | NEW |