Skip to content

Commit

Permalink
#303 - Correction for problem background coverage when using collapse…
Browse files Browse the repository at this point in the history
…d table borders.

We were using a generic border bounds function to determine the clipping area for background painting. This did not take into account collapsed borders. We now use the collapsed border bounds, when available.

Includes tests for collapsed and separated table cell borders.
  • Loading branch information
danfickle committed Dec 24, 2018
1 parent 11f18db commit ddadde8
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,9 @@ bounds, getTable().getColumnBounds(c, getCol()),

c.getOutputDevice().paintBackground(c, rowStyle, bounds, imageContainer, border);

c.getOutputDevice().paintBackground(c, getStyle(), bounds, getPaintingBorderEdge(c), border);
BorderPropertySet cellBorder = _collapsedLayoutBorder != null ? _collapsedLayoutBorder : border;

c.getOutputDevice().paintBackground(c, getStyle(), bounds, getPaintingBorderEdge(c), cellBorder);
}

public void paintBorder(RenderingContext c) {
Expand Down Expand Up @@ -770,6 +772,7 @@ private CollapsedBorderValue collapsedBottomBorder(CssContext c) {
private Rectangle getCollapsedBorderBounds(CssContext c) {
BorderPropertySet border = getCollapsedPaintingBorder();
Rectangle bounds = getPaintingBorderEdge(c);

bounds.x -= (int) border.left() / 2;
bounds.y -= (int) border.top() / 2;
bounds.width += (int) border.left() / 2 + ((int) border.right() + 1) / 2;
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<html>
<head>
<style>
@page {
size: 250px 50px;
margin: 0;
}
body {
margin: 0;
}
td {
min-width: 100px;
padding: 0;
background-color: blue;
min-height: 20px;
}
.left {
border-right: 10px solid pink;
}
.right {
border-left: 10px solid orange;
}
</style>
</head>
<body>
<div style="background-color: red;">
<table style="">
<tr>
<td class="left"></td><td class="right"></td>
</tr>
</table>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<html>
<head>
<style>
@page {
size: 250px 50px;
margin: 0;
}
body {
margin: 0;
}
td {
min-width: 100px;
padding: 0;
background-color: blue;
min-height: 20px;
}
.left {
border-right: 10px solid pink;
}
.right {
border-left: 10px solid orange;
}
</style>
</head>
<body>
<!-- Measuring stick -->
<div style="display: inline-block; width: 100px; background-color: green; min-height: 20px; margin: 0; padding: 0;"></div><div style="display: inline-block; width: 10px; background-color: black; min-height: 20px; margin: 0; padding: 0;"></div><div style="display: inline-block; width: 100px; background-color: gray; min-height: 20px; margin: 0; padding: 0;"></div>
<br/>

<div style="background-color: red;">
<table style="border-collapse: collapse;">
<tr>
<td class="left"></td><td class="right"></td>
</tr>
</table>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,22 @@ public void testTableFineLines() throws IOException {
assertTrue(vt.runTest("table-fine-lines"));
}

/**
* Further tests on collapsed table cell borders. Issue 303.
*/
@Test
public void testTableCellBorders() throws IOException {
assertTrue(vt.runTest("table-cell-borders"));
}

/**
* Further tests on separated table cell borders.
*/
@Test
public void testTableCellBorders2() throws IOException {
assertTrue(vt.runTest("table-cell-borders-2"));
}

/**
* Tests than an inline block, floated, with border, that the border is visible. Issue 297.
*/
Expand Down

0 comments on commit ddadde8

Please sign in to comment.