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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
245 if (inColSpan) | 245 if (inColSpan) |
246 c.inColSpan = true; | 246 c.inColSpan = true; |
247 } | 247 } |
248 m_cCol++; | 248 m_cCol++; |
249 cSpan -= currentSpan; | 249 cSpan -= currentSpan; |
250 inColSpan = true; | 250 inColSpan = true; |
251 } | 251 } |
252 cell->setCol(table()->effColToCol(col)); | 252 cell->setCol(table()->effColToCol(col)); |
253 } | 253 } |
254 | 254 |
255 // Distribute rowSpan cell height in rows those comes in rowSpan cell based on t he ratio of row's height if | 255 // Getting height of rows in current rowSpan cell, getting total height of rows and adjusting rowSpan cell height with border spacing. |
256 // 1. RowSpan cell height is greater then the total height of rows in rowSpan ce ll | 256 int RenderTableSection::getRowsHeightInRowSpan(RenderTableCell* cell, int& expec tedTotalRowsHeight, Vector<int>& rowsHeight) |
257 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) | |
258 { | 257 { |
259 ASSERT(rowSpanCells.size()); | 258 ASSERT(cell); |
260 | |
261 // FIXME: For now, we handle the first rowspan cell in the table but this is wrong. | |
262 RenderTableCell* cell = rowSpanCells[0]; | |
263 | 259 |
264 unsigned rowSpan = cell->rowSpan(); | 260 unsigned rowSpan = cell->rowSpan(); |
265 unsigned rowIndex = cell->rowIndex(); | 261 unsigned rowIndex = cell->rowIndex(); |
266 int initialPos = m_rowPos[rowIndex + rowSpan]; | 262 int rowSpanCellHeight = cell->logicalHeightForRowSizing(); |
263 int totalRowsHeight = 0; | |
267 | 264 |
268 int totalRowsHeight = 0; | |
269 int rowSpanCellHeight = cell->logicalHeightForRowSizing(); | |
270 Vector<int> rowsHeight(rowSpan); | |
271 | |
272 // Getting height of rows in current rowSpan cell, getting total height of r ows and adjusting rowSpan cell height with border spacing. | |
273 for (unsigned row = 0; row < rowSpan; row++) { | 265 for (unsigned row = 0; row < rowSpan; row++) { |
274 unsigned actualRow = row + rowIndex; | 266 unsigned actualRow = row + rowIndex; |
275 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); |
276 totalRowsHeight += rowsHeight[row]; | 268 totalRowsHeight += rowsHeight[row]; |
277 rowSpanCellHeight -= borderSpacingForRow(actualRow); | 269 rowSpanCellHeight -= borderSpacingForRow(actualRow); |
278 } | 270 } |
279 rowSpanCellHeight += borderSpacingForRow(rowIndex + rowSpan - 1); | 271 rowSpanCellHeight += borderSpacingForRow(rowIndex + rowSpan - 1); |
280 | 272 |
281 if (!totalRowsHeight || rowSpanCellHeight <= totalRowsHeight) | 273 expectedTotalRowsHeight = rowSpanCellHeight; |
274 | |
275 return totalRowsHeight; | |
276 } | |
277 | |
278 // Calculate new logical height for the rows those comes in row spanning cell | |
279 // First we distribute the extra height in percentage rows | |
280 // Remaining extra height distributes to auto rows | |
281 // If auro rows are not present in the table then remaining extra height distrib utes in all rows except percentage rows | |
282 void RenderTableSection::recalcRowsHeightInRowSpanningCell(RenderTableCell* cell , int& expectedTotalRowsHeight, int& currTotalRowsHeight, Vector<int>& rowsHeigh t) | |
Julien - ping for review
2013/06/27 22:09:25
You pass |currTotalRowsHeight| as a reference, yet
| |
283 { | |
284 ASSERT(cell); | |
Julien - ping for review
2013/06/27 22:09:25
If you need those type of ASSERT, it means that yo
| |
285 ASSERT(currTotalRowsHeight); | |
286 ASSERT(expectedTotalRowsHeight > currTotalRowsHeight); | |
287 | |
288 if (expectedTotalRowsHeight <= currTotalRowsHeight) | |
289 return; | |
290 | |
291 unsigned rowSpan = cell->rowSpan(); | |
292 unsigned rowIndex = cell->rowIndex(); | |
293 int totalPercent = 0; | |
294 int totalAutoRowsHeight = 0; | |
295 int extraHeight = expectedTotalRowsHeight - currTotalRowsHeight; | |
Julien - ping for review
2013/06/27 22:09:25
I am sorry but I can't say what |expectedTotalRowH
| |
296 int totalRowsHeightExceptPercentRows = 0; | |
297 | |
298 ASSERT(rowsHeight.size() == rowSpan); | |
299 | |
300 // Calculate total percentage, total auto rows height and total rows height except percent rows. | |
301 totalRowsHeightExceptPercentRows = currTotalRowsHeight; | |
Julien - ping for review
2013/06/27 22:09:25
Why do we need 2 initialization of this variable?
| |
302 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | |
303 if (m_grid[row].logicalHeight.isPercent()) { | |
304 totalPercent += m_grid[row].logicalHeight.percent(); | |
305 totalRowsHeightExceptPercentRows -= rowsHeight[row - rowIndex]; | |
306 } else if (m_grid[row].logicalHeight.isAuto()) { | |
307 totalAutoRowsHeight += rowsHeight[row - rowIndex]; | |
308 } | |
309 } | |
310 | |
311 // If percent is 100 or more then whole extra height would be distribute in percent rows based on their percent ratios so that | |
312 // all percent rows would get its own share from extra height based on their percentages. | |
313 // Else total percent share would go to percent rows and remaining would be distributed in other rows. | |
314 if (100 <= totalPercent) { | |
315 int changedPosBy = 0; | |
316 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | |
317 if (m_grid[row].logicalHeight.isPercent()) | |
318 changedPosBy += extraHeight * m_grid[row].logicalHeight.percent( ) / totalPercent; | |
319 m_rowPos[row + 1] += changedPosBy; | |
320 } | |
321 | |
322 // Remaining height added in the last row under rowSpan cell | |
323 m_rowPos[rowIndex + rowSpan] += extraHeight - changedPosBy; | |
324 extraHeight = 0; | |
325 } else { | |
326 int changedPosBy = 0; | |
327 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | |
328 if (m_grid[row].logicalHeight.isPercent()) | |
329 changedPosBy += extraHeight * m_grid[row].logicalHeight.percent( ) / 100; | |
330 m_rowPos[row + 1] += changedPosBy; | |
331 } | |
332 | |
333 extraHeight = extraHeight - changedPosBy; | |
334 } | |
335 | |
336 if (extraHeight) { | |
337 ASSERT(totalRowsHeightExceptPercentRows); | |
338 | |
339 // If auto rows present in the table then remaining extra height would b e distribute in auto rows based on their height ratios so that | |
340 // all auto rows would get its own share from remaining extra height bas ed on their heights. | |
341 // Else remaining extra height would be distribute in all rows (except p ercent rows) based on their height ratios so that | |
342 // all rows would get its own share from remaining extra height based on their heights. | |
343 if (totalAutoRowsHeight) { | |
344 int changedPosBy = 0; | |
345 | |
346 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | |
347 if (m_grid[row].logicalHeight.isAuto()) | |
348 changedPosBy += (extraHeight * rowsHeight[row - rowIndex]) / totalAutoRowsHeight; | |
349 m_rowPos[row + 1] += changedPosBy; | |
350 } | |
351 // Remaining height added in the last row under rowSpan cell | |
352 m_rowPos[rowIndex + rowSpan] += extraHeight - changedPosBy; | |
353 } else if (totalRowsHeightExceptPercentRows) { | |
354 int changedPosBy = 0; | |
355 | |
356 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | |
357 if (!m_grid[row].logicalHeight.isPercent()) | |
358 changedPosBy += (extraHeight * rowsHeight[row - rowIndex]) / totalRowsHeightExceptPercentRows; | |
359 m_rowPos[row + 1] += changedPosBy; | |
360 } | |
361 // Remaining height added in the last row under rowSpan cell | |
362 m_rowPos[rowIndex + rowSpan] += extraHeight - changedPosBy; | |
363 } | |
364 } | |
365 } | |
366 | |
367 // Distribute rowSpan cell height in rows those comes in rowSpan cell based on t he ratio of row's height if | |
368 // 1. RowSpan cell height is greater then the total height of rows in rowSpan ce ll | |
369 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) | |
370 { | |
371 ASSERT(rowSpanCells.size()); | |
372 | |
373 // FIXME: For now, we handle the first rowspan cell in the table but this is wrong. | |
374 RenderTableCell* cell = rowSpanCells[0]; | |
375 | |
376 unsigned rowSpan = cell->rowSpan(); | |
377 unsigned rowIndex = cell->rowIndex(); | |
378 int initialPos = m_rowPos[rowIndex + rowSpan]; | |
379 | |
380 int expectedTotalRowsHeight = 0; | |
381 Vector<int> rowsHeight(rowSpan); | |
382 | |
383 int totalRowsHeight = getRowsHeightInRowSpan(cell, expectedTotalRowsHeight, rowsHeight); | |
384 | |
385 if (!totalRowsHeight || expectedTotalRowsHeight <= totalRowsHeight) | |
282 return; | 386 return; |
283 | 387 |
284 // Recalculating the height of rows based on rowSpan cell height if rowSpan cell height is more than total height of rows. | 388 // Recalculating the height of rows based on rowSpan cell height if rowSpan cell height is more than total height of rows. |
285 int remainingHeight = rowSpanCellHeight; | 389 recalcRowsHeightInRowSpanningCell(cell, expectedTotalRowsHeight, totalRowsHe ight, rowsHeight); |
286 | |
287 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | |
288 int rowHeight = (rowSpanCellHeight * rowsHeight[row - rowIndex]) / total RowsHeight; | |
289 remainingHeight -= rowHeight; | |
290 m_rowPos[row + 1] = m_rowPos[row] + rowHeight + borderSpacingForRow(row) ; | |
291 } | |
292 // Remaining height added in the last row under rowSpan cell | |
293 m_rowPos[rowIndex + rowSpan] += remainingHeight; | |
294 | 390 |
295 // Getting total changed height in the table | 391 // Getting total changed height in the table |
296 unsigned changedHeight = changedHeight = m_rowPos[rowIndex + rowSpan] - init ialPos; | 392 unsigned changedHeight = m_rowPos[rowIndex + rowSpan] - initialPos; |
297 | 393 |
298 if (changedHeight) { | 394 if (changedHeight) { |
299 unsigned totalRows = m_grid.size(); | 395 unsigned totalRows = m_grid.size(); |
300 | 396 |
301 // Apply changed height by rowSpan cells to rows present at the end of t he table | 397 // Apply changed height by rowSpan cells to rows present at the end of t he table |
302 for (unsigned row = rowIndex + rowSpan + 1; row <= totalRows; row++) | 398 for (unsigned row = rowIndex + rowSpan + 1; row <= totalRows; row++) |
303 m_rowPos[row] += changedHeight; | 399 m_rowPos[row] += changedHeight; |
304 } | 400 } |
305 } | 401 } |
306 | 402 |
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1521 info.addMember(logicalHeight, "logicalHeight"); | 1617 info.addMember(logicalHeight, "logicalHeight"); |
1522 } | 1618 } |
1523 | 1619 |
1524 void RenderTableSection::CellStruct::reportMemoryUsage(MemoryObjectInfo* memoryO bjectInfo) const | 1620 void RenderTableSection::CellStruct::reportMemoryUsage(MemoryObjectInfo* memoryO bjectInfo) const |
1525 { | 1621 { |
1526 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Rendering) ; | 1622 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Rendering) ; |
1527 info.addMember(cells, "cells"); | 1623 info.addMember(cells, "cells"); |
1528 } | 1624 } |
1529 | 1625 |
1530 } // namespace WebCore | 1626 } // namespace WebCore |
OLD | NEW |