Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(453)

Side by Side Diff: cc/layers/scrollbar_layer_unittest.cc

Issue 2824693002: Refactor LayerTreeImpl's scrollbar map to be keyed on element ids (Closed)
Patch Set: rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 gfx::PointF(), InputHandler::TOUCHSCREEN, scroll_tree, scroll_node); 286 gfx::PointF(), InputHandler::TOUCHSCREEN, scroll_tree, scroll_node);
287 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); 287 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread);
288 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable, 288 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable,
289 status.main_thread_scrolling_reasons); 289 status.main_thread_scrolling_reasons);
290 } 290 }
291 291
292 TEST_F(ScrollbarLayerTest, ScrollOffsetSynchronization) { 292 TEST_F(ScrollbarLayerTest, ScrollOffsetSynchronization) {
293 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar); 293 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar);
294 scoped_refptr<Layer> layer_tree_root = Layer::Create(); 294 scoped_refptr<Layer> layer_tree_root = Layer::Create();
295 scoped_refptr<Layer> scroll_layer = Layer::Create(); 295 scoped_refptr<Layer> scroll_layer = Layer::Create();
296 scroll_layer->SetElementId(LayerIdToElementIdForTesting(scroll_layer->id()));
296 scoped_refptr<Layer> content_layer = Layer::Create(); 297 scoped_refptr<Layer> content_layer = Layer::Create();
297 scoped_refptr<Layer> scrollbar_layer = PaintedScrollbarLayer::Create( 298 scoped_refptr<Layer> scrollbar_layer = PaintedScrollbarLayer::Create(
298 std::move(scrollbar), scroll_layer->id(), scroll_layer->element_id()); 299 std::move(scrollbar), scroll_layer->id(), scroll_layer->element_id());
299 300
300 // Choose bounds to give max_scroll_offset = (30, 50). 301 // Choose bounds to give max_scroll_offset = (30, 50).
301 layer_tree_root->SetBounds(gfx::Size(70, 150)); 302 layer_tree_root->SetBounds(gfx::Size(70, 150));
302 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); 303 scroll_layer->SetScrollClipLayerId(layer_tree_root->id());
303 scroll_layer->SetScrollOffset(gfx::ScrollOffset(10, 20)); 304 scroll_layer->SetScrollOffset(gfx::ScrollOffset(10, 20));
304 scroll_layer->SetBounds(gfx::Size(100, 200)); 305 scroll_layer->SetBounds(gfx::Size(100, 200));
305 content_layer->SetBounds(gfx::Size(100, 200)); 306 content_layer->SetBounds(gfx::Size(100, 200));
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 } 400 }
400 401
401 TEST_F(ScrollbarLayerTest, ThumbRect) { 402 TEST_F(ScrollbarLayerTest, ThumbRect) {
402 scoped_refptr<Layer> root_clip_layer = Layer::Create(); 403 scoped_refptr<Layer> root_clip_layer = Layer::Create();
403 scoped_refptr<Layer> root_layer = Layer::Create(); 404 scoped_refptr<Layer> root_layer = Layer::Create();
404 scoped_refptr<Layer> content_layer = Layer::Create(); 405 scoped_refptr<Layer> content_layer = Layer::Create();
405 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = 406 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer =
406 FakePaintedScrollbarLayer::Create(false, true, root_layer->id(), 407 FakePaintedScrollbarLayer::Create(false, true, root_layer->id(),
407 root_layer->element_id()); 408 root_layer->element_id());
408 409
410 root_layer->SetElementId(LayerIdToElementIdForTesting(root_layer->id()));
409 root_layer->SetScrollClipLayerId(root_clip_layer->id()); 411 root_layer->SetScrollClipLayerId(root_clip_layer->id());
410 // Give the root-clip a size that will result in MaxScrollOffset = (80, 0). 412 // Give the root-clip a size that will result in MaxScrollOffset = (80, 0).
411 root_clip_layer->SetBounds(gfx::Size(20, 50)); 413 root_clip_layer->SetBounds(gfx::Size(20, 50));
412 root_layer->SetBounds(gfx::Size(100, 50)); 414 root_layer->SetBounds(gfx::Size(100, 50));
413 content_layer->SetBounds(gfx::Size(100, 50)); 415 content_layer->SetBounds(gfx::Size(100, 50));
414 416
415 layer_tree_host_->SetRootLayer(root_clip_layer); 417 layer_tree_host_->SetRootLayer(root_clip_layer);
416 root_clip_layer->AddChild(root_layer); 418 root_clip_layer->AddChild(root_layer);
417 root_layer->AddChild(content_layer); 419 root_layer->AddChild(content_layer);
418 root_layer->AddChild(scrollbar_layer); 420 root_layer->AddChild(scrollbar_layer);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 592
591 TEST_F(ScrollbarLayerTest, LayerDrivenSolidColorDrawQuads) { 593 TEST_F(ScrollbarLayerTest, LayerDrivenSolidColorDrawQuads) {
592 const int kThumbThickness = 3; 594 const int kThumbThickness = 3;
593 const int kTrackStart = 0; 595 const int kTrackStart = 0;
594 const int kTrackLength = 10; 596 const int kTrackLength = 10;
595 597
596 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); 598 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true));
597 599
598 scoped_refptr<Layer> layer_tree_root = Layer::Create(); 600 scoped_refptr<Layer> layer_tree_root = Layer::Create();
599 scoped_refptr<Layer> scroll_layer = Layer::Create(); 601 scoped_refptr<Layer> scroll_layer = Layer::Create();
602 scroll_layer->SetElementId(LayerIdToElementIdForTesting(scroll_layer->id()));
600 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); 603 scroll_layer->SetScrollClipLayerId(layer_tree_root->id());
601 scoped_refptr<Layer> child1 = Layer::Create(); 604 scoped_refptr<Layer> child1 = Layer::Create();
602 scoped_refptr<Layer> child2; 605 scoped_refptr<Layer> child2;
603 const bool kIsLeftSideVerticalScrollbar = false; 606 const bool kIsLeftSideVerticalScrollbar = false;
604 child2 = SolidColorScrollbarLayer::Create( 607 child2 = SolidColorScrollbarLayer::Create(
605 scrollbar->Orientation(), kThumbThickness, kTrackStart, 608 scrollbar->Orientation(), kThumbThickness, kTrackStart,
606 kIsLeftSideVerticalScrollbar, scroll_layer->id(), 609 kIsLeftSideVerticalScrollbar, scroll_layer->id(),
607 scroll_layer->element_id()); 610 scroll_layer->element_id());
608 scroll_layer->AddChild(child1); 611 scroll_layer->AddChild(child1);
609 scroll_layer->InsertChild(child2, 1); 612 scroll_layer->InsertChild(child2, 1);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 // Pushing changed bounds of scroll layer can lead to calling 728 // Pushing changed bounds of scroll layer can lead to calling
726 // OnOpacityAnimated on scrollbar layer which means OnOpacityAnimated should 729 // OnOpacityAnimated on scrollbar layer which means OnOpacityAnimated should
727 // 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
728 // its properties after scroll layer. 731 // its properties after scroll layer.
729 const int kThumbThickness = 3; 732 const int kThumbThickness = 3;
730 const int kTrackStart = 0; 733 const int kTrackStart = 0;
731 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); 734 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true));
732 735
733 scoped_refptr<Layer> layer_tree_root = Layer::Create(); 736 scoped_refptr<Layer> layer_tree_root = Layer::Create();
734 scoped_refptr<Layer> scroll_layer = Layer::Create(); 737 scoped_refptr<Layer> scroll_layer = Layer::Create();
738 scroll_layer->SetElementId(LayerIdToElementIdForTesting(scroll_layer->id()));
735 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); 739 scroll_layer->SetScrollClipLayerId(layer_tree_root->id());
736 scoped_refptr<Layer> child1 = Layer::Create(); 740 scoped_refptr<Layer> child1 = Layer::Create();
737 scoped_refptr<Layer> scrollbar_layer; 741 scoped_refptr<Layer> scrollbar_layer;
738 const bool kIsLeftSideVerticalScrollbar = false; 742 const bool kIsLeftSideVerticalScrollbar = false;
739 scrollbar_layer = SolidColorScrollbarLayer::Create( 743 scrollbar_layer = SolidColorScrollbarLayer::Create(
740 scrollbar->Orientation(), kThumbThickness, kTrackStart, 744 scrollbar->Orientation(), kThumbThickness, kTrackStart,
741 kIsLeftSideVerticalScrollbar, scroll_layer->id(), 745 kIsLeftSideVerticalScrollbar, scroll_layer->id(),
742 scroll_layer->element_id()); 746 scroll_layer->element_id());
743 scroll_layer->SetScrollClipLayerId(layer_tree_root->id());
744 scroll_layer->AddChild(child1); 747 scroll_layer->AddChild(child1);
745 scroll_layer->InsertChild(scrollbar_layer, 1); 748 scroll_layer->InsertChild(scrollbar_layer, 1);
746 layer_tree_root->AddChild(scroll_layer); 749 layer_tree_root->AddChild(scroll_layer);
747 layer_tree_host_->SetRootLayer(layer_tree_root); 750 layer_tree_host_->SetRootLayer(layer_tree_root);
748 751
749 layer_tree_root->SetBounds(gfx::Size(2, 2)); 752 layer_tree_root->SetBounds(gfx::Size(2, 2));
750 scroll_layer->SetBounds(gfx::Size(10, 10)); 753 scroll_layer->SetBounds(gfx::Size(10, 10));
751 layer_tree_host_->UpdateLayers(); 754 layer_tree_host_->UpdateLayers();
752 layer_tree_host_->CommitAndCreateLayerImplTree(); 755 layer_tree_host_->CommitAndCreateLayerImplTree();
753 LayerTreeHostImpl* host_impl = layer_tree_host_->host_impl(); 756 LayerTreeHostImpl* host_impl = layer_tree_host_->host_impl();
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); 1251 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f);
1249 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); 1252 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f);
1250 1253
1251 // Horizontal Scrollbars. 1254 // Horizontal Scrollbars.
1252 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); 1255 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f);
1253 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); 1256 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f);
1254 } 1257 }
1255 1258
1256 } // namespace 1259 } // namespace
1257 } // namespace cc 1260 } // namespace cc
OLDNEW
« no previous file with comments | « cc/input/single_scrollbar_animation_controller_thinning_unittest.cc ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698