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) |
Julien - ping for review
2013/07/02 02:16:18
This function starts to smell badly as you now hav
a.suchit
2013/07/03 12:59:57
Done.
| |
257 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) | |
258 { | 257 { |
259 ASSERT(rowSpanCells.size()); | |
260 | |
261 // FIXME: For now, we handle the first rowspan cell in the table but this is wrong. | |
262 RenderTableCell* cell = rowSpanCells[0]; | |
263 | |
264 unsigned rowSpan = cell->rowSpan(); | 258 unsigned rowSpan = cell->rowSpan(); |
265 unsigned rowIndex = cell->rowIndex(); | 259 unsigned rowIndex = cell->rowIndex(); |
266 int initialPos = m_rowPos[rowIndex + rowSpan]; | 260 int rowSpanCellHeight = cell->logicalHeightForRowSizing(); |
261 int totalRowsHeight = 0; | |
267 | 262 |
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++) { | 263 for (unsigned row = 0; row < rowSpan; row++) { |
274 unsigned actualRow = row + rowIndex; | 264 unsigned actualRow = row + rowIndex; |
275 rowsHeight[row] = m_rowPos[actualRow + 1] - m_rowPos[actualRow] - border SpacingForRow(actualRow); | 265 rowsHeight[row] = m_rowPos[actualRow + 1] - m_rowPos[actualRow] - border SpacingForRow(actualRow); |
276 totalRowsHeight += rowsHeight[row]; | 266 totalRowsHeight += rowsHeight[row]; |
277 rowSpanCellHeight -= borderSpacingForRow(actualRow); | 267 rowSpanCellHeight -= borderSpacingForRow(actualRow); |
278 } | 268 } |
279 rowSpanCellHeight += borderSpacingForRow(rowIndex + rowSpan - 1); | 269 rowSpanCellHeight += borderSpacingForRow(rowIndex + rowSpan - 1); |
280 | 270 |
281 if (!totalRowsHeight || rowSpanCellHeight <= totalRowsHeight) | 271 expectedTotalRowsHeight = rowSpanCellHeight; |
272 | |
273 return totalRowsHeight; | |
274 } | |
275 | |
276 // If percent is 100 or more then whole extra height would be distribute in perc ent rows based on their percent ratios so that | |
277 // all percent rows would get its own share from extra height based on their per centages. | |
278 // Else total percent share would go to percent rows and remaining would be dist ributed in other rows. | |
Julien - ping for review
2013/07/02 02:16:18
I read this several times and failed to understand
| |
279 void RenderTableSection::distributeExtraRowSpanHeightToPrecentRows(RenderTableCe ll* cell, int totalPercent, int& extraRowSpanningHeight, Vector<int>& rowsHeight ) | |
280 { | |
281 if (!extraRowSpanningHeight || !totalPercent) | |
282 return; | 282 return; |
283 | 283 |
284 // Recalculating the height of rows based on rowSpan cell height if rowSpan cell height is more than total height of rows. | 284 unsigned rowSpan = cell->rowSpan(); |
285 int remainingHeight = rowSpanCellHeight; | 285 unsigned rowIndex = cell->rowIndex(); |
286 | |
287 if (100 <= totalPercent) { | |
Julien - ping for review
2013/07/02 02:16:18
I had a hard time understanding this check and bel
a.suchit
2013/07/03 12:59:57
At this point, total table height is not fixed so
Julien - ping for review
2013/07/03 21:08:22
I am still not totally convinced this is correct t
| |
288 int changedPosBy = 0; | |
289 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | |
290 if (m_grid[row].logicalHeight.isPercent()) | |
291 changedPosBy += extraRowSpanningHeight * m_grid[row].logicalHeig ht.percent() / totalPercent; | |
292 m_rowPos[row + 1] += changedPosBy; | |
293 } | |
294 | |
295 // Remaining height added in the last row under rowSpan cell | |
296 m_rowPos[rowIndex + rowSpan] += extraRowSpanningHeight - changedPosBy; | |
297 extraRowSpanningHeight = 0; | |
Julien - ping for review
2013/07/02 02:16:18
Again, it is WRONG to clear extraRowSpanningHeight
a.suchit
2013/07/03 12:59:57
Done.
| |
298 } else { | |
299 int changedPosBy = 0; | |
300 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | |
301 if (m_grid[row].logicalHeight.isPercent()) | |
302 changedPosBy += extraRowSpanningHeight * m_grid[row].logicalHeig ht.percent() / 100; | |
303 m_rowPos[row + 1] += changedPosBy; | |
304 } | |
305 | |
306 extraRowSpanningHeight -= changedPosBy; | |
307 } | |
308 } | |
309 | |
310 // If auto rows are present then whole extra height would be distribute in auto rows based on their height ratios so that | |
311 // all auto rows would get its own share from extra height. | |
312 // Else extra height would be distributed in other rows. | |
313 void RenderTableSection::distributeExtraRowSpanHeightToAutoRows(RenderTableCell* cell, int totalAutoRowsHeight, int& extraRowSpanningHeight, Vector<int>& rowsHe ight) | |
314 { | |
315 if (!extraRowSpanningHeight || !totalAutoRowsHeight) | |
316 return; | |
317 | |
318 unsigned rowSpan = cell->rowSpan(); | |
319 unsigned rowIndex = cell->rowIndex(); | |
320 int changedPosBy = 0; | |
286 | 321 |
287 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | 322 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { |
288 int rowHeight = (rowSpanCellHeight * rowsHeight[row - rowIndex]) / total RowsHeight; | 323 if (m_grid[row].logicalHeight.isAuto()) |
289 remainingHeight -= rowHeight; | 324 changedPosBy += (extraRowSpanningHeight * rowsHeight[row - rowIndex] ) / totalAutoRowsHeight; |
290 m_rowPos[row + 1] = m_rowPos[row] + rowHeight + borderSpacingForRow(row) ; | 325 m_rowPos[row + 1] += changedPosBy; |
291 } | 326 } |
292 // Remaining height added in the last row under rowSpan cell | 327 // Remaining height added in the last row under rowSpan cell |
293 m_rowPos[rowIndex + rowSpan] += remainingHeight; | 328 m_rowPos[rowIndex + rowSpan] += extraRowSpanningHeight - changedPosBy; |
329 | |
330 extraRowSpanningHeight = 0; | |
Julien - ping for review
2013/07/02 02:16:18
This is wrong to clear extraRowSpanningHeight unco
a.suchit
2013/07/03 12:59:57
Done.
| |
331 } | |
332 // Whole extra height would be distribute in remaining rows based on their heig ht ratios so that | |
333 // all rows would get its own share from extra height. | |
334 void RenderTableSection::distributeExtraRowSpanHeightToRemainingRows(RenderTable Cell* cell, int totalRemainingRowsHeight, int& extraRowSpanningHeight, Vector<in t>& rowsHeight) | |
Julien - ping for review
2013/07/02 02:16:18
Because of extraRowSpanningHeight = 0; above, this
a.suchit
2013/07/03 12:59:57
If rowspan cell does not contain auto rows then ex
a.suchit
2013/07/03 12:59:57
Done.
| |
335 { | |
336 if (!extraRowSpanningHeight || !totalRemainingRowsHeight) | |
337 return; | |
338 | |
339 unsigned rowSpan = cell->rowSpan(); | |
340 unsigned rowIndex = cell->rowIndex(); | |
341 int changedPosBy = 0; | |
342 | |
343 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | |
344 if (!m_grid[row].logicalHeight.isPercent()) | |
345 changedPosBy += (extraRowSpanningHeight * rowsHeight[row - rowIndex] ) / totalRemainingRowsHeight; | |
346 m_rowPos[row + 1] += changedPosBy; | |
Julien - ping for review
2013/07/02 02:16:18
The more I see these lines that basically mandates
a.suchit
2013/07/03 12:59:57
m_rowPos is already handled to store the absolute
Julien - ping for review
2013/07/03 21:08:22
That's an understatement! However this argument sh
| |
347 } | |
348 // Remaining height added in the last row under rowSpan cell | |
349 m_rowPos[rowIndex + rowSpan] += extraRowSpanningHeight - changedPosBy; | |
350 | |
351 extraRowSpanningHeight = 0; | |
Julien - ping for review
2013/07/02 02:16:18
This is just gross. Nothing guarantees that change
a.suchit
2013/07/03 12:59:57
Done.
| |
352 } | |
353 | |
354 // Distribute rowSpan cell height in rows those comes in rowSpan cell based on t he ratio of row's height if | |
355 // 1. RowSpan cell height is greater then the total height of rows in rowSpan ce ll | |
356 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) | |
357 { | |
358 ASSERT(rowSpanCells.size()); | |
359 | |
360 // FIXME: For now, we handle the first rowspan cell in the table but this is wrong. | |
361 RenderTableCell* cell = rowSpanCells[0]; | |
362 | |
363 unsigned rowSpan = cell->rowSpan(); | |
364 | |
365 int expectedTotalRowsHeight = 0; | |
366 Vector<int> rowsHeight(rowSpan); | |
367 | |
368 int totalRowsHeight = getRowsHeightInRowSpan(cell, expectedTotalRowsHeight, rowsHeight); | |
369 | |
370 if (!totalRowsHeight || expectedTotalRowsHeight <= totalRowsHeight) | |
371 return; | |
372 | |
373 unsigned rowIndex = cell->rowIndex(); | |
374 int totalPercent = 0; | |
375 int totalAutoRowsHeight = 0; | |
376 int totalRemainingRowsHeight = totalRowsHeight; | |
377 | |
378 // Calculate total percentage, total auto rows height and total rows height except percent rows. | |
379 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | |
380 if (m_grid[row].logicalHeight.isPercent()) { | |
381 totalPercent += m_grid[row].logicalHeight.percent(); | |
382 totalRemainingRowsHeight -= rowsHeight[row - rowIndex]; | |
383 } else if (m_grid[row].logicalHeight.isAuto()) { | |
384 totalAutoRowsHeight += rowsHeight[row - rowIndex]; | |
385 } | |
386 } | |
387 | |
388 int initialPos = m_rowPos[rowIndex + rowSpan]; | |
389 int extraRowSpanningHeight = expectedTotalRowsHeight - totalRowsHeight; | |
390 | |
391 distributeExtraRowSpanHeightToPrecentRows(cell, totalPercent, extraRowSpanni ngHeight, rowsHeight); | |
392 distributeExtraRowSpanHeightToAutoRows(cell, totalAutoRowsHeight, extraRowSp anningHeight, rowsHeight); | |
393 distributeExtraRowSpanHeightToRemainingRows(cell, totalRemainingRowsHeight, extraRowSpanningHeight, rowsHeight); | |
394 | |
395 ASSERT(!extraRowSpanningHeight); | |
294 | 396 |
295 // Getting total changed height in the table | 397 // Getting total changed height in the table |
296 unsigned changedHeight = changedHeight = m_rowPos[rowIndex + rowSpan] - init ialPos; | 398 unsigned changedHeight = m_rowPos[rowIndex + rowSpan] - initialPos; |
297 | 399 |
298 if (changedHeight) { | 400 if (changedHeight) { |
299 unsigned totalRows = m_grid.size(); | 401 unsigned totalRows = m_grid.size(); |
300 | 402 |
301 // Apply changed height by rowSpan cells to rows present at the end of t he table | 403 // 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++) | 404 for (unsigned row = rowIndex + rowSpan + 1; row <= totalRows; row++) |
303 m_rowPos[row] += changedHeight; | 405 m_rowPos[row] += changedHeight; |
304 } | 406 } |
305 } | 407 } |
306 | 408 |
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1521 info.addMember(logicalHeight, "logicalHeight"); | 1623 info.addMember(logicalHeight, "logicalHeight"); |
1522 } | 1624 } |
1523 | 1625 |
1524 void RenderTableSection::CellStruct::reportMemoryUsage(MemoryObjectInfo* memoryO bjectInfo) const | 1626 void RenderTableSection::CellStruct::reportMemoryUsage(MemoryObjectInfo* memoryO bjectInfo) const |
1525 { | 1627 { |
1526 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Rendering) ; | 1628 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Rendering) ; |
1527 info.addMember(cells, "cells"); | 1629 info.addMember(cells, "cells"); |
1528 } | 1630 } |
1529 | 1631 |
1530 } // namespace WebCore | 1632 } // namespace WebCore |
OLD | NEW |