Bug 3964

Summary: Dotted borders render w/ artifacts and sometimes as solid lines
Product: WebKit Reporter: Eric O'Connell <eric>
Component: TablesAssignee: Pravin D <pravind>
Status: RESOLVED FIXED    
Severity: Normal CC: arpitabahuguna, buildbot, ca2, commit-queue, dglazkov, donggwan.kim, dw.im, emacemac7, eric, esprehn+autocc, glenn, ian, jchaffraix, mitz, ojan.autocc, rniwa, robin, webkit.review.bot
Priority: P2 Keywords: HasReduction
Version: 412   
Hardware: Mac   
OS: OS X 10.4   
URL: http://www.bodytalksystem.com/test/dotted-borders.html
Attachments:
Description Flags
Colspan above causes border to extend to other cells
none
Minimal test case, border-collapse, two rows, no colspan
none
HTML, minimal test case, collapsed and thin dotted borders
none
WIP - 1
none
Archive of layout-test-results from gce-cr-linux-05 for chromium-linux-x86_64
none
Archive of layout-test-results from webkit-ews-14 for mac-mountainlion-wk2
none
Archive of layout-test-results from webkit-ews-01 for mac-future
none
Archive of layout-test-results from webkit-ews-05 for mac-future
none
Patch
none
Patch
none
Patch
none
Archive of layout-test-results from webkit-ews-09 for mac-mountainlion-wk2 none

Description Eric O'Connell 2005-07-12 10:47:36 PDT
This bug seems to be mainly affected by the length of the th element relative to the td's.  Only occurs on 
tables with border-collapse: collapse & dotted border on th element.
Comment 1 John Sullivan 2005-07-12 12:51:54 PDT
I see the bug on the page listed here, so confirming.
Comment 2 Eric Seidel (no email) 2005-12-27 14:34:03 PST
Seems like a pattern offset bug.  It's possible mitz might know this area of the code.
Comment 3 mitz 2005-12-28 07:42:12 PST
Created attachment 5338 [details]
Colspan above causes border to extend to other cells

This demonstrates what I think is the core issue here: the cell with colspan 2
on the first row adopts as its bottom border the top border of the first cell
on the second row.
Comment 4 Joost de Valk (AlthA) 2005-12-29 00:01:26 PST
Added HasReduction. I think this bug is related to bug 3820, in the very least because both seem to be 
pointing out errors in code relating to colspan.
Comment 5 Robin Whittleton 2011-01-14 08:37:43 PST
Another minimal testcase:

data:text/html;charset=utf-8,<!DOCTYPE html><html lang%3D"en"><head><meta charset%3D"UTF-8" /><style>table{ border-collapse: collapse; }td{ border-bottom: 1px dotted red; }</style></head><body><table><tr><td>Col 1</td><td>Col 2</td></tr><tr><td colspan%3D"2">Cell spanning 2 columns.</td></tr></table></body></html>


Getting rid of border-collapse:collapse fixes it.

Broken in Chrome 8 and Safari 5. Working in Firefox 4b9
Comment 6 kitchin 2011-06-27 09:26:19 PDT
Created attachment 98738 [details]
Minimal test case, border-collapse, two rows, no colspan

Any EVEN number in the padding will make the 2px dotted border solid.

Tested in Google Chrome 12.0.742.100 on WinXP.
Comment 7 kitchin 2011-06-27 09:29:00 PDT
A workaround for HTML authors is to try changing padding by one pixel.
Comment 8 William Rummler 2013-02-16 20:34:49 PST
Created attachment 188751 [details]
HTML, minimal test case, collapsed and thin dotted borders

My specific encounter: In a table element with collapsed borders and thin dotted cell borders, the border between a spanning cell and every other one of its neighbor cells becomes solid.

Reproduced on Win7 x64 with Webkit r131444 (16 Oct 2012), version 537.17.

Did not occur for me using non-thin dotted cell borders. Also fails to reproduce at a few intermediate zoom levels.

