| 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 reserv
ed. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserv
ed. |
| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 int HTMLTableRowElement::rowIndex() const | 59 int HTMLTableRowElement::rowIndex() const |
| 60 { | 60 { |
| 61 ContainerNode* maybeTable = parentNode(); | 61 ContainerNode* maybeTable = parentNode(); |
| 62 if (maybeTable && isHTMLTableSectionElement(maybeTable)) { | 62 if (maybeTable && isHTMLTableSectionElement(maybeTable)) { |
| 63 // Skip THEAD, TBODY and TFOOT. | 63 // Skip THEAD, TBODY and TFOOT. |
| 64 maybeTable = maybeTable->parentNode(); | 64 maybeTable = maybeTable->parentNode(); |
| 65 } | 65 } |
| 66 if (!(maybeTable && isHTMLTableElement(maybeTable))) | 66 if (!(maybeTable && isHTMLTableElement(maybeTable))) |
| 67 return -1; | 67 return -1; |
| 68 | 68 |
| 69 RefPtrWillBeRawPtr<HTMLTableRowsCollection> rows = | 69 RawPtr<HTMLTableRowsCollection> rows = |
| 70 toHTMLTableElement(maybeTable)->rows(); | 70 toHTMLTableElement(maybeTable)->rows(); |
| 71 HTMLTableRowElement* candidate = rows->item(0); | 71 HTMLTableRowElement* candidate = rows->item(0); |
| 72 for (int i = 0; candidate; i++, candidate = rows->item(i)) { | 72 for (int i = 0; candidate; i++, candidate = rows->item(i)) { |
| 73 if (this == candidate) | 73 if (this == candidate) |
| 74 return i; | 74 return i; |
| 75 } | 75 } |
| 76 | 76 |
| 77 return -1; | 77 return -1; |
| 78 } | 78 } |
| 79 | 79 |
| 80 int HTMLTableRowElement::sectionRowIndex() const | 80 int HTMLTableRowElement::sectionRowIndex() const |
| 81 { | 81 { |
| 82 int rIndex = 0; | 82 int rIndex = 0; |
| 83 const Node* n = this; | 83 const Node* n = this; |
| 84 do { | 84 do { |
| 85 n = n->previousSibling(); | 85 n = n->previousSibling(); |
| 86 if (n && isHTMLTableRowElement(*n)) | 86 if (n && isHTMLTableRowElement(*n)) |
| 87 ++rIndex; | 87 ++rIndex; |
| 88 } while (n); | 88 } while (n); |
| 89 | 89 |
| 90 return rIndex; | 90 return rIndex; |
| 91 } | 91 } |
| 92 | 92 |
| 93 PassRefPtrWillBeRawPtr<HTMLElement> HTMLTableRowElement::insertCell(int index, E
xceptionState& exceptionState) | 93 RawPtr<HTMLElement> HTMLTableRowElement::insertCell(int index, ExceptionState& e
xceptionState) |
| 94 { | 94 { |
| 95 RefPtrWillBeRawPtr<HTMLCollection> children = cells(); | 95 RawPtr<HTMLCollection> children = cells(); |
| 96 int numCells = children ? children->length() : 0; | 96 int numCells = children ? children->length() : 0; |
| 97 if (index < -1 || index > numCells) { | 97 if (index < -1 || index > numCells) { |
| 98 exceptionState.throwDOMException(IndexSizeError, "The value provided ("
+ String::number(index) + ") is outside the range [-1, " + String::number(numCel
ls) + "]."); | 98 exceptionState.throwDOMException(IndexSizeError, "The value provided ("
+ String::number(index) + ") is outside the range [-1, " + String::number(numCel
ls) + "]."); |
| 99 return nullptr; | 99 return nullptr; |
| 100 } | 100 } |
| 101 | 101 |
| 102 RefPtrWillBeRawPtr<HTMLTableCellElement> cell = HTMLTableCellElement::create
(tdTag, document()); | 102 RawPtr<HTMLTableCellElement> cell = HTMLTableCellElement::create(tdTag, docu
ment()); |
| 103 if (numCells == index || index == -1) | 103 if (numCells == index || index == -1) |
| 104 appendChild(cell, exceptionState); | 104 appendChild(cell, exceptionState); |
| 105 else | 105 else |
| 106 insertBefore(cell, children->item(index), exceptionState); | 106 insertBefore(cell, children->item(index), exceptionState); |
| 107 return cell.release(); | 107 return cell.release(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void HTMLTableRowElement::deleteCell(int index, ExceptionState& exceptionState) | 110 void HTMLTableRowElement::deleteCell(int index, ExceptionState& exceptionState) |
| 111 { | 111 { |
| 112 RefPtrWillBeRawPtr<HTMLCollection> children = cells(); | 112 RawPtr<HTMLCollection> children = cells(); |
| 113 int numCells = children ? children->length() : 0; | 113 int numCells = children ? children->length() : 0; |
| 114 if (index == -1) | 114 if (index == -1) |
| 115 index = numCells-1; | 115 index = numCells-1; |
| 116 if (index >= 0 && index < numCells) { | 116 if (index >= 0 && index < numCells) { |
| 117 RefPtrWillBeRawPtr<Element> cell = children->item(index); | 117 RawPtr<Element> cell = children->item(index); |
| 118 HTMLElement::removeChild(cell.get(), exceptionState); | 118 HTMLElement::removeChild(cell.get(), exceptionState); |
| 119 } else { | 119 } else { |
| 120 exceptionState.throwDOMException(IndexSizeError, "The value provided ("
+ String::number(index) + ") is outside the range [0, " + String::number(numCell
s) + ")."); | 120 exceptionState.throwDOMException(IndexSizeError, "The value provided ("
+ String::number(index) + ") is outside the range [0, " + String::number(numCell
s) + ")."); |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 | 123 |
| 124 PassRefPtrWillBeRawPtr<HTMLCollection> HTMLTableRowElement::cells() | 124 RawPtr<HTMLCollection> HTMLTableRowElement::cells() |
| 125 { | 125 { |
| 126 return ensureCachedCollection<HTMLCollection>(TRCells); | 126 return ensureCachedCollection<HTMLCollection>(TRCells); |
| 127 } | 127 } |
| 128 | 128 |
| 129 } // namespace blink | 129 } // namespace blink |
| OLD | NEW |