Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/LayoutTable.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/LayoutTable.cpp b/third_party/WebKit/Source/core/layout/LayoutTable.cpp |
| index 6f0b62e686cc00807ab2b155b451a7adfd20c415..7b0bc6f24a44849a4dca2d8243bb3f867fb421da 100644 |
| --- a/third_party/WebKit/Source/core/layout/LayoutTable.cpp |
| +++ b/third_party/WebKit/Source/core/layout/LayoutTable.cpp |
| @@ -752,7 +752,7 @@ void LayoutTable::layout() { |
| } |
| void LayoutTable::invalidateCollapsedBorders() { |
| - m_collapsedBorders.clear(); |
| + m_collapsedBordersInfo = nullptr; |
| if (!collapseBorders()) |
| return; |
| @@ -765,24 +765,64 @@ void LayoutTable::invalidateCollapsedBorders() { |
| // cache of its containing section, and invalidates itself if any border |
| // changes. This method doesn't affect layout. |
| void LayoutTable::recalcCollapsedBordersIfNeeded() { |
| - if (m_collapsedBordersValid || !collapseBorders()) |
| + if (m_collapsedBordersValid) |
| return; |
| m_collapsedBordersValid = true; |
| - m_collapsedBorders.clear(); |
| + m_collapsedBordersInfo = nullptr; |
| + if (!collapseBorders()) |
| + return; |
| + |
| + // This records if any cell changed collapsed border and the cell is on a |
| + // composited layer of the cell itself, the row or the section. |
| + bool changedWithChildCompositedLayers = false; |
| + |
| + Vector<CollapsedBorderValue> values; |
| for (LayoutObject* section = firstChild(); section; |
| section = section->nextSibling()) { |
| if (!section->isTableSection()) |
| continue; |
| + bool sectionChanged = false; |
| for (LayoutTableRow* row = toLayoutTableSection(section)->firstRow(); row; |
| row = row->nextRow()) { |
| + bool rowChanged = false; |
| for (LayoutTableCell* cell = row->firstCell(); cell; |
| cell = cell->nextCell()) { |
| ASSERT(cell->table() == this); |
| - cell->collectBorderValues(m_collapsedBorders); |
| + bool cellChanged = cell->collectBorderValues(values); |
| + rowChanged |= cellChanged; |
| + sectionChanged |= cellChanged; |
| + changedWithChildCompositedLayers |= |
| + cellChanged && cell->isPaintInvalidationContainer(); |
| } |
| + changedWithChildCompositedLayers |= |
| + rowChanged && row->isPaintInvalidationContainer(); |
| } |
| + changedWithChildCompositedLayers |= |
| + sectionChanged && section->isPaintInvalidationContainer(); |
| + } |
| + if (!values.isEmpty()) { |
| + LayoutTableCell::sortBorderValues(values); |
| + m_collapsedBordersInfo = |
| + wrapUnique(new CollapsedBordersInfo(std::move(values))); |
| + } |
| + |
| + if (shouldDoFullPaintInvalidation()) |
| + return; |
| + |
| + // All collapsed borders are painted on the table's composited layer. |
| + // If there is no changed collapsed borders on child composited layer, the |
| + // changed cells should have already set paint invalidation flags because of |
| + // layout or style change that affected collapsed borders, and their paint |
| + // invalidation will invalidate the rects of the cells on the table's layer. |
| + // Otherwise we conservatively mark the whole table as needing paint |
| + // invalidation to cover any changed cells on the table's composited layer. |
| + if (changedWithChildCompositedLayers) { |
|
chrishtr
2016/11/11 19:18:01
How about using invalidatePaintRectangle of the un
Xianzhu
2016/11/11 20:09:30
Done.
The new patch issues redundant rectangle pa
|
| + setShouldDoFullPaintInvalidation(); |
| + } else if (!shouldDoFullPaintInvalidation()) { |
| + ObjectPaintInvalidator(*this) |
| + .slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient( |
| + *this, PaintInvalidationStyleChange); |
| } |
| - LayoutTableCell::sortBorderValues(m_collapsedBorders); |
| } |
| void LayoutTable::addOverflowFromChildren() { |
| @@ -1662,10 +1702,10 @@ void LayoutTable::ensureIsReadyForPaintInvalidation() { |
| PaintInvalidationReason LayoutTable::invalidatePaintIfNeeded( |
| const PaintInvalidationState& paintInvalidationState) { |
| - if (collapseBorders() && !m_collapsedBorders.isEmpty()) |
| + if (hasCollapsedBorders()) { |
| paintInvalidationState.paintingLayer() |
| .setNeedsPaintPhaseDescendantBlockBackgrounds(); |
| - |
| + } |
| return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); |
| } |