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/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/layout/svg/LayoutSVGRoot.h" |
10 #include "core/paint/BoxPainter.h" | 11 #include "core/paint/BoxPainter.h" |
11 #include "core/paint/LayoutObjectDrawingRecorder.h" | 12 #include "core/paint/LayoutObjectDrawingRecorder.h" |
12 #include "core/paint/ObjectPainter.h" | 13 #include "core/paint/ObjectPainter.h" |
13 #include "core/paint/PaintInfo.h" | 14 #include "core/paint/PaintInfo.h" |
14 #include "core/paint/PaintLayer.h" | 15 #include "core/paint/PaintLayer.h" |
15 #include "core/paint/RoundedInnerRectClipper.h" | 16 #include "core/paint/RoundedInnerRectClipper.h" |
16 #include "wtf/Optional.h" | 17 #include "wtf/Optional.h" |
17 | 18 |
18 namespace blink { | 19 namespace blink { |
19 | 20 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 if (m_layoutReplaced.selectionState() == SelectionNone) | 53 if (m_layoutReplaced.selectionState() == SelectionNone) |
53 return; | 54 return; |
54 | 55 |
55 { | 56 { |
56 Optional<RoundedInnerRectClipper> clipper; | 57 Optional<RoundedInnerRectClipper> clipper; |
57 bool completelyClippedOut = false; | 58 bool completelyClippedOut = false; |
58 if (m_layoutReplaced.style()->hasBorderRadius()) { | 59 if (m_layoutReplaced.style()->hasBorderRadius()) { |
59 if (borderRect.isEmpty()) { | 60 if (borderRect.isEmpty()) { |
60 completelyClippedOut = true; | 61 completelyClippedOut = true; |
61 } else { | 62 } else { |
62 // Push a clip if we have a border radius, since we want to roun
d the foreground content that gets painted. | 63 if (!m_layoutReplaced.isSVGRoot() || toLayoutSVGRoot(&m_layoutRe
placed)->shouldApplyViewportClip()) { |
63 FloatRoundedRect roundedInnerRect = m_layoutReplaced.style()->ge
tRoundedInnerBorderFor(borderRect, | 64 // Push a clip if we have a border radius, since we want to
round the foreground content that gets painted. |
64 LayoutRectOutsets( | 65 FloatRoundedRect roundedInnerRect = m_layoutReplaced.style()
->getRoundedInnerBorderFor(borderRect, |
65 -(m_layoutReplaced.paddingTop() + m_layoutReplaced.borde
rTop()), | 66 LayoutRectOutsets( |
66 -(m_layoutReplaced.paddingRight() + m_layoutReplaced.bor
derRight()), | 67 -(m_layoutReplaced.paddingTop() + m_layoutReplaced.b
orderTop()), |
67 -(m_layoutReplaced.paddingBottom() + m_layoutReplaced.bo
rderBottom()), | 68 -(m_layoutReplaced.paddingRight() + m_layoutReplaced
.borderRight()), |
68 -(m_layoutReplaced.paddingLeft() + m_layoutReplaced.bord
erLeft())), | 69 -(m_layoutReplaced.paddingBottom() + m_layoutReplace
d.borderBottom()), |
69 true, true); | 70 -(m_layoutReplaced.paddingLeft() + m_layoutReplaced.
borderLeft())), |
| 71 true, true); |
70 | 72 |
71 clipper.emplace(m_layoutReplaced, paintInfo, borderRect, rounded
InnerRect, ApplyToDisplayList); | 73 clipper.emplace(m_layoutReplaced, paintInfo, borderRect, rou
ndedInnerRect, ApplyToDisplayList); |
| 74 } |
72 } | 75 } |
73 } | 76 } |
74 | 77 |
75 if (!completelyClippedOut) { | 78 if (!completelyClippedOut) { |
76 if (paintInfo.phase == PaintPhaseClippingMask) { | 79 if (paintInfo.phase == PaintPhaseClippingMask) { |
77 BoxPainter(m_layoutReplaced).paintClippingMask(paintInfo, adjust
edPaintOffset); | 80 BoxPainter(m_layoutReplaced).paintClippingMask(paintInfo, adjust
edPaintOffset); |
78 } else { | 81 } else { |
79 m_layoutReplaced.paintReplaced(paintInfo, adjustedPaintOffset); | 82 m_layoutReplaced.paintReplaced(paintInfo, adjustedPaintOffset); |
80 } | 83 } |
81 } | 84 } |
82 } | 85 } |
83 | 86 |
84 // The selection tint never gets clipped by border-radius rounding, since we
want it to run right up to the edges of | 87 // The selection tint never gets clipped by border-radius rounding, since we
want it to run right up to the edges of |
85 // surrounding content. | 88 // surrounding content. |
86 bool drawSelectionTint = paintInfo.phase == PaintPhaseForeground && m_layout
Replaced.selectionState() != SelectionNone && !paintInfo.isPrinting(); | 89 bool drawSelectionTint = paintInfo.phase == PaintPhaseForeground && m_layout
Replaced.selectionState() != SelectionNone && !paintInfo.isPrinting(); |
87 if (drawSelectionTint && !LayoutObjectDrawingRecorder::useCachedDrawingIfPos
sible(*paintInfo.context, m_layoutReplaced, DisplayItem::SelectionTint, adjusted
PaintOffset)) { | 90 if (drawSelectionTint && !LayoutObjectDrawingRecorder::useCachedDrawingIfPos
sible(*paintInfo.context, m_layoutReplaced, DisplayItem::SelectionTint, adjusted
PaintOffset)) { |
88 LayoutRect selectionPaintingRect = m_layoutReplaced.localSelectionRect()
; | 91 LayoutRect selectionPaintingRect = m_layoutReplaced.localSelectionRect()
; |
89 selectionPaintingRect.moveBy(adjustedPaintOffset); | 92 selectionPaintingRect.moveBy(adjustedPaintOffset); |
90 IntRect selectionPaintingIntRect = pixelSnappedIntRect(selectionPainting
Rect); | 93 IntRect selectionPaintingIntRect = pixelSnappedIntRect(selectionPainting
Rect); |
91 | 94 |
92 LayoutObjectDrawingRecorder drawingRecorder(*paintInfo.context, m_layout
Replaced, DisplayItem::SelectionTint, selectionPaintingIntRect, adjustedPaintOff
set); | 95 LayoutObjectDrawingRecorder drawingRecorder(*paintInfo.context, m_layout
Replaced, DisplayItem::SelectionTint, selectionPaintingIntRect, adjustedPaintOff
set); |
93 paintInfo.context->fillRect(selectionPaintingIntRect, m_layoutReplaced.s
electionBackgroundColor()); | 96 paintInfo.context->fillRect(selectionPaintingIntRect, m_layoutReplaced.s
electionBackgroundColor()); |
94 } | 97 } |
95 } | 98 } |
96 | 99 |
97 } // namespace blink | 100 } // namespace blink |
OLD | NEW |