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 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 ASSERT(!needsLayout()); | 946 ASSERT(!needsLayout()); |
947 | 947 |
948 LayoutAnalyzer::Scope analyzer(*this); | 948 LayoutAnalyzer::Scope analyzer(*this); |
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 m_overflow.clear(); | |
957 m_overflowingCells.clear(); | |
958 m_forceSlowPaintPathWithOverflowingCell = false; | |
959 | 956 |
960 int vspacing = table()->vBorderSpacing(); | 957 int vspacing = table()->vBorderSpacing(); |
961 unsigned nEffCols = table()->numEffectiveColumns(); | 958 unsigned nEffCols = table()->numEffectiveColumns(); |
962 | 959 |
963 LayoutState state(*this, locationOffset()); | 960 LayoutState state(*this, locationOffset()); |
964 | 961 |
965 for (unsigned r = 0; r < totalRows; r++) { | 962 for (unsigned r = 0; r < totalRows; r++) { |
966 // Set the row's x/y position and width/height. | 963 // Set the row's x/y position and width/height. |
967 LayoutTableRow* rowLayoutObject = m_grid[r].rowLayoutObject; | 964 LayoutTableRow* rowLayoutObject = m_grid[r].rowLayoutObject; |
968 if (rowLayoutObject) { | 965 if (rowLayoutObject) { |
969 rowLayoutObject->setLocation(LayoutPoint(0, m_rowPos[r])); | 966 rowLayoutObject->setLocation(LayoutPoint(0, m_rowPos[r])); |
970 rowLayoutObject->setLogicalWidth(logicalWidth()); | 967 rowLayoutObject->setLogicalWidth(logicalWidth()); |
971 rowLayoutObject->setLogicalHeight(LayoutUnit(m_rowPos[r + 1] - m_row
Pos[r] - vspacing)); | 968 rowLayoutObject->setLogicalHeight(LayoutUnit(m_rowPos[r + 1] - m_row
Pos[r] - vspacing)); |
972 rowLayoutObject->updateLayerTransformAfterLayout(); | 969 rowLayoutObject->updateLayerTransformAfterLayout(); |
973 rowLayoutObject->clearAllOverflows(); | |
974 rowLayoutObject->addVisualEffectOverflow(); | |
975 } | 970 } |
976 | 971 |
977 int rowHeightIncreaseForPagination = 0; | 972 int rowHeightIncreaseForPagination = 0; |
978 | 973 |
979 for (unsigned c = 0; c < nEffCols; c++) { | 974 for (unsigned c = 0; c < nEffCols; c++) { |
980 CellStruct& cs = cellAt(r, c); | 975 CellStruct& cs = cellAt(r, c); |
981 LayoutTableCell* cell = cs.primaryCell(); | 976 LayoutTableCell* cell = cs.primaryCell(); |
982 | 977 |
983 if (!cell || cs.inColSpan) | 978 if (!cell || cs.inColSpan) |
984 continue; | 979 continue; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 // FIXME: Pagination might have made us change size. For now jus
t shrink or grow the cell to fit without doing a relayout. | 1050 // 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 | 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 |
1057 // either. It's at least stable though and won't result in an in
finite # of relayouts that may never stabilize. | 1052 // 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(); | 1053 LayoutUnit oldLogicalHeight = cell->logicalHeight(); |
1059 if (oldLogicalHeight > rHeight) | 1054 if (oldLogicalHeight > rHeight) |
1060 rowHeightIncreaseForPagination = std::max<int>(rowHeightIncr
easeForPagination, oldLogicalHeight - rHeight); | 1055 rowHeightIncreaseForPagination = std::max<int>(rowHeightIncr
easeForPagination, oldLogicalHeight - rHeight); |
1061 cell->setLogicalHeight(LayoutUnit(rHeight)); | 1056 cell->setLogicalHeight(LayoutUnit(rHeight)); |
1062 cell->computeOverflow(oldLogicalHeight, false); | 1057 cell->computeOverflow(oldLogicalHeight, false); |
1063 } | 1058 } |
1064 | 1059 |
1065 if (rowLayoutObject) | |
1066 rowLayoutObject->addOverflowFromCell(cell); | |
1067 | |
1068 LayoutSize childOffset(cell->location() - oldCellRect.location()); | 1060 LayoutSize childOffset(cell->location() - oldCellRect.location()); |
1069 if (childOffset.width() || childOffset.height()) { | 1061 if (childOffset.width() || childOffset.height()) { |
1070 // If the child moved, we have to issue paint invalidations to i
t as well as any floating/positioned | 1062 // If the child moved, we have to issue paint invalidations to i
t as well as any floating/positioned |
1071 // descendants. An exception is if we need a layout. In this cas
e, we know we're going to | 1063 // descendants. An exception is if we need a layout. In this cas
e, we know we're going to |
1072 // issue paint invalidations ourselves (and the child) anyway. | 1064 // issue paint invalidations ourselves (and the child) anyway. |
1073 if (!table()->selfNeedsLayout()) | 1065 if (!table()->selfNeedsLayout()) |
1074 cell->setMayNeedPaintInvalidation(); | 1066 cell->setMayNeedPaintInvalidation(); |
1075 } | 1067 } |
1076 } | 1068 } |
1077 if (rowHeightIncreaseForPagination) { | 1069 if (rowHeightIncreaseForPagination) { |
1078 for (unsigned rowIndex = r + 1; rowIndex <= totalRows; rowIndex++) | 1070 for (unsigned rowIndex = r + 1; rowIndex <= totalRows; rowIndex++) |
1079 m_rowPos[rowIndex] += rowHeightIncreaseForPagination; | 1071 m_rowPos[rowIndex] += rowHeightIncreaseForPagination; |
1080 for (unsigned c = 0; c < nEffCols; ++c) { | 1072 for (unsigned c = 0; c < nEffCols; ++c) { |
1081 Vector<LayoutTableCell*, 1>& cells = cellAt(r, c).cells; | 1073 Vector<LayoutTableCell*, 1>& cells = cellAt(r, c).cells; |
1082 for (size_t i = 0; i < cells.size(); ++i) { | 1074 for (size_t i = 0; i < cells.size(); ++i) { |
1083 LayoutUnit oldLogicalHeight = cells[i]->logicalHeight(); | 1075 LayoutUnit oldLogicalHeight = cells[i]->logicalHeight(); |
1084 cells[i]->setLogicalHeight(oldLogicalHeight + rowHeightIncre
aseForPagination); | 1076 cells[i]->setLogicalHeight(oldLogicalHeight + rowHeightIncre
aseForPagination); |
1085 cells[i]->computeOverflow(oldLogicalHeight, false); | 1077 cells[i]->computeOverflow(oldLogicalHeight, false); |
1086 } | 1078 } |
1087 } | 1079 } |
1088 } | 1080 } |
| 1081 if (rowLayoutObject) |
| 1082 rowLayoutObject->computeOverflow(); |
1089 } | 1083 } |
1090 | 1084 |
1091 ASSERT(!needsLayout()); | 1085 ASSERT(!needsLayout()); |
1092 | 1086 |
1093 setLogicalHeight(LayoutUnit(m_rowPos[totalRows])); | 1087 setLogicalHeight(LayoutUnit(m_rowPos[totalRows])); |
1094 | 1088 |
1095 computeOverflowFromCells(totalRows, nEffCols); | 1089 computeOverflowFromCells(totalRows, nEffCols); |
1096 } | 1090 } |
1097 | 1091 |
1098 void LayoutTableSection::computeOverflowFromCells() | 1092 void LayoutTableSection::computeOverflowFromCells() |
1099 { | 1093 { |
1100 unsigned totalRows = m_grid.size(); | 1094 unsigned totalRows = m_grid.size(); |
1101 unsigned nEffCols = table()->numEffectiveColumns(); | 1095 unsigned nEffCols = table()->numEffectiveColumns(); |
1102 computeOverflowFromCells(totalRows, nEffCols); | 1096 computeOverflowFromCells(totalRows, nEffCols); |
1103 } | 1097 } |
1104 | 1098 |
1105 void LayoutTableSection::computeOverflowFromCells(unsigned totalRows, unsigned n
EffCols) | 1099 void LayoutTableSection::computeOverflowFromCells(unsigned totalRows, unsigned n
EffCols) |
1106 { | 1100 { |
1107 unsigned totalCellsCount = nEffCols * totalRows; | 1101 unsigned totalCellsCount = nEffCols * totalRows; |
1108 unsigned maxAllowedOverflowingCellsCount = totalCellsCount < gMinTableSizeTo
UseFastPaintPathWithOverflowingCell ? 0 : gMaxAllowedOverflowingCellRatioForFast
PaintPath * totalCellsCount; | 1102 unsigned maxAllowedOverflowingCellsCount = totalCellsCount < gMinTableSizeTo
UseFastPaintPathWithOverflowingCell ? 0 : gMaxAllowedOverflowingCellRatioForFast
PaintPath * totalCellsCount; |
1109 | 1103 |
| 1104 m_overflow.clear(); |
| 1105 m_overflowingCells.clear(); |
| 1106 m_forceSlowPaintPathWithOverflowingCell = false; |
1110 #if ENABLE(ASSERT) | 1107 #if ENABLE(ASSERT) |
1111 bool hasOverflowingCell = false; | 1108 bool hasOverflowingCell = false; |
1112 #endif | 1109 #endif |
1113 // Now that our height has been determined, add in overflow from cells. | 1110 // Now that our height has been determined, add in overflow from cells. |
1114 for (unsigned r = 0; r < totalRows; r++) { | 1111 for (unsigned r = 0; r < totalRows; r++) { |
1115 for (unsigned c = 0; c < nEffCols; c++) { | 1112 for (unsigned c = 0; c < nEffCols; c++) { |
1116 CellStruct& cs = cellAt(r, c); | 1113 CellStruct& cs = cellAt(r, c); |
1117 LayoutTableCell* cell = cs.primaryCell(); | 1114 LayoutTableCell* cell = cs.primaryCell(); |
1118 if (!cell || cs.inColSpan) | 1115 if (!cell || cs.inColSpan) |
1119 continue; | 1116 continue; |
(...skipping 11 matching lines...) Expand all Loading... |
1131 // The slow path does not make any use of the overflowing ce
lls info, don't hold on to the memory. | 1128 // The slow path does not make any use of the overflowing ce
lls info, don't hold on to the memory. |
1132 m_overflowingCells.clear(); | 1129 m_overflowingCells.clear(); |
1133 } | 1130 } |
1134 } | 1131 } |
1135 } | 1132 } |
1136 } | 1133 } |
1137 | 1134 |
1138 ASSERT(hasOverflowingCell == this->hasOverflowingCell()); | 1135 ASSERT(hasOverflowingCell == this->hasOverflowingCell()); |
1139 } | 1136 } |
1140 | 1137 |
| 1138 bool LayoutTableSection::recalcChildOverflowAfterStyleChange() |
| 1139 { |
| 1140 ASSERT(childNeedsOverflowRecalcAfterStyleChange()); |
| 1141 clearChildNeedsOverflowRecalcAfterStyleChange(); |
| 1142 unsigned totalRows = m_grid.size(); |
| 1143 unsigned numEffCols = table()->numEffectiveColumns(); |
| 1144 bool childrenOverflowChanged = false; |
| 1145 for (unsigned r = 0; r < totalRows; r++) { |
| 1146 LayoutTableRow* rowLayouter = rowLayoutObjectAt(r); |
| 1147 if (!rowLayouter || !rowLayouter->childNeedsOverflowRecalcAfterStyleChan
ge()) |
| 1148 continue; |
| 1149 rowLayouter->clearChildNeedsOverflowRecalcAfterStyleChange(); |
| 1150 bool rowChildrenOverflowChanged = false; |
| 1151 for (unsigned c = 0; c < numEffCols; c++) { |
| 1152 CellStruct& cs = cellAt(r, c); |
| 1153 LayoutTableCell* cell = cs.primaryCell(); |
| 1154 if (!cell || cs.inColSpan || !cell->needsOverflowRecalcAfterStyleCha
nge()) |
| 1155 continue; |
| 1156 rowChildrenOverflowChanged |= cell->recalcOverflowAfterStyleChange()
; |
| 1157 } |
| 1158 if (rowChildrenOverflowChanged) |
| 1159 rowLayouter->computeOverflow(); |
| 1160 childrenOverflowChanged |= rowChildrenOverflowChanged; |
| 1161 } |
| 1162 // TODO(crbug.com/604136): Add visual overflow from rows too. |
| 1163 if (childrenOverflowChanged) |
| 1164 computeOverflowFromCells(totalRows, numEffCols); |
| 1165 return childrenOverflowChanged; |
| 1166 } |
| 1167 |
1141 int LayoutTableSection::calcBlockDirectionOuterBorder(BlockBorderSide side) cons
t | 1168 int LayoutTableSection::calcBlockDirectionOuterBorder(BlockBorderSide side) cons
t |
1142 { | 1169 { |
1143 unsigned totalCols = table()->numEffectiveColumns(); | 1170 unsigned totalCols = table()->numEffectiveColumns(); |
1144 if (!m_grid.size() || !totalCols) | 1171 if (!m_grid.size() || !totalCols) |
1145 return 0; | 1172 return 0; |
1146 | 1173 |
1147 int borderWidth = 0; | 1174 int borderWidth = 0; |
1148 | 1175 |
1149 const BorderValue& sb = side == BorderBefore ? style()->borderBefore() : sty
le()->borderAfter(); | 1176 const BorderValue& sb = side == BorderBefore ? style()->borderBefore() : sty
le()->borderAfter(); |
1150 if (sb.style() == BorderStyleHidden) | 1177 if (sb.style() == BorderStyleHidden) |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1641 // FIXME: The table's direction should determine our row's direction, not th
e section's (see bug 96691). | 1668 // FIXME: The table's direction should determine our row's direction, not th
e section's (see bug 96691). |
1642 if (!style()->isLeftToRightDirection()) | 1669 if (!style()->isLeftToRightDirection()) |
1643 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[table()
->numEffectiveColumns()] - table()->effectiveColumnPositions()[table()->absolute
ColumnToEffectiveColumn(cell->absoluteColumnIndex() + cell->colSpan())] + horizo
ntalBorderSpacing)); | 1670 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[table()
->numEffectiveColumns()] - table()->effectiveColumnPositions()[table()->absolute
ColumnToEffectiveColumn(cell->absoluteColumnIndex() + cell->colSpan())] + horizo
ntalBorderSpacing)); |
1644 else | 1671 else |
1645 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[effecti
veColumn] + horizontalBorderSpacing)); | 1672 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[effecti
veColumn] + horizontalBorderSpacing)); |
1646 | 1673 |
1647 cell->setLogicalLocation(cellLocation); | 1674 cell->setLogicalLocation(cellLocation); |
1648 } | 1675 } |
1649 | 1676 |
1650 } // namespace blink | 1677 } // namespace blink |
OLD | NEW |