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 "core/paint/ReplacedPainter.h" | 5 #include "core/paint/ReplacedPainter.h" |
6 | 6 |
7 #include "core/layout/LayoutReplaced.h" | 7 #include "core/layout/LayoutReplaced.h" |
8 #include "core/layout/api/SelectionState.h" | 8 #include "core/layout/api/SelectionState.h" |
9 #include "core/layout/svg/LayoutSVGRoot.h" | 9 #include "core/layout/svg/LayoutSVGRoot.h" |
10 #include "core/paint/BoxPainter.h" | 10 #include "core/paint/BoxPainter.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 if (m_layoutReplaced.getSelectionState() == SelectionNone) | 63 if (m_layoutReplaced.getSelectionState() == SelectionNone) |
64 return; | 64 return; |
65 | 65 |
66 { | 66 { |
67 Optional<RoundedInnerRectClipper> clipper; | 67 Optional<RoundedInnerRectClipper> clipper; |
68 bool completelyClippedOut = false; | 68 bool completelyClippedOut = false; |
69 if (m_layoutReplaced.style()->hasBorderRadius()) { | 69 if (m_layoutReplaced.style()->hasBorderRadius()) { |
70 if (borderRect.isEmpty()) { | 70 if (borderRect.isEmpty()) { |
71 completelyClippedOut = true; | 71 completelyClippedOut = true; |
72 } else if (shouldApplyViewportClip(m_layoutReplaced)) { | 72 } else if (shouldApplyViewportClip(m_layoutReplaced)) { |
73 // Push a clip if we have a border radius, since we want to round the fo
reground content that gets painted. | 73 // Push a clip if we have a border radius, since we want to round the |
| 74 // foreground content that gets painted. |
74 FloatRoundedRect roundedInnerRect = | 75 FloatRoundedRect roundedInnerRect = |
75 m_layoutReplaced.style()->getRoundedInnerBorderFor( | 76 m_layoutReplaced.style()->getRoundedInnerBorderFor( |
76 borderRect, | 77 borderRect, |
77 LayoutRectOutsets(-(m_layoutReplaced.paddingTop() + | 78 LayoutRectOutsets(-(m_layoutReplaced.paddingTop() + |
78 m_layoutReplaced.borderTop()), | 79 m_layoutReplaced.borderTop()), |
79 -(m_layoutReplaced.paddingRight() + | 80 -(m_layoutReplaced.paddingRight() + |
80 m_layoutReplaced.borderRight()), | 81 m_layoutReplaced.borderRight()), |
81 -(m_layoutReplaced.paddingBottom() + | 82 -(m_layoutReplaced.paddingBottom() + |
82 m_layoutReplaced.borderBottom()), | 83 m_layoutReplaced.borderBottom()), |
83 -(m_layoutReplaced.paddingLeft() + | 84 -(m_layoutReplaced.paddingLeft() + |
84 m_layoutReplaced.borderLeft())), | 85 m_layoutReplaced.borderLeft())), |
85 true, true); | 86 true, true); |
86 | 87 |
87 clipper.emplace(m_layoutReplaced, paintInfo, borderRect, | 88 clipper.emplace(m_layoutReplaced, paintInfo, borderRect, |
88 roundedInnerRect, ApplyToDisplayList); | 89 roundedInnerRect, ApplyToDisplayList); |
89 } | 90 } |
90 } | 91 } |
91 | 92 |
92 if (!completelyClippedOut) { | 93 if (!completelyClippedOut) { |
93 if (paintInfo.phase == PaintPhaseClippingMask) { | 94 if (paintInfo.phase == PaintPhaseClippingMask) { |
94 BoxPainter(m_layoutReplaced) | 95 BoxPainter(m_layoutReplaced) |
95 .paintClippingMask(paintInfo, adjustedPaintOffset); | 96 .paintClippingMask(paintInfo, adjustedPaintOffset); |
96 } else { | 97 } else { |
97 m_layoutReplaced.paintReplaced(paintInfo, adjustedPaintOffset); | 98 m_layoutReplaced.paintReplaced(paintInfo, adjustedPaintOffset); |
98 } | 99 } |
99 } | 100 } |
100 } | 101 } |
101 | 102 |
102 // The selection tint never gets clipped by border-radius rounding, since we w
ant it to run right up to the edges of | 103 // The selection tint never gets clipped by border-radius rounding, since we |
103 // surrounding content. | 104 // want it to run right up to the edges of surrounding content. |
104 bool drawSelectionTint = | 105 bool drawSelectionTint = |
105 paintInfo.phase == PaintPhaseForeground && | 106 paintInfo.phase == PaintPhaseForeground && |
106 m_layoutReplaced.getSelectionState() != SelectionNone && | 107 m_layoutReplaced.getSelectionState() != SelectionNone && |
107 !paintInfo.isPrinting(); | 108 !paintInfo.isPrinting(); |
108 if (drawSelectionTint && | 109 if (drawSelectionTint && |
109 !LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( | 110 !LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( |
110 paintInfo.context, m_layoutReplaced, DisplayItem::kSelectionTint)) { | 111 paintInfo.context, m_layoutReplaced, DisplayItem::kSelectionTint)) { |
111 LayoutRect selectionPaintingRect = m_layoutReplaced.localSelectionRect(); | 112 LayoutRect selectionPaintingRect = m_layoutReplaced.localSelectionRect(); |
112 selectionPaintingRect.moveBy(adjustedPaintOffset); | 113 selectionPaintingRect.moveBy(adjustedPaintOffset); |
113 IntRect selectionPaintingIntRect = | 114 IntRect selectionPaintingIntRect = |
(...skipping 11 matching lines...) Expand all Loading... |
125 const PaintInfo& paintInfo, | 126 const PaintInfo& paintInfo, |
126 const LayoutPoint& adjustedPaintOffset) const { | 127 const LayoutPoint& adjustedPaintOffset) const { |
127 if (paintInfo.phase != PaintPhaseForeground && | 128 if (paintInfo.phase != PaintPhaseForeground && |
128 !shouldPaintSelfOutline(paintInfo.phase) && | 129 !shouldPaintSelfOutline(paintInfo.phase) && |
129 paintInfo.phase != PaintPhaseSelection && | 130 paintInfo.phase != PaintPhaseSelection && |
130 paintInfo.phase != PaintPhaseMask && | 131 paintInfo.phase != PaintPhaseMask && |
131 paintInfo.phase != PaintPhaseClippingMask) | 132 paintInfo.phase != PaintPhaseClippingMask) |
132 return false; | 133 return false; |
133 | 134 |
134 // If we're invisible or haven't received a layout yet, just bail. | 135 // If we're invisible or haven't received a layout yet, just bail. |
135 // But if it's an SVG root, there can be children, so we'll check visibility l
ater. | 136 // But if it's an SVG root, there can be children, so we'll check visibility |
| 137 // later. |
136 if (!m_layoutReplaced.isSVGRoot() && | 138 if (!m_layoutReplaced.isSVGRoot() && |
137 m_layoutReplaced.style()->visibility() != EVisibility::Visible) | 139 m_layoutReplaced.style()->visibility() != EVisibility::Visible) |
138 return false; | 140 return false; |
139 | 141 |
140 LayoutRect paintRect(m_layoutReplaced.visualOverflowRect()); | 142 LayoutRect paintRect(m_layoutReplaced.visualOverflowRect()); |
141 paintRect.unite(m_layoutReplaced.localSelectionRect()); | 143 paintRect.unite(m_layoutReplaced.localSelectionRect()); |
142 paintRect.moveBy(adjustedPaintOffset); | 144 paintRect.moveBy(adjustedPaintOffset); |
143 | 145 |
144 if (!paintInfo.cullRect().intersectsCullRect(paintRect)) | 146 if (!paintInfo.cullRect().intersectsCullRect(paintRect)) |
145 return false; | 147 return false; |
146 | 148 |
147 return true; | 149 return true; |
148 } | 150 } |
149 | 151 |
150 } // namespace blink | 152 } // namespace blink |
OLD | NEW |