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

Unified Diff: third_party/WebKit/Source/core/paint/TableSectionPainter.cpp

Issue 2884763003: Combine and simplify LayoutTableSection::DirtiedRows() and DirtiedEffectiveColumns() (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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/TableSectionPainter.cpp
diff --git a/third_party/WebKit/Source/core/paint/TableSectionPainter.cpp b/third_party/WebKit/Source/core/paint/TableSectionPainter.cpp
index 18fb12a6ef3c8d28f42d6e891c64d05c331f6c5a..3bc333896e7460dcaff0800e981e6d8e642c46b5 100644
--- a/third_party/WebKit/Source/core/paint/TableSectionPainter.cpp
+++ b/third_party/WebKit/Source/core/paint/TableSectionPainter.cpp
@@ -109,11 +109,6 @@ void TableSectionPainter::PaintSection(const PaintInfo& paint_info,
.PaintOutline(paint_info, adjusted_paint_offset);
}
-static inline bool CompareCellPositions(const LayoutTableCell* elem1,
- const LayoutTableCell* elem2) {
- return elem1->RowIndex() < elem2->RowIndex();
-}
-
void TableSectionPainter::PaintCollapsedBorders(
const PaintInfo& paint_info,
const LayoutPoint& paint_offset,
@@ -145,19 +140,20 @@ void TableSectionPainter::PaintCollapsedSectionBorders(
layout_table_section_.LogicalRectForWritingModeAndDirection(
local_visual_rect);
- CellSpan dirtied_rows = layout_table_section_.DirtiedRows(table_aligned_rect);
- CellSpan dirtied_columns =
- layout_table_section_.DirtiedEffectiveColumns(table_aligned_rect);
+ CellSpan dirtied_rows;
+ CellSpan dirtied_columns;
+ layout_table_section_.DirtiedRowsAndEffectiveColumns(
+ table_aligned_rect, dirtied_rows, dirtied_columns);
- if (dirtied_columns.Start() >= dirtied_columns.end())
+ if (dirtied_columns.Start() >= dirtied_columns.End())
return;
// Collapsed borders are painted from the bottom right to the top left so that
// precedence due to cell position is respected.
- for (unsigned r = dirtied_rows.end(); r > dirtied_rows.Start(); r--) {
+ for (unsigned r = dirtied_rows.End(); r > dirtied_rows.Start(); r--) {
unsigned row = r - 1;
unsigned n_cols = layout_table_section_.NumEffectiveColumns(row);
- for (unsigned c = std::min(dirtied_columns.end(), n_cols);
+ for (unsigned c = std::min(dirtied_columns.End(), n_cols);
c > dirtied_columns.Start(); c--) {
unsigned col = c - 1;
if (const LayoutTableCell* cell =
@@ -181,9 +177,10 @@ void TableSectionPainter::PaintObject(const PaintInfo& paint_info,
layout_table_section_.LogicalRectForWritingModeAndDirection(
local_visual_rect);
- CellSpan dirtied_rows = layout_table_section_.DirtiedRows(table_aligned_rect);
- CellSpan dirtied_columns =
- layout_table_section_.DirtiedEffectiveColumns(table_aligned_rect);
+ CellSpan dirtied_rows;
+ CellSpan dirtied_columns;
+ layout_table_section_.DirtiedRowsAndEffectiveColumns(
+ table_aligned_rect, dirtied_rows, dirtied_columns);
PaintInfo paint_info_for_descendants = paint_info.ForDescendants();
@@ -196,7 +193,7 @@ void TableSectionPainter::PaintObject(const PaintInfo& paint_info,
return;
if (ShouldPaintDescendantBlockBackgrounds(paint_info.phase)) {
- for (unsigned r = dirtied_rows.Start(); r < dirtied_rows.end(); r++) {
+ for (unsigned r = dirtied_rows.Start(); r < dirtied_rows.End(); r++) {
const LayoutTableRow* row = layout_table_section_.RowLayoutObjectAt(r);
// If a row has a layer, we'll paint row background though
// TableRowPainter::paint().
@@ -210,16 +207,14 @@ void TableSectionPainter::PaintObject(const PaintInfo& paint_info,
// This is tested after background painting because during background painting
// we need to check validity of the previous background display item based on
// dirtyRows and dirtyColumns.
- if (dirtied_rows.Start() >= dirtied_rows.end() ||
- dirtied_columns.Start() >= dirtied_columns.end())
+ if (dirtied_rows.Start() >= dirtied_rows.End() ||
+ dirtied_columns.Start() >= dirtied_columns.End())
return;
const auto& overflowing_cells = layout_table_section_.OverflowingCells();
- if (!layout_table_section_.HasMultipleCellLevels() &&
- overflowing_cells.IsEmpty()) {
+ if (overflowing_cells.IsEmpty()) {
// This path is for 2 cases:
- // 1. Normal partial paint, without overflowing cells and multiple cell
- // levels;
+ // 1. Normal partial paint, without overflowing cells;
// 2. Full paint, for small sections or big sections with many overflowing
// cells.
// The difference between the normal partial paint and full paint is that
@@ -229,7 +224,7 @@ void TableSectionPainter::PaintObject(const PaintInfo& paint_info,
dirtied_columns ==
layout_table_section_.FullTableEffectiveColumnSpan()));
- for (unsigned r = dirtied_rows.Start(); r < dirtied_rows.end(); r++) {
+ for (unsigned r = dirtied_rows.Start(); r < dirtied_rows.End(); r++) {
const LayoutTableRow* row = layout_table_section_.RowLayoutObjectAt(r);
// TODO(crbug.com/577282): This painting order is inconsistent with other
// outlines.
@@ -238,7 +233,7 @@ void TableSectionPainter::PaintObject(const PaintInfo& paint_info,
TableRowPainter(*row).PaintOutline(paint_info_for_descendants,
paint_offset);
}
- for (unsigned c = dirtied_columns.Start(); c < dirtied_columns.end();
+ for (unsigned c = dirtied_columns.Start(); c < dirtied_columns.End();
c++) {
if (const LayoutTableCell* cell =
layout_table_section_.OriginatingCellAt(r, c))
@@ -246,14 +241,14 @@ void TableSectionPainter::PaintObject(const PaintInfo& paint_info,
}
}
} else {
- // This path paints section with multiple cell levels or a reasonable number
- // of overflowing cells. This is the "partial paint path" for overflowing
- // cells referred in LayoutTableSection::ComputeOverflowFromDescendants().
+ // This path paints section with a reasonable number of overflowing cells.
+ // This is the "partial paint path" for overflowing cells referred in
+ // LayoutTableSection::ComputeOverflowFromDescendants().
Vector<const LayoutTableCell*> cells;
CopyToVector(overflowing_cells, cells);
HashSet<const LayoutTableCell*> spanning_cells;
- for (unsigned r = dirtied_rows.Start(); r < dirtied_rows.end(); r++) {
+ for (unsigned r = dirtied_rows.Start(); r < dirtied_rows.End(); r++) {
const LayoutTableRow* row = layout_table_section_.RowLayoutObjectAt(r);
// TODO(crbug.com/577282): This painting order is inconsistent with other
// outlines.
@@ -264,30 +259,16 @@ void TableSectionPainter::PaintObject(const PaintInfo& paint_info,
}
unsigned n_cols = layout_table_section_.NumEffectiveColumns(r);
for (unsigned c = dirtied_columns.Start();
- c < n_cols && c < dirtied_columns.end(); c++) {
- for (const auto* cell :
- layout_table_section_.GridCellAt(r, c).Cells()) {
- if (overflowing_cells.Contains(cell))
- continue;
- if (cell->RowSpan() > 1 || cell->ColSpan() > 1) {
- if (!spanning_cells.insert(cell).is_new_entry)
- continue;
- }
- cells.push_back(cell);
+ c < n_cols && c < dirtied_columns.End(); c++) {
+ if (const auto* cell = layout_table_section_.OriginatingCellAt(r, c)) {
+ if (!overflowing_cells.Contains(cell))
+ cells.push_back(cell);
Xianzhu 2017/05/16 17:18:13 This is simplified because dirtied_columns and dir
}
}
}
// Sort the dirty cells by paint order.
- if (!overflowing_cells.size()) {
- std::stable_sort(cells.begin(), cells.end(), CompareCellPositions);
- } else {
- // This comparison is used only when we have overflowing cells as we have
- // an unsorted array to sort. We thus need to sort both on rows and
- // columns to paint in proper order.
- std::sort(cells.begin(), cells.end(), LayoutTableCell::CompareInDOMOrder);
- }
-
+ std::sort(cells.begin(), cells.end(), LayoutTableCell::CompareInDOMOrder);
Xianzhu 2017/05/16 17:18:13 Now only one sort method left because we enter thi
for (const auto* cell : cells)
PaintCell(*cell, paint_info_for_descendants, paint_offset);
}
@@ -331,8 +312,8 @@ void TableSectionPainter::PaintBoxDecorationBackground(
if (may_have_background) {
PaintInfo paint_info_for_cells = paint_info.ForDescendants();
- for (auto r = dirtied_rows.Start(); r < dirtied_rows.end(); r++) {
- for (auto c = dirtied_columns.Start(); c < dirtied_columns.end(); c++) {
+ for (auto r = dirtied_rows.Start(); r < dirtied_rows.End(); r++) {
+ for (auto c = dirtied_columns.Start(); c < dirtied_columns.End(); c++) {
if (const auto* cell = layout_table_section_.OriginatingCellAt(r, c)) {
PaintBackgroundsBehindCell(*cell, paint_info_for_cells, paint_offset);
}

Powered by Google App Engine
This is Rietveld 408576698