| 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/ScrollbarPainter.h" | 6 #include "core/paint/ScrollbarPainter.h" |
| 7 | 7 |
| 8 #include "core/layout/LayoutScrollbar.h" | 8 #include "core/layout/LayoutScrollbar.h" |
| 9 #include "core/layout/LayoutScrollbarPart.h" | 9 #include "core/layout/LayoutScrollbarPart.h" |
| 10 #include "core/paint/BlockPainter.h" | 10 #include "core/paint/BlockPainter.h" |
| 11 #include "core/paint/PaintInfo.h" | 11 #include "core/paint/PaintInfo.h" |
| 12 #include "platform/graphics/GraphicsContext.h" | 12 #include "platform/graphics/GraphicsContext.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 void ScrollbarPainter::paintPart(GraphicsContext* graphicsContext, ScrollbarPart
partType, const IntRect& rect) | 16 void ScrollbarPainter::paintPart(GraphicsContext& graphicsContext, ScrollbarPart
partType, const IntRect& rect) |
| 17 { | 17 { |
| 18 const LayoutScrollbarPart* partLayoutObject = m_layoutScrollbar->getPart(par
tType); | 18 const LayoutScrollbarPart* partLayoutObject = m_layoutScrollbar->getPart(par
tType); |
| 19 if (!partLayoutObject) | 19 if (!partLayoutObject) |
| 20 return; | 20 return; |
| 21 paintIntoRect(*partLayoutObject, graphicsContext, m_layoutScrollbar->locatio
n(), LayoutRect(rect)); | 21 paintIntoRect(*partLayoutObject, graphicsContext, m_layoutScrollbar->locatio
n(), LayoutRect(rect)); |
| 22 } | 22 } |
| 23 | 23 |
| 24 void ScrollbarPainter::paintIntoRect(const LayoutScrollbarPart& layoutScrollbarP
art, GraphicsContext* graphicsContext, const LayoutPoint& paintOffset, const Lay
outRect& rect) | 24 void ScrollbarPainter::paintIntoRect(const LayoutScrollbarPart& layoutScrollbarP
art, GraphicsContext& graphicsContext, const LayoutPoint& paintOffset, const Lay
outRect& rect) |
| 25 { | 25 { |
| 26 // Make sure our dimensions match the rect. | 26 // Make sure our dimensions match the rect. |
| 27 // FIXME: Setting these is a bad layering violation! | 27 // FIXME: Setting these is a bad layering violation! |
| 28 const_cast<LayoutScrollbarPart&>(layoutScrollbarPart).setLocation(rect.locat
ion() - toSize(paintOffset)); | 28 const_cast<LayoutScrollbarPart&>(layoutScrollbarPart).setLocation(rect.locat
ion() - toSize(paintOffset)); |
| 29 const_cast<LayoutScrollbarPart&>(layoutScrollbarPart).setWidth(rect.width())
; | 29 const_cast<LayoutScrollbarPart&>(layoutScrollbarPart).setWidth(rect.width())
; |
| 30 const_cast<LayoutScrollbarPart&>(layoutScrollbarPart).setHeight(rect.height(
)); | 30 const_cast<LayoutScrollbarPart&>(layoutScrollbarPart).setHeight(rect.height(
)); |
| 31 | 31 |
| 32 // Now do the paint. | 32 // Now do the paint. |
| 33 PaintInfo paintInfo(graphicsContext, pixelSnappedIntRect(rect), PaintPhaseBl
ockBackground, GlobalPaintNormalPhase, PaintLayerNoFlag); | 33 PaintInfo paintInfo(&graphicsContext, pixelSnappedIntRect(rect), PaintPhaseB
lockBackground, GlobalPaintNormalPhase, PaintLayerNoFlag); |
| 34 BlockPainter blockPainter(layoutScrollbarPart); | 34 BlockPainter blockPainter(layoutScrollbarPart); |
| 35 blockPainter.paint(paintInfo, paintOffset); | 35 blockPainter.paint(paintInfo, paintOffset); |
| 36 paintInfo.phase = PaintPhaseChildBlockBackgrounds; | 36 paintInfo.phase = PaintPhaseChildBlockBackgrounds; |
| 37 blockPainter.paint(paintInfo, paintOffset); | 37 blockPainter.paint(paintInfo, paintOffset); |
| 38 paintInfo.phase = PaintPhaseFloat; | 38 paintInfo.phase = PaintPhaseFloat; |
| 39 blockPainter.paint(paintInfo, paintOffset); | 39 blockPainter.paint(paintInfo, paintOffset); |
| 40 paintInfo.phase = PaintPhaseForeground; | 40 paintInfo.phase = PaintPhaseForeground; |
| 41 blockPainter.paint(paintInfo, paintOffset); | 41 blockPainter.paint(paintInfo, paintOffset); |
| 42 paintInfo.phase = PaintPhaseOutline; | 42 paintInfo.phase = PaintPhaseOutline; |
| 43 blockPainter.paint(paintInfo, paintOffset); | 43 blockPainter.paint(paintInfo, paintOffset); |
| 44 } | 44 } |
| 45 | 45 |
| 46 } // namespace blink | 46 } // namespace blink |
| OLD | NEW |