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 | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights |
8 * reserved. | 8 * reserved. |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 appendChild(cell, exceptionState); | 107 appendChild(cell, exceptionState); |
108 else | 108 else |
109 insertBefore(cell, children->item(index), exceptionState); | 109 insertBefore(cell, children->item(index), exceptionState); |
110 return cell; | 110 return cell; |
111 } | 111 } |
112 | 112 |
113 void HTMLTableRowElement::deleteCell(int index, | 113 void HTMLTableRowElement::deleteCell(int index, |
114 ExceptionState& exceptionState) { | 114 ExceptionState& exceptionState) { |
115 HTMLCollection* children = cells(); | 115 HTMLCollection* children = cells(); |
116 int numCells = children ? children->length() : 0; | 116 int numCells = children ? children->length() : 0; |
117 if (index == -1) | 117 // 1. If index is less than −1 or greater than or equal to the number of |
118 index = numCells - 1; | 118 // elements in the cells collection, then throw "IndexSizeError". |
119 if (index >= 0 && index < numCells) { | 119 if (index < -1 || index >= numCells) { |
120 Element* cell = children->item(index); | |
121 HTMLElement::removeChild(cell, exceptionState); | |
122 } else { | |
123 exceptionState.throwDOMException( | 120 exceptionState.throwDOMException( |
124 IndexSizeError, "The value provided (" + String::number(index) + | 121 IndexSizeError, "The value provided (" + String::number(index) + |
125 ") is outside the range [0, " + | 122 ") is outside the range [0, " + |
126 String::number(numCells) + ")."); | 123 String::number(numCells) + ")."); |
| 124 return; |
127 } | 125 } |
| 126 // 2. If index is −1, remove the last element in the cells collection |
| 127 // from its parent, or do nothing if the cells collection is empty. |
| 128 if (index == -1) { |
| 129 if (numCells == 0) |
| 130 return; |
| 131 index = numCells - 1; |
| 132 } |
| 133 // 3. Remove the indexth element in the cells collection from its parent. |
| 134 Element* cell = children->item(index); |
| 135 HTMLElement::removeChild(cell, exceptionState); |
128 } | 136 } |
129 | 137 |
130 HTMLCollection* HTMLTableRowElement::cells() { | 138 HTMLCollection* HTMLTableRowElement::cells() { |
131 return ensureCachedCollection<HTMLCollection>(TRCells); | 139 return ensureCachedCollection<HTMLCollection>(TRCells); |
132 } | 140 } |
133 | 141 |
134 } // namespace blink | 142 } // namespace blink |
OLD | NEW |