| 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/paint/BoxPainter.h" | 9 #include "core/paint/BoxPainter.h" |
| 10 #include "core/paint/DeprecatedPaintLayer.h" | 10 #include "core/paint/DeprecatedPaintLayer.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 return; | 49 return; |
| 50 | 50 |
| 51 if (!paintInfo.shouldPaintWithinRoot(&m_layoutReplaced)) | 51 if (!paintInfo.shouldPaintWithinRoot(&m_layoutReplaced)) |
| 52 return; | 52 return; |
| 53 | 53 |
| 54 if (paintInfo.phase == PaintPhaseSelection) | 54 if (paintInfo.phase == PaintPhaseSelection) |
| 55 if (m_layoutReplaced.selectionState() == LayoutObject::SelectionNone) | 55 if (m_layoutReplaced.selectionState() == LayoutObject::SelectionNone) |
| 56 return; | 56 return; |
| 57 | 57 |
| 58 { | 58 { |
| 59 OwnPtr<RoundedInnerRectClipper> clipper; | 59 RoundedInnerRectClipper clipper(m_layoutReplaced, paintInfo); |
| 60 bool completelyClippedOut = false; | 60 bool completelyClippedOut = false; |
| 61 if (m_layoutReplaced.style()->hasBorderRadius()) { | 61 if (m_layoutReplaced.style()->hasBorderRadius()) { |
| 62 LayoutRect borderRect = LayoutRect(adjustedPaintOffset, m_layoutRepl
aced.size()); | 62 LayoutRect borderRect = LayoutRect(adjustedPaintOffset, m_layoutRepl
aced.size()); |
| 63 | 63 |
| 64 if (borderRect.isEmpty()) { | 64 if (borderRect.isEmpty()) { |
| 65 completelyClippedOut = true; | 65 completelyClippedOut = true; |
| 66 } else { | 66 } else { |
| 67 // Push a clip if we have a border radius, since we want to roun
d the foreground content that gets painted. | 67 // 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, | 68 FloatRoundedRect roundedInnerRect = m_layoutReplaced.style()->ge
tRoundedInnerBorderFor(paintRect, |
| 69 LayoutRectOutsets( | 69 LayoutRectOutsets( |
| 70 -(m_layoutReplaced.paddingTop() + m_layoutReplaced.borde
rTop()), | 70 -(m_layoutReplaced.paddingTop() + m_layoutReplaced.borde
rTop()), |
| 71 -(m_layoutReplaced.paddingRight() + m_layoutReplaced.bor
derRight()), | 71 -(m_layoutReplaced.paddingRight() + m_layoutReplaced.bor
derRight()), |
| 72 -(m_layoutReplaced.paddingBottom() + m_layoutReplaced.bo
rderBottom()), | 72 -(m_layoutReplaced.paddingBottom() + m_layoutReplaced.bo
rderBottom()), |
| 73 -(m_layoutReplaced.paddingLeft() + m_layoutReplaced.bord
erLeft())), | 73 -(m_layoutReplaced.paddingLeft() + m_layoutReplaced.bord
erLeft())), |
| 74 true, true); | 74 true, true); |
| 75 | 75 |
| 76 clipper = adoptPtr(new RoundedInnerRectClipper(m_layoutReplaced,
paintInfo, paintRect, roundedInnerRect, ApplyToDisplayListIfEnabled)); | 76 clipper.begin(paintRect, roundedInnerRect, ApplyToDisplayListIfE
nabled); |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 if (!completelyClippedOut) { | 80 if (!completelyClippedOut) { |
| 81 if (paintInfo.phase == PaintPhaseClippingMask) { | 81 if (paintInfo.phase == PaintPhaseClippingMask) { |
| 82 BoxPainter(m_layoutReplaced).paintClippingMask(paintInfo, adjust
edPaintOffset); | 82 BoxPainter(m_layoutReplaced).paintClippingMask(paintInfo, adjust
edPaintOffset); |
| 83 } else { | 83 } else { |
| 84 m_layoutReplaced.paintReplaced(paintInfo, adjustedPaintOffset); | 84 m_layoutReplaced.paintReplaced(paintInfo, adjustedPaintOffset); |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 | 88 |
| 89 // The selection tint never gets clipped by border-radius rounding, since we
want it to run right up to the edges of | 89 // 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. | 90 // surrounding content. |
| 91 bool drawSelectionTint = paintInfo.phase == PaintPhaseForeground && m_layout
Replaced.selectionState() != LayoutObject::SelectionNone && !m_layoutReplaced.do
cument().printing(); | 91 bool drawSelectionTint = paintInfo.phase == PaintPhaseForeground && m_layout
Replaced.selectionState() != LayoutObject::SelectionNone && !m_layoutReplaced.do
cument().printing(); |
| 92 if (drawSelectionTint) { | 92 if (drawSelectionTint) { |
| 93 LayoutRect selectionPaintingRect = m_layoutReplaced.localSelectionRect()
; | 93 LayoutRect selectionPaintingRect = m_layoutReplaced.localSelectionRect()
; |
| 94 selectionPaintingRect.moveBy(adjustedPaintOffset); | 94 selectionPaintingRect.moveBy(adjustedPaintOffset); |
| 95 IntRect selectionPaintingIntRect = pixelSnappedIntRect(selectionPainting
Rect); | 95 IntRect selectionPaintingIntRect = pixelSnappedIntRect(selectionPainting
Rect); |
| 96 | 96 |
| 97 LayoutObjectDrawingRecorder drawingRecorder(*paintInfo.context, m_layout
Replaced, DisplayItem::SelectionTint, selectionPaintingIntRect); | 97 LayoutObjectDrawingRecorder drawingRecorder(*paintInfo.context, m_layout
Replaced, DisplayItem::SelectionTint, selectionPaintingIntRect); |
| 98 if (drawingRecorder.canUseCachedDrawing()) | 98 if (drawingRecorder.canUseCachedDrawing()) |
| 99 return; | 99 return; |
| 100 paintInfo.context->fillRect(selectionPaintingIntRect, m_layoutReplaced.s
electionBackgroundColor()); | 100 paintInfo.context->fillRect(selectionPaintingIntRect, m_layoutReplaced.s
electionBackgroundColor()); |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 | 103 |
| 104 } // namespace blink | 104 } // namespace blink |
| OLD | NEW |