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

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

Issue 1549693002: Optimize collapsed border painting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months 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 0fc9192c6c566f8e62a348534055b936b1872ee2..3cf797437f0561b547ee4b0898878885a4a09984 100644
--- a/third_party/WebKit/Source/core/layout/LayoutTableCell.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutTableCell.cpp
@@ -43,6 +43,7 @@ using namespace HTMLNames;
struct SameSizeAsLayoutTableCell : public LayoutBlockFlow {
unsigned bitfields;
int paddings[2];
+ void* pointer;
};
static_assert(sizeof(LayoutTableCell) == sizeof(SameSizeAsLayoutTableCell), "LayoutTableCell should stay small");
@@ -65,7 +66,6 @@ void LayoutTableCell::willBeRemovedFromTree()
LayoutBlockFlow::willBeRemovedFromTree();
section()->setNeedsCellRecalc();
- section()->removeCachedCollapsedBorders(this);
}
unsigned LayoutTableCell::parseColSpanFromDOM() const
@@ -908,25 +908,40 @@ static void addBorderStyle(LayoutTable::CollapsedBorderValues& borderValues,
void LayoutTableCell::collectBorderValues(LayoutTable::CollapsedBorderValues& borderValues)
{
- CollapsedBorderValue startBorder = computeCollapsedStartBorder();
- CollapsedBorderValue endBorder = computeCollapsedEndBorder();
- CollapsedBorderValue beforeBorder = computeCollapsedBeforeBorder();
- CollapsedBorderValue afterBorder = computeCollapsedAfterBorder();
- LayoutTableSection* section = this->section();
- bool changed = section->setCachedCollapsedBorder(this, CBSStart, startBorder);
- changed |= section->setCachedCollapsedBorder(this, CBSEnd, endBorder);
- changed |= section->setCachedCollapsedBorder(this, CBSBefore, beforeBorder);
- changed |= section->setCachedCollapsedBorder(this, CBSAfter, afterBorder);
-
- // In slimming paint mode, we need to invalidate all cells with collapsed border changed.
- // FIXME: Need a way to invalidate/repaint the borders only. crbug.com/451090#c5.
+ CollapsedBorderValues newValues = {
+ computeCollapsedStartBorder(),
+ computeCollapsedEndBorder(),
+ computeCollapsedBeforeBorder(),
+ computeCollapsedAfterBorder()
+ };
+
+ bool changed = false;
+ 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 = adoptPtr(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);
+ if (changed)
+ *m_collapsedBorderValues = 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)
table()->invalidateDisplayItemClient(*this);
- addBorderStyle(borderValues, startBorder);
- addBorderStyle(borderValues, endBorder);
- addBorderStyle(borderValues, beforeBorder);
- addBorderStyle(borderValues, afterBorder);
+ addBorderStyle(borderValues, newValues.startBorder);
+ addBorderStyle(borderValues, newValues.endBorder);
+ addBorderStyle(borderValues, newValues.beforeBorder);
+ addBorderStyle(borderValues, newValues.afterBorder);
}
void LayoutTableCell::sortBorderValues(LayoutTable::CollapsedBorderValues& borderValues)
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutTableCell.h ('k') | third_party/WebKit/Source/core/layout/LayoutTableSection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698