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 // To avoid unneeded extra height distributions, we apply the following sorting algorithm: | |
373 // 1. We sort the cells by increasing starting row, then increasing last row (ie the top-most, longest cells first) | |
Julien - ping for review
2013/07/31 18:21:10
Please don't just copy and paste what I said witho
| |
374 // 2. For cells spanning the same rows, we sort by intrinsic size. | |
375 static bool compareRowSpanCellsInHeightDistributionOrder(const RenderTableCell* cell2, const RenderTableCell* cell1) | |
376 { | |
377 unsigned cellRowIndex1 = cell1->rowIndex(); | |
378 unsigned cellRowSpan1 = cell1->rowSpan(); | |
379 unsigned cellRowIndex2 = cell2->rowIndex(); | |
380 unsigned cellRowSpan2 = cell2->rowSpan(); | |
381 | |
382 if (cellRowIndex1 == cellRowIndex2 && cellRowSpan1 == cellRowSpan2) | |
383 return (cell2->logicalHeightForRowSizing() > cell1->logicalHeightForRowS izing()); | |
384 | |
385 return (cellRowIndex2 >= cellRowIndex1 && (cellRowIndex2 + cellRowSpan2) <= (cellRowIndex1 + cellRowSpan1)); | |
Julien - ping for review
2013/07/31 18:21:10
By a strict operator I meant an operator that defi
| |
386 } | |
387 | |
372 // Distribute rowSpan cell height in rows those comes in rowSpan cell based on t he ratio of row's height if | 388 // 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 | 389 // 1. RowSpan cell height is greater then the total height of rows in rowSpan ce ll |
374 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) | 390 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) |
375 { | 391 { |
376 ASSERT(rowSpanCells.size()); | 392 ASSERT(rowSpanCells.size()); |
377 | 393 |
394 // 'rowSpanCells' list is already sorted based on the cells rowIndex in asce nding order | |
395 // Arrange row spanning cell in the order in which we need to process first. | |
396 std::sort(rowSpanCells.begin(), rowSpanCells.end(), compareRowSpanCellsInHei ghtDistributionOrder); | |
397 | |
378 unsigned extraHeightToPropagate = 0; | 398 unsigned extraHeightToPropagate = 0; |
379 unsigned lastRowIndex = 0; | 399 unsigned lastRowIndex = 0; |
380 unsigned lastRowSpan = 0; | 400 unsigned lastRowSpan = 0; |
381 | 401 |
382 for (unsigned i = 0; i < rowSpanCells.size(); i++) { | 402 for (unsigned i = 0; i < rowSpanCells.size(); i++) { |
383 RenderTableCell* cell = rowSpanCells[i]; | 403 RenderTableCell* cell = rowSpanCells[i]; |
384 | 404 |
385 unsigned rowIndex = cell->rowIndex(); | 405 unsigned rowIndex = cell->rowIndex(); |
386 | 406 |
387 // FIXME: For now, we are handling only rowspan cells those are not over lapping with other | 407 unsigned rowSpan = cell->rowSpan(); |
388 // rowspan cells but this is wrong. | 408 |
389 if (rowIndex < lastRowIndex + lastRowSpan) | 409 // Only heightest spanning cell will distribute it's extra height in row if more then one spanning cells |
410 // present at same level. | |
411 if (rowIndex == lastRowIndex && rowSpan == lastRowSpan) | |
390 continue; | 412 continue; |
391 | 413 |
392 unsigned rowSpan = cell->rowSpan(); | |
393 int originalBeforePosition = m_rowPos[rowIndex + rowSpan]; | 414 int originalBeforePosition = m_rowPos[rowIndex + rowSpan]; |
394 | 415 |
395 if (extraHeightToPropagate) { | 416 if (extraHeightToPropagate) { |
396 for (unsigned row = lastRowIndex + lastRowSpan + 1; row <= rowIndex + rowSpan; row++) | 417 for (unsigned row = lastRowIndex + lastRowSpan + 1; row <= rowIndex + rowSpan; row++) |
397 m_rowPos[row] += extraHeightToPropagate; | 418 m_rowPos[row] += extraHeightToPropagate; |
398 } | 419 } |
399 | 420 |
400 lastRowIndex = rowIndex; | 421 lastRowIndex = rowIndex; |
401 lastRowSpan = rowSpan; | 422 lastRowSpan = rowSpan; |
402 | 423 |
403 struct SpanningRowsHeight spanningRowsHeight; | 424 struct SpanningRowsHeight spanningRowsHeight; |
404 | 425 |
405 populateSpanningRowsHeightFromCell(cell, spanningRowsHeight); | 426 populateSpanningRowsHeightFromCell(cell, spanningRowsHeight); |
406 | 427 |
407 if (!spanningRowsHeight.totalRowsHeight || spanningRowsHeight.spanningCe llHeightIgnoringBorderSpacing <= spanningRowsHeight.totalRowsHeight) | 428 if (!spanningRowsHeight.totalRowsHeight || spanningRowsHeight.spanningCe llHeightIgnoringBorderSpacing <= spanningRowsHeight.totalRowsHeight) |
408 continue; | 429 continue; |
409 | 430 |
410 int totalPercent = 0; | 431 int totalPercent = 0; |
411 int totalAutoRowsHeight = 0; | 432 int totalAutoRowsHeight = 0; |
412 int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight; | 433 int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight; |
413 | 434 |
435 // FIXME: Inner spanning cell height should not change if it have fixed height when it's parent spanning cell | |
436 // is distributing it's extra height in rows. | |
437 | |
414 // Calculate total percentage, total auto rows height and total rows hei ght except percent rows. | 438 // Calculate total percentage, total auto rows height and total rows hei ght except percent rows. |
415 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | 439 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { |
416 if (m_grid[row].logicalHeight.isPercent()) { | 440 if (m_grid[row].logicalHeight.isPercent()) { |
417 totalPercent += m_grid[row].logicalHeight.percent(); | 441 totalPercent += m_grid[row].logicalHeight.percent(); |
418 totalRemainingRowsHeight -= spanningRowsHeight.rowHeight[row - r owIndex]; | 442 totalRemainingRowsHeight -= spanningRowsHeight.rowHeight[row - r owIndex]; |
419 } else if (m_grid[row].logicalHeight.isAuto()) { | 443 } else if (m_grid[row].logicalHeight.isAuto()) { |
420 totalAutoRowsHeight += spanningRowsHeight.rowHeight[row - rowInd ex]; | 444 totalAutoRowsHeight += spanningRowsHeight.rowHeight[row - rowInd ex]; |
421 } | 445 } |
422 } | 446 } |
423 | 447 |
(...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1652 if (!style()->isLeftToRightDirection()) | 1676 if (!style()->isLeftToRightDirection()) |
1653 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); | 1677 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); |
1654 else | 1678 else |
1655 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); | 1679 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); |
1656 | 1680 |
1657 cell->setLogicalLocation(cellLocation); | 1681 cell->setLogicalLocation(cellLocation); |
1658 view()->addLayoutDelta(oldCellLocation - cell->location()); | 1682 view()->addLayoutDelta(oldCellLocation - cell->location()); |
1659 } | 1683 } |
1660 | 1684 |
1661 } // namespace WebCore | 1685 } // namespace WebCore |
OLD | NEW |