| 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 "base/containers/hash_tables.h" | 5 #include "base/containers/hash_tables.h" |
| 6 #include "cc/animation/scrollbar_animation_controller.h" | 6 #include "cc/animation/scrollbar_animation_controller.h" |
| 7 #include "cc/layers/append_quads_data.h" | 7 #include "cc/layers/append_quads_data.h" |
| 8 #include "cc/layers/painted_scrollbar_layer.h" | 8 #include "cc/layers/painted_scrollbar_layer.h" |
| 9 #include "cc/layers/painted_scrollbar_layer_impl.h" | 9 #include "cc/layers/painted_scrollbar_layer_impl.h" |
| 10 #include "cc/layers/scrollbar_layer_interface.h" | 10 #include "cc/layers/scrollbar_layer_interface.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( | 100 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( |
| 101 host.get(), scrollbar.Pass(), false, false, 0, 0); | 101 host.get(), scrollbar.Pass(), false, false, 0, 0); |
| 102 PaintedScrollbarLayerImpl* scrollbar_layer_impl = | 102 PaintedScrollbarLayerImpl* scrollbar_layer_impl = |
| 103 static_cast<PaintedScrollbarLayerImpl*>( | 103 static_cast<PaintedScrollbarLayerImpl*>( |
| 104 layer_impl_tree_root->children()[1]); | 104 layer_impl_tree_root->children()[1]); |
| 105 | 105 |
| 106 // When the scrollbar is not an overlay scrollbar, the scroll should be | 106 // When the scrollbar is not an overlay scrollbar, the scroll should be |
| 107 // responded to on the main thread as the compositor does not yet implement | 107 // responded to on the main thread as the compositor does not yet implement |
| 108 // scrollbar scrolling. | 108 // scrollbar scrolling. |
| 109 EXPECT_EQ(InputHandler::ScrollOnMainThread, | 109 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 110 scrollbar_layer_impl->TryScroll(gfx::Point(0, 0), | 110 scrollbar_layer_impl->TryScroll( |
| 111 InputHandler::Gesture)); | 111 gfx::Point(0, 0), InputHandler::Gesture, ScrollBlocksOnNone)); |
| 112 | 112 |
| 113 // Create and attach an overlay scrollbar. | 113 // Create and attach an overlay scrollbar. |
| 114 scrollbar.reset(new FakeScrollbar(false, false, true)); | 114 scrollbar.reset(new FakeScrollbar(false, false, true)); |
| 115 | 115 |
| 116 layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( | 116 layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( |
| 117 host.get(), scrollbar.Pass(), false, false, 0, 0); | 117 host.get(), scrollbar.Pass(), false, false, 0, 0); |
| 118 scrollbar_layer_impl = static_cast<PaintedScrollbarLayerImpl*>( | 118 scrollbar_layer_impl = static_cast<PaintedScrollbarLayerImpl*>( |
| 119 layer_impl_tree_root->children()[1]); | 119 layer_impl_tree_root->children()[1]); |
| 120 | 120 |
| 121 // The user shouldn't be able to drag an overlay scrollbar and the scroll | 121 // The user shouldn't be able to drag an overlay scrollbar and the scroll |
| 122 // may be handled in the compositor. | 122 // may be handled in the compositor. |
| 123 EXPECT_EQ(InputHandler::ScrollIgnored, | 123 EXPECT_EQ(InputHandler::ScrollIgnored, |
| 124 scrollbar_layer_impl->TryScroll(gfx::Point(0, 0), | 124 scrollbar_layer_impl->TryScroll( |
| 125 InputHandler::Gesture)); | 125 gfx::Point(0, 0), InputHandler::Gesture, ScrollBlocksOnNone)); |
| 126 } | 126 } |
| 127 | 127 |
| 128 TEST(PaintedScrollbarLayerTest, ScrollOffsetSynchronization) { | 128 TEST(PaintedScrollbarLayerTest, ScrollOffsetSynchronization) { |
| 129 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 129 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
| 130 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&client); | 130 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&client); |
| 131 | 131 |
| 132 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); | 132 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); |
| 133 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 133 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 134 scoped_refptr<Layer> scroll_layer = Layer::Create(); | 134 scoped_refptr<Layer> scroll_layer = Layer::Create(); |
| 135 scoped_refptr<Layer> content_layer = Layer::Create(); | 135 scoped_refptr<Layer> content_layer = Layer::Create(); |
| (...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); | 1095 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); |
| 1096 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); | 1096 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); |
| 1097 | 1097 |
| 1098 // Horizontal Scrollbars. | 1098 // Horizontal Scrollbars. |
| 1099 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); | 1099 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); |
| 1100 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); | 1100 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); |
| 1101 } | 1101 } |
| 1102 | 1102 |
| 1103 } // namespace | 1103 } // namespace |
| 1104 } // namespace cc | 1104 } // namespace cc |
| OLD | NEW |