Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: Source/core/paint/ViewPainter.cpp

Issue 589283002: Move painting code from RenderView to ViewPainter. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/paint/ViewPainter.h"
7
8 #include "core/frame/FrameView.h"
9 #include "core/rendering/GraphicsContextAnnotator.h"
10 #include "core/rendering/PaintInfo.h"
11 #include "core/rendering/RenderBox.h"
12 #include "core/rendering/RenderView.h"
13
14 namespace blink {
15
16 void ViewPainter::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
17 {
18 // If we ever require layout but receive a paint anyway, something has gone horribly wrong.
19 ASSERT(!needsLayout());
pdr. 2014/09/22 22:49:17 We can move this up, or remove it entirely.
chrishtr 2014/09/22 23:10:51 Done.
20 // RenderViews should never be called to paint with an offset not on device pixels.
21 ASSERT(LayoutPoint(IntPoint(paintOffset.x(), paintOffset.y())) == paintOffse t);
22
23 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, &m_renderView);
24
25 // This avoids painting garbage between columns if there is a column gap.
26 if (m_renderView.frameView() && m_renderView.style()->isOverflowPaged())
27 paintInfo.context->fillRect(paintInfo.rect, m_renderView.frameView()->ba seBackgroundColor());
28
29 m_renderView.paintObject(paintInfo, paintOffset);
30 }
31
32 static inline bool rendererObscuresBackground(RenderBox* rootBox)
33 {
34 ASSERT(rootBox);
35 RenderStyle* style = rootBox->style();
36 if (style->visibility() != VISIBLE
37 || style->opacity() != 1
38 || style->hasFilter()
39 || style->hasTransform())
40 return false;
41
42 if (rootBox->compositingState() == PaintsIntoOwnBacking)
43 return false;
44
45 const RenderObject* rootRenderer = rootBox->rendererForRootBackground();
46 if (rootRenderer->style()->backgroundClip() == TextFillBox)
47 return false;
48
49 return true;
50 }
51
52 void ViewPainter::paintBoxDecorationBackground(PaintInfo& paintInfo)
53 {
54 if (m_renderView.document().ownerElement() || !m_renderView.view())
55 return;
56
57 if (paintInfo.skipRootBackground())
58 return;
59
60 bool shouldPaintBackground = true;
61 Node* documentElement = m_renderView.document().documentElement();
62 if (RenderBox* rootBox = documentElement ? toRenderBox(documentElement->rend erer()) : 0)
63 shouldPaintBackground = !rootFillsViewportBackground(rootBox) || !render erObscuresBackground(rootBox);
64
65 // If painting will entirely fill the view, no need to fill the background.
66 if (!shouldPaintBackground)
67 return;
68
69 // This code typically only executes if the root element's visibility has be en set to hidden,
70 // if there is a transform on the <html>, or if there is a page scale factor less than 1.
71 // Only fill with the base background color (typically white) if we're the r oot document,
72 // since iframes/frames with no background in the child document should show the parent's background.
73 if (!m_renderView.frameView()->isTransparent()) {
74 Color baseColor = m_renderView.frameView()->baseBackgroundColor();
75 if (baseColor.alpha()) {
76 CompositeOperator previousOperator = paintInfo.context->compositeOpe ration();
77 paintInfo.context->setCompositeOperation(CompositeCopy);
78 paintInfo.context->fillRect(paintInfo.rect, baseColor);
79 paintInfo.context->setCompositeOperation(previousOperator);
80 } else {
81 paintInfo.context->clearRect(paintInfo.rect);
82 }
83 }
84 }
85
86 bool ViewPainter::rootFillsViewportBackground(RenderBox* rootBox) const
87 {
88 ASSERT(rootBox);
89 // CSS Boxes always fill the viewport background (see paintRootBoxFillLayers )
90 if (!rootBox->isSVG())
91 return true;
92
93 return rootBox->frameRect().contains(m_renderView.frameRect());
94 }
95
96 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698