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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 PassRefPtr<HTMLElement> HTMLTableSectionElement::insertRow(int index, ExceptionS
tate& exceptionState) | 66 PassRefPtr<HTMLElement> HTMLTableSectionElement::insertRow(int index, ExceptionS
tate& exceptionState) |
67 { | 67 { |
68 RefPtr<HTMLCollection> children = rows(); | 68 RefPtr<HTMLCollection> children = rows(); |
69 int numRows = children ? static_cast<int>(children->length()) : 0; | 69 int numRows = children ? static_cast<int>(children->length()) : 0; |
70 if (index < -1 || index > numRows) { | 70 if (index < -1 || index > numRows) { |
71 exceptionState.throwDOMException(IndexSizeError, "The provided index ("
+ String::number(index) + " is outside the range [-1, " + String::number(numRows
) + "]."); | 71 exceptionState.throwDOMException(IndexSizeError, "The provided index ("
+ String::number(index) + " is outside the range [-1, " + String::number(numRows
) + "]."); |
72 return nullptr; | 72 return nullptr; |
73 } | 73 } |
74 | 74 |
75 RefPtr<HTMLTableRowElement> row = HTMLTableRowElement::create(document()); | 75 RefPtr<HTMLTableRowElement> row = HTMLTableRowElement::create(document()); |
76 if (numRows == index || index == -1) { | 76 if (numRows == index || index == -1) |
77 appendChild(row, exceptionState); | 77 appendChild(row, exceptionState); |
78 } else { | 78 else |
79 Node* n = index ? children->item(index) : firstChild(); | 79 insertBefore(row, children->item(index), exceptionState); |
80 insertBefore(row, n, exceptionState); | |
81 } | |
82 return row.release(); | 80 return row.release(); |
83 } | 81 } |
84 | 82 |
85 void HTMLTableSectionElement::deleteRow(int index, ExceptionState& exceptionStat
e) | 83 void HTMLTableSectionElement::deleteRow(int index, ExceptionState& exceptionStat
e) |
86 { | 84 { |
87 RefPtr<HTMLCollection> children = rows(); | 85 RefPtr<HTMLCollection> children = rows(); |
88 int numRows = children ? (int)children->length() : 0; | 86 int numRows = children ? (int)children->length() : 0; |
89 if (index == -1) | 87 if (index == -1) |
90 index = numRows - 1; | 88 index = numRows - 1; |
91 if (index >= 0 && index < numRows) { | 89 if (index >= 0 && index < numRows) { |
(...skipping 11 matching lines...) Expand all Loading... |
103 ++rowCount; | 101 ++rowCount; |
104 return rowCount; | 102 return rowCount; |
105 } | 103 } |
106 | 104 |
107 PassRefPtr<HTMLCollection> HTMLTableSectionElement::rows() | 105 PassRefPtr<HTMLCollection> HTMLTableSectionElement::rows() |
108 { | 106 { |
109 return ensureCachedHTMLCollection(TSectionRows); | 107 return ensureCachedHTMLCollection(TSectionRows); |
110 } | 108 } |
111 | 109 |
112 } | 110 } |
OLD | NEW |