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

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

Issue 2507893002: Fix painting background for composited table cells in a non-composited row. (Closed)
Patch Set: Add test expectations. 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..7774d759996f234fac7bc24bfa309b99ebeff0cb 100644
--- a/third_party/WebKit/Source/core/layout/LayoutTableCell.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutTableCell.cpp
@@ -46,7 +46,8 @@ using namespace HTMLNames;
struct SameSizeAsLayoutTableCell : public LayoutBlockFlow {
unsigned bitfields;
int paddings[2];
- void* pointer;
+ void* pointer1;
+ void* pointer2;
};
static_assert(sizeof(LayoutTableCell) == sizeof(SameSizeAsLayoutTableCell),
@@ -463,6 +464,24 @@ int LayoutTableCell::cellBaselinePosition() const {
return (borderBefore() + paddingBefore() + contentLogicalHeight()).toInt();
}
+void LayoutTableCell::createCompositedCellDisplayItemClients() {
+ if (!usesCompositedCellDisplayItemClients())
+ return;
+
+ if (row()->styleRef().hasBackground() && !m_rowBackgroundDisplayItemClient) {
Xianzhu 2016/11/16 20:39:03 We should remove the hasbackground() condition for
wkorman 2016/11/16 21:42:45 Done.
+ m_rowBackgroundDisplayItemClient =
+ wrapUnique(new LayoutTableCell::RowBackgroundDisplayItemClient(*row()));
+ }
+}
+
+void LayoutTableCell::ensureIsReadyForPaintInvalidation() {
+ LayoutBlockFlow::ensureIsReadyForPaintInvalidation();
+ // Below handles the case where a page starts out in a state where the table
+ // cell compositing state and its container styling is such that one or more
+ // special display item clients are needed.
+ createCompositedCellDisplayItemClients();
Xianzhu 2016/11/16 20:39:03 With the call to createCompositedCellDisplayItemCl
wkorman 2016/11/16 21:42:44 Done.
+}
+
void LayoutTableCell::styleDidChange(StyleDifference diff,
const ComputedStyle* oldStyle) {
DCHECK_EQ(style()->display(), EDisplay::TableCell);
@@ -508,6 +527,18 @@ void LayoutTableCell::styleDidChange(StyleDifference diff,
}
}
+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();
+}
+
// The following rules apply for resolving conflicts and figuring out which
// border to use.
// (1) Borders with the 'border-style' of 'hidden' take precedence over all
@@ -1416,7 +1447,7 @@ bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect(
return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect);
}
-bool LayoutTableCell::usesTableAsAdditionalDisplayItemClient() const {
+bool LayoutTableCell::usesCompositedCellDisplayItemClients() 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.
@@ -1426,11 +1457,18 @@ bool LayoutTableCell::usesTableAsAdditionalDisplayItemClient() const {
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);
+ }
}
// TODO(lunalu): Deliberately dump the "inner" box of table cells, since that

Powered by Google App Engine
This is Rietveld 408576698