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

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

Issue 1129793005: Replace OwnPtr with WTF::Optional for optional recorders. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: merge with master Created 5 years, 6 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/layout/LayoutPart.h" 8 #include "core/layout/LayoutPart.h"
9 #include "core/paint/BoxPainter.h" 9 #include "core/paint/BoxPainter.h"
10 #include "core/paint/DeprecatedPaintLayer.h" 10 #include "core/paint/DeprecatedPaintLayer.h"
11 #include "core/paint/LayoutObjectDrawingRecorder.h" 11 #include "core/paint/LayoutObjectDrawingRecorder.h"
12 #include "core/paint/PaintInfo.h" 12 #include "core/paint/PaintInfo.h"
13 #include "core/paint/RoundedInnerRectClipper.h" 13 #include "core/paint/RoundedInnerRectClipper.h"
14 #include "core/paint/ScrollableAreaPainter.h" 14 #include "core/paint/ScrollableAreaPainter.h"
15 #include "core/paint/TransformRecorder.h" 15 #include "core/paint/TransformRecorder.h"
16 #include "wtf/Optional.h"
16 17
17 namespace blink { 18 namespace blink {
18 19
19 void PartPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffs et) 20 void PartPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffs et)
20 { 21 {
21 if (!m_layoutPart.shouldPaint(paintInfo, paintOffset)) 22 if (!m_layoutPart.shouldPaint(paintInfo, paintOffset))
22 return; 23 return;
23 24
24 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutPart.location(); 25 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutPart.location();
25 LayoutRect borderRect(adjustedPaintOffset, m_layoutPart.size()); 26 LayoutRect borderRect(adjustedPaintOffset, m_layoutPart.size());
26 27
27 if (m_layoutPart.hasBoxDecorationBackground() && (paintInfo.phase == PaintPh aseForeground || paintInfo.phase == PaintPhaseSelection)) 28 if (m_layoutPart.hasBoxDecorationBackground() && (paintInfo.phase == PaintPh aseForeground || paintInfo.phase == PaintPhaseSelection))
28 BoxPainter(m_layoutPart).paintBoxDecorationBackground(paintInfo, adjuste dPaintOffset); 29 BoxPainter(m_layoutPart).paintBoxDecorationBackground(paintInfo, adjuste dPaintOffset);
29 30
30 if (paintInfo.phase == PaintPhaseMask) { 31 if (paintInfo.phase == PaintPhaseMask) {
31 BoxPainter(m_layoutPart).paintMask(paintInfo, adjustedPaintOffset); 32 BoxPainter(m_layoutPart).paintMask(paintInfo, adjustedPaintOffset);
32 return; 33 return;
33 } 34 }
34 35
35 LayoutRect visualOverflowRect(m_layoutPart.visualOverflowRect()); 36 LayoutRect visualOverflowRect(m_layoutPart.visualOverflowRect());
36 visualOverflowRect.moveBy(adjustedPaintOffset); 37 visualOverflowRect.moveBy(adjustedPaintOffset);
37 38
38 if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSe lfOutline) && m_layoutPart.style()->hasOutline()) 39 if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSe lfOutline) && m_layoutPart.style()->hasOutline())
39 ObjectPainter(m_layoutPart).paintOutline(paintInfo, borderRect, visualOv erflowRect); 40 ObjectPainter(m_layoutPart).paintOutline(paintInfo, borderRect, visualOv erflowRect);
40 41
41 if (paintInfo.phase != PaintPhaseForeground) 42 if (paintInfo.phase != PaintPhaseForeground)
42 return; 43 return;
43 44
44 { 45 {
45 OwnPtr<RoundedInnerRectClipper> clipper; 46 Optional<RoundedInnerRectClipper> clipper;
46 if (m_layoutPart.style()->hasBorderRadius()) { 47 if (m_layoutPart.style()->hasBorderRadius()) {
47 if (borderRect.isEmpty()) 48 if (borderRect.isEmpty())
48 return; 49 return;
49 50
50 FloatRoundedRect roundedInnerRect = m_layoutPart.style()->getRounded InnerBorderFor(borderRect, 51 FloatRoundedRect roundedInnerRect = m_layoutPart.style()->getRounded InnerBorderFor(borderRect,
51 LayoutRectOutsets( 52 LayoutRectOutsets(
52 -(m_layoutPart.paddingTop() + m_layoutPart.borderTop()), 53 -(m_layoutPart.paddingTop() + m_layoutPart.borderTop()),
53 -(m_layoutPart.paddingRight() + m_layoutPart.borderRight()), 54 -(m_layoutPart.paddingRight() + m_layoutPart.borderRight()),
54 -(m_layoutPart.paddingBottom() + m_layoutPart.borderBottom() ), 55 -(m_layoutPart.paddingBottom() + m_layoutPart.borderBottom() ),
55 -(m_layoutPart.paddingLeft() + m_layoutPart.borderLeft())), 56 -(m_layoutPart.paddingLeft() + m_layoutPart.borderLeft())),
56 true, true); 57 true, true);
57 clipper = adoptPtr(new RoundedInnerRectClipper(m_layoutPart, paintIn fo, borderRect, roundedInnerRect, ApplyToDisplayListIfEnabled)); 58 clipper.emplace(m_layoutPart, paintInfo, borderRect, roundedInnerRec t, ApplyToDisplayListIfEnabled);
58 } 59 }
59 60
60 if (m_layoutPart.widget()) 61 if (m_layoutPart.widget())
61 m_layoutPart.paintContents(paintInfo, paintOffset); 62 m_layoutPart.paintContents(paintInfo, paintOffset);
62 } 63 }
63 64
64 // Paint a partially transparent wash over selected widgets. 65 // Paint a partially transparent wash over selected widgets.
65 if (m_layoutPart.isSelected() && !m_layoutPart.document().printing()) { 66 if (m_layoutPart.isSelected() && !m_layoutPart.document().printing()) {
66 LayoutRect rect = m_layoutPart.localSelectionRect(); 67 LayoutRect rect = m_layoutPart.localSelectionRect();
67 rect.moveBy(adjustedPaintOffset); 68 rect.moveBy(adjustedPaintOffset);
(...skipping 24 matching lines...) Expand all
92 IntSize widgetPaintOffset = paintLocation - widgetLocation; 93 IntSize widgetPaintOffset = paintLocation - widgetLocation;
93 // When painting widgets into compositing layers, tx and ty are relative to the enclosing compositing layer, 94 // When painting widgets into compositing layers, tx and ty are relative to the enclosing compositing layer,
94 // not the root. In this case, shift the CTM and adjust the paintRect to be root-relative to fix plugin drawing. 95 // not the root. In this case, shift the CTM and adjust the paintRect to be root-relative to fix plugin drawing.
95 TransformRecorder transform(*paintInfo.context, m_layoutPart, 96 TransformRecorder transform(*paintInfo.context, m_layoutPart,
96 AffineTransform::translation(widgetPaintOffset.width(), widgetPaintOffse t.height())); 97 AffineTransform::translation(widgetPaintOffset.width(), widgetPaintOffse t.height()));
97 paintRect.move(-widgetPaintOffset); 98 paintRect.move(-widgetPaintOffset);
98 widget->paint(paintInfo.context, paintRect); 99 widget->paint(paintInfo.context, paintRect);
99 } 100 }
100 101
101 } // namespace blink 102 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698