Commit 97c55dd1 authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

SetNeedsPaint on tables when collapsed borders change

Tables always paint collapsed borders, even if the rows are seprately
composited. While we don't need to invalidate paint for the table
(because the row is the DisplayItemClient for the borders), we do need
to cause repaint for its painting layer, because the table paints those
borders.

See also (*), which removed the code that previously had the same
effect. There was previously no test for this code.

(*) https://chromium-review.googlesource.com/c/chromium/src/+/2317848

Change-Id: I269101d3bf28445c0ec3d1f6bcad1a23cf3e46d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2321234
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#792138}
parent 3be7110a
......@@ -34,6 +34,8 @@
#include "third_party/blink/renderer/core/layout/layout_table_cell.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/layout/subtree_layout_scope.h"
#include "third_party/blink/renderer/core/paint/paint_invalidator.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/paint/table_row_painter.h"
namespace blink {
......@@ -124,6 +126,17 @@ void LayoutTableRow::StyleDidChange(StyleDifference diff,
}
}
void LayoutTableRow::InvalidatePaint(
const PaintInvalidatorContext& context) const {
LayoutTableBoxComponent::InvalidatePaint(context);
if (Table()->HasCollapsedBorders()) {
// Repaint the painting layer of the table. The table's composited backing
// always paints collapsed borders (even though it uses the row as a
// DisplayItemClient).
context.ParentContext()->ParentContext()->painting_layer->SetNeedsRepaint();
}
}
void LayoutTableRow::AddChild(LayoutObject* child, LayoutObject* before_child) {
if (!child->IsTableCell()) {
LayoutObject* last = before_child;
......
......@@ -125,6 +125,9 @@ class CORE_EXPORT LayoutTableRow final : public LayoutTableBoxComponent,
bool BackgroundIsKnownToBeOpaqueInRect(const PhysicalRect&) const override {
return false;
}
void InvalidatePaint(const PaintInvalidatorContext&) const final;
// LayoutNGTableRowInterface methods start.
const LayoutNGTableRowInterface* ToLayoutNGTableRowInterface() const final {
......
......@@ -133,8 +133,6 @@ void TableRowPainter::PaintCollapsedBorders(const PaintInfo& paint_info,
DisplayItem::kTableCollapsedBorders,
paint_state.PaintOffset());
// Otherwise TablePainter should have created the drawing recorder.
const auto* section = layout_table_row_.Section();
unsigned row = layout_table_row_.RowIndex();
for (unsigned c = std::min(dirtied_columns.End(), section->NumCols(row));
......
<!doctype HTML>
<html>
<link rel="author" title="Chris Harrelson" href="mailto:chrishtr@chromium.org">
<link rel="help" href="https://www.w3.org/TR/CSS2/tables.html#borders">
<link rel="help" href="https://drafts.csswg.org/css-will-change/#will-change">
<style>
td { border: 3px solid black; }
.composited { will-change: transform; }
</style>
<table style="border-collapse: collapse">
<tr class=composited>
<td style="border-color: green">First</td>
<td >Second</td>
</tr>
<tr class=composited>
<td>Third</td>
<td>Fourth</td>
</tr>
</table>
</html>
<!doctype HTML>
<html class=reftest-wait>
<link rel="author" title="Chris Harrelson" href="mailto:chrishtr@chromium.org">
<link rel="help" href="https://www.w3.org/TR/CSS2/tables.html#borders">
<link rel="help" href="https://drafts.csswg.org/css-will-change/#will-change">
<link rel="match" href="collapsed-border-color-change-with-compositing-ref.html">
<script src="/common/reftest-wait.js"></script>
<style>
td { border: 3px solid black; }
.composited { will-change: transform; }
</style>
<table style="border-collapse: collapse">
<tr class=composited>
<td id=target style="border-color: red">First</td>
<td >Second</td>
</tr>
<tr class=composited>
<td>Third</td>
<td>Fourth</td>
</tr>
</table>
</html>
<script>
onload = () => requestAnimationFrame(() =>
requestAnimationFrame(() => {
target.style.borderColor = 'green';
document.documentElement.classList.remove('reftest-wait');
}));
</script>
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