| 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..55423926bcf79a6fe4f08a1a8bacd659ccde60d9 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); | 
|  | 
| 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); | 
| +        bool cellChanged = cell->collectBorderValues(values); | 
| +        if (cellChanged && !shouldDoFullPaintInvalidation()) { | 
| +          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); | 
| } | 
|  | 
|  |