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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 if (inColSpan) | 248 if (inColSpan) |
| 249 c.inColSpan = true; | 249 c.inColSpan = true; |
| 250 } | 250 } |
| 251 m_cCol++; | 251 m_cCol++; |
| 252 cSpan -= currentSpan; | 252 cSpan -= currentSpan; |
| 253 inColSpan = true; | 253 inColSpan = true; |
| 254 } | 254 } |
| 255 cell->setCol(table()->effColToCol(col)); | 255 cell->setCol(table()->effColToCol(col)); |
| 256 } | 256 } |
| 257 | 257 |
| 258 void RenderTableSection::calcRowsHeightInRowSpan(RenderTableCell* cell, struct S panningRowsHeight& spanningRowsHeight) | |
|
Julien - ping for review
2013/07/16 17:22:13
Not a huge fan of the name (calc is an abbreviatio
a.suchit
2013/07/18 17:05:32
Done.
| |
| 259 { | |
| 260 const unsigned rowSpan = cell->rowSpan(); | |
| 261 const unsigned rowIndex = cell->rowIndex(); | |
| 262 | |
| 263 spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing = cell->logicalHe ightForRowSizing(); | |
| 264 | |
| 265 spanningRowsHeight.rowHeight.resize(rowSpan); | |
| 266 spanningRowsHeight.totalRowsHeight = 0; | |
| 267 for (unsigned row = 0; row < rowSpan; row++) { | |
| 268 unsigned actualRow = row + rowIndex; | |
| 269 spanningRowsHeight.rowHeight[row] = m_rowPos[actualRow + 1] - m_rowPos[a ctualRow] - borderSpacingForRow(actualRow); | |
| 270 spanningRowsHeight.totalRowsHeight += spanningRowsHeight.rowHeight[row]; | |
| 271 spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing -= borderSpac ingForRow(actualRow); | |
| 272 } | |
| 273 spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing += borderSpacingF orRow(rowIndex + rowSpan - 1); | |
|
Julien - ping for review
2013/07/16 17:22:13
This is typically the line of code that would requ
a.suchit
2013/07/18 17:05:32
Done.
| |
| 274 } | |
| 275 | |
| 276 void RenderTableSection::distributeExtraRowSpanHeightToPercentRows(RenderTableCe ll* cell, int tableHeight, int totalPercent, int& extraRowSpanningHeight) | |
| 277 { | |
| 278 if (!extraRowSpanningHeight || !totalPercent) | |
| 279 return; | |
| 280 | |
| 281 const unsigned rowSpan = cell->rowSpan(); | |
| 282 const unsigned rowIndex = cell->rowIndex(); | |
| 283 int percent = min(totalPercent, 100); | |
| 284 int remainingRowSpanningHeight = extraRowSpanningHeight; | |
|
Julien - ping for review
2013/07/16 17:22:13
tableHeight + extraRowSpanningHeight is the only r
a.suchit
2013/07/18 17:05:32
Done.
| |
| 285 | |
| 286 int accumulatedPositionIncrease = 0; | |
| 287 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | |
| 288 if (percent > 0 && remainingRowSpanningHeight > 0) { | |
| 289 if (m_grid[row].logicalHeight.isPercent()) { | |
| 290 int toAdd = (tableHeight + extraRowSpanningHeight) * m_grid[row] .logicalHeight.percent() / 100; | |
|
Julien - ping for review
2013/07/16 17:22:13
The whole algorithm really need some explanations,
| |
| 291 | |
| 292 toAdd = min(toAdd, remainingRowSpanningHeight); | |
| 293 accumulatedPositionIncrease += toAdd; | |
| 294 remainingRowSpanningHeight -= toAdd; | |
| 295 percent -= m_grid[row].logicalHeight.percent(); | |
| 296 } | |
| 297 } | |
| 298 m_rowPos[row + 1] += accumulatedPositionIncrease; | |
| 299 } | |
| 300 | |
| 301 extraRowSpanningHeight = remainingRowSpanningHeight; | |
| 302 } | |
| 303 | |
| 304 void RenderTableSection::distributeExtraRowSpanHeightToAutoRows(RenderTableCell* cell, int totalAutoRowsHeight, int& extraRowSpanningHeight, Vector<int>& rowsHe ight) | |
| 305 { | |
| 306 if (!extraRowSpanningHeight || !totalAutoRowsHeight) | |
| 307 return; | |
| 308 | |
| 309 const unsigned rowSpan = cell->rowSpan(); | |
| 310 const unsigned rowIndex = cell->rowIndex(); | |
| 311 int accumulatedPositionIncrease = 0; | |
| 312 | |
| 313 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | |
| 314 if (m_grid[row].logicalHeight.isAuto()) | |
| 315 accumulatedPositionIncrease += (extraRowSpanningHeight * rowsHeight[ row - rowIndex]) / totalAutoRowsHeight; | |
| 316 m_rowPos[row + 1] += accumulatedPositionIncrease; | |
| 317 } | |
| 318 | |
| 319 extraRowSpanningHeight -= accumulatedPositionIncrease; | |
| 320 | |
| 321 // FIXME: In some cases extraRowSpanning height is remain which is very smal l and cannot be again distributed in | |
| 322 // spanning rows. So this remaining height added to last spanning row to mai ntain the spanning cell height and | |
| 323 // set extra row spanning height to 0. | |
| 324 // Value should be round properly in the algorithm. | |
| 325 m_rowPos[rowIndex + rowSpan] += extraRowSpanningHeight; | |
| 326 extraRowSpanningHeight = 0; | |
| 327 } | |
| 328 | |
| 329 void RenderTableSection::distributeExtraRowSpanHeightToRemainingRows(RenderTable Cell* cell, int totalRemainingRowsHeight, int& extraRowSpanningHeight, Vector<in t>& rowsHeight) | |
| 330 { | |
| 331 if (!extraRowSpanningHeight || !totalRemainingRowsHeight) | |
| 332 return; | |
| 333 | |
| 334 const unsigned rowSpan = cell->rowSpan(); | |
| 335 const unsigned rowIndex = cell->rowIndex(); | |
| 336 int accumulatedPositionIncrease = 0; | |
| 337 | |
| 338 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | |
| 339 if (!m_grid[row].logicalHeight.isPercent()) | |
| 340 accumulatedPositionIncrease += (extraRowSpanningHeight * rowsHeight[ row - rowIndex]) / totalRemainingRowsHeight; | |
| 341 m_rowPos[row + 1] += accumulatedPositionIncrease; | |
| 342 } | |
| 343 | |
| 344 extraRowSpanningHeight -= accumulatedPositionIncrease; | |
| 345 | |
| 346 // FIXME: In some cases extraRowSpanning height is remain which is very smal l and cannot be again distributed in | |
| 347 // spanning rows. So this remaining height added to last spanning row to mai ntain the spanning cell height and | |
| 348 // set extra row spanning height to 0. | |
| 349 // Value should be round properly in the algorithm. | |
|
Julien - ping for review
2013/07/16 17:22:13
Can't we do the rounding properly instead of swipi
a.suchit
2013/07/18 17:05:32
Done.
| |
| 350 m_rowPos[rowIndex + rowSpan] += extraRowSpanningHeight; | |
| 351 extraRowSpanningHeight = 0; | |
| 352 } | |
| 353 | |
| 258 // Distribute rowSpan cell height in rows those comes in rowSpan cell based on t he ratio of row's height if | 354 // Distribute rowSpan cell height in rows those comes in rowSpan cell based on t he ratio of row's height if |
| 259 // 1. RowSpan cell height is greater then the total height of rows in rowSpan ce ll | 355 // 1. RowSpan cell height is greater then the total height of rows in rowSpan ce ll |
| 260 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) | 356 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) |
| 261 { | 357 { |
| 262 ASSERT(rowSpanCells.size()); | 358 ASSERT(rowSpanCells.size()); |
| 263 | 359 |
| 264 // FIXME: For now, we handle the first rowspan cell in the table but this is wrong. | 360 // FIXME: For now, we handle the first rowspan cell in the table but this is wrong. |
| 265 RenderTableCell* cell = rowSpanCells[0]; | 361 RenderTableCell* cell = rowSpanCells[0]; |
| 266 | 362 |
| 267 unsigned rowSpan = cell->rowSpan(); | 363 unsigned rowSpan = cell->rowSpan(); |
| 268 unsigned rowIndex = cell->rowIndex(); | |
| 269 int initialPos = m_rowPos[rowIndex + rowSpan]; | |
| 270 | 364 |
| 271 int totalRowsHeight = 0; | 365 struct SpanningRowsHeight spanningRowsHeight; |
| 272 int rowSpanCellHeight = cell->logicalHeightForRowSizing(); | |
| 273 Vector<int> rowsHeight(rowSpan); | |
| 274 | 366 |
| 275 // Getting height of rows in current rowSpan cell, getting total height of r ows and adjusting rowSpan cell height with border spacing. | 367 calcRowsHeightInRowSpan(cell, spanningRowsHeight); |
| 276 for (unsigned row = 0; row < rowSpan; row++) { | |
| 277 unsigned actualRow = row + rowIndex; | |
| 278 rowsHeight[row] = m_rowPos[actualRow + 1] - m_rowPos[actualRow] - border SpacingForRow(actualRow); | |
| 279 totalRowsHeight += rowsHeight[row]; | |
| 280 rowSpanCellHeight -= borderSpacingForRow(actualRow); | |
| 281 } | |
| 282 rowSpanCellHeight += borderSpacingForRow(rowIndex + rowSpan - 1); | |
| 283 | 368 |
| 284 if (!totalRowsHeight || rowSpanCellHeight <= totalRowsHeight) | 369 if (!spanningRowsHeight.totalRowsHeight || spanningRowsHeight.spanningCellHe ightIgnoringBorderSpacing <= spanningRowsHeight.totalRowsHeight) |
| 285 return; | 370 return; |
| 286 | 371 |
| 287 // Recalculating the height of rows based on rowSpan cell height if rowSpan cell height is more than total height of rows. | 372 unsigned rowIndex = cell->rowIndex(); |
| 288 int remainingHeight = rowSpanCellHeight; | 373 int totalPercent = 0; |
| 374 int totalAutoRowsHeight = 0; | |
| 375 int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight; | |
| 289 | 376 |
| 377 // Calculate total percentage, total auto rows height and total rows height except percent rows. | |
| 290 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | 378 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { |
| 291 int rowHeight = (rowSpanCellHeight * rowsHeight[row - rowIndex]) / total RowsHeight; | 379 if (m_grid[row].logicalHeight.isPercent()) { |
| 292 remainingHeight -= rowHeight; | 380 totalPercent += m_grid[row].logicalHeight.percent(); |
| 293 m_rowPos[row + 1] = m_rowPos[row] + rowHeight + borderSpacingForRow(row) ; | 381 totalRemainingRowsHeight -= spanningRowsHeight.rowHeight[row - rowIn dex]; |
| 382 } else if (m_grid[row].logicalHeight.isAuto()) { | |
| 383 totalAutoRowsHeight += spanningRowsHeight.rowHeight[row - rowIndex]; | |
| 384 } | |
| 294 } | 385 } |
| 295 // Remaining height added in the last row under rowSpan cell | 386 |
| 296 m_rowPos[rowIndex + rowSpan] += remainingHeight; | 387 int initialPos = m_rowPos[rowIndex + rowSpan]; |
| 388 int extraRowSpanningHeight = spanningRowsHeight.spanningCellHeightIgnoringBo rderSpacing - spanningRowsHeight.totalRowsHeight; | |
| 389 | |
| 390 distributeExtraRowSpanHeightToPercentRows(cell, m_rowPos[m_grid.size()], tot alPercent, extraRowSpanningHeight); | |
| 391 distributeExtraRowSpanHeightToAutoRows(cell, totalAutoRowsHeight, extraRowSp anningHeight, spanningRowsHeight.rowHeight); | |
| 392 distributeExtraRowSpanHeightToRemainingRows(cell, totalRemainingRowsHeight, extraRowSpanningHeight, spanningRowsHeight.rowHeight); | |
| 297 | 393 |
|
Julien - ping for review
2013/07/16 17:22:13
The ASSERT was really important, what I wasn't hap
a.suchit
2013/07/18 17:05:32
Done.
| |
| 298 // Getting total changed height in the table | 394 // Getting total changed height in the table |
| 299 unsigned changedHeight = changedHeight = m_rowPos[rowIndex + rowSpan] - init ialPos; | 395 unsigned changedHeight = m_rowPos[rowIndex + rowSpan] - initialPos; |
| 300 | 396 |
| 301 if (changedHeight) { | 397 if (changedHeight) { |
| 302 unsigned totalRows = m_grid.size(); | 398 unsigned totalRows = m_grid.size(); |
| 303 | 399 |
| 304 // Apply changed height by rowSpan cells to rows present at the end of t he table | 400 // Apply changed height by rowSpan cells to rows present at the end of t he table |
| 305 for (unsigned row = rowIndex + rowSpan + 1; row <= totalRows; row++) | 401 for (unsigned row = rowIndex + rowSpan + 1; row <= totalRows; row++) |
| 306 m_rowPos[row] += changedHeight; | 402 m_rowPos[row] += changedHeight; |
| 307 } | 403 } |
| 308 } | 404 } |
| 309 | 405 |
| (...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1544 info.addMember(logicalHeight, "logicalHeight"); | 1640 info.addMember(logicalHeight, "logicalHeight"); |
| 1545 } | 1641 } |
| 1546 | 1642 |
| 1547 void RenderTableSection::CellStruct::reportMemoryUsage(MemoryObjectInfo* memoryO bjectInfo) const | 1643 void RenderTableSection::CellStruct::reportMemoryUsage(MemoryObjectInfo* memoryO bjectInfo) const |
| 1548 { | 1644 { |
| 1549 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Rendering) ; | 1645 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Rendering) ; |
| 1550 info.addMember(cells, "cells"); | 1646 info.addMember(cells, "cells"); |
| 1551 } | 1647 } |
| 1552 | 1648 |
| 1553 } // namespace WebCore | 1649 } // namespace WebCore |
| OLD | NEW |