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

Unified Diff: Source/core/rendering/RenderTableSection.cpp

Issue 596823002: Tables with specific merge cell configuration render with extra height to tr elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Review comments addressed Created 6 years, 2 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
Index: Source/core/rendering/RenderTableSection.cpp
diff --git a/Source/core/rendering/RenderTableSection.cpp b/Source/core/rendering/RenderTableSection.cpp
index 9798ab87a229cc917135d91d964a4b6988882107..410888d0ac4965b7b98ed406c2f3fba154f17b6c 100644
--- a/Source/core/rendering/RenderTableSection.cpp
+++ b/Source/core/rendering/RenderTableSection.cpp
@@ -485,57 +485,65 @@ static bool compareRowSpanCellsInHeightDistributionOrder(const RenderTableCell*
return false;
}
-bool RenderTableSection::isHeightNeededForRowHavingOnlySpanningCells(unsigned row)
+unsigned RenderTableSection::calcRowHeightHavingOnlySpanningCells(unsigned row, int& accumulatedPositionIncrease, unsigned effectedRowByExtraHeight, unsigned& extraHeightToPropagate, Vector<int>& rowsCountWithOnlySpanningCells)
dsinclair 2014/10/15 21:37:41 s/rowsCountWithOnlySpanningCells/rowCountWithOnlyS
dsinclair 2014/10/15 21:37:42 How does accumulatedPositionIncrease relate to ext
dsinclair 2014/10/15 21:37:42 What does effectedRowByExtraHeight mean? Does it m
suchit.agrawal 2014/10/25 04:28:59 There is no relation between these 2. extraHeight
dsinclair 2014/11/05 17:03:20 So, if I'm understanding correctly, accumulatedPos
a.suchit 2014/12/03 13:09:13 right.
{
+ 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()) {
dsinclair 2014/10/15 21:37:41 if (!rowSpanCell.cells.size()) continue;
a.suchit 2014/12/03 13:09:13 Done.
RenderTableCell* cell = rowSpanCell.cells[0];
- const unsigned rowIndex = cell->rowIndex();
- const unsigned rowSpan = cell->rowSpan();
- int totalRowSpanCellHeight = 0;
- for (unsigned row = 0; row < rowSpan; row++) {
- unsigned actualRow = row + rowIndex;
- totalRowSpanCellHeight += m_rowPos[actualRow + 1] - m_rowPos[actualRow];
- }
- totalRowSpanCellHeight -= borderSpacingForRow(rowIndex + rowSpan - 1);
+ if (cell->rowSpan() > 1) {
dsinclair 2014/10/15 21:37:42 if (cell.rowSpan() <= 1) continue;
a.suchit 2014/12/03 13:09:13 Done.
+ const unsigned rowIndex = cell->rowIndex();
+ const unsigned rowSpan = cell->rowSpan();
dsinclair 2014/10/15 21:37:42 Can we rename these to cellRowIndex and cellRowSpa
a.suchit 2014/12/03 13:09:13 Done.
+
+ // As we are moving from top to bottom for calculating rows height of row with only spanning cells
+ // and all previous rows are already processed so we need to find the number of rows with only
dsinclair 2014/10/15 21:37:41 This comment is difficult to process, does the bel
a.suchit 2014/12/03 13:09:13 Done.
+ // spanning cells presents from current row to end of the spanning cell.
+ unsigned startRow = max(rowIndex, row);
+ unsigned endRow = rowIndex + rowSpan;
dsinclair 2014/10/15 21:37:42 Does this mean the endRow of our current cell, or
suchit.agrawal 2014/10/25 04:28:59 we can see it in 2 ways, 1. It is the row that com
+ unsigned spanningCellsRowsCountHavingZeroHeight = 0;
+
+ if (startRow) {
+ spanningCellsRowsCountHavingZeroHeight = rowsCountWithOnlySpanningCells[endRow - 1] - rowsCountWithOnlySpanningCells[startRow - 1];
dsinclair 2014/10/15 21:37:42 Why is this startRow - 1 and not startRow?
suchit.agrawal 2014/10/25 04:28:59 000112223334 ^ ^ 4-3=1. Means 1 row with
+ } else {
+ spanningCellsRowsCountHavingZeroHeight = (rowsCountWithOnlySpanningCells[endRow - 1] - rowsCountWithOnlySpanningCells[startRow]) + rowsCountWithOnlySpanningCells[0];
dsinclair 2014/10/15 21:37:41 If I'm reading this correctly we're doing: spanni
suchit.agrawal 2014/10/25 04:28:59 yes, we can remove subtraction and addition.
a.suchit 2014/12/03 13:09:13 Done.
+ }
- if (totalRowSpanCellHeight < cell->logicalHeightForRowSizing())
- return true;
- }
- }
+ int totalRowspanCellHeight = m_rowPos[endRow] - m_rowPos[rowIndex];
dsinclair 2014/10/15 21:37:41 It's very confusing that we jump back and forth be
suchit.agrawal 2014/10/25 04:28:59 I will change |startRow| to |startRowforSpanningCe
a.suchit 2014/12/03 13:09:13 Done.
- return false;
-}
+ totalRowspanCellHeight -= borderSpacingForRow(endRow - 1);
-unsigned RenderTableSection::calcRowHeightHavingOnlySpanningCells(unsigned row)
-{
- ASSERT(rowHasOnlySpanningCells(row));
+ totalRowspanCellHeight += accumulatedPositionIncrease;
+ if (effectedRowByExtraHeight >= rowIndex && effectedRowByExtraHeight < endRow)
+ totalRowspanCellHeight += extraHeightToPropagate;
- unsigned totalCols = m_grid[row].row.size();
+ if (totalRowspanCellHeight < cell->logicalHeightForRowSizing()) {
+ unsigned extraHeightRequired = rowSpanCell.cells[0]->logicalHeightForRowSizing() - totalRowspanCellHeight;
+ int remainder = extraHeightRequired % spanningCellsRowsCountHavingZeroHeight;
- if (!totalCols)
- return 0;
+ if (remainder)
+ extraHeightRequired += spanningCellsRowsCountHavingZeroHeight - remainder;
- unsigned rowHeight = 0;
-
- 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());
+ rowHeight = std::max(rowHeight, extraHeightRequired / spanningCellsRowsCountHavingZeroHeight);
dsinclair 2014/10/15 21:37:41 Wont' this fail to set rowHeight in the case where
dsinclair 2014/10/15 21:37:41 Can we ever have a case where spanningCellsRowsCou
suchit.agrawal 2014/10/25 04:28:59 rowHeight would be less than logicalHeightForRowSi
suchit.agrawal 2014/10/25 04:28:59 spanningCellsRowsCountHavingZeroHeight would not b
+ }
+ }
+ }
}
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());
@@ -547,8 +555,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);
dsinclair 2014/10/15 21:37:41 We set effectedRowByExtraHeight to rowIndex + rowS
suchit.agrawal 2014/10/25 04:28:59 In calcRowHeightHavingOnlySpanningCells(), We may
accumulatedPositionIncrease += spanningRowsHeight.rowHeight[row];
}
m_rowPos[actualRow + 1] += accumulatedPositionIncrease;
@@ -571,6 +579,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.
dsinclair 2014/10/15 21:37:42 This comment doesn't make sense to me, can you re-
suchit.agrawal 2014/10/25 04:28:59 We are collecting the information of the rows with
+ int count = 0;
+ for (unsigned row = 0; row < m_grid.size(); row++) {
+ if (rowHasOnlySpanningCells(row))
+ count++;
+ rowsCountWithOnlySpanningCells.append(count);
dsinclair 2014/10/15 21:37:41 I'm not sure I understand what this is storing. We
suchit.agrawal 2014/10/25 04:28:59 yes, we are doing same here.
+ }
+
for (unsigned i = 0; i < rowSpanCells.size(); i++) {
RenderTableCell* cell = rowSpanCells[i];
@@ -608,7 +626,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
« Source/core/rendering/RenderTableSection.h ('K') | « Source/core/rendering/RenderTableSection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698