Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1866)

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLTableRowElement.cpp

Issue 2409773002: Implement a parent check in sectionRowIndex (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 HTMLTableRowElement* candidate = rows->item(0); 68 HTMLTableRowElement* candidate = rows->item(0);
69 for (int i = 0; candidate; i++, candidate = rows->item(i)) { 69 for (int i = 0; candidate; i++, candidate = rows->item(i)) {
70 if (this == candidate) 70 if (this == candidate)
71 return i; 71 return i;
72 } 72 }
73 73
74 return -1; 74 return -1;
75 } 75 }
76 76
77 int HTMLTableRowElement::sectionRowIndex() const { 77 int HTMLTableRowElement::sectionRowIndex() const {
78 ContainerNode* maybeTable = parentNode();
79 if (!(maybeTable && (isHTMLTableSectionElement(maybeTable) ||
80 isHTMLTableElement(maybeTable))))
81 return -1;
78 int rIndex = 0; 82 int rIndex = 0;
79 const Node* n = this; 83 const Node* n = this;
80 do { 84 do {
81 n = n->previousSibling(); 85 n = n->previousSibling();
82 if (n && isHTMLTableRowElement(*n)) 86 if (n && isHTMLTableRowElement(*n))
83 ++rIndex; 87 ++rIndex;
foolip 2016/10/11 09:28:45 Does this counting match exactly what the spec say
rwlbuis 2016/10/11 16:54:48 Yes, implementation seems pretty/too simple atm, f
84 } while (n); 88 } while (n);
85 89
86 return rIndex; 90 return rIndex;
87 } 91 }
88 92
89 HTMLElement* HTMLTableRowElement::insertCell(int index, 93 HTMLElement* HTMLTableRowElement::insertCell(int index,
90 ExceptionState& exceptionState) { 94 ExceptionState& exceptionState) {
91 HTMLCollection* children = cells(); 95 HTMLCollection* children = cells();
92 int numCells = children ? children->length() : 0; 96 int numCells = children ? children->length() : 0;
93 if (index < -1 || index > numCells) { 97 if (index < -1 || index > numCells) {
(...skipping 27 matching lines...) Expand all
121 ") is outside the range [0, " + 125 ") is outside the range [0, " +
122 String::number(numCells) + ")."); 126 String::number(numCells) + ").");
123 } 127 }
124 } 128 }
125 129
126 HTMLCollection* HTMLTableRowElement::cells() { 130 HTMLCollection* HTMLTableRowElement::cells() {
127 return ensureCachedCollection<HTMLCollection>(TRCells); 131 return ensureCachedCollection<HTMLCollection>(TRCells);
128 } 132 }
129 133
130 } // namespace blink 134 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/imported/wpt/html/semantics/tabular-data/the-tr-element/sectionRowIndex-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698