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

Side by Side 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: 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 unified diff | Download patch
« no previous file with comments | « LayoutTests/fast/table/table-rowspan-crash-with-huge-pedding-value-expected.txt ('k') | 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 Apple Inc. All rights reserved. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights 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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 toAdd = min(toAdd, extraRowSpanningHeight); 321 toAdd = min(toAdd, extraRowSpanningHeight);
322 accumulatedPositionIncrease += toAdd; 322 accumulatedPositionIncrease += toAdd;
323 extraRowSpanningHeight -= toAdd; 323 extraRowSpanningHeight -= toAdd;
324 percent -= m_grid[row].logicalHeight.percent(); 324 percent -= m_grid[row].logicalHeight.percent();
325 } 325 }
326 } 326 }
327 m_rowPos[row + 1] += accumulatedPositionIncrease; 327 m_rowPos[row + 1] += accumulatedPositionIncrease;
328 } 328 }
329 } 329 }
330 330
331 // Sometimes the multiplication of the 2 values below will overflow an integer.
332 // So we convert the parameters to 'long long' instead of 'int' to avoid the
333 // problem in this function.
334 static void updatePositionIncreasedWithRowHeight(long long extraHeight, long lon g rowHeight, long long totalHeight, int& accumulatedPositionIncrease, int& remai nder)
335 {
336 COMPILE_ASSERT(sizeof(long long int) > sizeof(int), int_should_be_less_than_ longlong);
337
338 accumulatedPositionIncrease += (extraHeight * rowHeight) / totalHeight;
339 remainder += (extraHeight * rowHeight) % totalHeight;
340 }
341
331 void RenderTableSection::distributeExtraRowSpanHeightToAutoRows(RenderTableCell* cell, int totalAutoRowsHeight, int& extraRowSpanningHeight, Vector<int>& rowsHe ight) 342 void RenderTableSection::distributeExtraRowSpanHeightToAutoRows(RenderTableCell* cell, int totalAutoRowsHeight, int& extraRowSpanningHeight, Vector<int>& rowsHe ight)
332 { 343 {
333 if (!extraRowSpanningHeight || !totalAutoRowsHeight) 344 if (!extraRowSpanningHeight || !totalAutoRowsHeight)
334 return; 345 return;
335 346
336 const unsigned rowSpan = cell->rowSpan(); 347 const unsigned rowSpan = cell->rowSpan();
337 const unsigned rowIndex = cell->rowIndex(); 348 const unsigned rowIndex = cell->rowIndex();
338 int accumulatedPositionIncrease = 0; 349 int accumulatedPositionIncrease = 0;
339 int remainder = 0; 350 int remainder = 0;
340 351
341 // Aspect ratios of auto rows should not change otherwise table may look dif ferent than user expected. 352 // Aspect ratios of auto rows should not change otherwise table may look dif ferent than user expected.
342 // So extra height distributed in auto spanning rows based on their weight i n spanning cell. 353 // So extra height distributed in auto spanning rows based on their weight i n spanning cell.
343 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { 354 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) {
344 if (m_grid[row].logicalHeight.isAuto()) { 355 if (m_grid[row].logicalHeight.isAuto()) {
345 accumulatedPositionIncrease += (extraRowSpanningHeight * rowsHeight[ row - rowIndex]) / totalAutoRowsHeight; 356 updatePositionIncreasedWithRowHeight(extraRowSpanningHeight, rowsHei ght[row - rowIndex], totalAutoRowsHeight, accumulatedPositionIncrease, remainder );
346 remainder += (extraRowSpanningHeight * rowsHeight[row - rowIndex]) % totalAutoRowsHeight;
347 357
348 // While whole extra spanning height is distributing in auto spannin g rows, rational parts remains 358 // While whole extra spanning height is distributing in auto spannin g rows, rational parts remains
349 // in every integer division. So accumulating all remainder part in integer division and when total remainder 359 // in every integer division. So accumulating all remainder part in integer division and when total remainder
350 // is equvalent to divisor then 1 unit increased in row position. 360 // is equvalent to divisor then 1 unit increased in row position.
351 // Note that this algorithm is biased towards adding more space towa rds the lower rows. 361 // Note that this algorithm is biased towards adding more space towa rds the lower rows.
352 if (remainder >= totalAutoRowsHeight) { 362 if (remainder >= totalAutoRowsHeight) {
353 remainder -= totalAutoRowsHeight; 363 remainder -= totalAutoRowsHeight;
354 accumulatedPositionIncrease++; 364 accumulatedPositionIncrease++;
355 } 365 }
356 } 366 }
(...skipping 12 matching lines...) Expand all
369 379
370 const unsigned rowSpan = cell->rowSpan(); 380 const unsigned rowSpan = cell->rowSpan();
371 const unsigned rowIndex = cell->rowIndex(); 381 const unsigned rowIndex = cell->rowIndex();
372 int accumulatedPositionIncrease = 0; 382 int accumulatedPositionIncrease = 0;
373 int remainder = 0; 383 int remainder = 0;
374 384
375 // Aspect ratios of the rows should not change otherwise table may look diff erent than user expected. 385 // Aspect ratios of the rows should not change otherwise table may look diff erent than user expected.
376 // So extra height distribution in remaining spanning rows based on their we ight in spanning cell. 386 // So extra height distribution in remaining spanning rows based on their we ight in spanning cell.
377 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { 387 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) {
378 if (!m_grid[row].logicalHeight.isPercent()) { 388 if (!m_grid[row].logicalHeight.isPercent()) {
379 accumulatedPositionIncrease += (extraRowSpanningHeight * rowsHeight[ row - rowIndex]) / totalRemainingRowsHeight; 389 updatePositionIncreasedWithRowHeight(extraRowSpanningHeight, rowsHei ght[row - rowIndex], totalRemainingRowsHeight, accumulatedPositionIncrease, rema inder);
380 remainder += (extraRowSpanningHeight * rowsHeight[row - rowIndex]) % totalRemainingRowsHeight;
381 390
382 // While whole extra spanning height is distributing in remaining sp anning rows, rational parts remains 391 // While whole extra spanning height is distributing in remaining sp anning rows, rational parts remains
383 // in every integer division. So accumulating all remainder part in integer division and when total remainder 392 // in every integer division. So accumulating all remainder part in integer division and when total remainder
384 // is equvalent to divisor then 1 unit increased in row position. 393 // is equvalent to divisor then 1 unit increased in row position.
385 // Note that this algorithm is biased towards adding more space towa rds the lower rows. 394 // Note that this algorithm is biased towards adding more space towa rds the lower rows.
386 if (remainder >= totalRemainingRowsHeight) { 395 if (remainder >= totalRemainingRowsHeight) {
387 remainder -= totalRemainingRowsHeight; 396 remainder -= totalRemainingRowsHeight;
388 accumulatedPositionIncrease++; 397 accumulatedPositionIncrease++;
389 } 398 }
390 } 399 }
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1731 else 1740 else
1732 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); 1741 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing);
1733 1742
1734 cell->setLogicalLocation(cellLocation); 1743 cell->setLogicalLocation(cellLocation);
1735 1744
1736 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) 1745 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled())
1737 view()->addLayoutDelta(oldCellLocation - cell->location()); 1746 view()->addLayoutDelta(oldCellLocation - cell->location());
1738 } 1747 }
1739 1748
1740 } // namespace WebCore 1749 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/table/table-rowspan-crash-with-huge-pedding-value-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698