Index: Source/core/rendering/RenderTableSection.cpp |
diff --git a/Source/core/rendering/RenderTableSection.cpp b/Source/core/rendering/RenderTableSection.cpp |
index b49f47f6987963472b955849aa78f06dab026038..a69ff0153b77a978f987b0e9bd55ea138863b1c2 100644 |
--- a/Source/core/rendering/RenderTableSection.cpp |
+++ b/Source/core/rendering/RenderTableSection.cpp |
@@ -253,6 +253,29 @@ void RenderTableSection::addCell(RenderTableCell* cell, RenderTableRow* row) |
cell->setCol(table()->effColToCol(col)); |
} |
+unsigned RenderTableSection::rowHasOnlySpanningCells(unsigned row) |
+{ |
+ ASSERT(row < m_grid.size()); |
Julien - ping for review
2013/09/18 18:39:37
This ...
a.suchit
2013/09/19 08:18:36
Done.
|
+ |
+ if (row >= m_grid.size()) |
Julien - ping for review
2013/09/18 18:39:37
.. and this are unneeded ...
a.suchit
2013/09/19 08:18:36
Done.
|
+ return false; |
+ |
+ unsigned totalCols = m_grid[row].row.size(); |
Julien - ping for review
2013/09/18 18:39:37
... because m_grid[row] calls Vector::at(size_t i)
|
+ |
+ if (!totalCols) |
+ return false; |
+ |
+ for (unsigned col = 0; col < totalCols; col++) { |
+ const CellStruct& rowSpanCell = cellAt(row, col); |
+ |
+ // Empty cell would be 1 rowspan cell only if we consider that empty cell is valid cell. |
Julien - ping for review
2013/09/18 18:39:37
The more I read this comment the less I understand
a.suchit
2013/09/19 08:18:36
Done.
|
+ if (rowSpanCell.cells.isEmpty() || rowSpanCell.cells[0]->rowSpan() == 1) |
Julien - ping for review
2013/09/18 18:39:37
Nit: I would have separated these 2 conditions so
a.suchit
2013/09/19 08:18:36
Done.
|
+ return false; |
+ } |
+ |
+ return true; |
+} |
+ |
void RenderTableSection::populateSpanningRowsHeightFromCell(RenderTableCell* cell, struct SpanningRowsHeight& spanningRowsHeight) |
{ |
const unsigned rowSpan = cell->rowSpan(); |
@@ -264,7 +287,11 @@ void RenderTableSection::populateSpanningRowsHeightFromCell(RenderTableCell* cel |
spanningRowsHeight.totalRowsHeight = 0; |
for (unsigned row = 0; row < rowSpan; row++) { |
unsigned actualRow = row + rowIndex; |
+ |
spanningRowsHeight.rowHeight[row] = m_rowPos[actualRow + 1] - m_rowPos[actualRow] - borderSpacingForRow(actualRow); |
+ if (!spanningRowsHeight.rowHeight[row]) |
+ spanningRowsHeight.rowWithOnlySpanningCells |= rowHasOnlySpanningCells(actualRow); |
+ |
spanningRowsHeight.totalRowsHeight += spanningRowsHeight.rowHeight[row]; |
spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing -= borderSpacingForRow(actualRow); |
} |
@@ -395,6 +422,52 @@ static bool compareRowSpanCellsInHeightDistributionOrder(const RenderTableCell* |
return false; |
} |
+unsigned RenderTableSection::calcRowHeightHavingOnlySpanningCells(unsigned row) |
+{ |
+ ASSERT(row < m_grid.size()); |
Julien - ping for review
2013/09/18 18:39:37
Same comment as above, unneeded and should be remo
a.suchit
2013/09/19 08:18:36
Done.
|
+ ASSERT(rowHasOnlySpanningCells(row)); |
+ |
+ if (row >= m_grid.size()) |
Julien - ping for review
2013/09/18 18:39:37
Same comment as above, unneeded and should be remo
a.suchit
2013/09/19 08:18:36
Done.
|
+ return 0; |
+ |
+ unsigned totalCols = m_grid[row].row.size(); |
+ |
+ if (!totalCols) |
+ return 0; |
+ |
+ unsigned rowHeight = 0; |
+ |
+ for (unsigned col = 0; col < totalCols; col++) { |
+ CellStruct rowSpanCell = cellAt(row, col); |
Julien - ping for review
2013/09/18 18:39:37
Again, const reference to avoid an implicit copy!
a.suchit
2013/09/19 08:18:36
Done.
|
+ if (rowSpanCell.cells.size() && rowSpanCell.cells[0]->rowSpan() > 1) |
+ rowHeight = max(rowHeight, rowSpanCell.cells[0]->logicalHeightForRowSizing() / rowSpanCell.cells[0]->rowSpan()); |
+ } |
+ |
+ return rowHeight; |
+} |
+ |
+void RenderTableSection::updateRowsHeightHavingOnlySpanningCells(RenderTableCell* cell, struct SpanningRowsHeight& spanningRowsHeight) |
+{ |
+ ASSERT(spanningRowsHeight.rowHeight.size()); |
+ |
+ int accumulatedPositionIncrease = 0; |
+ const unsigned rowSpan = cell->rowSpan(); |
+ const unsigned rowIndex = cell->rowIndex(); |
+ |
+ ASSERT(rowSpan == spanningRowsHeight.rowHeight.size()); |
+ |
+ for (unsigned row = 0; row < spanningRowsHeight.rowHeight.size(); row++) { |
+ unsigned actualRow = row + rowIndex; |
+ if (!spanningRowsHeight.rowHeight[row] && rowHasOnlySpanningCells(actualRow)) { |
+ spanningRowsHeight.rowHeight[row] = calcRowHeightHavingOnlySpanningCells(actualRow); |
+ accumulatedPositionIncrease += spanningRowsHeight.rowHeight[row]; |
+ } |
+ m_rowPos[actualRow + 1] += accumulatedPositionIncrease; |
+ } |
+ |
+ spanningRowsHeight.totalRowsHeight += accumulatedPositionIncrease; |
+} |
+ |
// Distribute rowSpan cell height in rows those comes in rowSpan cell based on the ratio of row's height if |
// 1. RowSpan cell height is greater then the total height of rows in rowSpan cell |
void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) |
@@ -444,8 +517,13 @@ void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& |
populateSpanningRowsHeightFromCell(cell, spanningRowsHeight); |
- if (!spanningRowsHeight.totalRowsHeight || spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing <= spanningRowsHeight.totalRowsHeight) |
+ if (spanningRowsHeight.rowWithOnlySpanningCells) |
+ updateRowsHeightHavingOnlySpanningCells(cell, spanningRowsHeight); |
+ |
+ if (!spanningRowsHeight.totalRowsHeight || spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing <= spanningRowsHeight.totalRowsHeight) { |
+ extraHeightToPropagate = m_rowPos[rowIndex + rowSpan] - originalBeforePosition; |
continue; |
+ } |
int totalPercent = 0; |
int totalAutoRowsHeight = 0; |