| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 217 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
| 218 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable, | 218 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable, |
| 219 status.main_thread_scrolling_reasons); | 219 status.main_thread_scrolling_reasons); |
| 220 } | 220 } |
| 221 | 221 |
| 222 TEST_F(ScrollbarLayerTest, ScrollOffsetSynchronization) { | 222 TEST_F(ScrollbarLayerTest, ScrollOffsetSynchronization) { |
| 223 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar); | 223 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar); |
| 224 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 224 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 225 scoped_refptr<Layer> scroll_layer = Layer::Create(); | 225 scoped_refptr<Layer> scroll_layer = Layer::Create(); |
| 226 scoped_refptr<Layer> content_layer = Layer::Create(); | 226 scoped_refptr<Layer> content_layer = Layer::Create(); |
| 227 scoped_refptr<Layer> scrollbar_layer = PaintedScrollbarLayer::Create( | 227 scoped_refptr<Layer> scrollbar_layer = |
| 228 std::move(scrollbar), layer_tree_root->id()); | 228 PaintedScrollbarLayer::Create(std::move(scrollbar), scroll_layer->id()); |
| 229 | 229 |
| 230 // Choose bounds to give max_scroll_offset = (30, 50). | 230 // Choose bounds to give max_scroll_offset = (30, 50). |
| 231 layer_tree_root->SetBounds(gfx::Size(70, 150)); | 231 layer_tree_root->SetBounds(gfx::Size(70, 150)); |
| 232 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); | 232 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); |
| 233 scroll_layer->SetScrollOffset(gfx::ScrollOffset(10, 20)); | 233 scroll_layer->SetScrollOffset(gfx::ScrollOffset(10, 20)); |
| 234 scroll_layer->SetBounds(gfx::Size(100, 200)); | 234 scroll_layer->SetBounds(gfx::Size(100, 200)); |
| 235 content_layer->SetBounds(gfx::Size(100, 200)); | 235 content_layer->SetBounds(gfx::Size(100, 200)); |
| 236 | 236 |
| 237 layer_tree_host_->SetRootLayer(layer_tree_root); | 237 layer_tree_host_->SetRootLayer(layer_tree_root); |
| 238 layer_tree_root->AddChild(scroll_layer); | 238 layer_tree_root->AddChild(scroll_layer); |
| 239 scroll_layer->AddChild(content_layer); | 239 scroll_layer->AddChild(content_layer); |
| 240 layer_tree_root->AddChild(scrollbar_layer); | 240 layer_tree_root->AddChild(scrollbar_layer); |
| 241 scrollbar_layer->ToScrollbarLayer()->SetScrollLayer(scroll_layer->id()); | |
| 242 | 241 |
| 243 layer_tree_root->SavePaintProperties(); | 242 layer_tree_root->SavePaintProperties(); |
| 244 content_layer->SavePaintProperties(); | 243 content_layer->SavePaintProperties(); |
| 245 layer_tree_host_->UpdateLayers(); | 244 layer_tree_host_->UpdateLayers(); |
| 246 LayerImpl* layer_impl_tree_root = | 245 LayerImpl* layer_impl_tree_root = |
| 247 layer_tree_host_->CommitAndCreateLayerImplTree(); | 246 layer_tree_host_->CommitAndCreateLayerImplTree(); |
| 248 | 247 |
| 249 ScrollbarLayerImplBase* cc_scrollbar_layer = | 248 ScrollbarLayerImplBase* cc_scrollbar_layer = |
| 250 static_cast<PaintedScrollbarLayerImpl*>( | 249 static_cast<PaintedScrollbarLayerImpl*>( |
| 251 layer_impl_tree_root->layer_tree_impl()->LayerById( | 250 layer_impl_tree_root->layer_tree_impl()->LayerById( |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); | 523 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); |
| 525 | 524 |
| 526 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 525 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 527 scoped_refptr<Layer> scroll_layer = Layer::Create(); | 526 scoped_refptr<Layer> scroll_layer = Layer::Create(); |
| 528 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); | 527 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); |
| 529 scoped_refptr<Layer> child1 = Layer::Create(); | 528 scoped_refptr<Layer> child1 = Layer::Create(); |
| 530 scoped_refptr<Layer> child2; | 529 scoped_refptr<Layer> child2; |
| 531 const bool kIsLeftSideVerticalScrollbar = false; | 530 const bool kIsLeftSideVerticalScrollbar = false; |
| 532 child2 = SolidColorScrollbarLayer::Create( | 531 child2 = SolidColorScrollbarLayer::Create( |
| 533 scrollbar->Orientation(), kThumbThickness, kTrackStart, | 532 scrollbar->Orientation(), kThumbThickness, kTrackStart, |
| 534 kIsLeftSideVerticalScrollbar, child1->id()); | 533 kIsLeftSideVerticalScrollbar, scroll_layer->id()); |
| 535 child2->ToScrollbarLayer()->SetScrollLayer(scroll_layer->id()); | |
| 536 scroll_layer->AddChild(child1); | 534 scroll_layer->AddChild(child1); |
| 537 scroll_layer->InsertChild(child2, 1); | 535 scroll_layer->InsertChild(child2, 1); |
| 538 layer_tree_root->AddChild(scroll_layer); | 536 layer_tree_root->AddChild(scroll_layer); |
| 539 layer_tree_host_->SetRootLayer(layer_tree_root); | 537 layer_tree_host_->SetRootLayer(layer_tree_root); |
| 540 | 538 |
| 541 // Choose layer bounds to give max_scroll_offset = (8, 8). | 539 // Choose layer bounds to give max_scroll_offset = (8, 8). |
| 542 layer_tree_root->SetBounds(gfx::Size(2, 2)); | 540 layer_tree_root->SetBounds(gfx::Size(2, 2)); |
| 543 scroll_layer->SetBounds(gfx::Size(10, 10)); | 541 scroll_layer->SetBounds(gfx::Size(10, 10)); |
| 544 | 542 |
| 545 layer_tree_host_->UpdateLayers(); | 543 layer_tree_host_->UpdateLayers(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); | 575 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); |
| 578 | 576 |
| 579 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 577 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 580 scoped_refptr<Layer> scroll_layer = Layer::Create(); | 578 scoped_refptr<Layer> scroll_layer = Layer::Create(); |
| 581 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); | 579 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); |
| 582 scoped_refptr<Layer> child1 = Layer::Create(); | 580 scoped_refptr<Layer> child1 = Layer::Create(); |
| 583 scoped_refptr<Layer> scrollbar_layer; | 581 scoped_refptr<Layer> scrollbar_layer; |
| 584 const bool kIsLeftSideVerticalScrollbar = false; | 582 const bool kIsLeftSideVerticalScrollbar = false; |
| 585 scrollbar_layer = SolidColorScrollbarLayer::Create( | 583 scrollbar_layer = SolidColorScrollbarLayer::Create( |
| 586 scrollbar->Orientation(), kThumbThickness, kTrackStart, | 584 scrollbar->Orientation(), kThumbThickness, kTrackStart, |
| 587 kIsLeftSideVerticalScrollbar, child1->id()); | 585 kIsLeftSideVerticalScrollbar, scroll_layer->id()); |
| 588 scrollbar_layer->ToScrollbarLayer()->SetScrollLayer(scroll_layer->id()); | |
| 589 scroll_layer->AddChild(child1); | 586 scroll_layer->AddChild(child1); |
| 590 scroll_layer->InsertChild(scrollbar_layer, 1); | 587 scroll_layer->InsertChild(scrollbar_layer, 1); |
| 591 layer_tree_root->AddChild(scroll_layer); | 588 layer_tree_root->AddChild(scroll_layer); |
| 592 layer_tree_host_->SetRootLayer(layer_tree_root); | 589 layer_tree_host_->SetRootLayer(layer_tree_root); |
| 593 | 590 |
| 594 // Choose layer bounds to give max_scroll_offset = (8, 8). | 591 // Choose layer bounds to give max_scroll_offset = (8, 8). |
| 595 layer_tree_root->SetBounds(gfx::Size(2, 2)); | 592 layer_tree_root->SetBounds(gfx::Size(2, 2)); |
| 596 scroll_layer->SetBounds(gfx::Size(10, 10)); | 593 scroll_layer->SetBounds(gfx::Size(10, 10)); |
| 597 | 594 |
| 598 // Building property trees twice shouldn't change the size of | 595 // Building property trees twice shouldn't change the size of |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); | 656 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); |
| 660 | 657 |
| 661 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 658 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 662 scoped_refptr<Layer> scroll_layer = Layer::Create(); | 659 scoped_refptr<Layer> scroll_layer = Layer::Create(); |
| 663 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); | 660 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); |
| 664 scoped_refptr<Layer> child1 = Layer::Create(); | 661 scoped_refptr<Layer> child1 = Layer::Create(); |
| 665 scoped_refptr<Layer> scrollbar_layer; | 662 scoped_refptr<Layer> scrollbar_layer; |
| 666 const bool kIsLeftSideVerticalScrollbar = false; | 663 const bool kIsLeftSideVerticalScrollbar = false; |
| 667 scrollbar_layer = SolidColorScrollbarLayer::Create( | 664 scrollbar_layer = SolidColorScrollbarLayer::Create( |
| 668 scrollbar->Orientation(), kThumbThickness, kTrackStart, | 665 scrollbar->Orientation(), kThumbThickness, kTrackStart, |
| 669 kIsLeftSideVerticalScrollbar, child1->id()); | 666 kIsLeftSideVerticalScrollbar, scroll_layer->id()); |
| 670 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); | 667 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); |
| 671 scrollbar_layer->ToScrollbarLayer()->SetScrollLayer(scroll_layer->id()); | |
| 672 scroll_layer->AddChild(child1); | 668 scroll_layer->AddChild(child1); |
| 673 scroll_layer->InsertChild(scrollbar_layer, 1); | 669 scroll_layer->InsertChild(scrollbar_layer, 1); |
| 674 layer_tree_root->AddChild(scroll_layer); | 670 layer_tree_root->AddChild(scroll_layer); |
| 675 layer_tree_host_->SetRootLayer(layer_tree_root); | 671 layer_tree_host_->SetRootLayer(layer_tree_root); |
| 676 | 672 |
| 677 layer_tree_root->SetBounds(gfx::Size(2, 2)); | 673 layer_tree_root->SetBounds(gfx::Size(2, 2)); |
| 678 scroll_layer->SetBounds(gfx::Size(10, 10)); | 674 scroll_layer->SetBounds(gfx::Size(10, 10)); |
| 679 layer_tree_host_->UpdateLayers(); | 675 layer_tree_host_->UpdateLayers(); |
| 680 layer_tree_host_->CommitAndCreateLayerImplTree(); | 676 layer_tree_host_->CommitAndCreateLayerImplTree(); |
| 681 LayerTreeHostImpl* host_impl = layer_tree_host_->host_impl(); | 677 LayerTreeHostImpl* host_impl = layer_tree_host_->host_impl(); |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1171 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); | 1167 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); |
| 1172 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); | 1168 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); |
| 1173 | 1169 |
| 1174 // Horizontal Scrollbars. | 1170 // Horizontal Scrollbars. |
| 1175 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); | 1171 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); |
| 1176 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); | 1172 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); |
| 1177 } | 1173 } |
| 1178 | 1174 |
| 1179 } // namespace | 1175 } // namespace |
| 1180 } // namespace cc | 1176 } // namespace cc |
| OLD | NEW |