Index: Source/core/layout/LayoutTableSection.cpp |
diff --git a/Source/core/layout/LayoutTableSection.cpp b/Source/core/layout/LayoutTableSection.cpp |
index 29e2a0c609103400515219cc23d2224ab18a3e07..005e41c88d38114a6e8e98b9ad7e54cff80dc80b 100644 |
--- a/Source/core/layout/LayoutTableSection.cpp |
+++ b/Source/core/layout/LayoutTableSection.cpp |
@@ -293,14 +293,15 @@ void LayoutTableSection::populateSpanningRowsHeightFromCell(LayoutTableCell* cel |
spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing += borderSpacingForRow(rowIndex + rowSpan - 1); |
} |
-void LayoutTableSection::distributeExtraRowSpanHeightToPercentRows(LayoutTableCell* cell, int totalPercent, int& extraRowSpanningHeight, Vector<int>& rowsHeight) |
+void LayoutTableSection::distributeExtraRowSpanHeightToPercentRows(LayoutTableCell* cell, LayoutUnit totalPercent, int& extraRowSpanningHeight, Vector<int>& rowsHeight) |
{ |
if (!extraRowSpanningHeight || !totalPercent) |
return; |
const unsigned rowSpan = cell->rowSpan(); |
const unsigned rowIndex = cell->rowIndex(); |
- int percent = std::min(totalPercent, 100); |
+ LayoutUnit percent = 100; |
+ percent = std::min(totalPercent, percent); |
const int tableHeight = m_rowPos[m_grid.size()] + extraRowSpanningHeight; |
// Our algorithm matches Firefox. Extra spanning height would be distributed Only in first percent height rows |
@@ -323,15 +324,18 @@ void LayoutTableSection::distributeExtraRowSpanHeightToPercentRows(LayoutTableCe |
} |
} |
-// Sometimes the multiplication of the 2 values below will overflow an integer. |
-// So we convert the parameters to 'long long' instead of 'int' to avoid the |
-// problem in this function. |
-static void updatePositionIncreasedWithRowHeight(long long extraHeight, long long rowHeight, long long totalHeight, int& accumulatedPositionIncrease, int& remainder) |
+static void updatePositionIncreasedWithRowHeight(int extraHeight, LayoutUnit rowHeight, LayoutUnit totalHeight, int& accumulatedPositionIncrease, int& remainder) |
{ |
static_assert(sizeof(long long int) > sizeof(int), "int should be smaller than long long"); |
- accumulatedPositionIncrease += (extraHeight * rowHeight) / totalHeight; |
- remainder += (extraHeight * rowHeight) % totalHeight; |
+ // Multiplication of the 2 values below will overflow in LayoutUnit. |
+ // So we converted to 'long long' instead of 'int' to avoid the problem in this function. |
+ // Upto 2 digits of rational part is considered for calculation. |
Julien - ping for review
2015/03/26 17:05:15
That's a lot of computation, most of which makes l
|
+ long long rHeight = static_cast<int>(rowHeight * 100); |
+ long long tHeight = static_cast<int>(totalHeight * 100); |
+ |
+ accumulatedPositionIncrease += (extraHeight * rHeight) / tHeight; |
+ remainder += ((extraHeight * rHeight) % tHeight) / 100; |
} |
// This is mainly used to distribute whole extra rowspanning height in percent rows when all spanning rows are |
@@ -339,7 +343,7 @@ static void updatePositionIncreasedWithRowHeight(long long extraHeight, long lon |
// Distributing whole extra rowspanning height in percent rows based on the ratios of percent because this method works |
// same as percent distribution when only percent rows are present and percent is 100. Also works perfectly fine when |
// percent is not equal to 100. |
-void LayoutTableSection::distributeWholeExtraRowSpanHeightToPercentRows(LayoutTableCell* cell, int totalPercent, int& extraRowSpanningHeight, Vector<int>& rowsHeight) |
+void LayoutTableSection::distributeWholeExtraRowSpanHeightToPercentRows(LayoutTableCell* cell, LayoutUnit totalPercent, int& extraRowSpanningHeight, Vector<int>& rowsHeight) |
{ |
if (!extraRowSpanningHeight || !totalPercent) |
return; |
@@ -358,7 +362,7 @@ void LayoutTableSection::distributeWholeExtraRowSpanHeightToPercentRows(LayoutTa |
// is equvalent to divisor then 1 unit increased in row position. |
// Note that this algorithm is biased towards adding more space towards the lower rows. |
if (remainder >= totalPercent) { |
- remainder -= totalPercent; |
+ remainder = remainder - totalPercent; |
accumulatedPositionIncrease++; |
} |
} |
@@ -619,7 +623,7 @@ void LayoutTableSection::distributeRowSpanHeightToRows(SpanningLayoutTableCells& |
} |
// Below we are handling only row(s) who have at least one visible cell without rowspan value. |
- int totalPercent = 0; |
+ LayoutUnit totalPercent = 0; |
int totalAutoRowsHeight = 0; |
int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight; |