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

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

Issue 2786463004: Paint backgrounds of a table section/row in one display item (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/TablePaintInvalidator.cpp
diff --git a/third_party/WebKit/Source/core/paint/TablePaintInvalidator.cpp b/third_party/WebKit/Source/core/paint/TablePaintInvalidator.cpp
index f76452aa5ec361e5e0a9ec28ca27b3c851cfdbd1..01897fa73fbcd6d1541e89eb4b99f5cf5932d545 100644
--- a/third_party/WebKit/Source/core/paint/TablePaintInvalidator.cpp
+++ b/third_party/WebKit/Source/core/paint/TablePaintInvalidator.cpp
@@ -18,81 +18,37 @@ PaintInvalidationReason TablePaintInvalidator::invalidatePaintIfNeeded() {
PaintInvalidationReason reason =
BoxPaintInvalidator(m_table, m_context).invalidatePaintIfNeeded();
- // Table cells paint background from the containing column group, column,
- // section and row. If background of any of them changed, we need to
- // invalidate all affected cells. Here use shouldDoFullPaintInvalidation() as
- // a broader condition of background change.
-
- // If any col changed background, we'll check all cells for background
- // changes.
+ // If any col changed background, we need to invalidate all sections because
+ // col background paints into section's background display item.
bool hasColChangedBackground = false;
- bool visualRectChanged = m_context.oldVisualRect != m_table.visualRect();
- for (LayoutTableCol* col = m_table.firstColumn(); col;
- col = col->nextColumn()) {
- // LayoutTableCol uses the table's localVisualRect(). Should check column
- // for paint invalidation when table's visual rect changed.
- if (visualRectChanged)
- col->setMayNeedPaintInvalidation();
- // This ensures that the backgroundChangedSinceLastPaintInvalidation flag
- // is up-to-date.
- col->ensureIsReadyForPaintInvalidation();
- if (col->backgroundChangedSinceLastPaintInvalidation()) {
- hasColChangedBackground = true;
- break;
+ if (m_table.hasColElements()) {
+ bool visualRectChanged = m_context.oldVisualRect != m_table.visualRect();
+ for (LayoutTableCol* col = m_table.firstColumn(); col;
+ col = col->nextColumn()) {
+ // LayoutTableCol uses the table's localVisualRect(). Should check column
+ // for paint invalidation when table's visual rect changed.
+ if (visualRectChanged)
+ col->setMayNeedPaintInvalidation();
+ // This ensures that the backgroundChangedSinceLastPaintInvalidation flag
+ // is up-to-date.
+ col->ensureIsReadyForPaintInvalidation();
+ if (col->backgroundChangedSinceLastPaintInvalidation()) {
+ hasColChangedBackground = true;
+ break;
+ }
}
}
- for (LayoutObject* child = m_table.firstChild(); child;
- child = child->nextSibling()) {
- if (!child->isTableSection())
- continue;
- LayoutTableSection* section = toLayoutTableSection(child);
- section->ensureIsReadyForPaintInvalidation();
- ObjectPaintInvalidator sectionInvalidator(*section);
- if (!hasColChangedBackground && !section->shouldCheckForPaintInvalidation())
- continue;
- for (LayoutTableRow* row = section->firstRow(); row; row = row->nextRow()) {
- row->ensureIsReadyForPaintInvalidation();
- if (!hasColChangedBackground &&
- !section->backgroundChangedSinceLastPaintInvalidation() &&
- !row->backgroundChangedSinceLastPaintInvalidation())
+
+ if (hasColChangedBackground) {
+ for (LayoutObject* child = m_table.firstChild(); child;
+ child = child->nextSibling()) {
+ if (!child->isTableSection())
continue;
- for (LayoutTableCell* cell = row->firstCell(); cell;
- cell = cell->nextCell()) {
- cell->ensureIsReadyForPaintInvalidation();
- bool invalidated = false;
- // Table cells paint container's background on the container's backing
- // instead of its own (if any), so we must invalidate it by the
- // containers.
- if (section->backgroundChangedSinceLastPaintInvalidation()) {
- sectionInvalidator
- .slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient(
- cell->backgroundDisplayItemClient(),
- PaintInvalidationStyleChange);
- invalidated = true;
- } else if (hasColChangedBackground) {
- LayoutTable::ColAndColGroup colAndColGroup =
- m_table.colElementAtAbsoluteColumn(cell->absoluteColumnIndex());
- LayoutTableCol* column = colAndColGroup.col;
- LayoutTableCol* columnGroup = colAndColGroup.colgroup;
- if ((columnGroup &&
- columnGroup->backgroundChangedSinceLastPaintInvalidation()) ||
- (column &&
- column->backgroundChangedSinceLastPaintInvalidation())) {
- sectionInvalidator
- .slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient(
- cell->backgroundDisplayItemClient(),
- PaintInvalidationStyleChange);
- invalidated = true;
- }
- }
- if ((!invalidated || row->hasSelfPaintingLayer()) &&
- row->backgroundChangedSinceLastPaintInvalidation()) {
- ObjectPaintInvalidator(*row)
- .slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient(
- cell->backgroundDisplayItemClient(),
- PaintInvalidationStyleChange);
- }
- }
+ LayoutTableSection* section = toLayoutTableSection(child);
+ section->ensureIsReadyForPaintInvalidation();
+ ObjectPaintInvalidator(*section)
+ .slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient(
+ *section, PaintInvalidationStyleChange);
}
}

Powered by Google App Engine
This is Rietveld 408576698