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

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

Issue 2851553002: Invalidate row/section for backgrounds when cell's geometry changes (Closed)
Patch Set: Created 3 years, 8 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/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

Powered by Google App Engine
This is Rietveld 408576698