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 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/17 16:51:26
This will be caught by Vector::at() (even in relea
a.suchit
2013/09/18 11:40:38
returned if row have more than vector size.
| |
| 259 | |
| 260 unsigned totalCols = m_grid[row].row.size(); | |
| 261 | |
| 262 if (!totalCols) | |
| 263 return false; | |
| 264 | |
| 265 for (unsigned col = 0; col < totalCols; col++) { | |
| 266 CellStruct rowSpanCell = cellAt(row, col); | |
|
Julien - ping for review
2013/09/17 16:51:26
Let's avoid a copy by using a reference here. Also
a.suchit
2013/09/18 11:40:38
Done.
| |
| 267 if (rowSpanCell.cells.size()) { | |
| 268 if (rowSpanCell.cells[0]->rowSpan() == 1) | |
| 269 return false; | |
| 270 } else { | |
| 271 return false; | |
| 272 } | |
|
Julien - ping for review
2013/09/17 16:51:26
Let's write this (more readable with the early ret
a.suchit
2013/09/18 11:40:38
Done.
| |
| 273 } | |
| 274 | |
| 275 return true; | |
| 276 } | |
| 277 | |
| 256 void RenderTableSection::populateSpanningRowsHeightFromCell(RenderTableCell* cel l, struct SpanningRowsHeight& spanningRowsHeight) | 278 void RenderTableSection::populateSpanningRowsHeightFromCell(RenderTableCell* cel l, struct SpanningRowsHeight& spanningRowsHeight) |
| 257 { | 279 { |
| 258 const unsigned rowSpan = cell->rowSpan(); | 280 const unsigned rowSpan = cell->rowSpan(); |
| 259 const unsigned rowIndex = cell->rowIndex(); | 281 const unsigned rowIndex = cell->rowIndex(); |
| 260 | 282 |
| 261 spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing = cell->logicalHe ightForRowSizing(); | 283 spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing = cell->logicalHe ightForRowSizing(); |
| 262 | 284 |
| 263 spanningRowsHeight.rowHeight.resize(rowSpan); | 285 spanningRowsHeight.rowHeight.resize(rowSpan); |
| 264 spanningRowsHeight.totalRowsHeight = 0; | 286 spanningRowsHeight.totalRowsHeight = 0; |
| 265 for (unsigned row = 0; row < rowSpan; row++) { | 287 for (unsigned row = 0; row < rowSpan; row++) { |
| 266 unsigned actualRow = row + rowIndex; | 288 unsigned actualRow = row + rowIndex; |
| 267 spanningRowsHeight.rowHeight[row] = m_rowPos[actualRow + 1] - m_rowPos[a ctualRow] - borderSpacingForRow(actualRow); | 289 spanningRowsHeight.rowHeight[row] = m_rowPos[actualRow + 1] - m_rowPos[a ctualRow] - borderSpacingForRow(actualRow); |
| 290 if (!spanningRowsHeight.rowHeight[row]) { | |
| 291 if (rowHasOnlySpanningCells(actualRow)) { | |
| 292 spanningRowsHeight.rowWithOnlySpanningCells = true; | |
|
Julien - ping for review
2013/09/17 16:51:26
We can remove the inner branch (yay!):
spanningRo
a.suchit
2013/09/18 11:40:38
Done.
| |
| 293 } | |
| 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) | |
|
Julien - ping for review
2013/09/17 16:51:26
This function is never called.
a.suchit
2013/09/18 11:40:38
It is called by function "updateRowsHeightHavingOn
| |
| 426 { | |
| 427 ASSERT(row < m_grid.size()); | |
|
Julien - ping for review
2013/09/17 16:51:26
Again, duplicated by Vector::at().
a.suchit
2013/09/18 11:40:38
returned if row have more than vector size.
| |
| 428 ASSERT(rowHasOnlySpanningCells(row)); | |
| 429 | |
| 430 unsigned totalCols = m_grid[row].row.size(); | |
| 431 | |
| 432 if (!totalCols) | |
| 433 return 0; | |
| 434 | |
| 435 unsigned rowHeight = 0; | |
| 436 | |
| 437 for (unsigned col = 0; col < totalCols; col++) { | |
| 438 CellStruct rowSpanCell = cellAt(row, col); | |
| 439 if (rowSpanCell.cells.size() && rowSpanCell.cells[0]->rowSpan() > 1) | |
| 440 rowHeight = max(rowHeight, rowSpanCell.cells[0]->logicalHeightForRow Sizing() / rowSpanCell.cells[0]->rowSpan()); | |
| 441 } | |
| 442 | |
| 443 return rowHeight; | |
| 444 } | |
| 445 | |
| 446 void RenderTableSection::updateRowsHeightHavingOnlySpanningCells(RenderTableCell * cell, struct SpanningRowsHeight& spanningRowsHeight) | |
| 447 { | |
| 448 ASSERT(spanningRowsHeight.rowHeight.size()); | |
| 449 | |
| 450 int accumulatedPositionIncrease = 0; | |
| 451 const unsigned rowSpan = cell->rowSpan(); | |
| 452 const unsigned rowIndex = cell->rowIndex(); | |
| 453 | |
| 454 ASSERT(rowSpan == spanningRowsHeight.rowHeight.size()); | |
|
Julien - ping for review
2013/09/17 16:51:26
Nice!
| |
| 455 | |
| 456 for (unsigned row = 0; row < spanningRowsHeight.rowHeight.size(); row++) { | |
| 457 unsigned actualRow = row + rowIndex; | |
| 458 if (!spanningRowsHeight.rowHeight[row] && rowHasOnlySpanningCells(actual Row)) { | |
| 459 spanningRowsHeight.rowHeight[row] = calcRowHeightHavingOnlySpanningC ells(actualRow); | |
| 460 accumulatedPositionIncrease += spanningRowsHeight.rowHeight[row]; | |
| 461 } | |
| 462 m_rowPos[actualRow + 1] += accumulatedPositionIncrease; | |
| 463 } | |
| 464 | |
| 465 spanningRowsHeight.totalRowsHeight += accumulatedPositionIncrease; | |
| 466 } | |
| 467 | |
| 398 // Distribute rowSpan cell height in rows those comes in rowSpan cell based on t he ratio of row's height if | 468 // 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 | 469 // 1. RowSpan cell height is greater then the total height of rows in rowSpan ce ll |
| 400 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) | 470 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) |
| 401 { | 471 { |
| 402 ASSERT(rowSpanCells.size()); | 472 ASSERT(rowSpanCells.size()); |
| 403 | 473 |
| 404 // 'rowSpanCells' list is already sorted based on the cells rowIndex in asce nding order | 474 // '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. | 475 // Arrange row spanning cell in the order in which we need to process first. |
| 406 std::sort(rowSpanCells.begin(), rowSpanCells.end(), compareRowSpanCellsInHei ghtDistributionOrder); | 476 std::sort(rowSpanCells.begin(), rowSpanCells.end(), compareRowSpanCellsInHei ghtDistributionOrder); |
| 407 | 477 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 437 m_rowPos[row] += extraHeightToPropagate; | 507 m_rowPos[row] += extraHeightToPropagate; |
| 438 } | 508 } |
| 439 | 509 |
| 440 lastRowIndex = rowIndex; | 510 lastRowIndex = rowIndex; |
| 441 lastRowSpan = rowSpan; | 511 lastRowSpan = rowSpan; |
| 442 | 512 |
| 443 struct SpanningRowsHeight spanningRowsHeight; | 513 struct SpanningRowsHeight spanningRowsHeight; |
| 444 | 514 |
| 445 populateSpanningRowsHeightFromCell(cell, spanningRowsHeight); | 515 populateSpanningRowsHeightFromCell(cell, spanningRowsHeight); |
| 446 | 516 |
| 447 if (!spanningRowsHeight.totalRowsHeight || spanningRowsHeight.spanningCe llHeightIgnoringBorderSpacing <= spanningRowsHeight.totalRowsHeight) | 517 if (spanningRowsHeight.rowWithOnlySpanningCells) |
| 518 updateRowsHeightHavingOnlySpanningCells(cell, spanningRowsHeight); | |
| 519 | |
| 520 if (!spanningRowsHeight.totalRowsHeight || spanningRowsHeight.spanningCe llHeightIgnoringBorderSpacing <= spanningRowsHeight.totalRowsHeight) { | |
| 521 extraHeightToPropagate = m_rowPos[rowIndex + rowSpan] - originalBefo rePosition; | |
| 448 continue; | 522 continue; |
| 523 } | |
| 449 | 524 |
| 450 int totalPercent = 0; | 525 int totalPercent = 0; |
| 451 int totalAutoRowsHeight = 0; | 526 int totalAutoRowsHeight = 0; |
| 452 int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight; | 527 int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight; |
| 453 | 528 |
| 454 // FIXME: Inner spanning cell height should not change if it have fixed height when it's parent spanning cell | 529 // 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. | 530 // is distributing it's extra height in rows. |
| 456 | 531 |
| 457 // Calculate total percentage, total auto rows height and total rows hei ght except percent rows. | 532 // Calculate total percentage, total auto rows height and total rows hei ght except percent rows. |
| 458 for (unsigned row = rowIndex; row < spanningCellEndIndex; row++) { | 533 for (unsigned row = rowIndex; row < spanningCellEndIndex; row++) { |
| (...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1697 if (!style()->isLeftToRightDirection()) | 1772 if (!style()->isLeftToRightDirection()) |
| 1698 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); | 1773 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); |
| 1699 else | 1774 else |
| 1700 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); | 1775 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); |
| 1701 | 1776 |
| 1702 cell->setLogicalLocation(cellLocation); | 1777 cell->setLogicalLocation(cellLocation); |
| 1703 view()->addLayoutDelta(oldCellLocation - cell->location()); | 1778 view()->addLayoutDelta(oldCellLocation - cell->location()); |
| 1704 } | 1779 } |
| 1705 | 1780 |
| 1706 } // namespace WebCore | 1781 } // namespace WebCore |
| OLD | NEW |