summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/HTMLTableRowsCollection.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
commit32761a6cee1d0dee366b885b7b9c777e67885688 (patch)
treed6bec92bebfb216f4126356e55518842c2f476a1 /Source/WebCore/html/HTMLTableRowsCollection.cpp
parenta4e969f4965059196ca948db781e52f7cfebf19e (diff)
downloadWebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/WebCore/html/HTMLTableRowsCollection.cpp')
-rw-r--r--Source/WebCore/html/HTMLTableRowsCollection.cpp73
1 files changed, 37 insertions, 36 deletions
diff --git a/Source/WebCore/html/HTMLTableRowsCollection.cpp b/Source/WebCore/html/HTMLTableRowsCollection.cpp
index 2d91d9d48..0e4ac0830 100644
--- a/Source/WebCore/html/HTMLTableRowsCollection.cpp
+++ b/Source/WebCore/html/HTMLTableRowsCollection.cpp
@@ -10,7 +10,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Inc. ("Apple") nor the names of
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@@ -38,7 +38,7 @@ namespace WebCore {
using namespace HTMLNames;
-static inline void assertRowIsInTable(HTMLTableElement& table, HTMLTableRowElement* row)
+static inline void assertRowIsInTable(HTMLTableElement* table, HTMLTableRowElement* row)
{
#if !ASSERT_DISABLED
UNUSED_PARAM(table);
@@ -46,29 +46,30 @@ static inline void assertRowIsInTable(HTMLTableElement& table, HTMLTableRowEleme
#else
if (!row)
return;
- if (row->parentNode() == &table)
+ if (row->parentNode() == table)
return;
ASSERT(row->parentNode());
ASSERT(row->parentNode()->hasTagName(theadTag) || row->parentNode()->hasTagName(tbodyTag) || row->parentNode()->hasTagName(tfootTag));
- ASSERT(row->parentNode()->parentNode() == &table);
+ ASSERT(row->parentNode()->parentNode() == table);
#endif
}
-static inline bool isInSection(HTMLTableRowElement& row, const HTMLQualifiedName& sectionTag)
+static inline bool isInSection(HTMLTableRowElement* row, const QualifiedName& sectionTag)
{
- // Because we know that the parent is a table or a section, it's safe to cast it to an HTMLElement
- // giving us access to the faster hasTagName overload from that class.
- return downcast<HTMLElement>(*row.parentNode()).hasTagName(sectionTag);
+ // Because we know that the parent is a table or a section, all of which are in the HTML
+ // namespace, it's OK to do the faster hasLocalName here instead of the more typical hasTagName,
+ // since we don't need the check for the HTML namespace.
+ return toElement(row->parentNode())->hasLocalName(sectionTag);
}
-HTMLTableRowElement* HTMLTableRowsCollection::rowAfter(HTMLTableElement& table, HTMLTableRowElement* previous)
+HTMLTableRowElement* HTMLTableRowsCollection::rowAfter(HTMLTableElement* table, HTMLTableRowElement* previous)
{
// The HTMLCollection caching mechanism, along with the code in this class, will guarantee that the previous row
// is an immediate child of either the table, or a table section that is itself an immediate child of the table.
assertRowIsInTable(table, previous);
// Start by looking for the next row in this section. Continue only if there is none.
- if (previous && previous->parentNode() != &table) {
+ if (previous && previous->parentNode() != table) {
auto childRows = childrenOfType<HTMLTableRowElement>(*previous->parentNode());
auto row = childRows.beginAt(*previous);
if (++row != childRows.end())
@@ -80,9 +81,9 @@ HTMLTableRowElement* HTMLTableRowsCollection::rowAfter(HTMLTableElement& table,
// If still looking at head sections, find the first row in the next head section.
if (!previous)
child = ElementTraversal::firstChild(table);
- else if (isInSection(*previous, theadTag))
- child = ElementTraversal::nextSibling(*previous->parentNode());
- for (; child; child = ElementTraversal::nextSibling(*child)) {
+ else if (isInSection(previous, theadTag))
+ child = ElementTraversal::nextSibling(previous->parentNode());
+ for (; child; child = ElementTraversal::nextSibling(child)) {
if (child->hasTagName(theadTag)) {
if (auto row = childrenOfType<HTMLTableRowElement>(*child).first())
return row;
@@ -90,15 +91,15 @@ HTMLTableRowElement* HTMLTableRowsCollection::rowAfter(HTMLTableElement& table,
}
// If still looking at top level and bodies, find the next row in top level or the first in the next body section.
- if (!previous || isInSection(*previous, theadTag))
+ if (!previous || isInSection(previous, theadTag))
child = ElementTraversal::firstChild(table);
- else if (previous->parentNode() == &table)
- child = ElementTraversal::nextSibling(*previous);
- else if (isInSection(*previous, tbodyTag))
- child = ElementTraversal::nextSibling(*previous->parentNode());
- for (; child; child = ElementTraversal::nextSibling(*child)) {
- if (is<HTMLTableRowElement>(*child))
- return downcast<HTMLTableRowElement>(child);
+ else if (previous->parentNode() == table)
+ child = ElementTraversal::nextSibling(previous);
+ else if (isInSection(previous, tbodyTag))
+ child = ElementTraversal::nextSibling(previous->parentNode());
+ for (; child; child = ElementTraversal::nextSibling(child)) {
+ if (isHTMLTableRowElement(child))
+ return toHTMLTableRowElement(child);
if (child->hasTagName(tbodyTag)) {
if (auto row = childrenOfType<HTMLTableRowElement>(*child).first())
return row;
@@ -106,11 +107,11 @@ HTMLTableRowElement* HTMLTableRowsCollection::rowAfter(HTMLTableElement& table,
}
// Find the first row in the next foot section.
- if (!previous || !isInSection(*previous, tfootTag))
+ if (!previous || !isInSection(previous, tfootTag))
child = ElementTraversal::firstChild(table);
else
- child = ElementTraversal::nextSibling(*previous->parentNode());
- for (; child; child = ElementTraversal::nextSibling(*child)) {
+ child = ElementTraversal::nextSibling(previous->parentNode());
+ for (; child; child = ElementTraversal::nextSibling(child)) {
if (child->hasTagName(tfootTag)) {
if (auto row = childrenOfType<HTMLTableRowElement>(*child).first())
return row;
@@ -120,27 +121,27 @@ HTMLTableRowElement* HTMLTableRowsCollection::rowAfter(HTMLTableElement& table,
return nullptr;
}
-HTMLTableRowElement* HTMLTableRowsCollection::lastRow(HTMLTableElement& table)
+HTMLTableRowElement* HTMLTableRowsCollection::lastRow(HTMLTableElement* table)
{
- for (auto* child = ElementTraversal::lastChild(table); child; child = ElementTraversal::previousSibling(*child)) {
+ for (auto child = ElementTraversal::lastChild(table); child; child = ElementTraversal::previousSibling(child)) {
if (child->hasTagName(tfootTag)) {
- if (auto* row = childrenOfType<HTMLTableRowElement>(*child).last())
+ if (auto row = childrenOfType<HTMLTableRowElement>(*child).last())
return row;
}
}
- for (auto* child = ElementTraversal::lastChild(table); child; child = ElementTraversal::previousSibling(*child)) {
- if (is<HTMLTableRowElement>(*child))
- return downcast<HTMLTableRowElement>(child);
+ for (auto child = ElementTraversal::lastChild(table); child; child = ElementTraversal::previousSibling(child)) {
+ if (isHTMLTableRowElement(child))
+ return toHTMLTableRowElement(child);
if (child->hasTagName(tbodyTag)) {
- if (auto* row = childrenOfType<HTMLTableRowElement>(*child).last())
+ if (auto row = childrenOfType<HTMLTableRowElement>(*child).last())
return row;
}
}
- for (auto* child = ElementTraversal::lastChild(table); child; child = ElementTraversal::previousSibling(*child)) {
+ for (auto child = ElementTraversal::lastChild(table); child; child = ElementTraversal::previousSibling(child)) {
if (child->hasTagName(theadTag)) {
- if (auto* row = childrenOfType<HTMLTableRowElement>(*child).last())
+ if (auto row = childrenOfType<HTMLTableRowElement>(*child).last())
return row;
}
}
@@ -149,11 +150,11 @@ HTMLTableRowElement* HTMLTableRowsCollection::lastRow(HTMLTableElement& table)
}
HTMLTableRowsCollection::HTMLTableRowsCollection(HTMLTableElement& table)
- : CachedHTMLCollection<HTMLTableRowsCollection, CollectionTypeTraits<TableRows>::traversalType>(table, TableRows)
+ : HTMLCollection(table, TableRows, CustomForwardOnlyTraversal)
{
}
-Ref<HTMLTableRowsCollection> HTMLTableRowsCollection::create(HTMLTableElement& table, CollectionType type)
+PassRef<HTMLTableRowsCollection> HTMLTableRowsCollection::create(HTMLTableElement& table, CollectionType type)
{
ASSERT_UNUSED(type, type == TableRows);
return adoptRef(*new HTMLTableRowsCollection(table));
@@ -161,7 +162,7 @@ Ref<HTMLTableRowsCollection> HTMLTableRowsCollection::create(HTMLTableElement& t
Element* HTMLTableRowsCollection::customElementAfter(Element* previous) const
{
- return rowAfter(const_cast<HTMLTableElement&>(tableElement()), downcast<HTMLTableRowElement>(previous));
+ return rowAfter(const_cast<HTMLTableElement*>(&tableElement()), toHTMLTableRowElement(previous));
}
}