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

Unified Diff: third_party/WebKit/Source/core/paint/TablePainter.cpp

Issue 2430313004: Paint collapsed borders of a table as one display item (Closed)
Patch Set: Rebaseline-cl Created 4 years, 1 month 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/paint/TablePainter.cpp
diff --git a/third_party/WebKit/Source/core/paint/TablePainter.cpp b/third_party/WebKit/Source/core/paint/TablePainter.cpp
index 16f910484ae6263f1cb44bbaf6332af82bd83f8f..acd6d7572faefbc79922dc93fab14043c4ee5a15 100644
--- a/third_party/WebKit/Source/core/paint/TablePainter.cpp
+++ b/third_party/WebKit/Source/core/paint/TablePainter.cpp
@@ -44,31 +44,60 @@ void TablePainter::paintObject(const PaintInfo& paintInfo,
}
}
- if (m_layoutTable.collapseBorders() &&
- shouldPaintDescendantBlockBackgrounds(paintPhase) &&
- m_layoutTable.style()->visibility() == EVisibility::Visible) {
- // Using our cached sorted styles, we then do individual passes,
- // painting each style of border from lowest precedence to highest
- // precedence.
- LayoutTable::CollapsedBorderValues collapsedBorders =
- m_layoutTable.collapsedBorders();
- size_t count = collapsedBorders.size();
- for (size_t i = 0; i < count; ++i) {
- for (LayoutTableSection* section = m_layoutTable.bottomSection();
- section; section = m_layoutTable.sectionAbove(section)) {
- LayoutPoint childPoint =
- m_layoutTable.flipForWritingModeForChild(section, paintOffset);
- TableSectionPainter(*section).paintCollapsedBorders(
- paintInfoForDescendants, childPoint, collapsedBorders[i]);
- }
- }
- }
+ if (shouldPaintDescendantBlockBackgrounds(paintPhase))
+ paintCollapsedBorders(paintInfoForDescendants, paintOffset);
}
if (shouldPaintSelfOutline(paintPhase))
ObjectPainter(m_layoutTable).paintOutline(paintInfo, paintOffset);
}
+void TablePainter::paintCollapsedBorders(const PaintInfo& paintInfo,
+ const LayoutPoint& paintOffset) {
+ if (!m_layoutTable.hasCollapsedBorders() ||
+ m_layoutTable.style()->visibility() != EVisibility::Visible)
+ return;
+
+ LayoutTable::CollapsedBordersInfo& collapsedBorders =
+ m_layoutTable.getCollapsedBordersInfo();
+
+ // Normally we don't clip individual display items by paint dirty rect
chrishtr 2016/11/03 21:16:29 Is such an optimization already implemented in the
Xianzhu 2016/11/03 21:26:55 Yes, in TableSectionPainter, to skip painting coll
+ // (aka interest rect), to keep display items independent with paint dirty
+ // rect so we can just depend on paint invalidation status to repaint them.
+ // However, the collapsed border display item may be too big to contain all
+ // collapsed borders in a huge table, so we clip it to paint dirty rect.
+ // We need to invalidate the display item if the previous paint is clipped
+ // and the paint dirty rect changed.
+ if (collapsedBorders.lastPaintResult != FullyPainted &&
+ collapsedBorders.lastPaintRect != paintInfo.cullRect())
+ m_layoutTable.setDisplayItemsUncached();
+
+ if (!DrawingRecorder::useCachedDrawingIfPossible(
chrishtr 2016/11/03 21:16:29 if (DrawingRecorder::useCachedDrawingIfPossible(..
Xianzhu 2016/11/03 21:26:55 Done.
+ paintInfo.context, m_layoutTable,
+ DisplayItem::kTableCollapsedBorders)) {
+ DrawingRecorder recorder(
+ paintInfo.context, m_layoutTable, DisplayItem::kTableCollapsedBorders,
+ FloatRect(LayoutRect(paintOffset, m_layoutTable.size())));
+
+ // Using our cached sorted styles, we then do individual passes, painting
+ // each style of border from lowest precedence to highest precedence.
+ PaintResult paintResult = FullyPainted;
+ for (const auto& borderValue : collapsedBorders.values) {
+ for (LayoutTableSection* section = m_layoutTable.bottomSection(); section;
+ section = m_layoutTable.sectionAbove(section)) {
+ LayoutPoint childPoint =
+ m_layoutTable.flipForWritingModeForChild(section, paintOffset);
+ if (TableSectionPainter(*section).paintCollapsedBorders(
+ paintInfo, childPoint, borderValue) ==
+ MayBeClippedByPaintDirtyRect)
+ paintResult = MayBeClippedByPaintDirtyRect;
+ }
+ }
+ collapsedBorders.lastPaintResult = paintResult;
+ collapsedBorders.lastPaintRect = paintInfo.cullRect();
+ }
+}
+
void TablePainter::paintBoxDecorationBackground(
const PaintInfo& paintInfo,
const LayoutPoint& paintOffset) {

Powered by Google App Engine
This is Rietveld 408576698