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 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
936 #endif | 936 #endif |
937 | 937 |
938 ASSERT(!needsLayout()); | 938 ASSERT(!needsLayout()); |
939 | 939 |
940 // FIXME: Changing the height without a layout can change the overflow so it seems wrong. | 940 // FIXME: Changing the height without a layout can change the overflow so it seems wrong. |
941 | 941 |
942 unsigned totalRows = m_grid.size(); | 942 unsigned totalRows = m_grid.size(); |
943 | 943 |
944 // Set the width of our section now. The rows will also be this width. | 944 // Set the width of our section now. The rows will also be this width. |
945 setLogicalWidth(table()->contentLogicalWidth()); | 945 setLogicalWidth(table()->contentLogicalWidth()); |
946 m_overflow.clear(); | 946 |
947 // We will clear and recompute overflow in computeOverflowFromCells(). | |
948 // Clear m_overflowCells early to avoid stale pointers from it. | |
947 m_overflowingCells.clear(); | 949 m_overflowingCells.clear(); |
Julien - ping for review
2014/11/26 23:21:25
I missed that layoutRows calls computeOverflowFrom
Xianzhu
2014/11/27 00:28:48
Acknowledged.
| |
948 m_forceSlowPaintPathWithOverflowingCell = false; | |
949 | 950 |
950 int vspacing = table()->vBorderSpacing(); | 951 int vspacing = table()->vBorderSpacing(); |
951 unsigned nEffCols = table()->numEffCols(); | 952 unsigned nEffCols = table()->numEffCols(); |
952 | 953 |
953 LayoutState state(*this, locationOffset()); | 954 LayoutState state(*this, locationOffset()); |
954 | 955 |
955 for (unsigned r = 0; r < totalRows; r++) { | 956 for (unsigned r = 0; r < totalRows; r++) { |
956 // Set the row's x/y position and width/height. | 957 // Set the row's x/y position and width/height. |
957 RenderTableRow* rowRenderer = m_grid[r].rowRenderer; | 958 RenderTableRow* rowRenderer = m_grid[r].rowRenderer; |
958 if (rowRenderer) { | 959 if (rowRenderer) { |
959 rowRenderer->setLocation(LayoutPoint(0, m_rowPos[r])); | 960 rowRenderer->setLocation(LayoutPoint(0, m_rowPos[r])); |
960 rowRenderer->setLogicalWidth(logicalWidth()); | 961 rowRenderer->setLogicalWidth(logicalWidth()); |
961 rowRenderer->setLogicalHeight(m_rowPos[r + 1] - m_rowPos[r] - vspaci ng); | 962 rowRenderer->setLogicalHeight(m_rowPos[r + 1] - m_rowPos[r] - vspaci ng); |
962 rowRenderer->updateLayerTransformAfterLayout(); | 963 rowRenderer->updateLayerTransformAfterLayout(); |
963 rowRenderer->clearAllOverflows(); | |
964 rowRenderer->addVisualEffectOverflow(); | |
965 } | 964 } |
966 | 965 |
967 int rowHeightIncreaseForPagination = 0; | 966 int rowHeightIncreaseForPagination = 0; |
968 | 967 |
969 for (unsigned c = 0; c < nEffCols; c++) { | 968 for (unsigned c = 0; c < nEffCols; c++) { |
970 CellStruct& cs = cellAt(r, c); | 969 CellStruct& cs = cellAt(r, c); |
971 RenderTableCell* cell = cs.primaryCell(); | 970 RenderTableCell* cell = cs.primaryCell(); |
972 | 971 |
973 if (!cell || cs.inColSpan) | 972 if (!cell || cs.inColSpan) |
974 continue; | 973 continue; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1046 // FIXME: Pagination might have made us change size. For now jus t shrink or grow the cell to fit without doing a relayout. | 1045 // FIXME: Pagination might have made us change size. For now jus t shrink or grow the cell to fit without doing a relayout. |
1047 // 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 | 1046 // 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 |
1048 // either. It's at least stable though and won't result in an in finite # of relayouts that may never stabilize. | 1047 // either. It's at least stable though and won't result in an in finite # of relayouts that may never stabilize. |
1049 LayoutUnit oldLogicalHeight = cell->logicalHeight(); | 1048 LayoutUnit oldLogicalHeight = cell->logicalHeight(); |
1050 if (oldLogicalHeight > rHeight) | 1049 if (oldLogicalHeight > rHeight) |
1051 rowHeightIncreaseForPagination = std::max<int>(rowHeightIncr easeForPagination, oldLogicalHeight - rHeight); | 1050 rowHeightIncreaseForPagination = std::max<int>(rowHeightIncr easeForPagination, oldLogicalHeight - rHeight); |
1052 cell->setLogicalHeight(rHeight); | 1051 cell->setLogicalHeight(rHeight); |
1053 cell->computeOverflow(oldLogicalHeight, false); | 1052 cell->computeOverflow(oldLogicalHeight, false); |
1054 } | 1053 } |
1055 | 1054 |
1056 if (rowRenderer) | |
1057 rowRenderer->addOverflowFromCell(cell); | |
1058 | |
1059 LayoutSize childOffset(cell->location() - oldCellRect.location()); | 1055 LayoutSize childOffset(cell->location() - oldCellRect.location()); |
1060 if (childOffset.width() || childOffset.height()) { | 1056 if (childOffset.width() || childOffset.height()) { |
1061 // If the child moved, we have to issue paint invalidations to i t as well as any floating/positioned | 1057 // If the child moved, we have to issue paint invalidations to i t as well as any floating/positioned |
1062 // descendants. An exception is if we need a layout. In this cas e, we know we're going to | 1058 // descendants. An exception is if we need a layout. In this cas e, we know we're going to |
1063 // issue paint invalidations ourselves (and the child) anyway. | 1059 // issue paint invalidations ourselves (and the child) anyway. |
1064 if (!table()->selfNeedsLayout()) | 1060 if (!table()->selfNeedsLayout()) |
1065 cell->setMayNeedPaintInvalidation(true); | 1061 cell->setMayNeedPaintInvalidation(true); |
1066 } | 1062 } |
1067 } | 1063 } |
1068 if (rowHeightIncreaseForPagination) { | 1064 if (rowHeightIncreaseForPagination) { |
(...skipping 22 matching lines...) Expand all Loading... | |
1091 unsigned totalRows = m_grid.size(); | 1087 unsigned totalRows = m_grid.size(); |
1092 unsigned nEffCols = table()->numEffCols(); | 1088 unsigned nEffCols = table()->numEffCols(); |
1093 computeOverflowFromCells(totalRows, nEffCols); | 1089 computeOverflowFromCells(totalRows, nEffCols); |
1094 } | 1090 } |
1095 | 1091 |
1096 void RenderTableSection::computeOverflowFromCells(unsigned totalRows, unsigned n EffCols) | 1092 void RenderTableSection::computeOverflowFromCells(unsigned totalRows, unsigned n EffCols) |
1097 { | 1093 { |
1098 unsigned totalCellsCount = nEffCols * totalRows; | 1094 unsigned totalCellsCount = nEffCols * totalRows; |
1099 unsigned maxAllowedOverflowingCellsCount = totalCellsCount < gMinTableSizeTo UseFastPaintPathWithOverflowingCell ? 0 : gMaxAllowedOverflowingCellRatioForFast PaintPath * totalCellsCount; | 1095 unsigned maxAllowedOverflowingCellsCount = totalCellsCount < gMinTableSizeTo UseFastPaintPathWithOverflowingCell ? 0 : gMaxAllowedOverflowingCellRatioForFast PaintPath * totalCellsCount; |
1100 | 1096 |
1097 m_overflow.clear(); | |
1098 m_overflowingCells.clear(); | |
1099 m_forceSlowPaintPathWithOverflowingCell = false; | |
1100 | |
1101 #if ENABLE(ASSERT) | 1101 #if ENABLE(ASSERT) |
1102 bool hasOverflowingCell = false; | 1102 bool hasOverflowingCell = false; |
1103 #endif | 1103 #endif |
1104 // Now that our height has been determined, add in overflow from cells. | 1104 // Now that our height has been determined, add in overflow from cells. |
1105 for (unsigned r = 0; r < totalRows; r++) { | 1105 for (unsigned r = 0; r < totalRows; r++) { |
1106 RenderTableRow* rowRenderer = rowRendererAt(r); | |
1107 if (rowRenderer) { | |
1108 rowRenderer->clearAllOverflows(); | |
1109 rowRenderer->addVisualEffectOverflow(); | |
1110 } | |
1111 | |
1106 for (unsigned c = 0; c < nEffCols; c++) { | 1112 for (unsigned c = 0; c < nEffCols; c++) { |
1107 CellStruct& cs = cellAt(r, c); | 1113 CellStruct& cs = cellAt(r, c); |
1108 RenderTableCell* cell = cs.primaryCell(); | 1114 RenderTableCell* cell = cs.primaryCell(); |
1109 if (!cell || cs.inColSpan) | 1115 if (!cell || cs.inColSpan) |
1110 continue; | 1116 continue; |
1111 if (r < totalRows - 1 && cell == primaryCellAt(r + 1, c)) | 1117 if (r < totalRows - 1 && cell == primaryCellAt(r + 1, c)) |
1112 continue; | 1118 continue; |
1113 addOverflowFromChild(cell); | 1119 addOverflowFromChild(cell); |
1114 #if ENABLE(ASSERT) | 1120 #if ENABLE(ASSERT) |
1115 hasOverflowingCell |= cell->hasVisualOverflow(); | 1121 hasOverflowingCell |= cell->hasVisualOverflow(); |
1116 #endif | 1122 #endif |
1123 | |
1124 // FIXME: this misses visual effect overflow of of the rowRenderer. crbug.com/437012. | |
Julien - ping for review
2014/11/26 23:21:25
Note that RenderTableRow::layout() actually calls
Xianzhu
2014/11/27 00:28:48
Acknowledged.
Xianzhu
2014/11/27 00:28:48
Acknowledged.
| |
1125 if (rowRenderer) | |
1126 rowRenderer->addOverflowFromCell(cell); | |
1127 | |
1117 if (cell->hasVisualOverflow() && !m_forceSlowPaintPathWithOverflowin gCell) { | 1128 if (cell->hasVisualOverflow() && !m_forceSlowPaintPathWithOverflowin gCell) { |
1118 m_overflowingCells.add(cell); | 1129 m_overflowingCells.add(cell); |
1119 if (m_overflowingCells.size() > maxAllowedOverflowingCellsCount) { | 1130 if (m_overflowingCells.size() > maxAllowedOverflowingCellsCount) { |
1120 // 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. | 1131 // 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. |
1121 m_forceSlowPaintPathWithOverflowingCell = true; | 1132 m_forceSlowPaintPathWithOverflowingCell = true; |
1122 // The slow path does not make any use of the overflowing ce lls info, don't hold on to the memory. | 1133 // The slow path does not make any use of the overflowing ce lls info, don't hold on to the memory. |
1123 m_overflowingCells.clear(); | 1134 m_overflowingCells.clear(); |
1124 } | 1135 } |
1125 } | 1136 } |
1126 } | 1137 } |
1127 } | 1138 } |
1128 | 1139 |
1129 ASSERT(hasOverflowingCell == this->hasOverflowingCell()); | 1140 ASSERT(hasOverflowingCell == this->hasOverflowingCell()); |
1130 } | 1141 } |
1131 | 1142 |
1143 bool RenderTableSection::recalcChildOverflowAfterStyleChange() | |
1144 { | |
1145 ASSERT(childNeedsOverflowRecalcAfterStyleChange()); | |
1146 clearChildNeedsOverflowRecalcAfterStyleChange(); | |
1147 | |
1148 unsigned totalRows = m_grid.size(); | |
1149 unsigned numEffCols = table()->numEffCols(); | |
1150 bool childrenOverflowChanged = false; | |
1151 | |
1152 for (unsigned r = 0; r < totalRows; r++) { | |
1153 RenderTableRow* rowRenderer = rowRendererAt(r); | |
1154 if (!rowRenderer || !rowRenderer->childNeedsOverflowRecalcAfterStyleChan ge()) | |
1155 continue; | |
1156 | |
1157 rowRenderer->clearChildNeedsOverflowRecalcAfterStyleChange(); | |
Julien - ping for review
2014/11/26 23:21:25
Do we check somewhere that this is cleared for eve
Xianzhu
2014/11/27 00:28:48
No for now. Will consider adding it.
| |
1158 | |
1159 for (unsigned c = 0; c < numEffCols; c++) { | |
1160 CellStruct& cs = cellAt(r, c); | |
1161 RenderTableCell* cell = cs.primaryCell(); | |
1162 if (!cell || cs.inColSpan || !cell->needsOverflowRecalcAfterStyleCha nge()) | |
1163 continue; | |
1164 childrenOverflowChanged |= cell->recalcOverflowAfterStyleChange(); | |
1165 } | |
1166 } | |
1167 | |
1168 // FIXME: We should do a full recomputeOverflow which will be feasible after we make RenderBox recomputeOverflow-capable. | |
1169 // crbug.com/437012. | |
Julien - ping for review
2014/11/26 23:21:25
I don't think we should do it this way: we should
Xianzhu
2014/11/27 00:28:48
Removed FIXME. With extracted RenderTableRow::reco
| |
1170 if (childrenOverflowChanged) | |
1171 computeOverflowFromCells(totalRows, numEffCols); | |
1172 | |
1173 return childrenOverflowChanged; | |
1174 } | |
1175 | |
1132 int RenderTableSection::calcBlockDirectionOuterBorder(BlockBorderSide side) cons t | 1176 int RenderTableSection::calcBlockDirectionOuterBorder(BlockBorderSide side) cons t |
1133 { | 1177 { |
1134 unsigned totalCols = table()->numEffCols(); | 1178 unsigned totalCols = table()->numEffCols(); |
1135 if (!m_grid.size() || !totalCols) | 1179 if (!m_grid.size() || !totalCols) |
1136 return 0; | 1180 return 0; |
1137 | 1181 |
1138 unsigned borderWidth = 0; | 1182 unsigned borderWidth = 0; |
1139 | 1183 |
1140 const BorderValue& sb = side == BorderBefore ? style()->borderBefore() : sty le()->borderAfter(); | 1184 const BorderValue& sb = side == BorderBefore ? style()->borderBefore() : sty le()->borderAfter(); |
1141 if (sb.style() == BHIDDEN) | 1185 if (sb.style() == BHIDDEN) |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1613 // FIXME: The table's direction should determine our row's direction, not th e section's (see bug 96691). | 1657 // FIXME: The table's direction should determine our row's direction, not th e section's (see bug 96691). |
1614 if (!style()->isLeftToRightDirection()) | 1658 if (!style()->isLeftToRightDirection()) |
1615 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); | 1659 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); |
1616 else | 1660 else |
1617 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); | 1661 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); |
1618 | 1662 |
1619 cell->setLogicalLocation(cellLocation); | 1663 cell->setLogicalLocation(cellLocation); |
1620 } | 1664 } |
1621 | 1665 |
1622 } // namespace blink | 1666 } // namespace blink |
OLD | NEW |