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

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

Issue 47923009: Table rows are incorrectly collapsed in case of hidden cells and rowspans. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Review comments addressed Created 6 years, 9 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 282
283 spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing = cell->logicalHe ightForRowSizing(); 283 spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing = cell->logicalHe ightForRowSizing();
284 284
285 spanningRowsHeight.rowHeight.resize(rowSpan); 285 spanningRowsHeight.rowHeight.resize(rowSpan);
286 spanningRowsHeight.totalRowsHeight = 0; 286 spanningRowsHeight.totalRowsHeight = 0;
287 for (unsigned row = 0; row < rowSpan; row++) { 287 for (unsigned row = 0; row < rowSpan; row++) {
288 unsigned actualRow = row + rowIndex; 288 unsigned actualRow = row + rowIndex;
289 289
290 spanningRowsHeight.rowHeight[row] = m_rowPos[actualRow + 1] - m_rowPos[a ctualRow] - borderSpacingForRow(actualRow); 290 spanningRowsHeight.rowHeight[row] = m_rowPos[actualRow + 1] - m_rowPos[a ctualRow] - borderSpacingForRow(actualRow);
291 if (!spanningRowsHeight.rowHeight[row]) 291 if (!spanningRowsHeight.rowHeight[row])
292 spanningRowsHeight.rowWithOnlySpanningCells |= rowHasOnlySpanningCel ls(actualRow); 292 spanningRowsHeight.isAnyRowWithOnlySpanningCells |= rowHasOnlySpanni ngCells(actualRow);
293 293
294 spanningRowsHeight.totalRowsHeight += spanningRowsHeight.rowHeight[row]; 294 spanningRowsHeight.totalRowsHeight += spanningRowsHeight.rowHeight[row];
295 spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing -= borderSpac ingForRow(actualRow); 295 spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing -= borderSpac ingForRow(actualRow);
296 } 296 }
297 // We don't span the following row so its border-spacing (if any) should be included. 297 // We don't span the following row so its border-spacing (if any) should be included.
298 spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing += borderSpacingF orRow(rowIndex + rowSpan - 1); 298 spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing += borderSpacingF orRow(rowIndex + rowSpan - 1);
299 } 299 }
300 300
301 void RenderTableSection::distributeExtraRowSpanHeightToPercentRows(RenderTableCe ll* cell, int totalPercent, int& extraRowSpanningHeight, Vector<int>& rowsHeight ) 301 void RenderTableSection::distributeExtraRowSpanHeightToPercentRows(RenderTableCe ll* cell, int totalPercent, int& extraRowSpanningHeight, Vector<int>& rowsHeight )
302 { 302 {
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 m_rowPos[row] += extraHeightToPropagate; 535 m_rowPos[row] += extraHeightToPropagate;
536 } 536 }
537 537
538 lastRowIndex = rowIndex; 538 lastRowIndex = rowIndex;
539 lastRowSpan = rowSpan; 539 lastRowSpan = rowSpan;
540 540
541 struct SpanningRowsHeight spanningRowsHeight; 541 struct SpanningRowsHeight spanningRowsHeight;
542 542
543 populateSpanningRowsHeightFromCell(cell, spanningRowsHeight); 543 populateSpanningRowsHeightFromCell(cell, spanningRowsHeight);
544 544
545 if (spanningRowsHeight.rowWithOnlySpanningCells) 545 // Here we are handling only row(s) who have only rowspanning cells and do not have any empty cell.
546 if (spanningRowsHeight.isAnyRowWithOnlySpanningCells)
546 updateRowsHeightHavingOnlySpanningCells(cell, spanningRowsHeight); 547 updateRowsHeightHavingOnlySpanningCells(cell, spanningRowsHeight);
547 548
548 if (!spanningRowsHeight.totalRowsHeight || spanningRowsHeight.spanningCe llHeightIgnoringBorderSpacing <= spanningRowsHeight.totalRowsHeight) { 549 // This code handle row(s) that have rowspanning cell(s) and at least on e empty cell.
550 // Such rows are not handled below and end up having a height of 0. That would mean
551 // content overlapping if one of their cells has any content. To avoid t he problem, we
552 // add all the remaining spanning cells' height to the last spanned row.
553 // This means that we could grow a row past its 'height' or break percen tage spreading
554 // however this is better than overlapping content.
555 // FIXME: Is there a better algorithm?
556 if (!spanningRowsHeight.totalRowsHeight) {
557 if (spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing)
558 m_rowPos[spanningCellEndIndex] += spanningRowsHeight.spanningCel lHeightIgnoringBorderSpacing + borderSpacingForRow(spanningCellEndIndex - 1);
559
560 extraHeightToPropagate = m_rowPos[spanningCellEndIndex] - originalBe forePosition;
561 continue;
562 }
563
564 if (spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing <= spanni ngRowsHeight.totalRowsHeight) {
549 extraHeightToPropagate = m_rowPos[rowIndex + rowSpan] - originalBefo rePosition; 565 extraHeightToPropagate = m_rowPos[rowIndex + rowSpan] - originalBefo rePosition;
550 continue; 566 continue;
551 } 567 }
552 568
569 // Below we are handling only row(s) who have at least one visible cell without rowspan value.
553 int totalPercent = 0; 570 int totalPercent = 0;
554 int totalAutoRowsHeight = 0; 571 int totalAutoRowsHeight = 0;
555 int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight; 572 int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight;
556 573
557 // FIXME: Inner spanning cell height should not change if it have fixed height when it's parent spanning cell 574 // FIXME: Inner spanning cell height should not change if it have fixed height when it's parent spanning cell
558 // is distributing it's extra height in rows. 575 // is distributing it's extra height in rows.
559 576
560 // Calculate total percentage, total auto rows height and total rows hei ght except percent rows. 577 // Calculate total percentage, total auto rows height and total rows hei ght except percent rows.
561 for (unsigned row = rowIndex; row < spanningCellEndIndex; row++) { 578 for (unsigned row = rowIndex; row < spanningCellEndIndex; row++) {
562 if (m_grid[row].logicalHeight.isPercent()) { 579 if (m_grid[row].logicalHeight.isPercent()) {
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 else 1727 else
1711 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); 1728 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing);
1712 1729
1713 cell->setLogicalLocation(cellLocation); 1730 cell->setLogicalLocation(cellLocation);
1714 1731
1715 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) 1732 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled())
1716 view()->addLayoutDelta(oldCellLocation - cell->location()); 1733 view()->addLayoutDelta(oldCellLocation - cell->location());
1717 } 1734 }
1718 1735
1719 } // namespace WebCore 1736 } // 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