| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/paint/BoxPainter.h" | 6 #include "core/paint/BoxPainter.h" |
| 7 | 7 |
| 8 #include "core/HTMLNames.h" | 8 #include "core/HTMLNames.h" |
| 9 #include "core/frame/Settings.h" | 9 #include "core/frame/Settings.h" |
| 10 #include "core/html/HTMLFrameOwnerElement.h" | 10 #include "core/html/HTMLFrameOwnerElement.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 if (boxDecorationData.bleedAvoidance == BackgroundBleedClipLayer) | 107 if (boxDecorationData.bleedAvoidance == BackgroundBleedClipLayer) |
| 108 paintInfo.context->beginLayer(); | 108 paintInfo.context->beginLayer(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 // If we have a native theme appearance, paint that before painting our back
ground. | 111 // If we have a native theme appearance, paint that before painting our back
ground. |
| 112 // The theme will tell us whether or not we should also paint the CSS backgr
ound. | 112 // The theme will tell us whether or not we should also paint the CSS backgr
ound. |
| 113 IntRect snappedPaintRect(pixelSnappedIntRect(paintRect)); | 113 IntRect snappedPaintRect(pixelSnappedIntRect(paintRect)); |
| 114 ThemePainter& themePainter = LayoutTheme::theme().painter(); | 114 ThemePainter& themePainter = LayoutTheme::theme().painter(); |
| 115 bool themePainted = boxDecorationData.hasAppearance && !themePainter.paint(&
m_layoutBox, paintInfo, snappedPaintRect); | 115 bool themePainted = boxDecorationData.hasAppearance && !themePainter.paint(&
m_layoutBox, paintInfo, snappedPaintRect); |
| 116 if (!themePainted) { | 116 if (!themePainted) { |
| 117 if (boxDecorationData.bleedAvoidance == BackgroundBleedBackgroundOverBor
der) | |
| 118 paintBorder(m_layoutBox, paintInfo, paintRect, style, boxDecorationD
ata.bleedAvoidance); | |
| 119 | |
| 120 paintBackground(paintInfo, paintRect, boxDecorationData.backgroundColor,
boxDecorationData.bleedAvoidance); | 117 paintBackground(paintInfo, paintRect, boxDecorationData.backgroundColor,
boxDecorationData.bleedAvoidance); |
| 121 | 118 |
| 122 if (boxDecorationData.hasAppearance) | 119 if (boxDecorationData.hasAppearance) |
| 123 themePainter.paintDecorations(&m_layoutBox, paintInfo, snappedPaintR
ect); | 120 themePainter.paintDecorations(&m_layoutBox, paintInfo, snappedPaintR
ect); |
| 124 } | 121 } |
| 125 paintBoxShadow(paintInfo, paintRect, style, Inset); | 122 paintBoxShadow(paintInfo, paintRect, style, Inset); |
| 126 | 123 |
| 127 // The theme will tell us whether or not we should also paint the CSS border
. | 124 // The theme will tell us whether or not we should also paint the CSS border
. |
| 128 if (boxDecorationData.hasBorderDecoration && boxDecorationData.bleedAvoidanc
e != BackgroundBleedBackgroundOverBorder | 125 if (boxDecorationData.hasBorderDecoration |
| 129 && (!boxDecorationData.hasAppearance || (!themePainted && LayoutTheme::t
heme().painter().paintBorderOnly(&m_layoutBox, paintInfo, snappedPaintRect))) | 126 && (!boxDecorationData.hasAppearance || (!themePainted && LayoutTheme::t
heme().painter().paintBorderOnly(&m_layoutBox, paintInfo, snappedPaintRect))) |
| 130 && !(m_layoutBox.isTable() && toLayoutTable(&m_layoutBox)->collapseBorde
rs())) | 127 && !(m_layoutBox.isTable() && toLayoutTable(&m_layoutBox)->collapseBorde
rs())) |
| 131 paintBorder(m_layoutBox, paintInfo, paintRect, style, boxDecorationData.
bleedAvoidance); | 128 paintBorder(m_layoutBox, paintInfo, paintRect, style, boxDecorationData.
bleedAvoidance); |
| 132 | 129 |
| 133 if (boxDecorationData.bleedAvoidance == BackgroundBleedClipLayer) | 130 if (boxDecorationData.bleedAvoidance == BackgroundBleedClipLayer) |
| 134 paintInfo.context->endLayer(); | 131 paintInfo.context->endLayer(); |
| 135 } | 132 } |
| 136 | 133 |
| 137 void BoxPainter::paintBackground(const PaintInfo& paintInfo, const LayoutRect& p
aintRect, const Color& backgroundColor, BackgroundBleedAvoidance bleedAvoidance) | 134 void BoxPainter::paintBackground(const PaintInfo& paintInfo, const LayoutRect& p
aintRect, const Color& backgroundColor, BackgroundBleedAvoidance bleedAvoidance) |
| 138 { | 135 { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 -fractionalInset * edges[BSLeft].width); | 279 -fractionalInset * edges[BSLeft].width); |
| 283 | 280 |
| 284 FloatRoundedRect backgroundRoundedRect = getBackgroundRoundedRect(obj, b
orderRect, box, boxSize.width(), boxSize.height(), | 281 FloatRoundedRect backgroundRoundedRect = getBackgroundRoundedRect(obj, b
orderRect, box, boxSize.width(), boxSize.height(), |
| 285 includeLogicalLeftEdge, includeLogicalRightEdge); | 282 includeLogicalLeftEdge, includeLogicalRightEdge); |
| 286 FloatRect insetRect(backgroundRoundedRect.rect()); | 283 FloatRect insetRect(backgroundRoundedRect.rect()); |
| 287 insetRect.expand(insets); | 284 insetRect.expand(insets); |
| 288 FloatRoundedRect::Radii insetRadii(backgroundRoundedRect.radii()); | 285 FloatRoundedRect::Radii insetRadii(backgroundRoundedRect.radii()); |
| 289 insetRadii.shrink(-insets.top(), -insets.bottom(), -insets.left(), -inse
ts.right()); | 286 insetRadii.shrink(-insets.top(), -insets.bottom(), -insets.left(), -inse
ts.right()); |
| 290 return FloatRoundedRect(insetRect, insetRadii); | 287 return FloatRoundedRect(insetRect, insetRadii); |
| 291 } | 288 } |
| 292 if (bleedAvoidance == BackgroundBleedBackgroundOverBorder) | |
| 293 return obj.style()->getRoundedInnerBorderFor(borderRect, includeLogicalL
eftEdge, includeLogicalRightEdge); | |
| 294 | 289 |
| 295 return getBackgroundRoundedRect(obj, borderRect, box, boxSize.width(), boxSi
ze.height(), includeLogicalLeftEdge, includeLogicalRightEdge); | 290 return getBackgroundRoundedRect(obj, borderRect, box, boxSize.width(), boxSi
ze.height(), includeLogicalLeftEdge, includeLogicalRightEdge); |
| 296 } | 291 } |
| 297 | 292 |
| 298 void BoxPainter::paintFillLayerExtended(LayoutBoxModelObject& obj, const PaintIn
fo& paintInfo, const Color& color, const FillLayer& bgLayer, const LayoutRect& r
ect, BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox* box, const LayoutSi
ze& boxSize, SkXfermode::Mode op, LayoutObject* backgroundObject) | 293 void BoxPainter::paintFillLayerExtended(LayoutBoxModelObject& obj, const PaintIn
fo& paintInfo, const Color& color, const FillLayer& bgLayer, const LayoutRect& r
ect, BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox* box, const LayoutSi
ze& boxSize, SkXfermode::Mode op, LayoutObject* backgroundObject) |
| 299 { | 294 { |
| 300 GraphicsContext* context = paintInfo.context; | 295 GraphicsContext* context = paintInfo.context; |
| 301 if (rect.isEmpty()) | 296 if (rect.isEmpty()) |
| 302 return; | 297 return; |
| 303 | 298 |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 } | 1044 } |
| 1050 } | 1045 } |
| 1051 | 1046 |
| 1052 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle&
style, const Document& document) | 1047 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle&
style, const Document& document) |
| 1053 { | 1048 { |
| 1054 return document.printing() && style.printColorAdjust() == PrintColorAdjustEc
onomy | 1049 return document.printing() && style.printColorAdjust() == PrintColorAdjustEc
onomy |
| 1055 && (!document.settings() || !document.settings()->shouldPrintBackgrounds
()); | 1050 && (!document.settings() || !document.settings()->shouldPrintBackgrounds
()); |
| 1056 } | 1051 } |
| 1057 | 1052 |
| 1058 } // namespace blink | 1053 } // namespace blink |
| OLD | NEW |