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/PartPainter.h" | 6 #include "core/paint/PartPainter.h" |
7 | 7 |
8 #include "core/layout/Layer.h" | 8 #include "core/layout/Layer.h" |
| 9 #include "core/layout/LayoutPart.h" |
9 #include "core/layout/PaintInfo.h" | 10 #include "core/layout/PaintInfo.h" |
10 #include "core/paint/BoxPainter.h" | 11 #include "core/paint/BoxPainter.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/paint/RoundedInnerRectClipper.h" | 14 #include "core/paint/RoundedInnerRectClipper.h" |
14 #include "core/paint/ScrollableAreaPainter.h" | 15 #include "core/paint/ScrollableAreaPainter.h" |
15 #include "core/paint/TransformRecorder.h" | 16 #include "core/paint/TransformRecorder.h" |
16 #include "core/rendering/RenderPart.h" | |
17 | 17 |
18 namespace blink { | 18 namespace blink { |
19 | 19 |
20 void PartPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffs
et) | 20 void PartPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffs
et) |
21 { | 21 { |
22 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, &m_renderPart); | 22 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, &m_layoutPart); |
23 | 23 |
24 if (!m_renderPart.shouldPaint(paintInfo, paintOffset)) | 24 if (!m_layoutPart.shouldPaint(paintInfo, paintOffset)) |
25 return; | 25 return; |
26 | 26 |
27 LayoutPoint adjustedPaintOffset = paintOffset + m_renderPart.location(); | 27 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutPart.location(); |
28 LayoutRect borderRect(adjustedPaintOffset, m_renderPart.size()); | 28 LayoutRect borderRect(adjustedPaintOffset, m_layoutPart.size()); |
29 | 29 |
30 if (m_renderPart.hasBoxDecorationBackground() && (paintInfo.phase == PaintPh
aseForeground || paintInfo.phase == PaintPhaseSelection)) | 30 if (m_layoutPart.hasBoxDecorationBackground() && (paintInfo.phase == PaintPh
aseForeground || paintInfo.phase == PaintPhaseSelection)) |
31 BoxPainter(m_renderPart).paintBoxDecorationBackground(paintInfo, adjuste
dPaintOffset); | 31 BoxPainter(m_layoutPart).paintBoxDecorationBackground(paintInfo, adjuste
dPaintOffset); |
32 | 32 |
33 if (paintInfo.phase == PaintPhaseMask) { | 33 if (paintInfo.phase == PaintPhaseMask) { |
34 BoxPainter(m_renderPart).paintMask(paintInfo, adjustedPaintOffset); | 34 BoxPainter(m_layoutPart).paintMask(paintInfo, adjustedPaintOffset); |
35 return; | 35 return; |
36 } | 36 } |
37 | 37 |
38 if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSe
lfOutline) && m_renderPart.style()->hasOutline()) | 38 if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSe
lfOutline) && m_layoutPart.style()->hasOutline()) |
39 ObjectPainter(m_renderPart).paintOutline(paintInfo, borderRect); | 39 ObjectPainter(m_layoutPart).paintOutline(paintInfo, borderRect); |
40 | 40 |
41 if (paintInfo.phase != PaintPhaseForeground) | 41 if (paintInfo.phase != PaintPhaseForeground) |
42 return; | 42 return; |
43 | 43 |
44 { | 44 { |
45 OwnPtr<RoundedInnerRectClipper> clipper; | 45 OwnPtr<RoundedInnerRectClipper> clipper; |
46 if (m_renderPart.style()->hasBorderRadius()) { | 46 if (m_layoutPart.style()->hasBorderRadius()) { |
47 if (borderRect.isEmpty()) | 47 if (borderRect.isEmpty()) |
48 return; | 48 return; |
49 | 49 |
50 FloatRoundedRect roundedInnerRect = m_renderPart.style()->getRounded
InnerBorderFor(borderRect, | 50 FloatRoundedRect roundedInnerRect = m_layoutPart.style()->getRounded
InnerBorderFor(borderRect, |
51 m_renderPart.paddingTop() + m_renderPart.borderTop(), m_renderPa
rt.paddingBottom() + m_renderPart.borderBottom(), m_renderPart.paddingLeft() + m
_renderPart.borderLeft(), m_renderPart.paddingRight() + m_renderPart.borderRight
(), true, true); | 51 m_layoutPart.paddingTop() + m_layoutPart.borderTop(), m_layoutPa
rt.paddingBottom() + m_layoutPart.borderBottom(), m_layoutPart.paddingLeft() + m
_layoutPart.borderLeft(), m_layoutPart.paddingRight() + m_layoutPart.borderRight
(), true, true); |
52 clipper = adoptPtr(new RoundedInnerRectClipper(m_renderPart, paintIn
fo, borderRect, roundedInnerRect, ApplyToDisplayListIfEnabled)); | 52 clipper = adoptPtr(new RoundedInnerRectClipper(m_layoutPart, paintIn
fo, borderRect, roundedInnerRect, ApplyToDisplayListIfEnabled)); |
53 } | 53 } |
54 | 54 |
55 if (m_renderPart.widget()) | 55 if (m_layoutPart.widget()) |
56 m_renderPart.paintContents(paintInfo, paintOffset); | 56 m_layoutPart.paintContents(paintInfo, paintOffset); |
57 } | 57 } |
58 | 58 |
59 // Paint a partially transparent wash over selected widgets. | 59 // Paint a partially transparent wash over selected widgets. |
60 if (m_renderPart.isSelected() && !m_renderPart.document().printing()) { | 60 if (m_layoutPart.isSelected() && !m_layoutPart.document().printing()) { |
61 LayoutRect rect = m_renderPart.localSelectionRect(); | 61 LayoutRect rect = m_layoutPart.localSelectionRect(); |
62 rect.moveBy(adjustedPaintOffset); | 62 rect.moveBy(adjustedPaintOffset); |
63 IntRect selectionRect = pixelSnappedIntRect(rect); | 63 IntRect selectionRect = pixelSnappedIntRect(rect); |
64 RenderDrawingRecorder recorder(paintInfo.context, m_renderPart, paintInf
o.phase, selectionRect); | 64 RenderDrawingRecorder recorder(paintInfo.context, m_layoutPart, paintInf
o.phase, selectionRect); |
65 paintInfo.context->fillRect(selectionRect, m_renderPart.selectionBackgro
undColor()); | 65 paintInfo.context->fillRect(selectionRect, m_layoutPart.selectionBackgro
undColor()); |
66 } | 66 } |
67 | 67 |
68 if (m_renderPart.canResize()) | 68 if (m_layoutPart.canResize()) |
69 ScrollableAreaPainter(*m_renderPart.layer()->scrollableArea()).paintResi
zer(paintInfo.context, roundedIntPoint(adjustedPaintOffset), paintInfo.rect); | 69 ScrollableAreaPainter(*m_layoutPart.layer()->scrollableArea()).paintResi
zer(paintInfo.context, roundedIntPoint(adjustedPaintOffset), paintInfo.rect); |
70 } | 70 } |
71 | 71 |
72 void PartPainter::paintContents(const PaintInfo& paintInfo, const LayoutPoint& p
aintOffset) | 72 void PartPainter::paintContents(const PaintInfo& paintInfo, const LayoutPoint& p
aintOffset) |
73 { | 73 { |
74 LayoutPoint adjustedPaintOffset = paintOffset + m_renderPart.location(); | 74 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutPart.location(); |
75 | 75 |
76 Widget* widget = m_renderPart.widget(); | 76 Widget* widget = m_layoutPart.widget(); |
77 RELEASE_ASSERT(widget); | 77 RELEASE_ASSERT(widget); |
78 | 78 |
79 // Tell the widget to paint now. This is the only time the widget is allowed | 79 // Tell the widget to paint now. This is the only time the widget is allowed |
80 // to paint itself. That way it will composite properly with z-indexed layer
s. | 80 // to paint itself. That way it will composite properly with z-indexed layer
s. |
81 IntPoint widgetLocation = widget->frameRect().location(); | 81 IntPoint widgetLocation = widget->frameRect().location(); |
82 IntPoint paintLocation(roundToInt(adjustedPaintOffset.x() + m_renderPart.bor
derLeft() + m_renderPart.paddingLeft()), | 82 IntPoint paintLocation(roundToInt(adjustedPaintOffset.x() + m_layoutPart.bor
derLeft() + m_layoutPart.paddingLeft()), |
83 roundToInt(adjustedPaintOffset.y() + m_renderPart.borderTop() + m_render
Part.paddingTop())); | 83 roundToInt(adjustedPaintOffset.y() + m_layoutPart.borderTop() + m_layout
Part.paddingTop())); |
84 IntRect paintRect = paintInfo.rect; | 84 IntRect paintRect = paintInfo.rect; |
85 | 85 |
86 IntSize widgetPaintOffset = paintLocation - widgetLocation; | 86 IntSize widgetPaintOffset = paintLocation - widgetLocation; |
87 // When painting widgets into compositing layers, tx and ty are relative to
the enclosing compositing layer, | 87 // When painting widgets into compositing layers, tx and ty are relative to
the enclosing compositing layer, |
88 // not the root. In this case, shift the CTM and adjust the paintRect to be
root-relative to fix plug-in drawing. | 88 // not the root. In this case, shift the CTM and adjust the paintRect to be
root-relative to fix plug-in drawing. |
89 TransformRecorder transform(*paintInfo.context, m_renderPart.displayItemClie
nt(), | 89 TransformRecorder transform(*paintInfo.context, m_layoutPart.displayItemClie
nt(), |
90 AffineTransform::translation(widgetPaintOffset.width(), widgetPaintOffse
t.height())); | 90 AffineTransform::translation(widgetPaintOffset.width(), widgetPaintOffse
t.height())); |
91 paintRect.move(-widgetPaintOffset); | 91 paintRect.move(-widgetPaintOffset); |
92 widget->paint(paintInfo.context, paintRect); | 92 widget->paint(paintInfo.context, paintRect); |
93 } | 93 } |
94 | 94 |
95 } // namespace blink | 95 } // namespace blink |
OLD | NEW |