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

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 4 years, 11 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 a8f3d7752261439945f7837105e2a34c4ed9fcd0..b7528f52b286d9984606c40791a161706a60c77f 100644
--- a/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
@@ -330,14 +330,14 @@ 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, 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
@@ -347,9 +347,7 @@ 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) - rowsHeight[row - rowIndex];
a.suchit2 2016/01/19 13:02:16 Do we need to use LayoutUnit here after this chang
mstensho (USE GERRIT) 2016/01/20 13:00:59 OK, I get it now. I had a hard time following the
toAdd = std::max(std::min(toAdd, extraRowSpanningHeight), 0);
accumulatedPositionIncrease += toAdd;

Powered by Google App Engine
This is Rietveld 408576698