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 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(); |
| 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 if (rowRenderer) | |
| 1125 rowRenderer->addOverflowFromCell(cell); | |
| 1126 | |
| 1117 if (cell->hasVisualOverflow() && !m_forceSlowPaintPathWithOverflowin gCell) { | 1127 if (cell->hasVisualOverflow() && !m_forceSlowPaintPathWithOverflowin gCell) { |
| 1118 m_overflowingCells.add(cell); | 1128 m_overflowingCells.add(cell); |
| 1119 if (m_overflowingCells.size() > maxAllowedOverflowingCellsCount) { | 1129 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. | 1130 // 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; | 1131 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. | 1132 // 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(); | 1133 m_overflowingCells.clear(); |
| 1124 } | 1134 } |
| 1125 } | 1135 } |
| 1126 } | 1136 } |
| 1127 } | 1137 } |
| 1128 | 1138 |
| 1129 ASSERT(hasOverflowingCell == this->hasOverflowingCell()); | 1139 ASSERT(hasOverflowingCell == this->hasOverflowingCell()); |
| 1130 } | 1140 } |
| 1131 | 1141 |
| 1142 bool RenderTableSection::recalcChildOverflowAfterStyleChange() | |
| 1143 { | |
| 1144 ASSERT(childNeedsOverflowRecalcAfterStyleChange()); | |
| 1145 clearChildNeedsOverflowRecalcAfterStyleChange(); | |
| 1146 | |
| 1147 unsigned totalRows = m_grid.size(); | |
| 1148 unsigned numEffCols = table()->numEffCols(); | |
| 1149 bool childrenOverflowChanged = false; | |
| 1150 | |
| 1151 for (unsigned r = 0; r < totalRows; r++) { | |
| 1152 RenderTableRow* rowRenderer = rowRendererAt(r); | |
| 1153 if (!rowRenderer || !rowRenderer->childNeedsOverflowRecalcAfterStyleChan ge()) | |
| 1154 continue; | |
| 1155 | |
| 1156 rowRenderer->clearChildNeedsOverflowRecalcAfterStyleChange(); | |
| 1157 | |
| 1158 for (unsigned c = 0; c < numEffCols; c++) { | |
| 1159 CellStruct& cs = cellAt(r, c); | |
| 1160 RenderTableCell* cell = cs.primaryCell(); | |
| 1161 if (!cell || cs.inColSpan || !cell->needsOverflowRecalcAfterStyleCha nge()) | |
| 1162 continue; | |
| 1163 if (cell->recalcOverflowAfterStyleChange()) | |
| 1164 childrenOverflowChanged = true; | |
| 1165 } | |
| 1166 } | |
| 1167 | |
| 1168 if (childrenOverflowChanged) | |
|
Julien - ping for review
2014/11/26 19:23:34
If we changed only overflow for the second (think
Xianzhu
2014/11/26 20:53:30
Done.
Actually we never call addVisualEffectOverf
| |
| 1169 computeOverflowFromCells(totalRows, numEffCols); | |
|
Julien - ping for review
2014/11/26 19:23:34
While the performance is better, you will still bl
Xianzhu
2014/11/26 20:53:30
Thought of a similar method, but considering the f
Julien - ping for review
2014/11/26 23:21:25
By incremental, I mean we have to recompute the fu
Xianzhu
2014/11/27 00:28:48
computeOverflowFromCells() doesn't recompute overf
| |
| 1170 | |
| 1171 return childrenOverflowChanged; | |
| 1172 } | |
| 1173 | |
| 1132 int RenderTableSection::calcBlockDirectionOuterBorder(BlockBorderSide side) cons t | 1174 int RenderTableSection::calcBlockDirectionOuterBorder(BlockBorderSide side) cons t |
| 1133 { | 1175 { |
| 1134 unsigned totalCols = table()->numEffCols(); | 1176 unsigned totalCols = table()->numEffCols(); |
| 1135 if (!m_grid.size() || !totalCols) | 1177 if (!m_grid.size() || !totalCols) |
| 1136 return 0; | 1178 return 0; |
| 1137 | 1179 |
| 1138 unsigned borderWidth = 0; | 1180 unsigned borderWidth = 0; |
| 1139 | 1181 |
| 1140 const BorderValue& sb = side == BorderBefore ? style()->borderBefore() : sty le()->borderAfter(); | 1182 const BorderValue& sb = side == BorderBefore ? style()->borderBefore() : sty le()->borderAfter(); |
| 1141 if (sb.style() == BHIDDEN) | 1183 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). | 1655 // FIXME: The table's direction should determine our row's direction, not th e section's (see bug 96691). |
| 1614 if (!style()->isLeftToRightDirection()) | 1656 if (!style()->isLeftToRightDirection()) |
| 1615 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); | 1657 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); |
| 1616 else | 1658 else |
| 1617 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); | 1659 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); |
| 1618 | 1660 |
| 1619 cell->setLogicalLocation(cellLocation); | 1661 cell->setLogicalLocation(cellLocation); |
| 1620 } | 1662 } |
| 1621 | 1663 |
| 1622 } // namespace blink | 1664 } // namespace blink |
| OLD | NEW |