| 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 "core/paint/BoxDecorationData.h" | 5 #include "core/paint/BoxDecorationData.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutBox.h" | 7 #include "core/layout/LayoutBox.h" |
| 8 #include "core/paint/BoxPainter.h" |
| 8 #include "core/style/BorderEdge.h" | 9 #include "core/style/BorderEdge.h" |
| 9 #include "core/style/ComputedStyle.h" | 10 #include "core/style/ComputedStyle.h" |
| 10 #include "platform/RuntimeEnabledFeatures.h" | 11 #include "platform/RuntimeEnabledFeatures.h" |
| 11 #include "platform/graphics/GraphicsContext.h" | 12 #include "platform/graphics/GraphicsContext.h" |
| 12 | 13 |
| 13 namespace blink { | 14 namespace blink { |
| 14 | 15 |
| 15 BoxDecorationData::BoxDecorationData(const LayoutBox& layoutBox) | 16 BoxDecorationData::BoxDecorationData(const LayoutBox& layoutBox) |
| 16 { | 17 { |
| 17 backgroundColor = layoutBox.style()->visitedDependentColor(CSSPropertyBackgr
oundColor); | 18 backgroundColor = layoutBox.style()->visitedDependentColor(CSSPropertyBackgr
oundColor); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 40 } // anonymous namespace | 41 } // anonymous namespace |
| 41 | 42 |
| 42 BackgroundBleedAvoidance BoxDecorationData::determineBackgroundBleedAvoidance(co
nst LayoutBox& layoutBox) | 43 BackgroundBleedAvoidance BoxDecorationData::determineBackgroundBleedAvoidance(co
nst LayoutBox& layoutBox) |
| 43 { | 44 { |
| 44 if (layoutBox.isDocumentElement()) | 45 if (layoutBox.isDocumentElement()) |
| 45 return BackgroundBleedNone; | 46 return BackgroundBleedNone; |
| 46 | 47 |
| 47 if (!hasBackground) | 48 if (!hasBackground) |
| 48 return BackgroundBleedNone; | 49 return BackgroundBleedNone; |
| 49 | 50 |
| 50 if (!hasBorderDecoration || !layoutBox.style()->hasBorderRadius() || layoutB
ox.canRenderBorderImage()) { | 51 const ComputedStyle& boxStyle = layoutBox.styleRef(); |
| 52 const bool hasBorderRadius = boxStyle.hasBorderRadius(); |
| 53 if (!hasBorderDecoration || !hasBorderRadius || layoutBox.canRenderBorderIma
ge()) { |
| 51 if (layoutBox.backgroundShouldAlwaysBeClipped()) | 54 if (layoutBox.backgroundShouldAlwaysBeClipped()) |
| 52 return BackgroundBleedClipOnly; | 55 return BackgroundBleedClipOnly; |
| 56 // Border radius clipping may require layer bleed avoidance if we are go
ing to draw |
| 57 // an image over something else, because we do not want the antialiasing
to lead to bleeding |
| 58 if (boxStyle.hasBackgroundImage() && hasBorderRadius) { |
| 59 // But if the top layer is opaque for the purposes of background pai
nting, we do not |
| 60 // need the bleed avoidance because we will not paint anything behin
d the top layer. |
| 61 // But only if we need to draw something underneath. |
| 62 const FillLayer& fillLayer = layoutBox.style()->backgroundLayers(); |
| 63 if ((backgroundColor.alpha() || fillLayer.next()) && !BoxPainter::is
FillLayerOpaque(fillLayer, layoutBox)) |
| 64 return BackgroundBleedClipLayer; |
| 65 } |
| 53 return BackgroundBleedNone; | 66 return BackgroundBleedNone; |
| 54 } | 67 } |
| 55 | 68 |
| 56 if (borderObscuresBackgroundEdge(*layoutBox.style())) | 69 if (borderObscuresBackgroundEdge(boxStyle)) |
| 57 return BackgroundBleedShrinkBackground; | 70 return BackgroundBleedShrinkBackground; |
| 58 | 71 |
| 59 return BackgroundBleedClipLayer; | 72 return BackgroundBleedClipLayer; |
| 60 } | 73 } |
| 61 | 74 |
| 62 } // namespace blink | 75 } // namespace blink |
| OLD | NEW |