Chromium Code Reviews| Index: Source/core/rendering/RenderTableSection.cpp |
| diff --git a/Source/core/rendering/RenderTableSection.cpp b/Source/core/rendering/RenderTableSection.cpp |
| index a41c97a5de7950ca19ec976c8127dd7d73bced19..8e404a8e465ec5120e6a9fe2a1874a79e83e298c 100644 |
| --- a/Source/core/rendering/RenderTableSection.cpp |
| +++ b/Source/core/rendering/RenderTableSection.cpp |
| @@ -484,57 +484,59 @@ static bool compareRowSpanCellsInHeightDistributionOrder(const RenderTableCell* |
| return false; |
| } |
| -bool RenderTableSection::isHeightNeededForRowHavingOnlySpanningCells(unsigned row) |
| +unsigned RenderTableSection::calcRowHeightHavingOnlySpanningCells(unsigned row, int& accumulatedCellPositionIncrease, unsigned rowToApplyExtraHeight, unsigned& extraTableHeightToPropgate, Vector<int>& rowsCountWithOnlySpanningCells) |
| { |
| + ASSERT(rowHasOnlySpanningCells(row)); |
| + |
| unsigned totalCols = m_grid[row].row.size(); |
| if (!totalCols) |
| - return false; |
| + return 0; |
| + |
| + unsigned rowHeight = 0; |
| for (unsigned col = 0; col < totalCols; col++) { |
| const CellStruct& rowSpanCell = cellAt(row, col); |
| - if (rowSpanCell.cells.size()) { |
| - RenderTableCell* cell = rowSpanCell.cells[0]; |
| - const unsigned rowIndex = cell->rowIndex(); |
| - const unsigned rowSpan = cell->rowSpan(); |
| - int totalRowSpanCellHeight = 0; |
| + if (!rowSpanCell.cells.size()) |
| + continue; |
| - for (unsigned row = 0; row < rowSpan; row++) { |
| - unsigned actualRow = row + rowIndex; |
| - totalRowSpanCellHeight += m_rowPos[actualRow + 1] - m_rowPos[actualRow]; |
| - } |
| - totalRowSpanCellHeight -= borderSpacingForRow(rowIndex + rowSpan - 1); |
| + RenderTableCell* cell = rowSpanCell.cells[0]; |
| - if (totalRowSpanCellHeight < cell->logicalHeightForRowSizing()) |
| - return true; |
| - } |
| - } |
| + if (cell->rowSpan() <= 1) |
|
Julien - ping for review
2014/12/16 23:00:27
rowSpan is at least 1 so we shouldn't put use <= a
a.suchit
2014/12/17 13:50:37
Done.
|
| + continue; |
| - return false; |
| -} |
| + const unsigned cellRowIndex = cell->rowIndex(); |
| + const unsigned cellRowSpan = cell->rowSpan(); |
|
Julien - ping for review
2014/12/16 23:00:27
Note that the Chromium coding style bans the use o
a.suchit
2014/12/17 13:50:37
In that case, we need to change it in whole table
|
| -unsigned RenderTableSection::calcRowHeightHavingOnlySpanningCells(unsigned row) |
| -{ |
| - ASSERT(rowHasOnlySpanningCells(row)); |
| + // As we are going from the top of the table to the bottom to calculate the row |
| + // heights for rows that only contain spanning cells and all previous rows are |
| + // processed we only need to find the number of rows with spanning cells from the |
| + // current cell to the end of the current cells spanning height. |
| + unsigned startRowForSpanningCellCount = max(cellRowIndex, row); |
|
Julien - ping for review
2014/12/16 23:00:27
Coding style: std::max should be used not max.
a.suchit
2014/12/17 13:50:37
Done.
|
| + unsigned endRow = cellRowIndex + cellRowSpan; |
| + unsigned spanningCellsRowsCountHavingZeroHeight = rowsCountWithOnlySpanningCells[endRow - 1]; |
| - unsigned totalCols = m_grid[row].row.size(); |
| + if (startRowForSpanningCellCount) |
| + spanningCellsRowsCountHavingZeroHeight -= rowsCountWithOnlySpanningCells[startRowForSpanningCellCount - 1]; |
| - if (!totalCols) |
| - return 0; |
| + int totalRowspanCellHeight = (m_rowPos[endRow] - m_rowPos[cellRowIndex]) - borderSpacingForRow(endRow - 1); |
| - unsigned rowHeight = 0; |
| + totalRowspanCellHeight += accumulatedCellPositionIncrease; |
| + if (rowToApplyExtraHeight >= cellRowIndex && rowToApplyExtraHeight < endRow) |
| + totalRowspanCellHeight += extraTableHeightToPropgate; |
| - for (unsigned col = 0; col < totalCols; col++) { |
| - const CellStruct& rowSpanCell = cellAt(row, col); |
| - if (rowSpanCell.cells.size() && rowSpanCell.cells[0]->rowSpan() > 1) |
| - rowHeight = std::max(rowHeight, rowSpanCell.cells[0]->logicalHeightForRowSizing() / rowSpanCell.cells[0]->rowSpan()); |
| + if (totalRowspanCellHeight < cell->logicalHeightForRowSizing()) { |
| + unsigned extraHeightRequired = cell->logicalHeightForRowSizing() - totalRowspanCellHeight; |
| + |
| + rowHeight = std::max(rowHeight, extraHeightRequired / spanningCellsRowsCountHavingZeroHeight); |
| + } |
| } |
| return rowHeight; |
| } |
| -void RenderTableSection::updateRowsHeightHavingOnlySpanningCells(RenderTableCell* cell, struct SpanningRowsHeight& spanningRowsHeight) |
| +void RenderTableSection::updateRowsHeightHavingOnlySpanningCells(RenderTableCell* cell, struct SpanningRowsHeight& spanningRowsHeight, unsigned& extraHeightToPropagate, Vector<int>& rowsCountWithOnlySpanningCells) |
| { |
| ASSERT(spanningRowsHeight.rowHeight.size()); |
| @@ -546,8 +548,8 @@ void RenderTableSection::updateRowsHeightHavingOnlySpanningCells(RenderTableCell |
| for (unsigned row = 0; row < spanningRowsHeight.rowHeight.size(); row++) { |
| unsigned actualRow = row + rowIndex; |
| - if (!spanningRowsHeight.rowHeight[row] && rowHasOnlySpanningCells(actualRow) && isHeightNeededForRowHavingOnlySpanningCells(actualRow)) { |
| - spanningRowsHeight.rowHeight[row] = calcRowHeightHavingOnlySpanningCells(actualRow); |
| + if (!spanningRowsHeight.rowHeight[row] && rowHasOnlySpanningCells(actualRow)) { |
| + spanningRowsHeight.rowHeight[row] = calcRowHeightHavingOnlySpanningCells(actualRow, accumulatedPositionIncrease, rowIndex + rowSpan, extraHeightToPropagate, rowsCountWithOnlySpanningCells); |
| accumulatedPositionIncrease += spanningRowsHeight.rowHeight[row]; |
| } |
| m_rowPos[actualRow + 1] += accumulatedPositionIncrease; |
| @@ -570,6 +572,16 @@ void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& |
| unsigned lastRowIndex = 0; |
| unsigned lastRowSpan = 0; |
| + Vector<int> rowsCountWithOnlySpanningCells; |
| + |
| + // At this stage, Height of the rows are zero for the one containing only spanning cells. |
| + int count = 0; |
| + for (unsigned row = 0; row < m_grid.size(); row++) { |
| + if (rowHasOnlySpanningCells(row)) |
| + count++; |
| + rowsCountWithOnlySpanningCells.append(count); |
| + } |
| + |
| for (unsigned i = 0; i < rowSpanCells.size(); i++) { |
| RenderTableCell* cell = rowSpanCells[i]; |
| @@ -607,7 +619,7 @@ void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& |
| // Here we are handling only row(s) who have only rowspanning cells and do not have any empty cell. |
| if (spanningRowsHeight.isAnyRowWithOnlySpanningCells) |
| - updateRowsHeightHavingOnlySpanningCells(cell, spanningRowsHeight); |
| + updateRowsHeightHavingOnlySpanningCells(cell, spanningRowsHeight, extraHeightToPropagate, rowsCountWithOnlySpanningCells); |
| // This code handle row(s) that have rowspanning cell(s) and at least one empty cell. |
| // Such rows are not handled below and end up having a height of 0. That would mean |