| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 TEST_F(ScrollbarLayerTest, ShouldScrollNonOverlayOnMainThread) { | 152 TEST_F(ScrollbarLayerTest, ShouldScrollNonOverlayOnMainThread) { |
| 153 // Create and attach a non-overlay scrollbar. | 153 // Create and attach a non-overlay scrollbar. |
| 154 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); | 154 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); |
| 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 layer_impl_tree_root->layer_tree_impl()->BuildPropertyTreesForTesting(); |
| 162 ScrollTree& scroll_tree = |
| 163 layer_impl_tree_root->layer_tree_impl()->property_trees()->scroll_tree; |
| 164 ScrollNode* scroll_node = |
| 165 scroll_tree.Node(scrollbar_layer_impl->scroll_tree_index()); |
| 161 | 166 |
| 162 // When the scrollbar is not an overlay scrollbar, the scroll should be | 167 // 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 | 168 // responded to on the main thread as the compositor does not yet implement |
| 164 // scrollbar scrolling. | 169 // scrollbar scrolling. |
| 165 InputHandler::ScrollStatus status = | 170 InputHandler::ScrollStatus status = layer_tree_host_->host_impl()->TryScroll( |
| 166 scrollbar_layer_impl->TryScroll(gfx::PointF(), InputHandler::GESTURE); | 171 gfx::PointF(), InputHandler::GESTURE, scroll_tree, scroll_node); |
| 167 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 172 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
| 168 EXPECT_EQ(MainThreadScrollingReason::kScrollbarScrolling, | 173 EXPECT_EQ(MainThreadScrollingReason::kScrollbarScrolling, |
| 169 status.main_thread_scrolling_reasons); | 174 status.main_thread_scrolling_reasons); |
| 170 | 175 |
| 171 // Create and attach an overlay scrollbar. | 176 // Create and attach an overlay scrollbar. |
| 172 scrollbar.reset(new FakeScrollbar(false, false, true)); | 177 scrollbar.reset(new FakeScrollbar(false, false, true)); |
| 173 | 178 |
| 174 layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( | 179 layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( |
| 175 layer_settings(), layer_tree_host_.get(), std::move(scrollbar), false, | 180 layer_settings(), layer_tree_host_.get(), std::move(scrollbar), false, |
| 176 false, 0, 0); | 181 false, 0, 0); |
| 177 scrollbar_layer_impl = static_cast<PaintedScrollbarLayerImpl*>( | 182 scrollbar_layer_impl = static_cast<PaintedScrollbarLayerImpl*>( |
| 178 layer_impl_tree_root->children()[1].get()); | 183 layer_impl_tree_root->children()[1].get()); |
| 184 layer_impl_tree_root->layer_tree_impl()->BuildPropertyTreesForTesting(); |
| 185 scroll_tree = |
| 186 layer_impl_tree_root->layer_tree_impl()->property_trees()->scroll_tree; |
| 187 scroll_node = scroll_tree.Node(scrollbar_layer_impl->scroll_tree_index()); |
| 179 | 188 |
| 180 // 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 |
| 181 // may be handled in the compositor. | 190 // may be handled in the compositor. |
| 182 status = | 191 status = layer_tree_host_->host_impl()->TryScroll( |
| 183 scrollbar_layer_impl->TryScroll(gfx::PointF(), InputHandler::GESTURE); | 192 gfx::PointF(), InputHandler::GESTURE, scroll_tree, scroll_node); |
| 184 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 193 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
| 185 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable, | 194 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable, |
| 186 status.main_thread_scrolling_reasons); | 195 status.main_thread_scrolling_reasons); |
| 187 } | 196 } |
| 188 | 197 |
| 189 TEST_F(ScrollbarLayerTest, ScrollOffsetSynchronization) { | 198 TEST_F(ScrollbarLayerTest, ScrollOffsetSynchronization) { |
| 190 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); | 199 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); |
| 191 scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings()); | 200 scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings()); |
| 192 scoped_refptr<Layer> scroll_layer = Layer::Create(layer_settings()); | 201 scoped_refptr<Layer> scroll_layer = Layer::Create(layer_settings()); |
| 193 scoped_refptr<Layer> content_layer = Layer::Create(layer_settings()); | 202 scoped_refptr<Layer> content_layer = Layer::Create(layer_settings()); |
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1012 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); | 1021 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); |
| 1013 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); | 1022 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); |
| 1014 | 1023 |
| 1015 // Horizontal Scrollbars. | 1024 // Horizontal Scrollbars. |
| 1016 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); | 1025 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); |
| 1017 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); | 1026 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); |
| 1018 } | 1027 } |
| 1019 | 1028 |
| 1020 } // namespace | 1029 } // namespace |
| 1021 } // namespace cc | 1030 } // namespace cc |
| OLD | NEW |