Index: Source/core/rendering/RenderTableSection.cpp |
diff --git a/Source/core/rendering/RenderTableSection.cpp b/Source/core/rendering/RenderTableSection.cpp |
index 765b35e238ac819d6edba8188fcf0df6bf4c88cc..d4d0c9324da6cd9f57449809348c85b6c9b29713 100644 |
--- a/Source/core/rendering/RenderTableSection.cpp |
+++ b/Source/core/rendering/RenderTableSection.cpp |
@@ -369,12 +369,65 @@ void RenderTableSection::distributeExtraRowSpanHeightToRemainingRows(RenderTable |
extraRowSpanningHeight -= accumulatedPositionIncrease; |
} |
+// Arrange row spanning cell in the oder in which we need to process first. |
Julien - ping for review
2013/07/29 16:52:55
This comment should be embedded into the method na
a.suchit
2013/07/30 08:42:20
Done.
|
+static inline void rearrangeRowSpanCells(RenderTableSection::SpanningRenderTableCells& rowSpanCells) |
+{ |
+ unsigned totalCells = rowSpanCells.size(); |
+ |
+ // 'rowSpanCelss' list is already sorted based on the cells rowIndex in ascending order |
Julien - ping for review
2013/07/29 16:52:55
typo: rowSpanCelss
a.suchit
2013/07/30 08:42:20
Done.
|
+ |
+ for (unsigned i = 0; i < totalCells; i++) { |
+ bool sortCompleted = true; |
+ |
+ for (unsigned j = totalCells - 1; j > i; j--) { |
Julien - ping for review
2013/07/29 16:52:55
As mentioned on IRC, reusing std::sort with a cust
a.suchit
2013/07/30 08:42:20
Done.
|
+ unsigned cellRowIndex = rowSpanCells[j]->rowIndex(); |
+ unsigned cellRowSpan = rowSpanCells[j]->rowSpan(); |
+ unsigned prevCellRowIndex = rowSpanCells[j - 1]->rowIndex(); |
+ unsigned prevCellRowSpan = rowSpanCells[j - 1]->rowSpan(); |
+ bool swap = false; |
+ |
+ if (cellRowIndex == prevCellRowIndex) { |
+ if (cellRowSpan == prevCellRowSpan) { |
+ // if 2 or more row spanning cells start and end at same rows then we need to process only |
+ // one row spanning cell which have highest height. So these types of cells are sorted in |
+ // descending order based on their heights. |
+ if (rowSpanCells[j]->logicalHeightForRowSizing() > rowSpanCells[j - 1]->logicalHeightForRowSizing()) |
+ swap = true; |
+ } else if (cellRowSpan < prevCellRowSpan) { |
+ // if 2 or more row spanning cells start at same row but end at diffrent rows then smaller |
+ // row spanning cell should get process first. So these types of cells are sorted in ascending |
+ // order based on their sizes. |
+ swap = true; |
+ } |
+ } else if (cellRowIndex > prevCellRowIndex) { |
+ // if the row spanning cell comes under the boundries of another row spanning cell then inner row |
+ // spanning cell should get process first. So these types of cells are sorted in ascending order |
+ // based on their sizes. |
+ if ((cellRowIndex + cellRowSpan) <= (prevCellRowIndex + prevCellRowSpan)) |
+ swap = true; |
+ } |
+ |
+ if (swap) { |
+ RenderTableCell* cell = rowSpanCells[j]; |
+ rowSpanCells[j] = rowSpanCells[j - 1]; |
+ rowSpanCells[j - 1] = cell; |
+ sortCompleted = false; |
+ } |
+ } |
+ |
+ if (sortCompleted) |
+ break; |
+ } |
+} |
+ |
// 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()); |
+ rearrangeRowSpanCells(rowSpanCells); |
+ |
unsigned extraHeightToPropagate = 0; |
unsigned lastRowIndex = 0; |
unsigned lastRowSpan = 0; |
@@ -384,14 +437,12 @@ void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& |
unsigned rowIndex = cell->rowIndex(); |
- // FIXME: For now, we are handling only rowspan cells those are not overlapping with other |
- // rowspan cells but this is wrong. |
- if (rowIndex < lastRowIndex + lastRowSpan) |
- continue; |
- |
unsigned rowSpan = cell->rowSpan(); |
int originalBeforePosition = m_rowPos[rowIndex + rowSpan]; |
+ if (rowIndex == lastRowIndex && rowSpan == lastRowSpan) |
+ continue; |
+ |
if (extraHeightToPropagate) { |
for (unsigned row = lastRowIndex + lastRowSpan + 1; row <= rowIndex + rowSpan; row++) |
m_rowPos[row] += extraHeightToPropagate; |