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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 if (inColSpan) | 246 if (inColSpan) |
247 c.inColSpan = true; | 247 c.inColSpan = true; |
248 } | 248 } |
249 m_cCol++; | 249 m_cCol++; |
250 cSpan -= currentSpan; | 250 cSpan -= currentSpan; |
251 inColSpan = true; | 251 inColSpan = true; |
252 } | 252 } |
253 cell->setCol(table()->effColToCol(col)); | 253 cell->setCol(table()->effColToCol(col)); |
254 } | 254 } |
255 | 255 |
256 unsigned RenderTableSection::rowHasOnlySpanningCells(unsigned row) | |
257 { | |
258 ASSERT(row < m_grid.size()); | |
Julien - ping for review
2013/09/18 18:39:37
This ...
a.suchit
2013/09/19 08:18:36
Done.
| |
259 | |
260 if (row >= m_grid.size()) | |
Julien - ping for review
2013/09/18 18:39:37
.. and this are unneeded ...
a.suchit
2013/09/19 08:18:36
Done.
| |
261 return false; | |
262 | |
263 unsigned totalCols = m_grid[row].row.size(); | |
Julien - ping for review
2013/09/18 18:39:37
... because m_grid[row] calls Vector::at(size_t i)
| |
264 | |
265 if (!totalCols) | |
266 return false; | |
267 | |
268 for (unsigned col = 0; col < totalCols; col++) { | |
269 const CellStruct& rowSpanCell = cellAt(row, col); | |
270 | |
271 // Empty cell would be 1 rowspan cell only if we consider that empty cel l is valid cell. | |
Julien - ping for review
2013/09/18 18:39:37
The more I read this comment the less I understand
a.suchit
2013/09/19 08:18:36
Done.
| |
272 if (rowSpanCell.cells.isEmpty() || rowSpanCell.cells[0]->rowSpan() == 1) | |
Julien - ping for review
2013/09/18 18:39:37
Nit: I would have separated these 2 conditions so
a.suchit
2013/09/19 08:18:36
Done.
| |
273 return false; | |
274 } | |
275 | |
276 return true; | |
277 } | |
278 | |
256 void RenderTableSection::populateSpanningRowsHeightFromCell(RenderTableCell* cel l, struct SpanningRowsHeight& spanningRowsHeight) | 279 void RenderTableSection::populateSpanningRowsHeightFromCell(RenderTableCell* cel l, struct SpanningRowsHeight& spanningRowsHeight) |
257 { | 280 { |
258 const unsigned rowSpan = cell->rowSpan(); | 281 const unsigned rowSpan = cell->rowSpan(); |
259 const unsigned rowIndex = cell->rowIndex(); | 282 const unsigned rowIndex = cell->rowIndex(); |
260 | 283 |
261 spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing = cell->logicalHe ightForRowSizing(); | 284 spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing = cell->logicalHe ightForRowSizing(); |
262 | 285 |
263 spanningRowsHeight.rowHeight.resize(rowSpan); | 286 spanningRowsHeight.rowHeight.resize(rowSpan); |
264 spanningRowsHeight.totalRowsHeight = 0; | 287 spanningRowsHeight.totalRowsHeight = 0; |
265 for (unsigned row = 0; row < rowSpan; row++) { | 288 for (unsigned row = 0; row < rowSpan; row++) { |
266 unsigned actualRow = row + rowIndex; | 289 unsigned actualRow = row + rowIndex; |
290 | |
267 spanningRowsHeight.rowHeight[row] = m_rowPos[actualRow + 1] - m_rowPos[a ctualRow] - borderSpacingForRow(actualRow); | 291 spanningRowsHeight.rowHeight[row] = m_rowPos[actualRow + 1] - m_rowPos[a ctualRow] - borderSpacingForRow(actualRow); |
292 if (!spanningRowsHeight.rowHeight[row]) | |
293 spanningRowsHeight.rowWithOnlySpanningCells |= rowHasOnlySpanningCel ls(actualRow); | |
294 | |
268 spanningRowsHeight.totalRowsHeight += spanningRowsHeight.rowHeight[row]; | 295 spanningRowsHeight.totalRowsHeight += spanningRowsHeight.rowHeight[row]; |
269 spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing -= borderSpac ingForRow(actualRow); | 296 spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing -= borderSpac ingForRow(actualRow); |
270 } | 297 } |
271 // We don't span the following row so its border-spacing (if any) should be included. | 298 // We don't span the following row so its border-spacing (if any) should be included. |
272 spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing += borderSpacingF orRow(rowIndex + rowSpan - 1); | 299 spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing += borderSpacingF orRow(rowIndex + rowSpan - 1); |
273 } | 300 } |
274 | 301 |
275 void RenderTableSection::distributeExtraRowSpanHeightToPercentRows(RenderTableCe ll* cell, int totalPercent, int& extraRowSpanningHeight, Vector<int>& rowsHeight ) | 302 void RenderTableSection::distributeExtraRowSpanHeightToPercentRows(RenderTableCe ll* cell, int totalPercent, int& extraRowSpanningHeight, Vector<int>& rowsHeight ) |
276 { | 303 { |
277 if (!extraRowSpanningHeight || !totalPercent) | 304 if (!extraRowSpanningHeight || !totalPercent) |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 if (cellIsFullyIncludedInOtherCell(cell1, cell2)) | 415 if (cellIsFullyIncludedInOtherCell(cell1, cell2)) |
389 return true; | 416 return true; |
390 // Sorting lower row index first because first we need to apply the extra he ight of spanning cell which | 417 // Sorting lower row index first because first we need to apply the extra he ight of spanning cell which |
391 // comes first in the table so lower rows's position would increment in sequ ence. | 418 // comes first in the table so lower rows's position would increment in sequ ence. |
392 if (cellIsFullyIncludedInOtherCell(cell2, cell1)) | 419 if (cellIsFullyIncludedInOtherCell(cell2, cell1)) |
393 return (cell1->rowIndex() < cell2->rowIndex()); | 420 return (cell1->rowIndex() < cell2->rowIndex()); |
394 | 421 |
395 return false; | 422 return false; |
396 } | 423 } |
397 | 424 |
425 unsigned RenderTableSection::calcRowHeightHavingOnlySpanningCells(unsigned row) | |
426 { | |
427 ASSERT(row < m_grid.size()); | |
Julien - ping for review
2013/09/18 18:39:37
Same comment as above, unneeded and should be remo
a.suchit
2013/09/19 08:18:36
Done.
| |
428 ASSERT(rowHasOnlySpanningCells(row)); | |
429 | |
430 if (row >= m_grid.size()) | |
Julien - ping for review
2013/09/18 18:39:37
Same comment as above, unneeded and should be remo
a.suchit
2013/09/19 08:18:36
Done.
| |
431 return 0; | |
432 | |
433 unsigned totalCols = m_grid[row].row.size(); | |
434 | |
435 if (!totalCols) | |
436 return 0; | |
437 | |
438 unsigned rowHeight = 0; | |
439 | |
440 for (unsigned col = 0; col < totalCols; col++) { | |
441 CellStruct rowSpanCell = cellAt(row, col); | |
Julien - ping for review
2013/09/18 18:39:37
Again, const reference to avoid an implicit copy!
a.suchit
2013/09/19 08:18:36
Done.
| |
442 if (rowSpanCell.cells.size() && rowSpanCell.cells[0]->rowSpan() > 1) | |
443 rowHeight = max(rowHeight, rowSpanCell.cells[0]->logicalHeightForRow Sizing() / rowSpanCell.cells[0]->rowSpan()); | |
444 } | |
445 | |
446 return rowHeight; | |
447 } | |
448 | |
449 void RenderTableSection::updateRowsHeightHavingOnlySpanningCells(RenderTableCell * cell, struct SpanningRowsHeight& spanningRowsHeight) | |
450 { | |
451 ASSERT(spanningRowsHeight.rowHeight.size()); | |
452 | |
453 int accumulatedPositionIncrease = 0; | |
454 const unsigned rowSpan = cell->rowSpan(); | |
455 const unsigned rowIndex = cell->rowIndex(); | |
456 | |
457 ASSERT(rowSpan == spanningRowsHeight.rowHeight.size()); | |
458 | |
459 for (unsigned row = 0; row < spanningRowsHeight.rowHeight.size(); row++) { | |
460 unsigned actualRow = row + rowIndex; | |
461 if (!spanningRowsHeight.rowHeight[row] && rowHasOnlySpanningCells(actual Row)) { | |
462 spanningRowsHeight.rowHeight[row] = calcRowHeightHavingOnlySpanningC ells(actualRow); | |
463 accumulatedPositionIncrease += spanningRowsHeight.rowHeight[row]; | |
464 } | |
465 m_rowPos[actualRow + 1] += accumulatedPositionIncrease; | |
466 } | |
467 | |
468 spanningRowsHeight.totalRowsHeight += accumulatedPositionIncrease; | |
469 } | |
470 | |
398 // Distribute rowSpan cell height in rows those comes in rowSpan cell based on t he ratio of row's height if | 471 // Distribute rowSpan cell height in rows those comes in rowSpan cell based on t he ratio of row's height if |
399 // 1. RowSpan cell height is greater then the total height of rows in rowSpan ce ll | 472 // 1. RowSpan cell height is greater then the total height of rows in rowSpan ce ll |
400 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) | 473 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) |
401 { | 474 { |
402 ASSERT(rowSpanCells.size()); | 475 ASSERT(rowSpanCells.size()); |
403 | 476 |
404 // 'rowSpanCells' list is already sorted based on the cells rowIndex in asce nding order | 477 // 'rowSpanCells' list is already sorted based on the cells rowIndex in asce nding order |
405 // Arrange row spanning cell in the order in which we need to process first. | 478 // Arrange row spanning cell in the order in which we need to process first. |
406 std::sort(rowSpanCells.begin(), rowSpanCells.end(), compareRowSpanCellsInHei ghtDistributionOrder); | 479 std::sort(rowSpanCells.begin(), rowSpanCells.end(), compareRowSpanCellsInHei ghtDistributionOrder); |
407 | 480 |
(...skipping 29 matching lines...) Expand all Loading... | |
437 m_rowPos[row] += extraHeightToPropagate; | 510 m_rowPos[row] += extraHeightToPropagate; |
438 } | 511 } |
439 | 512 |
440 lastRowIndex = rowIndex; | 513 lastRowIndex = rowIndex; |
441 lastRowSpan = rowSpan; | 514 lastRowSpan = rowSpan; |
442 | 515 |
443 struct SpanningRowsHeight spanningRowsHeight; | 516 struct SpanningRowsHeight spanningRowsHeight; |
444 | 517 |
445 populateSpanningRowsHeightFromCell(cell, spanningRowsHeight); | 518 populateSpanningRowsHeightFromCell(cell, spanningRowsHeight); |
446 | 519 |
447 if (!spanningRowsHeight.totalRowsHeight || spanningRowsHeight.spanningCe llHeightIgnoringBorderSpacing <= spanningRowsHeight.totalRowsHeight) | 520 if (spanningRowsHeight.rowWithOnlySpanningCells) |
521 updateRowsHeightHavingOnlySpanningCells(cell, spanningRowsHeight); | |
522 | |
523 if (!spanningRowsHeight.totalRowsHeight || spanningRowsHeight.spanningCe llHeightIgnoringBorderSpacing <= spanningRowsHeight.totalRowsHeight) { | |
524 extraHeightToPropagate = m_rowPos[rowIndex + rowSpan] - originalBefo rePosition; | |
448 continue; | 525 continue; |
526 } | |
449 | 527 |
450 int totalPercent = 0; | 528 int totalPercent = 0; |
451 int totalAutoRowsHeight = 0; | 529 int totalAutoRowsHeight = 0; |
452 int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight; | 530 int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight; |
453 | 531 |
454 // FIXME: Inner spanning cell height should not change if it have fixed height when it's parent spanning cell | 532 // FIXME: Inner spanning cell height should not change if it have fixed height when it's parent spanning cell |
455 // is distributing it's extra height in rows. | 533 // is distributing it's extra height in rows. |
456 | 534 |
457 // Calculate total percentage, total auto rows height and total rows hei ght except percent rows. | 535 // Calculate total percentage, total auto rows height and total rows hei ght except percent rows. |
458 for (unsigned row = rowIndex; row < spanningCellEndIndex; row++) { | 536 for (unsigned row = rowIndex; row < spanningCellEndIndex; row++) { |
(...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1707 if (!style()->isLeftToRightDirection()) | 1785 if (!style()->isLeftToRightDirection()) |
1708 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); | 1786 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); |
1709 else | 1787 else |
1710 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); | 1788 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); |
1711 | 1789 |
1712 cell->setLogicalLocation(cellLocation); | 1790 cell->setLogicalLocation(cellLocation); |
1713 view()->addLayoutDelta(oldCellLocation - cell->location()); | 1791 view()->addLayoutDelta(oldCellLocation - cell->location()); |
1714 } | 1792 } |
1715 | 1793 |
1716 } // namespace WebCore | 1794 } // namespace WebCore |
OLD | NEW |