Chromium Code Reviews| Index: third_party/WebKit/Source/core/paint/TableCellPaintInvalidator.cpp |
| diff --git a/third_party/WebKit/Source/core/paint/TableCellPaintInvalidator.cpp b/third_party/WebKit/Source/core/paint/TableCellPaintInvalidator.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..970fc1d101f2d75d8ef2e180c0e81ea7c5d2039a |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/paint/TableCellPaintInvalidator.cpp |
| @@ -0,0 +1,54 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "core/paint/TableCellPaintInvalidator.h" |
| + |
| +#include "core/layout/LayoutTable.h" |
| +#include "core/layout/LayoutTableCell.h" |
| +#include "core/layout/LayoutTableCol.h" |
| +#include "core/layout/LayoutTableRow.h" |
| +#include "core/layout/LayoutTableSection.h" |
| +#include "core/paint/BlockPaintInvalidator.h" |
| +#include "core/paint/ObjectPaintInvalidator.h" |
| +#include "core/paint/PaintInvalidator.h" |
| +#include "core/paint/PaintLayer.h" |
| + |
| +namespace blink { |
| + |
| +PaintInvalidationReason TableCellPaintInvalidator::InvalidatePaintIfNeeded() { |
|
wkorman
2017/04/27 22:30:23
Can we add a unit test for this new class/logic? I
Xianzhu
2017/04/28 00:31:06
I'm not sure how a unit test would benefit us for
wkorman
2017/04/28 02:24:54
Well, unit tests are faster, less flaky, and are c
|
| + // The cell's containing row and section paint backgrounds behind the cell. |
| + // If the cell's geometry changed, invalidate the background display items. |
| + if (context_.old_location != context_.new_location || |
| + cell_.Size() != cell_.PreviousSize()) { |
| + const auto& row = *cell_.Row(); |
| + if (row.GetPaintInvalidationReason() == kPaintInvalidationNone && |
| + row.StyleRef().HasBackground()) { |
| + context_.parent_context->painting_layer->SetNeedsRepaint(); |
| + row.InvalidateDisplayItemClients(kPaintInvalidationForcedByLayout); |
| + } |
| + |
| + const auto& section = *row.Section(); |
| + if (section.GetPaintInvalidationReason() == kPaintInvalidationNone) { |
| + bool section_paints_background = section.StyleRef().HasBackground(); |
| + if (!section_paints_background) { |
| + auto col_and_colgroup = section.Table()->ColElementAtAbsoluteColumn( |
| + cell_.AbsoluteColumnIndex()); |
| + if ((col_and_colgroup.col && |
| + col_and_colgroup.col->StyleRef().HasBackground()) || |
| + (col_and_colgroup.colgroup && |
| + col_and_colgroup.colgroup->StyleRef().HasBackground())) |
| + section_paints_background = true; |
| + } |
| + if (section_paints_background) { |
| + context_.parent_context->parent_context->painting_layer |
| + ->SetNeedsRepaint(); |
| + section.InvalidateDisplayItemClients(kPaintInvalidationForcedByLayout); |
| + } |
| + } |
| + } |
| + |
| + return BlockPaintInvalidator(cell_).InvalidatePaintIfNeeded(context_); |
| +} |
| + |
| +} // namespace blink |