| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( | 155 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( |
| 156 layer_settings(), layer_tree_host_.get(), std::move(scrollbar), false, | 156 layer_settings(), layer_tree_host_.get(), std::move(scrollbar), false, |
| 157 false, 0, 0); | 157 false, 0, 0); |
| 158 PaintedScrollbarLayerImpl* scrollbar_layer_impl = | 158 PaintedScrollbarLayerImpl* scrollbar_layer_impl = |
| 159 static_cast<PaintedScrollbarLayerImpl*>( | 159 static_cast<PaintedScrollbarLayerImpl*>( |
| 160 layer_impl_tree_root->children()[1].get()); | 160 layer_impl_tree_root->children()[1].get()); |
| 161 | 161 |
| 162 // When the scrollbar is not an overlay scrollbar, the scroll should be | 162 // When the scrollbar is not an overlay scrollbar, the scroll should be |
| 163 // responded to on the main thread as the compositor does not yet implement | 163 // responded to on the main thread as the compositor does not yet implement |
| 164 // scrollbar scrolling. | 164 // scrollbar scrolling. |
| 165 InputHandler::ScrollStatus status = scrollbar_layer_impl->TryScroll( | 165 InputHandler::ScrollStatus status = |
| 166 gfx::PointF(), InputHandler::GESTURE, SCROLL_BLOCKS_ON_NONE); | 166 scrollbar_layer_impl->TryScroll(gfx::PointF(), InputHandler::GESTURE); |
| 167 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 167 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
| 168 EXPECT_EQ(MainThreadScrollingReason::kScrollbarScrolling, | 168 EXPECT_EQ(MainThreadScrollingReason::kScrollbarScrolling, |
| 169 status.main_thread_scrolling_reasons); | 169 status.main_thread_scrolling_reasons); |
| 170 | 170 |
| 171 // Create and attach an overlay scrollbar. | 171 // Create and attach an overlay scrollbar. |
| 172 scrollbar.reset(new FakeScrollbar(false, false, true)); | 172 scrollbar.reset(new FakeScrollbar(false, false, true)); |
| 173 | 173 |
| 174 layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( | 174 layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( |
| 175 layer_settings(), layer_tree_host_.get(), std::move(scrollbar), false, | 175 layer_settings(), layer_tree_host_.get(), std::move(scrollbar), false, |
| 176 false, 0, 0); | 176 false, 0, 0); |
| 177 scrollbar_layer_impl = static_cast<PaintedScrollbarLayerImpl*>( | 177 scrollbar_layer_impl = static_cast<PaintedScrollbarLayerImpl*>( |
| 178 layer_impl_tree_root->children()[1].get()); | 178 layer_impl_tree_root->children()[1].get()); |
| 179 | 179 |
| 180 // The user shouldn't be able to drag an overlay scrollbar and the scroll | 180 // The user shouldn't be able to drag an overlay scrollbar and the scroll |
| 181 // may be handled in the compositor. | 181 // may be handled in the compositor. |
| 182 status = scrollbar_layer_impl->TryScroll(gfx::PointF(), InputHandler::GESTURE, | 182 status = |
| 183 SCROLL_BLOCKS_ON_NONE); | 183 scrollbar_layer_impl->TryScroll(gfx::PointF(), InputHandler::GESTURE); |
| 184 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 184 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
| 185 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable, | 185 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable, |
| 186 status.main_thread_scrolling_reasons); | 186 status.main_thread_scrolling_reasons); |
| 187 } | 187 } |
| 188 | 188 |
| 189 TEST_F(ScrollbarLayerTest, ScrollOffsetSynchronization) { | 189 TEST_F(ScrollbarLayerTest, ScrollOffsetSynchronization) { |
| 190 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); | 190 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); |
| 191 scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings()); | 191 scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings()); |
| 192 scoped_refptr<Layer> scroll_layer = Layer::Create(layer_settings()); | 192 scoped_refptr<Layer> scroll_layer = Layer::Create(layer_settings()); |
| 193 scoped_refptr<Layer> content_layer = Layer::Create(layer_settings()); | 193 scoped_refptr<Layer> content_layer = Layer::Create(layer_settings()); |
| (...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); | 1009 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); |
| 1010 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); | 1010 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); |
| 1011 | 1011 |
| 1012 // Horizontal Scrollbars. | 1012 // Horizontal Scrollbars. |
| 1013 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); | 1013 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); |
| 1014 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); | 1014 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); |
| 1015 } | 1015 } |
| 1016 | 1016 |
| 1017 } // namespace | 1017 } // namespace |
| 1018 } // namespace cc | 1018 } // namespace cc |
| OLD | NEW |