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

Unified Diff: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp

Issue 2196583002: Paint local background colors onto foreground layer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename PaintLayer::shouldPaintBackgroundOntoForeground to PaintLayer::shouldPaintBackgroundOntoScro… Created 4 years, 4 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/compositing/CompositedLayerMapping.cpp
diff --git a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
index 51159637bc5b210ce7b76982670cd289db156338..6d0d87b9e861dad3123174b393e1ce3a56d9591d 100644
--- a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
+++ b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
@@ -309,8 +309,22 @@ void CompositedLayerMapping::updateContentsOpaque()
m_graphicsLayer->setContentsOpaque(false);
m_backgroundLayer->setContentsOpaque(m_owningLayer.backgroundIsKnownToBeOpaqueInRect(compositedBounds()));
} else {
- // For non-root layers, background is always painted by the primary graphics layer.
- m_graphicsLayer->setContentsOpaque(m_owningLayer.backgroundIsKnownToBeOpaqueInRect(compositedBounds()));
+ // For non-root layers, background is painted by the scrolling contents layer if all backgrounds
+ // are background attachment local, otherwise background is painted by the primary graphics layer.
+ if (hasScrollingLayer() && m_owningLayer.shouldPaintBackgroundOntoScrollingContentsLayer()) {
+ // Backgrounds painted onto the foreground are clipped by the padding box rect.
+ // TODO(flackr): This should actually check the entire overflow rect within the
+ // scrolling contents layer but since we currently only trigger this for solid
+ // color backgrounds the answer will be the same.
+ m_scrollingContentsLayer->setContentsOpaque(m_owningLayer.backgroundIsKnownToBeOpaqueInRect(toLayoutBox(layoutObject())->paddingBoxRect()));
+
+ // When we paint the background onto the scrolling contents layer we are going
+ // to leave a hole in the m_graphicsLayer where the background is so it is
+ // not opaque.
+ m_graphicsLayer->setContentsOpaque(false);
+ } else {
+ m_graphicsLayer->setContentsOpaque(m_owningLayer.backgroundIsKnownToBeOpaqueInRect(compositedBounds()));
+ }
}
}
@@ -2426,7 +2440,7 @@ void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G
if (graphicsLayer == m_backgroundLayer.get())
paintLayerFlags |= (PaintLayerPaintingRootBackgroundOnly | PaintLayerPaintingCompositingForegroundPhase); // Need PaintLayerPaintingCompositingForegroundPhase to walk child layers.
- else if (compositor()->fixedRootBackgroundLayer())
+ else if (compositor()->fixedRootBackgroundLayer() && m_owningLayer.isRootLayer())
paintLayerFlags |= PaintLayerPaintingSkipRootBackground;
if (graphicsLayer == m_graphicsLayer.get()
@@ -2436,6 +2450,12 @@ void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G
|| graphicsLayer == m_childClippingMaskLayer.get()
|| graphicsLayer == m_scrollingContentsLayer.get()) {
+ bool paintRootBackgroundIntoScrollingContentsLayer = m_owningLayer.shouldPaintBackgroundOntoScrollingContentsLayer();
chrishtr 2016/08/05 00:40:08 Add: DCHECK(!paintRootBackgroundIntoScrollingCont
flackr 2016/08/08 18:01:30 Done.
+ bool shouldSkipRootBackground = paintRootBackgroundIntoScrollingContentsLayer
+ ? graphicsLayer != m_scrollingContentsLayer.get()
+ : !(graphicsLayerPaintingPhase & GraphicsLayerPaintBackground);
+ if (shouldSkipRootBackground)
+ paintLayerFlags |= PaintLayerPaintingSkipRootBackground;
GraphicsLayerPaintInfo paintInfo;
paintInfo.paintLayer = &m_owningLayer;
paintInfo.compositedBounds = compositedBounds();

Powered by Google App Engine
This is Rietveld 408576698