| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); | 166 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); |
| 167 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( | 167 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( |
| 168 layer_tree_host_.get(), scrollbar.Pass(), false, false, 0, 0); | 168 layer_tree_host_.get(), scrollbar.Pass(), false, false, 0, 0); |
| 169 PaintedScrollbarLayerImpl* scrollbar_layer_impl = | 169 PaintedScrollbarLayerImpl* scrollbar_layer_impl = |
| 170 static_cast<PaintedScrollbarLayerImpl*>( | 170 static_cast<PaintedScrollbarLayerImpl*>( |
| 171 layer_impl_tree_root->children()[1]); | 171 layer_impl_tree_root->children()[1]); |
| 172 | 172 |
| 173 // When the scrollbar is not an overlay scrollbar, the scroll should be | 173 // When the scrollbar is not an overlay scrollbar, the scroll should be |
| 174 // responded to on the main thread as the compositor does not yet implement | 174 // responded to on the main thread as the compositor does not yet implement |
| 175 // scrollbar scrolling. | 175 // scrollbar scrolling. |
| 176 EXPECT_EQ(InputHandler::ScrollOnMainThread, | 176 EXPECT_EQ( |
| 177 scrollbar_layer_impl->TryScroll( | 177 InputHandler::SCROLL_ON_MAIN_THREAD, |
| 178 gfx::Point(0, 0), InputHandler::Gesture, ScrollBlocksOnNone)); | 178 scrollbar_layer_impl->TryScroll(gfx::Point(0, 0), InputHandler::GESTURE, |
| 179 SCROLL_BLOCKS_ON_NONE)); |
| 179 | 180 |
| 180 // Create and attach an overlay scrollbar. | 181 // Create and attach an overlay scrollbar. |
| 181 scrollbar.reset(new FakeScrollbar(false, false, true)); | 182 scrollbar.reset(new FakeScrollbar(false, false, true)); |
| 182 | 183 |
| 183 layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( | 184 layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( |
| 184 layer_tree_host_.get(), scrollbar.Pass(), false, false, 0, 0); | 185 layer_tree_host_.get(), scrollbar.Pass(), false, false, 0, 0); |
| 185 scrollbar_layer_impl = static_cast<PaintedScrollbarLayerImpl*>( | 186 scrollbar_layer_impl = static_cast<PaintedScrollbarLayerImpl*>( |
| 186 layer_impl_tree_root->children()[1]); | 187 layer_impl_tree_root->children()[1]); |
| 187 | 188 |
| 188 // The user shouldn't be able to drag an overlay scrollbar and the scroll | 189 // The user shouldn't be able to drag an overlay scrollbar and the scroll |
| 189 // may be handled in the compositor. | 190 // may be handled in the compositor. |
| 190 EXPECT_EQ(InputHandler::ScrollIgnored, | 191 EXPECT_EQ( |
| 191 scrollbar_layer_impl->TryScroll( | 192 InputHandler::SCROLL_IGNORED, |
| 192 gfx::Point(0, 0), InputHandler::Gesture, ScrollBlocksOnNone)); | 193 scrollbar_layer_impl->TryScroll(gfx::Point(0, 0), InputHandler::GESTURE, |
| 194 SCROLL_BLOCKS_ON_NONE)); |
| 193 } | 195 } |
| 194 | 196 |
| 195 TEST_F(ScrollbarLayerTest, ScrollOffsetSynchronization) { | 197 TEST_F(ScrollbarLayerTest, ScrollOffsetSynchronization) { |
| 196 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); | 198 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); |
| 197 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 199 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 198 scoped_refptr<Layer> scroll_layer = Layer::Create(); | 200 scoped_refptr<Layer> scroll_layer = Layer::Create(); |
| 199 scoped_refptr<Layer> content_layer = Layer::Create(); | 201 scoped_refptr<Layer> content_layer = Layer::Create(); |
| 200 scoped_refptr<Layer> scrollbar_layer = | 202 scoped_refptr<Layer> scrollbar_layer = |
| 201 PaintedScrollbarLayer::Create(scrollbar.Pass(), layer_tree_root->id()); | 203 PaintedScrollbarLayer::Create(scrollbar.Pass(), layer_tree_root->id()); |
| 202 | 204 |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); | 1057 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); |
| 1056 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); | 1058 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); |
| 1057 | 1059 |
| 1058 // Horizontal Scrollbars. | 1060 // Horizontal Scrollbars. |
| 1059 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); | 1061 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); |
| 1060 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); | 1062 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); |
| 1061 } | 1063 } |
| 1062 | 1064 |
| 1063 } // namespace | 1065 } // namespace |
| 1064 } // namespace cc | 1066 } // namespace cc |
| OLD | NEW |