Chromium Code Reviews| 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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 362 } | 362 } |
| 363 } | 363 } |
| 364 m_rowPos[row + 1] += accumulatedPositionIncrease; | 364 m_rowPos[row + 1] += accumulatedPositionIncrease; |
| 365 } | 365 } |
| 366 | 366 |
| 367 ASSERT(!remainder); | 367 ASSERT(!remainder); |
| 368 | 368 |
| 369 extraRowSpanningHeight -= accumulatedPositionIncrease; | 369 extraRowSpanningHeight -= accumulatedPositionIncrease; |
| 370 } | 370 } |
| 371 | 371 |
| 372 // 1. To save extra height distribution of all spanning cells those start and en d at same row, We process only | |
| 373 // heighest spanning cell and sort these type of cells in descending order based on their height. | |
| 374 // 2. If inner most cell's extra height distributed first then it's parent spann ing cells height can be set as | |
| 375 // specified by user. So sorting these types of cells in ascending order based o n their size. | |
|
Julien - ping for review
2013/07/30 23:43:07
The comment is OK but I think we could make this c
a.suchit
2013/07/31 10:26:13
Done.
| |
| 376 static bool compareRowSpanCellsInHeightDistributionOrder(RenderTableCell* cell2, RenderTableCell* cell1) | |
|
Julien - ping for review
2013/07/30 23:43:07
const RenderTableCell*, const RenderTableCell*
a.suchit
2013/07/31 10:26:13
Done.
| |
| 377 { | |
|
a.suchit
2013/07/31 10:26:13
+----------+----------+----------+
| |
| |
| 378 ASSERT(cell1); | |
| 379 ASSERT(cell2); | |
|
Julien - ping for review
2013/07/30 23:43:07
These ASSERTs are unneeded for 2 reasons:
- unless
a.suchit
2013/07/31 10:26:13
Done.
| |
| 380 | |
| 381 unsigned cellRowIndex1 = cell1->rowIndex(); | |
| 382 unsigned cellRowSpan1 = cell1->rowSpan(); | |
| 383 unsigned cellRowIndex2 = cell2->rowIndex(); | |
| 384 unsigned cellRowSpan2 = cell2->rowSpan(); | |
| 385 | |
| 386 if (cellRowIndex1 == cellRowIndex2 && cellRowSpan1 == cellRowSpan2) | |
| 387 return (cell2->logicalHeightForRowSizing() > cell1->logicalHeightForRowS izing()); | |
|
a.suchit
2013/07/31 10:26:13
This condition covers below case. In below case, A
| |
| 388 | |
| 389 return (cellRowIndex2 >= cellRowIndex1 && (cellRowIndex2 + cellRowSpan2) <= (cellRowIndex1 + cellRowSpan1)); | |
|
Julien - ping for review
2013/07/30 23:43:07
The comparator function passed to std::sort should
a.suchit
2013/07/31 10:26:13
I did not get meaning of strict comparator and not
| |
| 390 } | |
| 391 | |
| 372 // Distribute rowSpan cell height in rows those comes in rowSpan cell based on t he ratio of row's height if | 392 // Distribute rowSpan cell height in rows those comes in rowSpan cell based on t he ratio of row's height if |
| 373 // 1. RowSpan cell height is greater then the total height of rows in rowSpan ce ll | 393 // 1. RowSpan cell height is greater then the total height of rows in rowSpan ce ll |
| 374 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) | 394 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) |
| 375 { | 395 { |
| 376 ASSERT(rowSpanCells.size()); | 396 ASSERT(rowSpanCells.size()); |
| 377 | 397 |
| 398 // 'rowSpanCells' list is already sorted based on the cells rowIndex in asce nding order | |
| 399 // Arrange row spanning cell in the order in which we need to process first. | |
| 400 std::sort(rowSpanCells.begin(), rowSpanCells.end(), compareRowSpanCellsInHei ghtDistributionOrder); | |
| 401 | |
| 378 unsigned extraHeightToPropagate = 0; | 402 unsigned extraHeightToPropagate = 0; |
| 379 unsigned lastRowIndex = 0; | 403 unsigned lastRowIndex = 0; |
| 380 unsigned lastRowSpan = 0; | 404 unsigned lastRowSpan = 0; |
| 381 | 405 |
| 382 for (unsigned i = 0; i < rowSpanCells.size(); i++) { | 406 for (unsigned i = 0; i < rowSpanCells.size(); i++) { |
| 383 RenderTableCell* cell = rowSpanCells[i]; | 407 RenderTableCell* cell = rowSpanCells[i]; |
| 384 | 408 |
| 385 unsigned rowIndex = cell->rowIndex(); | 409 unsigned rowIndex = cell->rowIndex(); |
| 386 | 410 |
| 387 // FIXME: For now, we are handling only rowspan cells those are not over lapping with other | |
| 388 // rowspan cells but this is wrong. | |
| 389 if (rowIndex < lastRowIndex + lastRowSpan) | |
| 390 continue; | |
| 391 | |
| 392 unsigned rowSpan = cell->rowSpan(); | 411 unsigned rowSpan = cell->rowSpan(); |
| 393 int originalBeforePosition = m_rowPos[rowIndex + rowSpan]; | 412 int originalBeforePosition = m_rowPos[rowIndex + rowSpan]; |
| 394 | 413 |
| 414 if (rowIndex == lastRowIndex && rowSpan == lastRowSpan) | |
|
Julien - ping for review
2013/07/30 23:43:07
Nit: Do we need to compute |originalBeforePosition
a.suchit
2013/07/31 10:26:13
Done.
| |
| 415 continue; | |
| 416 | |
| 395 if (extraHeightToPropagate) { | 417 if (extraHeightToPropagate) { |
| 396 for (unsigned row = lastRowIndex + lastRowSpan + 1; row <= rowIndex + rowSpan; row++) | 418 for (unsigned row = lastRowIndex + lastRowSpan + 1; row <= rowIndex + rowSpan; row++) |
| 397 m_rowPos[row] += extraHeightToPropagate; | 419 m_rowPos[row] += extraHeightToPropagate; |
| 398 } | 420 } |
| 399 | 421 |
| 400 lastRowIndex = rowIndex; | 422 lastRowIndex = rowIndex; |
| 401 lastRowSpan = rowSpan; | 423 lastRowSpan = rowSpan; |
| 402 | 424 |
| 403 struct SpanningRowsHeight spanningRowsHeight; | 425 struct SpanningRowsHeight spanningRowsHeight; |
| 404 | 426 |
| 405 populateSpanningRowsHeightFromCell(cell, spanningRowsHeight); | 427 populateSpanningRowsHeightFromCell(cell, spanningRowsHeight); |
| 406 | 428 |
| 407 if (!spanningRowsHeight.totalRowsHeight || spanningRowsHeight.spanningCe llHeightIgnoringBorderSpacing <= spanningRowsHeight.totalRowsHeight) | 429 if (!spanningRowsHeight.totalRowsHeight || spanningRowsHeight.spanningCe llHeightIgnoringBorderSpacing <= spanningRowsHeight.totalRowsHeight) |
| 408 continue; | 430 continue; |
| 409 | 431 |
| 410 int totalPercent = 0; | 432 int totalPercent = 0; |
| 411 int totalAutoRowsHeight = 0; | 433 int totalAutoRowsHeight = 0; |
| 412 int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight; | 434 int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight; |
| 413 | 435 |
| 436 // FIXME: Inner spanning cell height should not change if it have fixed height when it's parent spanning cell | |
| 437 // is distributing it's extra height in rows. | |
| 438 | |
| 414 // Calculate total percentage, total auto rows height and total rows hei ght except percent rows. | 439 // Calculate total percentage, total auto rows height and total rows hei ght except percent rows. |
| 415 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | 440 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { |
| 416 if (m_grid[row].logicalHeight.isPercent()) { | 441 if (m_grid[row].logicalHeight.isPercent()) { |
| 417 totalPercent += m_grid[row].logicalHeight.percent(); | 442 totalPercent += m_grid[row].logicalHeight.percent(); |
| 418 totalRemainingRowsHeight -= spanningRowsHeight.rowHeight[row - r owIndex]; | 443 totalRemainingRowsHeight -= spanningRowsHeight.rowHeight[row - r owIndex]; |
| 419 } else if (m_grid[row].logicalHeight.isAuto()) { | 444 } else if (m_grid[row].logicalHeight.isAuto()) { |
| 420 totalAutoRowsHeight += spanningRowsHeight.rowHeight[row - rowInd ex]; | 445 totalAutoRowsHeight += spanningRowsHeight.rowHeight[row - rowInd ex]; |
| 421 } | 446 } |
| 422 } | 447 } |
| 423 | 448 |
| (...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1652 if (!style()->isLeftToRightDirection()) | 1677 if (!style()->isLeftToRightDirection()) |
| 1653 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); | 1678 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); |
| 1654 else | 1679 else |
| 1655 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); | 1680 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); |
| 1656 | 1681 |
| 1657 cell->setLogicalLocation(cellLocation); | 1682 cell->setLogicalLocation(cellLocation); |
| 1658 view()->addLayoutDelta(oldCellLocation - cell->location()); | 1683 view()->addLayoutDelta(oldCellLocation - cell->location()); |
| 1659 } | 1684 } |
| 1660 | 1685 |
| 1661 } // namespace WebCore | 1686 } // namespace WebCore |
| OLD | NEW |