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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 return adoptRef(new HTMLTableSectionElement(tagName, document)); | 48 return adoptRef(new HTMLTableSectionElement(tagName, document)); |
49 } | 49 } |
50 | 50 |
51 const StylePropertySet* HTMLTableSectionElement::additionalPresentationAttribute Style() | 51 const StylePropertySet* HTMLTableSectionElement::additionalPresentationAttribute Style() |
52 { | 52 { |
53 if (HTMLTableElement* table = findParentTable()) | 53 if (HTMLTableElement* table = findParentTable()) |
54 return table->additionalGroupStyle(true); | 54 return table->additionalGroupStyle(true); |
55 return 0; | 55 return 0; |
56 } | 56 } |
57 | 57 |
58 PassRefPtr<HTMLElement> HTMLTableSectionElement::insertRow(ExceptionState& excep tionState) | |
59 { | |
60 // The default 'index' argument value is -1. | |
61 return insertRow(-1, exceptionState); | |
62 } | |
63 | |
58 // these functions are rather slow, since we need to get the row at | 64 // these functions are rather slow, since we need to get the row at |
59 // the index... but they aren't used during usual HTML parsing anyway | 65 // the index... but they aren't used during usual HTML parsing anyway |
60 PassRefPtr<HTMLElement> HTMLTableSectionElement::insertRow(int index, ExceptionS tate& exceptionState) | 66 PassRefPtr<HTMLElement> HTMLTableSectionElement::insertRow(int index, ExceptionS tate& exceptionState) |
61 { | 67 { |
62 RefPtr<HTMLTableRowElement> row; | |
63 RefPtr<HTMLCollection> children = rows(); | 68 RefPtr<HTMLCollection> children = rows(); |
64 int numRows = children ? (int)children->length() : 0; | 69 int numRows = children ? static_cast<int>(children->length()) : 0; |
65 if (index < -1 || index > numRows) { | 70 if (index < -1 || index > numRows) { |
eseidel
2014/05/05 15:33:42
Lame that indicies don't work like python here. :)
| |
66 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; | |
73 } | |
74 | |
75 RefPtr<HTMLTableRowElement> row = HTMLTableRowElement::create(document()); | |
76 if (numRows == index || index == -1) { | |
77 appendChild(row, exceptionState); | |
67 } else { | 78 } else { |
68 row = HTMLTableRowElement::create(document()); | 79 Node* n = index ? children->item(index) : firstChild(); |
arv (Not doing code reviews)
2014/05/06 17:53:42
fistChild does not seem right here. It should be f
Inactive
2014/05/06 17:57:54
Oh, I thought this looked weird as well when I ref
Inactive
2014/05/06 18:55:45
Yes, I confirmed we behave differently thatn Firef
| |
69 if (numRows == index || index == -1) | 80 insertBefore(row, n, exceptionState); |
70 appendChild(row, exceptionState); | |
71 else { | |
72 Node* n; | |
73 if (index < 1) | |
74 n = firstChild(); | |
75 else | |
76 n = children->item(index); | |
77 insertBefore(row, n, exceptionState); | |
78 } | |
79 } | 81 } |
80 return row.release(); | 82 return row.release(); |
81 } | 83 } |
82 | 84 |
83 void HTMLTableSectionElement::deleteRow(int index, ExceptionState& exceptionStat e) | 85 void HTMLTableSectionElement::deleteRow(int index, ExceptionState& exceptionStat e) |
84 { | 86 { |
85 RefPtr<HTMLCollection> children = rows(); | 87 RefPtr<HTMLCollection> children = rows(); |
86 int numRows = children ? (int)children->length() : 0; | 88 int numRows = children ? (int)children->length() : 0; |
87 if (index == -1) | 89 if (index == -1) |
88 index = numRows - 1; | 90 index = numRows - 1; |
(...skipping 12 matching lines...) Expand all Loading... | |
101 ++rowCount; | 103 ++rowCount; |
102 return rowCount; | 104 return rowCount; |
103 } | 105 } |
104 | 106 |
105 PassRefPtr<HTMLCollection> HTMLTableSectionElement::rows() | 107 PassRefPtr<HTMLCollection> HTMLTableSectionElement::rows() |
106 { | 108 { |
107 return ensureCachedHTMLCollection(TSectionRows); | 109 return ensureCachedHTMLCollection(TSectionRows); |
108 } | 110 } |
109 | 111 |
110 } | 112 } |
OLD | NEW |