OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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/TablePaintInvalidator.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/BoxPaintInvalidator.h" |
| 13 #include "core/paint/PaintInvalidator.h" |
| 14 |
| 15 namespace blink { |
| 16 |
| 17 PaintInvalidationReason TablePaintInvalidator::invalidatePaintIfNeeded() |
| 18 { |
| 19 PaintInvalidationReason reason = BoxPaintInvalidator(m_table, m_context).inv
alidatePaintIfNeeded(); |
| 20 |
| 21 // Table cells paint background from the containing column group, column, se
ction and row. |
| 22 // If background of any of them changed, we need to invalidate all affected
cells. |
| 23 // Here use shouldDoFullPaintInvalidation() as a broader condition of backgr
ound change. |
| 24 |
| 25 // If any col changed background, we'll check all cells for background chang
es. |
| 26 bool hasColChangedBackground = false; |
| 27 for (LayoutTableCol* col = m_table.firstColumn(); col; col = col->nextColumn
()) { |
| 28 if (col->backgroundChangedSinceLastPaintInvalidation()) { |
| 29 hasColChangedBackground = true; |
| 30 break; |
| 31 } |
| 32 } |
| 33 for (LayoutObject* child = m_table.firstChild(); child; child = child->nextS
ibling()) { |
| 34 if (!child->isTableSection()) |
| 35 continue; |
| 36 LayoutTableSection* section = toLayoutTableSection(child); |
| 37 if (!hasColChangedBackground && !section->shouldCheckForPaintInvalidatio
nRegardlessOfPaintInvalidationState()) |
| 38 continue; |
| 39 for (LayoutTableRow* row = section->firstRow(); row; row = row->nextRow(
)) { |
| 40 if (!hasColChangedBackground && !section->backgroundChangedSinceLast
PaintInvalidation() && !row->backgroundChangedSinceLastPaintInvalidation()) |
| 41 continue; |
| 42 for (LayoutTableCell* cell = row->firstCell(); cell; cell = cell->ne
xtCell()) { |
| 43 bool invalidated = false; |
| 44 // Table cells paint container's background on the container's b
acking instead of its own (if any), |
| 45 // so we must invalidate it by the containers. |
| 46 if (section->backgroundChangedSinceLastPaintInvalidation()) { |
| 47 section->slowSetPaintingLayerNeedsRepaintAndInvalidateDispla
yItemClient(*cell, PaintInvalidationStyleChange); |
| 48 invalidated = true; |
| 49 } else if (hasColChangedBackground) { |
| 50 LayoutTable::ColAndColGroup colAndColGroup = m_table.colElem
entAtAbsoluteColumn(cell->absoluteColumnIndex()); |
| 51 LayoutTableCol* column = colAndColGroup.col; |
| 52 LayoutTableCol* columnGroup = colAndColGroup.colgroup; |
| 53 if ((columnGroup && columnGroup->backgroundChangedSinceLastP
aintInvalidation()) |
| 54 || (column && column->backgroundChangedSinceLastPaintInv
alidation())) { |
| 55 section->slowSetPaintingLayerNeedsRepaintAndInvalidateDi
splayItemClient(*cell, PaintInvalidationStyleChange); |
| 56 invalidated = true; |
| 57 } |
| 58 } |
| 59 if ((!invalidated || row->hasSelfPaintingLayer()) && row->backgr
oundChangedSinceLastPaintInvalidation()) |
| 60 row->slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayIte
mClient(*cell, PaintInvalidationStyleChange); |
| 61 } |
| 62 } |
| 63 } |
| 64 |
| 65 return reason; |
| 66 } |
| 67 |
| 68 } // namespace blink |
OLD | NEW |