RESOLVED FIXED Bug 4571
rows in footer must be last in rows HTMLCollection regardless of doc. order
https://bugs.webkit.org/show_bug.cgi?id=4571
Summary rows in footer must be last in rows HTMLCollection regardless of doc. order
Darin Adler
Reported 2005-08-21 17:39:50 PDT
The rows collection currently returns the rows of a table in document order. But this is incorrect. As with the rowIndex function (which has a working implementation that does this correctly), any rows in a table footer have to come after all the rows in the table body. Two of the W3C DOM Level 2 HTML test suite tests are failing because of this issue: HTMLCollection07 HTMLCollection08
Attachments
fix HTMLCollection07 and HTMLCollection08 (9.56 KB, patch)
2007-09-23 12:46 PDT, Vincent Ricard
mjs: review-
Darin Adler
Comment 1 2005-08-21 18:27:49 PDT
Turns out there was a third test affected: HTMLTableElement39
Maks Orlovich
Comment 2 2005-08-21 19:09:36 PDT
Actually, rowIndex seems broken wrt to putting <thead> first from looking at the code (it only puts tfoot last). Do you (Darin) want a separate BR + testcase for that?
Darin Adler
Comment 3 2005-08-22 08:49:13 PDT
Yes, lets use a separate bug report for that.
Darin Adler
Comment 4 2005-08-26 19:56:02 PDT
Looks like Maks has a great fix for this in the KDE KHTML tree. We should get that.
Maks Orlovich
Comment 5 2005-09-06 10:02:32 PDT
I haven't committed it yet, but it's at http://www.cs.cornell.edu/~maksim/patches/table_rows_order.diff (the diff also includes a fix to rowIndex). The patch is only sane because we cache more stuff than you do, though.
Darin Adler
Comment 6 2005-09-11 10:08:38 PDT
Anders is looking into this.
Vicki Murley
Comment 7 2005-09-12 20:57:25 PDT
Please don't forget to update the DOM catalog after fixing this (or remind me to).
Vicki Murley
Comment 8 2005-10-05 15:49:47 PDT
Vincent Ricard
Comment 9 2007-09-23 12:46:58 PDT
Created attachment 16362 [details] fix HTMLCollection07 and HTMLCollection08 This patch fixes the test cases HTMLCollection07 and HTMLCollection08, and also the bug #8133 (maybe it could be marked as duplicated?). I extended HTMLCollection and overrided traverseNextItem() (rather than modifiy HTMLCollection::traverseNextItem(), i think is more readable and more maintenable like this. I copy/pasted the header for the both new files, i guess the copyright are wrong; is there a header sample on the wiki or elsewhere? I ran the tests, and i didnt see new regression.
Maciej Stachowiak
Comment 10 2007-09-29 19:13:41 PDT
Comment on attachment 16362 [details] fix HTMLCollection07 and HTMLCollection08 The general concept looks good. However, there are a few issues. 1) I see a lot of code using braces around single-line if or while bodies like the below. In WebKit coding style, we do not use braces in such cases. + if (table->firstTBody()) { + current = table->firstTBody()->rows()->firstItem(); + } 2) In general, the logic seems more complicated than necessary. I think just by adding a flag that says whether you haven't started, are currently doing the thead, are currently doing bodies, or are currently doing the tfoot, you could make the logic much simpler. You could do the thead as the first phase, then in phase two do the normal traversal (which will find trs that sit directly in the table, which can happen in XHTML) but refusing to enter thead or tfoot elements, then finally do the tfoot if there is one. 3) It looks like if there is a tfoot, your code will miss tr elements that sit directly in the table or are otherwise misnested (which can happen with XHTML or via direct DOM operations). However, if there isn't a tfoot but there is a tbody, your code will find them. The general approach is good and it's great that you are doing this fix, but please fix up the coding style issue and consider the correctness issue in #3. It might help to add additional test cases to cover weird edge cases like that.
Maciej Stachowiak
Comment 11 2007-09-29 19:17:24 PDT
Comment on attachment 16362 [details] fix HTMLCollection07 and HTMLCollection08 r- for above comments. Please address.
Maciej Stachowiak
Comment 12 2007-09-29 19:18:55 PDT
*** Bug 8133 has been marked as a duplicate of this bug. ***
Ian 'Hixie' Hickson
Comment 13 2008-01-06 17:24:28 PST
HTML5 makes this explicit, fwiw.
Vincent Ricard
Comment 14 2008-02-20 12:04:10 PST
According to the log of r29101, HTMLCollection07 and HTMLCollection pass. So the bug is still valid? (r29101 | darin@apple.com | 2008-01-03)
Darin Adler
Comment 15 2008-02-20 12:32:11 PST
Fixed in r29101.
Note You need to log in before you can comment on or make changes to this bug.