OLD | NEW |
(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::InvalidatePaint() { |
| 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 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) |
| 28 context_.parent_context->painting_layer->SetNeedsRepaint(); |
| 29 else |
| 30 ObjectPaintInvalidator(row).SlowSetPaintingLayerNeedsRepaint(); |
| 31 row.InvalidateDisplayItemClients(kPaintInvalidationForcedByLayout); |
| 32 } |
| 33 |
| 34 const auto& section = *row.Section(); |
| 35 if (section.GetPaintInvalidationReason() == kPaintInvalidationNone) { |
| 36 bool section_paints_background = section.StyleRef().HasBackground(); |
| 37 if (!section_paints_background) { |
| 38 auto col_and_colgroup = section.Table()->ColElementAtAbsoluteColumn( |
| 39 cell_.AbsoluteColumnIndex()); |
| 40 if ((col_and_colgroup.col && |
| 41 col_and_colgroup.col->StyleRef().HasBackground()) || |
| 42 (col_and_colgroup.colgroup && |
| 43 col_and_colgroup.colgroup->StyleRef().HasBackground())) |
| 44 section_paints_background = true; |
| 45 } |
| 46 if (section_paints_background) { |
| 47 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) { |
| 48 context_.parent_context->parent_context->painting_layer |
| 49 ->SetNeedsRepaint(); |
| 50 } else { |
| 51 ObjectPaintInvalidator(section).SlowSetPaintingLayerNeedsRepaint(); |
| 52 } |
| 53 section.InvalidateDisplayItemClients(kPaintInvalidationForcedByLayout); |
| 54 } |
| 55 } |
| 56 } |
| 57 |
| 58 return BlockPaintInvalidator(cell_).InvalidatePaint(context_); |
| 59 } |
| 60 |
| 61 } // namespace blink |
OLD | NEW |