Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 1805343006: cc: Impl thread scroll on ScrollNode instead of LayerImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve comments Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 1124
1125 DrawFrame(); 1125 DrawFrame();
1126 1126
1127 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 1127 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
1128 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 1128 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
1129 InputHandler::WHEEL) 1129 InputHandler::WHEEL)
1130 .thread); 1130 .thread);
1131 1131
1132 // Trying to scroll if not user_scrollable_vertical will fail. 1132 // Trying to scroll if not user_scrollable_vertical will fail.
1133 host_impl_->InnerViewportScrollLayer()->set_user_scrollable_vertical(false); 1133 host_impl_->InnerViewportScrollLayer()->set_user_scrollable_vertical(false);
1134 SetNeedsRebuildPropertyTrees();
1135 DrawFrame();
1134 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage( 1136 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage(
1135 gfx::Point(), SCROLL_FORWARD)); 1137 gfx::Point(), SCROLL_FORWARD));
1136 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage( 1138 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage(
1137 gfx::Point(), SCROLL_BACKWARD)); 1139 gfx::Point(), SCROLL_BACKWARD));
1138 1140
1139 host_impl_->InnerViewportScrollLayer()->set_user_scrollable_vertical(true); 1141 host_impl_->InnerViewportScrollLayer()->set_user_scrollable_vertical(true);
1142 SetNeedsRebuildPropertyTrees();
1143 DrawFrame();
1140 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( 1144 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage(
1141 gfx::Point(), SCROLL_FORWARD)); 1145 gfx::Point(), SCROLL_FORWARD));
1142 EXPECT_FLOAT_EQ(875.f, 1146 EXPECT_FLOAT_EQ(875.f,
1143 ScrollDelta(host_impl_->InnerViewportScrollLayer()).y()); 1147 ScrollDelta(host_impl_->InnerViewportScrollLayer()).y());
1144 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( 1148 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage(
1145 gfx::Point(), SCROLL_BACKWARD)); 1149 gfx::Point(), SCROLL_BACKWARD));
1146 } 1150 }
1147 1151
1148 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { 1152 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) {
1149 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); 1153 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200));
(...skipping 21 matching lines...) Expand all
1171 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); 1175 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset());
1172 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->CurrentScrollOffset()); 1176 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->CurrentScrollOffset());
1173 1177
1174 gfx::Vector2dF scroll_delta(10, 10); 1178 gfx::Vector2dF scroll_delta(10, 10);
1175 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); 1179 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get());
1176 host_impl_->ScrollEnd(EndState().get()); 1180 host_impl_->ScrollEnd(EndState().get());
1177 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); 1181 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset());
1178 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); 1182 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset());
1179 1183
1180 overflow->set_user_scrollable_horizontal(false); 1184 overflow->set_user_scrollable_horizontal(false);
1185 SetNeedsRebuildPropertyTrees();
1186 DrawFrame();
1181 1187
1182 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 1188 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
1183 host_impl_->ScrollBegin(BeginState(scroll_position).get(), 1189 host_impl_->ScrollBegin(BeginState(scroll_position).get(),
1184 InputHandler::WHEEL) 1190 InputHandler::WHEEL)
1185 .thread); 1191 .thread);
1186 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); 1192 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset());
1187 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); 1193 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset());
1188 1194
1189 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); 1195 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get());
1190 host_impl_->ScrollEnd(EndState().get()); 1196 host_impl_->ScrollEnd(EndState().get());
1191 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset()); 1197 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset());
1192 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); 1198 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset());
1193 1199
1194 overflow->set_user_scrollable_vertical(false); 1200 overflow->set_user_scrollable_vertical(false);
1201 SetNeedsRebuildPropertyTrees();
1202 DrawFrame();
1195 1203
1196 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 1204 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
1197 host_impl_->ScrollBegin(BeginState(scroll_position).get(), 1205 host_impl_->ScrollBegin(BeginState(scroll_position).get(),
1198 InputHandler::WHEEL) 1206 InputHandler::WHEEL)
1199 .thread); 1207 .thread);
1200 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset()); 1208 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset());
1201 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); 1209 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset());
1202 1210
1203 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); 1211 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get());
1204 host_impl_->ScrollEnd(EndState().get()); 1212 host_impl_->ScrollEnd(EndState().get());
(...skipping 7856 matching lines...) Expand 10 before | Expand all | Expand 10 after
9061 host_impl_->ScrollEnd(EndState().get()); 9069 host_impl_->ScrollEnd(EndState().get());
9062 } 9070 }
9063 9071
9064 TEST_F(LayerTreeHostImplVirtualViewportTest, 9072 TEST_F(LayerTreeHostImplVirtualViewportTest,
9065 NoOverscrollWhenInnerViewportCantScroll) { 9073 NoOverscrollWhenInnerViewportCantScroll) {
9066 InputHandlerScrollResult scroll_result; 9074 InputHandlerScrollResult scroll_result;
9067 gfx::Size content_size = gfx::Size(100, 160); 9075 gfx::Size content_size = gfx::Size(100, 160);
9068 gfx::Size outer_viewport = gfx::Size(50, 80); 9076 gfx::Size outer_viewport = gfx::Size(50, 80);
9069 gfx::Size inner_viewport = gfx::Size(25, 40); 9077 gfx::Size inner_viewport = gfx::Size(25, 40);
9070 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); 9078 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport);
9071 SetNeedsRebuildPropertyTrees();
9072 DrawFrame();
9073
9074 // Make inner viewport unscrollable. 9079 // Make inner viewport unscrollable.
9075 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); 9080 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer();
9076 inner_scroll->set_user_scrollable_horizontal(false); 9081 inner_scroll->set_user_scrollable_horizontal(false);
9077 inner_scroll->set_user_scrollable_vertical(false); 9082 inner_scroll->set_user_scrollable_vertical(false);
9083 SetNeedsRebuildPropertyTrees();
9084 DrawFrame();
9078 9085
9079 // Ensure inner viewport doesn't react to scrolls (test it's unscrollable). 9086 // Ensure inner viewport doesn't react to scrolls (test it's unscrollable).
9080 EXPECT_VECTOR_EQ(gfx::Vector2dF(), inner_scroll->CurrentScrollOffset()); 9087 EXPECT_VECTOR_EQ(gfx::Vector2dF(), inner_scroll->CurrentScrollOffset());
9081 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 9088 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
9082 host_impl_ 9089 host_impl_
9083 ->ScrollBegin(BeginState(gfx::Point()).get(), 9090 ->ScrollBegin(BeginState(gfx::Point()).get(),
9084 InputHandler::TOUCHSCREEN) 9091 InputHandler::TOUCHSCREEN)
9085 .thread); 9092 .thread);
9086 scroll_result = host_impl_->ScrollBy( 9093 scroll_result = host_impl_->ScrollBy(
9087 UpdateState(gfx::Point(), gfx::Vector2dF(0, 100)).get()); 9094 UpdateState(gfx::Point(), gfx::Vector2dF(0, 100)).get());
(...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after
10350 // There should not be any jitter measured till we hit the fixed point hits 10357 // There should not be any jitter measured till we hit the fixed point hits
10351 // threshold. 10358 // threshold.
10352 float expected_jitter = 10359 float expected_jitter =
10353 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; 10360 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0;
10354 EXPECT_EQ(jitter, expected_jitter); 10361 EXPECT_EQ(jitter, expected_jitter);
10355 } 10362 }
10356 } 10363 }
10357 10364
10358 } // namespace 10365 } // namespace
10359 } // namespace cc 10366 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698