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

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

Issue 471173003: Introduce HasHTMLTagName functor and use it with ElementTraversal (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add comment Created 6 years, 4 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/HTMLTableRowElement.cpp ('k') | no next file » | 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) 2008, 2011, 2012, 2014 Apple Inc. All rights reserved. 2 * Copyright (C) 2008, 2011, 2012, 2014 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 if (HTMLTableRowElement* row = Traversal<HTMLTableRowElement>::first Child(*child)) 93 if (HTMLTableRowElement* row = Traversal<HTMLTableRowElement>::first Child(*child))
94 return row; 94 return row;
95 } 95 }
96 } 96 }
97 97
98 return 0; 98 return 0;
99 } 99 }
100 100
101 HTMLTableRowElement* HTMLTableRowsCollection::lastRow(HTMLTableElement& table) 101 HTMLTableRowElement* HTMLTableRowsCollection::lastRow(HTMLTableElement& table)
102 { 102 {
103 for (HTMLElement* child = Traversal<HTMLElement>::lastChild(table); child; c hild = Traversal<HTMLElement>::previousSibling(*child)) { 103 for (HTMLElement* tfoot = Traversal<HTMLElement>::lastChild(table, HasHTMLTa gName(tfootTag)); tfoot; tfoot = Traversal<HTMLElement>::previousSibling(*tfoot, HasHTMLTagName(tfootTag))) {
104 if (child->hasTagName(tfootTag)) { 104 if (HTMLTableRowElement* lastRow = Traversal<HTMLTableRowElement>::lastC hild(*tfoot))
105 if (HTMLTableRowElement* lastRow = Traversal<HTMLTableRowElement>::l astChild(*child))
106 return lastRow; 105 return lastRow;
107 }
108 } 106 }
109 107
110 for (HTMLElement* child = Traversal<HTMLElement>::lastChild(table); child; c hild = Traversal<HTMLElement>::previousSibling(*child)) { 108 for (HTMLElement* child = Traversal<HTMLElement>::lastChild(table); child; c hild = Traversal<HTMLElement>::previousSibling(*child)) {
111 if (isHTMLTableRowElement(child)) 109 if (isHTMLTableRowElement(child))
112 return toHTMLTableRowElement(child); 110 return toHTMLTableRowElement(child);
113 if (child->hasTagName(tbodyTag)) { 111 if (child->hasTagName(tbodyTag)) {
114 if (HTMLTableRowElement* lastRow = Traversal<HTMLTableRowElement>::l astChild(*child)) 112 if (HTMLTableRowElement* lastRow = Traversal<HTMLTableRowElement>::l astChild(*child))
115 return lastRow; 113 return lastRow;
116 } 114 }
117 } 115 }
118 116
119 for (HTMLElement* child = Traversal<HTMLElement>::lastChild(table); child; c hild = Traversal<HTMLElement>::previousSibling(*child)) { 117 for (HTMLElement* thead = Traversal<HTMLElement>::lastChild(table, HasHTMLTa gName(theadTag)); thead; thead = Traversal<HTMLElement>::previousSibling(*thead, HasHTMLTagName(theadTag))) {
120 if (child->hasTagName(theadTag)) { 118 if (HTMLTableRowElement* lastRow = Traversal<HTMLTableRowElement>::lastC hild(*thead))
121 if (HTMLTableRowElement* lastRow = Traversal<HTMLTableRowElement>::l astChild(*child)) 119 return lastRow;
122 return lastRow;
123 }
124 } 120 }
125 121
126 return 0; 122 return 0;
127 } 123 }
128 124
129 // Must call get() on the table in case that argument is compiled before derefer encing the 125 // Must call get() on the table in case that argument is compiled before derefer encing the
130 // table to get at the collection cache. Order of argument evaluation is undefin ed and can 126 // table to get at the collection cache. Order of argument evaluation is undefin ed and can
131 // differ between compilers. 127 // differ between compilers.
132 HTMLTableRowsCollection::HTMLTableRowsCollection(ContainerNode& table) 128 HTMLTableRowsCollection::HTMLTableRowsCollection(ContainerNode& table)
133 : HTMLCollection(table, TableRows, OverridesItemAfter) 129 : HTMLCollection(table, TableRows, OverridesItemAfter)
134 { 130 {
135 ASSERT(isHTMLTableElement(table)); 131 ASSERT(isHTMLTableElement(table));
136 } 132 }
137 133
138 PassRefPtrWillBeRawPtr<HTMLTableRowsCollection> HTMLTableRowsCollection::create( ContainerNode& table, CollectionType type) 134 PassRefPtrWillBeRawPtr<HTMLTableRowsCollection> HTMLTableRowsCollection::create( ContainerNode& table, CollectionType type)
139 { 135 {
140 ASSERT_UNUSED(type, type == TableRows); 136 ASSERT_UNUSED(type, type == TableRows);
141 return adoptRefWillBeNoop(new HTMLTableRowsCollection(table)); 137 return adoptRefWillBeNoop(new HTMLTableRowsCollection(table));
142 } 138 }
143 139
144 Element* HTMLTableRowsCollection::virtualItemAfter(Element* previous) const 140 Element* HTMLTableRowsCollection::virtualItemAfter(Element* previous) const
145 { 141 {
146 return rowAfter(toHTMLTableElement(ownerNode()), toHTMLTableRowElement(previ ous)); 142 return rowAfter(toHTMLTableElement(ownerNode()), toHTMLTableRowElement(previ ous));
147 } 143 }
148 144
149 } 145 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLTableRowElement.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698