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

Side by Side 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: 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) 2 * Copyright (C) 1997 Martin Jones (mjones@kde.org)
3 * (C) 1997 Torben Weis (weis@kde.org) 3 * (C) 1997 Torben Weis (weis@kde.org)
4 * (C) 1998 Waldo Bastian (bastian@kde.org) 4 * (C) 1998 Waldo Bastian (bastian@kde.org)
5 * (C) 1999 Lars Knoll (knoll@kde.org) 5 * (C) 1999 Lars Knoll (knoll@kde.org)
6 * (C) 1999 Antti Koivisto (koivisto@kde.org) 6 * (C) 1999 Antti Koivisto (koivisto@kde.org)
7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2013 Apple Inc. All r ights reserved. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2013 Apple Inc. All r ights reserved.
8 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 { 307 {
308 if (!extraRowSpanningHeight || !totalPercent) 308 if (!extraRowSpanningHeight || !totalPercent)
309 return; 309 return;
310 310
311 const unsigned rowSpan = cell->rowSpan(); 311 const unsigned rowSpan = cell->rowSpan();
312 const unsigned rowIndex = cell->rowIndex(); 312 const unsigned rowIndex = cell->rowIndex();
313 int percent = std::min(totalPercent, 100); 313 int percent = std::min(totalPercent, 100);
314 const int tableHeight = m_rowPos[m_grid.size()] + extraRowSpanningHeight; 314 const int tableHeight = m_rowPos[m_grid.size()] + extraRowSpanningHeight;
315 315
316 // Our algorithm matches Firefox. Extra spanning height would be distributed Only in first percent height rows 316 // Our algorithm matches Firefox. Extra spanning height would be distributed Only in first percent height rows
317 // those total percent is 100. Other percent rows would be uneffected even e xtra spanning height is remain. 317 // those total percent is 100. Other percent rows would be uneffected even e xtra spanning height is remain.
mstensho (USE GERRIT) 2015/10/16 18:19:13 I have trouble with my overall understanding of th
a.suchit2 2015/10/19 10:01:04 line 320, 'percent > 0' have condition for stoppin
mstensho (USE GERRIT) 2015/10/19 18:17:47 Yeah, but what if the initial value of |percent| i
a.suchit2 2015/10/20 05:15:07 yes, I am fixing same scenario here. But I should
mstensho (USE GERRIT) 2015/10/20 08:12:37 I think you should divide by |totalPercent|, but I
318 int accumulatedPositionIncrease = 0; 318 int accumulatedPositionIncrease = 0;
319 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { 319 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) {
320 if (percent > 0 && extraRowSpanningHeight > 0) { 320 if (percent > 0 && extraRowSpanningHeight > 0) {
321 // TODO(alancutter): Make this work correctly for calc lengths. 321 // TODO(alancutter): Make this work correctly for calc lengths.
322 if (m_grid[row].logicalHeight.hasPercent()) { 322 if (m_grid[row].logicalHeight.hasPercent()) {
323 int toAdd = (tableHeight * m_grid[row].logicalHeight.percent() / 100) - rowsHeight[row - rowIndex]; 323 float maxPercent = 100.0;
mstensho (USE GERRIT) 2015/10/16 18:19:13 I see no need for |maxPercent|. Just put 100.0 in
a.suchit2 2015/10/19 10:01:04 100.0 can not be used directly inside std::min bec
mstensho (USE GERRIT) 2015/10/19 18:17:47 So float(100.0) should work, then.
a.suchit2 2015/10/20 05:15:07 ok I will do it but I am not sure that it is accep
324 int toAdd = (tableHeight *
325 std::min(m_grid[row].logicalHeight.percent(), maxPercent) / 100)
mstensho (USE GERRIT) 2015/10/16 18:19:13 Say, shouldn't you really divide by |totalPercent|
a.suchit2 2015/10/19 10:01:04 If we are using the |totalPercent| in place of 100
326 - rowsHeight[row - rowIndex];
324 // FIXME: Note that this is wrong if we have a percentage above 100% and may make us grow 327 // FIXME: Note that this is wrong if we have a percentage above 100% and may make us grow
mstensho (USE GERRIT) 2015/10/16 18:19:13 I guess this would no longer be the case, and that
a.suchit2 2015/10/19 10:01:04 Yes, we can remove it.
325 // above the available space. 328 // above the available space.
326 329
327 toAdd = std::max(std::min(toAdd, extraRowSpanningHeight), 0); 330 toAdd = std::max(std::min(toAdd, extraRowSpanningHeight), 0);
328 accumulatedPositionIncrease += toAdd; 331 accumulatedPositionIncrease += toAdd;
329 extraRowSpanningHeight -= toAdd; 332 extraRowSpanningHeight -= toAdd;
330 percent -= m_grid[row].logicalHeight.percent(); 333 percent -= m_grid[row].logicalHeight.percent();
331 } 334 }
332 } 335 }
333 m_rowPos[row + 1] += accumulatedPositionIncrease; 336 m_rowPos[row + 1] += accumulatedPositionIncrease;
334 } 337 }
(...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 // FIXME: The table's direction should determine our row's direction, not th e section's (see bug 96691). 1647 // FIXME: The table's direction should determine our row's direction, not th e section's (see bug 96691).
1645 if (!style()->isLeftToRightDirection()) 1648 if (!style()->isLeftToRightDirection())
1646 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); 1649 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing);
1647 else 1650 else
1648 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); 1651 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing);
1649 1652
1650 cell->setLogicalLocation(cellLocation); 1653 cell->setLogicalLocation(cellLocation);
1651 } 1654 }
1652 1655
1653 } // namespace blink 1656 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698