Commit 8fdd7b1b authored by robhogan's avatar robhogan Committed by Commit bot

Account for border spacing correctly when repeating header groups

BUG=642814

Review-Url: https://codereview.chromium.org/2422163003
Cr-Commit-Position: refs/heads/master@{#427044}
parent bd75dc34
<!DOCTYPE html>
<style>
td, th {
background-color: #ddd;
border: 1px solid black;
}
thead, tr {
break-inside: avoid;
}
</style>
<p>crbug.com/642814: A row positioned naturally at the top of a column should move below any repeating table header.</p>
<div style="columns:3; line-height: 18px; column-fill: auto; height:72px; background-color: yellow; position:relative;">
<table>
<tr>
<th>Col 1</th>
<th>Col 2</th>
</tr>
<tr><td>Te</td><td>xt</td></tr>
<tr><td>Te</td><td>xt</td></tr>
</table>
<table style="position: absolute; top: 0px">
<tr>
<th>Col 1</th>
<th>Col 2</th>
</tr>
<tr><td>Te</td><td>xt</td></tr>
<tr><td>Te</td><td>xt</td></tr>
</table>
</div>
<!DOCTYPE html>
<style>
td, th {
background-color: #ddd;
border: 1px solid black;
}
thead, tr {
break-inside: avoid;
}
</style>
<p>crbug.com/642814: A row positioned naturally at the top of a column should move below any repeating table header.</p>
<div style="columns:3; line-height: 18px; column-fill: auto; height:72px; background-color: yellow;">
<table>
<thead>
<tr>
<th>Col 1</th>
<th>Col 2</th>
</tr>
</thead>
<tr><td>Te</td><td>xt</td></tr>
<tr><td>Te</td><td>xt</td></tr>
<tr><td>Te</td><td>xt</td></tr>
<tr><td>Te</td><td>xt</td></tr>
</table>
</div>
......@@ -1246,14 +1246,6 @@ int LayoutTableSection::paginationStrutForRow(LayoutTableRow* row,
LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(
logicalOffset, LayoutBlock::AssociateWithLatterPage);
LayoutUnit offsetForBorderSpacing =
pageLogicalHeight - (remainingLogicalHeight + table()->vBorderSpacing());
// Border spacing from the previous row has pushed this row just past the top
// of the page, so we must reposition it to the top of the page and avoid any
// repeating header.
if (offsetForBorderSpacing < 0)
return offsetForBorderSpacing.toInt();
if (remainingLogicalHeight >= rowLogicalHeight)
return 0; // It fits fine where it is. No need to break.
LayoutUnit paginationStrut = calculatePaginationStrutToFitContent(
......@@ -1998,12 +1990,18 @@ void LayoutTableSection::adjustRowForPagination(LayoutTableRow& rowObject,
rowObject.setLogicalHeight(LayoutUnit(logicalHeightForRow(rowObject)));
int paginationStrut =
paginationStrutForRow(&rowObject, rowObject.logicalTop());
bool rowIsAtTopOfColumn = false;
LayoutUnit offsetFromTopOfPage;
if (!paginationStrut) {
bool rowIsAtTopOfColumn =
state.heightOffsetForTableHeaders() &&
pageLogicalHeightForOffset(rowObject.logicalTop()) ==
pageRemainingLogicalHeightForOffset(rowObject.logicalTop(),
AssociateWithLatterPage);
if (state.heightOffsetForTableHeaders()) {
offsetFromTopOfPage =
pageLogicalHeightForOffset(rowObject.logicalTop()) -
pageRemainingLogicalHeightForOffset(rowObject.logicalTop(),
AssociateWithLatterPage);
rowIsAtTopOfColumn = !offsetFromTopOfPage ||
offsetFromTopOfPage <= table()->vBorderSpacing();
}
if (!rowIsAtTopOfColumn)
return;
}
......@@ -2021,6 +2019,12 @@ void LayoutTableSection::adjustRowForPagination(LayoutTableRow& rowObject,
state.setHeightOffsetForTableHeaders(state.heightOffsetForTableHeaders() -
header->logicalHeight());
}
// Border spacing from the previous row has pushed this row just past the top
// of the page, so we must reposition it to the top of the page and avoid any
// repeating header.
if (rowIsAtTopOfColumn && offsetFromTopOfPage)
paginationStrut -= offsetFromTopOfPage.toInt();
// If we have a header group we will paint it at the top of each page,
// move the rows down to accomodate it.
paginationStrut += state.heightOffsetForTableHeaders().toInt();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment