Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/LayoutTableCell.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/LayoutTableCell.cpp b/third_party/WebKit/Source/core/layout/LayoutTableCell.cpp |
| index 055f3998e48333c6b2c7b58ce258685e11094af7..686c04e039785f0d23e775a77f7961c1c9b4aeea 100644 |
| --- a/third_party/WebKit/Source/core/layout/LayoutTableCell.cpp |
| +++ b/third_party/WebKit/Source/core/layout/LayoutTableCell.cpp |
| @@ -32,6 +32,7 @@ |
| #include "core/layout/LayoutTableCol.h" |
| #include "core/layout/SubtreeLayoutScope.h" |
| #include "core/paint/ObjectPaintInvalidator.h" |
| +#include "core/paint/PaintLayer.h" |
| #include "core/paint/TableCellPainter.h" |
| #include "core/style/CollapsedBorderValue.h" |
| #include "platform/geometry/FloatQuad.h" |
| @@ -65,6 +66,34 @@ LayoutTableCell::LayoutTableCell(Element* element) |
| updateColAndRowSpanFlags(); |
| } |
| +LayoutTableCell::CollapsedBorderValues::CollapsedBorderValues( |
| + const LayoutTable& layoutTable, |
| + const CollapsedBorderValue& startBorder, |
| + const CollapsedBorderValue& endBorder, |
| + const CollapsedBorderValue& beforeBorder, |
| + const CollapsedBorderValue& afterBorder) |
| + : m_layoutTable(layoutTable), |
| + m_startBorder(startBorder), |
| + m_endBorder(endBorder), |
| + m_beforeBorder(beforeBorder), |
| + m_afterBorder(afterBorder) {} |
| + |
| +void LayoutTableCell::CollapsedBorderValues::setCollapsedBorderValues( |
| + const CollapsedBorderValues& other) { |
| + m_startBorder = other.startBorder(); |
| + m_endBorder = other.endBorder(); |
| + m_beforeBorder = other.beforeBorder(); |
| + m_afterBorder = other.afterBorder(); |
| +} |
| + |
| +String LayoutTableCell::CollapsedBorderValues::debugName() const { |
| + return "CollapsedBorderValues"; |
| +} |
| + |
| +LayoutRect LayoutTableCell::CollapsedBorderValues::visualRect() const { |
| + return m_layoutTable.visualRect(); |
| +} |
| + |
| void LayoutTableCell::willBeRemovedFromTree() { |
| LayoutBlockFlow::willBeRemovedFromTree(); |
| @@ -1264,32 +1293,35 @@ static void addBorderStyle(LayoutTable::CollapsedBorderValues& borderValues, |
| void LayoutTableCell::collectBorderValues( |
| LayoutTable::CollapsedBorderValues& borderValues) { |
| - CollapsedBorderValues newValues = { |
| - computeCollapsedStartBorder(), computeCollapsedEndBorder(), |
| - computeCollapsedBeforeBorder(), computeCollapsedAfterBorder()}; |
| + CollapsedBorderValues newValues( |
| + *table(), computeCollapsedStartBorder(), computeCollapsedEndBorder(), |
| + computeCollapsedBeforeBorder(), computeCollapsedAfterBorder()); |
| bool changed = false; |
| - if (!newValues.startBorder.isVisible() && !newValues.endBorder.isVisible() && |
| - !newValues.beforeBorder.isVisible() && |
| - !newValues.afterBorder.isVisible()) { |
| + if (!newValues.startBorder().isVisible() && |
| + !newValues.endBorder().isVisible() && |
| + !newValues.beforeBorder().isVisible() && |
| + !newValues.afterBorder().isVisible()) { |
| changed = !!m_collapsedBorderValues; |
| m_collapsedBorderValues = nullptr; |
| } else if (!m_collapsedBorderValues) { |
| changed = true; |
| - m_collapsedBorderValues = wrapUnique(new CollapsedBorderValues(newValues)); |
| + m_collapsedBorderValues = wrapUnique(new CollapsedBorderValues( |
| + *table(), newValues.startBorder(), newValues.endBorder(), |
| + newValues.beforeBorder(), newValues.afterBorder())); |
| } else { |
| // We check visuallyEquals so that the table cell is invalidated only if a |
| // changed collapsed border is visible in the first place. |
| - changed = !m_collapsedBorderValues->startBorder.visuallyEquals( |
| - newValues.startBorder) || |
| - !m_collapsedBorderValues->endBorder.visuallyEquals( |
| - newValues.endBorder) || |
| - !m_collapsedBorderValues->beforeBorder.visuallyEquals( |
| - newValues.beforeBorder) || |
| - !m_collapsedBorderValues->afterBorder.visuallyEquals( |
| - newValues.afterBorder); |
| + changed = !m_collapsedBorderValues->startBorder().visuallyEquals( |
| + newValues.startBorder()) || |
| + !m_collapsedBorderValues->endBorder().visuallyEquals( |
| + newValues.endBorder()) || |
| + !m_collapsedBorderValues->beforeBorder().visuallyEquals( |
| + newValues.beforeBorder()) || |
| + !m_collapsedBorderValues->afterBorder().visuallyEquals( |
| + newValues.afterBorder()); |
| if (changed) |
| - *m_collapsedBorderValues = newValues; |
| + m_collapsedBorderValues->setCollapsedBorderValues(newValues); |
| } |
| // If collapsed borders changed, invalidate the cell's display item client on |
| @@ -1301,10 +1333,10 @@ void LayoutTableCell::collectBorderValues( |
| .slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient( |
| *this, PaintInvalidationStyleChange); |
| - addBorderStyle(borderValues, newValues.startBorder); |
| - addBorderStyle(borderValues, newValues.endBorder); |
| - addBorderStyle(borderValues, newValues.beforeBorder); |
| - addBorderStyle(borderValues, newValues.afterBorder); |
| + addBorderStyle(borderValues, newValues.startBorder()); |
| + addBorderStyle(borderValues, newValues.endBorder()); |
| + addBorderStyle(borderValues, newValues.beforeBorder()); |
| + addBorderStyle(borderValues, newValues.afterBorder()); |
| } |
| void LayoutTableCell::sortBorderValues( |
| @@ -1389,6 +1421,20 @@ bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect( |
| return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect); |
| } |
| +bool LayoutTableCell::usesTableAsDisplayItemClient() const { |
| + return (hasLayer() && layer()->compositingState() != NotComposited) || |
|
chrishtr
2016/10/19 01:13:21
Add a note explaining this conditional.
wkorman
2016/10/19 23:07:39
Done.
|
| + RuntimeEnabledFeatures::slimmingPaintV2Enabled(); |
| +} |
| + |
| +void LayoutTableCell::invalidateDisplayItemClients( |
| + PaintInvalidationReason reason) const { |
| + if (m_collapsedBorderValues && usesTableAsDisplayItemClient()) { |
| + ObjectPaintInvalidator(*this).invalidateDisplayItemClient( |
| + *m_collapsedBorderValues, reason); |
| + } |
| + LayoutBlockFlow::invalidateDisplayItemClients(reason); |
| +} |
| + |
| // TODO(lunalu): Deliberately dump the "inner" box of table cells, since that |
| // is what current results reflect. We'd like to clean up the results to dump |
| // both the outer box and the intrinsic padding so that both bits of information |