Chromium Code Reviews| 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 7586ee7266b54949e7ef25b59c22ed8cee6c79cc..fcf3fb0ef86ed968fe1cb45b077f391fc6cdd806 100644 |
| --- a/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp |
| +++ b/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp |
| @@ -856,6 +856,11 @@ int LayoutTableSection::calcRowLogicalHeight() { |
| HashSet<const LayoutTableCell*> uniqueCells; |
| #endif |
| + // At fragmentainer breaks we need to prevent rowspanned cells (and whatever |
| + // else) from distributing their extra height requirements over the rows that |
| + // it spans. Otherwise we'd need to refragment afterwards. |
| + unsigned indexOfFirstStretchableRow = 0; |
| + |
| for (unsigned r = 0; r < m_grid.size(); r++) { |
| m_grid[r].baseline = -1; |
| int baselineDescent = 0; |
| @@ -888,7 +893,20 @@ int LayoutTableSection::calcRowLogicalHeight() { |
| if (current.inColSpan && cell->rowSpan() == 1) |
| continue; |
| - if (cell->rowSpan() > 1) { |
| + if (r < indexOfFirstStretchableRow || |
| + (state.isPaginated() && |
| + crossesPageBoundary( |
| + LayoutUnit(m_rowPos[cell->rowIndex()]), |
| + LayoutUnit(cell->logicalHeightForRowSizing())))) { |
| + // Entering or extending a range of unstretchable rows. We enter this |
| + // mode when a cell in a row crosses a fragmentainer boundary, and |
| + // we'll stay in this mode until we get to a row where we're past all |
| + // rowspanned cells that we encountered while in this mode. |
| + DCHECK(state.isPaginated()); |
| + unsigned rowIndexBelowCell = cell->rowIndex() + cell->rowSpan(); |
| + indexOfFirstStretchableRow = |
| + std::max(indexOfFirstStretchableRow, rowIndexBelowCell); |
| + } else if (cell->rowSpan() > 1) { |
| // For row spanning cells, we only handle them for the first row they |
| // span. This ensures we take their baseline into account. |
| if (lastRowSpanCell != cell && cell->rowIndex() == r) { |
| @@ -919,6 +937,14 @@ int LayoutTableSection::calcRowLogicalHeight() { |
| } |
| } |
| + if (r < indexOfFirstStretchableRow && m_grid[r].rowLayoutObject) { |
| + // We're not allowed to resize this row. Just scratch what we've |
| + // calculated so far, and use the height that we got during initial |
| + // layout instead. |
| + m_rowPos[r + 1] = |
| + m_rowPos[r] + m_grid[r].rowLayoutObject->logicalHeight().toInt(); |
| + } |
| + |
| // Add the border-spacing to our final position. |
| m_rowPos[r + 1] += borderSpacingForRow(r); |
| m_rowPos[r + 1] = std::max(m_rowPos[r + 1], m_rowPos[r]); |
| @@ -1974,11 +2000,28 @@ int LayoutTableSection::logicalHeightForRow( |
| const LayoutTableCell* cell = cellStruct.primaryCell(); |
| if (!cell || cellStruct.inColSpan) |
| continue; |
| - // TODO(mstensho): Rowspanned cells also need to contribute to row heights |
| - // during the first layout pass, in order to get fragmentation right. |
| - if (cell->rowSpan() == 1) { |
| + unsigned rowSpan = cell->rowSpan(); |
| + if (rowSpan == 1) { |
| logicalHeight = |
| std::max(logicalHeight, cell->logicalHeightForRowSizing()); |
| + continue; |
| + } |
| + unsigned rowIndexForCell = cell->rowIndex(); |
| + if (rowIndex == m_grid.size() - 1 || |
| + (rowSpan > 1 && rowIndex - rowIndexForCell == rowSpan - 1)) { |
| + // This is the last row of the rowspanned cell. Add extra height if |
| + // needed. |
| + if (LayoutTableRow* firstRowForCell = |
| + m_grid[rowIndexForCell].rowLayoutObject) { |
| + int rowLogicalTop = rowObject.logicalTop().round(); |
| + |
| + int minLogicalHeight = cell->logicalHeightForRowSizing(); |
| + // Subtract space provided by previous rows. |
| + minLogicalHeight -= |
| + rowLogicalTop - firstRowForCell->logicalTop().toInt(); |
|
eae
2016/10/20 16:53:58
Above you round the logicalTop and here you floor
mstensho (USE GERRIT)
2016/10/20 19:05:56
Better use toInt() everywhere, unless there are go
|
| + |
| + logicalHeight = std::max(logicalHeight, minLogicalHeight); |
| + } |
| } |
| } |