Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutTableSection.cpp

Issue 2861373003: Let table row and section's self visual overflow cover whole collapsed borders (Closed)
Patch Set: - Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 m_forcesSlowPaintPath only if there is a least one
wkorman 2017/05/08 17:51:23 a least -> at least
Xianzhu 2017/05/09 03:55:43 Done.
Xianzhu 2017/05/09 03:55:43 Done.
1310 overflowing_cells_.insert(cell); 1317 // overflowing cells as the hit testing code rely on this information.
wkorman 2017/05/08 17:51:23 cells -> cell, rely -> relies
Xianzhu 2017/05/09 03:55:43 Done.
1311 if (overflowing_cells_.size() > max_allowed_overflowing_cells_count) { 1318 force_slow_paint_path_with_overflowing_cell_ = true;
1312 // We need to set m_forcesSlowPaintPath only if there is a least one 1319 // The slow path does not make any use of the overflowing cells info,
1313 // overflowing cells as the hit testing code rely on this information. 1320 // don't hold on to the memory.
1314 force_slow_paint_path_with_overflowing_cell_ = true; 1321 overflowing_cells_.clear();
1315 // The slow path does not make any use of the overflowing cells info, 1322 continue;
1316 // don't hold on to the memory.
1317 overflowing_cells_.clear();
1318 }
1319 } 1323 }
1324
1325 overflowing_cells_.insert(cell);
1320 } 1326 }
1321 } 1327 }
1322 1328
1323 #if DCHECK_IS_ON() 1329 #if DCHECK_IS_ON()
1324 DCHECK_EQ(has_overflowing_cell, this->HasOverflowingCell()); 1330 DCHECK_EQ(has_overflowing_cell, this->HasOverflowingCell());
1325 #endif 1331 #endif
1326 } 1332 }
1327 1333
1328 bool LayoutTableSection::RecalcChildOverflowAfterStyleChange() { 1334 bool LayoutTableSection::RecalcChildOverflowAfterStyleChange() {
1329 DCHECK(ChildNeedsOverflowRecalcAfterStyleChange()); 1335 DCHECK(ChildNeedsOverflowRecalcAfterStyleChange());
(...skipping 11 matching lines...) Expand all
1341 for (unsigned c = 0; c < n_cols; c++) { 1347 for (unsigned c = 0; c < n_cols; c++) {
1342 auto* cell = OriginatingCellAt(r, c); 1348 auto* cell = OriginatingCellAt(r, c);
1343 if (!cell || !cell->NeedsOverflowRecalcAfterStyleChange()) 1349 if (!cell || !cell->NeedsOverflowRecalcAfterStyleChange())
1344 continue; 1350 continue;
1345 row_children_overflow_changed |= cell->RecalcOverflowAfterStyleChange(); 1351 row_children_overflow_changed |= cell->RecalcOverflowAfterStyleChange();
1346 } 1352 }
1347 if (row_children_overflow_changed) 1353 if (row_children_overflow_changed)
1348 row_layouter->ComputeOverflow(); 1354 row_layouter->ComputeOverflow();
1349 children_overflow_changed |= row_children_overflow_changed; 1355 children_overflow_changed |= row_children_overflow_changed;
1350 } 1356 }
1351 // TODO(crbug.com/604136): Add visual overflow from rows too.
1352 if (children_overflow_changed) 1357 if (children_overflow_changed)
1353 ComputeOverflowFromCells(total_rows, Table()->NumEffectiveColumns()); 1358 ComputeOverflowFromDescendants();
1354 return children_overflow_changed; 1359 return children_overflow_changed;
1355 } 1360 }
1356 1361
1357 void LayoutTableSection::MarkAllCellsWidthsDirtyAndOrNeedsLayout( 1362 void LayoutTableSection::MarkAllCellsWidthsDirtyAndOrNeedsLayout(
1358 LayoutTable::WhatToMarkAllCells what_to_mark) { 1363 LayoutTable::WhatToMarkAllCells what_to_mark) {
1359 for (LayoutTableRow* row = FirstRow(); row; row = row->NextRow()) { 1364 for (LayoutTableRow* row = FirstRow(); row; row = row->NextRow()) {
1360 for (LayoutTableCell* cell = row->FirstCell(); cell; 1365 for (LayoutTableCell* cell = row->FirstCell(); cell;
1361 cell = cell->NextCell()) { 1366 cell = cell->NextCell()) {
1362 cell->SetPreferredLogicalWidthsDirty(); 1367 cell->SetPreferredLogicalWidthsDirty();
1363 if (what_to_mark == LayoutTable::kMarkDirtyAndNeedsLayout) 1368 if (what_to_mark == LayoutTable::kMarkDirtyAndNeedsLayout)
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
2168 bool LayoutTableSection::PaintedOutputOfObjectHasNoEffectRegardlessOfSize() 2173 bool LayoutTableSection::PaintedOutputOfObjectHasNoEffectRegardlessOfSize()
2169 const { 2174 const {
2170 // LayoutTableSection paints background from columns. 2175 // LayoutTableSection paints background from columns.
2171 if (Table()->HasColElements()) 2176 if (Table()->HasColElements())
2172 return false; 2177 return false;
2173 return LayoutTableBoxComponent:: 2178 return LayoutTableBoxComponent::
2174 PaintedOutputOfObjectHasNoEffectRegardlessOfSize(); 2179 PaintedOutputOfObjectHasNoEffectRegardlessOfSize();
2175 } 2180 }
2176 2181
2177 } // namespace blink 2182 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698