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

Side by Side Diff: Source/core/rendering/RenderTableSection.cpp

Issue 398013005: ASSERTION FAILED: !extraRowSpanningHeight in WebCore::RenderTableSection::distributeRowSpanHeightTo… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 4 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 | « Source/core/rendering/RenderTableSection.h ('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, 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 // So we convert the parameters to 'long long' instead of 'int' to avoid the 350 // So we convert the parameters to 'long long' instead of 'int' to avoid the
351 // problem in this function. 351 // problem in this function.
352 static void updatePositionIncreasedWithRowHeight(long long extraHeight, long lon g rowHeight, long long totalHeight, int& accumulatedPositionIncrease, int& remai nder) 352 static void updatePositionIncreasedWithRowHeight(long long extraHeight, long lon g rowHeight, long long totalHeight, int& accumulatedPositionIncrease, int& remai nder)
353 { 353 {
354 COMPILE_ASSERT(sizeof(long long int) > sizeof(int), int_should_be_less_than_ longlong); 354 COMPILE_ASSERT(sizeof(long long int) > sizeof(int), int_should_be_less_than_ longlong);
355 355
356 accumulatedPositionIncrease += (extraHeight * rowHeight) / totalHeight; 356 accumulatedPositionIncrease += (extraHeight * rowHeight) / totalHeight;
357 remainder += (extraHeight * rowHeight) % totalHeight; 357 remainder += (extraHeight * rowHeight) % totalHeight;
358 } 358 }
359 359
360 // This is mainly used to distribute whole extra rowspanning height in percent r ows when all spanning rows are
361 // percent rows.
362 // Distributing whole extra rowspanning height in percent rows based on the rati os of percent because this method works
363 // same as percent distribution when only percent rows are present and percent i s 100. Also works perfectly fine when
364 // percent is not equal to 100.
365 void RenderTableSection::distributeWholeExtraRowSpanHeightToPercentRows(RenderTa bleCell* cell, int totalPercent, int& extraRowSpanningHeight, Vector<int>& rowsH eight)
366 {
367 if (!extraRowSpanningHeight || !totalPercent)
368 return;
369
370 const unsigned rowSpan = cell->rowSpan();
371 const unsigned rowIndex = cell->rowIndex();
372 int remainder = 0;
373
374 int accumulatedPositionIncrease = 0;
375 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) {
376 if (m_grid[row].logicalHeight.isPercent()) {
377 updatePositionIncreasedWithRowHeight(extraRowSpanningHeight, m_grid[ row].logicalHeight.percent(), totalPercent, accumulatedPositionIncrease, remaind er);
Julien - ping for review 2014/08/15 20:17:09 distributeExtraRowSpanHeightToPercentRows doesn't
suchit.agrawal 2014/08/17 07:16:22 Acknowledged.
378
379 // While whole extra spanning height is distributing in percent span ning rows, rational parts remains
380 // in every integer division. So accumulating all remainder part in integer division and when total remainder
381 // is equvalent to divisor then 1 unit increased in row position.
382 // Note that this algorithm is biased towards adding more space towa rds the lower rows.
383 if (remainder >= totalPercent) {
384 remainder -= totalPercent;
385 accumulatedPositionIncrease++;
386 }
387 }
388 m_rowPos[row + 1] += accumulatedPositionIncrease;
389 }
390
391 ASSERT(!remainder);
392
393 extraRowSpanningHeight -= accumulatedPositionIncrease;
394 }
395
360 void RenderTableSection::distributeExtraRowSpanHeightToAutoRows(RenderTableCell* cell, int totalAutoRowsHeight, int& extraRowSpanningHeight, Vector<int>& rowsHe ight) 396 void RenderTableSection::distributeExtraRowSpanHeightToAutoRows(RenderTableCell* cell, int totalAutoRowsHeight, int& extraRowSpanningHeight, Vector<int>& rowsHe ight)
361 { 397 {
362 if (!extraRowSpanningHeight || !totalAutoRowsHeight) 398 if (!extraRowSpanningHeight || !totalAutoRowsHeight)
363 return; 399 return;
364 400
365 const unsigned rowSpan = cell->rowSpan(); 401 const unsigned rowSpan = cell->rowSpan();
366 const unsigned rowIndex = cell->rowIndex(); 402 const unsigned rowIndex = cell->rowIndex();
367 int accumulatedPositionIncrease = 0; 403 int accumulatedPositionIncrease = 0;
368 int remainder = 0; 404 int remainder = 0;
369 405
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 if (m_grid[row].logicalHeight.isPercent()) { 642 if (m_grid[row].logicalHeight.isPercent()) {
607 totalPercent += m_grid[row].logicalHeight.percent(); 643 totalPercent += m_grid[row].logicalHeight.percent();
608 totalRemainingRowsHeight -= spanningRowsHeight.rowHeight[row - r owIndex]; 644 totalRemainingRowsHeight -= spanningRowsHeight.rowHeight[row - r owIndex];
609 } else if (m_grid[row].logicalHeight.isAuto()) { 645 } else if (m_grid[row].logicalHeight.isAuto()) {
610 totalAutoRowsHeight += spanningRowsHeight.rowHeight[row - rowInd ex]; 646 totalAutoRowsHeight += spanningRowsHeight.rowHeight[row - rowInd ex];
611 } 647 }
612 } 648 }
613 649
614 int extraRowSpanningHeight = spanningRowsHeight.spanningCellHeightIgnori ngBorderSpacing - spanningRowsHeight.totalRowsHeight; 650 int extraRowSpanningHeight = spanningRowsHeight.spanningCellHeightIgnori ngBorderSpacing - spanningRowsHeight.totalRowsHeight;
615 651
616 distributeExtraRowSpanHeightToPercentRows(cell, totalPercent, extraRowSp anningHeight, spanningRowsHeight.rowHeight); 652 if (totalPercent < 100 && !totalAutoRowsHeight && !totalRemainingRowsHei ght) {
617 distributeExtraRowSpanHeightToAutoRows(cell, totalAutoRowsHeight, extraR owSpanningHeight, spanningRowsHeight.rowHeight); 653 // Distributing whole extra rowspanning height in percent row when o nly non-percent rows height is 0.
618 distributeExtraRowSpanHeightToRemainingRows(cell, totalRemainingRowsHeig ht, extraRowSpanningHeight, spanningRowsHeight.rowHeight); 654 distributeWholeExtraRowSpanHeightToPercentRows(cell, totalPercent, e xtraRowSpanningHeight, spanningRowsHeight.rowHeight);
655 } else {
656 distributeExtraRowSpanHeightToPercentRows(cell, totalPercent, extraR owSpanningHeight, spanningRowsHeight.rowHeight);
657 distributeExtraRowSpanHeightToAutoRows(cell, totalAutoRowsHeight, ex traRowSpanningHeight, spanningRowsHeight.rowHeight);
658 distributeExtraRowSpanHeightToRemainingRows(cell, totalRemainingRows Height, extraRowSpanningHeight, spanningRowsHeight.rowHeight);
659 }
619 660
620 ASSERT(!extraRowSpanningHeight); 661 ASSERT(!extraRowSpanningHeight);
621 662
622 // Getting total changed height in the table 663 // Getting total changed height in the table
623 extraHeightToPropagate = m_rowPos[spanningCellEndIndex] - originalBefore Position; 664 extraHeightToPropagate = m_rowPos[spanningCellEndIndex] - originalBefore Position;
624 } 665 }
625 666
626 if (extraHeightToPropagate) { 667 if (extraHeightToPropagate) {
627 // Apply changed height by rowSpan cells to rows present at the end of t he table 668 // Apply changed height by rowSpan cells to rows present at the end of t he table
628 for (unsigned row = lastRowIndex + lastRowSpan + 1; row <= m_grid.size() ; row++) 669 for (unsigned row = lastRowIndex + lastRowSpan + 1; row <= m_grid.size() ; row++)
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 // FIXME: The table's direction should determine our row's direction, not th e section's (see bug 96691). 1769 // FIXME: The table's direction should determine our row's direction, not th e section's (see bug 96691).
1729 if (!style()->isLeftToRightDirection()) 1770 if (!style()->isLeftToRightDirection())
1730 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); 1771 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing);
1731 else 1772 else
1732 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); 1773 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing);
1733 1774
1734 cell->setLogicalLocation(cellLocation); 1775 cell->setLogicalLocation(cellLocation);
1735 } 1776 }
1736 1777
1737 } // namespace blink 1778 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderTableSection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698