OLD | NEW |
---|---|
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 Loading... | |
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 // Some time multiplication of below 2 values is overflowing from integer. So | |
332 // type of variable in computation are taken as 'long long' in place of int. | |
333 // In this computation, only 2 integer variables are multiplied which would not | |
334 // overflow long long. | |
335 static int calcIncreasedRowHeight(long long extraHeight, long long rowHeight, lo ng long totalHeight, int& remainder) | |
Julien - ping for review
2014/03/10 18:36:39
Let's not abbreviate function names.
I don't real
a.suchit
2014/03/11 12:33:56
Done.
| |
336 { | |
337 remainder += (extraHeight * rowHeight) % totalHeight; | |
Julien - ping for review
2014/03/10 18:36:39
Per my comment, there should be some ASSERT about
a.suchit
2014/03/11 12:33:56
Done.
| |
338 return (extraHeight * rowHeight) / totalHeight; | |
339 } | |
340 | |
331 void RenderTableSection::distributeExtraRowSpanHeightToAutoRows(RenderTableCell* cell, int totalAutoRowsHeight, int& extraRowSpanningHeight, Vector<int>& rowsHe ight) | 341 void RenderTableSection::distributeExtraRowSpanHeightToAutoRows(RenderTableCell* cell, int totalAutoRowsHeight, int& extraRowSpanningHeight, Vector<int>& rowsHe ight) |
332 { | 342 { |
333 if (!extraRowSpanningHeight || !totalAutoRowsHeight) | 343 if (!extraRowSpanningHeight || !totalAutoRowsHeight) |
334 return; | 344 return; |
335 | 345 |
336 const unsigned rowSpan = cell->rowSpan(); | 346 const unsigned rowSpan = cell->rowSpan(); |
337 const unsigned rowIndex = cell->rowIndex(); | 347 const unsigned rowIndex = cell->rowIndex(); |
338 int accumulatedPositionIncrease = 0; | 348 int accumulatedPositionIncrease = 0; |
339 int remainder = 0; | 349 int remainder = 0; |
340 | 350 |
341 // Aspect ratios of auto rows should not change otherwise table may look dif ferent than user expected. | 351 // 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. | 352 // 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++) { | 353 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { |
344 if (m_grid[row].logicalHeight.isAuto()) { | 354 if (m_grid[row].logicalHeight.isAuto()) { |
345 accumulatedPositionIncrease += (extraRowSpanningHeight * rowsHeight[ row - rowIndex]) / totalAutoRowsHeight; | 355 accumulatedPositionIncrease += calcIncreasedRowHeight(extraRowSpanni ngHeight, rowsHeight[row - rowIndex], totalAutoRowsHeight, remainder); |
346 remainder += (extraRowSpanningHeight * rowsHeight[row - rowIndex]) % totalAutoRowsHeight; | |
347 | 356 |
348 // While whole extra spanning height is distributing in auto spannin g rows, rational parts remains | 357 // 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 | 358 // 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. | 359 // 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. | 360 // Note that this algorithm is biased towards adding more space towa rds the lower rows. |
352 if (remainder >= totalAutoRowsHeight) { | 361 if (remainder >= totalAutoRowsHeight) { |
353 remainder -= totalAutoRowsHeight; | 362 remainder -= totalAutoRowsHeight; |
354 accumulatedPositionIncrease++; | 363 accumulatedPositionIncrease++; |
355 } | 364 } |
356 } | 365 } |
(...skipping 12 matching lines...) Expand all Loading... | |
369 | 378 |
370 const unsigned rowSpan = cell->rowSpan(); | 379 const unsigned rowSpan = cell->rowSpan(); |
371 const unsigned rowIndex = cell->rowIndex(); | 380 const unsigned rowIndex = cell->rowIndex(); |
372 int accumulatedPositionIncrease = 0; | 381 int accumulatedPositionIncrease = 0; |
373 int remainder = 0; | 382 int remainder = 0; |
374 | 383 |
375 // Aspect ratios of the rows should not change otherwise table may look diff erent than user expected. | 384 // 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. | 385 // 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++) { | 386 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { |
378 if (!m_grid[row].logicalHeight.isPercent()) { | 387 if (!m_grid[row].logicalHeight.isPercent()) { |
379 accumulatedPositionIncrease += (extraRowSpanningHeight * rowsHeight[ row - rowIndex]) / totalRemainingRowsHeight; | 388 accumulatedPositionIncrease += calcIncreasedRowHeight(extraRowSpanni ngHeight, rowsHeight[row - rowIndex], totalRemainingRowsHeight, remainder); |
380 remainder += (extraRowSpanningHeight * rowsHeight[row - rowIndex]) % totalRemainingRowsHeight; | |
381 | 389 |
382 // While whole extra spanning height is distributing in remaining sp anning rows, rational parts remains | 390 // 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 | 391 // 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. | 392 // 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. | 393 // Note that this algorithm is biased towards adding more space towa rds the lower rows. |
386 if (remainder >= totalRemainingRowsHeight) { | 394 if (remainder >= totalRemainingRowsHeight) { |
387 remainder -= totalRemainingRowsHeight; | 395 remainder -= totalRemainingRowsHeight; |
388 accumulatedPositionIncrease++; | 396 accumulatedPositionIncrease++; |
389 } | 397 } |
390 } | 398 } |
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1727 else | 1735 else |
1728 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); | 1736 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); |
1729 | 1737 |
1730 cell->setLogicalLocation(cellLocation); | 1738 cell->setLogicalLocation(cellLocation); |
1731 | 1739 |
1732 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) | 1740 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) |
1733 view()->addLayoutDelta(oldCellLocation - cell->location()); | 1741 view()->addLayoutDelta(oldCellLocation - cell->location()); |
1734 } | 1742 } |
1735 | 1743 |
1736 } // namespace WebCore | 1744 } // namespace WebCore |
OLD | NEW |