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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutTableSection.cpp

Issue 1602773005: Respect break-inside:avoid on table rows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated Created 4 years, 8 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
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 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 unsigned totalRows = m_grid.size(); 952 unsigned totalRows = m_grid.size();
953 953
954 // Set the width of our section now. The rows will also be this width. 954 // Set the width of our section now. The rows will also be this width.
955 setLogicalWidth(table()->contentLogicalWidth()); 955 setLogicalWidth(table()->contentLogicalWidth());
956 m_overflow.clear(); 956 m_overflow.clear();
957 m_overflowingCells.clear(); 957 m_overflowingCells.clear();
958 m_forceSlowPaintPathWithOverflowingCell = false; 958 m_forceSlowPaintPathWithOverflowingCell = false;
959 959
960 int vspacing = table()->vBorderSpacing(); 960 int vspacing = table()->vBorderSpacing();
961 unsigned nEffCols = table()->numEffectiveColumns(); 961 unsigned nEffCols = table()->numEffectiveColumns();
962 bool isPaginated = view()->layoutState()->isPaginated();
962 963
963 LayoutState state(*this, locationOffset()); 964 LayoutState state(*this, locationOffset());
964 965
965 for (unsigned r = 0; r < totalRows; r++) { 966 for (unsigned r = 0; r < totalRows; r++) {
966 // Set the row's x/y position and width/height. 967 // Set the row's x/y position and width/height.
967 LayoutTableRow* rowLayoutObject = m_grid[r].rowLayoutObject; 968 LayoutTableRow* rowLayoutObject = m_grid[r].rowLayoutObject;
969 int paginationStrutOnRow = 0;
968 if (rowLayoutObject) { 970 if (rowLayoutObject) {
969 rowLayoutObject->setLocation(LayoutPoint(0, m_rowPos[r])); 971 rowLayoutObject->setLocation(LayoutPoint(0, m_rowPos[r]));
970 rowLayoutObject->setLogicalWidth(logicalWidth()); 972 rowLayoutObject->setLogicalWidth(logicalWidth());
971 rowLayoutObject->setLogicalHeight(LayoutUnit(m_rowPos[r + 1] - m_row Pos[r] - vspacing)); 973 rowLayoutObject->setLogicalHeight(LayoutUnit(m_rowPos[r + 1] - m_row Pos[r] - vspacing));
972 rowLayoutObject->updateLayerTransformAfterLayout(); 974 rowLayoutObject->updateLayerTransformAfterLayout();
973 rowLayoutObject->clearAllOverflows(); 975 rowLayoutObject->clearAllOverflows();
974 rowLayoutObject->addVisualEffectOverflow(); 976 rowLayoutObject->addVisualEffectOverflow();
977 if (isPaginated) {
978 paginationStrutOnRow = paginationStrutForRow(rowLayoutObject, La youtUnit(m_rowPos[r]));
979 for (unsigned rowIndex = r; paginationStrutOnRow && rowIndex <= totalRows; rowIndex++)
mstensho (USE GERRIT) 2016/04/04 21:05:39 Better check paginationStrutOnRow before entering
980 m_rowPos[rowIndex] += paginationStrutOnRow;
981 }
975 } 982 }
976 983
977 int rowHeightIncreaseForPagination = 0; 984 int rowHeightIncreaseForPagination = 0;
978 985
979 for (unsigned c = 0; c < nEffCols; c++) { 986 for (unsigned c = 0; c < nEffCols; c++) {
980 CellStruct& cs = cellAt(r, c); 987 CellStruct& cs = cellAt(r, c);
981 LayoutTableCell* cell = cs.primaryCell(); 988 LayoutTableCell* cell = cs.primaryCell();
982 989
983 if (!cell || cs.inColSpan) 990 if (!cell || cs.inColSpan)
984 continue; 991 continue;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 LayoutRect oldCellRect = cell->frameRect(); 1051 LayoutRect oldCellRect = cell->frameRect();
1045 1052
1046 setLogicalPositionForCell(cell, c); 1053 setLogicalPositionForCell(cell, c);
1047 1054
1048 if (!cell->needsLayout()) 1055 if (!cell->needsLayout())
1049 cell->markForPaginationRelayoutIfNeeded(layouter); 1056 cell->markForPaginationRelayoutIfNeeded(layouter);
1050 1057
1051 cell->layoutIfNeeded(); 1058 cell->layoutIfNeeded();
1052 1059
1053 // FIXME: Make pagination work with vertical tables. 1060 // FIXME: Make pagination work with vertical tables.
1054 if (view()->layoutState()->pageLogicalHeight() && cell->logicalHeigh t() != rHeight) { 1061 if (!paginationStrutOnRow && view()->layoutState()->pageLogicalHeigh t() && cell->logicalHeight() != rHeight) {
1055 // FIXME: Pagination might have made us change size. For now jus t shrink or grow the cell to fit without doing a relayout. 1062 // FIXME: Pagination might have made us change size. For now jus t shrink or grow the cell to fit without doing a relayout.
1056 // We'll also do a basic increase of the row height to accommoda te the cell if it's bigger, but this isn't quite right 1063 // We'll also do a basic increase of the row height to accommoda te the cell if it's bigger, but this isn't quite right
1057 // either. It's at least stable though and won't result in an in finite # of relayouts that may never stabilize. 1064 // either. It's at least stable though and won't result in an in finite # of relayouts that may never stabilize.
1058 LayoutUnit oldLogicalHeight = cell->logicalHeight(); 1065 LayoutUnit oldLogicalHeight = cell->logicalHeight();
1059 if (oldLogicalHeight > rHeight) 1066 if (oldLogicalHeight > rHeight)
1060 rowHeightIncreaseForPagination = std::max<int>(rowHeightIncr easeForPagination, oldLogicalHeight - rHeight); 1067 rowHeightIncreaseForPagination = std::max<int>(rowHeightIncr easeForPagination, oldLogicalHeight - rHeight);
1061 cell->setLogicalHeight(LayoutUnit(rHeight)); 1068 cell->setLogicalHeight(LayoutUnit(rHeight));
1062 cell->computeOverflow(oldLogicalHeight, false); 1069 cell->computeOverflow(oldLogicalHeight, false);
1063 } 1070 }
1064 1071
(...skipping 23 matching lines...) Expand all
1088 } 1095 }
1089 } 1096 }
1090 1097
1091 ASSERT(!needsLayout()); 1098 ASSERT(!needsLayout());
1092 1099
1093 setLogicalHeight(LayoutUnit(m_rowPos[totalRows])); 1100 setLogicalHeight(LayoutUnit(m_rowPos[totalRows]));
1094 1101
1095 computeOverflowFromCells(totalRows, nEffCols); 1102 computeOverflowFromCells(totalRows, nEffCols);
1096 } 1103 }
1097 1104
1105 int LayoutTableSection::paginationStrutForRow(LayoutTableRow* row, LayoutUnit lo gicalOffset) const
1106 {
1107 if (row->getPaginationBreakability() == AllowAnyBreaks)
1108 return 0;
1109 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
1110 if (!pageLogicalHeight)
1111 return 0;
1112 // If the row is too tall for the page don't insert a strut.
1113 LayoutUnit rowLogicalHeight = row->logicalHeight();
1114 if (rowLogicalHeight > pageLogicalHeight)
1115 return 0;
1116 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi calOffset, LayoutBlock::AssociateWithLatterPage);
1117 if (remainingLogicalHeight >= rowLogicalHeight)
1118 return 0; // It fits fine where it is. No need to break.
1119 LayoutUnit paginationStrut = calculatePaginationStrutToFitContent(logicalOff set, remainingLogicalHeight, rowLogicalHeight);
1120 if (paginationStrut == remainingLogicalHeight && remainingLogicalHeight == p ageLogicalHeight) {
1121 // Don't break if we were at the top of a page, and we failed to fit the content
1122 // completely. No point in leaving a page completely blank.
1123 return 0;
1124 }
1125 return paginationStrut;
1126 }
1127
1098 void LayoutTableSection::computeOverflowFromCells() 1128 void LayoutTableSection::computeOverflowFromCells()
1099 { 1129 {
1100 unsigned totalRows = m_grid.size(); 1130 unsigned totalRows = m_grid.size();
1101 unsigned nEffCols = table()->numEffectiveColumns(); 1131 unsigned nEffCols = table()->numEffectiveColumns();
1102 computeOverflowFromCells(totalRows, nEffCols); 1132 computeOverflowFromCells(totalRows, nEffCols);
1103 } 1133 }
1104 1134
1105 void LayoutTableSection::computeOverflowFromCells(unsigned totalRows, unsigned n EffCols) 1135 void LayoutTableSection::computeOverflowFromCells(unsigned totalRows, unsigned n EffCols)
1106 { 1136 {
1107 unsigned totalCellsCount = nEffCols * totalRows; 1137 unsigned totalCellsCount = nEffCols * totalRows;
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 // FIXME: The table's direction should determine our row's direction, not th e section's (see bug 96691). 1671 // FIXME: The table's direction should determine our row's direction, not th e section's (see bug 96691).
1642 if (!style()->isLeftToRightDirection()) 1672 if (!style()->isLeftToRightDirection())
1643 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[table() ->numEffectiveColumns()] - table()->effectiveColumnPositions()[table()->absolute ColumnToEffectiveColumn(cell->absoluteColumnIndex() + cell->colSpan())] + horizo ntalBorderSpacing)); 1673 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[table() ->numEffectiveColumns()] - table()->effectiveColumnPositions()[table()->absolute ColumnToEffectiveColumn(cell->absoluteColumnIndex() + cell->colSpan())] + horizo ntalBorderSpacing));
1644 else 1674 else
1645 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[effecti veColumn] + horizontalBorderSpacing)); 1675 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[effecti veColumn] + horizontalBorderSpacing));
1646 1676
1647 cell->setLogicalLocation(cellLocation); 1677 cell->setLogicalLocation(cellLocation);
1648 } 1678 }
1649 1679
1650 } // namespace blink 1680 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698