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

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

Issue 596313004: Move painting code from RenderReplaced to ReplacedPainter. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Merged Created 6 years, 2 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
« no previous file with comments | « Source/core/paint/ReplacedPainter.h ('k') | Source/core/rendering/RenderReplaced.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ReplacedPainter.h"
7
8 #include "core/paint/BoxPainter.h"
9 #include "core/rendering/GraphicsContextAnnotator.h"
10 #include "core/rendering/PaintInfo.h"
11 #include "core/rendering/RenderLayer.h"
12 #include "core/rendering/RenderReplaced.h"
13
14 namespace blink {
15
16 void ReplacedPainter::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset )
17 {
18 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, &m_renderReplaced);
19
20 if (!m_renderReplaced.shouldPaint(paintInfo, paintOffset))
21 return;
22
23 LayoutPoint adjustedPaintOffset = paintOffset + m_renderReplaced.location();
24
25 if (m_renderReplaced.hasBoxDecorationBackground() && (paintInfo.phase == Pai ntPhaseForeground || paintInfo.phase == PaintPhaseSelection))
26 m_renderReplaced.paintBoxDecorationBackground(paintInfo, adjustedPaintOf fset);
27
28 if (paintInfo.phase == PaintPhaseMask) {
29 m_renderReplaced.paintMask(paintInfo, adjustedPaintOffset);
30 return;
31 }
32
33 if (paintInfo.phase == PaintPhaseClippingMask && (!m_renderReplaced.hasLayer () || !m_renderReplaced.layer()->hasCompositedClippingMask()))
34 return;
35
36 LayoutRect paintRect = LayoutRect(adjustedPaintOffset, m_renderReplaced.size ());
37 if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSe lfOutline) && m_renderReplaced.style()->outlineWidth())
38 m_renderReplaced.paintOutline(paintInfo, paintRect);
39
40 if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhase Selection && !m_renderReplaced.canHaveChildren() && paintInfo.phase != PaintPhas eClippingMask)
41 return;
42
43 if (!paintInfo.shouldPaintWithinRoot(&m_renderReplaced))
44 return;
45
46 bool drawSelectionTint = m_renderReplaced.selectionState() != RenderObject:: SelectionNone && !m_renderReplaced.document().printing();
47 if (paintInfo.phase == PaintPhaseSelection) {
48 if (m_renderReplaced.selectionState() == RenderObject::SelectionNone)
49 return;
50 drawSelectionTint = false;
51 }
52
53 bool completelyClippedOut = false;
54 if (m_renderReplaced.style()->hasBorderRadius()) {
55 LayoutRect borderRect = LayoutRect(adjustedPaintOffset, m_renderReplaced .size());
56
57 if (borderRect.isEmpty()) {
58 completelyClippedOut = true;
59 } else {
60 // Push a clip if we have a border radius, since we want to round th e foreground content that gets painted.
61 paintInfo.context->save();
62 RoundedRect roundedInnerRect = m_renderReplaced.style()->getRoundedI nnerBorderFor(paintRect,
63 m_renderReplaced.paddingTop() + m_renderReplaced.borderTop(), m_ renderReplaced.paddingBottom() + m_renderReplaced.borderBottom(), m_renderReplac ed.paddingLeft() + m_renderReplaced.borderLeft(), m_renderReplaced.paddingRight( ) + m_renderReplaced.borderRight(), true, true);
64 BoxPainter::clipRoundedInnerRect(paintInfo.context, paintRect, round edInnerRect);
65 }
66 }
67
68 if (!completelyClippedOut) {
69 if (paintInfo.phase == PaintPhaseClippingMask) {
70 m_renderReplaced.paintClippingMask(paintInfo, adjustedPaintOffset);
71 } else {
72 m_renderReplaced.paintReplaced(paintInfo, adjustedPaintOffset);
73 }
74
75 if (m_renderReplaced.style()->hasBorderRadius())
76 paintInfo.context->restore();
77 }
78
79 // The selection tint never gets clipped by border-radius rounding, since we want it to run right up to the edges of
80 // surrounding content.
81 if (drawSelectionTint) {
82 LayoutRect selectionPaintingRect = m_renderReplaced.localSelectionRect() ;
83 selectionPaintingRect.moveBy(adjustedPaintOffset);
84 paintInfo.context->fillRect(pixelSnappedIntRect(selectionPaintingRect), m_renderReplaced.selectionBackgroundColor());
85 }
86 }
87
88 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/ReplacedPainter.h ('k') | Source/core/rendering/RenderReplaced.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698