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

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

Issue 821203003: Handling of percent less than 1 while extra height distribution in spanning rows. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 12 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
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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 const unsigned rowIndex = cell->rowIndex(); 325 const unsigned rowIndex = cell->rowIndex();
326 int percent = std::min(totalPercent, 100); 326 int percent = std::min(totalPercent, 100);
327 const int tableHeight = m_rowPos[m_grid.size()] + extraRowSpanningHeight; 327 const int tableHeight = m_rowPos[m_grid.size()] + extraRowSpanningHeight;
328 328
329 // Our algorithm matches Firefox. Extra spanning height would be distributed Only in first percent height rows 329 // Our algorithm matches Firefox. Extra spanning height would be distributed Only in first percent height rows
330 // those total percent is 100. Other percent rows would be uneffected even e xtra spanning height is remain. 330 // those total percent is 100. Other percent rows would be uneffected even e xtra spanning height is remain.
331 int accumulatedPositionIncrease = 0; 331 int accumulatedPositionIncrease = 0;
332 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { 332 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) {
333 if (percent > 0 && extraRowSpanningHeight > 0) { 333 if (percent > 0 && extraRowSpanningHeight > 0) {
334 if (m_grid[row].logicalHeight.isPercent()) { 334 if (m_grid[row].logicalHeight.isPercent()) {
335 int toAdd = (tableHeight * m_grid[row].logicalHeight.percent() / 100) - rowsHeight[row - rowIndex]; 335 int toAdd = (tableHeight * std::ceil(m_grid[row].logicalHeight.p ercent()) / 100) - rowsHeight[row - rowIndex];
Julien - ping for review 2015/01/02 10:13:37 It's not a good change. 0.5% is not 1% but after t
a.suchit 2015/01/07 11:17:09 Yes you are right but should we start this change
Julien - ping for review 2015/01/07 13:30:10 As a rule floats should be used for local computat
336 // FIXME: Note that this is wrong if we have a percentage above 100% and may make us grow 336 // FIXME: Note that this is wrong if we have a percentage above 100% and may make us grow
337 // above the available space. 337 // above the available space.
338 338
339 toAdd = std::min(toAdd, extraRowSpanningHeight); 339 toAdd = std::min(toAdd, extraRowSpanningHeight);
340 accumulatedPositionIncrease += toAdd; 340 accumulatedPositionIncrease += toAdd;
341 extraRowSpanningHeight -= toAdd; 341 extraRowSpanningHeight -= toAdd;
342 percent -= m_grid[row].logicalHeight.percent(); 342 percent -= m_grid[row].logicalHeight.percent();
343 } 343 }
344 } 344 }
345 m_rowPos[row + 1] += accumulatedPositionIncrease; 345 m_rowPos[row + 1] += accumulatedPositionIncrease;
(...skipping 21 matching lines...) Expand all
367 if (!extraRowSpanningHeight || !totalPercent) 367 if (!extraRowSpanningHeight || !totalPercent)
368 return; 368 return;
369 369
370 const unsigned rowSpan = cell->rowSpan(); 370 const unsigned rowSpan = cell->rowSpan();
371 const unsigned rowIndex = cell->rowIndex(); 371 const unsigned rowIndex = cell->rowIndex();
372 int remainder = 0; 372 int remainder = 0;
373 373
374 int accumulatedPositionIncrease = 0; 374 int accumulatedPositionIncrease = 0;
375 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { 375 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) {
376 if (m_grid[row].logicalHeight.isPercent()) { 376 if (m_grid[row].logicalHeight.isPercent()) {
377 updatePositionIncreasedWithRowHeight(extraRowSpanningHeight, m_grid[ row].logicalHeight.percent(), totalPercent, accumulatedPositionIncrease, remaind er); 377 updatePositionIncreasedWithRowHeight(extraRowSpanningHeight, std::ce il(m_grid[row].logicalHeight.percent()), totalPercent, accumulatedPositionIncrea se, remainder);
378 378
379 // While whole extra spanning height is distributing in percent span ning rows, rational parts remains 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 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. 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. 382 // Note that this algorithm is biased towards adding more space towa rds the lower rows.
383 if (remainder >= totalPercent) { 383 if (remainder >= totalPercent) {
384 remainder -= totalPercent; 384 remainder -= totalPercent;
385 accumulatedPositionIncrease++; 385 accumulatedPositionIncrease++;
386 } 386 }
387 } 387 }
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 int totalPercent = 0; 633 int totalPercent = 0;
634 int totalAutoRowsHeight = 0; 634 int totalAutoRowsHeight = 0;
635 int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight; 635 int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight;
636 636
637 // FIXME: Inner spanning cell height should not change if it have fixed height when it's parent spanning cell 637 // FIXME: Inner spanning cell height should not change if it have fixed height when it's parent spanning cell
638 // is distributing it's extra height in rows. 638 // is distributing it's extra height in rows.
639 639
640 // Calculate total percentage, total auto rows height and total rows hei ght except percent rows. 640 // Calculate total percentage, total auto rows height and total rows hei ght except percent rows.
641 for (unsigned row = rowIndex; row < spanningCellEndIndex; row++) { 641 for (unsigned row = rowIndex; row < spanningCellEndIndex; row++) {
642 if (m_grid[row].logicalHeight.isPercent()) { 642 if (m_grid[row].logicalHeight.isPercent()) {
643 totalPercent += m_grid[row].logicalHeight.percent(); 643 totalPercent += std::ceil(m_grid[row].logicalHeight.percent());
644 totalRemainingRowsHeight -= spanningRowsHeight.rowHeight[row - r owIndex]; 644 totalRemainingRowsHeight -= spanningRowsHeight.rowHeight[row - r owIndex];
645 } else if (m_grid[row].logicalHeight.isAuto()) { 645 } else if (m_grid[row].logicalHeight.isAuto()) {
646 totalAutoRowsHeight += spanningRowsHeight.rowHeight[row - rowInd ex]; 646 totalAutoRowsHeight += spanningRowsHeight.rowHeight[row - rowInd ex];
647 } 647 }
648 } 648 }
649 649
650 int extraRowSpanningHeight = spanningRowsHeight.spanningCellHeightIgnori ngBorderSpacing - spanningRowsHeight.totalRowsHeight; 650 int extraRowSpanningHeight = spanningRowsHeight.spanningCellHeightIgnori ngBorderSpacing - spanningRowsHeight.totalRowsHeight;
651 651
652 if (totalPercent < 100 && !totalAutoRowsHeight && !totalRemainingRowsHei ght) { 652 if (totalPercent < 100 && !totalAutoRowsHeight && !totalRemainingRowsHei ght) {
653 // Distributing whole extra rowspanning height in percent row when o nly non-percent rows height is 0. 653 // Distributing whole extra rowspanning height in percent row when o nly non-percent rows height is 0.
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 // FIXME: The table's direction should determine our row's direction, not th e section's (see bug 96691). 1615 // FIXME: The table's direction should determine our row's direction, not th e section's (see bug 96691).
1616 if (!style()->isLeftToRightDirection()) 1616 if (!style()->isLeftToRightDirection())
1617 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); 1617 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing);
1618 else 1618 else
1619 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); 1619 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing);
1620 1620
1621 cell->setLogicalLocation(cellLocation); 1621 cell->setLogicalLocation(cellLocation);
1622 } 1622 }
1623 1623
1624 } // namespace blink 1624 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698