Chromium Code Reviews| 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..a512bd4d946ccb8424da11d05640aeda9f07da54 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() & PaintLayerPaintingBackgroundOntoForeground)) { |
| + paintRect = m_layoutBox.borderBoxRect(); |
| + } else { |
| + // Need to include overflow when drawing into the scrolling contents layer. |
|
chrishtr
2016/07/29 21:04:34
What about boxes that are scrolling but are not co
flackr
2016/08/02 16:58:14
PaintLayerPaintingBackgroundOntoForeground only ge
|
| + 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 |
| + || !(paintInfo.paintFlags() & PaintLayerPaintingBackgroundOntoForeground)) |
| + ? 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() & PaintLayerPaintingBackgroundOntoForeground); |
| 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); |
| - // 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() & PaintLayerPaintingBackgroundOntoForeground)); |
| + 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() & PaintLayerPaintingBackgroundOntoForeground; |
| + if (info.isClippedWithLocalScrolling && !isPaintingScrollingContentsLayer) { |
| // Clip to the overflow area. |
| const LayoutBox& thisBox = toLayoutBox(obj); |
| // TODO(chrishtr): this should be pixel-snapped. |