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/ViewPainter.h" | 6 #include "core/paint/ViewPainter.h" |
7 | 7 |
8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
9 #include "core/frame/Settings.h" | 9 #include "core/frame/Settings.h" |
10 #include "core/layout/LayoutBox.h" | 10 #include "core/layout/LayoutBox.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 // 1. The view paints background for the root element, the background positi
oning respects | 42 // 1. The view paints background for the root element, the background positi
oning respects |
43 // the positioning and transformation of the root element. | 43 // the positioning and transformation of the root element. |
44 // 2. CSS background-clip is ignored, the background layers always expand to
cover the whole | 44 // 2. CSS background-clip is ignored, the background layers always expand to
cover the whole |
45 // canvas. None of the stacking context effects (except transformation) o
n the root element | 45 // canvas. None of the stacking context effects (except transformation) o
n the root element |
46 // affects the background. | 46 // affects the background. |
47 // 3. The main frame is also responsible for painting the user-agent-defined
base background | 47 // 3. The main frame is also responsible for painting the user-agent-defined
base background |
48 // color. Conceptually it should be painted by the embedder but painting
it here allows | 48 // color. Conceptually it should be painted by the embedder but painting
it here allows |
49 // culling and pre-blending optimization when possible. | 49 // culling and pre-blending optimization when possible. |
50 | 50 |
51 GraphicsContext& context = *paintInfo.context; | 51 GraphicsContext& context = *paintInfo.context; |
52 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, m_layou
tView, DisplayItem::BoxDecorationBackground)) | 52 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, m_layou
tView, DisplayItem::BoxDecorationBackground, LayoutPoint())) |
53 return; | 53 return; |
54 | 54 |
55 IntRect documentRect = m_layoutView.unscaledDocumentRect(); | 55 IntRect documentRect = m_layoutView.unscaledDocumentRect(); |
56 const Document& document = m_layoutView.document(); | 56 const Document& document = m_layoutView.document(); |
57 const FrameView& frameView = *m_layoutView.frameView(); | 57 const FrameView& frameView = *m_layoutView.frameView(); |
58 bool isMainFrame = !document.ownerElement(); | 58 bool isMainFrame = !document.ownerElement(); |
59 bool paintsBaseBackground = isMainFrame && !frameView.isTransparent(); | 59 bool paintsBaseBackground = isMainFrame && !frameView.isTransparent(); |
60 bool shouldClearCanvas = paintsBaseBackground && (document.settings() && doc
ument.settings()->shouldClearDocumentBackground()); | 60 bool shouldClearCanvas = paintsBaseBackground && (document.settings() && doc
ument.settings()->shouldClearDocumentBackground()); |
61 Color baseBackgroundColor = paintsBaseBackground ? frameView.baseBackgroundC
olor() : Color(); | 61 Color baseBackgroundColor = paintsBaseBackground ? frameView.baseBackgroundC
olor() : Color(); |
62 Color rootBackgroundColor = m_layoutView.style()->visitedDependentColor(CSSP
ropertyBackgroundColor); | 62 Color rootBackgroundColor = m_layoutView.style()->visitedDependentColor(CSSP
ropertyBackgroundColor); |
63 const LayoutObject* rootObject = document.documentElement() ? document.docum
entElement()->layoutObject() : nullptr; | 63 const LayoutObject* rootObject = document.documentElement() ? document.docum
entElement()->layoutObject() : nullptr; |
64 | 64 |
65 LayoutObjectDrawingRecorder recorder(context, m_layoutView, DisplayItem::Box
DecorationBackground, documentRect); | 65 LayoutObjectDrawingRecorder recorder(context, m_layoutView, DisplayItem::Box
DecorationBackground, documentRect, LayoutPoint()); |
66 | 66 |
67 // Special handling for print economy mode. | 67 // Special handling for print economy mode. |
68 bool forceBackgroundToWhite = BoxPainter::shouldForceWhiteBackgroundForPrint
Economy(m_layoutView.styleRef(), document); | 68 bool forceBackgroundToWhite = BoxPainter::shouldForceWhiteBackgroundForPrint
Economy(m_layoutView.styleRef(), document); |
69 if (forceBackgroundToWhite) { | 69 if (forceBackgroundToWhite) { |
70 // If for any reason the view background is not transparent, paint white
instead, otherwise keep transparent as is. | 70 // If for any reason the view background is not transparent, paint white
instead, otherwise keep transparent as is. |
71 if (paintsBaseBackground || rootBackgroundColor.alpha() || m_layoutView.
style()->backgroundLayers().image()) | 71 if (paintsBaseBackground || rootBackgroundColor.alpha() || m_layoutView.
style()->backgroundLayers().image()) |
72 context.fillRect(documentRect, Color::white, SkXfermode::kSrc_Mode); | 72 context.fillRect(documentRect, Color::white, SkXfermode::kSrc_Mode); |
73 return; | 73 return; |
74 } | 74 } |
75 | 75 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 ASSERT((*it)->clip() == BorderFillBox); | 141 ASSERT((*it)->clip() == BorderFillBox); |
142 BoxPainter::paintFillLayerExtended(m_layoutView, paintInfo, Color(), **i
t, LayoutRect(paintRect), BackgroundBleedNone); | 142 BoxPainter::paintFillLayerExtended(m_layoutView, paintInfo, Color(), **i
t, LayoutRect(paintRect), BackgroundBleedNone); |
143 } | 143 } |
144 context.restore(); | 144 context.restore(); |
145 | 145 |
146 if (shouldDrawBackgroundInSeparateBuffer) | 146 if (shouldDrawBackgroundInSeparateBuffer) |
147 context.endLayer(); | 147 context.endLayer(); |
148 } | 148 } |
149 | 149 |
150 } // namespace blink | 150 } // namespace blink |
OLD | NEW |