Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 949 | 949 |
| 950 // FIXME: Changing the height without a layout can change the overflow so it seems wrong. | 950 // FIXME: Changing the height without a layout can change the overflow so it seems wrong. |
| 951 | 951 |
| 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 | 956 |
| 957 int vspacing = table()->vBorderSpacing(); | 957 int vspacing = table()->vBorderSpacing(); |
| 958 unsigned nEffCols = table()->numEffectiveColumns(); | 958 unsigned nEffCols = table()->numEffectiveColumns(); |
| 959 bool isPaginated = view()->layoutState()->isPaginated(); | |
| 959 | 960 |
| 960 LayoutState state(*this, locationOffset()); | 961 LayoutState state(*this, locationOffset()); |
| 961 | 962 |
| 962 for (unsigned r = 0; r < totalRows; r++) { | 963 for (unsigned r = 0; r < totalRows; r++) { |
| 963 // Set the row's x/y position and width/height. | 964 // Set the row's x/y position and width/height. |
| 964 LayoutTableRow* rowLayoutObject = m_grid[r].rowLayoutObject; | 965 LayoutTableRow* rowLayoutObject = m_grid[r].rowLayoutObject; |
| 966 int paginationStrutOnRow = 0; | |
| 965 if (rowLayoutObject) { | 967 if (rowLayoutObject) { |
| 966 rowLayoutObject->setLocation(LayoutPoint(0, m_rowPos[r])); | 968 rowLayoutObject->setLocation(LayoutPoint(0, m_rowPos[r])); |
| 967 rowLayoutObject->setLogicalWidth(logicalWidth()); | 969 rowLayoutObject->setLogicalWidth(logicalWidth()); |
| 968 rowLayoutObject->setLogicalHeight(LayoutUnit(m_rowPos[r + 1] - m_row Pos[r] - vspacing)); | 970 rowLayoutObject->setLogicalHeight(LayoutUnit(m_rowPos[r + 1] - m_row Pos[r] - vspacing)); |
| 969 rowLayoutObject->updateLayerTransformAfterLayout(); | 971 rowLayoutObject->updateLayerTransformAfterLayout(); |
| 972 if (isPaginated) { | |
| 973 paginationStrutOnRow = paginationStrutForRow(rowLayoutObject, La youtUnit(m_rowPos[r])); | |
| 974 if (paginationStrutOnRow) { | |
| 975 for (unsigned rowIndex = r; rowIndex <= totalRows; rowIndex+ +) | |
| 976 m_rowPos[rowIndex] += paginationStrutOnRow; | |
| 977 } | |
| 978 } | |
| 970 } | 979 } |
| 971 | 980 |
| 972 int rowHeightIncreaseForPagination = 0; | 981 int rowHeightIncreaseForPagination = INT_MIN; |
| 973 | 982 |
| 974 for (unsigned c = 0; c < nEffCols; c++) { | 983 for (unsigned c = 0; c < nEffCols; c++) { |
| 975 CellStruct& cs = cellAt(r, c); | 984 CellStruct& cs = cellAt(r, c); |
| 976 LayoutTableCell* cell = cs.primaryCell(); | 985 LayoutTableCell* cell = cs.primaryCell(); |
| 977 | 986 |
| 978 if (!cell || cs.inColSpan) | 987 if (!cell || cs.inColSpan) |
| 979 continue; | 988 continue; |
| 980 | 989 |
| 981 int rowIndex = cell->rowIndex(); | 990 int rowIndex = cell->rowIndex(); |
| 982 int rHeight = m_rowPos[rowIndex + cell->rowSpan()] - m_rowPos[rowInd ex] - vspacing; | 991 int rHeight = m_rowPos[rowIndex + cell->rowSpan()] - m_rowPos[rowInd ex] - vspacing; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1044 cell->markForPaginationRelayoutIfNeeded(layouter); | 1053 cell->markForPaginationRelayoutIfNeeded(layouter); |
| 1045 | 1054 |
| 1046 cell->layoutIfNeeded(); | 1055 cell->layoutIfNeeded(); |
| 1047 | 1056 |
| 1048 // FIXME: Make pagination work with vertical tables. | 1057 // FIXME: Make pagination work with vertical tables. |
| 1049 if (view()->layoutState()->pageLogicalHeight() && cell->logicalHeigh t() != rHeight) { | 1058 if (view()->layoutState()->pageLogicalHeight() && cell->logicalHeigh t() != rHeight) { |
| 1050 // FIXME: Pagination might have made us change size. For now jus t shrink or grow the cell to fit without doing a relayout. | 1059 // FIXME: Pagination might have made us change size. For now jus t shrink or grow the cell to fit without doing a relayout. |
| 1051 // 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 | 1060 // 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 |
| 1052 // either. It's at least stable though and won't result in an in finite # of relayouts that may never stabilize. | 1061 // either. It's at least stable though and won't result in an in finite # of relayouts that may never stabilize. |
| 1053 LayoutUnit oldLogicalHeight = cell->logicalHeight(); | 1062 LayoutUnit oldLogicalHeight = cell->logicalHeight(); |
| 1054 if (oldLogicalHeight > rHeight) | 1063 rowHeightIncreaseForPagination = std::max<int>(rowHeightIncrease ForPagination, oldLogicalHeight - rHeight); |
|
mstensho (USE GERRIT)
2016/05/04 20:23:44
This is new. What is it for? Looks like you want t
rhogan
2016/05/04 20:31:45
This is per your comment: " When paginationStrutFo
mstensho (USE GERRIT)
2016/05/04 21:02:23
Oh, I said that? Indeed I did. Well, can't argue w
| |
| 1055 rowHeightIncreaseForPagination = std::max<int>(rowHeightIncr easeForPagination, oldLogicalHeight - rHeight); | |
| 1056 cell->setLogicalHeight(LayoutUnit(rHeight)); | 1064 cell->setLogicalHeight(LayoutUnit(rHeight)); |
| 1057 cell->computeOverflow(oldLogicalHeight, false); | 1065 cell->computeOverflow(oldLogicalHeight, false); |
| 1058 } | 1066 } |
| 1059 | 1067 |
| 1060 LayoutSize childOffset(cell->location() - oldCellRect.location()); | 1068 LayoutSize childOffset(cell->location() - oldCellRect.location()); |
| 1061 if (childOffset.width() || childOffset.height()) { | 1069 if (childOffset.width() || childOffset.height()) { |
| 1062 // If the child moved, we have to issue paint invalidations to i t as well as any floating/positioned | 1070 // If the child moved, we have to issue paint invalidations to i t as well as any floating/positioned |
| 1063 // descendants. An exception is if we need a layout. In this cas e, we know we're going to | 1071 // descendants. An exception is if we need a layout. In this cas e, we know we're going to |
| 1064 // issue paint invalidations ourselves (and the child) anyway. | 1072 // issue paint invalidations ourselves (and the child) anyway. |
| 1065 if (!table()->selfNeedsLayout()) | 1073 if (!table()->selfNeedsLayout()) |
| 1066 cell->setMayNeedPaintInvalidation(); | 1074 cell->setMayNeedPaintInvalidation(); |
| 1067 } | 1075 } |
| 1068 } | 1076 } |
| 1069 if (rowHeightIncreaseForPagination) { | 1077 if (rowHeightIncreaseForPagination > INT_MIN) { |
| 1070 for (unsigned rowIndex = r + 1; rowIndex <= totalRows; rowIndex++) | 1078 for (unsigned rowIndex = r + 1; rowIndex <= totalRows; rowIndex++) |
| 1071 m_rowPos[rowIndex] += rowHeightIncreaseForPagination; | 1079 m_rowPos[rowIndex] += rowHeightIncreaseForPagination; |
| 1072 for (unsigned c = 0; c < nEffCols; ++c) { | 1080 for (unsigned c = 0; c < nEffCols; ++c) { |
| 1073 Vector<LayoutTableCell*, 1>& cells = cellAt(r, c).cells; | 1081 Vector<LayoutTableCell*, 1>& cells = cellAt(r, c).cells; |
| 1074 for (size_t i = 0; i < cells.size(); ++i) { | 1082 for (size_t i = 0; i < cells.size(); ++i) { |
| 1075 LayoutUnit oldLogicalHeight = cells[i]->logicalHeight(); | 1083 LayoutUnit oldLogicalHeight = cells[i]->logicalHeight(); |
| 1076 cells[i]->setLogicalHeight(oldLogicalHeight + rowHeightIncre aseForPagination); | 1084 cells[i]->setLogicalHeight(oldLogicalHeight + rowHeightIncre aseForPagination); |
| 1077 cells[i]->computeOverflow(oldLogicalHeight, false); | 1085 cells[i]->computeOverflow(oldLogicalHeight, false); |
| 1078 } | 1086 } |
| 1079 } | 1087 } |
| 1080 } | 1088 } |
| 1081 if (rowLayoutObject) | 1089 if (rowLayoutObject) |
| 1082 rowLayoutObject->computeOverflow(); | 1090 rowLayoutObject->computeOverflow(); |
| 1083 } | 1091 } |
| 1084 | 1092 |
| 1085 ASSERT(!needsLayout()); | 1093 ASSERT(!needsLayout()); |
| 1086 | 1094 |
| 1087 setLogicalHeight(LayoutUnit(m_rowPos[totalRows])); | 1095 setLogicalHeight(LayoutUnit(m_rowPos[totalRows])); |
| 1088 | 1096 |
| 1089 computeOverflowFromCells(totalRows, nEffCols); | 1097 computeOverflowFromCells(totalRows, nEffCols); |
| 1090 } | 1098 } |
| 1091 | 1099 |
| 1100 int LayoutTableSection::paginationStrutForRow(LayoutTableRow* row, LayoutUnit lo gicalOffset) const | |
| 1101 { | |
| 1102 if (row->getPaginationBreakability() == AllowAnyBreaks) | |
| 1103 return 0; | |
| 1104 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); | |
| 1105 if (!pageLogicalHeight) | |
| 1106 return 0; | |
| 1107 // If the row is too tall for the page don't insert a strut. | |
| 1108 LayoutUnit rowLogicalHeight = row->logicalHeight(); | |
| 1109 if (rowLogicalHeight > pageLogicalHeight) | |
| 1110 return 0; | |
| 1111 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi calOffset, LayoutBlock::AssociateWithLatterPage); | |
| 1112 if (remainingLogicalHeight >= rowLogicalHeight) | |
| 1113 return 0; // It fits fine where it is. No need to break. | |
| 1114 LayoutUnit paginationStrut = calculatePaginationStrutToFitContent(logicalOff set, remainingLogicalHeight, rowLogicalHeight); | |
| 1115 if (paginationStrut == remainingLogicalHeight && remainingLogicalHeight == p ageLogicalHeight) { | |
| 1116 // Don't break if we were at the top of a page, and we failed to fit the content | |
| 1117 // completely. No point in leaving a page completely blank. | |
| 1118 return 0; | |
| 1119 } | |
| 1120 return paginationStrut; | |
| 1121 } | |
| 1122 | |
| 1092 void LayoutTableSection::computeOverflowFromCells() | 1123 void LayoutTableSection::computeOverflowFromCells() |
| 1093 { | 1124 { |
| 1094 unsigned totalRows = m_grid.size(); | 1125 unsigned totalRows = m_grid.size(); |
| 1095 unsigned nEffCols = table()->numEffectiveColumns(); | 1126 unsigned nEffCols = table()->numEffectiveColumns(); |
| 1096 computeOverflowFromCells(totalRows, nEffCols); | 1127 computeOverflowFromCells(totalRows, nEffCols); |
| 1097 } | 1128 } |
| 1098 | 1129 |
| 1099 void LayoutTableSection::computeOverflowFromCells(unsigned totalRows, unsigned n EffCols) | 1130 void LayoutTableSection::computeOverflowFromCells(unsigned totalRows, unsigned n EffCols) |
| 1100 { | 1131 { |
| 1101 unsigned totalCellsCount = nEffCols * totalRows; | 1132 unsigned totalCellsCount = nEffCols * totalRows; |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1668 // FIXME: The table's direction should determine our row's direction, not th e section's (see bug 96691). | 1699 // FIXME: The table's direction should determine our row's direction, not th e section's (see bug 96691). |
| 1669 if (!style()->isLeftToRightDirection()) | 1700 if (!style()->isLeftToRightDirection()) |
| 1670 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[table() ->numEffectiveColumns()] - table()->effectiveColumnPositions()[table()->absolute ColumnToEffectiveColumn(cell->absoluteColumnIndex() + cell->colSpan())] + horizo ntalBorderSpacing)); | 1701 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[table() ->numEffectiveColumns()] - table()->effectiveColumnPositions()[table()->absolute ColumnToEffectiveColumn(cell->absoluteColumnIndex() + cell->colSpan())] + horizo ntalBorderSpacing)); |
| 1671 else | 1702 else |
| 1672 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[effecti veColumn] + horizontalBorderSpacing)); | 1703 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[effecti veColumn] + horizontalBorderSpacing)); |
| 1673 | 1704 |
| 1674 cell->setLogicalLocation(cellLocation); | 1705 cell->setLogicalLocation(cellLocation); |
| 1675 } | 1706 } |
| 1676 | 1707 |
| 1677 } // namespace blink | 1708 } // namespace blink |
| OLD | NEW |