Ensure that on Windows 7, relaunching the browser via chrome://restart or changing...
[chromium-blink-merge.git] / cc / test / fake_scrollbar.cc
blob754b6f75997901aad3491a5ef29dc80cdfaa6f4e
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"
10 namespace cc {
12 FakeScrollbar::FakeScrollbar()
13 : paint_(false),
14 has_thumb_(false),
15 is_overlay_(false),
16 thumb_thickness_(10),
17 thumb_length_(5),
18 track_rect_(0, 0, 100, 10),
19 fill_color_(SK_ColorGREEN) {}
21 FakeScrollbar::FakeScrollbar(bool paint, bool has_thumb, bool is_overlay)
22 : paint_(paint),
23 has_thumb_(has_thumb),
24 is_overlay_(is_overlay),
25 thumb_thickness_(10),
26 thumb_length_(5),
27 track_rect_(0, 0, 100, 10),
28 fill_color_(SK_ColorGREEN) {}
30 FakeScrollbar::~FakeScrollbar() {}
32 ScrollbarOrientation FakeScrollbar::Orientation() const {
33 return HORIZONTAL;
36 bool FakeScrollbar::IsLeftSideVerticalScrollbar() const {
37 return false;
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 {
51 return thumb_length_;
54 gfx::Rect FakeScrollbar::TrackRect() const {
55 return track_rect_;
58 void FakeScrollbar::PaintPart(SkCanvas* canvas,
59 ScrollbarPart part,
60 const gfx::Rect& content_rect) {
61 if (!paint_)
62 return;
64 // Fill the scrollbar with a different color each time.
65 fill_color_++;
66 SkPaint paint;
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);
78 } // namespace cc