1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cc/test/fake_scrollbar.h"
7 #include "third_party/skia/include/core/SkCanvas.h"
8 #include "ui/gfx/skia_util.h"
12 FakeScrollbar::FakeScrollbar()
18 track_rect_(0, 0, 100, 10),
19 fill_color_(SK_ColorGREEN
) {}
21 FakeScrollbar::FakeScrollbar(bool paint
, bool has_thumb
, bool is_overlay
)
23 has_thumb_(has_thumb
),
24 is_overlay_(is_overlay
),
27 track_rect_(0, 0, 100, 10),
28 fill_color_(SK_ColorGREEN
) {}
30 FakeScrollbar::~FakeScrollbar() {}
32 ScrollbarOrientation
FakeScrollbar::Orientation() const {
36 bool FakeScrollbar::IsLeftSideVerticalScrollbar() const {
40 gfx::Point
FakeScrollbar::Location() const { return location_
; }
42 bool FakeScrollbar::IsOverlay() const { return is_overlay_
; }
44 bool FakeScrollbar::HasThumb() const { return has_thumb_
; }
46 int FakeScrollbar::ThumbThickness() const {
47 return thumb_thickness_
;
50 int FakeScrollbar::ThumbLength() const {
54 gfx::Rect
FakeScrollbar::TrackRect() const {
58 void FakeScrollbar::PaintPart(SkCanvas
* canvas
,
60 const gfx::Rect
& content_rect
) {
64 // Fill the scrollbar with a different color each time.
67 paint
.setAntiAlias(false);
68 paint
.setColor(paint_fill_color());
69 paint
.setStyle(SkPaint::kFill_Style
);
71 // Emulate the how the real scrollbar works by using scrollbar's rect for
72 // TRACK and the given content_rect for the THUMB
73 SkRect rect
= part
== TRACK
? RectToSkRect(TrackRect())
74 : RectToSkRect(content_rect
);
75 canvas
->drawRect(rect
, paint
);