Chromium Code Reviews| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 bool HTMLTableRowElement::hasLegalLinkAttribute( | 48 bool HTMLTableRowElement::hasLegalLinkAttribute( |
| 49 const QualifiedName& name) const { | 49 const QualifiedName& name) const { |
| 50 return name == backgroundAttr || | 50 return name == backgroundAttr || |
| 51 HTMLTablePartElement::hasLegalLinkAttribute(name); | 51 HTMLTablePartElement::hasLegalLinkAttribute(name); |
| 52 } | 52 } |
| 53 | 53 |
| 54 const QualifiedName& HTMLTableRowElement::subResourceAttributeName() const { | 54 const QualifiedName& HTMLTableRowElement::subResourceAttributeName() const { |
| 55 return backgroundAttr; | 55 return backgroundAttr; |
| 56 } | 56 } |
| 57 | 57 |
| 58 static int findIndexInRowCollection(HTMLCollection* rows, | |
|
tkent
2016/10/27 02:31:28
nit: Because |rows| isn't nullptr and it isn't mod
| |
| 59 const HTMLTableRowElement* target) { | |
|
tkent
2016/10/27 02:31:28
nit: |target| isn't nullptr. The argument type sh
| |
| 60 Element* candidate = rows->item(0); | |
| 61 for (int i = 0; candidate; i++, candidate = rows->item(i)) { | |
| 62 if (target == candidate) | |
| 63 return i; | |
| 64 } | |
| 65 return -1; | |
| 66 } | |
| 67 | |
| 58 int HTMLTableRowElement::rowIndex() const { | 68 int HTMLTableRowElement::rowIndex() const { |
| 59 ContainerNode* maybeTable = parentNode(); | 69 ContainerNode* maybeTable = parentNode(); |
| 60 if (maybeTable && isHTMLTableSectionElement(maybeTable)) { | 70 if (maybeTable && isHTMLTableSectionElement(maybeTable)) { |
| 61 // Skip THEAD, TBODY and TFOOT. | 71 // Skip THEAD, TBODY and TFOOT. |
| 62 maybeTable = maybeTable->parentNode(); | 72 maybeTable = maybeTable->parentNode(); |
| 63 } | 73 } |
| 64 if (!(maybeTable && isHTMLTableElement(maybeTable))) | 74 if (!(maybeTable && isHTMLTableElement(maybeTable))) |
| 65 return -1; | 75 return -1; |
| 66 | 76 return findIndexInRowCollection(toHTMLTableElement(maybeTable)->rows(), this); |
| 67 HTMLTableRowsCollection* rows = toHTMLTableElement(maybeTable)->rows(); | |
| 68 HTMLTableRowElement* candidate = rows->item(0); | |
| 69 for (int i = 0; candidate; i++, candidate = rows->item(i)) { | |
| 70 if (this == candidate) | |
| 71 return i; | |
| 72 } | |
| 73 | |
| 74 return -1; | |
| 75 } | 77 } |
| 76 | 78 |
| 77 int HTMLTableRowElement::sectionRowIndex() const { | 79 int HTMLTableRowElement::sectionRowIndex() const { |
| 78 ContainerNode* maybeTable = parentNode(); | 80 ContainerNode* maybeTable = parentNode(); |
| 79 if (!(maybeTable && (isHTMLTableSectionElement(maybeTable) || | 81 if (!maybeTable) |
| 80 isHTMLTableElement(maybeTable)))) | |
| 81 return -1; | 82 return -1; |
| 82 int rIndex = 0; | 83 HTMLCollection* rows = nullptr; |
| 83 const Node* n = this; | 84 if (isHTMLTableSectionElement(maybeTable)) |
| 84 do { | 85 rows = toHTMLTableSectionElement(maybeTable)->rows(); |
| 85 n = n->previousSibling(); | 86 else if (isHTMLTableElement(maybeTable)) |
| 86 if (n && isHTMLTableRowElement(*n)) | 87 rows = toHTMLTableElement(maybeTable)->rows(); |
| 87 ++rIndex; | 88 if (!rows) |
| 88 } while (n); | 89 return -1; |
| 89 | 90 return findIndexInRowCollection(rows, this); |
| 90 return rIndex; | |
| 91 } | 91 } |
| 92 | 92 |
| 93 HTMLElement* HTMLTableRowElement::insertCell(int index, | 93 HTMLElement* HTMLTableRowElement::insertCell(int index, |
| 94 ExceptionState& exceptionState) { | 94 ExceptionState& exceptionState) { |
| 95 HTMLCollection* children = cells(); | 95 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( | 98 exceptionState.throwDOMException( |
| 99 IndexSizeError, "The value provided (" + String::number(index) + | 99 IndexSizeError, "The value provided (" + String::number(index) + |
| 100 ") is outside the range [-1, " + | 100 ") is outside the range [-1, " + |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 // 3. Remove the indexth element in the cells collection from its parent. | 133 // 3. Remove the indexth element in the cells collection from its parent. |
| 134 Element* cell = children->item(index); | 134 Element* cell = children->item(index); |
| 135 HTMLElement::removeChild(cell, exceptionState); | 135 HTMLElement::removeChild(cell, exceptionState); |
| 136 } | 136 } |
| 137 | 137 |
| 138 HTMLCollection* HTMLTableRowElement::cells() { | 138 HTMLCollection* HTMLTableRowElement::cells() { |
| 139 return ensureCachedCollection<HTMLCollection>(TRCells); | 139 return ensureCachedCollection<HTMLCollection>(TRCells); |
| 140 } | 140 } |
| 141 | 141 |
| 142 } // namespace blink | 142 } // namespace blink |
| OLD | NEW |