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. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2013 Apple Inc. |
8 * All rights reserved. | 8 * All rights reserved. |
9 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 9 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
10 * | 10 * |
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 } | 1231 } |
1232 } | 1232 } |
1233 if (row_layout_object) | 1233 if (row_layout_object) |
1234 row_layout_object->ComputeOverflow(); | 1234 row_layout_object->ComputeOverflow(); |
1235 } | 1235 } |
1236 | 1236 |
1237 DCHECK(!NeedsLayout()); | 1237 DCHECK(!NeedsLayout()); |
1238 | 1238 |
1239 SetLogicalHeight(LayoutUnit(row_pos_[total_rows])); | 1239 SetLogicalHeight(LayoutUnit(row_pos_[total_rows])); |
1240 | 1240 |
1241 ComputeOverflowFromCells(total_rows, Table()->NumEffectiveColumns()); | 1241 ComputeOverflowFromDescendants(); |
1242 } | 1242 } |
1243 | 1243 |
1244 int LayoutTableSection::PaginationStrutForRow(LayoutTableRow* row, | 1244 int LayoutTableSection::PaginationStrutForRow(LayoutTableRow* row, |
1245 LayoutUnit logical_offset) const { | 1245 LayoutUnit logical_offset) const { |
1246 DCHECK(row); | 1246 DCHECK(row); |
1247 if (row->GetPaginationBreakability() == kAllowAnyBreaks) | 1247 if (row->GetPaginationBreakability() == kAllowAnyBreaks) |
1248 return 0; | 1248 return 0; |
1249 LayoutUnit page_logical_height = PageLogicalHeightForOffset(logical_offset); | 1249 LayoutUnit page_logical_height = PageLogicalHeightForOffset(logical_offset); |
1250 if (!page_logical_height) | 1250 if (!page_logical_height) |
1251 return 0; | 1251 return 0; |
(...skipping 13 matching lines...) Expand all Loading... |
1265 // Don't break if we were at the top of a page, and we failed to fit the | 1265 // Don't break if we were at the top of a page, and we failed to fit the |
1266 // content completely. No point in leaving a page completely blank. | 1266 // content completely. No point in leaving a page completely blank. |
1267 return 0; | 1267 return 0; |
1268 } | 1268 } |
1269 // Table layout parts only work on integers, so we have to round. Round up, to | 1269 // Table layout parts only work on integers, so we have to round. Round up, to |
1270 // make sure that no fraction ever gets left behind in the previous | 1270 // make sure that no fraction ever gets left behind in the previous |
1271 // fragmentainer. | 1271 // fragmentainer. |
1272 return pagination_strut.Ceil(); | 1272 return pagination_strut.Ceil(); |
1273 } | 1273 } |
1274 | 1274 |
1275 void LayoutTableSection::ComputeOverflowFromCells() { | 1275 void LayoutTableSection::ComputeOverflowFromDescendants() { |
1276 unsigned total_rows = grid_.size(); | 1276 unsigned total_cells_count = NumRows() * Table()->NumEffectiveColumns(); |
1277 unsigned n_eff_cols = Table()->NumEffectiveColumns(); | |
1278 ComputeOverflowFromCells(total_rows, n_eff_cols); | |
1279 } | |
1280 | |
1281 void LayoutTableSection::ComputeOverflowFromCells(unsigned total_rows, | |
1282 unsigned n_eff_cols) { | |
1283 unsigned total_cells_count = n_eff_cols * total_rows; | |
1284 unsigned max_allowed_overflowing_cells_count = | 1277 unsigned max_allowed_overflowing_cells_count = |
1285 total_cells_count < | 1278 total_cells_count < |
1286 g_min_table_size_to_use_fast_paint_path_with_overflowing_cell | 1279 g_min_table_size_to_use_fast_paint_path_with_overflowing_cell |
1287 ? 0 | 1280 ? 0 |
1288 : kGMaxAllowedOverflowingCellRatioForFastPaintPath * | 1281 : kGMaxAllowedOverflowingCellRatioForFastPaintPath * |
1289 total_cells_count; | 1282 total_cells_count; |
1290 | 1283 |
1291 overflow_.reset(); | 1284 overflow_.reset(); |
1292 overflowing_cells_.clear(); | 1285 overflowing_cells_.clear(); |
1293 force_slow_paint_path_with_overflowing_cell_ = false; | 1286 force_slow_paint_path_with_overflowing_cell_ = false; |
1294 #if DCHECK_IS_ON() | 1287 #if DCHECK_IS_ON() |
1295 bool has_overflowing_cell = false; | 1288 bool has_overflowing_cell = false; |
1296 #endif | 1289 #endif |
1297 // Now that our height has been determined, add in overflow from cells. | 1290 |
1298 for (unsigned r = 0; r < total_rows; r++) { | 1291 for (auto* row = FirstRow(); row; row = row->NextRow()) { |
1299 unsigned n_cols = NumCols(r); | 1292 AddOverflowFromChild(*row); |
1300 for (unsigned c = 0; c < n_cols; c++) { | 1293 |
1301 const auto* cell = OriginatingCellAt(r, c); | 1294 for (auto* cell = row->FirstCell(); cell; cell = cell->NextCell()) { |
1302 if (!cell) | 1295 // Let the section's self visual overflow cover the cell's whole collapsed |
| 1296 // borders. This ensures correct raster invalidation on section border |
| 1297 // style change. |
| 1298 // TODO(wangxianzhu): When implementing row as DisplayItemClient of |
| 1299 // collapsed borders, the following logic should be replaced by |
| 1300 // invalidation of rows on section border style change. crbug.com/663208. |
| 1301 if (const auto* collapsed_borders = cell->GetCollapsedBorderValues()) { |
| 1302 LayoutRect rect = cell->RectForOverflowPropagation( |
| 1303 collapsed_borders->LocalVisualRect()); |
| 1304 rect.MoveBy(cell->Location()); |
| 1305 AddSelfVisualOverflow(rect); |
| 1306 } |
| 1307 |
| 1308 if (force_slow_paint_path_with_overflowing_cell_ || |
| 1309 !cell->HasVisualOverflow()) |
1303 continue; | 1310 continue; |
1304 AddOverflowFromChild(*cell); | 1311 |
1305 #if DCHECK_IS_ON() | 1312 #if DCHECK_IS_ON() |
1306 has_overflowing_cell |= cell->HasVisualOverflow(); | 1313 has_overflowing_cell = true; |
1307 #endif | 1314 #endif |
1308 if (cell->HasVisualOverflow() && | 1315 if (overflowing_cells_.size() >= max_allowed_overflowing_cells_count) { |
1309 !force_slow_paint_path_with_overflowing_cell_) { | 1316 // We need to set force_slow_paint_path_with_overflowing_cell_ only if |
1310 overflowing_cells_.insert(cell); | 1317 // there is at least one overflowing cell as the hit testing code relies |
1311 if (overflowing_cells_.size() > max_allowed_overflowing_cells_count) { | 1318 // on this information. |
1312 // We need to set m_forcesSlowPaintPath only if there is a least one | 1319 force_slow_paint_path_with_overflowing_cell_ = true; |
1313 // overflowing cells as the hit testing code rely on this information. | 1320 // The slow path does not make any use of the overflowing cells info, |
1314 force_slow_paint_path_with_overflowing_cell_ = true; | 1321 // don't hold on to the memory. |
1315 // The slow path does not make any use of the overflowing cells info, | 1322 overflowing_cells_.clear(); |
1316 // don't hold on to the memory. | 1323 continue; |
1317 overflowing_cells_.clear(); | |
1318 } | |
1319 } | 1324 } |
| 1325 |
| 1326 overflowing_cells_.insert(cell); |
1320 } | 1327 } |
1321 } | 1328 } |
1322 | 1329 |
1323 #if DCHECK_IS_ON() | 1330 #if DCHECK_IS_ON() |
1324 DCHECK_EQ(has_overflowing_cell, this->HasOverflowingCell()); | 1331 DCHECK_EQ(has_overflowing_cell, this->HasOverflowingCell()); |
1325 #endif | 1332 #endif |
1326 } | 1333 } |
1327 | 1334 |
1328 bool LayoutTableSection::RecalcChildOverflowAfterStyleChange() { | 1335 bool LayoutTableSection::RecalcChildOverflowAfterStyleChange() { |
1329 DCHECK(ChildNeedsOverflowRecalcAfterStyleChange()); | 1336 DCHECK(ChildNeedsOverflowRecalcAfterStyleChange()); |
(...skipping 11 matching lines...) Expand all Loading... |
1341 for (unsigned c = 0; c < n_cols; c++) { | 1348 for (unsigned c = 0; c < n_cols; c++) { |
1342 auto* cell = OriginatingCellAt(r, c); | 1349 auto* cell = OriginatingCellAt(r, c); |
1343 if (!cell || !cell->NeedsOverflowRecalcAfterStyleChange()) | 1350 if (!cell || !cell->NeedsOverflowRecalcAfterStyleChange()) |
1344 continue; | 1351 continue; |
1345 row_children_overflow_changed |= cell->RecalcOverflowAfterStyleChange(); | 1352 row_children_overflow_changed |= cell->RecalcOverflowAfterStyleChange(); |
1346 } | 1353 } |
1347 if (row_children_overflow_changed) | 1354 if (row_children_overflow_changed) |
1348 row_layouter->ComputeOverflow(); | 1355 row_layouter->ComputeOverflow(); |
1349 children_overflow_changed |= row_children_overflow_changed; | 1356 children_overflow_changed |= row_children_overflow_changed; |
1350 } | 1357 } |
1351 // TODO(crbug.com/604136): Add visual overflow from rows too. | |
1352 if (children_overflow_changed) | 1358 if (children_overflow_changed) |
1353 ComputeOverflowFromCells(total_rows, Table()->NumEffectiveColumns()); | 1359 ComputeOverflowFromDescendants(); |
1354 return children_overflow_changed; | 1360 return children_overflow_changed; |
1355 } | 1361 } |
1356 | 1362 |
1357 void LayoutTableSection::MarkAllCellsWidthsDirtyAndOrNeedsLayout( | 1363 void LayoutTableSection::MarkAllCellsWidthsDirtyAndOrNeedsLayout( |
1358 LayoutTable::WhatToMarkAllCells what_to_mark) { | 1364 LayoutTable::WhatToMarkAllCells what_to_mark) { |
1359 for (LayoutTableRow* row = FirstRow(); row; row = row->NextRow()) { | 1365 for (LayoutTableRow* row = FirstRow(); row; row = row->NextRow()) { |
1360 for (LayoutTableCell* cell = row->FirstCell(); cell; | 1366 for (LayoutTableCell* cell = row->FirstCell(); cell; |
1361 cell = cell->NextCell()) { | 1367 cell = cell->NextCell()) { |
1362 cell->SetPreferredLogicalWidthsDirty(); | 1368 cell->SetPreferredLogicalWidthsDirty(); |
1363 if (what_to_mark == LayoutTable::kMarkDirtyAndNeedsLayout) | 1369 if (what_to_mark == LayoutTable::kMarkDirtyAndNeedsLayout) |
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2168 bool LayoutTableSection::PaintedOutputOfObjectHasNoEffectRegardlessOfSize() | 2174 bool LayoutTableSection::PaintedOutputOfObjectHasNoEffectRegardlessOfSize() |
2169 const { | 2175 const { |
2170 // LayoutTableSection paints background from columns. | 2176 // LayoutTableSection paints background from columns. |
2171 if (Table()->HasColElements()) | 2177 if (Table()->HasColElements()) |
2172 return false; | 2178 return false; |
2173 return LayoutTableBoxComponent:: | 2179 return LayoutTableBoxComponent:: |
2174 PaintedOutputOfObjectHasNoEffectRegardlessOfSize(); | 2180 PaintedOutputOfObjectHasNoEffectRegardlessOfSize(); |
2175 } | 2181 } |
2176 | 2182 |
2177 } // namespace blink | 2183 } // namespace blink |
OLD | NEW |