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

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

Issue 189923002: Use new Traversal<HTML*Element> API in HTML code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 return -1; 59 return -1;
60 60
61 // To match Firefox, the row indices work like this: 61 // To match Firefox, the row indices work like this:
62 // Rows from the first <thead> are numbered before all <tbody> rows. 62 // Rows from the first <thead> are numbered before all <tbody> rows.
63 // Rows from the first <tfoot> are numbered after all <tbody> rows. 63 // Rows from the first <tfoot> are numbered after all <tbody> rows.
64 // 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.
65 65
66 int rIndex = 0; 66 int rIndex = 0;
67 67
68 if (HTMLTableSectionElement* head = toHTMLTableElement(table)->tHead()) { 68 if (HTMLTableSectionElement* head = toHTMLTableElement(table)->tHead()) {
69 for (Element* row = ElementTraversal::firstWithin(*head); row; row = Ele mentTraversal::nextSibling(*row)) { 69 for (HTMLTableRowElement* row = Traversal<HTMLTableRowElement>::firstChi ld(*head); row; row = Traversal<HTMLTableRowElement>::nextSibling(*row)) {
70 if (row == this) 70 if (row == this)
71 return rIndex; 71 return rIndex;
72 if (row->hasTagName(trTag)) 72 ++rIndex;
73 ++rIndex;
74 } 73 }
75 } 74 }
76 75
77 for (Element* child = ElementTraversal::firstWithin(*table); child; child = ElementTraversal::nextSibling(*child)) { 76 for (Element* child = ElementTraversal::firstWithin(*table); child; child = ElementTraversal::nextSibling(*child)) {
78 if (child->hasTagName(tbodyTag)) { 77 if (child->hasTagName(tbodyTag)) {
79 HTMLTableSectionElement* section = toHTMLTableSectionElement(child); 78 HTMLTableSectionElement* section = toHTMLTableSectionElement(child);
80 for (Element* row = ElementTraversal::firstWithin(*section); row; ro w = ElementTraversal::nextSibling(*row)) { 79 for (HTMLTableRowElement* row = Traversal<HTMLTableRowElement>::firs tChild(*section); row; row = Traversal<HTMLTableRowElement>::nextSibling(*row)) {
81 if (row == this) 80 if (row == this)
82 return rIndex; 81 return rIndex;
83 if (row->hasTagName(trTag)) 82 ++rIndex;
84 ++rIndex;
85 } 83 }
86 } 84 }
87 } 85 }
88 86
89 if (HTMLTableSectionElement* foot = toHTMLTableElement(table)->tFoot()) { 87 if (HTMLTableSectionElement* foot = toHTMLTableElement(table)->tFoot()) {
90 for (Element* row = ElementTraversal::firstWithin(*foot); row; row = Ele mentTraversal::nextSibling(*row)) { 88 for (HTMLTableRowElement* row = Traversal<HTMLTableRowElement>::firstChi ld(*foot); row; row = Traversal<HTMLTableRowElement>::nextSibling(*row)) {
91 if (row == this) 89 if (row == this)
92 return rIndex; 90 return rIndex;
93 if (row->hasTagName(trTag)) 91 ++rIndex;
94 ++rIndex;
95 } 92 }
96 } 93 }
97 94
98 // We get here for rows that are in <thead> or <tfoot> sections other than t he main header and footer. 95 // We get here for rows that are in <thead> or <tfoot> sections other than t he main header and footer.
99 return -1; 96 return -1;
100 } 97 }
101 98
102 int HTMLTableRowElement::sectionRowIndex() const 99 int HTMLTableRowElement::sectionRowIndex() const
103 { 100 {
104 int rIndex = 0; 101 int rIndex = 0;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 exceptionState.throwDOMException(IndexSizeError, "The value provided (" + String::number(index) + ") is outside the range [0, " + String::number(numCell s) + ")."); 146 exceptionState.throwDOMException(IndexSizeError, "The value provided (" + String::number(index) + ") is outside the range [0, " + String::number(numCell s) + ").");
150 } 147 }
151 } 148 }
152 149
153 PassRefPtr<HTMLCollection> HTMLTableRowElement::cells() 150 PassRefPtr<HTMLCollection> HTMLTableRowElement::cells()
154 { 151 {
155 return ensureCachedHTMLCollection(TRCells); 152 return ensureCachedHTMLCollection(TRCells);
156 } 153 }
157 154
158 } 155 }
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