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

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

Issue 2196583002: Paint local background colors onto foreground layer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename PaintLayerPaintingBackgroundOntoForeground to PaintLayerPaintingRootBackgroundOntoForeground 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/paint/BoxPainter.cpp
diff --git a/third_party/WebKit/Source/core/paint/BoxPainter.cpp b/third_party/WebKit/Source/core/paint/BoxPainter.cpp
index b7e005a61ba2af7da17a4dfb21571ceabfc4df5e..4149757cf04e37fc9b0c0fc34e8a671ee5e9bc72 100644
--- a/third_party/WebKit/Source/core/paint/BoxPainter.cpp
+++ b/third_party/WebKit/Source/core/paint/BoxPainter.cpp
@@ -46,14 +46,36 @@ void BoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffse
void BoxPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
- LayoutRect paintRect = m_layoutBox.borderBoxRect();
+ LayoutRect paintRect;
+ if ((paintInfo.paintFlags() & PaintLayerPaintingCompositingBackgroundPhase)
+ || !(paintInfo.paintFlags() & PaintLayerPaintingRootBackgroundOntoForeground)) {
+ paintRect = m_layoutBox.borderBoxRect();
+ } else {
+ // Need to include overflow when drawing into the scrolling contents layer.
chrishtr 2016/08/03 18:58:00 Explicitly say in a comment that this code is spec
flackr 2016/08/03 20:58:53 Done.
+ paintRect = m_layoutBox.layoutOverflowRect();
+ paintRect.move(-m_layoutBox.scrolledContentOffset());
+
+ // The background painting code assumes that the borders are part of the paintRect so we
+ // expand the paintRect by the border size when painting the background into the
+ // scrolling contents layer.
+ paintRect.expandEdges(
+ LayoutUnit(m_layoutBox.borderTop()),
+ LayoutUnit(m_layoutBox.borderRight()),
+ LayoutUnit(m_layoutBox.borderBottom()),
+ LayoutUnit(m_layoutBox.borderLeft()));
+ }
+
paintRect.moveBy(paintOffset);
paintBoxDecorationBackgroundWithRect(paintInfo, paintOffset, paintRect);
}
-LayoutRect BoxPainter::boundsForDrawingRecorder(const LayoutPoint& adjustedPaintOffset)
+LayoutRect BoxPainter::boundsForDrawingRecorder(const PaintInfo& paintInfo, const LayoutPoint& adjustedPaintOffset)
{
- LayoutRect bounds = m_layoutBox.selfVisualOverflowRect();
+ LayoutRect bounds =
+ (paintInfo.paintFlags() & PaintLayerPaintingCompositingBackgroundPhase
chrishtr 2016/08/03 18:58:00 This conditional duplicates lines 50-51. Factor in
flackr 2016/08/03 20:58:53 Done.
+ || !(paintInfo.paintFlags() & PaintLayerPaintingRootBackgroundOntoForeground))
+ ? m_layoutBox.selfVisualOverflowRect()
+ : m_layoutBox.layoutOverflowRect();
bounds.moveBy(adjustedPaintOffset);
return bounds;
}
@@ -69,6 +91,8 @@ bool bleedAvoidanceIsClipping(BackgroundBleedAvoidance bleedAvoidance)
void BoxPainter::paintBoxDecorationBackgroundWithRect(const PaintInfo& paintInfo, const LayoutPoint& paintOffset, const LayoutRect& paintRect)
{
+ bool paintBackgroundOnly = !(paintInfo.paintFlags() & PaintLayerPaintingCompositingBackgroundPhase)
+ && (paintInfo.paintFlags() & PaintLayerPaintingRootBackgroundOntoForeground);
const ComputedStyle& style = m_layoutBox.styleRef();
// FIXME: For now we don't have notification on media buffered range change from media player
@@ -80,23 +104,26 @@ void BoxPainter::paintBoxDecorationBackgroundWithRect(const PaintInfo& paintInfo
if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.context, m_layoutBox, DisplayItem::BoxDecorationBackground))
return;
- LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutBox, DisplayItem::BoxDecorationBackground, boundsForDrawingRecorder(paintOffset));
+ LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutBox, DisplayItem::BoxDecorationBackground, boundsForDrawingRecorder(paintInfo, paintOffset));
BoxDecorationData boxDecorationData(m_layoutBox);
+ GraphicsContextStateSaver stateSaver(paintInfo.context, false);
chrishtr 2016/08/03 18:58:00 Why do you need this?
flackr 2016/08/03 20:58:53 It's moved from line 92. Putting it inside the con
- // FIXME: Should eventually give the theme control over whether the box shadow should paint, since controls could have
- // custom shadows of their own.
- if (!m_layoutBox.boxShadowShouldBeAppliedToBackground(boxDecorationData.bleedAvoidance))
- paintBoxShadow(paintInfo, paintRect, style, Normal);
+ if (!paintBackgroundOnly) {
+ // FIXME: Should eventually give the theme control over whether the box shadow should paint, since controls could have
+ // custom shadows of their own.
+ if (!m_layoutBox.boxShadowShouldBeAppliedToBackground(boxDecorationData.bleedAvoidance)) {
+ paintBoxShadow(paintInfo, paintRect, style, Normal);
+ }
- GraphicsContextStateSaver stateSaver(paintInfo.context, false);
- if (bleedAvoidanceIsClipping(boxDecorationData.bleedAvoidance)) {
- stateSaver.save();
- FloatRoundedRect border = style.getRoundedBorderFor(paintRect);
- paintInfo.context.clipRoundedRect(border);
+ if (bleedAvoidanceIsClipping(boxDecorationData.bleedAvoidance)) {
+ stateSaver.save();
+ FloatRoundedRect border = style.getRoundedBorderFor(paintRect);
+ paintInfo.context.clipRoundedRect(border);
- if (boxDecorationData.bleedAvoidance == BackgroundBleedClipLayer)
- paintInfo.context.beginLayer();
+ if (boxDecorationData.bleedAvoidance == BackgroundBleedClipLayer)
+ paintInfo.context.beginLayer();
+ }
}
// If we have a native theme appearance, paint that before painting our background.
@@ -104,19 +131,25 @@ void BoxPainter::paintBoxDecorationBackgroundWithRect(const PaintInfo& paintInfo
IntRect snappedPaintRect(pixelSnappedIntRect(paintRect));
ThemePainter& themePainter = LayoutTheme::theme().painter();
bool themePainted = boxDecorationData.hasAppearance && !themePainter.paint(m_layoutBox, paintInfo, snappedPaintRect);
- if (!themePainted) {
+ bool shouldPaintBackground = !themePainted
+ && (paintBackgroundOnly || !(paintInfo.paintFlags() & PaintLayerPaintingRootBackgroundOntoForeground));
+ if (shouldPaintBackground) {
paintBackground(paintInfo, paintRect, boxDecorationData.backgroundColor, boxDecorationData.bleedAvoidance);
if (boxDecorationData.hasAppearance)
themePainter.paintDecorations(m_layoutBox, paintInfo, snappedPaintRect);
}
- paintBoxShadow(paintInfo, paintRect, style, Inset);
- // The theme will tell us whether or not we should also paint the CSS border.
- if (boxDecorationData.hasBorderDecoration
- && (!boxDecorationData.hasAppearance || (!themePainted && LayoutTheme::theme().painter().paintBorderOnly(m_layoutBox, paintInfo, snappedPaintRect)))
- && !(m_layoutBox.isTable() && toLayoutTable(&m_layoutBox)->collapseBorders()))
- paintBorder(m_layoutBox, paintInfo, paintRect, style, boxDecorationData.bleedAvoidance);
+ if (!paintBackgroundOnly) {
+ paintBoxShadow(paintInfo, paintRect, style, Inset);
+
+ // The theme will tell us whether or not we should also paint the CSS border.
+ if (boxDecorationData.hasBorderDecoration
+ && (!boxDecorationData.hasAppearance || (!themePainted && LayoutTheme::theme().painter().paintBorderOnly(m_layoutBox, paintInfo, snappedPaintRect)))
+ && !(m_layoutBox.isTable() && toLayoutTable(&m_layoutBox)->collapseBorders())) {
+ paintBorder(m_layoutBox, paintInfo, paintRect, style, boxDecorationData.bleedAvoidance);
+ }
+ }
if (boxDecorationData.bleedAvoidance == BackgroundBleedClipLayer)
paintInfo.context.endLayer();
@@ -506,7 +539,9 @@ void BoxPainter::paintFillLayer(const LayoutBoxModelObject& obj, const PaintInfo
GraphicsContextStateSaver clipWithScrollingStateSaver(context, info.isClippedWithLocalScrolling);
LayoutRect scrolledPaintRect = rect;
- if (info.isClippedWithLocalScrolling) {
+ bool isPaintingScrollingContentsLayer = !(paintInfo.paintFlags() & PaintLayerPaintingCompositingBackgroundPhase)
+ && paintInfo.paintFlags() & PaintLayerPaintingRootBackgroundOntoForeground;
+ if (info.isClippedWithLocalScrolling && !isPaintingScrollingContentsLayer) {
// Clip to the overflow area.
const LayoutBox& thisBox = toLayoutBox(obj);
// TODO(chrishtr): this should be pixel-snapped.
« no previous file with comments | « third_party/WebKit/Source/core/paint/BoxPainter.h ('k') | third_party/WebKit/Source/core/paint/PaintLayer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698