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/ObjectPainter.h" |
9 #include "core/rendering/GraphicsContextAnnotator.h" | 10 #include "core/rendering/GraphicsContextAnnotator.h" |
10 #include "core/rendering/PaintInfo.h" | 11 #include "core/rendering/PaintInfo.h" |
11 #include "core/rendering/RenderLayer.h" | 12 #include "core/rendering/RenderLayer.h" |
12 #include "core/rendering/RenderReplaced.h" | 13 #include "core/rendering/RenderReplaced.h" |
13 | 14 |
14 namespace blink { | 15 namespace blink { |
15 | 16 |
16 void ReplacedPainter::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset
) | 17 void ReplacedPainter::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset
) |
17 { | 18 { |
18 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, &m_renderReplaced); | 19 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, &m_renderReplaced); |
19 | 20 |
20 if (!m_renderReplaced.shouldPaint(paintInfo, paintOffset)) | 21 if (!m_renderReplaced.shouldPaint(paintInfo, paintOffset)) |
21 return; | 22 return; |
22 | 23 |
23 LayoutPoint adjustedPaintOffset = paintOffset + m_renderReplaced.location(); | 24 LayoutPoint adjustedPaintOffset = paintOffset + m_renderReplaced.location(); |
24 | 25 |
25 if (m_renderReplaced.hasBoxDecorationBackground() && (paintInfo.phase == Pai
ntPhaseForeground || paintInfo.phase == PaintPhaseSelection)) | 26 if (m_renderReplaced.hasBoxDecorationBackground() && (paintInfo.phase == Pai
ntPhaseForeground || paintInfo.phase == PaintPhaseSelection)) |
26 m_renderReplaced.paintBoxDecorationBackground(paintInfo, adjustedPaintOf
fset); | 27 m_renderReplaced.paintBoxDecorationBackground(paintInfo, adjustedPaintOf
fset); |
27 | 28 |
28 if (paintInfo.phase == PaintPhaseMask) { | 29 if (paintInfo.phase == PaintPhaseMask) { |
29 m_renderReplaced.paintMask(paintInfo, adjustedPaintOffset); | 30 m_renderReplaced.paintMask(paintInfo, adjustedPaintOffset); |
30 return; | 31 return; |
31 } | 32 } |
32 | 33 |
33 if (paintInfo.phase == PaintPhaseClippingMask && (!m_renderReplaced.hasLayer
() || !m_renderReplaced.layer()->hasCompositedClippingMask())) | 34 if (paintInfo.phase == PaintPhaseClippingMask && (!m_renderReplaced.hasLayer
() || !m_renderReplaced.layer()->hasCompositedClippingMask())) |
34 return; | 35 return; |
35 | 36 |
36 LayoutRect paintRect = LayoutRect(adjustedPaintOffset, m_renderReplaced.size
()); | 37 LayoutRect paintRect = LayoutRect(adjustedPaintOffset, m_renderReplaced.size
()); |
37 if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSe
lfOutline) && m_renderReplaced.style()->outlineWidth()) | 38 if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSe
lfOutline) && m_renderReplaced.style()->outlineWidth()) |
38 m_renderReplaced.paintOutline(paintInfo, paintRect); | 39 ObjectPainter(m_renderReplaced).paintOutline(paintInfo, paintRect); |
39 | 40 |
40 if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhase
Selection && !m_renderReplaced.canHaveChildren() && paintInfo.phase != PaintPhas
eClippingMask) | 41 if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhase
Selection && !m_renderReplaced.canHaveChildren() && paintInfo.phase != PaintPhas
eClippingMask) |
41 return; | 42 return; |
42 | 43 |
43 if (!paintInfo.shouldPaintWithinRoot(&m_renderReplaced)) | 44 if (!paintInfo.shouldPaintWithinRoot(&m_renderReplaced)) |
44 return; | 45 return; |
45 | 46 |
46 bool drawSelectionTint = m_renderReplaced.selectionState() != RenderObject::
SelectionNone && !m_renderReplaced.document().printing(); | 47 bool drawSelectionTint = m_renderReplaced.selectionState() != RenderObject::
SelectionNone && !m_renderReplaced.document().printing(); |
47 if (paintInfo.phase == PaintPhaseSelection) { | 48 if (paintInfo.phase == PaintPhaseSelection) { |
48 if (m_renderReplaced.selectionState() == RenderObject::SelectionNone) | 49 if (m_renderReplaced.selectionState() == RenderObject::SelectionNone) |
(...skipping 30 matching lines...) Expand all Loading... |
79 // The selection tint never gets clipped by border-radius rounding, since we
want it to run right up to the edges of | 80 // The selection tint never gets clipped by border-radius rounding, since we
want it to run right up to the edges of |
80 // surrounding content. | 81 // surrounding content. |
81 if (drawSelectionTint) { | 82 if (drawSelectionTint) { |
82 LayoutRect selectionPaintingRect = m_renderReplaced.localSelectionRect()
; | 83 LayoutRect selectionPaintingRect = m_renderReplaced.localSelectionRect()
; |
83 selectionPaintingRect.moveBy(adjustedPaintOffset); | 84 selectionPaintingRect.moveBy(adjustedPaintOffset); |
84 paintInfo.context->fillRect(pixelSnappedIntRect(selectionPaintingRect),
m_renderReplaced.selectionBackgroundColor()); | 85 paintInfo.context->fillRect(pixelSnappedIntRect(selectionPaintingRect),
m_renderReplaced.selectionBackgroundColor()); |
85 } | 86 } |
86 } | 87 } |
87 | 88 |
88 } // namespace blink | 89 } // namespace blink |
OLD | NEW |