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 cb63f2ce4c19a644549fe31cf549e17cdc7e5c95..2b74e57a6c41215050929edd9889107bb3ff4fbc 100644 |
| --- a/third_party/WebKit/Source/core/layout/LayoutTable.cpp |
| +++ b/third_party/WebKit/Source/core/layout/LayoutTable.cpp |
| @@ -99,7 +99,8 @@ void LayoutTable::styleDidChange(StyleDifference diff, |
| // If border was changed, invalidate collapsed borders cache. |
| if (!needsLayout() && oldStyle && oldStyle->border() != style()->border()) |
| - invalidateCollapsedBorders(); |
| + invalidateCollapsedBorders(PaintInvalidationStyleChange); |
| + |
| if (LayoutTableBoxComponent::doCellsHaveDirtyWidth(*this, *this, diff, |
| *oldStyle)) |
| markAllCellsWidthsDirtyAndOrNeedsLayout(MarkDirtyAndNeedsLayout); |
| @@ -732,7 +733,7 @@ void LayoutTable::layout() { |
| updateLayerTransformAfterLayout(); |
| // Layout was changed, so probably borders too. |
| - invalidateCollapsedBorders(); |
| + invalidateCollapsedBorders(PaintInvalidationForcedByLayout); |
|
wkorman
2016/12/05 05:49:21
I assume this, and the check for it in line 764, a
Xianzhu
2016/12/05 17:28:54
Yes. This ensures invalidation of collapsed border
|
| computeOverflow(clientLogicalBottom()); |
| updateAfterLayout(); |
| @@ -751,13 +752,19 @@ void LayoutTable::layout() { |
| clearNeedsLayout(); |
| } |
| -void LayoutTable::invalidateCollapsedBorders() { |
| - m_collapsedBorders.clear(); |
| +void LayoutTable::invalidateCollapsedBorders(PaintInvalidationReason reason) { |
| + DCHECK(reason == PaintInvalidationStyleChange || |
| + reason == PaintInvalidationForcedByLayout); |
| + |
| + m_collapsedBordersInfo = nullptr; |
| if (!collapseBorders()) |
| return; |
| m_collapsedBordersValid = false; |
| - setMayNeedPaintInvalidation(); |
| + if (reason == PaintInvalidationForcedByLayout) |
| + setShouldDoFullPaintInvalidation(reason); |
| + else |
| + setMayNeedPaintInvalidation(); |
| } |
| // Collect all the unique border values that we want to paint in a sorted list. |
| @@ -765,10 +772,15 @@ 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; |
| + |
| + LayoutRect boundsOfChangedCells; |
| + Vector<CollapsedBorderValue> values; |
| for (LayoutObject* section = firstChild(); section; |
| section = section->nextSibling()) { |
| if (!section->isTableSection()) |
| @@ -777,12 +789,23 @@ void LayoutTable::recalcCollapsedBordersIfNeeded() { |
| row = row->nextRow()) { |
| for (LayoutTableCell* cell = row->firstCell(); cell; |
| cell = cell->nextCell()) { |
| - ASSERT(cell->table() == this); |
| - cell->collectBorderValues(m_collapsedBorders); |
| + DCHECK(cell->table() == this); |
| + if (cell->collectBorderValues(values) && |
| + !shouldDoFullPaintInvalidation()) { |
|
wkorman
2016/12/05 05:49:21
Do we potentially reduce a bit of work if we put s
Xianzhu
2016/12/05 17:28:54
No. We should always do collectBorderValues().
Ch
|
| + LayoutRect cellRect = cell->localVisualRect(); |
| + cell->mapToVisualRectInAncestorSpace(this, cellRect); |
| + boundsOfChangedCells.unite(cellRect); |
| + } |
| } |
| } |
| } |
| - LayoutTableCell::sortBorderValues(m_collapsedBorders); |
| + if (!values.isEmpty()) { |
| + LayoutTableCell::sortBorderValues(values); |
| + m_collapsedBordersInfo = |
| + wrapUnique(new CollapsedBordersInfo(std::move(values))); |
| + } |
| + |
| + invalidatePaintRectangle(boundsOfChangedCells); |
| } |
| void LayoutTable::addOverflowFromChildren() { |
| @@ -1662,10 +1685,10 @@ void LayoutTable::ensureIsReadyForPaintInvalidation() { |
| PaintInvalidationReason LayoutTable::invalidatePaintIfNeeded( |
| const PaintInvalidationState& paintInvalidationState) { |
| - if (collapseBorders() && !m_collapsedBorders.isEmpty()) |
| + if (hasCollapsedBorders()) { |
| paintInvalidationState.paintingLayer() |
| .setNeedsPaintPhaseDescendantBlockBackgrounds(); |
| - |
| + } |
| return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); |
| } |