summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsataya.m <sataya.m@samsung.com>2014-09-03 16:34:20 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-03 23:37:01 +0000
commitba7e0499e10b1c65ead54148a7582e0c60be6c6d (patch)
treeb66c378fcb5dcabb38223f6f8a24d97afd4f38dc
parent2c7c3113b8bf80e0e05da360ee2654055868b148 (diff)
downloadchromium_src-ba7e0499e10b1c65ead54148a7582e0c60be6c6d.zip
chromium_src-ba7e0499e10b1c65ead54148a7582e0c60be6c6d.tar.gz
chromium_src-ba7e0499e10b1c65ead54148a7582e0c60be6c6d.tar.bz2
Scrollbar ThumbLength is not updated, when window size is changed.
When a pop-up is opened the window size is 367 and content size is 451 and scrollbar of thumblength 202 is created. Pop-Window height has been resized to 451 because of JS . Before resizing of Pop-Window scrollbar thumb_length of 202 is been applied. After resizing Pop-Window vertical scrollbar is disabled during UpdateScrollbarGeometry(has_thumb_ = false). Now When PaintedScrollbarLayer::UpdateThumbAndTrackGeometry is called after pop-up window resize, as has_thumb_ = false , UpdateProperty on thumb_length_ is not applied, due to which we are seeing the unwanted scrollbar BUG=400136 Review URL: https://codereview.chromium.org/524373003 Cr-Commit-Position: refs/heads/master@{#293218}
-rw-r--r--cc/layers/painted_scrollbar_layer.cc3
-rw-r--r--cc/layers/scrollbar_layer_unittest.cc44
-rw-r--r--cc/test/fake_scrollbar.h1
3 files changed, 48 insertions, 0 deletions
diff --git a/cc/layers/painted_scrollbar_layer.cc b/cc/layers/painted_scrollbar_layer.cc
index c0b2a72..7062bc1 100644
--- a/cc/layers/painted_scrollbar_layer.cc
+++ b/cc/layers/painted_scrollbar_layer.cc
@@ -192,6 +192,9 @@ void PaintedScrollbarLayer::UpdateThumbAndTrackGeometry() {
if (has_thumb_) {
UpdateProperty(scrollbar_->ThumbThickness(), &thumb_thickness_);
UpdateProperty(scrollbar_->ThumbLength(), &thumb_length_);
+ } else {
+ UpdateProperty(0, &thumb_thickness_);
+ UpdateProperty(0, &thumb_length_);
}
}
diff --git a/cc/layers/scrollbar_layer_unittest.cc b/cc/layers/scrollbar_layer_unittest.cc
index bcec55a..4c5e5b4 100644
--- a/cc/layers/scrollbar_layer_unittest.cc
+++ b/cc/layers/scrollbar_layer_unittest.cc
@@ -192,6 +192,50 @@ TEST(PaintedScrollbarLayerTest, ScrollOffsetSynchronization) {
scrollbar_layer_impl->ScrollbarParametersDidChange(); \
} while (false)
+TEST(ScrollbarLayerTest, UpdatePropertiesOfScrollBarWhenThumbRemoved) {
+ scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create();
+ scoped_refptr<Layer> root_clip_layer = Layer::Create();
+ scoped_refptr<Layer> root_layer = Layer::Create();
+ scoped_refptr<Layer> content_layer = Layer::Create();
+ scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer =
+ FakePaintedScrollbarLayer::Create(false, true, root_layer->id());
+
+ root_layer->SetScrollClipLayerId(root_clip_layer->id());
+ // Give the root-clip a size that will result in MaxScrollOffset = (80, 0).
+ root_clip_layer->SetBounds(gfx::Size(20, 50));
+ root_layer->SetBounds(gfx::Size(100, 50));
+ content_layer->SetBounds(gfx::Size(100, 50));
+
+ host->SetRootLayer(root_clip_layer);
+ root_clip_layer->AddChild(root_layer);
+ root_layer->AddChild(content_layer);
+ root_layer->AddChild(scrollbar_layer);
+
+ root_layer->SetScrollOffset(gfx::Vector2d(0, 0));
+ scrollbar_layer->SetBounds(gfx::Size(70, 10));
+ scrollbar_layer->SetScrollLayer(root_layer->id());
+ scrollbar_layer->SetClipLayer(root_clip_layer->id());
+ scrollbar_layer->fake_scrollbar()->set_location(gfx::Point(20, 10));
+ scrollbar_layer->fake_scrollbar()->set_track_rect(gfx::Rect(30, 10, 50, 10));
+ scrollbar_layer->fake_scrollbar()->set_thumb_thickness(10);
+ scrollbar_layer->fake_scrollbar()->set_thumb_length(4);
+
+ scrollbar_layer->UpdateThumbAndTrackGeometry();
+ LayerImpl* root_clip_layer_impl = NULL;
+ LayerImpl* root_layer_impl = NULL;
+ PaintedScrollbarLayerImpl* scrollbar_layer_impl = NULL;
+
+ UPDATE_AND_EXTRACT_LAYER_POINTERS();
+ EXPECT_EQ(gfx::Rect(10, 0, 4, 10).ToString(),
+ scrollbar_layer_impl->ComputeThumbQuadRect().ToString());
+
+ scrollbar_layer->fake_scrollbar()->set_has_thumb(false);
+
+ UPDATE_AND_EXTRACT_LAYER_POINTERS();
+ EXPECT_EQ(gfx::Rect(10, 0, 0, 0).ToString(),
+ scrollbar_layer_impl->ComputeThumbQuadRect().ToString());
+}
+
TEST(ScrollbarLayerTest, ThumbRect) {
scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create();
scoped_refptr<Layer> root_clip_layer = Layer::Create();
diff --git a/cc/test/fake_scrollbar.h b/cc/test/fake_scrollbar.h
index 872b9d9..8e6d454 100644
--- a/cc/test/fake_scrollbar.h
+++ b/cc/test/fake_scrollbar.h
@@ -36,6 +36,7 @@ class FakeScrollbar : public Scrollbar {
thumb_thickness_ = thumb_thickness;
}
void set_thumb_length(int thumb_length) { thumb_length_ = thumb_length; }
+ void set_has_thumb(bool has_thumb) { has_thumb_ = has_thumb; }
SkColor paint_fill_color() const { return SK_ColorBLACK | fill_color_; }
private: