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

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

Issue 131103017: ASSERTION FAILED: !remainder in WebCore::RenderTableSection::distributeExtraRowSpanHeightToAutoRows (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added a test case and fixed review comments Created 6 years, 9 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 d0e9ba961b9e24556333e02eb4e43e5edbe99931..913692d3bdfa7d914e8e87ddc34c628daa91df68 100644
--- a/Source/core/rendering/RenderTableSection.cpp
+++ b/Source/core/rendering/RenderTableSection.cpp
@@ -328,6 +328,18 @@ void RenderTableSection::distributeExtraRowSpanHeightToPercentRows(RenderTableCe
}
}
+// Some time multiplication of below 2 values is overflowing from integer. So
Julien - ping for review 2014/03/21 04:18:05 In correct English: Sometimes the multiplication
a.suchit 2014/03/24 10:53:59 Done.
+// type of variable in computation are taken as 'long long' in place of int.
Julien - ping for review 2014/03/21 04:18:05 So we convert the parameters to 'long long' instea
a.suchit 2014/03/24 10:53:59 Done.
+// In this computation, only 2 integer variables are multiplied which would not
Julien - ping for review 2014/03/21 04:18:05 This sentence really doesn't add much IMO.
+// overflow long long.
+static void updatePositionIncreasedWithRowHeight(long long extraHeight, long long rowHeight, long long totalHeight, int& accumulatedPositionIncrease, int& remainder)
+{
+ COMPILE_ASSERT(sizeof(long long int) > sizeof(int), int_should_be_less_than_longlong);
+
+ accumulatedPositionIncrease += (extraHeight * rowHeight) / totalHeight;
+ remainder += (extraHeight * rowHeight) % totalHeight;
+}
+
void RenderTableSection::distributeExtraRowSpanHeightToAutoRows(RenderTableCell* cell, int totalAutoRowsHeight, int& extraRowSpanningHeight, Vector<int>& rowsHeight)
{
if (!extraRowSpanningHeight || !totalAutoRowsHeight)
@@ -342,8 +354,7 @@ void RenderTableSection::distributeExtraRowSpanHeightToAutoRows(RenderTableCell*
// So extra height distributed in auto spanning rows based on their weight in spanning cell.
for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) {
if (m_grid[row].logicalHeight.isAuto()) {
- accumulatedPositionIncrease += (extraRowSpanningHeight * rowsHeight[row - rowIndex]) / totalAutoRowsHeight;
- remainder += (extraRowSpanningHeight * rowsHeight[row - rowIndex]) % totalAutoRowsHeight;
+ updatePositionIncreasedWithRowHeight(extraRowSpanningHeight, rowsHeight[row - rowIndex], totalAutoRowsHeight, accumulatedPositionIncrease, remainder);
// While whole extra spanning height is distributing in auto spanning rows, rational parts remains
// in every integer division. So accumulating all remainder part in integer division and when total remainder
@@ -376,8 +387,7 @@ void RenderTableSection::distributeExtraRowSpanHeightToRemainingRows(RenderTable
// So extra height distribution in remaining spanning rows based on their weight in spanning cell.
for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) {
if (!m_grid[row].logicalHeight.isPercent()) {
- accumulatedPositionIncrease += (extraRowSpanningHeight * rowsHeight[row - rowIndex]) / totalRemainingRowsHeight;
- remainder += (extraRowSpanningHeight * rowsHeight[row - rowIndex]) % totalRemainingRowsHeight;
+ updatePositionIncreasedWithRowHeight(extraRowSpanningHeight, rowsHeight[row - rowIndex], totalRemainingRowsHeight, accumulatedPositionIncrease, remainder);
// While whole extra spanning height is distributing in remaining spanning rows, rational parts remains
// in every integer division. So accumulating all remainder part in integer division and when total remainder

Powered by Google App Engine
This is Rietveld 408576698