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

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

Issue 397733004: Allow assertions to be enabled in Blink Release builds. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased. Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderTableCell.h ('k') | Source/core/rendering/RenderText.h » ('j') | 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, 2013 Apple Inc. All r ights reserved. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2013 Apple Inc. All r ights 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 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 if (cell->rowSpan() == 1) { 625 if (cell->rowSpan() == 1) {
626 baselineDescent = std::max(baselineDescent, cell->logicalHeightForRo wSizing() - baselinePosition); 626 baselineDescent = std::max(baselineDescent, cell->logicalHeightForRo wSizing() - baselinePosition);
627 cellStartRowBaselineDescent = baselineDescent; 627 cellStartRowBaselineDescent = baselineDescent;
628 } 628 }
629 m_rowPos[row + 1] = std::max<int>(m_rowPos[row + 1], m_rowPos[row] + m_g rid[row].baseline + cellStartRowBaselineDescent); 629 m_rowPos[row + 1] = std::max<int>(m_rowPos[row + 1], m_rowPos[row] + m_g rid[row].baseline + cellStartRowBaselineDescent);
630 } 630 }
631 } 631 }
632 632
633 int RenderTableSection::calcRowLogicalHeight() 633 int RenderTableSection::calcRowLogicalHeight()
634 { 634 {
635 #ifndef NDEBUG 635 #if ENABLE(ASSERT)
636 SetLayoutNeededForbiddenScope layoutForbiddenScope(*this); 636 SetLayoutNeededForbiddenScope layoutForbiddenScope(*this);
637 #endif 637 #endif
638 638
639 ASSERT(!needsLayout()); 639 ASSERT(!needsLayout());
640 640
641 RenderTableCell* cell; 641 RenderTableCell* cell;
642 642
643 // FIXME: This shouldn't use the same constructor as RenderView. 643 // FIXME: This shouldn't use the same constructor as RenderView.
644 LayoutState state(*this); 644 LayoutState state(*this);
645 645
646 m_rowPos.resize(m_grid.size() + 1); 646 m_rowPos.resize(m_grid.size() + 1);
647 647
648 // We ignore the border-spacing on any non-top section as it is already incl uded in the previous section's last row position. 648 // We ignore the border-spacing on any non-top section as it is already incl uded in the previous section's last row position.
649 if (this == table()->topSection()) 649 if (this == table()->topSection())
650 m_rowPos[0] = table()->vBorderSpacing(); 650 m_rowPos[0] = table()->vBorderSpacing();
651 else 651 else
652 m_rowPos[0] = 0; 652 m_rowPos[0] = 0;
653 653
654 SpanningRenderTableCells rowSpanCells; 654 SpanningRenderTableCells rowSpanCells;
655 #ifndef NDEBUG 655 #if ENABLE(ASSERT)
656 HashSet<const RenderTableCell*> uniqueCells; 656 HashSet<const RenderTableCell*> uniqueCells;
657 #endif 657 #endif
658 658
659 for (unsigned r = 0; r < m_grid.size(); r++) { 659 for (unsigned r = 0; r < m_grid.size(); r++) {
660 m_grid[r].baseline = 0; 660 m_grid[r].baseline = 0;
661 LayoutUnit baselineDescent = 0; 661 LayoutUnit baselineDescent = 0;
662 662
663 // Our base size is the biggest logical height from our cells' styles (e xcluding row spanning cells). 663 // Our base size is the biggest logical height from our cells' styles (e xcluding row spanning cells).
664 m_rowPos[r + 1] = std::max(m_rowPos[r] + minimumValueForLength(m_grid[r] .logicalHeight, 0).round(), 0); 664 m_rowPos[r + 1] = std::max(m_rowPos[r] + minimumValueForLength(m_grid[r] .logicalHeight, 0).round(), 0);
665 665
666 Row& row = m_grid[r].row; 666 Row& row = m_grid[r].row;
667 unsigned totalCols = row.size(); 667 unsigned totalCols = row.size();
668 RenderTableCell* lastRowSpanCell = 0; 668 RenderTableCell* lastRowSpanCell = 0;
669 669
670 for (unsigned c = 0; c < totalCols; c++) { 670 for (unsigned c = 0; c < totalCols; c++) {
671 CellStruct& current = cellAt(r, c); 671 CellStruct& current = cellAt(r, c);
672 for (unsigned i = 0; i < current.cells.size(); i++) { 672 for (unsigned i = 0; i < current.cells.size(); i++) {
673 cell = current.cells[i]; 673 cell = current.cells[i];
674 if (current.inColSpan && cell->rowSpan() == 1) 674 if (current.inColSpan && cell->rowSpan() == 1)
675 continue; 675 continue;
676 676
677 if (cell->rowSpan() > 1) { 677 if (cell->rowSpan() > 1) {
678 // For row spanning cells, we only handle them for the first row they span. This ensures we take their baseline into account. 678 // For row spanning cells, we only handle them for the first row they span. This ensures we take their baseline into account.
679 if (lastRowSpanCell != cell && cell->rowIndex() == r) { 679 if (lastRowSpanCell != cell && cell->rowIndex() == r) {
680 #ifndef NDEBUG 680 #if ENABLE(ASSERT)
681 ASSERT(!uniqueCells.contains(cell)); 681 ASSERT(!uniqueCells.contains(cell));
682 uniqueCells.add(cell); 682 uniqueCells.add(cell);
683 #endif 683 #endif
684 684
685 rowSpanCells.append(cell); 685 rowSpanCells.append(cell);
686 lastRowSpanCell = cell; 686 lastRowSpanCell = cell;
687 687
688 // Find out the baseline. The baseline is set on the fir st row in a rowSpan. 688 // Find out the baseline. The baseline is set on the fir st row in a rowSpan.
689 updateBaselineForCell(cell, r, baselineDescent); 689 updateBaselineForCell(cell, r, baselineDescent);
690 } 690 }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 return extraLogicalHeight - remainingExtraLogicalHeight; 860 return extraLogicalHeight - remainingExtraLogicalHeight;
861 } 861 }
862 862
863 static bool shouldFlexCellChild(RenderObject* cellDescendant) 863 static bool shouldFlexCellChild(RenderObject* cellDescendant)
864 { 864 {
865 return cellDescendant->isReplaced() || (cellDescendant->isBox() && toRenderB ox(cellDescendant)->scrollsOverflow()); 865 return cellDescendant->isReplaced() || (cellDescendant->isBox() && toRenderB ox(cellDescendant)->scrollsOverflow());
866 } 866 }
867 867
868 void RenderTableSection::layoutRows() 868 void RenderTableSection::layoutRows()
869 { 869 {
870 #ifndef NDEBUG 870 #if ENABLE(ASSERT)
871 SetLayoutNeededForbiddenScope layoutForbiddenScope(*this); 871 SetLayoutNeededForbiddenScope layoutForbiddenScope(*this);
872 #endif 872 #endif
873 873
874 ASSERT(!needsLayout()); 874 ASSERT(!needsLayout());
875 875
876 // FIXME: Changing the height without a layout can change the overflow so it seems wrong. 876 // FIXME: Changing the height without a layout can change the overflow so it seems wrong.
877 877
878 unsigned totalRows = m_grid.size(); 878 unsigned totalRows = m_grid.size();
879 879
880 // Set the width of our section now. The rows will also be this width. 880 // Set the width of our section now. The rows will also be this width.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 unsigned totalRows = m_grid.size(); 1023 unsigned totalRows = m_grid.size();
1024 unsigned nEffCols = table()->numEffCols(); 1024 unsigned nEffCols = table()->numEffCols();
1025 computeOverflowFromCells(totalRows, nEffCols); 1025 computeOverflowFromCells(totalRows, nEffCols);
1026 } 1026 }
1027 1027
1028 void RenderTableSection::computeOverflowFromCells(unsigned totalRows, unsigned n EffCols) 1028 void RenderTableSection::computeOverflowFromCells(unsigned totalRows, unsigned n EffCols)
1029 { 1029 {
1030 unsigned totalCellsCount = nEffCols * totalRows; 1030 unsigned totalCellsCount = nEffCols * totalRows;
1031 unsigned maxAllowedOverflowingCellsCount = totalCellsCount < gMinTableSizeTo UseFastPaintPathWithOverflowingCell ? 0 : gMaxAllowedOverflowingCellRatioForFast PaintPath * totalCellsCount; 1031 unsigned maxAllowedOverflowingCellsCount = totalCellsCount < gMinTableSizeTo UseFastPaintPathWithOverflowingCell ? 0 : gMaxAllowedOverflowingCellRatioForFast PaintPath * totalCellsCount;
1032 1032
1033 #ifndef NDEBUG 1033 #if ENABLE(ASSERT)
1034 bool hasOverflowingCell = false; 1034 bool hasOverflowingCell = false;
1035 #endif 1035 #endif
1036 // Now that our height has been determined, add in overflow from cells. 1036 // Now that our height has been determined, add in overflow from cells.
1037 for (unsigned r = 0; r < totalRows; r++) { 1037 for (unsigned r = 0; r < totalRows; r++) {
1038 for (unsigned c = 0; c < nEffCols; c++) { 1038 for (unsigned c = 0; c < nEffCols; c++) {
1039 CellStruct& cs = cellAt(r, c); 1039 CellStruct& cs = cellAt(r, c);
1040 RenderTableCell* cell = cs.primaryCell(); 1040 RenderTableCell* cell = cs.primaryCell();
1041 if (!cell || cs.inColSpan) 1041 if (!cell || cs.inColSpan)
1042 continue; 1042 continue;
1043 if (r < totalRows - 1 && cell == primaryCellAt(r + 1, c)) 1043 if (r < totalRows - 1 && cell == primaryCellAt(r + 1, c))
1044 continue; 1044 continue;
1045 addOverflowFromChild(cell); 1045 addOverflowFromChild(cell);
1046 #ifndef NDEBUG 1046 #if ENABLE(ASSERT)
1047 hasOverflowingCell |= cell->hasVisualOverflow(); 1047 hasOverflowingCell |= cell->hasVisualOverflow();
1048 #endif 1048 #endif
1049 if (cell->hasVisualOverflow() && !m_forceSlowPaintPathWithOverflowin gCell) { 1049 if (cell->hasVisualOverflow() && !m_forceSlowPaintPathWithOverflowin gCell) {
1050 m_overflowingCells.add(cell); 1050 m_overflowingCells.add(cell);
1051 if (m_overflowingCells.size() > maxAllowedOverflowingCellsCount) { 1051 if (m_overflowingCells.size() > maxAllowedOverflowingCellsCount) {
1052 // We need to set m_forcesSlowPaintPath only if there is a l east one overflowing cells as the hit testing code rely on this information. 1052 // We need to set m_forcesSlowPaintPath only if there is a l east one overflowing cells as the hit testing code rely on this information.
1053 m_forceSlowPaintPathWithOverflowingCell = true; 1053 m_forceSlowPaintPathWithOverflowingCell = true;
1054 // The slow path does not make any use of the overflowing ce lls info, don't hold on to the memory. 1054 // The slow path does not make any use of the overflowing ce lls info, don't hold on to the memory.
1055 m_overflowingCells.clear(); 1055 m_overflowingCells.clear();
1056 } 1056 }
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 CellStruct& current = cellAt(r, c); 1410 CellStruct& current = cellAt(r, c);
1411 RenderTableCell* cell = current.primaryCell(); 1411 RenderTableCell* cell = current.primaryCell();
1412 if (!cell || (r > dirtiedRows.start() && primaryCellAt(r - 1, c) == cell) || (c > dirtiedColumns.start() && primaryCellAt(r, c - 1) == c ell)) 1412 if (!cell || (r > dirtiedRows.start() && primaryCellAt(r - 1, c) == cell) || (c > dirtiedColumns.start() && primaryCellAt(r, c - 1) == c ell))
1413 continue; 1413 continue;
1414 paintCell(cell, paintInfo, paintOffset); 1414 paintCell(cell, paintInfo, paintOffset);
1415 } 1415 }
1416 } 1416 }
1417 } 1417 }
1418 } else { 1418 } else {
1419 // The overflowing cells should be scarce to avoid adding a lot of c ells to the HashSet. 1419 // The overflowing cells should be scarce to avoid adding a lot of c ells to the HashSet.
1420 #ifndef NDEBUG 1420 #if ENABLE(ASSERT)
1421 unsigned totalRows = m_grid.size(); 1421 unsigned totalRows = m_grid.size();
1422 unsigned totalCols = table()->columns().size(); 1422 unsigned totalCols = table()->columns().size();
1423 ASSERT(m_overflowingCells.size() < totalRows * totalCols * gMaxAllow edOverflowingCellRatioForFastPaintPath); 1423 ASSERT(m_overflowingCells.size() < totalRows * totalCols * gMaxAllow edOverflowingCellRatioForFastPaintPath);
1424 #endif 1424 #endif
1425 1425
1426 // To make sure we properly repaint the section, we repaint all the overflowing cells that we collected. 1426 // To make sure we properly repaint the section, we repaint all the overflowing cells that we collected.
1427 Vector<RenderTableCell*> cells; 1427 Vector<RenderTableCell*> cells;
1428 copyToVector(m_overflowingCells, cells); 1428 copyToVector(m_overflowingCells, cells);
1429 1429
1430 HashSet<RenderTableCell*> spanningCells; 1430 HashSet<RenderTableCell*> spanningCells;
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1705 // FIXME: The table's direction should determine our row's direction, not th e section's (see bug 96691). 1705 // FIXME: The table's direction should determine our row's direction, not th e section's (see bug 96691).
1706 if (!style()->isLeftToRightDirection()) 1706 if (!style()->isLeftToRightDirection())
1707 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); 1707 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing);
1708 else 1708 else
1709 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); 1709 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing);
1710 1710
1711 cell->setLogicalLocation(cellLocation); 1711 cell->setLogicalLocation(cellLocation);
1712 } 1712 }
1713 1713
1714 } // namespace WebCore 1714 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderTableCell.h ('k') | Source/core/rendering/RenderText.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698