| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <unordered_map> | 7 #include <unordered_map> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 | 430 |
| 431 // Under-scroll (thumb position should clamp and be unchanged). | 431 // Under-scroll (thumb position should clamp and be unchanged). |
| 432 root_layer->SetScrollOffset(gfx::ScrollOffset(-5, 0)); | 432 root_layer->SetScrollOffset(gfx::ScrollOffset(-5, 0)); |
| 433 | 433 |
| 434 UPDATE_AND_EXTRACT_LAYER_POINTERS(); | 434 UPDATE_AND_EXTRACT_LAYER_POINTERS(); |
| 435 EXPECT_EQ(gfx::Rect(10, 0, 4, 10).ToString(), | 435 EXPECT_EQ(gfx::Rect(10, 0, 4, 10).ToString(), |
| 436 scrollbar_layer_impl->ComputeThumbQuadRect().ToString()); | 436 scrollbar_layer_impl->ComputeThumbQuadRect().ToString()); |
| 437 | 437 |
| 438 // Over-scroll (thumb position should clamp on the far side). | 438 // Over-scroll (thumb position should clamp on the far side). |
| 439 root_layer->SetScrollOffset(gfx::ScrollOffset(85, 0)); | 439 root_layer->SetScrollOffset(gfx::ScrollOffset(85, 0)); |
| 440 layer_tree_host_->UpdateLayers(); |
| 440 | 441 |
| 441 UPDATE_AND_EXTRACT_LAYER_POINTERS(); | 442 UPDATE_AND_EXTRACT_LAYER_POINTERS(); |
| 442 EXPECT_EQ(gfx::Rect(56, 0, 4, 10).ToString(), | 443 EXPECT_EQ(gfx::Rect(56, 0, 4, 10).ToString(), |
| 443 scrollbar_layer_impl->ComputeThumbQuadRect().ToString()); | 444 scrollbar_layer_impl->ComputeThumbQuadRect().ToString()); |
| 444 | 445 |
| 445 // Change thumb thickness and length. | 446 // Change thumb thickness and length. |
| 446 scrollbar_layer->fake_scrollbar()->set_thumb_thickness(4); | 447 scrollbar_layer->fake_scrollbar()->set_thumb_thickness(4); |
| 447 scrollbar_layer->fake_scrollbar()->set_thumb_length(6); | 448 scrollbar_layer->fake_scrollbar()->set_thumb_length(6); |
| 448 | 449 |
| 449 UPDATE_AND_EXTRACT_LAYER_POINTERS(); | 450 UPDATE_AND_EXTRACT_LAYER_POINTERS(); |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 } | 903 } |
| 903 | 904 |
| 904 class ScrollbarLayerTestResourceCreationAndRelease : public ScrollbarLayerTest { | 905 class ScrollbarLayerTestResourceCreationAndRelease : public ScrollbarLayerTest { |
| 905 public: | 906 public: |
| 906 void TestResourceUpload(int num_updates, | 907 void TestResourceUpload(int num_updates, |
| 907 size_t expected_resources, | 908 size_t expected_resources, |
| 908 int expected_created, | 909 int expected_created, |
| 909 int expected_deleted, | 910 int expected_deleted, |
| 910 bool use_solid_color_scrollbar) { | 911 bool use_solid_color_scrollbar) { |
| 911 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, false)); | 912 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, false)); |
| 913 scoped_refptr<Layer> root_clip_layer = Layer::Create(); |
| 912 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 914 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 913 scoped_refptr<Layer> content_layer = Layer::Create(); | 915 scoped_refptr<Layer> content_layer = Layer::Create(); |
| 914 scoped_refptr<Layer> scrollbar_layer; | 916 scoped_refptr<Layer> scrollbar_layer; |
| 915 if (use_solid_color_scrollbar) { | 917 if (use_solid_color_scrollbar) { |
| 916 const int kThumbThickness = 3; | 918 const int kThumbThickness = 3; |
| 917 const int kTrackStart = 0; | 919 const int kTrackStart = 0; |
| 918 const bool kIsLeftSideVerticalScrollbar = false; | 920 const bool kIsLeftSideVerticalScrollbar = false; |
| 919 scrollbar_layer = SolidColorScrollbarLayer::Create( | 921 scrollbar_layer = SolidColorScrollbarLayer::Create( |
| 920 scrollbar->Orientation(), kThumbThickness, kTrackStart, | 922 scrollbar->Orientation(), kThumbThickness, kTrackStart, |
| 921 kIsLeftSideVerticalScrollbar, layer_tree_root->element_id()); | 923 kIsLeftSideVerticalScrollbar, layer_tree_root->element_id()); |
| 922 } else { | 924 } else { |
| 923 scrollbar_layer = PaintedScrollbarLayer::Create( | 925 scrollbar_layer = PaintedScrollbarLayer::Create( |
| 924 std::move(scrollbar), layer_tree_root->element_id()); | 926 std::move(scrollbar), layer_tree_root->element_id()); |
| 925 } | 927 } |
| 926 layer_tree_root->AddChild(content_layer); | 928 layer_tree_root->AddChild(content_layer); |
| 927 layer_tree_root->AddChild(scrollbar_layer); | 929 layer_tree_root->AddChild(scrollbar_layer); |
| 928 | 930 |
| 929 layer_tree_host_->SetRootLayer(layer_tree_root); | 931 layer_tree_host_->SetRootLayer(layer_tree_root); |
| 930 | 932 |
| 931 scrollbar_layer->SetIsDrawable(true); | 933 scrollbar_layer->SetIsDrawable(true); |
| 932 scrollbar_layer->SetBounds(gfx::Size(100, 100)); | 934 scrollbar_layer->SetBounds(gfx::Size(100, 100)); |
| 935 layer_tree_root->SetScrollClipLayerId(root_clip_layer->id()); |
| 933 layer_tree_root->SetScrollOffset(gfx::ScrollOffset(10, 20)); | 936 layer_tree_root->SetScrollOffset(gfx::ScrollOffset(10, 20)); |
| 934 layer_tree_root->SetBounds(gfx::Size(100, 200)); | 937 layer_tree_root->SetBounds(gfx::Size(100, 200)); |
| 935 content_layer->SetBounds(gfx::Size(100, 200)); | 938 content_layer->SetBounds(gfx::Size(100, 200)); |
| 936 scrollbar_layer->set_visible_layer_rect(gfx::Rect(0, 0, 100, 200)); | 939 scrollbar_layer->set_visible_layer_rect(gfx::Rect(0, 0, 100, 200)); |
| 937 | 940 |
| 938 testing::Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 941 testing::Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
| 939 EXPECT_EQ(scrollbar_layer->GetLayerTreeHostForTesting(), | 942 EXPECT_EQ(scrollbar_layer->GetLayerTreeHostForTesting(), |
| 940 layer_tree_host_.get()); | 943 layer_tree_host_.get()); |
| 941 | 944 |
| 942 for (int update_counter = 0; update_counter < num_updates; update_counter++) | 945 for (int update_counter = 0; update_counter < num_updates; update_counter++) |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); | 1273 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); |
| 1271 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); | 1274 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); |
| 1272 | 1275 |
| 1273 // Horizontal Scrollbars. | 1276 // Horizontal Scrollbars. |
| 1274 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); | 1277 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); |
| 1275 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); | 1278 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); |
| 1276 } | 1279 } |
| 1277 | 1280 |
| 1278 } // namespace | 1281 } // namespace |
| 1279 } // namespace cc | 1282 } // namespace cc |
| OLD | NEW |