| 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/ScrollableAreaPainter.h" | 5 #include "core/paint/ScrollableAreaPainter.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutView.h" | 7 #include "core/layout/LayoutView.h" |
| 8 #include "core/page/Page.h" | 8 #include "core/page/Page.h" |
| 9 #include "core/paint/LayoutObjectDrawingRecorder.h" | 9 #include "core/paint/LayoutObjectDrawingRecorder.h" |
| 10 #include "core/paint/ObjectPaintProperties.h" | 10 #include "core/paint/ObjectPaintProperties.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( | 42 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( |
| 43 context, getScrollableArea().box(), DisplayItem::kResizer)) | 43 context, getScrollableArea().box(), DisplayItem::kResizer)) |
| 44 return; | 44 return; |
| 45 | 45 |
| 46 LayoutObjectDrawingRecorder recorder(context, getScrollableArea().box(), | 46 LayoutObjectDrawingRecorder recorder(context, getScrollableArea().box(), |
| 47 DisplayItem::kResizer, absRect); | 47 DisplayItem::kResizer, absRect); |
| 48 | 48 |
| 49 drawPlatformResizerImage(context, absRect); | 49 drawPlatformResizerImage(context, absRect); |
| 50 | 50 |
| 51 // Draw a frame around the resizer (1px grey line) if there are any scrollbars
present. | 51 // Draw a frame around the resizer (1px grey line) if there are any scrollbars |
| 52 // Clipping will exclude the right and bottom edges of this frame. | 52 // present. Clipping will exclude the right and bottom edges of this frame. |
| 53 if (!getScrollableArea().hasOverlayScrollbars() && | 53 if (!getScrollableArea().hasOverlayScrollbars() && |
| 54 getScrollableArea().hasScrollbar()) { | 54 getScrollableArea().hasScrollbar()) { |
| 55 GraphicsContextStateSaver stateSaver(context); | 55 GraphicsContextStateSaver stateSaver(context); |
| 56 context.clip(absRect); | 56 context.clip(absRect); |
| 57 IntRect largerCorner = absRect; | 57 IntRect largerCorner = absRect; |
| 58 largerCorner.setSize( | 58 largerCorner.setSize( |
| 59 IntSize(largerCorner.width() + 1, largerCorner.height() + 1)); | 59 IntSize(largerCorner.width() + 1, largerCorner.height() + 1)); |
| 60 context.setStrokeColor(Color(217, 217, 217)); | 60 context.setStrokeColor(Color(217, 217, 217)); |
| 61 context.setStrokeThickness(1.0f); | 61 context.setStrokeThickness(1.0f); |
| 62 context.setFillColor(Color::transparent); | 62 context.setFillColor(Color::transparent); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // Don't do anything if we have no overflow. | 111 // Don't do anything if we have no overflow. |
| 112 if (!getScrollableArea().box().hasOverflowClip()) | 112 if (!getScrollableArea().box().hasOverflowClip()) |
| 113 return; | 113 return; |
| 114 | 114 |
| 115 IntPoint adjustedPaintOffset = paintOffset; | 115 IntPoint adjustedPaintOffset = paintOffset; |
| 116 if (paintingOverlayControls) | 116 if (paintingOverlayControls) |
| 117 adjustedPaintOffset = getScrollableArea().cachedOverlayScrollbarOffset(); | 117 adjustedPaintOffset = getScrollableArea().cachedOverlayScrollbarOffset(); |
| 118 | 118 |
| 119 CullRect adjustedCullRect(cullRect, -adjustedPaintOffset); | 119 CullRect adjustedCullRect(cullRect, -adjustedPaintOffset); |
| 120 | 120 |
| 121 // Overlay scrollbars paint in a second pass through the layer tree so that th
ey will paint | 121 // Overlay scrollbars paint in a second pass through the layer tree so that |
| 122 // on top of everything else. If this is the normal painting pass, paintingOve
rlayControls | 122 // they will paint on top of everything else. If this is the normal painting |
| 123 // will be false, and we should just tell the root layer that there are overla
y scrollbars | 123 // pass, paintingOverlayControls will be false, and we should just tell the |
| 124 // that need to be painted. That will cause the second pass through the layer
tree to run, | 124 // root layer that there are overlay scrollbars that need to be painted. That |
| 125 // and we'll paint the scrollbars then. In the meantime, cache tx and ty so th
at the | 125 // will cause the second pass through the layer tree to run, and we'll paint |
| 126 // second pass doesn't need to re-enter the LayoutTree to get it right. | 126 // the scrollbars then. In the meantime, cache tx and ty so that the second |
| 127 // pass doesn't need to re-enter the LayoutTree to get it right. |
| 127 if (getScrollableArea().hasOverlayScrollbars() && !paintingOverlayControls) { | 128 if (getScrollableArea().hasOverlayScrollbars() && !paintingOverlayControls) { |
| 128 getScrollableArea().setCachedOverlayScrollbarOffset(paintOffset); | 129 getScrollableArea().setCachedOverlayScrollbarOffset(paintOffset); |
| 129 // It's not necessary to do the second pass if the scrollbars paint into lay
ers. | 130 // It's not necessary to do the second pass if the scrollbars paint into |
| 131 // layers. |
| 130 if ((getScrollableArea().horizontalScrollbar() && | 132 if ((getScrollableArea().horizontalScrollbar() && |
| 131 getScrollableArea().layerForHorizontalScrollbar()) || | 133 getScrollableArea().layerForHorizontalScrollbar()) || |
| 132 (getScrollableArea().verticalScrollbar() && | 134 (getScrollableArea().verticalScrollbar() && |
| 133 getScrollableArea().layerForVerticalScrollbar())) | 135 getScrollableArea().layerForVerticalScrollbar())) |
| 134 return; | 136 return; |
| 135 if (!overflowControlsIntersectRect(adjustedCullRect)) | 137 if (!overflowControlsIntersectRect(adjustedCullRect)) |
| 136 return; | 138 return; |
| 137 | 139 |
| 138 LayoutView* layoutView = getScrollableArea().box().view(); | 140 LayoutView* layoutView = getScrollableArea().box().view(); |
| 139 | 141 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 context, *getScrollableArea().verticalScrollbar(), | 182 context, *getScrollableArea().verticalScrollbar(), |
| 181 AffineTransform::translation(adjustedPaintOffset.x(), | 183 AffineTransform::translation(adjustedPaintOffset.x(), |
| 182 adjustedPaintOffset.y())); | 184 adjustedPaintOffset.y())); |
| 183 getScrollableArea().verticalScrollbar()->paint(context, adjustedCullRect); | 185 getScrollableArea().verticalScrollbar()->paint(context, adjustedCullRect); |
| 184 } | 186 } |
| 185 } | 187 } |
| 186 | 188 |
| 187 if (getScrollableArea().layerForScrollCorner()) | 189 if (getScrollableArea().layerForScrollCorner()) |
| 188 return; | 190 return; |
| 189 | 191 |
| 190 // We fill our scroll corner with white if we have a scrollbar that doesn't ru
n all the way up to the | 192 // We fill our scroll corner with white if we have a scrollbar that doesn't |
| 191 // edge of the box. | 193 // run all the way up to the edge of the box. |
| 192 paintScrollCorner(context, adjustedPaintOffset, cullRect); | 194 paintScrollCorner(context, adjustedPaintOffset, cullRect); |
| 193 | 195 |
| 194 // Paint our resizer last, since it sits on top of the scroll corner. | 196 // Paint our resizer last, since it sits on top of the scroll corner. |
| 195 paintResizer(context, adjustedPaintOffset, cullRect); | 197 paintResizer(context, adjustedPaintOffset, cullRect); |
| 196 } | 198 } |
| 197 | 199 |
| 198 bool ScrollableAreaPainter::overflowControlsIntersectRect( | 200 bool ScrollableAreaPainter::overflowControlsIntersectRect( |
| 199 const CullRect& cullRect) const { | 201 const CullRect& cullRect) const { |
| 200 const IntRect borderBox = | 202 const IntRect borderBox = |
| 201 getScrollableArea().box().pixelSnappedBorderBoxRect(); | 203 getScrollableArea().box().pixelSnappedBorderBoxRect(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 LayoutObjectDrawingRecorder recorder(context, getScrollableArea().box(), | 249 LayoutObjectDrawingRecorder recorder(context, getScrollableArea().box(), |
| 248 DisplayItem::kScrollbarCorner, absRect); | 250 DisplayItem::kScrollbarCorner, absRect); |
| 249 context.fillRect(absRect, Color::white); | 251 context.fillRect(absRect, Color::white); |
| 250 } | 252 } |
| 251 | 253 |
| 252 PaintLayerScrollableArea& ScrollableAreaPainter::getScrollableArea() const { | 254 PaintLayerScrollableArea& ScrollableAreaPainter::getScrollableArea() const { |
| 253 return *m_scrollableArea; | 255 return *m_scrollableArea; |
| 254 } | 256 } |
| 255 | 257 |
| 256 } // namespace blink | 258 } // namespace blink |
| OLD | NEW |