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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 if (m_layoutBox.backgroundStolenForBeingBody()) | 136 if (m_layoutBox.backgroundStolenForBeingBody()) |
137 return; | 137 return; |
138 if (m_layoutBox.boxDecorationBackgroundIsKnownToBeObscured()) | 138 if (m_layoutBox.boxDecorationBackgroundIsKnownToBeObscured()) |
139 return; | 139 return; |
140 paintFillLayers(paintInfo, backgroundColor, m_layoutBox.style()->backgroundL
ayers(), paintRect, bleedAvoidance); | 140 paintFillLayers(paintInfo, backgroundColor, m_layoutBox.style()->backgroundL
ayers(), paintRect, bleedAvoidance); |
141 } | 141 } |
142 | 142 |
143 static bool isFillLayerOpaque(const FillLayer& layer, const LayoutObject& imageC
lient) | 143 static bool isFillLayerOpaque(const FillLayer& layer, const LayoutObject& imageC
lient) |
144 { | 144 { |
145 return layer.hasOpaqueImage(&imageClient) | 145 return layer.hasOpaqueImage(&imageClient) |
146 && layer.image()->canRender(imageClient, imageClient.style()->effectiveZ
oom()) | 146 && layer.image()->canRender() |
147 && !layer.image()->imageSize(&imageClient, imageClient.style()->effectiv
eZoom()).isEmpty() | 147 && !layer.image()->imageSize(&imageClient, imageClient.style()->effectiv
eZoom()).isEmpty() |
148 && layer.hasRepeatXY(); | 148 && layer.hasRepeatXY(); |
149 } | 149 } |
150 | 150 |
151 bool BoxPainter::calculateFillLayerOcclusionCulling(FillLayerOcclusionOutputList
&reversedPaintList, const FillLayer& fillLayer) | 151 bool BoxPainter::calculateFillLayerOcclusionCulling(FillLayerOcclusionOutputList
&reversedPaintList, const FillLayer& fillLayer) |
152 { | 152 { |
153 bool isNonAssociative = false; | 153 bool isNonAssociative = false; |
154 for (auto currentLayer = &fillLayer; currentLayer; currentLayer = currentLay
er->next()) { | 154 for (auto currentLayer = &fillLayer; currentLayer; currentLayer = currentLay
er->next()) { |
155 reversedPaintList.append(currentLayer); | 155 reversedPaintList.append(currentLayer); |
156 // Stop traversal when an opaque layer is encountered. | 156 // Stop traversal when an opaque layer is encountered. |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 case BorderFillBox: | 431 case BorderFillBox: |
432 break; | 432 break; |
433 default: | 433 default: |
434 ASSERT_NOT_REACHED(); | 434 ASSERT_NOT_REACHED(); |
435 break; | 435 break; |
436 } | 436 } |
437 | 437 |
438 BackgroundImageGeometry geometry; | 438 BackgroundImageGeometry geometry; |
439 if (bgImage) | 439 if (bgImage) |
440 geometry.calculate(obj, paintInfo.paintContainer(), paintInfo.globalPain
tFlags(), bgLayer, scrolledPaintRect); | 440 geometry.calculate(obj, paintInfo.paintContainer(), paintInfo.globalPain
tFlags(), bgLayer, scrolledPaintRect); |
441 bool shouldPaintBackgroundImage = bgImage && bgImage->canRender(obj, obj.sty
le()->effectiveZoom()); | 441 bool shouldPaintBackgroundImage = bgImage && bgImage->canRender(); |
442 | 442 |
443 // Paint the color first underneath all images, culled if background image o
ccludes it. | 443 // Paint the color first underneath all images, culled if background image o
ccludes it. |
444 // TODO(trchen): In the !bgLayer.hasRepeatXY() case, we could improve the cu
lling test | 444 // TODO(trchen): In the !bgLayer.hasRepeatXY() case, we could improve the cu
lling test |
445 // by verifying whether the background image covers the entire painting area
. | 445 // by verifying whether the background image covers the entire painting area
. |
446 if (isBottomLayer) { | 446 if (isBottomLayer) { |
447 IntRect backgroundRect(pixelSnappedIntRect(scrolledPaintRect)); | 447 IntRect backgroundRect(pixelSnappedIntRect(scrolledPaintRect)); |
448 bool boxShadowShouldBeAppliedToBackground = obj.boxShadowShouldBeApplied
ToBackground(bleedAvoidance, box); | 448 bool boxShadowShouldBeAppliedToBackground = obj.boxShadowShouldBeApplied
ToBackground(bleedAvoidance, box); |
449 bool backgroundImageOccludesBackgroundColor = shouldPaintBackgroundImage
&& isFillLayerOpaque(bgLayer, obj); | 449 bool backgroundImageOccludesBackgroundColor = shouldPaintBackgroundImage
&& isFillLayerOpaque(bgLayer, obj); |
450 if (boxShadowShouldBeAppliedToBackground || !backgroundImageOccludesBack
groundColor) { | 450 if (boxShadowShouldBeAppliedToBackground || !backgroundImageOccludesBack
groundColor) { |
451 GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShould
BeAppliedToBackground); | 451 GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShould
BeAppliedToBackground); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 } | 705 } |
706 } | 706 } |
707 | 707 |
708 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle&
style, const Document& document) | 708 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle&
style, const Document& document) |
709 { | 709 { |
710 return document.printing() && style.printColorAdjust() == PrintColorAdjustEc
onomy | 710 return document.printing() && style.printColorAdjust() == PrintColorAdjustEc
onomy |
711 && (!document.settings() || !document.settings()->shouldPrintBackgrounds
()); | 711 && (!document.settings() || !document.settings()->shouldPrintBackgrounds
()); |
712 } | 712 } |
713 | 713 |
714 } // namespace blink | 714 } // namespace blink |
OLD | NEW |