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 | |
Julien - ping for review
2014/03/21 04:18:05
In correct English:
Sometimes the multiplication
a.suchit
2014/03/24 10:53:59
Done.
| |
332 // type of variable in computation are taken as 'long long' in place of int. | |
Julien - ping for review
2014/03/21 04:18:05
So we convert the parameters to 'long long' instea
a.suchit
2014/03/24 10:53:59
Done.
| |
333 // In this computation, only 2 integer variables are multiplied which would not | |
Julien - ping for review
2014/03/21 04:18:05
This sentence really doesn't add much IMO.
| |
334 // overflow long long. | |
335 static void updatePositionIncreasedWithRowHeight(long long extraHeight, long lon g rowHeight, long long totalHeight, int& accumulatedPositionIncrease, int& remai nder) | |
336 { | |
337 COMPILE_ASSERT(sizeof(long long int) > sizeof(int), int_should_be_less_than_ longlong); | |
338 | |
339 accumulatedPositionIncrease += (extraHeight * rowHeight) / totalHeight; | |
340 remainder += (extraHeight * rowHeight) % totalHeight; | |
341 } | |
342 | |
331 void RenderTableSection::distributeExtraRowSpanHeightToAutoRows(RenderTableCell* cell, int totalAutoRowsHeight, int& extraRowSpanningHeight, Vector<int>& rowsHe ight) | 343 void RenderTableSection::distributeExtraRowSpanHeightToAutoRows(RenderTableCell* cell, int totalAutoRowsHeight, int& extraRowSpanningHeight, Vector<int>& rowsHe ight) |
332 { | 344 { |
333 if (!extraRowSpanningHeight || !totalAutoRowsHeight) | 345 if (!extraRowSpanningHeight || !totalAutoRowsHeight) |
334 return; | 346 return; |
335 | 347 |
336 const unsigned rowSpan = cell->rowSpan(); | 348 const unsigned rowSpan = cell->rowSpan(); |
337 const unsigned rowIndex = cell->rowIndex(); | 349 const unsigned rowIndex = cell->rowIndex(); |
338 int accumulatedPositionIncrease = 0; | 350 int accumulatedPositionIncrease = 0; |
339 int remainder = 0; | 351 int remainder = 0; |
340 | 352 |
341 // Aspect ratios of auto rows should not change otherwise table may look dif ferent than user expected. | 353 // 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. | 354 // 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++) { | 355 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { |
344 if (m_grid[row].logicalHeight.isAuto()) { | 356 if (m_grid[row].logicalHeight.isAuto()) { |
345 accumulatedPositionIncrease += (extraRowSpanningHeight * rowsHeight[ row - rowIndex]) / totalAutoRowsHeight; | 357 updatePositionIncreasedWithRowHeight(extraRowSpanningHeight, rowsHei ght[row - rowIndex], totalAutoRowsHeight, accumulatedPositionIncrease, remainder ); |
346 remainder += (extraRowSpanningHeight * rowsHeight[row - rowIndex]) % totalAutoRowsHeight; | |
347 | 358 |
348 // While whole extra spanning height is distributing in auto spannin g rows, rational parts remains | 359 // 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 | 360 // 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. | 361 // 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. | 362 // Note that this algorithm is biased towards adding more space towa rds the lower rows. |
352 if (remainder >= totalAutoRowsHeight) { | 363 if (remainder >= totalAutoRowsHeight) { |
353 remainder -= totalAutoRowsHeight; | 364 remainder -= totalAutoRowsHeight; |
354 accumulatedPositionIncrease++; | 365 accumulatedPositionIncrease++; |
355 } | 366 } |
356 } | 367 } |
(...skipping 12 matching lines...) Expand all Loading... | |
369 | 380 |
370 const unsigned rowSpan = cell->rowSpan(); | 381 const unsigned rowSpan = cell->rowSpan(); |
371 const unsigned rowIndex = cell->rowIndex(); | 382 const unsigned rowIndex = cell->rowIndex(); |
372 int accumulatedPositionIncrease = 0; | 383 int accumulatedPositionIncrease = 0; |
373 int remainder = 0; | 384 int remainder = 0; |
374 | 385 |
375 // Aspect ratios of the rows should not change otherwise table may look diff erent than user expected. | 386 // 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. | 387 // 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++) { | 388 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { |
378 if (!m_grid[row].logicalHeight.isPercent()) { | 389 if (!m_grid[row].logicalHeight.isPercent()) { |
379 accumulatedPositionIncrease += (extraRowSpanningHeight * rowsHeight[ row - rowIndex]) / totalRemainingRowsHeight; | 390 updatePositionIncreasedWithRowHeight(extraRowSpanningHeight, rowsHei ght[row - rowIndex], totalRemainingRowsHeight, accumulatedPositionIncrease, rema inder); |
380 remainder += (extraRowSpanningHeight * rowsHeight[row - rowIndex]) % totalRemainingRowsHeight; | |
381 | 391 |
382 // While whole extra spanning height is distributing in remaining sp anning rows, rational parts remains | 392 // 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 | 393 // 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. | 394 // 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. | 395 // Note that this algorithm is biased towards adding more space towa rds the lower rows. |
386 if (remainder >= totalRemainingRowsHeight) { | 396 if (remainder >= totalRemainingRowsHeight) { |
387 remainder -= totalRemainingRowsHeight; | 397 remainder -= totalRemainingRowsHeight; |
388 accumulatedPositionIncrease++; | 398 accumulatedPositionIncrease++; |
389 } | 399 } |
390 } | 400 } |
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1727 else | 1737 else |
1728 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); | 1738 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); |
1729 | 1739 |
1730 cell->setLogicalLocation(cellLocation); | 1740 cell->setLogicalLocation(cellLocation); |
1731 | 1741 |
1732 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) | 1742 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) |
1733 view()->addLayoutDelta(oldCellLocation - cell->location()); | 1743 view()->addLayoutDelta(oldCellLocation - cell->location()); |
1734 } | 1744 } |
1735 | 1745 |
1736 } // namespace WebCore | 1746 } // namespace WebCore |
OLD | NEW |