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