OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1124 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 1124 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
1125 host_impl_->ScrollEnd(); | 1125 host_impl_->ScrollEnd(); |
1126 | 1126 |
1127 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1127 scoped_ptr<ScrollAndScaleSet> scroll_info = |
1128 host_impl_->ProcessScrollDeltas(); | 1128 host_impl_->ProcessScrollDeltas(); |
1129 ExpectContains(*scroll_info.get(), scroll_layer->id(), | 1129 ExpectContains(*scroll_info.get(), scroll_layer->id(), |
1130 gfx::Vector2d(0, scroll_delta.y() / page_scale_delta)); | 1130 gfx::Vector2d(0, scroll_delta.y() / page_scale_delta)); |
1131 } | 1131 } |
1132 } | 1132 } |
1133 | 1133 |
| 1134 TEST_F(LayerTreeHostImplTest, ImplPinchZoomWheelBubbleBetweenViewports) { |
| 1135 LayerImpl* inner_scroll_layer = |
| 1136 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 1137 |
| 1138 // Adjust the content layer to be larger than the outer viewport container so |
| 1139 // that we get scrolling in both viewports. |
| 1140 LayerImpl* content_layer = |
| 1141 host_impl_->OuterViewportScrollLayer()->children().back(); |
| 1142 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
| 1143 LayerImpl* inner_clip_layer = |
| 1144 host_impl_->InnerViewportScrollLayer()->parent()->parent(); |
| 1145 inner_clip_layer->SetBounds(gfx::Size(100, 100)); |
| 1146 inner_clip_layer->SetContentBounds(gfx::Size(100, 100)); |
| 1147 outer_scroll_layer->SetBounds(gfx::Size(200, 200)); |
| 1148 outer_scroll_layer->SetContentBounds(gfx::Size(200, 200)); |
| 1149 content_layer->SetBounds(gfx::Size(200, 200)); |
| 1150 content_layer->SetContentBounds(gfx::Size(200, 200)); |
| 1151 |
| 1152 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 1153 |
| 1154 DrawFrame(); |
| 1155 |
| 1156 // Zoom into the page by a 2X factor |
| 1157 float min_page_scale = 1.f, max_page_scale = 4.f; |
| 1158 float page_scale_factor = 2.f; |
| 1159 host_impl_->active_tree()->PushPageScaleFromMainThread( |
| 1160 page_scale_factor, min_page_scale, max_page_scale); |
| 1161 host_impl_->SetPageScaleOnActiveTree(page_scale_factor); |
| 1162 |
| 1163 // Scroll by a small amount, there should be no bubbling up to the inner |
| 1164 // viewport. |
| 1165 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::WHEEL); |
| 1166 host_impl_->ScrollBy(gfx::Point(0, 0), gfx::Vector2dF(10.f, 20.f)); |
| 1167 host_impl_->ScrollEnd(); |
| 1168 |
| 1169 EXPECT_VECTOR_EQ( |
| 1170 gfx::Vector2dF(5, 10), |
| 1171 outer_scroll_layer->CurrentScrollOffset()); |
| 1172 EXPECT_VECTOR_EQ( |
| 1173 gfx::Vector2dF(), |
| 1174 inner_scroll_layer->CurrentScrollOffset()); |
| 1175 |
| 1176 // Scroll by the outer viewport's max scroll extent, there the remainder |
| 1177 // should bubble up to the inner viewport. |
| 1178 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::WHEEL); |
| 1179 host_impl_->ScrollBy(gfx::Point(0, 0), gfx::Vector2dF(200.f, 200.f)); |
| 1180 host_impl_->ScrollEnd(); |
| 1181 |
| 1182 EXPECT_VECTOR_EQ( |
| 1183 gfx::Vector2dF(100, 100), |
| 1184 outer_scroll_layer->CurrentScrollOffset()); |
| 1185 EXPECT_VECTOR_EQ( |
| 1186 gfx::Vector2dF(5, 10), |
| 1187 inner_scroll_layer->CurrentScrollOffset()); |
| 1188 |
| 1189 // Scroll by the inner viewport's max scroll extent, it should all go to the |
| 1190 // inner viewport. |
| 1191 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::WHEEL); |
| 1192 host_impl_->ScrollBy(gfx::Point(0, 0), gfx::Vector2dF(90.f, 80.f)); |
| 1193 host_impl_->ScrollEnd(); |
| 1194 |
| 1195 EXPECT_VECTOR_EQ( |
| 1196 gfx::Vector2dF(100, 100), |
| 1197 outer_scroll_layer->CurrentScrollOffset()); |
| 1198 EXPECT_VECTOR_EQ( |
| 1199 gfx::Vector2dF(50, 50), |
| 1200 inner_scroll_layer->CurrentScrollOffset()); |
| 1201 } |
| 1202 |
1134 TEST_F(LayerTreeHostImplTest, ScrollWithSwapPromises) { | 1203 TEST_F(LayerTreeHostImplTest, ScrollWithSwapPromises) { |
1135 ui::LatencyInfo latency_info; | 1204 ui::LatencyInfo latency_info; |
1136 latency_info.trace_id = 1234; | 1205 latency_info.trace_id = 1234; |
1137 scoped_ptr<SwapPromise> swap_promise( | 1206 scoped_ptr<SwapPromise> swap_promise( |
1138 new LatencyInfoSwapPromise(latency_info)); | 1207 new LatencyInfoSwapPromise(latency_info)); |
1139 | 1208 |
1140 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1209 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
1141 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 1210 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
1142 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 1211 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
1143 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 1212 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
(...skipping 6625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7769 | 7838 |
7770 host_impl_->SetHasGpuRasterizationTrigger(false); | 7839 host_impl_->SetHasGpuRasterizationTrigger(false); |
7771 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 7840 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
7772 EXPECT_EQ(GpuRasterizationStatus::ON_FORCED, | 7841 EXPECT_EQ(GpuRasterizationStatus::ON_FORCED, |
7773 host_impl_->gpu_rasterization_status()); | 7842 host_impl_->gpu_rasterization_status()); |
7774 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 7843 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
7775 } | 7844 } |
7776 | 7845 |
7777 } // namespace | 7846 } // namespace |
7778 } // namespace cc | 7847 } // namespace cc |
OLD | NEW |