| 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 "core/paint/PartPainter.h" | 5 #include "core/paint/PartPainter.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutPart.h" | 7 #include "core/layout/LayoutPart.h" |
| 8 #include "core/paint/BoxPainter.h" | 8 #include "core/paint/BoxPainter.h" |
| 9 #include "core/paint/LayoutObjectDrawingRecorder.h" | 9 #include "core/paint/LayoutObjectDrawingRecorder.h" |
| 10 #include "core/paint/ObjectPainter.h" | 10 #include "core/paint/ObjectPainter.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 BoxPainter(m_layoutPart).paintMask(paintInfo, adjustedPaintOffset); | 62 BoxPainter(m_layoutPart).paintMask(paintInfo, adjustedPaintOffset); |
| 63 return; | 63 return; |
| 64 } | 64 } |
| 65 | 65 |
| 66 if (shouldPaintSelfOutline(paintInfo.phase)) | 66 if (shouldPaintSelfOutline(paintInfo.phase)) |
| 67 ObjectPainter(m_layoutPart).paintOutline(paintInfo, adjustedPaintOffset); | 67 ObjectPainter(m_layoutPart).paintOutline(paintInfo, adjustedPaintOffset); |
| 68 | 68 |
| 69 if (paintInfo.phase != PaintPhaseForeground) | 69 if (paintInfo.phase != PaintPhaseForeground) |
| 70 return; | 70 return; |
| 71 | 71 |
| 72 if (m_layoutPart.widget()) { | 72 if (m_layoutPart.frameViewBase()) { |
| 73 // TODO(schenney) crbug.com/93805 Speculative release assert to verify that | 73 // TODO(schenney) crbug.com/93805 Speculative release assert to verify that |
| 74 // the crashes we see in widget painting are due to a destroyed LayoutPart | 74 // the crashes we see in FrameViewBase painting are due to a destroyed |
| 75 // object. | 75 // LayoutPart object. |
| 76 CHECK(m_layoutPart.node()); | 76 CHECK(m_layoutPart.node()); |
| 77 Optional<RoundedInnerRectClipper> clipper; | 77 Optional<RoundedInnerRectClipper> clipper; |
| 78 if (m_layoutPart.style()->hasBorderRadius()) { | 78 if (m_layoutPart.style()->hasBorderRadius()) { |
| 79 if (borderRect.isEmpty()) | 79 if (borderRect.isEmpty()) |
| 80 return; | 80 return; |
| 81 | 81 |
| 82 FloatRoundedRect roundedInnerRect = | 82 FloatRoundedRect roundedInnerRect = |
| 83 m_layoutPart.style()->getRoundedInnerBorderFor( | 83 m_layoutPart.style()->getRoundedInnerBorderFor( |
| 84 borderRect, | 84 borderRect, |
| 85 LayoutRectOutsets( | 85 LayoutRectOutsets( |
| 86 -(m_layoutPart.paddingTop() + m_layoutPart.borderTop()), | 86 -(m_layoutPart.paddingTop() + m_layoutPart.borderTop()), |
| 87 -(m_layoutPart.paddingRight() + m_layoutPart.borderRight()), | 87 -(m_layoutPart.paddingRight() + m_layoutPart.borderRight()), |
| 88 -(m_layoutPart.paddingBottom() + m_layoutPart.borderBottom()), | 88 -(m_layoutPart.paddingBottom() + m_layoutPart.borderBottom()), |
| 89 -(m_layoutPart.paddingLeft() + m_layoutPart.borderLeft())), | 89 -(m_layoutPart.paddingLeft() + m_layoutPart.borderLeft())), |
| 90 true, true); | 90 true, true); |
| 91 clipper.emplace(m_layoutPart, paintInfo, borderRect, roundedInnerRect, | 91 clipper.emplace(m_layoutPart, paintInfo, borderRect, roundedInnerRect, |
| 92 ApplyToDisplayList); | 92 ApplyToDisplayList); |
| 93 } | 93 } |
| 94 | 94 |
| 95 m_layoutPart.paintContents(paintInfo, paintOffset); | 95 m_layoutPart.paintContents(paintInfo, paintOffset); |
| 96 } | 96 } |
| 97 | 97 |
| 98 // Paint a partially transparent wash over selected widgets. | 98 // Paint a partially transparent wash over selected FrameViewBases. |
| 99 if (isSelected() && !paintInfo.isPrinting() && | 99 if (isSelected() && !paintInfo.isPrinting() && |
| 100 !LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( | 100 !LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( |
| 101 paintInfo.context, m_layoutPart, paintInfo.phase)) { | 101 paintInfo.context, m_layoutPart, paintInfo.phase)) { |
| 102 LayoutRect rect = m_layoutPart.localSelectionRect(); | 102 LayoutRect rect = m_layoutPart.localSelectionRect(); |
| 103 rect.moveBy(adjustedPaintOffset); | 103 rect.moveBy(adjustedPaintOffset); |
| 104 IntRect selectionRect = pixelSnappedIntRect(rect); | 104 IntRect selectionRect = pixelSnappedIntRect(rect); |
| 105 LayoutObjectDrawingRecorder drawingRecorder(paintInfo.context, m_layoutPart, | 105 LayoutObjectDrawingRecorder drawingRecorder(paintInfo.context, m_layoutPart, |
| 106 paintInfo.phase, selectionRect); | 106 paintInfo.phase, selectionRect); |
| 107 paintInfo.context.fillRect(selectionRect, | 107 paintInfo.context.fillRect(selectionRect, |
| 108 m_layoutPart.selectionBackgroundColor()); | 108 m_layoutPart.selectionBackgroundColor()); |
| 109 } | 109 } |
| 110 | 110 |
| 111 if (m_layoutPart.canResize()) | 111 if (m_layoutPart.canResize()) |
| 112 ScrollableAreaPainter(*m_layoutPart.layer()->getScrollableArea()) | 112 ScrollableAreaPainter(*m_layoutPart.layer()->getScrollableArea()) |
| 113 .paintResizer(paintInfo.context, roundedIntPoint(adjustedPaintOffset), | 113 .paintResizer(paintInfo.context, roundedIntPoint(adjustedPaintOffset), |
| 114 paintInfo.cullRect()); | 114 paintInfo.cullRect()); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void PartPainter::paintContents(const PaintInfo& paintInfo, | 117 void PartPainter::paintContents(const PaintInfo& paintInfo, |
| 118 const LayoutPoint& paintOffset) { | 118 const LayoutPoint& paintOffset) { |
| 119 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutPart.location(); | 119 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutPart.location(); |
| 120 | 120 |
| 121 FrameViewBase* frameViewBase = m_layoutPart.widget(); | 121 FrameViewBase* frameViewBase = m_layoutPart.frameViewBase(); |
| 122 CHECK(frameViewBase); | 122 CHECK(frameViewBase); |
| 123 | 123 |
| 124 IntPoint paintLocation(roundedIntPoint( | 124 IntPoint paintLocation(roundedIntPoint( |
| 125 adjustedPaintOffset + m_layoutPart.replacedContentRect().location())); | 125 adjustedPaintOffset + m_layoutPart.replacedContentRect().location())); |
| 126 | 126 |
| 127 // FrameViewBases don't support painting with a paint offset, but instead | 127 // FrameViewBases don't support painting with a paint offset, but instead |
| 128 // offset themselves using the frame rect location. To paint widgets at our | 128 // offset themselves using the frame rect location. To paint FrameViewBases at |
| 129 // desired location, we need to apply paint offset as a transform, with the | 129 // our desired location, we need to apply paint offset as a transform, with |
| 130 // frame rect neutralized. | 130 // the frame rect neutralized. |
| 131 IntSize widgetPaintOffset = | 131 IntSize frameViewBasePaintOffset = |
| 132 paintLocation - frameViewBase->frameRect().location(); | 132 paintLocation - frameViewBase->frameRect().location(); |
| 133 TransformRecorder transform( | 133 TransformRecorder transform( |
| 134 paintInfo.context, m_layoutPart, | 134 paintInfo.context, m_layoutPart, |
| 135 AffineTransform::translation(widgetPaintOffset.width(), | 135 AffineTransform::translation(frameViewBasePaintOffset.width(), |
| 136 widgetPaintOffset.height())); | 136 frameViewBasePaintOffset.height())); |
| 137 CullRect adjustedCullRect(paintInfo.cullRect(), -widgetPaintOffset); | 137 CullRect adjustedCullRect(paintInfo.cullRect(), -frameViewBasePaintOffset); |
| 138 frameViewBase->paint(paintInfo.context, adjustedCullRect); | 138 frameViewBase->paint(paintInfo.context, adjustedCullRect); |
| 139 } | 139 } |
| 140 | 140 |
| 141 } // namespace blink | 141 } // namespace blink |
| OLD | NEW |