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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 | 368 |
369 extraRowSpanningHeight -= accumulatedPositionIncrease; | 369 extraRowSpanningHeight -= accumulatedPositionIncrease; |
370 } | 370 } |
371 | 371 |
372 // Distribute rowSpan cell height in rows those comes in rowSpan cell based on t he ratio of row's height if | 372 // 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 | 373 // 1. RowSpan cell height is greater then the total height of rows in rowSpan ce ll |
374 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) | 374 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) |
375 { | 375 { |
376 ASSERT(rowSpanCells.size()); | 376 ASSERT(rowSpanCells.size()); |
377 | 377 |
378 // FIXME: For now, we handle the first rowspan cell in the table but this is wrong. | 378 unsigned extraHeightToPropagate = 0; |
379 RenderTableCell* cell = rowSpanCells[0]; | 379 unsigned lastRowIndex = 0; |
380 unsigned lastRowSpan = 0; | |
380 | 381 |
381 unsigned rowSpan = cell->rowSpan(); | 382 for (unsigned i = 0; i < rowSpanCells.size(); i++) { |
383 RenderTableCell* cell = rowSpanCells[i]; | |
382 | 384 |
383 struct SpanningRowsHeight spanningRowsHeight; | 385 unsigned rowIndex = cell->rowIndex(); |
384 | 386 |
385 populateSpanningRowsHeightFromCell(cell, spanningRowsHeight); | 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; | |
386 | 391 |
387 if (!spanningRowsHeight.totalRowsHeight || spanningRowsHeight.spanningCellHe ightIgnoringBorderSpacing <= spanningRowsHeight.totalRowsHeight) | 392 unsigned rowSpan = cell->rowSpan(); |
388 return; | 393 int originalBeforePosition = m_rowPos[rowIndex + rowSpan]; |
389 | 394 |
390 unsigned rowIndex = cell->rowIndex(); | 395 if (extraHeightToPropagate) { |
391 int totalPercent = 0; | 396 for (unsigned row = lastRowIndex + lastRowSpan + 1; row <= rowIndex + rowSpan; row++) |
392 int totalAutoRowsHeight = 0; | 397 m_rowPos[row] += extraHeightToPropagate; |
393 int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight; | 398 } |
394 | 399 |
395 // Calculate total percentage, total auto rows height and total rows height except percent rows. | 400 lastRowIndex = rowIndex; |
396 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | 401 lastRowSpan = rowSpan; |
397 if (m_grid[row].logicalHeight.isPercent()) { | 402 |
398 totalPercent += m_grid[row].logicalHeight.percent(); | 403 struct SpanningRowsHeight spanningRowsHeight; |
399 totalRemainingRowsHeight -= spanningRowsHeight.rowHeight[row - rowIn dex]; | 404 |
400 } else if (m_grid[row].logicalHeight.isAuto()) { | 405 populateSpanningRowsHeightFromCell(cell, spanningRowsHeight); |
401 totalAutoRowsHeight += spanningRowsHeight.rowHeight[row - rowIndex]; | 406 |
407 if (spanningRowsHeight.totalRowsHeight && spanningRowsHeight.spanningCel lHeightIgnoringBorderSpacing > spanningRowsHeight.totalRowsHeight) { | |
Julien - ping for review
2013/07/23 18:00:12
Let's avoid nested the nested if by reversing the
a.suchit
2013/07/24 06:32:38
Done.
| |
408 | |
409 int totalPercent = 0; | |
410 int totalAutoRowsHeight = 0; | |
411 int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight; | |
412 | |
413 // Calculate total percentage, total auto rows height and total rows height except percent rows. | |
414 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | |
415 if (m_grid[row].logicalHeight.isPercent()) { | |
416 totalPercent += m_grid[row].logicalHeight.percent(); | |
417 totalRemainingRowsHeight -= spanningRowsHeight.rowHeight[row - rowIndex]; | |
418 } else if (m_grid[row].logicalHeight.isAuto()) { | |
419 totalAutoRowsHeight += spanningRowsHeight.rowHeight[row - ro wIndex]; | |
420 } | |
421 } | |
422 | |
423 int extraRowSpanningHeight = spanningRowsHeight.spanningCellHeightIg noringBorderSpacing - spanningRowsHeight.totalRowsHeight; | |
424 | |
425 distributeExtraRowSpanHeightToPercentRows(cell, totalPercent, extraR owSpanningHeight, spanningRowsHeight.rowHeight); | |
426 distributeExtraRowSpanHeightToAutoRows(cell, totalAutoRowsHeight, ex traRowSpanningHeight, spanningRowsHeight.rowHeight); | |
427 distributeExtraRowSpanHeightToRemainingRows(cell, totalRemainingRows Height, extraRowSpanningHeight, spanningRowsHeight.rowHeight); | |
428 | |
429 ASSERT(!extraRowSpanningHeight); | |
430 | |
431 // Getting total changed height in the table | |
432 extraHeightToPropagate = m_rowPos[rowIndex + rowSpan] - originalBefo rePosition; | |
402 } | 433 } |
403 } | 434 } |
404 | 435 |
405 int initialPos = m_rowPos[rowIndex + rowSpan]; | 436 if (extraHeightToPropagate) { |
406 int extraRowSpanningHeight = spanningRowsHeight.spanningCellHeightIgnoringBo rderSpacing - spanningRowsHeight.totalRowsHeight; | |
407 | |
408 distributeExtraRowSpanHeightToPercentRows(cell, totalPercent, extraRowSpanni ngHeight, spanningRowsHeight.rowHeight); | |
409 distributeExtraRowSpanHeightToAutoRows(cell, totalAutoRowsHeight, extraRowSp anningHeight, spanningRowsHeight.rowHeight); | |
410 distributeExtraRowSpanHeightToRemainingRows(cell, totalRemainingRowsHeight, extraRowSpanningHeight, spanningRowsHeight.rowHeight); | |
411 | |
412 ASSERT(!extraRowSpanningHeight); | |
413 | |
414 // Getting total changed height in the table | |
415 unsigned changedHeight = m_rowPos[rowIndex + rowSpan] - initialPos; | |
416 | |
417 if (changedHeight) { | |
418 unsigned totalRows = m_grid.size(); | |
419 | |
420 // Apply changed height by rowSpan cells to rows present at the end of t he table | 437 // Apply changed height by rowSpan cells to rows present at the end of t he table |
421 for (unsigned row = rowIndex + rowSpan + 1; row <= totalRows; row++) | 438 for (unsigned row = lastRowIndex + lastRowSpan + 1; row <= m_grid.size() ; row++) |
422 m_rowPos[row] += changedHeight; | 439 m_rowPos[row] += extraHeightToPropagate; |
423 } | 440 } |
424 } | 441 } |
425 | 442 |
426 // Find out the baseline of the cell | 443 // Find out the baseline of the cell |
427 // If the cell's baseline is more then the row's baseline then the cell's baseli ne become the row's baseline | 444 // If the cell's baseline is more then the row's baseline then the cell's baseli ne become the row's baseline |
428 // and if the row's baseline goes out of the row's boundries then adjust row hei ght accordingly. | 445 // and if the row's baseline goes out of the row's boundries then adjust row hei ght accordingly. |
429 void RenderTableSection::updateBaselineForCell(RenderTableCell* cell, unsigned r ow, LayoutUnit& baselineDescent) | 446 void RenderTableSection::updateBaselineForCell(RenderTableCell* cell, unsigned r ow, LayoutUnit& baselineDescent) |
430 { | 447 { |
431 if (!cell->isBaselineAligned()) | 448 if (!cell->isBaselineAligned()) |
432 return; | 449 return; |
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1635 if (!style()->isLeftToRightDirection()) | 1652 if (!style()->isLeftToRightDirection()) |
1636 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); | 1653 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); |
1637 else | 1654 else |
1638 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); | 1655 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); |
1639 | 1656 |
1640 cell->setLogicalLocation(cellLocation); | 1657 cell->setLogicalLocation(cellLocation); |
1641 view()->addLayoutDelta(oldCellLocation - cell->location()); | 1658 view()->addLayoutDelta(oldCellLocation - cell->location()); |
1642 } | 1659 } |
1643 | 1660 |
1644 } // namespace WebCore | 1661 } // namespace WebCore |
OLD | NEW |