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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 if (inColSpan) | 247 if (inColSpan) |
| 248 c.inColSpan = true; | 248 c.inColSpan = true; |
| 249 } | 249 } |
| 250 m_cCol++; | 250 m_cCol++; |
| 251 cSpan -= currentSpan; | 251 cSpan -= currentSpan; |
| 252 inColSpan = true; | 252 inColSpan = true; |
| 253 } | 253 } |
| 254 cell->setCol(table()->effColToCol(col)); | 254 cell->setCol(table()->effColToCol(col)); |
| 255 } | 255 } |
| 256 | 256 |
| 257 // Distribute rowSpan cell height in rows those comes in rowSpan cell based on t he ratio of row's height if | 257 // Getting height of rows in current rowSpan cell, getting total height of rows and adjusting rowSpan cell height with border spacing. |
| 258 // 1. RowSpan cell height is greater then the total height of rows in rowSpan ce ll | 258 void RenderTableSection::getRowsHeightInRowSpan(RenderTableCell* cell, int& expe ctedTotalRowsHeight, int& totalRowsHeight, Vector<int>& rowsHeight) |
|
Julien - ping for review
2013/07/03 21:08:22
Really get a structure for the parameters you alwa
a.suchit
2013/07/13 00:49:56
Done.
| |
| 259 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) | |
| 260 { | 259 { |
| 261 ASSERT(rowSpanCells.size()); | |
| 262 | |
| 263 // FIXME: For now, we handle the first rowspan cell in the table but this is wrong. | |
| 264 RenderTableCell* cell = rowSpanCells[0]; | |
| 265 | |
| 266 unsigned rowSpan = cell->rowSpan(); | 260 unsigned rowSpan = cell->rowSpan(); |
| 267 unsigned rowIndex = cell->rowIndex(); | 261 unsigned rowIndex = cell->rowIndex(); |
| 268 int initialPos = m_rowPos[rowIndex + rowSpan]; | 262 int rowSpanCellHeight = cell->logicalHeightForRowSizing(); |
| 269 | 263 |
| 270 int totalRowsHeight = 0; | 264 totalRowsHeight = 0; |
| 271 int rowSpanCellHeight = cell->logicalHeightForRowSizing(); | |
| 272 Vector<int> rowsHeight(rowSpan); | |
| 273 | |
| 274 // Getting height of rows in current rowSpan cell, getting total height of r ows and adjusting rowSpan cell height with border spacing. | |
| 275 for (unsigned row = 0; row < rowSpan; row++) { | 265 for (unsigned row = 0; row < rowSpan; row++) { |
| 276 unsigned actualRow = row + rowIndex; | 266 unsigned actualRow = row + rowIndex; |
| 277 rowsHeight[row] = m_rowPos[actualRow + 1] - m_rowPos[actualRow] - border SpacingForRow(actualRow); | 267 rowsHeight[row] = m_rowPos[actualRow + 1] - m_rowPos[actualRow] - border SpacingForRow(actualRow); |
| 278 totalRowsHeight += rowsHeight[row]; | 268 totalRowsHeight += rowsHeight[row]; |
| 279 rowSpanCellHeight -= borderSpacingForRow(actualRow); | 269 rowSpanCellHeight -= borderSpacingForRow(actualRow); |
| 280 } | 270 } |
| 281 rowSpanCellHeight += borderSpacingForRow(rowIndex + rowSpan - 1); | 271 rowSpanCellHeight += borderSpacingForRow(rowIndex + rowSpan - 1); |
| 282 | 272 |
| 283 if (!totalRowsHeight || rowSpanCellHeight <= totalRowsHeight) | 273 expectedTotalRowsHeight = rowSpanCellHeight; |
|
Julien - ping for review
2013/07/03 21:08:22
Why do we need |rowSpanCellHeight| then?
a.suchit
2013/07/13 00:49:56
Changed
| |
| 274 } | |
| 275 | |
| 276 // If percent is more than 100 then whole extra height would be distribute in pe rcent rows based on their percent ratios so that | |
| 277 // all percent rows would get additional height from extra rowspanning height. | |
| 278 // Else specified percent (totalPercent) of extra height would be distributed in percent rows and | |
| 279 // remaining would be distributed in other rows. | |
| 280 void RenderTableSection::distributeExtraRowSpanHeightToPrecentRows(RenderTableCe ll* cell, int totalPercent, int& extraRowSpanningHeight, Vector<int>& rowsHeight ) | |
|
Julien - ping for review
2013/07/03 21:08:22
|cell| is not modified (and is not expected to be)
| |
| 281 { | |
| 282 if (!extraRowSpanningHeight || !totalPercent) | |
| 284 return; | 283 return; |
| 285 | 284 |
| 286 // Recalculating the height of rows based on rowSpan cell height if rowSpan cell height is more than total height of rows. | 285 unsigned rowSpan = cell->rowSpan(); |
| 287 int remainingHeight = rowSpanCellHeight; | 286 unsigned rowIndex = cell->rowIndex(); |
| 287 | |
| 288 if (100 < totalPercent) { | |
|
Julien - ping for review
2013/07/03 21:08:22
You never answered about this and I am pretty much
a.suchit
2013/07/13 00:49:56
Removed
| |
| 289 int changedPosBy = 0; | |
| 290 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | |
| 291 if (m_grid[row].logicalHeight.isPercent()) | |
| 292 changedPosBy += extraRowSpanningHeight * m_grid[row].logicalHeig ht.percent() / totalPercent; | |
| 293 m_rowPos[row + 1] += changedPosBy; | |
| 294 } | |
| 295 | |
| 296 // Remaining height added in the last row under rowSpan cell | |
| 297 m_rowPos[rowIndex + rowSpan] += extraRowSpanningHeight - changedPosBy; | |
| 298 extraRowSpanningHeight -= changedPosBy; | |
| 299 } else { | |
| 300 int changedPosBy = 0; | |
| 301 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | |
| 302 if (m_grid[row].logicalHeight.isPercent()) | |
| 303 changedPosBy += extraRowSpanningHeight * m_grid[row].logicalHeig ht.percent() / 100; | |
|
Julien - ping for review
2013/07/03 21:08:22
This code is backwards if you look at what we do i
a.suchit
2013/07/13 00:49:56
Done.
| |
| 304 m_rowPos[row + 1] += changedPosBy; | |
| 305 } | |
| 306 | |
| 307 extraRowSpanningHeight -= changedPosBy; | |
| 308 } | |
| 309 } | |
| 310 | |
| 311 // If auto rows are present then whole extra height would be distribute in auto rows based on their height ratios so that | |
| 312 // all auto rows would get its own share from extra height. | |
| 313 // Else extra height would be distributed in other rows. | |
|
Julien - ping for review
2013/07/03 21:08:22
This line is useless. As a whole, your comments ar
a.suchit
2013/07/13 00:49:56
Done.
| |
| 314 void RenderTableSection::distributeExtraRowSpanHeightToAutoRows(RenderTableCell* cell, int totalAutoRowsHeight, int& extraRowSpanningHeight, Vector<int>& rowsHe ight) | |
| 315 { | |
| 316 if (!extraRowSpanningHeight || !totalAutoRowsHeight) | |
| 317 return; | |
| 318 | |
| 319 unsigned rowSpan = cell->rowSpan(); | |
| 320 unsigned rowIndex = cell->rowIndex(); | |
| 321 int changedPosBy = 0; | |
| 288 | 322 |
| 289 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | 323 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { |
| 290 int rowHeight = (rowSpanCellHeight * rowsHeight[row - rowIndex]) / total RowsHeight; | 324 if (m_grid[row].logicalHeight.isAuto()) |
| 291 remainingHeight -= rowHeight; | 325 changedPosBy += (extraRowSpanningHeight * rowsHeight[row - rowIndex] ) / totalAutoRowsHeight; |
| 292 m_rowPos[row + 1] = m_rowPos[row] + rowHeight + borderSpacingForRow(row) ; | 326 m_rowPos[row + 1] += changedPosBy; |
| 293 } | 327 } |
| 294 // Remaining height added in the last row under rowSpan cell | 328 // Remaining height added in the last row under rowSpan cell |
|
Julien - ping for review
2013/07/03 21:08:22
This comment is also a *what* comment, I would rat
a.suchit
2013/07/13 00:49:56
Done.
| |
| 295 m_rowPos[rowIndex + rowSpan] += remainingHeight; | 329 m_rowPos[rowIndex + rowSpan] += extraRowSpanningHeight - changedPosBy; |
| 330 | |
| 331 extraRowSpanningHeight -= changedPosBy; | |
| 332 } | |
| 333 // Whole extra height would be distribute in remaining rows based on their heig ht ratios so that | |
|
Julien - ping for review
2013/07/03 21:08:22
Again, that's a what comment. Here you could expla
a.suchit
2013/07/13 00:49:56
Done.
| |
| 334 // all rows would get its own share from extra height. | |
| 335 void RenderTableSection::distributeExtraRowSpanHeightToRemainingRows(RenderTable Cell* cell, int totalRemainingRowsHeight, int& extraRowSpanningHeight, Vector<in t>& rowsHeight) | |
| 336 { | |
| 337 if (!extraRowSpanningHeight || !totalRemainingRowsHeight) | |
| 338 return; | |
| 339 | |
| 340 unsigned rowSpan = cell->rowSpan(); | |
| 341 unsigned rowIndex = cell->rowIndex(); | |
| 342 int changedPosBy = 0; | |
| 343 | |
| 344 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | |
| 345 if (!m_grid[row].logicalHeight.isPercent()) | |
| 346 changedPosBy += (extraRowSpanningHeight * rowsHeight[row - rowIndex] ) / totalRemainingRowsHeight; | |
| 347 m_rowPos[row + 1] += changedPosBy; | |
| 348 } | |
| 349 // Remaining height added in the last row under rowSpan cell | |
| 350 m_rowPos[rowIndex + rowSpan] += extraRowSpanningHeight - changedPosBy; | |
| 351 | |
| 352 extraRowSpanningHeight -= changedPosBy; | |
| 353 } | |
| 354 | |
| 355 // Distribute rowSpan cell height in rows those comes in rowSpan cell based on t he ratio of row's height if | |
| 356 // 1. RowSpan cell height is greater then the total height of rows in rowSpan ce ll | |
| 357 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) | |
| 358 { | |
| 359 ASSERT(rowSpanCells.size()); | |
| 360 | |
| 361 // FIXME: For now, we handle the first rowspan cell in the table but this is wrong. | |
| 362 RenderTableCell* cell = rowSpanCells[0]; | |
| 363 | |
| 364 unsigned rowSpan = cell->rowSpan(); | |
| 365 | |
| 366 int expectedTotalRowsHeight = 0; | |
| 367 Vector<int> rowsHeight(rowSpan); | |
| 368 int totalRowsHeight = 0; | |
| 369 | |
| 370 getRowsHeightInRowSpan(cell, expectedTotalRowsHeight, totalRowsHeight, rowsH eight); | |
| 371 | |
| 372 if (!totalRowsHeight || expectedTotalRowsHeight <= totalRowsHeight) | |
| 373 return; | |
| 374 | |
| 375 unsigned rowIndex = cell->rowIndex(); | |
| 376 int totalPercent = 0; | |
| 377 int totalAutoRowsHeight = 0; | |
| 378 int totalRemainingRowsHeight = totalRowsHeight; | |
| 379 | |
| 380 // Calculate total percentage, total auto rows height and total rows height except percent rows. | |
| 381 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | |
| 382 if (m_grid[row].logicalHeight.isPercent()) { | |
| 383 totalPercent += m_grid[row].logicalHeight.percent(); | |
| 384 totalRemainingRowsHeight -= rowsHeight[row - rowIndex]; | |
| 385 } else if (m_grid[row].logicalHeight.isAuto()) { | |
| 386 totalAutoRowsHeight += rowsHeight[row - rowIndex]; | |
| 387 } | |
| 388 } | |
| 389 | |
| 390 int initialPos = m_rowPos[rowIndex + rowSpan]; | |
| 391 int extraRowSpanningHeight = expectedTotalRowsHeight - totalRowsHeight; | |
| 392 | |
| 393 distributeExtraRowSpanHeightToPrecentRows(cell, totalPercent, extraRowSpanni ngHeight, rowsHeight); | |
| 394 distributeExtraRowSpanHeightToAutoRows(cell, totalAutoRowsHeight, extraRowSp anningHeight, rowsHeight); | |
| 395 distributeExtraRowSpanHeightToRemainingRows(cell, totalRemainingRowsHeight, extraRowSpanningHeight, rowsHeight); | |
| 396 | |
| 397 ASSERT(!extraRowSpanningHeight); | |
| 296 | 398 |
| 297 // Getting total changed height in the table | 399 // Getting total changed height in the table |
| 298 unsigned changedHeight = changedHeight = m_rowPos[rowIndex + rowSpan] - init ialPos; | 400 unsigned changedHeight = m_rowPos[rowIndex + rowSpan] - initialPos; |
| 299 | 401 |
| 300 if (changedHeight) { | 402 if (changedHeight) { |
| 301 unsigned totalRows = m_grid.size(); | 403 unsigned totalRows = m_grid.size(); |
| 302 | 404 |
| 303 // Apply changed height by rowSpan cells to rows present at the end of t he table | 405 // Apply changed height by rowSpan cells to rows present at the end of t he table |
| 304 for (unsigned row = rowIndex + rowSpan + 1; row <= totalRows; row++) | 406 for (unsigned row = rowIndex + rowSpan + 1; row <= totalRows; row++) |
| 305 m_rowPos[row] += changedHeight; | 407 m_rowPos[row] += changedHeight; |
| 306 } | 408 } |
| 307 } | 409 } |
| 308 | 410 |
| (...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1544 info.addMember(logicalHeight, "logicalHeight"); | 1646 info.addMember(logicalHeight, "logicalHeight"); |
| 1545 } | 1647 } |
| 1546 | 1648 |
| 1547 void RenderTableSection::CellStruct::reportMemoryUsage(MemoryObjectInfo* memoryO bjectInfo) const | 1649 void RenderTableSection::CellStruct::reportMemoryUsage(MemoryObjectInfo* memoryO bjectInfo) const |
| 1548 { | 1650 { |
| 1549 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Rendering) ; | 1651 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Rendering) ; |
| 1550 info.addMember(cells, "cells"); | 1652 info.addMember(cells, "cells"); |
| 1551 } | 1653 } |
| 1552 | 1654 |
| 1553 } // namespace WebCore | 1655 } // namespace WebCore |
| OLD | NEW |