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

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

Issue 1321613002: Refactor ObjectPainter::paintOutline to take a paintOffset (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove ObjectPainter::outlineRectForSVG Created 5 years, 3 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
« no previous file with comments | « Source/core/paint/PartPainter.cpp ('k') | Source/core/paint/SVGContainerPainter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ReplacedPainter.h" 6 #include "core/paint/ReplacedPainter.h"
7 7
8 #include "core/layout/LayoutReplaced.h" 8 #include "core/layout/LayoutReplaced.h"
9 #include "core/layout/api/SelectionState.h" 9 #include "core/layout/api/SelectionState.h"
10 #include "core/paint/BoxPainter.h" 10 #include "core/paint/BoxPainter.h"
11 #include "core/paint/DeprecatedPaintLayer.h" 11 #include "core/paint/DeprecatedPaintLayer.h"
12 #include "core/paint/LayoutObjectDrawingRecorder.h" 12 #include "core/paint/LayoutObjectDrawingRecorder.h"
13 #include "core/paint/ObjectPainter.h" 13 #include "core/paint/ObjectPainter.h"
14 #include "core/paint/PaintInfo.h" 14 #include "core/paint/PaintInfo.h"
15 #include "core/paint/RoundedInnerRectClipper.h" 15 #include "core/paint/RoundedInnerRectClipper.h"
16 #include "wtf/Optional.h" 16 #include "wtf/Optional.h"
17 17
18 namespace blink { 18 namespace blink {
19 19
20 void ReplacedPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paint Offset) 20 void ReplacedPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paint Offset)
21 { 21 {
22 if (!m_layoutReplaced.shouldPaint(paintInfo, paintOffset)) 22 if (!m_layoutReplaced.shouldPaint(paintInfo, paintOffset))
23 return; 23 return;
24 24
25 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutReplaced.location(); 25 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutReplaced.location();
26 LayoutRect paintRect(adjustedPaintOffset, m_layoutReplaced.size()); 26 LayoutRect borderRect(adjustedPaintOffset, m_layoutReplaced.size());
27
28 LayoutRect visualOverflowRect(m_layoutReplaced.visualOverflowRect());
29 visualOverflowRect.moveBy(adjustedPaintOffset);
30 27
31 if (m_layoutReplaced.hasBoxDecorationBackground() && (paintInfo.phase == Pai ntPhaseForeground || paintInfo.phase == PaintPhaseSelection)) 28 if (m_layoutReplaced.hasBoxDecorationBackground() && (paintInfo.phase == Pai ntPhaseForeground || paintInfo.phase == PaintPhaseSelection))
32 m_layoutReplaced.paintBoxDecorationBackground(paintInfo, adjustedPaintOf fset); 29 m_layoutReplaced.paintBoxDecorationBackground(paintInfo, adjustedPaintOf fset);
33 30
34 if (paintInfo.phase == PaintPhaseMask) { 31 if (paintInfo.phase == PaintPhaseMask) {
35 m_layoutReplaced.paintMask(paintInfo, adjustedPaintOffset); 32 m_layoutReplaced.paintMask(paintInfo, adjustedPaintOffset);
36 return; 33 return;
37 } 34 }
38 35
39 if (paintInfo.phase == PaintPhaseClippingMask && (!m_layoutReplaced.hasLayer () || !m_layoutReplaced.layer()->hasCompositedClippingMask())) 36 if (paintInfo.phase == PaintPhaseClippingMask && (!m_layoutReplaced.hasLayer () || !m_layoutReplaced.layer()->hasCompositedClippingMask()))
40 return; 37 return;
41 38
42 if (paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSel fOutline) { 39 if (paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSel fOutline) {
43 if (m_layoutReplaced.styleRef().outlineWidth()) 40 if (m_layoutReplaced.styleRef().outlineWidth())
44 ObjectPainter(m_layoutReplaced).paintOutline(paintInfo, paintRect, v isualOverflowRect); 41 ObjectPainter(m_layoutReplaced).paintOutline(paintInfo, m_layoutRepl aced.visualOverflowRect(), borderRect.size(), adjustedPaintOffset);
45 return; 42 return;
46 } 43 }
47 44
48 if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhase Selection && !m_layoutReplaced.canHaveChildren() && paintInfo.phase != PaintPhas eClippingMask) 45 if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhase Selection && !m_layoutReplaced.canHaveChildren() && paintInfo.phase != PaintPhas eClippingMask)
49 return; 46 return;
50 47
51 if (!paintInfo.shouldPaintWithinRoot(&m_layoutReplaced)) 48 if (!paintInfo.shouldPaintWithinRoot(&m_layoutReplaced))
52 return; 49 return;
53 50
54 if (paintInfo.phase == PaintPhaseSelection) 51 if (paintInfo.phase == PaintPhaseSelection)
55 if (m_layoutReplaced.selectionState() == SelectionNone) 52 if (m_layoutReplaced.selectionState() == SelectionNone)
56 return; 53 return;
57 54
58 { 55 {
59 Optional<RoundedInnerRectClipper> clipper; 56 Optional<RoundedInnerRectClipper> clipper;
60 bool completelyClippedOut = false; 57 bool completelyClippedOut = false;
61 if (m_layoutReplaced.style()->hasBorderRadius()) { 58 if (m_layoutReplaced.style()->hasBorderRadius()) {
62 LayoutRect borderRect = LayoutRect(adjustedPaintOffset, m_layoutRepl aced.size());
63
64 if (borderRect.isEmpty()) { 59 if (borderRect.isEmpty()) {
65 completelyClippedOut = true; 60 completelyClippedOut = true;
66 } else { 61 } else {
67 // Push a clip if we have a border radius, since we want to roun d the foreground content that gets painted. 62 // Push a clip if we have a border radius, since we want to roun d the foreground content that gets painted.
68 FloatRoundedRect roundedInnerRect = m_layoutReplaced.style()->ge tRoundedInnerBorderFor(paintRect, 63 FloatRoundedRect roundedInnerRect = m_layoutReplaced.style()->ge tRoundedInnerBorderFor(borderRect,
69 LayoutRectOutsets( 64 LayoutRectOutsets(
70 -(m_layoutReplaced.paddingTop() + m_layoutReplaced.borde rTop()), 65 -(m_layoutReplaced.paddingTop() + m_layoutReplaced.borde rTop()),
71 -(m_layoutReplaced.paddingRight() + m_layoutReplaced.bor derRight()), 66 -(m_layoutReplaced.paddingRight() + m_layoutReplaced.bor derRight()),
72 -(m_layoutReplaced.paddingBottom() + m_layoutReplaced.bo rderBottom()), 67 -(m_layoutReplaced.paddingBottom() + m_layoutReplaced.bo rderBottom()),
73 -(m_layoutReplaced.paddingLeft() + m_layoutReplaced.bord erLeft())), 68 -(m_layoutReplaced.paddingLeft() + m_layoutReplaced.bord erLeft())),
74 true, true); 69 true, true);
75 70
76 clipper.emplace(m_layoutReplaced, paintInfo, paintRect, roundedI nnerRect, ApplyToDisplayListIfEnabled); 71 clipper.emplace(m_layoutReplaced, paintInfo, borderRect, rounded InnerRect, ApplyToDisplayListIfEnabled);
77 } 72 }
78 } 73 }
79 74
80 if (!completelyClippedOut) { 75 if (!completelyClippedOut) {
81 if (paintInfo.phase == PaintPhaseClippingMask) { 76 if (paintInfo.phase == PaintPhaseClippingMask) {
82 BoxPainter(m_layoutReplaced).paintClippingMask(paintInfo, adjust edPaintOffset); 77 BoxPainter(m_layoutReplaced).paintClippingMask(paintInfo, adjust edPaintOffset);
83 } else { 78 } else {
84 m_layoutReplaced.paintReplaced(paintInfo, adjustedPaintOffset); 79 m_layoutReplaced.paintReplaced(paintInfo, adjustedPaintOffset);
85 } 80 }
86 } 81 }
87 } 82 }
88 83
89 // The selection tint never gets clipped by border-radius rounding, since we want it to run right up to the edges of 84 // The selection tint never gets clipped by border-radius rounding, since we want it to run right up to the edges of
90 // surrounding content. 85 // surrounding content.
91 bool drawSelectionTint = paintInfo.phase == PaintPhaseForeground && m_layout Replaced.selectionState() != SelectionNone && !paintInfo.isPrinting(); 86 bool drawSelectionTint = paintInfo.phase == PaintPhaseForeground && m_layout Replaced.selectionState() != SelectionNone && !paintInfo.isPrinting();
92 if (drawSelectionTint && !LayoutObjectDrawingRecorder::useCachedDrawingIfPos sible(*paintInfo.context, m_layoutReplaced, DisplayItem::SelectionTint)) { 87 if (drawSelectionTint && !LayoutObjectDrawingRecorder::useCachedDrawingIfPos sible(*paintInfo.context, m_layoutReplaced, DisplayItem::SelectionTint)) {
93 LayoutRect selectionPaintingRect = m_layoutReplaced.localSelectionRect() ; 88 LayoutRect selectionPaintingRect = m_layoutReplaced.localSelectionRect() ;
94 selectionPaintingRect.moveBy(adjustedPaintOffset); 89 selectionPaintingRect.moveBy(adjustedPaintOffset);
95 IntRect selectionPaintingIntRect = pixelSnappedIntRect(selectionPainting Rect); 90 IntRect selectionPaintingIntRect = pixelSnappedIntRect(selectionPainting Rect);
96 91
97 LayoutObjectDrawingRecorder drawingRecorder(*paintInfo.context, m_layout Replaced, DisplayItem::SelectionTint, selectionPaintingIntRect); 92 LayoutObjectDrawingRecorder drawingRecorder(*paintInfo.context, m_layout Replaced, DisplayItem::SelectionTint, selectionPaintingIntRect);
98 paintInfo.context->fillRect(selectionPaintingIntRect, m_layoutReplaced.s electionBackgroundColor()); 93 paintInfo.context->fillRect(selectionPaintingIntRect, m_layoutReplaced.s electionBackgroundColor());
99 } 94 }
100 } 95 }
101 96
102 } // namespace blink 97 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/PartPainter.cpp ('k') | Source/core/paint/SVGContainerPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698