| 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/ScrollableAreaPainter.h" | 6 #include "core/paint/ScrollableAreaPainter.h" |
| 7 | 7 |
| 8 #include "core/layout/LayoutView.h" | 8 #include "core/layout/LayoutView.h" |
| 9 #include "core/page/Page.h" | 9 #include "core/page/Page.h" |
| 10 #include "core/paint/LayoutObjectDrawingRecorder.h" | 10 #include "core/paint/LayoutObjectDrawingRecorder.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 void ScrollableAreaPainter::paintOverflowControls(GraphicsContext* context, cons
t IntPoint& paintOffset, const CullRect& cullRect, bool paintingOverlayControls) | 88 void ScrollableAreaPainter::paintOverflowControls(GraphicsContext* context, cons
t IntPoint& paintOffset, const CullRect& cullRect, bool paintingOverlayControls) |
| 89 { | 89 { |
| 90 // Don't do anything if we have no overflow. | 90 // Don't do anything if we have no overflow. |
| 91 if (!scrollableArea().box().hasOverflowClip()) | 91 if (!scrollableArea().box().hasOverflowClip()) |
| 92 return; | 92 return; |
| 93 | 93 |
| 94 IntPoint adjustedPaintOffset = paintOffset; | 94 IntPoint adjustedPaintOffset = paintOffset; |
| 95 if (paintingOverlayControls) | 95 if (paintingOverlayControls) |
| 96 adjustedPaintOffset = scrollableArea().cachedOverlayScrollbarOffset(); | 96 adjustedPaintOffset = scrollableArea().cachedOverlayScrollbarOffset(); |
| 97 | 97 |
| 98 IntRect localDamageRect = cullRect.m_rect; | |
| 99 localDamageRect.moveBy(-adjustedPaintOffset); | |
| 100 | |
| 101 CullRect adjustedCullRect(cullRect, -adjustedPaintOffset); | 98 CullRect adjustedCullRect(cullRect, -adjustedPaintOffset); |
| 102 | 99 |
| 103 // Overlay scrollbars paint in a second pass through the layer tree so that
they will paint | 100 // Overlay scrollbars paint in a second pass through the layer tree so that
they will paint |
| 104 // on top of everything else. If this is the normal painting pass, paintingO
verlayControls | 101 // on top of everything else. If this is the normal painting pass, paintingO
verlayControls |
| 105 // will be false, and we should just tell the root layer that there are over
lay scrollbars | 102 // will be false, and we should just tell the root layer that there are over
lay scrollbars |
| 106 // that need to be painted. That will cause the second pass through the laye
r tree to run, | 103 // that need to be painted. That will cause the second pass through the laye
r tree to run, |
| 107 // and we'll paint the scrollbars then. In the meantime, cache tx and ty so
that the | 104 // and we'll paint the scrollbars then. In the meantime, cache tx and ty so
that the |
| 108 // second pass doesn't need to re-enter the LayoutTree to get it right. | 105 // second pass doesn't need to re-enter the LayoutTree to get it right. |
| 109 if (scrollableArea().hasOverlayScrollbars() && !paintingOverlayControls) { | 106 if (scrollableArea().hasOverlayScrollbars() && !paintingOverlayControls) { |
| 110 scrollableArea().setCachedOverlayScrollbarOffset(paintOffset); | 107 scrollableArea().setCachedOverlayScrollbarOffset(paintOffset); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 124 return; | 121 return; |
| 125 } | 122 } |
| 126 | 123 |
| 127 // This check is required to avoid painting custom CSS scrollbars twice. | 124 // This check is required to avoid painting custom CSS scrollbars twice. |
| 128 if (paintingOverlayControls && !scrollableArea().hasOverlayScrollbars()) | 125 if (paintingOverlayControls && !scrollableArea().hasOverlayScrollbars()) |
| 129 return; | 126 return; |
| 130 | 127 |
| 131 { | 128 { |
| 132 if (scrollableArea().horizontalScrollbar() && !scrollableArea().layerFor
HorizontalScrollbar()) { | 129 if (scrollableArea().horizontalScrollbar() && !scrollableArea().layerFor
HorizontalScrollbar()) { |
| 133 TransformRecorder translateRecorder(*context, *scrollableArea().hori
zontalScrollbar(), AffineTransform::translation(adjustedPaintOffset.x(), adjuste
dPaintOffset.y())); | 130 TransformRecorder translateRecorder(*context, *scrollableArea().hori
zontalScrollbar(), AffineTransform::translation(adjustedPaintOffset.x(), adjuste
dPaintOffset.y())); |
| 134 scrollableArea().horizontalScrollbar()->paint(context, localDamageRe
ct); | 131 scrollableArea().horizontalScrollbar()->paint(context, adjustedCullR
ect); |
| 135 } | 132 } |
| 136 if (scrollableArea().verticalScrollbar() && !scrollableArea().layerForVe
rticalScrollbar()) { | 133 if (scrollableArea().verticalScrollbar() && !scrollableArea().layerForVe
rticalScrollbar()) { |
| 137 TransformRecorder translateRecorder(*context, *scrollableArea().vert
icalScrollbar(), AffineTransform::translation(adjustedPaintOffset.x(), adjustedP
aintOffset.y())); | 134 TransformRecorder translateRecorder(*context, *scrollableArea().vert
icalScrollbar(), AffineTransform::translation(adjustedPaintOffset.x(), adjustedP
aintOffset.y())); |
| 138 scrollableArea().verticalScrollbar()->paint(context, localDamageRect
); | 135 scrollableArea().verticalScrollbar()->paint(context, adjustedCullRec
t); |
| 139 } | 136 } |
| 140 } | 137 } |
| 141 | 138 |
| 142 if (scrollableArea().layerForScrollCorner()) | 139 if (scrollableArea().layerForScrollCorner()) |
| 143 return; | 140 return; |
| 144 | 141 |
| 145 // We fill our scroll corner with white if we have a scrollbar that doesn't
run all the way up to the | 142 // We fill our scroll corner with white if we have a scrollbar that doesn't
run all the way up to the |
| 146 // edge of the box. | 143 // edge of the box. |
| 147 paintScrollCorner(context, adjustedPaintOffset, cullRect); | 144 paintScrollCorner(context, adjustedPaintOffset, cullRect); |
| 148 | 145 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 LayoutObjectDrawingRecorder recorder(*context, scrollableArea().box(), Displ
ayItem::ScrollbarCorner, absRect, paintOffset); | 191 LayoutObjectDrawingRecorder recorder(*context, scrollableArea().box(), Displ
ayItem::ScrollbarCorner, absRect, paintOffset); |
| 195 context->fillRect(absRect, Color::white); | 192 context->fillRect(absRect, Color::white); |
| 196 } | 193 } |
| 197 | 194 |
| 198 PaintLayerScrollableArea& ScrollableAreaPainter::scrollableArea() const | 195 PaintLayerScrollableArea& ScrollableAreaPainter::scrollableArea() const |
| 199 { | 196 { |
| 200 return *m_scrollableArea; | 197 return *m_scrollableArea; |
| 201 } | 198 } |
| 202 | 199 |
| 203 } // namespace blink | 200 } // namespace blink |
| OLD | NEW |