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

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

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

Powered by Google App Engine
This is Rietveld 408576698