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