diff options
author | ccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-20 01:15:36 +0000 |
---|---|---|
committer | ccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-20 01:15:36 +0000 |
commit | e22f03fac4fc1b0dd1874a2d8fef69c9220b52c9 (patch) | |
tree | 3093a956cf71e66f1fd81b529dc1f156eedb465f /cc/test | |
parent | 47203f336d91408ee2dfb9e3628ca1c42f8f2228 (diff) | |
download | chromium_src-e22f03fac4fc1b0dd1874a2d8fef69c9220b52c9.zip chromium_src-e22f03fac4fc1b0dd1874a2d8fef69c9220b52c9.tar.gz chromium_src-e22f03fac4fc1b0dd1874a2d8fef69c9220b52c9.tar.bz2 |
Correct computation of scrollbar track start
The track_start_ value should be the difference between where the track
starts and where the scrollbar starts. It was being set to the absolute
position where the track starts.
Add tests for ScrollbarLayerImpl::ComputeThumbQuadRect. Move syncing
geometry into a separate frunction from ScrollbarLayer::Update to
simplify tests.
BUG=271914
Review URL: https://chromiumcodereview.appspot.com/23007012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@218390 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/test')
-rw-r--r-- | cc/test/fake_scrollbar.cc | 12 | ||||
-rw-r--r-- | cc/test/fake_scrollbar.h | 8 | ||||
-rw-r--r-- | cc/test/fake_scrollbar_layer.cc | 19 | ||||
-rw-r--r-- | cc/test/fake_scrollbar_layer.h | 15 |
4 files changed, 39 insertions, 15 deletions
diff --git a/cc/test/fake_scrollbar.cc b/cc/test/fake_scrollbar.cc index e6b4253..67166f6 100644 --- a/cc/test/fake_scrollbar.cc +++ b/cc/test/fake_scrollbar.cc @@ -12,12 +12,18 @@ FakeScrollbar::FakeScrollbar() : paint_(false), has_thumb_(false), is_overlay_(false), + thumb_thickness_(10), + thumb_length_(5), + track_rect_(0, 0, 100, 10), fill_color_(SK_ColorGREEN) {} FakeScrollbar::FakeScrollbar(bool paint, bool has_thumb, bool is_overlay) : paint_(paint), has_thumb_(has_thumb), is_overlay_(is_overlay), + thumb_thickness_(10), + thumb_length_(5), + track_rect_(0, 0, 100, 10), fill_color_(SK_ColorGREEN) {} FakeScrollbar::~FakeScrollbar() {} @@ -33,15 +39,15 @@ bool FakeScrollbar::IsOverlay() const { return is_overlay_; } bool FakeScrollbar::HasThumb() const { return has_thumb_; } int FakeScrollbar::ThumbThickness() const { - return 10; + return thumb_thickness_; } int FakeScrollbar::ThumbLength() const { - return 10; + return thumb_length_; } gfx::Rect FakeScrollbar::TrackRect() const { - return gfx::Rect(0, 0, 100, 10); + return track_rect_; } void FakeScrollbar::PaintPart(SkCanvas* canvas, diff --git a/cc/test/fake_scrollbar.h b/cc/test/fake_scrollbar.h index b9ac409..0f068b0 100644 --- a/cc/test/fake_scrollbar.h +++ b/cc/test/fake_scrollbar.h @@ -30,12 +30,20 @@ class FakeScrollbar : public Scrollbar { gfx::Rect content_rect) OVERRIDE; void set_location(gfx::Point location) { location_ = location; } + void set_track_rect(gfx::Rect track_rect) { track_rect_ = track_rect; } + void set_thumb_thickness(int thumb_thickness) { + thumb_thickness_ = thumb_thickness; + } + void set_thumb_length(int thumb_length) { thumb_length_ = thumb_length; } private: bool paint_; bool has_thumb_; bool is_overlay_; + int thumb_thickness_; + int thumb_length_; gfx::Point location_; + gfx::Rect track_rect_; SkColor fill_color_; DISALLOW_COPY_AND_ASSIGN(FakeScrollbar); diff --git a/cc/test/fake_scrollbar_layer.cc b/cc/test/fake_scrollbar_layer.cc index 77cf826..d588cf5 100644 --- a/cc/test/fake_scrollbar_layer.cc +++ b/cc/test/fake_scrollbar_layer.cc @@ -10,15 +10,24 @@ namespace cc { -FakeScrollbarLayer::FakeScrollbarLayer(bool paint_during_update, - bool has_thumb, +scoped_refptr<FakeScrollbarLayer> FakeScrollbarLayer::Create( + bool paint_during_update, + bool has_thumb, + int scrolling_layer_id) { + FakeScrollbar* fake_scrollbar = new FakeScrollbar( + paint_during_update, has_thumb, false); + return make_scoped_refptr(new FakeScrollbarLayer( + fake_scrollbar, scrolling_layer_id)); +} + +FakeScrollbarLayer::FakeScrollbarLayer(FakeScrollbar* fake_scrollbar, int scrolling_layer_id) : ScrollbarLayer( - scoped_ptr<Scrollbar>( - new FakeScrollbar(paint_during_update, has_thumb, false)).Pass(), + scoped_ptr<Scrollbar>(fake_scrollbar).Pass(), scrolling_layer_id), update_count_(0), - push_properties_count_(0) { + push_properties_count_(0), + fake_scrollbar_(fake_scrollbar) { SetAnchorPoint(gfx::PointF(0.f, 0.f)); SetBounds(gfx::Size(1, 1)); SetIsDrawable(true); diff --git a/cc/test/fake_scrollbar_layer.h b/cc/test/fake_scrollbar_layer.h index 21d0399..775681d 100644 --- a/cc/test/fake_scrollbar_layer.h +++ b/cc/test/fake_scrollbar_layer.h @@ -7,6 +7,7 @@ #include "base/memory/scoped_ptr.h" #include "cc/layers/scrollbar_layer.h" +#include "cc/test/fake_scrollbar.h" namespace base { template<typename T> class AutoReset; } @@ -16,11 +17,7 @@ class FakeScrollbarLayer : public ScrollbarLayer { public: static scoped_refptr<FakeScrollbarLayer> Create(bool paint_during_update, bool has_thumb, - int scrolling_layer_id) { - return make_scoped_refptr(new FakeScrollbarLayer( - paint_during_update, has_thumb, scrolling_layer_id)); - } - + int scrolling_layer_id); int update_count() const { return update_count_; } void reset_update_count() { update_count_ = 0; } @@ -41,15 +38,19 @@ class FakeScrollbarLayer : public ScrollbarLayer { UIResourceId thumb_resource_id() { return ScrollbarLayer::thumb_resource_id(); } + FakeScrollbar* fake_scrollbar() { + return fake_scrollbar_; + } + using ScrollbarLayer::UpdateThumbAndTrackGeometry; private: - FakeScrollbarLayer(bool paint_during_update, - bool has_thumb, + FakeScrollbarLayer(FakeScrollbar* fake_scrollbar, int scrolling_layer_id); virtual ~FakeScrollbarLayer(); int update_count_; size_t push_properties_count_; + FakeScrollbar* fake_scrollbar_; }; } // namespace cc |