| 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 |
| 21 static bool shouldApplyViewportClip(const LayoutReplaced& layoutReplaced) |
| 22 { |
| 23 return !layoutReplaced.isSVGRoot() || toLayoutSVGRoot(&layoutReplaced)->shou
ldApplyViewportClip(); |
| 24 } |
| 25 |
| 20 void ReplacedPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paint
Offset) | 26 void ReplacedPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paint
Offset) |
| 21 { | 27 { |
| 22 if (!m_layoutReplaced.shouldPaint(paintInfo, paintOffset)) | 28 if (!m_layoutReplaced.shouldPaint(paintInfo, paintOffset)) |
| 23 return; | 29 return; |
| 24 | 30 |
| 25 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutReplaced.location(); | 31 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutReplaced.location(); |
| 26 LayoutRect borderRect(adjustedPaintOffset, m_layoutReplaced.size()); | 32 LayoutRect borderRect(adjustedPaintOffset, m_layoutReplaced.size()); |
| 27 | 33 |
| 28 if (m_layoutReplaced.hasBoxDecorationBackground() && (paintInfo.phase == Pai
ntPhaseForeground || paintInfo.phase == PaintPhaseSelection)) | 34 if (m_layoutReplaced.hasBoxDecorationBackground() && (paintInfo.phase == Pai
ntPhaseForeground || paintInfo.phase == PaintPhaseSelection)) |
| 29 m_layoutReplaced.paintBoxDecorationBackground(paintInfo, adjustedPaintOf
fset); | 35 m_layoutReplaced.paintBoxDecorationBackground(paintInfo, adjustedPaintOf
fset); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 51 if (paintInfo.phase == PaintPhaseSelection) | 57 if (paintInfo.phase == PaintPhaseSelection) |
| 52 if (m_layoutReplaced.selectionState() == SelectionNone) | 58 if (m_layoutReplaced.selectionState() == SelectionNone) |
| 53 return; | 59 return; |
| 54 | 60 |
| 55 { | 61 { |
| 56 Optional<RoundedInnerRectClipper> clipper; | 62 Optional<RoundedInnerRectClipper> clipper; |
| 57 bool completelyClippedOut = false; | 63 bool completelyClippedOut = false; |
| 58 if (m_layoutReplaced.style()->hasBorderRadius()) { | 64 if (m_layoutReplaced.style()->hasBorderRadius()) { |
| 59 if (borderRect.isEmpty()) { | 65 if (borderRect.isEmpty()) { |
| 60 completelyClippedOut = true; | 66 completelyClippedOut = true; |
| 61 } else { | 67 } else if (shouldApplyViewportClip(m_layoutReplaced)) { |
| 62 // 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. |
| 63 FloatRoundedRect roundedInnerRect = m_layoutReplaced.style()->ge
tRoundedInnerBorderFor(borderRect, | 69 FloatRoundedRect roundedInnerRect = m_layoutReplaced.style()->ge
tRoundedInnerBorderFor(borderRect, |
| 64 LayoutRectOutsets( | 70 LayoutRectOutsets( |
| 65 -(m_layoutReplaced.paddingTop() + m_layoutReplaced.borde
rTop()), | 71 -(m_layoutReplaced.paddingTop() + m_layoutReplaced.borde
rTop()), |
| 66 -(m_layoutReplaced.paddingRight() + m_layoutReplaced.bor
derRight()), | 72 -(m_layoutReplaced.paddingRight() + m_layoutReplaced.bor
derRight()), |
| 67 -(m_layoutReplaced.paddingBottom() + m_layoutReplaced.bo
rderBottom()), | 73 -(m_layoutReplaced.paddingBottom() + m_layoutReplaced.bo
rderBottom()), |
| 68 -(m_layoutReplaced.paddingLeft() + m_layoutReplaced.bord
erLeft())), | 74 -(m_layoutReplaced.paddingLeft() + m_layoutReplaced.bord
erLeft())), |
| 69 true, true); | 75 true, true); |
| 70 | 76 |
| 71 clipper.emplace(m_layoutReplaced, paintInfo, borderRect, rounded
InnerRect, ApplyToDisplayList); | 77 clipper.emplace(m_layoutReplaced, paintInfo, borderRect, rounded
InnerRect, ApplyToDisplayList); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 88 LayoutRect selectionPaintingRect = m_layoutReplaced.localSelectionRect()
; | 94 LayoutRect selectionPaintingRect = m_layoutReplaced.localSelectionRect()
; |
| 89 selectionPaintingRect.moveBy(adjustedPaintOffset); | 95 selectionPaintingRect.moveBy(adjustedPaintOffset); |
| 90 IntRect selectionPaintingIntRect = pixelSnappedIntRect(selectionPainting
Rect); | 96 IntRect selectionPaintingIntRect = pixelSnappedIntRect(selectionPainting
Rect); |
| 91 | 97 |
| 92 LayoutObjectDrawingRecorder drawingRecorder(*paintInfo.context, m_layout
Replaced, DisplayItem::SelectionTint, selectionPaintingIntRect, adjustedPaintOff
set); | 98 LayoutObjectDrawingRecorder drawingRecorder(*paintInfo.context, m_layout
Replaced, DisplayItem::SelectionTint, selectionPaintingIntRect, adjustedPaintOff
set); |
| 93 paintInfo.context->fillRect(selectionPaintingIntRect, m_layoutReplaced.s
electionBackgroundColor()); | 99 paintInfo.context->fillRect(selectionPaintingIntRect, m_layoutReplaced.s
electionBackgroundColor()); |
| 94 } | 100 } |
| 95 } | 101 } |
| 96 | 102 |
| 97 } // namespace blink | 103 } // namespace blink |
| OLD | NEW |