| 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 gfx::PointF(), InputHandler::TOUCHSCREEN, scroll_tree, scroll_node); | 284 gfx::PointF(), InputHandler::TOUCHSCREEN, scroll_tree, scroll_node); |
| 285 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 285 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
| 286 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable, | 286 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable, |
| 287 status.main_thread_scrolling_reasons); | 287 status.main_thread_scrolling_reasons); |
| 288 } | 288 } |
| 289 | 289 |
| 290 TEST_F(ScrollbarLayerTest, ScrollOffsetSynchronization) { | 290 TEST_F(ScrollbarLayerTest, ScrollOffsetSynchronization) { |
| 291 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar); | 291 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar); |
| 292 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 292 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 293 scoped_refptr<Layer> scroll_layer = Layer::Create(); | 293 scoped_refptr<Layer> scroll_layer = Layer::Create(); |
| 294 scroll_layer->SetElementId(LayerIdToElementIdForTesting(scroll_layer->id())); | 294 scroll_layer->SetElementId(scroll_layer->id()); |
| 295 scoped_refptr<Layer> content_layer = Layer::Create(); | 295 scoped_refptr<Layer> content_layer = Layer::Create(); |
| 296 scoped_refptr<Layer> scrollbar_layer = PaintedScrollbarLayer::Create( | 296 scoped_refptr<Layer> scrollbar_layer = PaintedScrollbarLayer::Create( |
| 297 std::move(scrollbar), scroll_layer->element_id()); | 297 std::move(scrollbar), scroll_layer->element_id()); |
| 298 | 298 |
| 299 // Choose bounds to give max_scroll_offset = (30, 50). | 299 // Choose bounds to give max_scroll_offset = (30, 50). |
| 300 layer_tree_root->SetBounds(gfx::Size(70, 150)); | 300 layer_tree_root->SetBounds(gfx::Size(70, 150)); |
| 301 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); | 301 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); |
| 302 scroll_layer->SetScrollOffset(gfx::ScrollOffset(10, 20)); | 302 scroll_layer->SetScrollOffset(gfx::ScrollOffset(10, 20)); |
| 303 scroll_layer->SetBounds(gfx::Size(100, 200)); | 303 scroll_layer->SetBounds(gfx::Size(100, 200)); |
| 304 content_layer->SetBounds(gfx::Size(100, 200)); | 304 content_layer->SetBounds(gfx::Size(100, 200)); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 scrollbar_layer_impl->ComputeThumbQuadRect().ToString()); | 397 scrollbar_layer_impl->ComputeThumbQuadRect().ToString()); |
| 398 } | 398 } |
| 399 | 399 |
| 400 TEST_F(ScrollbarLayerTest, ThumbRect) { | 400 TEST_F(ScrollbarLayerTest, ThumbRect) { |
| 401 scoped_refptr<Layer> root_clip_layer = Layer::Create(); | 401 scoped_refptr<Layer> root_clip_layer = Layer::Create(); |
| 402 scoped_refptr<Layer> root_layer = Layer::Create(); | 402 scoped_refptr<Layer> root_layer = Layer::Create(); |
| 403 scoped_refptr<Layer> content_layer = Layer::Create(); | 403 scoped_refptr<Layer> content_layer = Layer::Create(); |
| 404 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = | 404 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = |
| 405 FakePaintedScrollbarLayer::Create(false, true, root_layer->element_id()); | 405 FakePaintedScrollbarLayer::Create(false, true, root_layer->element_id()); |
| 406 | 406 |
| 407 root_layer->SetElementId(LayerIdToElementIdForTesting(root_layer->id())); | 407 root_layer->SetElementId(root_layer->id()); |
| 408 root_layer->SetScrollClipLayerId(root_clip_layer->id()); | 408 root_layer->SetScrollClipLayerId(root_clip_layer->id()); |
| 409 // Give the root-clip a size that will result in MaxScrollOffset = (80, 0). | 409 // Give the root-clip a size that will result in MaxScrollOffset = (80, 0). |
| 410 root_clip_layer->SetBounds(gfx::Size(20, 50)); | 410 root_clip_layer->SetBounds(gfx::Size(20, 50)); |
| 411 root_layer->SetBounds(gfx::Size(100, 50)); | 411 root_layer->SetBounds(gfx::Size(100, 50)); |
| 412 content_layer->SetBounds(gfx::Size(100, 50)); | 412 content_layer->SetBounds(gfx::Size(100, 50)); |
| 413 | 413 |
| 414 layer_tree_host_->SetRootLayer(root_clip_layer); | 414 layer_tree_host_->SetRootLayer(root_clip_layer); |
| 415 root_clip_layer->AddChild(root_layer); | 415 root_clip_layer->AddChild(root_layer); |
| 416 root_layer->AddChild(content_layer); | 416 root_layer->AddChild(content_layer); |
| 417 root_layer->AddChild(scrollbar_layer); | 417 root_layer->AddChild(scrollbar_layer); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 | 588 |
| 589 TEST_F(ScrollbarLayerTest, LayerDrivenSolidColorDrawQuads) { | 589 TEST_F(ScrollbarLayerTest, LayerDrivenSolidColorDrawQuads) { |
| 590 const int kThumbThickness = 3; | 590 const int kThumbThickness = 3; |
| 591 const int kTrackStart = 0; | 591 const int kTrackStart = 0; |
| 592 const int kTrackLength = 10; | 592 const int kTrackLength = 10; |
| 593 | 593 |
| 594 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); | 594 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); |
| 595 | 595 |
| 596 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 596 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 597 scoped_refptr<Layer> scroll_layer = Layer::Create(); | 597 scoped_refptr<Layer> scroll_layer = Layer::Create(); |
| 598 scroll_layer->SetElementId(LayerIdToElementIdForTesting(scroll_layer->id())); | 598 scroll_layer->SetElementId(scroll_layer->id()); |
| 599 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); | 599 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); |
| 600 scoped_refptr<Layer> child1 = Layer::Create(); | 600 scoped_refptr<Layer> child1 = Layer::Create(); |
| 601 scoped_refptr<Layer> child2; | 601 scoped_refptr<Layer> child2; |
| 602 const bool kIsLeftSideVerticalScrollbar = false; | 602 const bool kIsLeftSideVerticalScrollbar = false; |
| 603 child2 = SolidColorScrollbarLayer::Create( | 603 child2 = SolidColorScrollbarLayer::Create( |
| 604 scrollbar->Orientation(), kThumbThickness, kTrackStart, | 604 scrollbar->Orientation(), kThumbThickness, kTrackStart, |
| 605 kIsLeftSideVerticalScrollbar, scroll_layer->element_id()); | 605 kIsLeftSideVerticalScrollbar, scroll_layer->element_id()); |
| 606 scroll_layer->AddChild(child1); | 606 scroll_layer->AddChild(child1); |
| 607 scroll_layer->InsertChild(child2, 1); | 607 scroll_layer->InsertChild(child2, 1); |
| 608 layer_tree_root->AddChild(scroll_layer); | 608 layer_tree_root->AddChild(scroll_layer); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 // Pushing changed bounds of scroll layer can lead to calling | 722 // Pushing changed bounds of scroll layer can lead to calling |
| 723 // OnOpacityAnimated on scrollbar layer which means OnOpacityAnimated should | 723 // OnOpacityAnimated on scrollbar layer which means OnOpacityAnimated should |
| 724 // be independent of scrollbar layer's properties as scrollbar layer can push | 724 // be independent of scrollbar layer's properties as scrollbar layer can push |
| 725 // its properties after scroll layer. | 725 // its properties after scroll layer. |
| 726 const int kThumbThickness = 3; | 726 const int kThumbThickness = 3; |
| 727 const int kTrackStart = 0; | 727 const int kTrackStart = 0; |
| 728 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); | 728 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); |
| 729 | 729 |
| 730 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 730 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 731 scoped_refptr<Layer> scroll_layer = Layer::Create(); | 731 scoped_refptr<Layer> scroll_layer = Layer::Create(); |
| 732 scroll_layer->SetElementId(LayerIdToElementIdForTesting(scroll_layer->id())); | 732 scroll_layer->SetElementId(scroll_layer->id()); |
| 733 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); | 733 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); |
| 734 scoped_refptr<Layer> child1 = Layer::Create(); | 734 scoped_refptr<Layer> child1 = Layer::Create(); |
| 735 scoped_refptr<Layer> scrollbar_layer; | 735 scoped_refptr<Layer> scrollbar_layer; |
| 736 const bool kIsLeftSideVerticalScrollbar = false; | 736 const bool kIsLeftSideVerticalScrollbar = false; |
| 737 scrollbar_layer = SolidColorScrollbarLayer::Create( | 737 scrollbar_layer = SolidColorScrollbarLayer::Create( |
| 738 scrollbar->Orientation(), kThumbThickness, kTrackStart, | 738 scrollbar->Orientation(), kThumbThickness, kTrackStart, |
| 739 kIsLeftSideVerticalScrollbar, scroll_layer->element_id()); | 739 kIsLeftSideVerticalScrollbar, scroll_layer->element_id()); |
| 740 scroll_layer->AddChild(child1); | 740 scroll_layer->AddChild(child1); |
| 741 scroll_layer->InsertChild(scrollbar_layer, 1); | 741 scroll_layer->InsertChild(scrollbar_layer, 1); |
| 742 layer_tree_root->AddChild(scroll_layer); | 742 layer_tree_root->AddChild(scroll_layer); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 767 | 767 |
| 768 TEST_F(ScrollbarLayerTest, SubPixelCanScrollOrientation) { | 768 TEST_F(ScrollbarLayerTest, SubPixelCanScrollOrientation) { |
| 769 gfx::Size viewport_size(980, 980); | 769 gfx::Size viewport_size(980, 980); |
| 770 | 770 |
| 771 LayerTestCommon::LayerImplTest impl; | 771 LayerTestCommon::LayerImplTest impl; |
| 772 | 772 |
| 773 LayerImpl* clip_layer = impl.AddChildToRoot<LayerImpl>(); | 773 LayerImpl* clip_layer = impl.AddChildToRoot<LayerImpl>(); |
| 774 LayerImpl* scroll_layer = impl.AddChild<LayerImpl>(clip_layer); | 774 LayerImpl* scroll_layer = impl.AddChild<LayerImpl>(clip_layer); |
| 775 | 775 |
| 776 scroll_layer->SetScrollClipLayer(clip_layer->id()); | 776 scroll_layer->SetScrollClipLayer(clip_layer->id()); |
| 777 scroll_layer->SetElementId(LayerIdToElementIdForTesting(scroll_layer->id())); | 777 scroll_layer->SetElementId(scroll_layer->id()); |
| 778 | 778 |
| 779 const int kTrackStart = 0; | 779 const int kTrackStart = 0; |
| 780 const int kThumbThickness = 10; | 780 const int kThumbThickness = 10; |
| 781 const bool kIsLeftSideVerticalScrollbar = false; | 781 const bool kIsLeftSideVerticalScrollbar = false; |
| 782 const bool kIsOverlayScrollbar = false; | 782 const bool kIsOverlayScrollbar = false; |
| 783 | 783 |
| 784 SolidColorScrollbarLayerImpl* scrollbar_layer = | 784 SolidColorScrollbarLayerImpl* scrollbar_layer = |
| 785 impl.AddChild<SolidColorScrollbarLayerImpl>( | 785 impl.AddChild<SolidColorScrollbarLayerImpl>( |
| 786 scroll_layer, HORIZONTAL, kThumbThickness, kTrackStart, | 786 scroll_layer, HORIZONTAL, kThumbThickness, kTrackStart, |
| 787 kIsLeftSideVerticalScrollbar, kIsOverlayScrollbar); | 787 kIsLeftSideVerticalScrollbar, kIsOverlayScrollbar); |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1280 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); | 1280 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); |
| 1281 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); | 1281 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); |
| 1282 | 1282 |
| 1283 // Horizontal Scrollbars. | 1283 // Horizontal Scrollbars. |
| 1284 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); | 1284 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); |
| 1285 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); | 1285 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); |
| 1286 } | 1286 } |
| 1287 | 1287 |
| 1288 } // namespace | 1288 } // namespace |
| 1289 } // namespace cc | 1289 } // namespace cc |
| OLD | NEW |