Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: Source/core/rendering/RenderTableSection.cpp

Issue 23530044: Row with only spanning cells have a height of 0. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Review comments addressed Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/rendering/RenderTableSection.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 if (inColSpan) 246 if (inColSpan)
247 c.inColSpan = true; 247 c.inColSpan = true;
248 } 248 }
249 m_cCol++; 249 m_cCol++;
250 cSpan -= currentSpan; 250 cSpan -= currentSpan;
251 inColSpan = true; 251 inColSpan = true;
252 } 252 }
253 cell->setCol(table()->effColToCol(col)); 253 cell->setCol(table()->effColToCol(col));
254 } 254 }
255 255
256 bool RenderTableSection::rowHasOnlySpanningCells(unsigned row)
257 {
258 unsigned totalCols = m_grid[row].row.size();
259
260 if (!totalCols)
261 return false;
262
263 for (unsigned col = 0; col < totalCols; col++) {
264 const CellStruct& rowSpanCell = cellAt(row, col);
265
266 // Empty cell is not a valid cell so it is not a rowspan cell.
267 if (rowSpanCell.cells.isEmpty())
268 return false;
269
270 if (rowSpanCell.cells[0]->rowSpan() == 1)
271 return false;
272 }
273
274 return true;
275 }
276
256 void RenderTableSection::populateSpanningRowsHeightFromCell(RenderTableCell* cel l, struct SpanningRowsHeight& spanningRowsHeight) 277 void RenderTableSection::populateSpanningRowsHeightFromCell(RenderTableCell* cel l, struct SpanningRowsHeight& spanningRowsHeight)
257 { 278 {
258 const unsigned rowSpan = cell->rowSpan(); 279 const unsigned rowSpan = cell->rowSpan();
259 const unsigned rowIndex = cell->rowIndex(); 280 const unsigned rowIndex = cell->rowIndex();
260 281
261 spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing = cell->logicalHe ightForRowSizing(); 282 spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing = cell->logicalHe ightForRowSizing();
262 283
263 spanningRowsHeight.rowHeight.resize(rowSpan); 284 spanningRowsHeight.rowHeight.resize(rowSpan);
264 spanningRowsHeight.totalRowsHeight = 0; 285 spanningRowsHeight.totalRowsHeight = 0;
265 for (unsigned row = 0; row < rowSpan; row++) { 286 for (unsigned row = 0; row < rowSpan; row++) {
266 unsigned actualRow = row + rowIndex; 287 unsigned actualRow = row + rowIndex;
288
267 spanningRowsHeight.rowHeight[row] = m_rowPos[actualRow + 1] - m_rowPos[a ctualRow] - borderSpacingForRow(actualRow); 289 spanningRowsHeight.rowHeight[row] = m_rowPos[actualRow + 1] - m_rowPos[a ctualRow] - borderSpacingForRow(actualRow);
290 if (!spanningRowsHeight.rowHeight[row])
291 spanningRowsHeight.rowWithOnlySpanningCells |= rowHasOnlySpanningCel ls(actualRow);
292
268 spanningRowsHeight.totalRowsHeight += spanningRowsHeight.rowHeight[row]; 293 spanningRowsHeight.totalRowsHeight += spanningRowsHeight.rowHeight[row];
269 spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing -= borderSpac ingForRow(actualRow); 294 spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing -= borderSpac ingForRow(actualRow);
270 } 295 }
271 // We don't span the following row so its border-spacing (if any) should be included. 296 // We don't span the following row so its border-spacing (if any) should be included.
272 spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing += borderSpacingF orRow(rowIndex + rowSpan - 1); 297 spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing += borderSpacingF orRow(rowIndex + rowSpan - 1);
273 } 298 }
274 299
275 void RenderTableSection::distributeExtraRowSpanHeightToPercentRows(RenderTableCe ll* cell, int totalPercent, int& extraRowSpanningHeight, Vector<int>& rowsHeight ) 300 void RenderTableSection::distributeExtraRowSpanHeightToPercentRows(RenderTableCe ll* cell, int totalPercent, int& extraRowSpanningHeight, Vector<int>& rowsHeight )
276 { 301 {
277 if (!extraRowSpanningHeight || !totalPercent) 302 if (!extraRowSpanningHeight || !totalPercent)
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 if (cellIsFullyIncludedInOtherCell(cell1, cell2)) 413 if (cellIsFullyIncludedInOtherCell(cell1, cell2))
389 return true; 414 return true;
390 // Sorting lower row index first because first we need to apply the extra he ight of spanning cell which 415 // Sorting lower row index first because first we need to apply the extra he ight of spanning cell which
391 // comes first in the table so lower rows's position would increment in sequ ence. 416 // comes first in the table so lower rows's position would increment in sequ ence.
392 if (cellIsFullyIncludedInOtherCell(cell2, cell1)) 417 if (cellIsFullyIncludedInOtherCell(cell2, cell1))
393 return (cell1->rowIndex() < cell2->rowIndex()); 418 return (cell1->rowIndex() < cell2->rowIndex());
394 419
395 return false; 420 return false;
396 } 421 }
397 422
423 unsigned RenderTableSection::calcRowHeightHavingOnlySpanningCells(unsigned row)
424 {
425 ASSERT(rowHasOnlySpanningCells(row));
426
427 unsigned totalCols = m_grid[row].row.size();
428
429 if (!totalCols)
430 return 0;
431
432 unsigned rowHeight = 0;
433
434 for (unsigned col = 0; col < totalCols; col++) {
435 const CellStruct& rowSpanCell = cellAt(row, col);
436 if (rowSpanCell.cells.size() && rowSpanCell.cells[0]->rowSpan() > 1)
437 rowHeight = max(rowHeight, rowSpanCell.cells[0]->logicalHeightForRow Sizing() / rowSpanCell.cells[0]->rowSpan());
438 }
439
440 return rowHeight;
441 }
442
443 void RenderTableSection::updateRowsHeightHavingOnlySpanningCells(RenderTableCell * cell, struct SpanningRowsHeight& spanningRowsHeight)
444 {
445 ASSERT(spanningRowsHeight.rowHeight.size());
446
447 int accumulatedPositionIncrease = 0;
448 const unsigned rowSpan = cell->rowSpan();
449 const unsigned rowIndex = cell->rowIndex();
450
451 ASSERT(rowSpan == spanningRowsHeight.rowHeight.size());
452
453 for (unsigned row = 0; row < spanningRowsHeight.rowHeight.size(); row++) {
454 unsigned actualRow = row + rowIndex;
455 if (!spanningRowsHeight.rowHeight[row] && rowHasOnlySpanningCells(actual Row)) {
456 spanningRowsHeight.rowHeight[row] = calcRowHeightHavingOnlySpanningC ells(actualRow);
457 accumulatedPositionIncrease += spanningRowsHeight.rowHeight[row];
458 }
459 m_rowPos[actualRow + 1] += accumulatedPositionIncrease;
460 }
461
462 spanningRowsHeight.totalRowsHeight += accumulatedPositionIncrease;
463 }
464
398 // Distribute rowSpan cell height in rows those comes in rowSpan cell based on t he ratio of row's height if 465 // Distribute rowSpan cell height in rows those comes in rowSpan cell based on t he ratio of row's height if
399 // 1. RowSpan cell height is greater then the total height of rows in rowSpan ce ll 466 // 1. RowSpan cell height is greater then the total height of rows in rowSpan ce ll
400 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) 467 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells)
401 { 468 {
402 ASSERT(rowSpanCells.size()); 469 ASSERT(rowSpanCells.size());
403 470
404 // 'rowSpanCells' list is already sorted based on the cells rowIndex in asce nding order 471 // 'rowSpanCells' list is already sorted based on the cells rowIndex in asce nding order
405 // Arrange row spanning cell in the order in which we need to process first. 472 // Arrange row spanning cell in the order in which we need to process first.
406 std::sort(rowSpanCells.begin(), rowSpanCells.end(), compareRowSpanCellsInHei ghtDistributionOrder); 473 std::sort(rowSpanCells.begin(), rowSpanCells.end(), compareRowSpanCellsInHei ghtDistributionOrder);
407 474
(...skipping 29 matching lines...) Expand all
437 m_rowPos[row] += extraHeightToPropagate; 504 m_rowPos[row] += extraHeightToPropagate;
438 } 505 }
439 506
440 lastRowIndex = rowIndex; 507 lastRowIndex = rowIndex;
441 lastRowSpan = rowSpan; 508 lastRowSpan = rowSpan;
442 509
443 struct SpanningRowsHeight spanningRowsHeight; 510 struct SpanningRowsHeight spanningRowsHeight;
444 511
445 populateSpanningRowsHeightFromCell(cell, spanningRowsHeight); 512 populateSpanningRowsHeightFromCell(cell, spanningRowsHeight);
446 513
447 if (!spanningRowsHeight.totalRowsHeight || spanningRowsHeight.spanningCe llHeightIgnoringBorderSpacing <= spanningRowsHeight.totalRowsHeight) 514 if (spanningRowsHeight.rowWithOnlySpanningCells)
515 updateRowsHeightHavingOnlySpanningCells(cell, spanningRowsHeight);
516
517 if (!spanningRowsHeight.totalRowsHeight || spanningRowsHeight.spanningCe llHeightIgnoringBorderSpacing <= spanningRowsHeight.totalRowsHeight) {
518 extraHeightToPropagate = m_rowPos[rowIndex + rowSpan] - originalBefo rePosition;
448 continue; 519 continue;
520 }
449 521
450 int totalPercent = 0; 522 int totalPercent = 0;
451 int totalAutoRowsHeight = 0; 523 int totalAutoRowsHeight = 0;
452 int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight; 524 int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight;
453 525
454 // FIXME: Inner spanning cell height should not change if it have fixed height when it's parent spanning cell 526 // FIXME: Inner spanning cell height should not change if it have fixed height when it's parent spanning cell
455 // is distributing it's extra height in rows. 527 // is distributing it's extra height in rows.
456 528
457 // Calculate total percentage, total auto rows height and total rows hei ght except percent rows. 529 // Calculate total percentage, total auto rows height and total rows hei ght except percent rows.
458 for (unsigned row = rowIndex; row < spanningCellEndIndex; row++) { 530 for (unsigned row = rowIndex; row < spanningCellEndIndex; row++) {
(...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1707 if (!style()->isLeftToRightDirection()) 1779 if (!style()->isLeftToRightDirection())
1708 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); 1780 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing);
1709 else 1781 else
1710 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); 1782 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing);
1711 1783
1712 cell->setLogicalLocation(cellLocation); 1784 cell->setLogicalLocation(cellLocation);
1713 view()->addLayoutDelta(oldCellLocation - cell->location()); 1785 view()->addLayoutDelta(oldCellLocation - cell->location());
1714 } 1786 }
1715 1787
1716 } // namespace WebCore 1788 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderTableSection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698