Attaching another minimal test case.
Comment 9 Arpita Bahuguna 2013-03-22 01:07:03 PDT
The first two testcases seem similar to the issue specified in #5515 (https://bugs.webkit.org/show_bug.cgi?id=5515).
Comment 10 Pravin D 2013-03-25 12:49:48 PDT
Created attachment 194905 [details]
WIP - 1
Comment 11 Pravin D 2013-03-25 12:53:44 PDT
(In reply to comment #10)
> Created an attachment (id=194905) [details]
> WIP - 1
> 
The patch does not work properly for cells with colspan. Also the cell corners where the borders overlap is not proper. Will upload another addressing these issues.
Comment 12 WebKit Review Bot 2013-03-27 06:02:40 PDT
Attachment 194905 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCore/rendering/RenderTableCell.cpp']" exit_code: 1
Source/WebCore/rendering/RenderTableCell.cpp:1132:  When wrapping a line, only indent 4 spaces.  [whitespace/indent] [3]
Total errors found: 1 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 13 WebKit Review Bot 2013-03-27 06:21:42 PDT
Comment on attachment 194905 [details]
WIP - 1

Attachment 194905 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://webkit-commit-queue.appspot.com/results/17336108

New failing tests:
css2.1/20110323/border-conflict-element-001d.htm
http/tests/cache/subresource-failover-to-network.html
css2.1/t170602-bdr-conflct-w-19-d.html
css2.1/t170602-bdr-conflct-w-25-d.html
css2.1/t170602-bdr-conflct-w-03-d.html
css2.1/20110323/border-conflict-style-079.htm
css2.1/t170602-bdr-conflct-w-11-d.html
css2.1/t170602-bdr-conflct-w-07-d.html
css2.1/t170602-bdr-conflct-w-26-d.html
css2.1/t170602-bdr-conflct-w-15-d.html
css2.1/t170602-bdr-conflct-w-08-d.html
css2.1/t170602-bdr-conflct-w-12-d.html
css2.1/t170602-bdr-conflct-w-02-d.html
css2.1/t170602-bdr-conflct-w-21-d.html
css2.1/t170602-bdr-conflct-w-23-d.html
css2.1/20110323/border-collapse-offset-002.htm
css2.1/t170602-bdr-conflct-w-17-d.html
css2.1/t170602-bdr-conflct-w-28-d.html
css2.1/t170602-bdr-conflct-w-06-d.html
css2.1/20110323/border-conflict-style-088.htm
css2.1/t170602-bdr-conflct-w-16-d.html
css2.1/t170602-bdr-conflct-w-24-d.html
css2.1/t170602-bdr-conflct-w-13-d.html
css2.1/t170602-bdr-conflct-w-01-d.html
css2.1/t170602-bdr-conflct-w-04-d.html
css2.1/t170602-bdr-conflct-w-18-d.html
css2.1/t170602-bdr-conflct-w-27-d.html
css2.1/t170602-bdr-conflct-w-14-d.html
css2.1/t170602-bdr-conflct-w-05-d.html
css2.1/t170602-bdr-conflct-w-22-d.html
Comment 14 WebKit Review Bot 2013-03-27 06:21:46 PDT
Created attachment 195299 [details]
Archive of layout-test-results from gce-cr-linux-05 for chromium-linux-x86_64

The attached test failures were seen while running run-webkit-tests on the chromium-ews.
Bot: gce-cr-linux-05  Port: chromium-linux-x86_64  Platform: Linux-3.3.8-gcg-201212281604-x86_64-with-GCEL-10.04-gcel_10.04
Comment 15 Build Bot 2013-03-27 16:43:36 PDT
Comment on attachment 194905 [details]
WIP - 1

Attachment 194905 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-commit-queue.appspot.com/results/17324194

New failing tests:
css2.1/20110323/border-conflict-element-001d.htm
Comment 16 Build Bot 2013-03-27 16:43:39 PDT
Created attachment 195433 [details]
Archive of layout-test-results from webkit-ews-14 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-14  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.2
Comment 17 Build Bot 2013-03-28 06:19:40 PDT
Comment on attachment 194905 [details]
WIP - 1

Attachment 194905 [details] did not pass mac-ews (mac):
Output: http://webkit-commit-queue.appspot.com/results/17311557

New failing tests:
media/video-zoom.html
css2.1/20110323/border-conflict-element-001d.htm
Comment 18 Build Bot 2013-03-28 06:19:43 PDT
Created attachment 195550 [details]
Archive of layout-test-results from webkit-ews-01 for mac-future

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-01  Port: mac-future  Platform: Mac OS X 10.8.2
Comment 19 Build Bot 2013-03-28 06:48:36 PDT
Comment on attachment 194905 [details]
WIP - 1

Attachment 194905 [details] did not pass mac-ews (mac):
Output: http://webkit-commit-queue.appspot.com/results/17311581

New failing tests:
css2.1/20110323/border-conflict-element-001d.htm
Comment 20 Build Bot 2013-03-28 06:48:39 PDT
Created attachment 195559 [details]
Archive of layout-test-results from webkit-ews-05 for mac-future

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-05  Port: mac-future  Platform: Mac OS X 10.8.2
Comment 21 Pravin D 2013-06-13 07:26:22 PDT
Created attachment 204585 [details]
Patch
Comment 22 Elliott Sprehn 2013-06-17 21:46:54 PDT
Comment on attachment 204585 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=204585&action=review

> Source/WebCore/rendering/RenderTableCell.cpp:1113
> +bool RenderTableCell::alignTopBottomBorderPaintRect(RenderTableCell* cell, int& topYOffset, int& bottomYOffset)

This should just be a method on RenderTableCell instead of passing it as the first argument. It doesn't use any local state. cell->align...(...);

> Source/WebCore/rendering/RenderTableCell.cpp:1120
> +    bottomYOffset = max<int>(bottomYOffset, (bottom));

extra parens.

> Source/WebCore/rendering/RenderTableCell.cpp:1122
> +        bShouldDrawBorder = false;

return false;

> Source/WebCore/rendering/RenderTableCell.cpp:1123
> +    return bShouldDrawBorder;

return true;

> Source/WebCore/rendering/RenderTableCell.cpp:1163
> +    int bottomYOffsetLeft = bottomWidth, bottomYOffsetRight = bottomYOffsetLeft;

I think we usually do one variable init per line, but I don't know if the style is specific about it.

> Source/WebCore/rendering/RenderTableCell.cpp:1171
> +    bool shouldDrawLeftBorder = true, shouldDrawRightBorder = true;

Same deal.

> Source/WebCore/rendering/RenderTableCell.cpp:1174
> +        if (top->colSpan() > 1 || this->colSpan() > 1)

It's weird that one returns a boolean and one doesn't.

> Source/WebCore/rendering/RenderTableCell.cpp:1182
> +        shouldDrawLeftBorder = alignTopBottomBorderPaintRect(left, topYOffsetLeft, bottomYOffsetLeft);

if (left)
  left->alignTopBottom...(...);
Comment 23 Pravin D 2013-06-26 02:46:25 PDT
Created attachment 205465 [details]
Patch
Comment 24 Elliott Sprehn 2013-07-03 11:07:41 PDT
Comment on attachment 205465 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=205465&action=review

Looking at the layout test it's not clear if this is really better, you paint half blocks in the corners now which looks bad. I do see in Safari that if you zoom in the test case the borders will become dashes and sometimes even a solid line. Maybe you want the layout test to adjust the zoom?

> Source/WebCore/rendering/RenderTableCell.cpp:1106
> +    const RenderStyle* styleForTopCell = this->styleForCellFlow();

this-> is not needed anywhere in here.

> Source/WebCore/rendering/RenderTableCell.cpp:1118
> +    const RenderStyle* styleForBottomCell = this->styleForCellFlow();

Ditto.

> Source/WebCore/rendering/RenderTableCell.cpp:1166
> +    int topYOffsetLeft = topWidth;

These declarations are a bit weird, why is topWidth the same as topYOffsetLeft ?

> Source/WebCore/rendering/RenderTableCell.cpp:1186
> +    if (bottom)

I'd just merge all these declarations:

if (RenderTableCell* bottom = table()->cellBelow(this))
   bottom->...

> LayoutTests/fast/table/border-collapsing/dotted-collapsed-border.html:1
> +<html>

Add a doctype unless you need quirks mode.
Comment 25 Pravin D 2013-07-08 02:45:30 PDT
Created attachment 206225 [details]
Patch
Comment 26 Build Bot 2013-07-08 03:34:31 PDT
Comment on attachment 206225 [details]
Patch

Attachment 206225 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/949125

New failing tests:
fullscreen/full-screen-iframe-with-max-width-height.html
Comment 27 Build Bot 2013-07-08 03:34:34 PDT
Created attachment 206228 [details]
Archive of layout-test-results from webkit-ews-09 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-09  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.3
Comment 28 Pravin D 2013-07-09 00:15:27 PDT
(In reply to comment #24)
> (From update of attachment 205465 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=205465&action=review
> 
> Looking at the layout test it's not clear if this is really better, you paint half blocks in the corners now which looks bad. I do see in Safari that if you zoom in the test case the borders will become dashes and sometimes even a solid line. Maybe you want the layout test to adjust the zoom?
> 
Let me explain a little abt the issue..
Lets take the layout testcase as the example.
The collapse border(with the issue) are drawn as follows:
1) The top border of the lower cell is drawn. The start of the border is from the left extreme i.e from the left most point till which the left border extends. 
This translates to 
start X(top border)S1 = current cell start X - CellLeftWidth/2;
end X (top border)E1 = current cell end X - CellRightWidth/2;

2) The bottom border of the top cell is drawn to overlap the previously drawn border. The start and end points are same as above.
Lets name the start and end points as S2 and E2.


The problem occurs when S1 != S2 and/or E1 != E2. The problem becomes more and more visible when zoomed. 
The fix(only for dotted border case) is that we try to keep S1 = S2 and E1 = E2 by considering the left and right width of both the top and bottom cells which share the collapsed border.

> > Source/WebCore/rendering/RenderTableCell.cpp:1106
> > +    const RenderStyle* styleForTopCell = this->styleForCellFlow();
> 
> this-> is not needed anywhere in here.
> 
> > Source/WebCore/rendering/RenderTableCell.cpp:1118
> > +    const RenderStyle* styleForBottomCell = this->styleForCellFlow();
> 
> Ditto.
> 
done.
> > Source/WebCore/rendering/RenderTableCell.cpp:1166
> > +    int topYOffsetLeft = topWidth;
> 
> These declarations are a bit weird, why is topWidth the same as topYOffsetLeft ?
> 
Wen drawing the left border the starts from top most point where top border of the cell is drawn.

> > Source/WebCore/rendering/RenderTableCell.cpp:1186
> > +    if (bottom)
> 
> I'd just merge all these declarations:
> 
> if (RenderTableCell* bottom = table()->cellBelow(this))
>    bottom->...
> 
Done

> > LayoutTests/fast/table/border-collapsing/dotted-collapsed-border.html:1
> > +<html>
> 
> Add a doctype unless you need quirks mode.
> 
Done
Comment 29 WebKit Commit Bot 2013-07-30 21:58:37 PDT
Comment on attachment 206225 [details]
Patch

Clearing flags on attachment: 206225

Committed r153510: <http://trac.webkit.org/changeset/153510>
Comment 30 WebKit Commit Bot 2013-07-30 21:58:42 PDT
All reviewed patches have been landed.  Closing bug.