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

Side by Side 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, 7 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/paint/TableCellPaintInvalidator.h"
6
7 #include "core/layout/LayoutTable.h"
8 #include "core/layout/LayoutTableCell.h"
9 #include "core/layout/LayoutTableCol.h"
10 #include "core/layout/LayoutTableRow.h"
11 #include "core/layout/LayoutTableSection.h"
12 #include "core/paint/BlockPaintInvalidator.h"
13 #include "core/paint/ObjectPaintInvalidator.h"
14 #include "core/paint/PaintInvalidator.h"
15 #include "core/paint/PaintLayer.h"
16
17 namespace blink {
18
19 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
20 // The cell's containing row and section paint backgrounds behind the cell.
21 // If the cell's geometry changed, invalidate the background display items.
22 if (context_.old_location != context_.new_location ||
23 cell_.Size() != cell_.PreviousSize()) {
24 const auto& row = *cell_.Row();
25 if (row.GetPaintInvalidationReason() == kPaintInvalidationNone &&
26 row.StyleRef().HasBackground()) {
27 context_.parent_context->painting_layer->SetNeedsRepaint();
28 row.InvalidateDisplayItemClients(kPaintInvalidationForcedByLayout);
29 }
30
31 const auto& section = *row.Section();
32 if (section.GetPaintInvalidationReason() == kPaintInvalidationNone) {
33 bool section_paints_background = section.StyleRef().HasBackground();
34 if (!section_paints_background) {
35 auto col_and_colgroup = section.Table()->ColElementAtAbsoluteColumn(
36 cell_.AbsoluteColumnIndex());
37 if ((col_and_colgroup.col &&
38 col_and_colgroup.col->StyleRef().HasBackground()) ||
39 (col_and_colgroup.colgroup &&
40 col_and_colgroup.colgroup->StyleRef().HasBackground()))
41 section_paints_background = true;
42 }
43 if (section_paints_background) {
44 context_.parent_context->parent_context->painting_layer
45 ->SetNeedsRepaint();
46 section.InvalidateDisplayItemClients(kPaintInvalidationForcedByLayout);
47 }
48 }
49 }
50
51 return BlockPaintInvalidator(cell_).InvalidatePaintIfNeeded(context_);
52 }
53
54 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698