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

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, 7 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutTableSection.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 40ca5ea321701a5af3aaa059d5d63132947aff6d..504f386324e54f01e5cf365342782b118f022914 100644
--- a/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
@@ -956,20 +956,29 @@ void LayoutTableSection::layoutRows()
int vspacing = table()->vBorderSpacing();
unsigned nEffCols = table()->numEffectiveColumns();
+ bool isPaginated = view()->layoutState()->isPaginated();
LayoutState state(*this, locationOffset());
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());
rowLayoutObject->setLogicalHeight(LayoutUnit(m_rowPos[r + 1] - m_rowPos[r] - vspacing));
rowLayoutObject->updateLayerTransformAfterLayout();
+ if (isPaginated) {
+ paginationStrutOnRow = paginationStrutForRow(rowLayoutObject, LayoutUnit(m_rowPos[r]));
+ if (paginationStrutOnRow) {
+ for (unsigned rowIndex = r; rowIndex <= totalRows; rowIndex++)
+ m_rowPos[rowIndex] += paginationStrutOnRow;
+ }
+ }
}
- int rowHeightIncreaseForPagination = 0;
+ int rowHeightIncreaseForPagination = INT_MIN;
for (unsigned c = 0; c < nEffCols; c++) {
CellStruct& cs = cellAt(r, c);
@@ -1051,8 +1060,7 @@ void LayoutTableSection::layoutRows()
// 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.
LayoutUnit oldLogicalHeight = cell->logicalHeight();
- if (oldLogicalHeight > rHeight)
- rowHeightIncreaseForPagination = std::max<int>(rowHeightIncreaseForPagination, oldLogicalHeight - rHeight);
+ rowHeightIncreaseForPagination = std::max<int>(rowHeightIncreaseForPagination, oldLogicalHeight - rHeight);
cell->setLogicalHeight(LayoutUnit(rHeight));
cell->computeOverflow(oldLogicalHeight, false);
}
@@ -1066,7 +1074,7 @@ void LayoutTableSection::layoutRows()
cell->setMayNeedPaintInvalidation();
}
}
- if (rowHeightIncreaseForPagination) {
+ if (rowHeightIncreaseForPagination > INT_MIN) {
for (unsigned rowIndex = r + 1; rowIndex <= totalRows; rowIndex++)
m_rowPos[rowIndex] += rowHeightIncreaseForPagination;
for (unsigned c = 0; c < nEffCols; ++c) {
@@ -1089,6 +1097,29 @@ void LayoutTableSection::layoutRows()
computeOverflowFromCells(totalRows, nEffCols);
}
+int LayoutTableSection::paginationStrutForRow(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();
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutTableSection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698