| 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/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "cc/animation/scrollbar_animation_controller.h" | 10 #include "cc/animation/scrollbar_animation_controller.h" |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 scoped_refptr<Layer> child2; | 448 scoped_refptr<Layer> child2; |
| 449 const bool kIsLeftSideVerticalScrollbar = false; | 449 const bool kIsLeftSideVerticalScrollbar = false; |
| 450 child2 = SolidColorScrollbarLayer::Create( | 450 child2 = SolidColorScrollbarLayer::Create( |
| 451 layer_settings(), scrollbar->Orientation(), kThumbThickness, | 451 layer_settings(), scrollbar->Orientation(), kThumbThickness, |
| 452 kTrackStart, kIsLeftSideVerticalScrollbar, child1->id()); | 452 kTrackStart, kIsLeftSideVerticalScrollbar, child1->id()); |
| 453 child2->ToScrollbarLayer()->SetScrollLayer(scroll_layer->id()); | 453 child2->ToScrollbarLayer()->SetScrollLayer(scroll_layer->id()); |
| 454 scroll_layer->AddChild(child1); | 454 scroll_layer->AddChild(child1); |
| 455 scroll_layer->InsertChild(child2, 1); | 455 scroll_layer->InsertChild(child2, 1); |
| 456 layer_tree_root->AddChild(scroll_layer); | 456 layer_tree_root->AddChild(scroll_layer); |
| 457 layer_tree_host_->SetRootLayer(layer_tree_root); | 457 layer_tree_host_->SetRootLayer(layer_tree_root); |
| 458 |
| 459 // Choose layer bounds to give max_scroll_offset = (8, 8). |
| 460 layer_tree_root->SetBounds(gfx::Size(2, 2)); |
| 461 scroll_layer->SetBounds(gfx::Size(10, 10)); |
| 462 |
| 458 layer_tree_host_->UpdateLayers(); | 463 layer_tree_host_->UpdateLayers(); |
| 459 } | 464 } |
| 465 |
| 460 LayerImpl* layer_impl_tree_root = | 466 LayerImpl* layer_impl_tree_root = |
| 461 layer_tree_host_->CommitAndCreateLayerImplTree(); | 467 layer_tree_host_->CommitAndCreateLayerImplTree(); |
| 462 LayerImpl* scroll_layer_impl = layer_impl_tree_root->children()[0].get(); | 468 LayerImpl* scroll_layer_impl = layer_impl_tree_root->children()[0].get(); |
| 463 | 469 |
| 464 auto* scrollbar_layer_impl = static_cast<ScrollbarLayerImplBase*>( | 470 auto* scrollbar_layer_impl = static_cast<ScrollbarLayerImplBase*>( |
| 465 scroll_layer_impl->children()[1].get()); | 471 scroll_layer_impl->children()[1].get()); |
| 466 | 472 |
| 467 // Choose layer bounds to give max_scroll_offset = (8, 8). | |
| 468 layer_impl_tree_root->SetBounds(gfx::Size(2, 2)); | |
| 469 scroll_layer_impl->SetBounds(gfx::Size(10, 10)); | |
| 470 scroll_layer_impl->ScrollBy(gfx::Vector2dF(4.f, 0.f)); | 473 scroll_layer_impl->ScrollBy(gfx::Vector2dF(4.f, 0.f)); |
| 471 | 474 |
| 472 scrollbar_layer_impl->SetBounds(gfx::Size(kTrackLength, kThumbThickness)); | 475 scrollbar_layer_impl->SetBounds(gfx::Size(kTrackLength, kThumbThickness)); |
| 473 scrollbar_layer_impl->SetCurrentPos(4.f); | 476 scrollbar_layer_impl->SetCurrentPos(4.f); |
| 474 | 477 |
| 475 { | 478 { |
| 476 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 479 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 477 | 480 |
| 478 AppendQuadsData data; | 481 AppendQuadsData data; |
| 479 scrollbar_layer_impl->AppendQuads(render_pass.get(), &data); | 482 scrollbar_layer_impl->AppendQuads(render_pass.get(), &data); |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); | 1012 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); |
| 1010 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); | 1013 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); |
| 1011 | 1014 |
| 1012 // Horizontal Scrollbars. | 1015 // Horizontal Scrollbars. |
| 1013 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); | 1016 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); |
| 1014 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); | 1017 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); |
| 1015 } | 1018 } |
| 1016 | 1019 |
| 1017 } // namespace | 1020 } // namespace |
| 1018 } // namespace cc | 1021 } // namespace cc |
| OLD | NEW |