Commit e0378662 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Fix under-invalidation of collapsed borders when rowspan changes

Bug: 771375
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I09800a720d35f82921226e76b5d5fe4442bb5d9c
Reviewed-on: https://chromium-review.googlesource.com/699660Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506545}
parent f18dc482
{
"layers": [
{
"name": "LayoutView #document",
"bounds": [800, 600],
"contentsOpaque": true,
"backgroundColor": "#FFFFFF",
"paintInvalidations": [
{
"object": "LayoutTableRow TR id='row1'",
"rect": [8, 8, 200, 300],
"reason": "style change"
},
{
"object": "LayoutTableRow TR id='row3'",
"rect": [8, 207, 200, 101],
"reason": "style change"
},
{
"object": "LayoutTableRow TR id='row2'",
"rect": [8, 107, 200, 101],
"reason": "style change"
}
]
}
],
"objectPaintInvalidations": [
{
"object": "LayoutTable TABLE",
"reason": "full"
},
{
"object": "LayoutTableSection TBODY",
"reason": "geometry"
},
{
"object": "LayoutTableRow TR id='row1'",
"reason": "style change"
},
{
"object": "LayoutTableCell TD id='cell1'",
"reason": "full"
},
{
"object": "LayoutTableRow TR id='row2'",
"reason": "style change"
},
{
"object": "LayoutTableRow TR id='row3'",
"reason": "style change"
}
]
}
<!DOCTYPE html>
<style>
td { border: 1px black solid }
</style>
<table style="border-collapse: collapse; width: 200px; height: 300px">
<tr>
<td rowspan="3"></td>
<td></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td></td>
</tr>
</table>
{
"layers": [
{
"name": "LayoutView #document",
"bounds": [800, 600],
"contentsOpaque": true,
"backgroundColor": "#FFFFFF",
"paintInvalidations": [
{
"object": "LayoutTable TABLE",
"rect": [8, 8, 200, 300],
"reason": "full"
},
{
"object": "LayoutTableRow TR id='row1'",
"rect": [8, 8, 200, 300],
"reason": "style change"
},
{
"object": "LayoutTableSection TBODY",
"rect": [8, 8, 200, 300],
"reason": "geometry"
},
{
"object": "LayoutTableRow TR id='row3'",
"rect": [8, 207, 200, 101],
"reason": "style change"
},
{
"object": "LayoutTableRow TR id='row2'",
"rect": [8, 107, 200, 101],
"reason": "style change"
},
{
"object": "LayoutTableCell TD id='cell1'",
"rect": [8, 8, 99, 299],
"reason": "full"
},
{
"object": "LayoutTableCell TD id='cell3'",
"rect": [8, 207, 99, 100],
"reason": "disappeared"
},
{
"object": "LayoutTableCell TD id='cell2'",
"rect": [8, 107, 99, 100],
"reason": "disappeared"
}
]
}
],
"objectPaintInvalidations": [
{
"object": "LayoutTableCell TD id='cell3'",
"reason": "disappeared"
},
{
"object": "LayoutTableCell TD id='cell2'",
"reason": "disappeared"
},
{
"object": "LayoutTable TABLE",
"reason": "full"
},
{
"object": "LayoutTableSection TBODY",
"reason": "geometry"
},
{
"object": "LayoutTableRow TR id='row1'",
"reason": "style change"
},
{
"object": "LayoutTableCell TD id='cell1'",
"reason": "full"
},
{
"object": "LayoutTableRow TR id='row2'",
"reason": "style change"
},
{
"object": "LayoutTableRow TR id='row3'",
"reason": "style change"
}
]
}
<!DOCTYPE html>
<style>
td { border: 1px black solid }
</style>
<table style="border-collapse: collapse; width: 200px; height: 300px">
<tr id="row1">
<td id="cell1"></td>
<td></td>
</tr>
<tr id="row2">
<td id="cell2"></td>
<td></td>
</tr>
<tr id="row3">
<td id="cell3"></td>
<td></td>
</tr>
</table>
<script src="../resources/text-based-repaint.js"></script>
<script>
function repaintTest() {
cell2.style.display = 'none';
cell3.style.display = 'none';
cell1.setAttribute('rowspan', '3');
}
onload = runRepaintAndPixelTest;
</script>
...@@ -63,6 +63,7 @@ LayoutTableCell::LayoutTableCell(Element* element) ...@@ -63,6 +63,7 @@ LayoutTableCell::LayoutTableCell(Element* element)
is_spanning_collapsed_row_(false), is_spanning_collapsed_row_(false),
is_spanning_collapsed_column_(false), is_spanning_collapsed_column_(false),
collapsed_border_values_valid_(false), collapsed_border_values_valid_(false),
collapsed_borders_need_paint_invalidation_(false),
intrinsic_padding_before_(0), intrinsic_padding_before_(0),
intrinsic_padding_after_(0) { intrinsic_padding_after_(0) {
// We only update the flags when notified of DOM changes in // We only update the flags when notified of DOM changes in
...@@ -129,8 +130,11 @@ void LayoutTableCell::ColSpanOrRowSpanChanged() { ...@@ -129,8 +130,11 @@ void LayoutTableCell::ColSpanOrRowSpanChanged() {
SetNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( SetNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(
LayoutInvalidationReason::kAttributeChanged); LayoutInvalidationReason::kAttributeChanged);
if (Parent() && Section()) if (Parent() && Section()) {
Section()->SetNeedsCellRecalc(); Section()->SetNeedsCellRecalc();
if (Table() && Table()->ShouldCollapseBorders())
collapsed_borders_need_paint_invalidation_ = true;
}
} }
Length LayoutTableCell::LogicalWidthFromColumns( Length LayoutTableCell::LogicalWidthFromColumns(
...@@ -1097,9 +1101,16 @@ void LayoutTableCell::UpdateCollapsedBorderValues() const { ...@@ -1097,9 +1101,16 @@ void LayoutTableCell::UpdateCollapsedBorderValues() const {
} }
} }
// Invalidate the row which will paint the collapsed borders. if (!changed && !collapsed_borders_need_paint_invalidation_)
if (changed) return;
Row()->SetShouldDoFullPaintInvalidation(PaintInvalidationReason::kStyle);
// Invalidate the rows which will paint the collapsed borders.
auto row_span = RowSpan();
for (auto r = RowIndex(); r < RowIndex() + row_span; ++r) {
if (auto* row = Section()->RowLayoutObjectAt(r))
row->SetShouldDoFullPaintInvalidation(PaintInvalidationReason::kStyle);
}
collapsed_borders_need_paint_invalidation_ = false;
} }
void LayoutTableCell::PaintBoxDecorationBackground( void LayoutTableCell::PaintBoxDecorationBackground(
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
namespace blink { namespace blink {
#define BITS_OF_ABSOLUTE_COLUMN_INDEX 26 #define BITS_OF_ABSOLUTE_COLUMN_INDEX 25
static const unsigned kUnsetColumnIndex = static const unsigned kUnsetColumnIndex =
(1u << BITS_OF_ABSOLUTE_COLUMN_INDEX) - 1; (1u << BITS_OF_ABSOLUTE_COLUMN_INDEX) - 1;
static const unsigned kMaxColumnIndex = kUnsetColumnIndex - 1; static const unsigned kMaxColumnIndex = kUnsetColumnIndex - 1;
...@@ -496,8 +496,9 @@ class CORE_EXPORT LayoutTableCell final : public LayoutBlockFlow { ...@@ -496,8 +496,9 @@ class CORE_EXPORT LayoutTableCell final : public LayoutBlockFlow {
unsigned is_spanning_collapsed_row_ : 1; unsigned is_spanning_collapsed_row_ : 1;
unsigned is_spanning_collapsed_column_ : 1; unsigned is_spanning_collapsed_column_ : 1;
// This is set when collapsed_border_values_ needs recalculation. // This is set to false when |collapsed_border_values_| needs update.
mutable unsigned collapsed_border_values_valid_ : 1; mutable unsigned collapsed_border_values_valid_ : 1;
mutable unsigned collapsed_borders_need_paint_invalidation_ : 1;
mutable std::unique_ptr<CollapsedBorderValues> collapsed_border_values_; mutable std::unique_ptr<CollapsedBorderValues> collapsed_border_values_;
// The intrinsic padding. // The intrinsic padding.
......
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