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