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(); | |
| 947 m_overflowingCells.clear(); | |
| 948 m_forceSlowPaintPathWithOverflowingCell = false; | |
| 949 | 946 |
| 950 int vspacing = table()->vBorderSpacing(); | 947 int vspacing = table()->vBorderSpacing(); |
| 951 unsigned nEffCols = table()->numEffCols(); | 948 unsigned nEffCols = table()->numEffCols(); |
| 952 | 949 |
| 953 LayoutState state(*this, locationOffset()); | 950 LayoutState state(*this, locationOffset()); |
| 954 | 951 |
| 955 for (unsigned r = 0; r < totalRows; r++) { | 952 for (unsigned r = 0; r < totalRows; r++) { |
| 956 // Set the row's x/y position and width/height. | 953 // Set the row's x/y position and width/height. |
| 957 RenderTableRow* rowRenderer = m_grid[r].rowRenderer; | 954 RenderTableRow* rowRenderer = m_grid[r].rowRenderer; |
| 958 if (rowRenderer) { | 955 if (rowRenderer) { |
| 959 rowRenderer->setLocation(LayoutPoint(0, m_rowPos[r])); | 956 rowRenderer->setLocation(LayoutPoint(0, m_rowPos[r])); |
| 960 rowRenderer->setLogicalWidth(logicalWidth()); | 957 rowRenderer->setLogicalWidth(logicalWidth()); |
| 961 rowRenderer->setLogicalHeight(m_rowPos[r + 1] - m_rowPos[r] - vspaci ng); | 958 rowRenderer->setLogicalHeight(m_rowPos[r + 1] - m_rowPos[r] - vspaci ng); |
| 962 rowRenderer->updateLayerTransformAfterLayout(); | 959 rowRenderer->updateLayerTransformAfterLayout(); |
| 963 rowRenderer->clearAllOverflows(); | |
| 964 rowRenderer->addVisualEffectOverflow(); | |
| 965 } | 960 } |
| 966 | 961 |
| 967 int rowHeightIncreaseForPagination = 0; | 962 int rowHeightIncreaseForPagination = 0; |
| 968 | 963 |
| 969 for (unsigned c = 0; c < nEffCols; c++) { | 964 for (unsigned c = 0; c < nEffCols; c++) { |
| 970 CellStruct& cs = cellAt(r, c); | 965 CellStruct& cs = cellAt(r, c); |
| 971 RenderTableCell* cell = cs.primaryCell(); | 966 RenderTableCell* cell = cs.primaryCell(); |
| 972 | 967 |
| 973 if (!cell || cs.inColSpan) | 968 if (!cell || cs.inColSpan) |
| 974 continue; | 969 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. | 1041 // 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 | 1042 // 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. | 1043 // 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(); | 1044 LayoutUnit oldLogicalHeight = cell->logicalHeight(); |
| 1050 if (oldLogicalHeight > rHeight) | 1045 if (oldLogicalHeight > rHeight) |
| 1051 rowHeightIncreaseForPagination = std::max<int>(rowHeightIncr easeForPagination, oldLogicalHeight - rHeight); | 1046 rowHeightIncreaseForPagination = std::max<int>(rowHeightIncr easeForPagination, oldLogicalHeight - rHeight); |
| 1052 cell->setLogicalHeight(rHeight); | 1047 cell->setLogicalHeight(rHeight); |
| 1053 cell->computeOverflow(oldLogicalHeight, false); | 1048 cell->computeOverflow(oldLogicalHeight, false); |
| 1054 } | 1049 } |
| 1055 | 1050 |
| 1056 if (rowRenderer) | |
| 1057 rowRenderer->addOverflowFromCell(cell); | |
| 1058 | |
| 1059 LayoutSize childOffset(cell->location() - oldCellRect.location()); | 1051 LayoutSize childOffset(cell->location() - oldCellRect.location()); |
| 1060 if (childOffset.width() || childOffset.height()) { | 1052 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 | 1053 // 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 | 1054 // 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. | 1055 // issue paint invalidations ourselves (and the child) anyway. |
| 1064 if (!table()->selfNeedsLayout()) | 1056 if (!table()->selfNeedsLayout()) |
| 1065 cell->setMayNeedPaintInvalidation(true); | 1057 cell->setMayNeedPaintInvalidation(true); |
| 1066 } | 1058 } |
| 1067 } | 1059 } |
| 1068 if (rowHeightIncreaseForPagination) { | 1060 if (rowHeightIncreaseForPagination) { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 1091 unsigned totalRows = m_grid.size(); | 1083 unsigned totalRows = m_grid.size(); |
| 1092 unsigned nEffCols = table()->numEffCols(); | 1084 unsigned nEffCols = table()->numEffCols(); |
| 1093 computeOverflowFromCells(totalRows, nEffCols); | 1085 computeOverflowFromCells(totalRows, nEffCols); |
| 1094 } | 1086 } |
| 1095 | 1087 |
| 1096 void RenderTableSection::computeOverflowFromCells(unsigned totalRows, unsigned n EffCols) | 1088 void RenderTableSection::computeOverflowFromCells(unsigned totalRows, unsigned n EffCols) |
| 1097 { | 1089 { |
| 1098 unsigned totalCellsCount = nEffCols * totalRows; | 1090 unsigned totalCellsCount = nEffCols * totalRows; |
| 1099 unsigned maxAllowedOverflowingCellsCount = totalCellsCount < gMinTableSizeTo UseFastPaintPathWithOverflowingCell ? 0 : gMaxAllowedOverflowingCellRatioForFast PaintPath * totalCellsCount; | 1091 unsigned maxAllowedOverflowingCellsCount = totalCellsCount < gMinTableSizeTo UseFastPaintPathWithOverflowingCell ? 0 : gMaxAllowedOverflowingCellRatioForFast PaintPath * totalCellsCount; |
| 1100 | 1092 |
| 1093 m_overflow.clear(); | |
| 1094 m_overflowingCells.clear(); | |
|
Julien - ping for review
2014/11/25 18:33:10
We were clearing the overflowing cells early to mi
Xianzhu
2014/11/25 20:17:12
Restored the original one.
| |
| 1095 m_forceSlowPaintPathWithOverflowingCell = false; | |
| 1096 | |
| 1101 #if ENABLE(ASSERT) | 1097 #if ENABLE(ASSERT) |
| 1102 bool hasOverflowingCell = false; | 1098 bool hasOverflowingCell = false; |
| 1103 #endif | 1099 #endif |
| 1104 // Now that our height has been determined, add in overflow from cells. | 1100 // Now that our height has been determined, add in overflow from cells. |
| 1105 for (unsigned r = 0; r < totalRows; r++) { | 1101 for (unsigned r = 0; r < totalRows; r++) { |
| 1102 RenderTableRow* rowRenderer = rowRendererAt(r); | |
| 1103 if (rowRenderer) { | |
| 1104 rowRenderer->clearAllOverflows(); | |
| 1105 rowRenderer->addVisualEffectOverflow(); | |
| 1106 } | |
| 1107 | |
| 1106 for (unsigned c = 0; c < nEffCols; c++) { | 1108 for (unsigned c = 0; c < nEffCols; c++) { |
| 1107 CellStruct& cs = cellAt(r, c); | 1109 CellStruct& cs = cellAt(r, c); |
| 1108 RenderTableCell* cell = cs.primaryCell(); | 1110 RenderTableCell* cell = cs.primaryCell(); |
| 1109 if (!cell || cs.inColSpan) | 1111 if (!cell || cs.inColSpan) |
| 1110 continue; | 1112 continue; |
| 1111 if (r < totalRows - 1 && cell == primaryCellAt(r + 1, c)) | 1113 if (r < totalRows - 1 && cell == primaryCellAt(r + 1, c)) |
| 1112 continue; | 1114 continue; |
| 1113 addOverflowFromChild(cell); | 1115 addOverflowFromChild(cell); |
| 1114 #if ENABLE(ASSERT) | 1116 #if ENABLE(ASSERT) |
| 1115 hasOverflowingCell |= cell->hasVisualOverflow(); | 1117 hasOverflowingCell |= cell->hasVisualOverflow(); |
| 1116 #endif | 1118 #endif |
| 1119 | |
| 1120 if (rowRenderer) | |
| 1121 rowRenderer->addOverflowFromCell(cell); | |
| 1122 | |
| 1117 if (cell->hasVisualOverflow() && !m_forceSlowPaintPathWithOverflowin gCell) { | 1123 if (cell->hasVisualOverflow() && !m_forceSlowPaintPathWithOverflowin gCell) { |
| 1118 m_overflowingCells.add(cell); | 1124 m_overflowingCells.add(cell); |
| 1119 if (m_overflowingCells.size() > maxAllowedOverflowingCellsCount) { | 1125 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. | 1126 // 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; | 1127 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. | 1128 // 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(); | 1129 m_overflowingCells.clear(); |
| 1124 } | 1130 } |
| 1125 } | 1131 } |
| 1126 } | 1132 } |
| 1127 } | 1133 } |
| 1128 | 1134 |
| 1129 ASSERT(hasOverflowingCell == this->hasOverflowingCell()); | 1135 ASSERT(hasOverflowingCell == this->hasOverflowingCell()); |
| 1130 } | 1136 } |
| 1131 | 1137 |
| 1138 bool RenderTableSection::recalcChildOverflowAfterStyleChange() | |
| 1139 { | |
| 1140 ASSERT(childNeedsOverflowRecalcAfterStyleChange()); | |
| 1141 clearChildNeedsOverflowRecalcAfterStyleChange(); | |
| 1142 | |
| 1143 unsigned totalRows = m_grid.size(); | |
| 1144 unsigned numEffCols = table()->numEffCols(); | |
| 1145 bool childrenOverflowChanged = false; | |
| 1146 | |
| 1147 for (unsigned r = 0; r < totalRows; r++) { | |
| 1148 RenderTableRow* rowRenderer = rowRendererAt(r); | |
| 1149 if (!rowRenderer || !rowRenderer->childNeedsOverflowRecalcAfterStyleChan ge()) | |
| 1150 continue; | |
| 1151 | |
| 1152 rowRenderer->clearChildNeedsOverflowRecalcAfterStyleChange(); | |
| 1153 | |
| 1154 for (unsigned c = 0; c < numEffCols; c++) { | |
| 1155 CellStruct& cs = cellAt(r, c); | |
| 1156 RenderTableCell* cell = cs.primaryCell(); | |
| 1157 if (!cell || cs.inColSpan || !cell->needsOverflowRecalcAfterStyleCha nge()) | |
| 1158 continue; | |
| 1159 if (cell->recalcOverflowAfterStyleChange()) | |
| 1160 childrenOverflowChanged = true; | |
| 1161 } | |
| 1162 } | |
| 1163 | |
| 1164 if (childrenOverflowChanged) | |
| 1165 computeOverflowFromCells(totalRows, numEffCols); | |
| 1166 | |
| 1167 return childrenOverflowChanged; | |
| 1168 } | |
| 1169 | |
| 1132 int RenderTableSection::calcBlockDirectionOuterBorder(BlockBorderSide side) cons t | 1170 int RenderTableSection::calcBlockDirectionOuterBorder(BlockBorderSide side) cons t |
| 1133 { | 1171 { |
| 1134 unsigned totalCols = table()->numEffCols(); | 1172 unsigned totalCols = table()->numEffCols(); |
| 1135 if (!m_grid.size() || !totalCols) | 1173 if (!m_grid.size() || !totalCols) |
| 1136 return 0; | 1174 return 0; |
| 1137 | 1175 |
| 1138 unsigned borderWidth = 0; | 1176 unsigned borderWidth = 0; |
| 1139 | 1177 |
| 1140 const BorderValue& sb = side == BorderBefore ? style()->borderBefore() : sty le()->borderAfter(); | 1178 const BorderValue& sb = side == BorderBefore ? style()->borderBefore() : sty le()->borderAfter(); |
| 1141 if (sb.style() == BHIDDEN) | 1179 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). | 1651 // FIXME: The table's direction should determine our row's direction, not th e section's (see bug 96691). |
| 1614 if (!style()->isLeftToRightDirection()) | 1652 if (!style()->isLeftToRightDirection()) |
| 1615 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); | 1653 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); |
| 1616 else | 1654 else |
| 1617 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); | 1655 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); |
| 1618 | 1656 |
| 1619 cell->setLogicalLocation(cellLocation); | 1657 cell->setLogicalLocation(cellLocation); |
| 1620 } | 1658 } |
| 1621 | 1659 |
| 1622 } // namespace blink | 1660 } // namespace blink |
| OLD | NEW |