Bug 15273

Summary: Safari should not render a cell if the <td> is empty
Product: WebKit Reporter: Anantha Keesara <anantha>
Component: TablesAssignee: gur.trio
Status: RESOLVED FIXED    
Severity: Normal CC: arpitabahuguna, commit-queue, darin, eric, esprehn+autocc, glenn, gur.trio, jchaffraix, koivisto, kondapallykalyan, mitz, pravind.2k4, simon.fraser, vijayan.bits, zalan
Priority: P2    
Version: 523.x (Safari 3)   
Hardware: PC   
OS: Windows XP   
Bug Depends on: 15244    
Bug Blocks:    
Attachments:
Description Flags
Safari should not render a cell if the <td> is empty
none
Patch
none
Patch
none
Patch
none
Patch none

Anantha Keesara
Reported 2007-09-24 08:28:20 PDT
Safari should not render a column if the <td>, with some width specified, is empty and if parent table also does not have any width specified. Attached is the testcase.
Attachments
Safari should not render a cell if the <td> is empty (431 bytes, text/html)
2007-09-24 08:28 PDT, Anantha Keesara
no flags
Patch (37.33 KB, patch)
2014-03-10 08:07 PDT, gur.trio
no flags
Patch (7.82 KB, patch)
2014-03-13 23:50 PDT, gur.trio
no flags
Patch (7.79 KB, patch)
2014-03-16 22:25 PDT, gur.trio
no flags
Patch (7.89 KB, patch)
2014-03-17 02:29 PDT, gur.trio
no flags
Anantha Keesara
Comment 1 2007-09-24 08:28:52 PDT
Created attachment 16373 [details] Safari should not render a cell if the <td> is empty
mitz
Comment 2 2007-09-24 12:10:57 PDT
WinIE and FIrefox do not render the red border around the third cell.
Eric Seidel (no email)
Comment 3 2008-01-11 15:50:49 PST
This is probably a dupe of bug 15244. I might have even seen one other table bug like this today.
Eric Seidel (no email)
Comment 4 2008-04-15 09:27:32 PDT
My guess is this should be a pretty straightforward fix. We'd just have to check if we have a single empty text child. If so, don't draw borders. Possibly not draw backgrounds either, not sure. Also need to check whitespace handling. The hard part here is getting a comprehensive test case.
Arpita Bahuguna
Comment 5 2012-07-04 00:23:42 PDT
This issue still seems to be reproducible on WebKit. Based on some initial analysis, it seems that the painting of borders for an empty <td> also seems to be dependant on the doctype of the document: 1. No doctype specified. FF - No broders, Opera - No borders, I.E. - No borders, WebKit - Draws the borders. 2. Invalid doctype (name) e.g. <!doctype> or <!doctype xyz>. FF - No borders, Opera - No borders, I.E. - Draws the borders, WebKit - Draws the broders. 3. Valid doctype (HTML5 or otherwise) - All browsers draw the borders. Am not sure whether such behavior is part of some specification or not and whether we really need to fix this issue. Would appreciate thoughts on the same.
gur.trio
Comment 6 2014-03-10 08:07:35 PDT
gur.trio
Comment 7 2014-03-10 09:14:11 PDT
(In reply to comment #6) > Created an attachment (id=226303) [details] > Patch Hi Zalan. Can you please review this? Thanks.
Darin Adler
Comment 8 2014-03-10 09:44:08 PDT
Comment on attachment 226303 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=226303&action=review > Source/WebCore/rendering/RenderTableCell.cpp:1329 > + if (!style().hasBorder() || tableElt->collapseBorders() || (!firstChild() && !tableElt->document().doctype())) I’m not sure that checking firstChild for null is the right definition of empty. Test coverage is light, which makes it unclear to me. This should say just document(), not tableElt->document(). Checking doctype is not the correct way to check whether to apply this quirk. The specification may call this "doctype not present or not correct", but it’s actually a compatibility mode. The functions on Document for checking compatibility mode are Document::compatibilityMode, Document::inQuirksMode, Document::inLimitedQuirksMode, and Document::inNoQuirksMode and we should use one of those. Probably inQuirksMode. > LayoutTests/ChangeLog:13 > + * fast/table/table-cell-border-doctype-expected.png: Added. > + * fast/table/table-cell-border-doctype-expected.txt: Added. > + * fast/table/table-cell-border-doctype.html: Added. > + * fast/table/table-cell-border-no-doctype-expected.png: Added. > + * fast/table/table-cell-border-no-doctype-expected.txt: Added. > + * fast/table/table-cell-border-no-doctype.html: Added. These tests should be done as reference tests, where the expected files are also HTML, not as tests that have pixel results. The reference file could use a single space or non-breaking space to avoid having the cell be empty. Or it could use explicit properties to turn off the borders.
Darin Adler
Comment 9 2014-03-10 09:48:57 PDT
(In reply to comment #4) > My guess is this should be a pretty straightforward fix. We'd just have to check if we have a single empty text child. If so, don't draw borders. Possibly not draw backgrounds either, not sure. Also need to check whitespace handling. The hard part here is getting a comprehensive test case. I agree with what Eric said here back in 2008. We might have a text child with no text or some collapsible whitespace that collapsed or maybe that will be omitted from the render tree. We need sufficient test cases to make sure we are handling that case correctly.
gur.trio
Comment 10 2014-03-13 06:01:10 PDT
(In reply to comment #8) > (From update of attachment 226303 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=226303&action=review > > > Source/WebCore/rendering/RenderTableCell.cpp:1329 > > + if (!style().hasBorder() || tableElt->collapseBorders() || (!firstChild() && !tableElt->document().doctype())) > > I’m not sure that checking firstChild for null is the right definition of empty. Test coverage is light, which makes it unclear to me. > > This should say just document(), not tableElt->document(). > > Checking doctype is not the correct way to check whether to apply this quirk. The specification may call this "doctype not present or not correct", but it’s actually a compatibility mode. The functions on Document for checking compatibility mode are Document::compatibilityMode, Document::inQuirksMode, Document::inLimitedQuirksMode, and Document::inNoQuirksMode and we should use one of those. Probably inQuirksMode. > > > LayoutTests/ChangeLog:13 > > + * fast/table/table-cell-border-doctype-expected.png: Added. > > + * fast/table/table-cell-border-doctype-expected.txt: Added. > > + * fast/table/table-cell-border-doctype.html: Added. > > + * fast/table/table-cell-border-no-doctype-expected.png: Added. > > + * fast/table/table-cell-border-no-doctype-expected.txt: Added. > > + * fast/table/table-cell-border-no-doctype.html: Added. > > These tests should be done as reference tests, where the expected files are also HTML, not as tests that have pixel results. > > The reference file could use a single space or non-breaking space to avoid having the cell be empty. Or it could use explicit properties to turn off the borders. Thanks Darin for the review. Will make the code and test case changes and upload new patch.
gur.trio
Comment 11 2014-03-13 06:04:55 PDT
(In reply to comment #9) > (In reply to comment #4) > > My guess is this should be a pretty straightforward fix. We'd just have to check if we have a single empty text child. If so, don't draw borders. Possibly not draw backgrounds either, not sure. Also need to check whitespace handling. The hard part here is getting a comprehensive test case. > > I agree with what Eric said here back in 2008. We might have a text child with no text or some collapsible whitespace that collapsed or maybe that will be omitted from the render tree. We need sufficient test cases to make sure we are handling that case correctly. Text child with no text for example we create a text node with whitespace (multiple) and then append to table cell? <script> function runTest() { var tableCell = document.getElementById('noChild'); var text = document.createTextNode(" "); tableCell.appendChild(text); } </script> In this case td shows no children so the patch would work. Please correct if I am wrong.
Darin Adler
Comment 12 2014-03-13 10:00:16 PDT
(In reply to comment #11) > In this case td shows no children so the patch would work. By “work” you mean that it would omit the borders. Is that what the other browsers do in this case?
gur.trio
Comment 13 2014-03-13 21:47:04 PDT
(In reply to comment #12) > (In reply to comment #11) > > In this case td shows no children so the patch would work. > > By “work” you mean that it would omit the borders. Is that what the other browsers do in this case? Yes even Firefox omits the border for the above case i.e creating text node with no text.
gur.trio
Comment 14 2014-03-13 23:50:31 PDT
Darin Adler
Comment 15 2014-03-14 15:26:02 PDT
Comment on attachment 226658 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=226658&action=review > LayoutTests/ChangeLog:9 > + * fast/table/table-cell-border-doctype-expected-mismatch.html: Added. > + * fast/table/table-cell-border-doctype.html: Added. Can we do better than expected-mismatch for this test? Or is there no simple markup that will replicate the expected result? Can’t we just do border: 0px or something?
gur.trio
Comment 16 2014-03-16 22:25:22 PDT
gur.trio
Comment 17 2014-03-16 22:26:32 PDT
(In reply to comment #15) > (From update of attachment 226658 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=226658&action=review > > > LayoutTests/ChangeLog:9 > > + * fast/table/table-cell-border-doctype-expected-mismatch.html: Added. > > + * fast/table/table-cell-border-doctype.html: Added. > > Can we do better than expected-mismatch for this test? Or is there no simple markup that will replicate the expected result? Can’t we just do border: 0px or something? Hi Darin. Thanks for the review. Modified the test case.
Darin Adler
Comment 18 2014-03-17 00:28:45 PDT
Comment on attachment 226880 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=226880&action=review > LayoutTests/ChangeLog:8 > + * fast/table/table-cell-border-doctype-expected-mismatch.html: Added. This is still an expected-mismatch result. I think an expected match would be a much stronger test. Can we make this an expected match test, or is that impractical?
gur.trio
Comment 19 2014-03-17 02:29:48 PDT
gur.trio
Comment 20 2014-03-17 02:31:44 PDT
(In reply to comment #18) > (From update of attachment 226880 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=226880&action=review > > > LayoutTests/ChangeLog:8 > > + * fast/table/table-cell-border-doctype-expected-mismatch.html: Added. > > This is still an expected-mismatch result. I think an expected match would be a much stronger test. Can we make this an expected match test, or is that impractical? Modified table-cell-border-doctype-expected-mismatch.html to table-cell-border-doctype-expected.html. Tried to generate the same behaviour as table-cell-border-doctype.html. Hope this is fine now :)
WebKit Commit Bot
Comment 21 2014-03-17 10:28:43 PDT
Comment on attachment 226898 [details] Patch Clearing flags on attachment: 226898 Committed r165740: <http://trac.webkit.org/changeset/165740>
WebKit Commit Bot
Comment 22 2014-03-17 10:28:49 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.