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) | |
| 259 { | |
| 260 unsigned rowSpan = cell->rowSpan(); | |
| 261 unsigned rowIndex = cell->rowIndex(); | |
| 262 | |
| 263 spanningRowsHeight.expectedTotalRowsHeight = cell->logicalHeightForRowSizing (); | |
|
Julien - ping for review
2013/07/13 00:56:36
I have a hard time with this variable |expectedTot
a.suchit
2013/07/15 12:06:19
Done.
| |
| 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.expectedTotalRowsHeight -= borderSpacingForRow(actual Row); | |
| 272 } | |
| 273 spanningRowsHeight.expectedTotalRowsHeight += borderSpacingForRow(rowIndex + rowSpan - 1); | |
| 274 } | |
| 275 | |
| 276 void RenderTableSection::distributeExtraRowSpanHeightToPrecentRows(RenderTableCe ll* cell, int tableHeight, int totalPercent, int& extraRowSpanningHeight) | |
|
Julien - ping for review
2013/07/13 00:56:36
typo: PrecentRows
a.suchit
2013/07/15 12:06:19
Done.
| |
| 277 { | |
| 278 if (!extraRowSpanningHeight || !totalPercent) | |
| 279 return; | |
| 280 | |
| 281 unsigned rowSpan = cell->rowSpan(); | |
| 282 unsigned rowIndex = cell->rowIndex(); | |
|
Julien - ping for review
2013/07/13 00:56:36
const?
a.suchit
2013/07/15 12:06:19
Done.
| |
| 283 int percent = min(totalPercent, 100); | |
| 284 int remainingRowSpanningHeight = extraRowSpanningHeight; | |
| 285 | |
| 286 int changedPosBy = 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; | |
| 291 | |
| 292 changedPosBy += min(toAdd, remainingRowSpanningHeight); | |
| 293 remainingRowSpanningHeight -= toAdd; | |
| 294 percent -= m_grid[row].logicalHeight.percent(); | |
| 295 } | |
| 296 } | |
| 297 m_rowPos[row + 1] += changedPosBy; | |
| 298 } | |
| 299 | |
| 300 extraRowSpanningHeight = remainingRowSpanningHeight > 0 ? remainingRowSpanni ngHeight : 0; | |
|
Julien - ping for review
2013/07/13 00:56:36
If you need to do a max, please just use one inste
a.suchit
2013/07/15 12:06:19
changedPosBy += min(toAdd, remainingRowSpanningHei
| |
| 301 } | |
| 302 | |
| 303 void RenderTableSection::distributeExtraRowSpanHeightToAutoRows(RenderTableCell* cell, int totalAutoRowsHeight, int& extraRowSpanningHeight, Vector<int>& rowsHe ight) | |
| 304 { | |
| 305 if (!extraRowSpanningHeight || !totalAutoRowsHeight) | |
| 306 return; | |
| 307 | |
| 308 unsigned rowSpan = cell->rowSpan(); | |
| 309 unsigned rowIndex = cell->rowIndex(); | |
| 310 int changedPosBy = 0; | |
|
Julien - ping for review
2013/07/13 00:56:36
Not a fan of |changedPosBy|, how about |accumulate
a.suchit
2013/07/15 12:06:19
Done.
| |
| 311 | |
| 312 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | |
| 313 if (m_grid[row].logicalHeight.isAuto()) | |
| 314 changedPosBy += (extraRowSpanningHeight * rowsHeight[row - rowIndex] ) / totalAutoRowsHeight; | |
| 315 m_rowPos[row + 1] += changedPosBy; | |
| 316 } | |
| 317 // FIXME: Remaining height is very less which can not be distributed in rows so added it in the last spanning row | |
| 318 // and it save from assert used in caller. | |
| 319 m_rowPos[rowIndex + rowSpan] += extraRowSpanningHeight - changedPosBy; | |
| 320 | |
| 321 // Full height is distributed in auto rows so make it 0. | |
|
Julien - ping for review
2013/07/13 00:56:36
Remember my asking always about *why*, that's anot
a.suchit
2013/07/15 12:06:19
Done.
| |
| 322 extraRowSpanningHeight = 0; | |
| 323 } | |
| 324 | |
| 325 void RenderTableSection::distributeExtraRowSpanHeightToRemainingRows(RenderTable Cell* cell, int totalRemainingRowsHeight, int& extraRowSpanningHeight, Vector<in t>& rowsHeight) | |
| 326 { | |
| 327 if (!extraRowSpanningHeight || !totalRemainingRowsHeight) | |
| 328 return; | |
| 329 | |
| 330 unsigned rowSpan = cell->rowSpan(); | |
| 331 unsigned rowIndex = cell->rowIndex(); | |
| 332 int changedPosBy = 0; | |
| 333 | |
| 334 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | |
| 335 if (!m_grid[row].logicalHeight.isPercent()) | |
| 336 changedPosBy += (extraRowSpanningHeight * rowsHeight[row - rowIndex] ) / totalRemainingRowsHeight; | |
| 337 m_rowPos[row + 1] += changedPosBy; | |
| 338 } | |
| 339 // FIXME: Remaining height is very less which can not be distributed in rows so added it in the last spanning row | |
| 340 // and it save from assert used in caller. | |
| 341 m_rowPos[rowIndex + rowSpan] += extraRowSpanningHeight - changedPosBy; | |
| 342 | |
| 343 // Full height is distributed in rows so make it 0. | |
| 344 extraRowSpanningHeight = 0; | |
|
Julien - ping for review
2013/07/13 00:56:36
What guarantees that?
a.suchit
2013/07/15 12:06:19
We are distributing the whole extra row spanning h
| |
| 345 } | |
| 346 | |
| 258 // Distribute rowSpan cell height in rows those comes in rowSpan cell based on t he ratio of row's height if | 347 // 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 | 348 // 1. RowSpan cell height is greater then the total height of rows in rowSpan ce ll |
| 260 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) | 349 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) |
| 261 { | 350 { |
| 262 ASSERT(rowSpanCells.size()); | 351 ASSERT(rowSpanCells.size()); |
| 263 | 352 |
| 264 // FIXME: For now, we handle the first rowspan cell in the table but this is wrong. | 353 // FIXME: For now, we handle the first rowspan cell in the table but this is wrong. |
| 265 RenderTableCell* cell = rowSpanCells[0]; | 354 RenderTableCell* cell = rowSpanCells[0]; |
| 266 | 355 |
| 267 unsigned rowSpan = cell->rowSpan(); | 356 unsigned rowSpan = cell->rowSpan(); |
| 268 unsigned rowIndex = cell->rowIndex(); | |
| 269 int initialPos = m_rowPos[rowIndex + rowSpan]; | |
| 270 | 357 |
| 271 int totalRowsHeight = 0; | 358 struct SpanningRowsHeight spanningRowsHeight; |
| 272 int rowSpanCellHeight = cell->logicalHeightForRowSizing(); | |
| 273 Vector<int> rowsHeight(rowSpan); | |
| 274 | 359 |
| 275 // Getting height of rows in current rowSpan cell, getting total height of r ows and adjusting rowSpan cell height with border spacing. | 360 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 | 361 |
| 284 if (!totalRowsHeight || rowSpanCellHeight <= totalRowsHeight) | 362 if (!spanningRowsHeight.totalRowsHeight || spanningRowsHeight.expectedTotalR owsHeight <= spanningRowsHeight.totalRowsHeight) |
| 285 return; | 363 return; |
| 286 | 364 |
| 287 // Recalculating the height of rows based on rowSpan cell height if rowSpan cell height is more than total height of rows. | 365 unsigned rowIndex = cell->rowIndex(); |
| 288 int remainingHeight = rowSpanCellHeight; | 366 int totalPercent = 0; |
| 367 int totalAutoRowsHeight = 0; | |
| 368 int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight; | |
| 289 | 369 |
| 370 // Calculate total percentage, total auto rows height and total rows height except percent rows. | |
| 290 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | 371 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { |
| 291 int rowHeight = (rowSpanCellHeight * rowsHeight[row - rowIndex]) / total RowsHeight; | 372 if (m_grid[row].logicalHeight.isPercent()) { |
| 292 remainingHeight -= rowHeight; | 373 totalPercent += m_grid[row].logicalHeight.percent(); |
| 293 m_rowPos[row + 1] = m_rowPos[row] + rowHeight + borderSpacingForRow(row) ; | 374 totalRemainingRowsHeight -= spanningRowsHeight.rowHeight[row - rowIn dex]; |
| 375 } else if (m_grid[row].logicalHeight.isAuto()) { | |
| 376 totalAutoRowsHeight += spanningRowsHeight.rowHeight[row - rowIndex]; | |
| 377 } | |
| 294 } | 378 } |
| 295 // Remaining height added in the last row under rowSpan cell | 379 |
| 296 m_rowPos[rowIndex + rowSpan] += remainingHeight; | 380 int initialPos = m_rowPos[rowIndex + rowSpan]; |
| 381 int extraRowSpanningHeight = spanningRowsHeight.expectedTotalRowsHeight - sp anningRowsHeight.totalRowsHeight; | |
| 382 | |
| 383 distributeExtraRowSpanHeightToPrecentRows(cell, m_rowPos[m_grid.size()], tot alPercent, extraRowSpanningHeight); | |
| 384 distributeExtraRowSpanHeightToAutoRows(cell, totalAutoRowsHeight, extraRowSp anningHeight, spanningRowsHeight.rowHeight); | |
| 385 distributeExtraRowSpanHeightToRemainingRows(cell, totalRemainingRowsHeight, extraRowSpanningHeight, spanningRowsHeight.rowHeight); | |
| 386 | |
| 387 ASSERT(!extraRowSpanningHeight); | |
|
Julien - ping for review
2013/07/13 00:56:36
This ASSERT is neutered by distributeExtraRowSpanH
a.suchit
2013/07/15 12:06:19
Full height is distributed in the spanning rows by
| |
| 297 | 388 |
| 298 // Getting total changed height in the table | 389 // Getting total changed height in the table |
| 299 unsigned changedHeight = changedHeight = m_rowPos[rowIndex + rowSpan] - init ialPos; | 390 unsigned changedHeight = m_rowPos[rowIndex + rowSpan] - initialPos; |
| 300 | 391 |
| 301 if (changedHeight) { | 392 if (changedHeight) { |
| 302 unsigned totalRows = m_grid.size(); | 393 unsigned totalRows = m_grid.size(); |
| 303 | 394 |
| 304 // Apply changed height by rowSpan cells to rows present at the end of t he table | 395 // 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++) | 396 for (unsigned row = rowIndex + rowSpan + 1; row <= totalRows; row++) |
| 306 m_rowPos[row] += changedHeight; | 397 m_rowPos[row] += changedHeight; |
| 307 } | 398 } |
| 308 } | 399 } |
| 309 | 400 |
| (...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1544 info.addMember(logicalHeight, "logicalHeight"); | 1635 info.addMember(logicalHeight, "logicalHeight"); |
| 1545 } | 1636 } |
| 1546 | 1637 |
| 1547 void RenderTableSection::CellStruct::reportMemoryUsage(MemoryObjectInfo* memoryO bjectInfo) const | 1638 void RenderTableSection::CellStruct::reportMemoryUsage(MemoryObjectInfo* memoryO bjectInfo) const |
| 1548 { | 1639 { |
| 1549 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Rendering) ; | 1640 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Rendering) ; |
| 1550 info.addMember(cells, "cells"); | 1641 info.addMember(cells, "cells"); |
| 1551 } | 1642 } |
| 1552 | 1643 |
| 1553 } // namespace WebCore | 1644 } // namespace WebCore |
| OLD | NEW |