| 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, 2010 Apple Inc. All rights reserved. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2010 Apple Inc. All rights reserved. |
| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 // these functions are rather slow, since we need to get the row at | 54 // these functions are rather slow, since we need to get the row at |
| 55 // the index... but they aren't used during usual HTML parsing anyway | 55 // the index... but they aren't used during usual HTML parsing anyway |
| 56 HTMLElement* HTMLTableSectionElement::insertRow( | 56 HTMLElement* HTMLTableSectionElement::insertRow( |
| 57 int index, | 57 int index, |
| 58 ExceptionState& exceptionState) { | 58 ExceptionState& exceptionState) { |
| 59 HTMLCollection* children = rows(); | 59 HTMLCollection* children = rows(); |
| 60 int numRows = children ? static_cast<int>(children->length()) : 0; | 60 int numRows = children ? static_cast<int>(children->length()) : 0; |
| 61 if (index < -1 || index > numRows) { | 61 if (index < -1 || index > numRows) { |
| 62 exceptionState.throwDOMException( | 62 exceptionState.throwDOMException( |
| 63 IndexSizeError, "The provided index (" + String::number(index) + | 63 IndexSizeError, |
| 64 " is outside the range [-1, " + | 64 "The provided index (" + String::number(index) + |
| 65 String::number(numRows) + "]."); | 65 " is outside the range [-1, " + String::number(numRows) + "]."); |
| 66 return nullptr; | 66 return nullptr; |
| 67 } | 67 } |
| 68 | 68 |
| 69 HTMLTableRowElement* row = HTMLTableRowElement::create(document()); | 69 HTMLTableRowElement* row = HTMLTableRowElement::create(document()); |
| 70 if (numRows == index || index == -1) | 70 if (numRows == index || index == -1) |
| 71 appendChild(row, exceptionState); | 71 appendChild(row, exceptionState); |
| 72 else | 72 else |
| 73 insertBefore(row, children->item(index), exceptionState); | 73 insertBefore(row, children->item(index), exceptionState); |
| 74 return row; | 74 return row; |
| 75 } | 75 } |
| 76 | 76 |
| 77 void HTMLTableSectionElement::deleteRow(int index, | 77 void HTMLTableSectionElement::deleteRow(int index, |
| 78 ExceptionState& exceptionState) { | 78 ExceptionState& exceptionState) { |
| 79 HTMLCollection* children = rows(); | 79 HTMLCollection* children = rows(); |
| 80 int numRows = children ? (int)children->length() : 0; | 80 int numRows = children ? (int)children->length() : 0; |
| 81 if (index == -1) { | 81 if (index == -1) { |
| 82 if (!numRows) | 82 if (!numRows) |
| 83 return; | 83 return; |
| 84 index = numRows - 1; | 84 index = numRows - 1; |
| 85 } | 85 } |
| 86 if (index >= 0 && index < numRows) { | 86 if (index >= 0 && index < numRows) { |
| 87 Element* row = children->item(index); | 87 Element* row = children->item(index); |
| 88 HTMLElement::removeChild(row, exceptionState); | 88 HTMLElement::removeChild(row, exceptionState); |
| 89 } else { | 89 } else { |
| 90 exceptionState.throwDOMException( | 90 exceptionState.throwDOMException( |
| 91 IndexSizeError, "The provided index (" + String::number(index) + | 91 IndexSizeError, |
| 92 " is outside the range [-1, " + | 92 "The provided index (" + String::number(index) + |
| 93 String::number(numRows) + "]."); | 93 " is outside the range [-1, " + String::number(numRows) + "]."); |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 | 96 |
| 97 HTMLCollection* HTMLTableSectionElement::rows() { | 97 HTMLCollection* HTMLTableSectionElement::rows() { |
| 98 return ensureCachedCollection<HTMLCollection>(TSectionRows); | 98 return ensureCachedCollection<HTMLCollection>(TSectionRows); |
| 99 } | 99 } |
| 100 | 100 |
| 101 } // namespace blink | 101 } // namespace blink |
| OLD | NEW |