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

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

Issue 171663005: Consistently use ElementTraversal API when looking for an Element (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLTableElement.cpp ('k') | Source/core/html/HTMLTableSectionElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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
11 * License as published by the Free Software Foundation; either 11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version. 12 * version 2 of the License, or (at your option) any later version.
13 * 13 *
14 * This library is distributed in the hope that it will be useful, 14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details. 17 * Library General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU Library General Public License 19 * You should have received a copy of the GNU Library General Public License
20 * along with this library; see the file COPYING.LIB. If not, write to 20 * along with this library; see the file COPYING.LIB. If not, write to
21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA. 22 * Boston, MA 02110-1301, USA.
23 */ 23 */
24 24
25 #include "config.h" 25 #include "config.h"
26 #include "core/html/HTMLTableRowElement.h" 26 #include "core/html/HTMLTableRowElement.h"
27 27
28 #include "HTMLNames.h" 28 #include "HTMLNames.h"
29 #include "bindings/v8/ExceptionState.h" 29 #include "bindings/v8/ExceptionState.h"
30 #include "core/dom/ElementTraversal.h"
30 #include "core/dom/ExceptionCode.h" 31 #include "core/dom/ExceptionCode.h"
31 #include "core/html/HTMLCollection.h" 32 #include "core/html/HTMLCollection.h"
32 #include "core/html/HTMLTableCellElement.h" 33 #include "core/html/HTMLTableCellElement.h"
33 #include "core/html/HTMLTableElement.h" 34 #include "core/html/HTMLTableElement.h"
34 #include "core/html/HTMLTableSectionElement.h" 35 #include "core/html/HTMLTableSectionElement.h"
35 36
36 namespace WebCore { 37 namespace WebCore {
37 38
38 using namespace HTMLNames; 39 using namespace HTMLNames;
39 40
(...skipping 18 matching lines...) Expand all
58 return -1; 59 return -1;
59 60
60 // To match Firefox, the row indices work like this: 61 // To match Firefox, the row indices work like this:
61 // Rows from the first <thead> are numbered before all <tbody> rows. 62 // Rows from the first <thead> are numbered before all <tbody> rows.
62 // Rows from the first <tfoot> are numbered after all <tbody> rows. 63 // Rows from the first <tfoot> are numbered after all <tbody> rows.
63 // Rows from other <thead> and <tfoot> elements don't get row indices at a ll. 64 // Rows from other <thead> and <tfoot> elements don't get row indices at a ll.
64 65
65 int rIndex = 0; 66 int rIndex = 0;
66 67
67 if (HTMLTableSectionElement* head = toHTMLTableElement(table)->tHead()) { 68 if (HTMLTableSectionElement* head = toHTMLTableElement(table)->tHead()) {
68 for (Node *row = head->firstChild(); row; row = row->nextSibling()) { 69 for (Element* row = ElementTraversal::firstWithin(*head); row; row = Ele mentTraversal::nextSibling(*row)) {
69 if (row == this) 70 if (row == this)
70 return rIndex; 71 return rIndex;
71 if (row->hasTagName(trTag)) 72 if (row->hasTagName(trTag))
72 ++rIndex; 73 ++rIndex;
73 } 74 }
74 } 75 }
75 76
76 for (Node *node = table->firstChild(); node; node = node->nextSibling()) { 77 for (Element* child = ElementTraversal::firstWithin(*table); child; child = ElementTraversal::nextSibling(*child)) {
77 if (node->hasTagName(tbodyTag)) { 78 if (child->hasTagName(tbodyTag)) {
78 HTMLTableSectionElement* section = toHTMLTableSectionElement(node); 79 HTMLTableSectionElement* section = toHTMLTableSectionElement(child);
79 for (Node* row = section->firstChild(); row; row = row->nextSibling( )) { 80 for (Element* row = ElementTraversal::firstWithin(*section); row; ro w = ElementTraversal::nextSibling(*row)) {
80 if (row == this) 81 if (row == this)
81 return rIndex; 82 return rIndex;
82 if (row->hasTagName(trTag)) 83 if (row->hasTagName(trTag))
83 ++rIndex; 84 ++rIndex;
84 } 85 }
85 } 86 }
86 } 87 }
87 88
88 if (HTMLTableSectionElement* foot = toHTMLTableElement(table)->tFoot()) { 89 if (HTMLTableSectionElement* foot = toHTMLTableElement(table)->tFoot()) {
89 for (Node *row = foot->firstChild(); row; row = row->nextSibling()) { 90 for (Element* row = ElementTraversal::firstWithin(*foot); row; row = Ele mentTraversal::nextSibling(*row)) {
90 if (row == this) 91 if (row == this)
91 return rIndex; 92 return rIndex;
92 if (row->hasTagName(trTag)) 93 if (row->hasTagName(trTag))
93 ++rIndex; 94 ++rIndex;
94 } 95 }
95 } 96 }
96 97
97 // We get here for rows that are in <thead> or <tfoot> sections other than t he main header and footer. 98 // We get here for rows that are in <thead> or <tfoot> sections other than t he main header and footer.
98 return -1; 99 return -1;
99 } 100 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 exceptionState.throwDOMException(IndexSizeError, "The value provided (" + String::number(index) + ") is outside the range [0, " + String::number(numCell s) + ")."); 149 exceptionState.throwDOMException(IndexSizeError, "The value provided (" + String::number(index) + ") is outside the range [0, " + String::number(numCell s) + ").");
149 } 150 }
150 } 151 }
151 152
152 PassRefPtr<HTMLCollection> HTMLTableRowElement::cells() 153 PassRefPtr<HTMLCollection> HTMLTableRowElement::cells()
153 { 154 {
154 return ensureCachedHTMLCollection(TRCells); 155 return ensureCachedHTMLCollection(TRCells);
155 } 156 }
156 157
157 } 158 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLTableElement.cpp ('k') | Source/core/html/HTMLTableSectionElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698