Index: Source/core/html/HTMLTableCellElement.cpp |
diff --git a/Source/core/html/HTMLTableCellElement.cpp b/Source/core/html/HTMLTableCellElement.cpp |
index 833196300d642ccc56aba1d06a0409662caf94d3..9e0b4f1a9a3798edf8c9318286e0568b2de17427 100644 |
--- a/Source/core/html/HTMLTableCellElement.cpp |
+++ b/Source/core/html/HTMLTableCellElement.cpp |
@@ -67,14 +67,12 @@ int HTMLTableCellElement::rowSpan() const |
int HTMLTableCellElement::cellIndex() const |
{ |
- int index = 0; |
- if (!parentElement() || !parentElement()->hasTagName(trTag)) |
+ if (!isHTMLTableRowElement(parentElement())) |
return -1; |
- for (const Node * node = previousSibling(); node; node = node->previousSibling()) { |
- if (node->hasTagName(tdTag) || node->hasTagName(thTag)) |
- index++; |
- } |
+ int index = 0; |
+ for (const HTMLTableCellElement* element = Traversal<HTMLTableCellElement>::previousSibling(*this); element; element = Traversal<HTMLTableCellElement>::previousSibling(*element)) |
+ ++index; |
return index; |
} |