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

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

Issue 18050007: Height of fixed height cell is not proper when cell's row is under row spanning cell. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 6 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
« no previous file with comments | « Source/core/rendering/RenderTableSection.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderTableSection.cpp
diff --git a/Source/core/rendering/RenderTableSection.cpp b/Source/core/rendering/RenderTableSection.cpp
index 3bcff2dbf6d5d9c45795c5cf47efbd7cf47e71d3..f3b81a57a2c4370c9c5ffef8445e8213203065b9 100644
--- a/Source/core/rendering/RenderTableSection.cpp
+++ b/Source/core/rendering/RenderTableSection.cpp
@@ -252,24 +252,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.
+int RenderTableSection::getRowsHeightInRowSpan(RenderTableCell* cell, int& expectedTotalRowsHeight, Vector<int>& rowsHeight)
Julien - ping for review 2013/07/02 02:16:18 This function starts to smell badly as you now hav
a.suchit 2013/07/03 12:59:57 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);
+ int totalRowsHeight = 0;
- // Getting height of rows in current rowSpan cell, getting total height of rows and adjusting rowSpan cell height with border spacing.
for (unsigned row = 0; row < rowSpan; row++) {
unsigned actualRow = row + rowIndex;
rowsHeight[row] = m_rowPos[actualRow + 1] - m_rowPos[actualRow] - borderSpacingForRow(actualRow);
@@ -278,22 +268,134 @@ void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells&
}
rowSpanCellHeight += borderSpacingForRow(rowIndex + rowSpan - 1);
- if (!totalRowsHeight || rowSpanCellHeight <= totalRowsHeight)
+ expectedTotalRowsHeight = rowSpanCellHeight;
+
+ return totalRowsHeight;
+}
+
+// If percent is 100 or more then whole extra height would be distribute in percent rows based on their percent ratios so that
+// all percent rows would get its own share from extra height based on their percentages.
+// Else total percent share would go to percent rows and remaining would be distributed in other rows.
Julien - ping for review 2013/07/02 02:16:18 I read this several times and failed to understand
+void RenderTableSection::distributeExtraRowSpanHeightToPrecentRows(RenderTableCell* cell, int totalPercent, int& extraRowSpanningHeight, Vector<int>& rowsHeight)
+{
+ if (!extraRowSpanningHeight || !totalPercent)
+ return;
+
+ unsigned rowSpan = cell->rowSpan();
+ unsigned rowIndex = cell->rowIndex();
+
+ if (100 <= totalPercent) {
Julien - ping for review 2013/07/02 02:16:18 I had a hard time understanding this check and bel
a.suchit 2013/07/03 12:59:57 At this point, total table height is not fixed so
Julien - ping for review 2013/07/03 21:08:22 I am still not totally convinced this is correct t
+ 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 = 0;
Julien - ping for review 2013/07/02 02:16:18 Again, it is WRONG to clear extraRowSpanningHeight
a.suchit 2013/07/03 12:59:57 Done.
+ } 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;
+ 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.
+void RenderTableSection::distributeExtraRowSpanHeightToAutoRows(RenderTableCell* cell, int totalAutoRowsHeight, int& extraRowSpanningHeight, Vector<int>& rowsHeight)
+{
+ if (!extraRowSpanningHeight || !totalAutoRowsHeight)
+ 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.isAuto())
+ changedPosBy += (extraRowSpanningHeight * rowsHeight[row - rowIndex]) / totalAutoRowsHeight;
+ m_rowPos[row + 1] += changedPosBy;
+ }
+ // Remaining height added in the last row under rowSpan cell
+ m_rowPos[rowIndex + rowSpan] += extraRowSpanningHeight - changedPosBy;
+
+ extraRowSpanningHeight = 0;
Julien - ping for review 2013/07/02 02:16:18 This is wrong to clear extraRowSpanningHeight unco
a.suchit 2013/07/03 12:59:57 Done.
+}
+// Whole extra height would be distribute in remaining rows based on their height ratios so that
+// all rows would get its own share from extra height.
+void RenderTableSection::distributeExtraRowSpanHeightToRemainingRows(RenderTableCell* cell, int totalRemainingRowsHeight, int& extraRowSpanningHeight, Vector<int>& rowsHeight)
Julien - ping for review 2013/07/02 02:16:18 Because of extraRowSpanningHeight = 0; above, this
a.suchit 2013/07/03 12:59:57 If rowspan cell does not contain auto rows then ex
a.suchit 2013/07/03 12:59:57 Done.
+{
+ if (!extraRowSpanningHeight || !totalRemainingRowsHeight)
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.isPercent())
+ changedPosBy += (extraRowSpanningHeight * rowsHeight[row - rowIndex]) / totalRemainingRowsHeight;
+ m_rowPos[row + 1] += changedPosBy;
Julien - ping for review 2013/07/02 02:16:18 The more I see these lines that basically mandates
a.suchit 2013/07/03 12:59:57 m_rowPos is already handled to store the absolute
Julien - ping for review 2013/07/03 21:08:22 That's an understatement! However this argument sh
}
// Remaining height added in the last row under rowSpan cell
- m_rowPos[rowIndex + rowSpan] += remainingHeight;
+ m_rowPos[rowIndex + rowSpan] += extraRowSpanningHeight - changedPosBy;
+
+ extraRowSpanningHeight = 0;
Julien - ping for review 2013/07/02 02:16:18 This is just gross. Nothing guarantees that change
a.suchit 2013/07/03 12:59:57 Done.
+}
+
+// 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 = getRowsHeightInRowSpan(cell, expectedTotalRowsHeight, 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();
« no previous file with comments | « Source/core/rendering/RenderTableSection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698