Commit 9faf5981 authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

Always paint collapsed borders with the row DisplayItemClient.

This removes a reference to IsPaintInvalidationContainer in LayoutTable,
which in turn removes a dependency of PrePaint on compositing.

The need to paint on the table's DisplayItemClient appears to no longer
be necessary.

The code was added in:
https://chromium-review.googlesource.com/c/chromium/src/+/540178/

Change-Id: Ib1066d176511cfa4adc16579cc8aa7fc7475868f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2317848Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791715}
parent 46a70005
...@@ -60,7 +60,6 @@ LayoutTable::LayoutTable(Element* element) ...@@ -60,7 +60,6 @@ LayoutTable::LayoutTable(Element* element)
needs_adjust_collapsed_border_joints_(false), needs_adjust_collapsed_border_joints_(false),
needs_invalidate_collapsed_borders_for_all_cells_(false), needs_invalidate_collapsed_borders_for_all_cells_(false),
collapsed_outer_borders_valid_(false), collapsed_outer_borders_valid_(false),
should_paint_all_collapsed_borders_(false),
is_any_column_ever_collapsed_(false), is_any_column_ever_collapsed_(false),
has_col_elements_(false), has_col_elements_(false),
needs_section_recalc_(false), needs_section_recalc_(false),
...@@ -1675,13 +1674,11 @@ void LayoutTable::EnsureIsReadyForPaintInvalidation() { ...@@ -1675,13 +1674,11 @@ void LayoutTable::EnsureIsReadyForPaintInvalidation() {
collapsed_borders_valid_ = true; collapsed_borders_valid_ = true;
has_collapsed_borders_ = false; has_collapsed_borders_ = false;
needs_adjust_collapsed_border_joints_ = false; needs_adjust_collapsed_border_joints_ = false;
should_paint_all_collapsed_borders_ = false;
if (!ShouldCollapseBorders()) if (!ShouldCollapseBorders())
return; return;
CollapsedBorderValue first_border; CollapsedBorderValue first_border;
for (auto* section = TopSection(); section; section = SectionBelow(section)) { for (auto* section = TopSection(); section; section = SectionBelow(section)) {
bool section_may_be_composited = section->IsPaintInvalidationContainer();
for (auto* row = section->FirstRow(); row; row = row->NextRow()) { for (auto* row = section->FirstRow(); row; row = row->NextRow()) {
for (auto* cell = row->FirstCell(); cell; cell = cell->NextCell()) { for (auto* cell = row->FirstCell(); cell; cell = cell->NextCell()) {
DCHECK_EQ(cell->Table(), this); DCHECK_EQ(cell->Table(), this);
...@@ -1707,18 +1704,6 @@ void LayoutTable::EnsureIsReadyForPaintInvalidation() { ...@@ -1707,18 +1704,6 @@ void LayoutTable::EnsureIsReadyForPaintInvalidation() {
} }
} }
} }
// Collapsed borders should always be painted on the table's backing.
// If any row is not on the same composited layer as the table, the table
// should paint all collapsed borders.
if (has_collapsed_borders_ &&
(section_may_be_composited || row->IsPaintInvalidationContainer())) {
// Pass the row's paint invalidation flag to the table in case that the
// flag was set for collapsed borders.
if (row->ShouldDoFullPaintInvalidation())
SetShouldDoFullPaintInvalidation(PaintInvalidationReason::kStyle);
should_paint_all_collapsed_borders_ = true;
}
} }
} }
} }
......
...@@ -359,18 +359,6 @@ class CORE_EXPORT LayoutTable final : public LayoutBlock, ...@@ -359,18 +359,6 @@ class CORE_EXPORT LayoutTable final : public LayoutBlock,
return needs_adjust_collapsed_border_joints_; return needs_adjust_collapsed_border_joints_;
} }
// Returns true if the table has collapsed borders and any row doesn't paint
// onto the same compositing layer as the table (which is rare), and the table
// will create one display item for all collapsed borders. Otherwise each row
// will create one display item for collapsed borders.
// It always returns false for CAP.
bool ShouldPaintAllCollapsedBorders() const {
DCHECK(collapsed_borders_valid_);
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
DCHECK(!should_paint_all_collapsed_borders_);
return should_paint_all_collapsed_borders_;
}
bool HasSections() const { return Header() || Footer() || FirstBody(); } bool HasSections() const { return Header() || Footer() || FirstBody(); }
void RecalcSectionsIfNeeded() const final { void RecalcSectionsIfNeeded() const final {
...@@ -571,8 +559,6 @@ class CORE_EXPORT LayoutTable final : public LayoutBlock, ...@@ -571,8 +559,6 @@ class CORE_EXPORT LayoutTable final : public LayoutBlock,
bool needs_invalidate_collapsed_borders_for_all_cells_ : 1; bool needs_invalidate_collapsed_borders_for_all_cells_ : 1;
mutable bool collapsed_outer_borders_valid_ : 1; mutable bool collapsed_outer_borders_valid_ : 1;
bool should_paint_all_collapsed_borders_ : 1;
// Whether any column in the table section is or has been collapsed. // Whether any column in the table section is or has been collapsed.
bool is_any_column_ever_collapsed_ : 1; bool is_any_column_ever_collapsed_ : 1;
......
...@@ -45,17 +45,13 @@ void TableCellPaintInvalidator::InvalidatePaint() { ...@@ -45,17 +45,13 @@ void TableCellPaintInvalidator::InvalidatePaint() {
const auto& section = *row.Section(); const auto& section = *row.Section();
const auto& table = *section.Table(); const auto& table = *section.Table();
if (!DisplayItemClientIsFullyInvalidated(row) && if (!DisplayItemClientIsFullyInvalidated(row) &&
(row.StyleRef().HasBackground() || (row.StyleRef().HasBackground() || table.HasCollapsedBorders())) {
(table.HasCollapsedBorders() &&
LIKELY(!table.ShouldPaintAllCollapsedBorders())))) {
InvalidateContainerForCellGeometryChange(row, *context_.ParentContext()); InvalidateContainerForCellGeometryChange(row, *context_.ParentContext());
} // Mark the table as needing repaint, in order to paint collapsed borders.
context_.ParentContext()
if (UNLIKELY(table.ShouldPaintAllCollapsedBorders()) && ->ParentContext()
!DisplayItemClientIsFullyInvalidated(table)) { ->ParentContext()
DCHECK(table.HasCollapsedBorders()); ->painting_layer->SetNeedsRepaint();
InvalidateContainerForCellGeometryChange(
table, *context_.ParentContext()->ParentContext()->ParentContext());
} }
if (!DisplayItemClientIsFullyInvalidated(section)) { if (!DisplayItemClientIsFullyInvalidated(section)) {
......
...@@ -90,17 +90,6 @@ void TablePainter::PaintMask(const PaintInfo& paint_info, ...@@ -90,17 +90,6 @@ void TablePainter::PaintMask(const PaintInfo& paint_info,
void TablePainter::PaintCollapsedBorders(const PaintInfo& paint_info, void TablePainter::PaintCollapsedBorders(const PaintInfo& paint_info,
const PhysicalOffset& paint_offset) { const PhysicalOffset& paint_offset) {
base::Optional<BoxDrawingRecorder> recorder;
if (UNLIKELY(layout_table_.ShouldPaintAllCollapsedBorders())) {
if (DrawingRecorder::UseCachedDrawingIfPossible(
paint_info.context, layout_table_,
DisplayItem::kTableCollapsedBorders))
return;
recorder.emplace(paint_info.context, layout_table_,
DisplayItem::kTableCollapsedBorders, paint_offset);
}
// Otherwise each rows will create its own recorder.
for (LayoutTableSection* section = layout_table_.BottomSection(); section; for (LayoutTableSection* section = layout_table_.BottomSection(); section;
section = layout_table_.SectionAbove(section)) { section = layout_table_.SectionAbove(section)) {
TableSectionPainter(*section).PaintCollapsedBorders(paint_info); TableSectionPainter(*section).PaintCollapsedBorders(paint_info);
......
...@@ -122,18 +122,17 @@ void TableRowPainter::PaintCollapsedBorders(const PaintInfo& paint_info, ...@@ -122,18 +122,17 @@ void TableRowPainter::PaintCollapsedBorders(const PaintInfo& paint_info,
ScopedPaintState paint_state(layout_table_row_, paint_info); ScopedPaintState paint_state(layout_table_row_, paint_info);
base::Optional<BoxDrawingRecorder> recorder; base::Optional<BoxDrawingRecorder> recorder;
if (LIKELY(!layout_table_row_.Table()->ShouldPaintAllCollapsedBorders())) { HandleChangedPartialPaint(paint_info, dirtied_columns);
HandleChangedPartialPaint(paint_info, dirtied_columns);
if (DrawingRecorder::UseCachedDrawingIfPossible(
paint_info.context, layout_table_row_,
DisplayItem::kTableCollapsedBorders))
return;
if (DrawingRecorder::UseCachedDrawingIfPossible( recorder.emplace(paint_info.context, layout_table_row_,
paint_info.context, layout_table_row_, DisplayItem::kTableCollapsedBorders,
DisplayItem::kTableCollapsedBorders)) paint_state.PaintOffset());
return;
recorder.emplace(paint_info.context, layout_table_row_,
DisplayItem::kTableCollapsedBorders,
paint_state.PaintOffset());
}
// Otherwise TablePainter should have created the drawing recorder. // Otherwise TablePainter should have created the drawing recorder.
const auto* section = layout_table_row_.Section(); const auto* section = layout_table_row_.Section();
......
...@@ -145,16 +145,9 @@ void TableSectionPainter::PaintCollapsedSectionBorders( ...@@ -145,16 +145,9 @@ void TableSectionPainter::PaintCollapsedSectionBorders(
CellSpan dirtied_rows; CellSpan dirtied_rows;
CellSpan dirtied_columns; CellSpan dirtied_columns;
if (UNLIKELY( layout_table_section_.DirtiedRowsAndEffectiveColumns(
layout_table_section_.Table()->ShouldPaintAllCollapsedBorders())) { TableAlignedRect(local_paint_info, paint_offset), dirtied_rows,
// Ignore paint cull rect to simplify paint invalidation in such rare case. dirtied_columns);
dirtied_rows = layout_table_section_.FullSectionRowSpan();
dirtied_columns = layout_table_section_.FullTableEffectiveColumnSpan();
} else {
layout_table_section_.DirtiedRowsAndEffectiveColumns(
TableAlignedRect(local_paint_info, paint_offset), dirtied_rows,
dirtied_columns);
}
if (dirtied_columns.Start() >= dirtied_columns.End()) if (dirtied_columns.Start() >= dirtied_columns.End())
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment