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 // Arrange row spanning cell in the oder in which we need to process first. | |
|
Julien - ping for review
2013/07/29 16:52:55
This comment should be embedded into the method na
a.suchit
2013/07/30 08:42:20
Done.
| |
| 373 static inline void rearrangeRowSpanCells(RenderTableSection::SpanningRenderTable Cells& rowSpanCells) | |
| 374 { | |
| 375 unsigned totalCells = rowSpanCells.size(); | |
| 376 | |
| 377 // 'rowSpanCelss' list is already sorted based on the cells rowIndex in asce nding order | |
|
Julien - ping for review
2013/07/29 16:52:55
typo: rowSpanCelss
a.suchit
2013/07/30 08:42:20
Done.
| |
| 378 | |
| 379 for (unsigned i = 0; i < totalCells; i++) { | |
| 380 bool sortCompleted = true; | |
| 381 | |
| 382 for (unsigned j = totalCells - 1; j > i; j--) { | |
|
Julien - ping for review
2013/07/29 16:52:55
As mentioned on IRC, reusing std::sort with a cust
a.suchit
2013/07/30 08:42:20
Done.
| |
| 383 unsigned cellRowIndex = rowSpanCells[j]->rowIndex(); | |
| 384 unsigned cellRowSpan = rowSpanCells[j]->rowSpan(); | |
| 385 unsigned prevCellRowIndex = rowSpanCells[j - 1]->rowIndex(); | |
| 386 unsigned prevCellRowSpan = rowSpanCells[j - 1]->rowSpan(); | |
| 387 bool swap = false; | |
| 388 | |
| 389 if (cellRowIndex == prevCellRowIndex) { | |
| 390 if (cellRowSpan == prevCellRowSpan) { | |
| 391 // if 2 or more row spanning cells start and end at same row s then we need to process only | |
| 392 // one row spanning cell which have highest height. So these types of cells are sorted in | |
| 393 // descending order based on their heights. | |
| 394 if (rowSpanCells[j]->logicalHeightForRowSizing() > rowSpanCe lls[j - 1]->logicalHeightForRowSizing()) | |
| 395 swap = true; | |
| 396 } else if (cellRowSpan < prevCellRowSpan) { | |
| 397 // if 2 or more row spanning cells start at same row but end at diffrent rows then smaller | |
| 398 // row spanning cell should get process first. So these type s of cells are sorted in ascending | |
| 399 // order based on their sizes. | |
| 400 swap = true; | |
| 401 } | |
| 402 } else if (cellRowIndex > prevCellRowIndex) { | |
| 403 // if the row spanning cell comes under the boundries of another row spanning cell then inner row | |
| 404 // spanning cell should get process first. So these types of cel ls are sorted in ascending order | |
| 405 // based on their sizes. | |
| 406 if ((cellRowIndex + cellRowSpan) <= (prevCellRowIndex + prevCell RowSpan)) | |
| 407 swap = true; | |
| 408 } | |
| 409 | |
| 410 if (swap) { | |
| 411 RenderTableCell* cell = rowSpanCells[j]; | |
| 412 rowSpanCells[j] = rowSpanCells[j - 1]; | |
| 413 rowSpanCells[j - 1] = cell; | |
| 414 sortCompleted = false; | |
| 415 } | |
| 416 } | |
| 417 | |
| 418 if (sortCompleted) | |
| 419 break; | |
| 420 } | |
| 421 } | |
| 422 | |
| 372 // Distribute rowSpan cell height in rows those comes in rowSpan cell based on t he ratio of row's height if | 423 // 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 | 424 // 1. RowSpan cell height is greater then the total height of rows in rowSpan ce ll |
| 374 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) | 425 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) |
| 375 { | 426 { |
| 376 ASSERT(rowSpanCells.size()); | 427 ASSERT(rowSpanCells.size()); |
| 377 | 428 |
| 429 rearrangeRowSpanCells(rowSpanCells); | |
| 430 | |
| 378 unsigned extraHeightToPropagate = 0; | 431 unsigned extraHeightToPropagate = 0; |
| 379 unsigned lastRowIndex = 0; | 432 unsigned lastRowIndex = 0; |
| 380 unsigned lastRowSpan = 0; | 433 unsigned lastRowSpan = 0; |
| 381 | 434 |
| 382 for (unsigned i = 0; i < rowSpanCells.size(); i++) { | 435 for (unsigned i = 0; i < rowSpanCells.size(); i++) { |
| 383 RenderTableCell* cell = rowSpanCells[i]; | 436 RenderTableCell* cell = rowSpanCells[i]; |
| 384 | 437 |
| 385 unsigned rowIndex = cell->rowIndex(); | 438 unsigned rowIndex = cell->rowIndex(); |
| 386 | 439 |
| 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(); | 440 unsigned rowSpan = cell->rowSpan(); |
| 393 int originalBeforePosition = m_rowPos[rowIndex + rowSpan]; | 441 int originalBeforePosition = m_rowPos[rowIndex + rowSpan]; |
| 394 | 442 |
| 443 if (rowIndex == lastRowIndex && rowSpan == lastRowSpan) | |
| 444 continue; | |
| 445 | |
| 395 if (extraHeightToPropagate) { | 446 if (extraHeightToPropagate) { |
| 396 for (unsigned row = lastRowIndex + lastRowSpan + 1; row <= rowIndex + rowSpan; row++) | 447 for (unsigned row = lastRowIndex + lastRowSpan + 1; row <= rowIndex + rowSpan; row++) |
| 397 m_rowPos[row] += extraHeightToPropagate; | 448 m_rowPos[row] += extraHeightToPropagate; |
| 398 } | 449 } |
| 399 | 450 |
| 400 lastRowIndex = rowIndex; | 451 lastRowIndex = rowIndex; |
| 401 lastRowSpan = rowSpan; | 452 lastRowSpan = rowSpan; |
| 402 | 453 |
| 403 struct SpanningRowsHeight spanningRowsHeight; | 454 struct SpanningRowsHeight spanningRowsHeight; |
| 404 | 455 |
| (...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1652 if (!style()->isLeftToRightDirection()) | 1703 if (!style()->isLeftToRightDirection()) |
| 1653 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); | 1704 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); |
| 1654 else | 1705 else |
| 1655 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); | 1706 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); |
| 1656 | 1707 |
| 1657 cell->setLogicalLocation(cellLocation); | 1708 cell->setLogicalLocation(cellLocation); |
| 1658 view()->addLayoutDelta(oldCellLocation - cell->location()); | 1709 view()->addLayoutDelta(oldCellLocation - cell->location()); |
| 1659 } | 1710 } |
| 1660 | 1711 |
| 1661 } // namespace WebCore | 1712 } // namespace WebCore |
| OLD | NEW |