Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(528)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutTableSection.cpp

Issue 1602773005: Respect break-inside:avoid on table rows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp b/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
index 89b925af6f41a1551f1d609cd14bd23c85fada16..1045bb60d5a55f6a07973facd1b42397794927e1 100644
--- a/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
@@ -965,6 +965,7 @@ void LayoutTableSection::layoutRows()
for (unsigned r = 0; r < totalRows; r++) {
// Set the row's x/y position and width/height.
LayoutTableRow* rowLayoutObject = m_grid[r].rowLayoutObject;
+ int paginationStrutOnRow = 0;
if (rowLayoutObject) {
rowLayoutObject->setLocation(LayoutPoint(0, m_rowPos[r]));
rowLayoutObject->setLogicalWidth(logicalWidth());
@@ -972,6 +973,11 @@ void LayoutTableSection::layoutRows()
rowLayoutObject->updateLayerTransformAfterLayout();
rowLayoutObject->clearAllOverflows();
rowLayoutObject->addVisualEffectOverflow();
+ if (view()->layoutState()->isPaginated()) {
mstensho (USE GERRIT) 2016/03/29 09:57:46 Might want to cache this on the outside of the loo
+ paginationStrutOnRow = getPaginationStrutForRow(rowLayoutObject, LayoutUnit(m_rowPos[r]));
+ for (unsigned rowIndex = r; paginationStrutOnRow && rowIndex <= totalRows; rowIndex++)
+ m_rowPos[rowIndex] += paginationStrutOnRow;
+ }
}
int rowHeightIncreaseForPagination = 0;
@@ -1051,7 +1057,7 @@ void LayoutTableSection::layoutRows()
cell->layoutIfNeeded();
// FIXME: Make pagination work with vertical tables.
- if (view()->layoutState()->pageLogicalHeight() && cell->logicalHeight() != rHeight) {
+ if (!paginationStrutOnRow && view()->layoutState()->pageLogicalHeight() && cell->logicalHeight() != rHeight) {
// FIXME: Pagination might have made us change size. For now just shrink or grow the cell to fit without doing a relayout.
// We'll also do a basic increase of the row height to accommodate the cell if it's bigger, but this isn't quite right
// either. It's at least stable though and won't result in an infinite # of relayouts that may never stabilize.
@@ -1095,6 +1101,29 @@ void LayoutTableSection::layoutRows()
computeOverflowFromCells(totalRows, nEffCols);
}
+int LayoutTableSection::getPaginationStrutForRow(LayoutTableRow* row, LayoutUnit logicalOffset) const
+{
+ if (row->getPaginationBreakability() == AllowAnyBreaks)
+ return 0;
+ LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
+ if (!pageLogicalHeight)
+ return 0;
+ // If the row is too tall for the page don't insert a strut.
+ LayoutUnit rowLogicalHeight = row->logicalHeight();
+ if (rowLogicalHeight > pageLogicalHeight)
+ return 0;
+ LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logicalOffset, LayoutBlock::AssociateWithLatterPage);
+ if (remainingLogicalHeight >= rowLogicalHeight)
+ return 0; // It fits fine where it is. No need to break.
+ LayoutUnit paginationStrut = calculatePaginationStrutToFitContent(logicalOffset, remainingLogicalHeight, rowLogicalHeight);
+ if (paginationStrut == remainingLogicalHeight && remainingLogicalHeight == pageLogicalHeight) {
+ // Don't break if we were at the top of a page, and we failed to fit the content
+ // completely. No point in leaving a page completely blank.
+ return 0;
+ }
+ return paginationStrut;
+}
+
void LayoutTableSection::computeOverflowFromCells()
{
unsigned totalRows = m_grid.size();

Powered by Google App Engine
This is Rietveld 408576698