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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 return -1; | 90 return -1; |
91 return findIndexInRowCollection(*rows, *this); | 91 return findIndexInRowCollection(*rows, *this); |
92 } | 92 } |
93 | 93 |
94 HTMLElement* HTMLTableRowElement::insertCell(int index, | 94 HTMLElement* HTMLTableRowElement::insertCell(int index, |
95 ExceptionState& exceptionState) { | 95 ExceptionState& exceptionState) { |
96 HTMLCollection* children = cells(); | 96 HTMLCollection* children = cells(); |
97 int numCells = children ? children->length() : 0; | 97 int numCells = children ? children->length() : 0; |
98 if (index < -1 || index > numCells) { | 98 if (index < -1 || index > numCells) { |
99 exceptionState.throwDOMException( | 99 exceptionState.throwDOMException( |
100 IndexSizeError, "The value provided (" + String::number(index) + | 100 IndexSizeError, |
101 ") is outside the range [-1, " + | 101 "The value provided (" + String::number(index) + |
102 String::number(numCells) + "]."); | 102 ") is outside the range [-1, " + String::number(numCells) + "]."); |
103 return nullptr; | 103 return nullptr; |
104 } | 104 } |
105 | 105 |
106 HTMLTableCellElement* cell = HTMLTableCellElement::create(tdTag, document()); | 106 HTMLTableCellElement* cell = HTMLTableCellElement::create(tdTag, document()); |
107 if (numCells == index || index == -1) | 107 if (numCells == index || index == -1) |
108 appendChild(cell, exceptionState); | 108 appendChild(cell, exceptionState); |
109 else | 109 else |
110 insertBefore(cell, children->item(index), exceptionState); | 110 insertBefore(cell, children->item(index), exceptionState); |
111 return cell; | 111 return cell; |
112 } | 112 } |
113 | 113 |
114 void HTMLTableRowElement::deleteCell(int index, | 114 void HTMLTableRowElement::deleteCell(int index, |
115 ExceptionState& exceptionState) { | 115 ExceptionState& exceptionState) { |
116 HTMLCollection* children = cells(); | 116 HTMLCollection* children = cells(); |
117 int numCells = children ? children->length() : 0; | 117 int numCells = children ? children->length() : 0; |
118 // 1. If index is less than −1 or greater than or equal to the number of | 118 // 1. If index is less than −1 or greater than or equal to the number of |
119 // elements in the cells collection, then throw "IndexSizeError". | 119 // elements in the cells collection, then throw "IndexSizeError". |
120 if (index < -1 || index >= numCells) { | 120 if (index < -1 || index >= numCells) { |
121 exceptionState.throwDOMException( | 121 exceptionState.throwDOMException( |
122 IndexSizeError, "The value provided (" + String::number(index) + | 122 IndexSizeError, |
123 ") is outside the range [0, " + | 123 "The value provided (" + String::number(index) + |
124 String::number(numCells) + ")."); | 124 ") is outside the range [0, " + String::number(numCells) + ")."); |
125 return; | 125 return; |
126 } | 126 } |
127 // 2. If index is −1, remove the last element in the cells collection | 127 // 2. If index is −1, remove the last element in the cells collection |
128 // from its parent, or do nothing if the cells collection is empty. | 128 // from its parent, or do nothing if the cells collection is empty. |
129 if (index == -1) { | 129 if (index == -1) { |
130 if (numCells == 0) | 130 if (numCells == 0) |
131 return; | 131 return; |
132 index = numCells - 1; | 132 index = numCells - 1; |
133 } | 133 } |
134 // 3. Remove the indexth element in the cells collection from its parent. | 134 // 3. Remove the indexth element in the cells collection from its parent. |
135 Element* cell = children->item(index); | 135 Element* cell = children->item(index); |
136 HTMLElement::removeChild(cell, exceptionState); | 136 HTMLElement::removeChild(cell, exceptionState); |
137 } | 137 } |
138 | 138 |
139 HTMLCollection* HTMLTableRowElement::cells() { | 139 HTMLCollection* HTMLTableRowElement::cells() { |
140 return ensureCachedCollection<HTMLCollection>(TRCells); | 140 return ensureCachedCollection<HTMLCollection>(TRCells); |
141 } | 141 } |
142 | 142 |
143 } // namespace blink | 143 } // namespace blink |
OLD | NEW |