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

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

Issue 1405393002: Crashes when percent calculation of row's height goes very high. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments addressed Created 5 years, 2 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: third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp b/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
index afb1424af20b17dd535baaf7b8b72eb90a7b5c23..defb9b1615fb154cc41bfffd95ad8c1bbff6d81e 100644
--- a/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
@@ -303,14 +303,16 @@ 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, float totalPercent, int& extraRowSpanningHeight,
mstensho (USE GERRIT) 2015/11/02 10:46:42 Please put this back on one line.
a.suchit2 2016/01/12 06:46:35 Done.
+ Vector<int>& rowsHeight)
{
if (!extraRowSpanningHeight || !totalPercent)
return;
const unsigned rowSpan = cell->rowSpan();
const unsigned rowIndex = cell->rowIndex();
- int percent = std::min(totalPercent, 100);
+ float percent = std::min(totalPercent, 100.0f);
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
@@ -320,9 +322,9 @@ void LayoutTableSection::distributeExtraRowSpanHeightToPercentRows(LayoutTableCe
if (percent > 0 && extraRowSpanningHeight > 0) {
// TODO(alancutter): Make this work correctly for calc lengths.
if (m_grid[row].logicalHeight.hasPercent()) {
- int toAdd = (tableHeight * m_grid[row].logicalHeight.percent() / 100) - rowsHeight[row - rowIndex];
- // FIXME: Note that this is wrong if we have a percentage above 100% and may make us grow
- // above the available space.
+ int toAdd = (tableHeight *
+ std::min(m_grid[row].logicalHeight.percent(), percent) / 100)
mstensho (USE GERRIT) 2015/11/02 10:46:42 OK, so what you want to avoid here is integer over
a.suchit2 2016/01/12 06:46:35 I am avoiding high value of percent which is not a
mstensho (USE GERRIT) 2016/01/18 14:37:03 Because LayoutUnit cannot overflow, since it uses
a.suchit2 2016/01/19 13:02:16 Replied on latest patch set 5.
+ - rowsHeight[row - rowIndex];
toAdd = std::max(std::min(toAdd, extraRowSpanningHeight), 0);
accumulatedPositionIncrease += toAdd;

Powered by Google App Engine
This is Rietveld 408576698