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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutTableCell.cpp

Issue 2551963003: Reland of Paint collapsed borders of a table as one display item (Closed)
Patch Set: Created 4 years 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/layout/LayoutTableCell.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutTableCell.cpp b/third_party/WebKit/Source/core/layout/LayoutTableCell.cpp
index e8195e90beb6ba30acf91563244f9fd807b29af2..24d98a156c6b544941baf096995a507a95086c43 100644
--- a/third_party/WebKit/Source/core/layout/LayoutTableCell.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutTableCell.cpp
@@ -67,34 +67,6 @@
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();
@@ -500,7 +472,7 @@
return;
if (!table->selfNeedsLayout() && !table->normalChildNeedsLayout() &&
oldStyle && oldStyle->border() != style()->border())
- table->invalidateCollapsedBorders();
+ table->invalidateCollapsedBorders(PaintInvalidationStyleChange);
if (LayoutTableBoxComponent::doCellsHaveDirtyWidth(*this, *table, diff,
*oldStyle)) {
@@ -1303,7 +1275,7 @@
TableCellPainter(*this).paint(paintInfo, paintOffset);
}
-static void addBorderStyle(LayoutTable::CollapsedBorderValues& borderValues,
+static void addBorderStyle(Vector<CollapsedBorderValue>& borderValues,
CollapsedBorderValue borderValue) {
if (!borderValue.isVisible())
return;
@@ -1315,56 +1287,34 @@
borderValues.append(borderValue);
}
-void LayoutTableCell::collectBorderValues(
- LayoutTable::CollapsedBorderValues& borderValues) {
- CollapsedBorderValues newValues(
- *table(), computeCollapsedStartBorder(), computeCollapsedEndBorder(),
- computeCollapsedBeforeBorder(), computeCollapsedAfterBorder());
+bool LayoutTableCell::collectBorderValues(
+ Vector<CollapsedBorderValue>& borderValues) {
+ CollapsedBorderValues newValues = {
+ computeCollapsedStartBorder(), computeCollapsedEndBorder(),
+ computeCollapsedBeforeBorder(), computeCollapsedAfterBorder()};
bool changed = false;
- if (!newValues.startBorder().isVisible() &&
- !newValues.endBorder().isVisible() &&
- !newValues.beforeBorder().isVisible() &&
- !newValues.afterBorder().isVisible()) {
+ if (newValues.allBordersAreInvisible()) {
changed = !!m_collapsedBorderValues;
m_collapsedBorderValues = nullptr;
} else if (!m_collapsedBorderValues) {
changed = true;
- m_collapsedBorderValues = wrapUnique(new CollapsedBorderValues(
- *table(), newValues.startBorder(), newValues.endBorder(),
- newValues.beforeBorder(), newValues.afterBorder()));
+ m_collapsedBorderValues = wrapUnique(new CollapsedBorderValues(newValues));
} 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->bordersVisuallyEqual(newValues);
if (changed)
- m_collapsedBorderValues->setCollapsedBorderValues(newValues);
- }
-
- // If collapsed borders changed, invalidate the cell's display item client on
- // the table's backing.
- // TODO(crbug.com/451090#c5): Need a way to invalidate/repaint the borders
- // only.
- if (changed)
- ObjectPaintInvalidator(*table())
- .slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient(
- *this, PaintInvalidationStyleChange);
-
- addBorderStyle(borderValues, newValues.startBorder());
- addBorderStyle(borderValues, newValues.endBorder());
- addBorderStyle(borderValues, newValues.beforeBorder());
- addBorderStyle(borderValues, newValues.afterBorder());
+ *m_collapsedBorderValues = newValues;
+ }
+
+ addBorderStyle(borderValues, newValues.startBorder);
+ addBorderStyle(borderValues, newValues.endBorder);
+ addBorderStyle(borderValues, newValues.beforeBorder);
+ addBorderStyle(borderValues, newValues.afterBorder);
+ return changed;
}
void LayoutTableCell::sortBorderValues(
- LayoutTable::CollapsedBorderValues& borderValues) {
+ Vector<CollapsedBorderValue>& borderValues) {
std::sort(borderValues.begin(), borderValues.end(), compareBorders);
}
@@ -1459,8 +1409,6 @@
return;
ObjectPaintInvalidator invalidator(*this);
- if (m_collapsedBorderValues)
- invalidator.invalidateDisplayItemClient(*m_collapsedBorderValues, reason);
if (m_rowBackgroundDisplayItemClient) {
invalidator.invalidateDisplayItemClient(*m_rowBackgroundDisplayItemClient,
reason);
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutTableCell.h ('k') | third_party/WebKit/Source/core/layout/LayoutTableCol.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698