The cellIndex property of TD nodes is always 0, regardless of the actual position of the cell in the row.
Created attachment 2128 [details] A testcase for this bug
(This bug was copied from Apple's Bug Reporter #3756860)
Fixed in Konqueror
FYI, http://bugs.kde.org/show_bug.cgi?id=58799#c7 and http://websvn.kde.org/*checkout*/trunk/tests/khtmltests/regression/tests/unsorted/58799.html?rev=426346 . Previously it wasn't quite right.
Created attachment 2448 [details] Proposed patch
+ const NodeImpl * node = this; + int index = 0; + do { + node = node->previousSibling(); + if(node && (node->id() == ID_TD || node->id() == ID_TH)) + index++; + } while(node); for (const NodeImpl* node = node->previousSibling(); node; node = node->previousSibling()) if (node->id() == ID_TH || node->id() == ID_TH) index++; ... reads better to me then a do construct that still ends up null-checking.
+ const NodeImpl * node = this; + int index = 0; + do { + node = node->previousSibling(); + if(node && (node->id() == ID_TD || node->id() == ID_TH)) + index++; + } while(node); for (const NodeImpl* node = node->previousSibling(); node; node = node->previousSibling()) { if (node->id() == ID_TD || node->id() == ID_TH) index++; } ... reads better to me then a do construct that still ends up null-checking.
node = previousSibling(). Yes, I can write code. Really. ;)
Comment on attachment 2448 [details] Proposed patch r=me, would prefer for loop, but don't really feel strongly. :)
Created attachment 2449 [details] Proposed patch with better coding style :-)
Comment on attachment 2449 [details] Proposed patch with better coding style :-) r=me, fix the 8-space indentation to be 4-space though.
Created attachment 2456 [details] Remove outdated commnet I don't think the comment is valid anymore.
Created attachment 2457 [details] Remove outdated comment I don't think the comment is valid anymore.
Patch looks good, and since Justin has commit privileges I'm not going to land it for him. Justin, you should commit this!
The for loop idiom is pretty nice, nicer than the original do/while. There's also a good while idiom for this sort of thing that you can see in functions like HTMLOptionElementImpl::text.
*** Bug 3623 has been marked as a duplicate of this bug. ***
Fixed in 10.4.2