| 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/paint/BoxPainter.h" | 8 #include "core/paint/BoxPainter.h" |
| 9 #include "core/paint/GraphicsContextAnnotator.h" | 9 #include "core/paint/GraphicsContextAnnotator.h" |
| 10 #include "core/paint/ObjectPainter.h" | 10 #include "core/paint/ObjectPainter.h" |
| 11 #include "core/paint/RenderDrawingRecorder.h" | 11 #include "core/paint/RenderDrawingRecorder.h" |
| 12 #include "core/paint/RoundedInnerRectClipper.h" |
| 12 #include "core/rendering/PaintInfo.h" | 13 #include "core/rendering/PaintInfo.h" |
| 13 #include "core/rendering/RenderLayer.h" | 14 #include "core/rendering/RenderLayer.h" |
| 14 #include "core/rendering/RenderReplaced.h" | 15 #include "core/rendering/RenderReplaced.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 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, &m_renderReplaced); | 21 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, &m_renderReplaced); |
| 21 | 22 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 } | 55 } |
| 55 | 56 |
| 56 // FIXME(crbug.com/444591): Refactor this to not create a drawing recorder f
or renderers with children. | 57 // FIXME(crbug.com/444591): Refactor this to not create a drawing recorder f
or renderers with children. |
| 57 OwnPtr<RenderDrawingRecorder> renderDrawingRecorder; | 58 OwnPtr<RenderDrawingRecorder> renderDrawingRecorder; |
| 58 if (!m_renderReplaced.isSVGRoot()) | 59 if (!m_renderReplaced.isSVGRoot()) |
| 59 renderDrawingRecorder = adoptPtr(new RenderDrawingRecorder(paintInfo.con
text, m_renderReplaced, paintInfo.phase, paintRect)); | 60 renderDrawingRecorder = adoptPtr(new RenderDrawingRecorder(paintInfo.con
text, m_renderReplaced, paintInfo.phase, paintRect)); |
| 60 if (renderDrawingRecorder && renderDrawingRecorder->canUseCachedDrawing()) | 61 if (renderDrawingRecorder && renderDrawingRecorder->canUseCachedDrawing()) |
| 61 return; | 62 return; |
| 62 | 63 |
| 63 bool completelyClippedOut = false; | 64 bool completelyClippedOut = false; |
| 65 OwnPtr<RoundedInnerRectClipper> clipper; |
| 64 if (m_renderReplaced.style()->hasBorderRadius()) { | 66 if (m_renderReplaced.style()->hasBorderRadius()) { |
| 65 LayoutRect borderRect = LayoutRect(adjustedPaintOffset, m_renderReplaced
.size()); | 67 LayoutRect borderRect = LayoutRect(adjustedPaintOffset, m_renderReplaced
.size()); |
| 66 | 68 |
| 67 if (borderRect.isEmpty()) { | 69 if (borderRect.isEmpty()) { |
| 68 completelyClippedOut = true; | 70 completelyClippedOut = true; |
| 69 } else { | 71 } else { |
| 70 // Push a clip if we have a border radius, since we want to round th
e foreground content that gets painted. | 72 // Push a clip if we have a border radius, since we want to round th
e foreground content that gets painted. |
| 71 paintInfo.context->save(); | 73 paintInfo.context->save(); |
| 72 FloatRoundedRect roundedInnerRect = m_renderReplaced.style()->getRou
ndedInnerBorderFor(paintRect, | 74 FloatRoundedRect roundedInnerRect = m_renderReplaced.style()->getRou
ndedInnerBorderFor(paintRect, |
| 73 m_renderReplaced.paddingTop() + m_renderReplaced.borderTop(), m_
renderReplaced.paddingBottom() + m_renderReplaced.borderBottom(), m_renderReplac
ed.paddingLeft() + m_renderReplaced.borderLeft(), m_renderReplaced.paddingRight(
) + m_renderReplaced.borderRight(), true, true); | 75 m_renderReplaced.paddingTop() + m_renderReplaced.borderTop(), m_
renderReplaced.paddingBottom() + m_renderReplaced.borderBottom(), m_renderReplac
ed.paddingLeft() + m_renderReplaced.borderLeft(), m_renderReplaced.paddingRight(
) + m_renderReplaced.borderRight(), true, true); |
| 74 BoxPainter::clipRoundedInnerRect(paintInfo.context, paintRect, round
edInnerRect); | 76 |
| 77 clipper = adoptPtr(new RoundedInnerRectClipper(m_renderReplaced, pai
ntInfo, paintRect, roundedInnerRect, ApplyToContext)); |
| 75 } | 78 } |
| 76 } | 79 } |
| 77 | 80 |
| 78 if (!completelyClippedOut) { | 81 if (!completelyClippedOut) { |
| 79 if (paintInfo.phase == PaintPhaseClippingMask) { | 82 if (paintInfo.phase == PaintPhaseClippingMask) { |
| 80 m_renderReplaced.paintClippingMask(paintInfo, adjustedPaintOffset); | 83 m_renderReplaced.paintClippingMask(paintInfo, adjustedPaintOffset); |
| 81 } else { | 84 } else { |
| 82 m_renderReplaced.paintReplaced(paintInfo, adjustedPaintOffset); | 85 m_renderReplaced.paintReplaced(paintInfo, adjustedPaintOffset); |
| 83 } | 86 } |
| 84 | |
| 85 if (m_renderReplaced.style()->hasBorderRadius()) | |
| 86 paintInfo.context->restore(); | |
| 87 } | 87 } |
| 88 clipper.clear(); |
| 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 if (drawSelectionTint) { | 92 if (drawSelectionTint) { |
| 92 LayoutRect selectionPaintingRect = m_renderReplaced.localSelectionRect()
; | 93 LayoutRect selectionPaintingRect = m_renderReplaced.localSelectionRect()
; |
| 93 selectionPaintingRect.moveBy(adjustedPaintOffset); | 94 selectionPaintingRect.moveBy(adjustedPaintOffset); |
| 94 paintInfo.context->fillRect(pixelSnappedIntRect(selectionPaintingRect),
m_renderReplaced.selectionBackgroundColor()); | 95 paintInfo.context->fillRect(pixelSnappedIntRect(selectionPaintingRect),
m_renderReplaced.selectionBackgroundColor()); |
| 95 } | 96 } |
| 96 } | 97 } |
| 97 | 98 |
| 98 } // namespace blink | 99 } // namespace blink |
| OLD | NEW |