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 ElementId element_id; |
| 295 element_id.id = scroll_layer->id(); |
| 296 scroll_layer->SetElementId(element_id); |
295 scoped_refptr<Layer> content_layer = Layer::Create(); | 297 scoped_refptr<Layer> content_layer = Layer::Create(); |
296 scoped_refptr<Layer> scrollbar_layer = PaintedScrollbarLayer::Create( | 298 scoped_refptr<Layer> scrollbar_layer = PaintedScrollbarLayer::Create( |
297 std::move(scrollbar), scroll_layer->element_id()); | 299 std::move(scrollbar), scroll_layer->element_id()); |
298 | 300 |
299 // Choose bounds to give max_scroll_offset = (30, 50). | 301 // Choose bounds to give max_scroll_offset = (30, 50). |
300 layer_tree_root->SetBounds(gfx::Size(70, 150)); | 302 layer_tree_root->SetBounds(gfx::Size(70, 150)); |
301 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); | 303 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); |
302 scroll_layer->SetScrollOffset(gfx::ScrollOffset(10, 20)); | 304 scroll_layer->SetScrollOffset(gfx::ScrollOffset(10, 20)); |
303 scroll_layer->SetBounds(gfx::Size(100, 200)); | 305 scroll_layer->SetBounds(gfx::Size(100, 200)); |
304 content_layer->SetBounds(gfx::Size(100, 200)); | 306 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()); | 399 scrollbar_layer_impl->ComputeThumbQuadRect().ToString()); |
398 } | 400 } |
399 | 401 |
400 TEST_F(ScrollbarLayerTest, ThumbRect) { | 402 TEST_F(ScrollbarLayerTest, ThumbRect) { |
401 scoped_refptr<Layer> root_clip_layer = Layer::Create(); | 403 scoped_refptr<Layer> root_clip_layer = Layer::Create(); |
402 scoped_refptr<Layer> root_layer = Layer::Create(); | 404 scoped_refptr<Layer> root_layer = Layer::Create(); |
403 scoped_refptr<Layer> content_layer = Layer::Create(); | 405 scoped_refptr<Layer> content_layer = Layer::Create(); |
404 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = | 406 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = |
405 FakePaintedScrollbarLayer::Create(false, true, root_layer->element_id()); | 407 FakePaintedScrollbarLayer::Create(false, true, root_layer->element_id()); |
406 | 408 |
407 root_layer->SetElementId(LayerIdToElementIdForTesting(root_layer->id())); | 409 ElementId element_id; |
| 410 element_id.id = root_layer->id(); |
| 411 root_layer->SetElementId(element_id); |
408 root_layer->SetScrollClipLayerId(root_clip_layer->id()); | 412 root_layer->SetScrollClipLayerId(root_clip_layer->id()); |
409 // Give the root-clip a size that will result in MaxScrollOffset = (80, 0). | 413 // Give the root-clip a size that will result in MaxScrollOffset = (80, 0). |
410 root_clip_layer->SetBounds(gfx::Size(20, 50)); | 414 root_clip_layer->SetBounds(gfx::Size(20, 50)); |
411 root_layer->SetBounds(gfx::Size(100, 50)); | 415 root_layer->SetBounds(gfx::Size(100, 50)); |
412 content_layer->SetBounds(gfx::Size(100, 50)); | 416 content_layer->SetBounds(gfx::Size(100, 50)); |
413 | 417 |
414 layer_tree_host_->SetRootLayer(root_clip_layer); | 418 layer_tree_host_->SetRootLayer(root_clip_layer); |
415 root_clip_layer->AddChild(root_layer); | 419 root_clip_layer->AddChild(root_layer); |
416 root_layer->AddChild(content_layer); | 420 root_layer->AddChild(content_layer); |
417 root_layer->AddChild(scrollbar_layer); | 421 root_layer->AddChild(scrollbar_layer); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 | 592 |
589 TEST_F(ScrollbarLayerTest, LayerDrivenSolidColorDrawQuads) { | 593 TEST_F(ScrollbarLayerTest, LayerDrivenSolidColorDrawQuads) { |
590 const int kThumbThickness = 3; | 594 const int kThumbThickness = 3; |
591 const int kTrackStart = 0; | 595 const int kTrackStart = 0; |
592 const int kTrackLength = 10; | 596 const int kTrackLength = 10; |
593 | 597 |
594 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); | 598 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); |
595 | 599 |
596 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 600 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
597 scoped_refptr<Layer> scroll_layer = Layer::Create(); | 601 scoped_refptr<Layer> scroll_layer = Layer::Create(); |
598 scroll_layer->SetElementId(LayerIdToElementIdForTesting(scroll_layer->id())); | 602 ElementId element_id; |
| 603 element_id.id = scroll_layer->id(); |
| 604 scroll_layer->SetElementId(element_id); |
599 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); | 605 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); |
600 scoped_refptr<Layer> child1 = Layer::Create(); | 606 scoped_refptr<Layer> child1 = Layer::Create(); |
601 scoped_refptr<Layer> child2; | 607 scoped_refptr<Layer> child2; |
602 const bool kIsLeftSideVerticalScrollbar = false; | 608 const bool kIsLeftSideVerticalScrollbar = false; |
603 child2 = SolidColorScrollbarLayer::Create( | 609 child2 = SolidColorScrollbarLayer::Create( |
604 scrollbar->Orientation(), kThumbThickness, kTrackStart, | 610 scrollbar->Orientation(), kThumbThickness, kTrackStart, |
605 kIsLeftSideVerticalScrollbar, scroll_layer->element_id()); | 611 kIsLeftSideVerticalScrollbar, scroll_layer->element_id()); |
606 scroll_layer->AddChild(child1); | 612 scroll_layer->AddChild(child1); |
607 scroll_layer->InsertChild(child2, 1); | 613 scroll_layer->InsertChild(child2, 1); |
608 layer_tree_root->AddChild(scroll_layer); | 614 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 | 728 // Pushing changed bounds of scroll layer can lead to calling |
723 // OnOpacityAnimated on scrollbar layer which means OnOpacityAnimated should | 729 // OnOpacityAnimated on scrollbar layer which means OnOpacityAnimated should |
724 // be independent of scrollbar layer's properties as scrollbar layer can push | 730 // be independent of scrollbar layer's properties as scrollbar layer can push |
725 // its properties after scroll layer. | 731 // its properties after scroll layer. |
726 const int kThumbThickness = 3; | 732 const int kThumbThickness = 3; |
727 const int kTrackStart = 0; | 733 const int kTrackStart = 0; |
728 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); | 734 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); |
729 | 735 |
730 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 736 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
731 scoped_refptr<Layer> scroll_layer = Layer::Create(); | 737 scoped_refptr<Layer> scroll_layer = Layer::Create(); |
732 scroll_layer->SetElementId(LayerIdToElementIdForTesting(scroll_layer->id())); | 738 ElementId element_id; |
| 739 element_id.id = scroll_layer->id(); |
| 740 scroll_layer->SetElementId(element_id); |
733 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); | 741 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); |
734 scoped_refptr<Layer> child1 = Layer::Create(); | 742 scoped_refptr<Layer> child1 = Layer::Create(); |
735 scoped_refptr<Layer> scrollbar_layer; | 743 scoped_refptr<Layer> scrollbar_layer; |
736 const bool kIsLeftSideVerticalScrollbar = false; | 744 const bool kIsLeftSideVerticalScrollbar = false; |
737 scrollbar_layer = SolidColorScrollbarLayer::Create( | 745 scrollbar_layer = SolidColorScrollbarLayer::Create( |
738 scrollbar->Orientation(), kThumbThickness, kTrackStart, | 746 scrollbar->Orientation(), kThumbThickness, kTrackStart, |
739 kIsLeftSideVerticalScrollbar, scroll_layer->element_id()); | 747 kIsLeftSideVerticalScrollbar, scroll_layer->element_id()); |
740 scroll_layer->AddChild(child1); | 748 scroll_layer->AddChild(child1); |
741 scroll_layer->InsertChild(scrollbar_layer, 1); | 749 scroll_layer->InsertChild(scrollbar_layer, 1); |
742 layer_tree_root->AddChild(scroll_layer); | 750 layer_tree_root->AddChild(scroll_layer); |
(...skipping 24 matching lines...) Expand all Loading... |
767 | 775 |
768 TEST_F(ScrollbarLayerTest, SubPixelCanScrollOrientation) { | 776 TEST_F(ScrollbarLayerTest, SubPixelCanScrollOrientation) { |
769 gfx::Size viewport_size(980, 980); | 777 gfx::Size viewport_size(980, 980); |
770 | 778 |
771 LayerTestCommon::LayerImplTest impl; | 779 LayerTestCommon::LayerImplTest impl; |
772 | 780 |
773 LayerImpl* clip_layer = impl.AddChildToRoot<LayerImpl>(); | 781 LayerImpl* clip_layer = impl.AddChildToRoot<LayerImpl>(); |
774 LayerImpl* scroll_layer = impl.AddChild<LayerImpl>(clip_layer); | 782 LayerImpl* scroll_layer = impl.AddChild<LayerImpl>(clip_layer); |
775 | 783 |
776 scroll_layer->SetScrollClipLayer(clip_layer->id()); | 784 scroll_layer->SetScrollClipLayer(clip_layer->id()); |
777 scroll_layer->SetElementId(LayerIdToElementIdForTesting(scroll_layer->id())); | 785 ElementId element_id; |
| 786 element_id.id = scroll_layer->id(); |
| 787 scroll_layer->SetElementId(element_id); |
778 | 788 |
779 const int kTrackStart = 0; | 789 const int kTrackStart = 0; |
780 const int kThumbThickness = 10; | 790 const int kThumbThickness = 10; |
781 const bool kIsLeftSideVerticalScrollbar = false; | 791 const bool kIsLeftSideVerticalScrollbar = false; |
782 const bool kIsOverlayScrollbar = false; | 792 const bool kIsOverlayScrollbar = false; |
783 | 793 |
784 SolidColorScrollbarLayerImpl* scrollbar_layer = | 794 SolidColorScrollbarLayerImpl* scrollbar_layer = |
785 impl.AddChild<SolidColorScrollbarLayerImpl>( | 795 impl.AddChild<SolidColorScrollbarLayerImpl>( |
786 scroll_layer, HORIZONTAL, kThumbThickness, kTrackStart, | 796 scroll_layer, HORIZONTAL, kThumbThickness, kTrackStart, |
787 kIsLeftSideVerticalScrollbar, kIsOverlayScrollbar); | 797 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); | 1290 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); |
1281 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); | 1291 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); |
1282 | 1292 |
1283 // Horizontal Scrollbars. | 1293 // Horizontal Scrollbars. |
1284 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); | 1294 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); |
1285 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); | 1295 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); |
1286 } | 1296 } |
1287 | 1297 |
1288 } // namespace | 1298 } // namespace |
1289 } // namespace cc | 1299 } // namespace cc |
OLD | NEW |