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

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

Issue 2469903002: Use appropriate background object visual rect for composited table cell backgrounds. (Closed)
Patch Set: Explicitly create special clients if needed in TablePaintInvalidator. Add initally-empty test varia… 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/layout/LayoutTableCell.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutTableCell.cpp b/third_party/WebKit/Source/core/layout/LayoutTableCell.cpp
index b842de0d1adf12959601e2381e614de54c9f9d27..ffe9eae5de16e3672934304e5d278ef58a7ac8e7 100644
--- a/third_party/WebKit/Source/core/layout/LayoutTableCell.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutTableCell.cpp
@@ -46,7 +46,11 @@ using namespace HTMLNames;
struct SameSizeAsLayoutTableCell : public LayoutBlockFlow {
unsigned bitfields;
int paddings[2];
- void* pointer;
+ void* pointer1;
+ void* pointer2;
+ void* pointer3;
+ void* pointer4;
+ void* pointer5;
};
static_assert(sizeof(LayoutTableCell) == sizeof(SameSizeAsLayoutTableCell),
@@ -463,6 +467,44 @@ int LayoutTableCell::cellBaselinePosition() const {
return (borderBefore() + paddingBefore() + contentLogicalHeight()).toInt();
}
+void LayoutTableCell::createCompositedCellDisplayItemClients() {
+ if (!usesCompositedCellDisplayItemClients())
+ return;
+
+ if (row()->styleRef().hasBackground() && !m_rowBackgroundDisplayItemClient) {
+ m_rowBackgroundDisplayItemClient =
+ wrapUnique(new LayoutTableCell::RowBackgroundDisplayItemClient(*row()));
+ }
+
+ LayoutTable::ColAndColGroup colAndColGroup =
+ table()->colElementAtAbsoluteColumn(absoluteColumnIndex());
+ LayoutTableCol* column = colAndColGroup.col;
+ LayoutTableCol* columnGroup = colAndColGroup.colgroup;
+ if (column && column->styleRef().hasBackground() &&
+ !m_colBackgroundDisplayItemClient) {
+ m_colBackgroundDisplayItemClient = wrapUnique(
+ new LayoutTableCell::ColBackgroundDisplayItemClient(*column));
+ }
+ if (columnGroup && columnGroup->styleRef().hasBackground() &&
+ !m_colGroupBackgroundDisplayItemClient) {
+ m_colGroupBackgroundDisplayItemClient = wrapUnique(
+ new LayoutTableCell::ColBackgroundDisplayItemClient(*columnGroup));
+ }
+ if (section()->styleRef().hasBackground() &&
+ !m_sectionBackgroundDisplayItemClient) {
+ m_sectionBackgroundDisplayItemClient = wrapUnique(
+ new LayoutTableCell::SectionBackgroundDisplayItemClient(*section()));
+ }
+}
+
+void LayoutTableCell::ensureIsReadyForPaintInvalidation() {
+ LayoutBlockFlow::ensureIsReadyForPaintInvalidation();
+ // Below handles the case where a page starts out in a state where the table
wkorman 2016/11/15 01:05:33 I ended up keeping this as it handles one case (de
+ // cell compositing state and its container styling is such that one or more
+ // special display item clients are needed.
+ createCompositedCellDisplayItemClients();
+}
+
void LayoutTableCell::styleDidChange(StyleDifference diff,
const ComputedStyle* oldStyle) {
DCHECK_EQ(style()->display(), EDisplay::TableCell);
@@ -1416,21 +1458,84 @@ bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect(
return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect);
}
-bool LayoutTableCell::usesTableAsAdditionalDisplayItemClient() const {
- // In certain cases such as collapsed borders for composited table cells we
- // paint content for the cell into the table graphics layer backing and so
- // must use the table's visual rect.
+LayoutTableCell::RowBackgroundDisplayItemClient::RowBackgroundDisplayItemClient(
+ const LayoutTableRow& layoutTableRow)
+ : m_layoutTableRow(layoutTableRow) {}
+
+String LayoutTableCell::RowBackgroundDisplayItemClient::debugName() const {
+ return "RowBackground";
+}
+
+LayoutRect LayoutTableCell::RowBackgroundDisplayItemClient::visualRect() const {
+ return m_layoutTableRow.visualRect();
+}
+
+LayoutTableCell::ColBackgroundDisplayItemClient::ColBackgroundDisplayItemClient(
+ const LayoutTableCol& layoutTableCol)
+ : m_layoutTableCol(layoutTableCol) {}
+
+String LayoutTableCell::ColBackgroundDisplayItemClient::debugName() const {
+ return "ColBackground";
+}
+
+LayoutRect LayoutTableCell::ColBackgroundDisplayItemClient::visualRect() const {
+ return m_layoutTableCol.visualRect();
+}
+
+LayoutTableCell::SectionBackgroundDisplayItemClient::
+ SectionBackgroundDisplayItemClient(
+ const LayoutTableSection& layoutTableSection)
+ : m_layoutTableSection(layoutTableSection) {}
+
+String LayoutTableCell::SectionBackgroundDisplayItemClient::debugName() const {
+ return "SectionBackground";
+}
+
+LayoutRect LayoutTableCell::SectionBackgroundDisplayItemClient::visualRect()
+ const {
+ return m_layoutTableSection.visualRect();
+}
+
+bool LayoutTableCell::usesCompositedCellDisplayItemClients() const {
+ // Composited table cells are painted in special ways that require the use of
+ // custom display item clients:
+ //
+ // 1. When painting row background we paint content for the cell into the
+ // table row graphics layer backing and so must use the row's visual rect.
+ //
+ // 2. When painting section, column or column group backgrounds we paint
+ // content for the cell into the table section graphics layer backing and must
+ // use the visual rect for the respective background object
return (hasLayer() && layer()->compositingState() != NotComposited) ||
RuntimeEnabledFeatures::slimmingPaintV2Enabled();
Xianzhu 2016/11/15 02:58:23 This misses the case that the row is composited bu
wkorman 2016/11/15 19:46:02 Ah. I will look at adding tests for these cases (e
Xianzhu 2016/11/15 20:16:58 Sorry, "DisplayItemClients" should be "LayoutTable
}
void LayoutTableCell::invalidateDisplayItemClients(
PaintInvalidationReason reason) const {
- if (m_collapsedBorderValues && usesTableAsAdditionalDisplayItemClient()) {
- ObjectPaintInvalidator(*this).invalidateDisplayItemClient(
- *m_collapsedBorderValues, reason);
- }
LayoutBlockFlow::invalidateDisplayItemClients(reason);
+
+ if (!usesCompositedCellDisplayItemClients())
+ return;
+
+ ObjectPaintInvalidator invalidator(*this);
+ if (m_collapsedBorderValues)
+ invalidator.invalidateDisplayItemClient(*m_collapsedBorderValues, reason);
+ if (m_rowBackgroundDisplayItemClient) {
+ invalidator.invalidateDisplayItemClient(*m_rowBackgroundDisplayItemClient,
+ reason);
+ }
+ if (m_colBackgroundDisplayItemClient) {
+ invalidator.invalidateDisplayItemClient(*m_colBackgroundDisplayItemClient,
+ reason);
+ }
+ if (m_colGroupBackgroundDisplayItemClient) {
+ invalidator.invalidateDisplayItemClient(
+ *m_colGroupBackgroundDisplayItemClient, reason);
+ }
+ if (m_sectionBackgroundDisplayItemClient) {
+ invalidator.invalidateDisplayItemClient(
+ *m_sectionBackgroundDisplayItemClient, reason);
+ }
}
// TODO(lunalu): Deliberately dump the "inner" box of table cells, since that

Powered by Google App Engine
This is Rietveld 408576698