Chromium Code Reviews| 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/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "cc/animation/animation_host.h" | 10 #include "cc/animation/animation_host.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 scrollbar->Orientation(), thumb_thickness, track_start, | 138 scrollbar->Orientation(), thumb_thickness, track_start, |
| 139 kIsLeftSideVerticalScrollbar, child1->id()); | 139 kIsLeftSideVerticalScrollbar, child1->id()); |
| 140 } else { | 140 } else { |
| 141 child2 = | 141 child2 = |
| 142 PaintedScrollbarLayer::Create(std::move(scrollbar), child1->id()); | 142 PaintedScrollbarLayer::Create(std::move(scrollbar), child1->id()); |
| 143 } | 143 } |
| 144 layer_tree_root->AddChild(child1); | 144 layer_tree_root->AddChild(child1); |
| 145 layer_tree_root->InsertChild(child2, reverse_order ? 0 : 1); | 145 layer_tree_root->InsertChild(child2, reverse_order ? 0 : 1); |
| 146 scrollbar_layer_id_ = reverse_order ? child1->id() : child2->id(); | 146 scrollbar_layer_id_ = reverse_order ? child1->id() : child2->id(); |
| 147 host->SetRootLayer(layer_tree_root); | 147 host->SetRootLayer(layer_tree_root); |
| 148 host->BuildPropertyTreesForTesting(); | |
| 148 return host->CommitAndCreateLayerImplTree(); | 149 return host->CommitAndCreateLayerImplTree(); |
| 149 } | 150 } |
| 150 | 151 |
| 151 protected: | 152 protected: |
| 152 FakeLayerTreeHostClient fake_client_; | 153 FakeLayerTreeHostClient fake_client_; |
| 153 TestTaskGraphRunner task_graph_runner_; | 154 TestTaskGraphRunner task_graph_runner_; |
| 154 LayerTreeSettings layer_tree_settings_; | 155 LayerTreeSettings layer_tree_settings_; |
| 155 std::unique_ptr<FakeResourceTrackingLayerTreeHost> layer_tree_host_; | 156 std::unique_ptr<FakeResourceTrackingLayerTreeHost> layer_tree_host_; |
| 156 int scrollbar_layer_id_; | 157 int scrollbar_layer_id_; |
| 157 }; | 158 }; |
| 158 | 159 |
| 159 TEST_F(ScrollbarLayerTest, ShouldScrollNonOverlayOnMainThread) { | 160 TEST_F(ScrollbarLayerTest, ShouldScrollNonOverlayOnMainThread) { |
| 160 // Create and attach a non-overlay scrollbar. | 161 // Create and attach a non-overlay scrollbar. |
| 161 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar); | 162 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar); |
| 162 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( | 163 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( |
| 163 layer_tree_host_.get(), std::move(scrollbar), false, false, 0, 0); | 164 layer_tree_host_.get(), std::move(scrollbar), false, false, 0, 0); |
| 164 PaintedScrollbarLayerImpl* scrollbar_layer_impl = | 165 PaintedScrollbarLayerImpl* scrollbar_layer_impl = |
| 165 static_cast<PaintedScrollbarLayerImpl*>( | 166 static_cast<PaintedScrollbarLayerImpl*>( |
| 166 layer_impl_tree_root->layer_tree_impl()->LayerById( | 167 layer_impl_tree_root->layer_tree_impl()->LayerById( |
| 167 scrollbar_layer_id_)); | 168 scrollbar_layer_id_)); |
| 168 layer_impl_tree_root->layer_tree_impl() | |
| 169 ->BuildLayerListAndPropertyTreesForTesting(); | |
|
jaydasika
2016/06/09 05:07:54
Can't build property trees on compositor, they sho
| |
| 170 ScrollTree& scroll_tree = | 169 ScrollTree& scroll_tree = |
| 171 layer_impl_tree_root->layer_tree_impl()->property_trees()->scroll_tree; | 170 layer_impl_tree_root->layer_tree_impl()->property_trees()->scroll_tree; |
| 172 ScrollNode* scroll_node = | 171 ScrollNode* scroll_node = |
| 173 scroll_tree.Node(scrollbar_layer_impl->scroll_tree_index()); | 172 scroll_tree.Node(scrollbar_layer_impl->scroll_tree_index()); |
| 174 | 173 |
| 175 // When the scrollbar is not an overlay scrollbar, the scroll should be | 174 // When the scrollbar is not an overlay scrollbar, the scroll should be |
| 176 // responded to on the main thread as the compositor does not yet implement | 175 // responded to on the main thread as the compositor does not yet implement |
| 177 // scrollbar scrolling. | 176 // scrollbar scrolling. |
| 178 InputHandler::ScrollStatus status = layer_tree_host_->host_impl()->TryScroll( | 177 InputHandler::ScrollStatus status = layer_tree_host_->host_impl()->TryScroll( |
| 179 gfx::PointF(), InputHandler::TOUCHSCREEN, scroll_tree, scroll_node); | 178 gfx::PointF(), InputHandler::TOUCHSCREEN, scroll_tree, scroll_node); |
| 180 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 179 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
| 181 EXPECT_EQ(MainThreadScrollingReason::kScrollbarScrolling, | 180 EXPECT_EQ(MainThreadScrollingReason::kScrollbarScrolling, |
| 182 status.main_thread_scrolling_reasons); | 181 status.main_thread_scrolling_reasons); |
| 183 | 182 |
| 184 // Create and attach an overlay scrollbar. | 183 // Create and attach an overlay scrollbar. |
| 185 scrollbar.reset(new FakeScrollbar(false, false, true)); | 184 scrollbar.reset(new FakeScrollbar(false, false, true)); |
| 186 | 185 |
| 187 layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( | 186 layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( |
| 188 layer_tree_host_.get(), std::move(scrollbar), false, false, 0, 0); | 187 layer_tree_host_.get(), std::move(scrollbar), false, false, 0, 0); |
| 189 scrollbar_layer_impl = static_cast<PaintedScrollbarLayerImpl*>( | 188 scrollbar_layer_impl = static_cast<PaintedScrollbarLayerImpl*>( |
| 190 layer_impl_tree_root->layer_tree_impl()->LayerById(scrollbar_layer_id_)); | 189 layer_impl_tree_root->layer_tree_impl()->LayerById(scrollbar_layer_id_)); |
| 191 layer_impl_tree_root->layer_tree_impl() | |
| 192 ->BuildLayerListAndPropertyTreesForTesting(); | |
| 193 scroll_tree = | 190 scroll_tree = |
| 194 layer_impl_tree_root->layer_tree_impl()->property_trees()->scroll_tree; | 191 layer_impl_tree_root->layer_tree_impl()->property_trees()->scroll_tree; |
| 195 scroll_node = scroll_tree.Node(scrollbar_layer_impl->scroll_tree_index()); | 192 scroll_node = scroll_tree.Node(scrollbar_layer_impl->scroll_tree_index()); |
| 196 | 193 |
| 197 // The user shouldn't be able to drag an overlay scrollbar and the scroll | 194 // The user shouldn't be able to drag an overlay scrollbar and the scroll |
| 198 // may be handled in the compositor. | 195 // may be handled in the compositor. |
| 199 status = layer_tree_host_->host_impl()->TryScroll( | 196 status = layer_tree_host_->host_impl()->TryScroll( |
| 200 gfx::PointF(), InputHandler::TOUCHSCREEN, scroll_tree, scroll_node); | 197 gfx::PointF(), InputHandler::TOUCHSCREEN, scroll_tree, scroll_node); |
| 201 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 198 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
| 202 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable, | 199 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable, |
| (...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1149 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); | 1146 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); |
| 1150 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); | 1147 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); |
| 1151 | 1148 |
| 1152 // Horizontal Scrollbars. | 1149 // Horizontal Scrollbars. |
| 1153 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); | 1150 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); |
| 1154 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); | 1151 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); |
| 1155 } | 1152 } |
| 1156 | 1153 |
| 1157 } // namespace | 1154 } // namespace |
| 1158 } // namespace cc | 1155 } // namespace cc |
| OLD | NEW |