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/layout/LayoutBox.h" |
9 #include "core/layout/PaintInfo.h" | 10 #include "core/layout/PaintInfo.h" |
10 #include "core/paint/BlockPainter.h" | 11 #include "core/paint/BlockPainter.h" |
11 #include "core/paint/GraphicsContextAnnotator.h" | 12 #include "core/paint/GraphicsContextAnnotator.h" |
12 #include "core/paint/RenderDrawingRecorder.h" | 13 #include "core/paint/RenderDrawingRecorder.h" |
13 #include "core/rendering/RenderBox.h" | |
14 #include "core/rendering/RenderView.h" | 14 #include "core/rendering/RenderView.h" |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 | 17 |
18 void ViewPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffs
et) | 18 void ViewPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffs
et) |
19 { | 19 { |
20 // If we ever require layout but receive a paint anyway, something has gone
horribly wrong. | 20 // If we ever require layout but receive a paint anyway, something has gone
horribly wrong. |
21 ASSERT(!m_renderView.needsLayout()); | 21 ASSERT(!m_renderView.needsLayout()); |
22 // RenderViews should never be called to paint with an offset not on device
pixels. | 22 // RenderViews should never be called to paint with an offset not on device
pixels. |
23 ASSERT(LayoutPoint(IntPoint(paintOffset.x(), paintOffset.y())) == paintOffse
t); | 23 ASSERT(LayoutPoint(IntPoint(paintOffset.x(), paintOffset.y())) == paintOffse
t); |
24 | 24 |
25 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, &m_renderView); | 25 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, &m_renderView); |
26 | 26 |
27 // This avoids painting garbage between columns if there is a column gap. | 27 // This avoids painting garbage between columns if there is a column gap. |
28 if (m_renderView.frameView() && m_renderView.style()->isOverflowPaged()) { | 28 if (m_renderView.frameView() && m_renderView.style()->isOverflowPaged()) { |
29 LayoutRect paintRect = paintInfo.rect; | 29 LayoutRect paintRect = paintInfo.rect; |
30 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) | 30 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) |
31 paintRect = m_renderView.viewRect(); | 31 paintRect = m_renderView.viewRect(); |
32 | 32 |
33 RenderDrawingRecorder recorder(paintInfo.context, m_renderView, DisplayI
tem::ViewBackground, paintRect); | 33 RenderDrawingRecorder recorder(paintInfo.context, m_renderView, DisplayI
tem::ViewBackground, paintRect); |
34 if (!recorder.canUseCachedDrawing()) | 34 if (!recorder.canUseCachedDrawing()) |
35 paintInfo.context->fillRect(paintRect, m_renderView.frameView()->bas
eBackgroundColor()); | 35 paintInfo.context->fillRect(paintRect, m_renderView.frameView()->bas
eBackgroundColor()); |
36 } | 36 } |
37 | 37 |
38 m_renderView.paintObject(paintInfo, paintOffset); | 38 m_renderView.paintObject(paintInfo, paintOffset); |
39 BlockPainter(m_renderView).paintOverflowControlsIfNeeded(paintInfo, paintOff
set); | 39 BlockPainter(m_renderView).paintOverflowControlsIfNeeded(paintInfo, paintOff
set); |
40 } | 40 } |
41 | 41 |
42 static inline bool rendererObscuresBackground(RenderBox* rootBox) | 42 static inline bool rendererObscuresBackground(LayoutBox* rootBox) |
43 { | 43 { |
44 ASSERT(rootBox); | 44 ASSERT(rootBox); |
45 const LayoutStyle& style = rootBox->styleRef(); | 45 const LayoutStyle& style = rootBox->styleRef(); |
46 if (style.visibility() != VISIBLE | 46 if (style.visibility() != VISIBLE |
47 || style.opacity() != 1 | 47 || style.opacity() != 1 |
48 || style.hasFilter() | 48 || style.hasFilter() |
49 || style.hasTransform()) | 49 || style.hasTransform()) |
50 return false; | 50 return false; |
51 | 51 |
52 if (rootBox->compositingState() == PaintsIntoOwnBacking) | 52 if (rootBox->compositingState() == PaintsIntoOwnBacking) |
53 return false; | 53 return false; |
54 | 54 |
55 const LayoutObject* rootRenderer = rootBox->rendererForRootBackground(); | 55 const LayoutObject* rootRenderer = rootBox->rendererForRootBackground(); |
56 if (rootRenderer->style()->backgroundClip() == TextFillBox) | 56 if (rootRenderer->style()->backgroundClip() == TextFillBox) |
57 return false; | 57 return false; |
58 | 58 |
59 return true; | 59 return true; |
60 } | 60 } |
61 | 61 |
62 void ViewPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo) | 62 void ViewPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo) |
63 { | 63 { |
64 if (m_renderView.document().ownerElement() || !m_renderView.view()) | 64 if (m_renderView.document().ownerElement() || !m_renderView.view()) |
65 return; | 65 return; |
66 | 66 |
67 if (paintInfo.skipRootBackground()) | 67 if (paintInfo.skipRootBackground()) |
68 return; | 68 return; |
69 | 69 |
70 bool shouldPaintBackground = true; | 70 bool shouldPaintBackground = true; |
71 Node* documentElement = m_renderView.document().documentElement(); | 71 Node* documentElement = m_renderView.document().documentElement(); |
72 if (RenderBox* rootBox = documentElement ? toRenderBox(documentElement->rend
erer()) : 0) | 72 if (LayoutBox* rootBox = documentElement ? toLayoutBox(documentElement->rend
erer()) : 0) |
73 shouldPaintBackground = !rootFillsViewportBackground(rootBox) || !render
erObscuresBackground(rootBox); | 73 shouldPaintBackground = !rootFillsViewportBackground(rootBox) || !render
erObscuresBackground(rootBox); |
74 | 74 |
75 // If painting will entirely fill the view, no need to fill the background. | 75 // If painting will entirely fill the view, no need to fill the background. |
76 if (!shouldPaintBackground) | 76 if (!shouldPaintBackground) |
77 return; | 77 return; |
78 | 78 |
79 // This code typically only executes if the root element's visibility has be
en set to hidden, | 79 // This code typically only executes if the root element's visibility has be
en set to hidden, |
80 // if there is a transform on the <html>, or if there is a page scale factor
less than 1. | 80 // if there is a transform on the <html>, or if there is a page scale factor
less than 1. |
81 // Only fill with the base background color (typically white) if we're the r
oot document, | 81 // Only fill with the base background color (typically white) if we're the r
oot document, |
82 // since iframes/frames with no background in the child document should show
the parent's background. | 82 // since iframes/frames with no background in the child document should show
the parent's background. |
(...skipping 10 matching lines...) Expand all Loading... |
93 paintInfo.context->setCompositeOperation(SkXfermode::kSrc_Mode); | 93 paintInfo.context->setCompositeOperation(SkXfermode::kSrc_Mode); |
94 paintInfo.context->fillRect(paintRect, baseColor); | 94 paintInfo.context->fillRect(paintRect, baseColor); |
95 paintInfo.context->setCompositeOperation(previousOperation); | 95 paintInfo.context->setCompositeOperation(previousOperation); |
96 } else { | 96 } else { |
97 paintInfo.context->clearRect(paintRect); | 97 paintInfo.context->clearRect(paintRect); |
98 } | 98 } |
99 } | 99 } |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 bool ViewPainter::rootFillsViewportBackground(RenderBox* rootBox) const | 103 bool ViewPainter::rootFillsViewportBackground(LayoutBox* rootBox) const |
104 { | 104 { |
105 ASSERT(rootBox); | 105 ASSERT(rootBox); |
106 // CSS Boxes always fill the viewport background (see paintRootBoxFillLayers
) | 106 // CSS Boxes always fill the viewport background (see paintRootBoxFillLayers
) |
107 if (!rootBox->isSVG()) | 107 if (!rootBox->isSVG()) |
108 return true; | 108 return true; |
109 | 109 |
110 return rootBox->frameRect().contains(m_renderView.frameRect()); | 110 return rootBox->frameRect().contains(m_renderView.frameRect()); |
111 } | 111 } |
112 | 112 |
113 } // namespace blink | 113 } // namespace blink |
OLD | NEW |