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

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

Issue 714303003: Move painting code from RenderPart to PartPainter. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month 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/PartPainter.h"
7
8 #include "core/paint/BoxPainter.h"
9
10 #include "core/rendering/GraphicsContextAnnotator.h"
11 #include "core/rendering/PaintInfo.h"
12 #include "core/rendering/RenderLayer.h"
13 #include "core/rendering/RenderPart.h"
14
15 namespace blink {
16
17 void PartPainter::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
18 {
19 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, &m_renderPart);
20
21 if (!m_renderPart.shouldPaint(paintInfo, paintOffset))
22 return;
23
24 LayoutPoint adjustedPaintOffset = paintOffset + m_renderPart.location();
25
26 if (m_renderPart.hasBoxDecorationBackground() && (paintInfo.phase == PaintPh aseForeground || paintInfo.phase == PaintPhaseSelection))
27 BoxPainter(m_renderPart).paintBoxDecorationBackground(paintInfo, adjuste dPaintOffset);
28
29 if (paintInfo.phase == PaintPhaseMask) {
30 BoxPainter(m_renderPart).paintMask(paintInfo, adjustedPaintOffset);
31 return;
32 }
33
34 if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSe lfOutline) && m_renderPart.style()->hasOutline())
35 ObjectPainter(m_renderPart).paintOutline(paintInfo, LayoutRect(adjustedP aintOffset, m_renderPart.size()));
36
37 if (paintInfo.phase != PaintPhaseForeground)
38 return;
39
40 if (m_renderPart.style()->hasBorderRadius()) {
41 LayoutRect borderRect = LayoutRect(adjustedPaintOffset, m_renderPart.siz e());
42
43 if (borderRect.isEmpty())
44 return;
45
46 // Push a clip if we have a border radius, since we want to round the fo reground content that gets painted.
47 paintInfo.context->save();
48 RoundedRect roundedInnerRect = m_renderPart.style()->getRoundedInnerBord erFor(borderRect,
49 m_renderPart.paddingTop() + m_renderPart.borderTop(), m_renderPart.p addingBottom() + m_renderPart.borderBottom(), m_renderPart.paddingLeft() + m_ren derPart.borderLeft(), m_renderPart.paddingRight() + m_renderPart.borderRight(), true, true);
50 BoxPainter::clipRoundedInnerRect(paintInfo.context, borderRect, roundedI nnerRect);
51 }
52
53 if (m_renderPart.widget())
54 m_renderPart.paintContents(paintInfo, paintOffset);
55
56 if (m_renderPart.style()->hasBorderRadius())
57 paintInfo.context->restore();
58
59 // Paint a partially transparent wash over selected widgets.
60 if (m_renderPart.isSelected() && !m_renderPart.document().printing()) {
61 LayoutRect rect = m_renderPart.localSelectionRect();
62 rect.moveBy(adjustedPaintOffset);
63 paintInfo.context->fillRect(pixelSnappedIntRect(rect), m_renderPart.sele ctionBackgroundColor());
64 }
65
66 if (m_renderPart.canResize())
67 m_renderPart.layer()->scrollableArea()->paintResizer(paintInfo.context, roundedIntPoint(adjustedPaintOffset), paintInfo.rect);
68 }
69
70 void PartPainter::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOf fset)
71 {
72 LayoutPoint adjustedPaintOffset = paintOffset + m_renderPart.location();
73
74 Widget* widget = m_renderPart.widget();
75 RELEASE_ASSERT(widget);
76
77 // Tell the widget to paint now. This is the only time the widget is allowed
78 // to paint itself. That way it will composite properly with z-indexed layer s.
79 IntPoint widgetLocation = widget->frameRect().location();
80 IntPoint paintLocation(roundToInt(adjustedPaintOffset.x() + m_renderPart.bor derLeft() + m_renderPart.paddingLeft()),
81 roundToInt(adjustedPaintOffset.y() + m_renderPart.borderTop() + m_render Part.paddingTop()));
82 IntRect paintRect = paintInfo.rect;
83
84 IntSize widgetPaintOffset = paintLocation - widgetLocation;
85 // When painting widgets into compositing layers, tx and ty are relative to the enclosing compositing layer,
86 // not the root. In this case, shift the CTM and adjust the paintRect to be root-relative to fix plug-in drawing.
87 if (!widgetPaintOffset.isZero()) {
88 paintInfo.context->translate(widgetPaintOffset.width(), widgetPaintOffse t.height());
89 paintRect.move(-widgetPaintOffset);
90 }
91 widget->paint(paintInfo.context, paintRect);
92
93 if (!widgetPaintOffset.isZero())
94 paintInfo.context->translate(-widgetPaintOffset.width(), -widgetPaintOff set.height());
95 }
96
97 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698