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

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, 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
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 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 962
963 LayoutState state(*this, locationOffset()); 963 LayoutState state(*this, locationOffset());
964 964
965 for (unsigned r = 0; r < totalRows; r++) { 965 for (unsigned r = 0; r < totalRows; r++) {
966 // Set the row's x/y position and width/height. 966 // Set the row's x/y position and width/height.
967 LayoutTableRow* rowLayoutObject = m_grid[r].rowLayoutObject; 967 LayoutTableRow* rowLayoutObject = m_grid[r].rowLayoutObject;
968 int paginationStrutOnRow = 0;
968 if (rowLayoutObject) { 969 if (rowLayoutObject) {
969 rowLayoutObject->setLocation(LayoutPoint(0, m_rowPos[r])); 970 rowLayoutObject->setLocation(LayoutPoint(0, m_rowPos[r]));
970 rowLayoutObject->setLogicalWidth(logicalWidth()); 971 rowLayoutObject->setLogicalWidth(logicalWidth());
971 rowLayoutObject->setLogicalHeight(LayoutUnit(m_rowPos[r + 1] - m_row Pos[r] - vspacing)); 972 rowLayoutObject->setLogicalHeight(LayoutUnit(m_rowPos[r + 1] - m_row Pos[r] - vspacing));
972 rowLayoutObject->updateLayerTransformAfterLayout(); 973 rowLayoutObject->updateLayerTransformAfterLayout();
973 rowLayoutObject->clearAllOverflows(); 974 rowLayoutObject->clearAllOverflows();
974 rowLayoutObject->addVisualEffectOverflow(); 975 rowLayoutObject->addVisualEffectOverflow();
976 if (view()->layoutState()->isPaginated()) {
mstensho (USE GERRIT) 2016/03/29 09:57:46 Might want to cache this on the outside of the loo
977 paginationStrutOnRow = getPaginationStrutForRow(rowLayoutObject, LayoutUnit(m_rowPos[r]));
978 for (unsigned rowIndex = r; paginationStrutOnRow && rowIndex <= totalRows; rowIndex++)
979 m_rowPos[rowIndex] += paginationStrutOnRow;
980 }
975 } 981 }
976 982
977 int rowHeightIncreaseForPagination = 0; 983 int rowHeightIncreaseForPagination = 0;
978 984
979 for (unsigned c = 0; c < nEffCols; c++) { 985 for (unsigned c = 0; c < nEffCols; c++) {
980 CellStruct& cs = cellAt(r, c); 986 CellStruct& cs = cellAt(r, c);
981 LayoutTableCell* cell = cs.primaryCell(); 987 LayoutTableCell* cell = cs.primaryCell();
982 988
983 if (!cell || cs.inColSpan) 989 if (!cell || cs.inColSpan)
984 continue; 990 continue;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 LayoutRect oldCellRect = cell->frameRect(); 1050 LayoutRect oldCellRect = cell->frameRect();
1045 1051
1046 setLogicalPositionForCell(cell, c); 1052 setLogicalPositionForCell(cell, c);
1047 1053
1048 if (!cell->needsLayout()) 1054 if (!cell->needsLayout())
1049 cell->markForPaginationRelayoutIfNeeded(layouter); 1055 cell->markForPaginationRelayoutIfNeeded(layouter);
1050 1056
1051 cell->layoutIfNeeded(); 1057 cell->layoutIfNeeded();
1052 1058
1053 // FIXME: Make pagination work with vertical tables. 1059 // FIXME: Make pagination work with vertical tables.
1054 if (view()->layoutState()->pageLogicalHeight() && cell->logicalHeigh t() != rHeight) { 1060 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. 1061 // 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 1062 // 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. 1063 // 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(); 1064 LayoutUnit oldLogicalHeight = cell->logicalHeight();
1059 if (oldLogicalHeight > rHeight) 1065 if (oldLogicalHeight > rHeight)
1060 rowHeightIncreaseForPagination = std::max<int>(rowHeightIncr easeForPagination, oldLogicalHeight - rHeight); 1066 rowHeightIncreaseForPagination = std::max<int>(rowHeightIncr easeForPagination, oldLogicalHeight - rHeight);
1061 cell->setLogicalHeight(LayoutUnit(rHeight)); 1067 cell->setLogicalHeight(LayoutUnit(rHeight));
1062 cell->computeOverflow(oldLogicalHeight, false); 1068 cell->computeOverflow(oldLogicalHeight, false);
1063 } 1069 }
1064 1070
(...skipping 23 matching lines...) Expand all
1088 } 1094 }
1089 } 1095 }
1090 1096
1091 ASSERT(!needsLayout()); 1097 ASSERT(!needsLayout());
1092 1098
1093 setLogicalHeight(LayoutUnit(m_rowPos[totalRows])); 1099 setLogicalHeight(LayoutUnit(m_rowPos[totalRows]));
1094 1100
1095 computeOverflowFromCells(totalRows, nEffCols); 1101 computeOverflowFromCells(totalRows, nEffCols);
1096 } 1102 }
1097 1103
1104 int LayoutTableSection::getPaginationStrutForRow(LayoutTableRow* row, LayoutUnit logicalOffset) const
1105 {
1106 if (row->getPaginationBreakability() == AllowAnyBreaks)
1107 return 0;
1108 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
1109 if (!pageLogicalHeight)
1110 return 0;
1111 // If the row is too tall for the page don't insert a strut.
1112 LayoutUnit rowLogicalHeight = row->logicalHeight();
1113 if (rowLogicalHeight > pageLogicalHeight)
1114 return 0;
1115 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi calOffset, LayoutBlock::AssociateWithLatterPage);
1116 if (remainingLogicalHeight >= rowLogicalHeight)
1117 return 0; // It fits fine where it is. No need to break.
1118 LayoutUnit paginationStrut = calculatePaginationStrutToFitContent(logicalOff set, remainingLogicalHeight, rowLogicalHeight);
1119 if (paginationStrut == remainingLogicalHeight && remainingLogicalHeight == p ageLogicalHeight) {
1120 // Don't break if we were at the top of a page, and we failed to fit the content
1121 // completely. No point in leaving a page completely blank.
1122 return 0;
1123 }
1124 return paginationStrut;
1125 }
1126
1098 void LayoutTableSection::computeOverflowFromCells() 1127 void LayoutTableSection::computeOverflowFromCells()
1099 { 1128 {
1100 unsigned totalRows = m_grid.size(); 1129 unsigned totalRows = m_grid.size();
1101 unsigned nEffCols = table()->numEffectiveColumns(); 1130 unsigned nEffCols = table()->numEffectiveColumns();
1102 computeOverflowFromCells(totalRows, nEffCols); 1131 computeOverflowFromCells(totalRows, nEffCols);
1103 } 1132 }
1104 1133
1105 void LayoutTableSection::computeOverflowFromCells(unsigned totalRows, unsigned n EffCols) 1134 void LayoutTableSection::computeOverflowFromCells(unsigned totalRows, unsigned n EffCols)
1106 { 1135 {
1107 unsigned totalCellsCount = nEffCols * totalRows; 1136 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). 1670 // FIXME: The table's direction should determine our row's direction, not th e section's (see bug 96691).
1642 if (!style()->isLeftToRightDirection()) 1671 if (!style()->isLeftToRightDirection())
1643 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[table() ->numEffectiveColumns()] - table()->effectiveColumnPositions()[table()->absolute ColumnToEffectiveColumn(cell->absoluteColumnIndex() + cell->colSpan())] + horizo ntalBorderSpacing)); 1672 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[table() ->numEffectiveColumns()] - table()->effectiveColumnPositions()[table()->absolute ColumnToEffectiveColumn(cell->absoluteColumnIndex() + cell->colSpan())] + horizo ntalBorderSpacing));
1644 else 1673 else
1645 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[effecti veColumn] + horizontalBorderSpacing)); 1674 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[effecti veColumn] + horizontalBorderSpacing));
1646 1675
1647 cell->setLogicalLocation(cellLocation); 1676 cell->setLogicalLocation(cellLocation);
1648 } 1677 }
1649 1678
1650 } // namespace blink 1679 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698