Chromium Code Reviews| Index: Source/core/rendering/RenderTableSection.cpp |
| diff --git a/Source/core/rendering/RenderTableSection.cpp b/Source/core/rendering/RenderTableSection.cpp |
| index 8592fb6c455345607517620f1b567d709fd0069b..c764b3f66dddf69b19826fa8a97aa2e698c4b9aa 100644 |
| --- a/Source/core/rendering/RenderTableSection.cpp |
| +++ b/Source/core/rendering/RenderTableSection.cpp |
| @@ -254,24 +254,14 @@ void RenderTableSection::addCell(RenderTableCell* cell, RenderTableRow* row) |
| cell->setCol(table()->effColToCol(col)); |
| } |
| -// 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) |
| +// Getting height of rows in current rowSpan cell, getting total height of rows and adjusting rowSpan cell height with border spacing. |
| +void RenderTableSection::getRowsHeightInRowSpan(RenderTableCell* cell, int& expectedTotalRowsHeight, int& totalRowsHeight, Vector<int>& rowsHeight) |
|
Julien - ping for review
2013/07/03 21:08:22
Really get a structure for the parameters you alwa
a.suchit
2013/07/13 00:49:56
Done.
|
| { |
| - ASSERT(rowSpanCells.size()); |
| - |
| - // FIXME: For now, we handle the first rowspan cell in the table but this is wrong. |
| - RenderTableCell* cell = rowSpanCells[0]; |
| - |
| unsigned rowSpan = cell->rowSpan(); |
| unsigned rowIndex = cell->rowIndex(); |
| - int initialPos = m_rowPos[rowIndex + rowSpan]; |
| - |
| - int totalRowsHeight = 0; |
| int rowSpanCellHeight = cell->logicalHeightForRowSizing(); |
| - Vector<int> rowsHeight(rowSpan); |
| - // Getting height of rows in current rowSpan cell, getting total height of rows and adjusting rowSpan cell height with border spacing. |
| + totalRowsHeight = 0; |
| for (unsigned row = 0; row < rowSpan; row++) { |
| unsigned actualRow = row + rowIndex; |
| rowsHeight[row] = m_rowPos[actualRow + 1] - m_rowPos[actualRow] - borderSpacingForRow(actualRow); |
| @@ -280,22 +270,134 @@ void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& |
| } |
| rowSpanCellHeight += borderSpacingForRow(rowIndex + rowSpan - 1); |
| - if (!totalRowsHeight || rowSpanCellHeight <= totalRowsHeight) |
| + expectedTotalRowsHeight = rowSpanCellHeight; |
|
Julien - ping for review
2013/07/03 21:08:22
Why do we need |rowSpanCellHeight| then?
a.suchit
2013/07/13 00:49:56
Changed
|
| +} |
| + |
| +// If percent is more than 100 then whole extra height would be distribute in percent rows based on their percent ratios so that |
| +// all percent rows would get additional height from extra rowspanning height. |
| +// Else specified percent (totalPercent) of extra height would be distributed in percent rows and |
| +// remaining would be distributed in other rows. |
| +void RenderTableSection::distributeExtraRowSpanHeightToPrecentRows(RenderTableCell* cell, int totalPercent, int& extraRowSpanningHeight, Vector<int>& rowsHeight) |
|
Julien - ping for review
2013/07/03 21:08:22
|cell| is not modified (and is not expected to be)
|
| +{ |
| + if (!extraRowSpanningHeight || !totalPercent) |
| + return; |
| + |
| + unsigned rowSpan = cell->rowSpan(); |
| + unsigned rowIndex = cell->rowIndex(); |
| + |
| + if (100 < totalPercent) { |
|
Julien - ping for review
2013/07/03 21:08:22
You never answered about this and I am pretty much
a.suchit
2013/07/13 00:49:56
Removed
|
| + int changedPosBy = 0; |
| + for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { |
| + if (m_grid[row].logicalHeight.isPercent()) |
| + changedPosBy += extraRowSpanningHeight * m_grid[row].logicalHeight.percent() / totalPercent; |
| + m_rowPos[row + 1] += changedPosBy; |
| + } |
| + |
| + // Remaining height added in the last row under rowSpan cell |
| + m_rowPos[rowIndex + rowSpan] += extraRowSpanningHeight - changedPosBy; |
| + extraRowSpanningHeight -= changedPosBy; |
| + } else { |
| + int changedPosBy = 0; |
| + for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { |
| + if (m_grid[row].logicalHeight.isPercent()) |
| + changedPosBy += extraRowSpanningHeight * m_grid[row].logicalHeight.percent() / 100; |
|
Julien - ping for review
2013/07/03 21:08:22
This code is backwards if you look at what we do i
a.suchit
2013/07/13 00:49:56
Done.
|
| + m_rowPos[row + 1] += changedPosBy; |
| + } |
| + |
| + extraRowSpanningHeight -= changedPosBy; |
| + } |
| +} |
| + |
| +// If auto rows are present then whole extra height would be distribute in auto rows based on their height ratios so that |
| +// all auto rows would get its own share from extra height. |
| +// Else extra height would be distributed in other rows. |
|
Julien - ping for review
2013/07/03 21:08:22
This line is useless. As a whole, your comments ar
a.suchit
2013/07/13 00:49:56
Done.
|
| +void RenderTableSection::distributeExtraRowSpanHeightToAutoRows(RenderTableCell* cell, int totalAutoRowsHeight, int& extraRowSpanningHeight, Vector<int>& rowsHeight) |
| +{ |
| + if (!extraRowSpanningHeight || !totalAutoRowsHeight) |
| return; |
| - // Recalculating the height of rows based on rowSpan cell height if rowSpan cell height is more than total height of rows. |
| - int remainingHeight = rowSpanCellHeight; |
| + unsigned rowSpan = cell->rowSpan(); |
| + unsigned rowIndex = cell->rowIndex(); |
| + int changedPosBy = 0; |
| for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { |
| - int rowHeight = (rowSpanCellHeight * rowsHeight[row - rowIndex]) / totalRowsHeight; |
| - remainingHeight -= rowHeight; |
| - m_rowPos[row + 1] = m_rowPos[row] + rowHeight + borderSpacingForRow(row); |
| + if (m_grid[row].logicalHeight.isAuto()) |
| + changedPosBy += (extraRowSpanningHeight * rowsHeight[row - rowIndex]) / totalAutoRowsHeight; |
| + m_rowPos[row + 1] += changedPosBy; |
| } |
| // Remaining height added in the last row under rowSpan cell |
|
Julien - ping for review
2013/07/03 21:08:22
This comment is also a *what* comment, I would rat
a.suchit
2013/07/13 00:49:56
Done.
|
| - m_rowPos[rowIndex + rowSpan] += remainingHeight; |
| + m_rowPos[rowIndex + rowSpan] += extraRowSpanningHeight - changedPosBy; |
| + |
| + extraRowSpanningHeight -= changedPosBy; |
| +} |
| +// Whole extra height would be distribute in remaining rows based on their height ratios so that |
|
Julien - ping for review
2013/07/03 21:08:22
Again, that's a what comment. Here you could expla
a.suchit
2013/07/13 00:49:56
Done.
|
| +// all rows would get its own share from extra height. |
| +void RenderTableSection::distributeExtraRowSpanHeightToRemainingRows(RenderTableCell* cell, int totalRemainingRowsHeight, int& extraRowSpanningHeight, Vector<int>& rowsHeight) |
| +{ |
| + if (!extraRowSpanningHeight || !totalRemainingRowsHeight) |
| + return; |
| + |
| + unsigned rowSpan = cell->rowSpan(); |
| + unsigned rowIndex = cell->rowIndex(); |
| + int changedPosBy = 0; |
| + |
| + for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { |
| + if (!m_grid[row].logicalHeight.isPercent()) |
| + changedPosBy += (extraRowSpanningHeight * rowsHeight[row - rowIndex]) / totalRemainingRowsHeight; |
| + m_rowPos[row + 1] += changedPosBy; |
| + } |
| + // Remaining height added in the last row under rowSpan cell |
| + m_rowPos[rowIndex + rowSpan] += extraRowSpanningHeight - changedPosBy; |
| + |
| + extraRowSpanningHeight -= changedPosBy; |
| +} |
| + |
| +// 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) |
| +{ |
| + ASSERT(rowSpanCells.size()); |
| + |
| + // FIXME: For now, we handle the first rowspan cell in the table but this is wrong. |
| + RenderTableCell* cell = rowSpanCells[0]; |
| + |
| + unsigned rowSpan = cell->rowSpan(); |
| + |
| + int expectedTotalRowsHeight = 0; |
| + Vector<int> rowsHeight(rowSpan); |
| + int totalRowsHeight = 0; |
| + |
| + getRowsHeightInRowSpan(cell, expectedTotalRowsHeight, totalRowsHeight, rowsHeight); |
| + |
| + if (!totalRowsHeight || expectedTotalRowsHeight <= totalRowsHeight) |
| + return; |
| + |
| + unsigned rowIndex = cell->rowIndex(); |
| + int totalPercent = 0; |
| + int totalAutoRowsHeight = 0; |
| + int totalRemainingRowsHeight = totalRowsHeight; |
| + |
| + // Calculate total percentage, total auto rows height and total rows height except percent rows. |
| + for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { |
| + if (m_grid[row].logicalHeight.isPercent()) { |
| + totalPercent += m_grid[row].logicalHeight.percent(); |
| + totalRemainingRowsHeight -= rowsHeight[row - rowIndex]; |
| + } else if (m_grid[row].logicalHeight.isAuto()) { |
| + totalAutoRowsHeight += rowsHeight[row - rowIndex]; |
| + } |
| + } |
| + |
| + int initialPos = m_rowPos[rowIndex + rowSpan]; |
| + int extraRowSpanningHeight = expectedTotalRowsHeight - totalRowsHeight; |
| + |
| + distributeExtraRowSpanHeightToPrecentRows(cell, totalPercent, extraRowSpanningHeight, rowsHeight); |
| + distributeExtraRowSpanHeightToAutoRows(cell, totalAutoRowsHeight, extraRowSpanningHeight, rowsHeight); |
| + distributeExtraRowSpanHeightToRemainingRows(cell, totalRemainingRowsHeight, extraRowSpanningHeight, rowsHeight); |
| + |
| + ASSERT(!extraRowSpanningHeight); |
| // Getting total changed height in the table |
| - unsigned changedHeight = changedHeight = m_rowPos[rowIndex + rowSpan] - initialPos; |
| + unsigned changedHeight = m_rowPos[rowIndex + rowSpan] - initialPos; |
| if (changedHeight) { |
| unsigned totalRows = m_grid.size(); |