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

Unified Diff: Source/core/layout/LayoutTableSection.cpp

Issue 821203003: Handling of percent less than 1 while extra height distribution in spanning rows. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 8 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/layout/LayoutTableSection.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/LayoutTableSection.cpp
diff --git a/Source/core/layout/LayoutTableSection.cpp b/Source/core/layout/LayoutTableSection.cpp
index 2a56e6d45398cac51ff9a9bbb62ba032f846000b..1568c54304a5c5382a9453fcb2ea8791052b0413 100644
--- a/Source/core/layout/LayoutTableSection.cpp
+++ b/Source/core/layout/LayoutTableSection.cpp
@@ -324,15 +324,19 @@ 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, float rowHeight, float 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;
+ // Sometimes the multiplication of the 2 values below will overflow a float.
+ // So we convert them to 'long long' instead of 'float' to avoid the overflow
+ // and multiply with 100 for taking 2 decimal degits in calculation.
+ long long rHeight = rowHeight * 100;
+ long long tHeight = 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
@@ -340,7 +344,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, float totalPercent, int& extraRowSpanningHeight, Vector<int>& rowsHeight)
{
if (!extraRowSpanningHeight || !totalPercent)
return;
@@ -620,7 +624,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;
+ float totalPercent = 0;
int totalAutoRowsHeight = 0;
int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight;
« no previous file with comments | « Source/core/layout/LayoutTableSection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698