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

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

Issue 2554913002: Prevent overlay scrollbars expand or hover together (Closed)
Patch Set: add ScrollbarAnimationControllerThinningTest Created 4 years 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
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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 layer_tree_impl->BuildPropertyTreesForTesting(); 355 layer_tree_impl->BuildPropertyTreesForTesting();
356 layer_tree_impl->SetViewportLayersFromIds( 356 layer_tree_impl->SetViewportLayersFromIds(
357 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, 357 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId,
358 kOuterViewportScrollLayerId); 358 kOuterViewportScrollLayerId);
359 359
360 layer_tree_impl->DidBecomeActive(); 360 layer_tree_impl->DidBecomeActive();
361 return layer_tree_impl->InnerViewportScrollLayer(); 361 return layer_tree_impl->InnerViewportScrollLayer();
362 } 362 }
363 363
364 LayerImpl* SetupScrollAndContentsLayers(const gfx::Size& content_size) { 364 LayerImpl* SetupScrollAndContentsLayers(const gfx::Size& content_size) {
365 LayerImpl* scroll_layer = CreateScrollAndContentsLayers( 365 LayerImpl* scroll_layer =
366 host_impl_->active_tree(), content_size); 366 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size);
367 host_impl_->active_tree()->DidBecomeActive(); 367 host_impl_->active_tree()->DidBecomeActive();
368 return scroll_layer; 368 return scroll_layer;
369 } 369 }
370 370
371 // Sets up a typical virtual viewport setup with one child content layer. 371 // Sets up a typical virtual viewport setup with one child content layer.
372 // Returns a pointer to the content layer. 372 // Returns a pointer to the content layer.
373 LayerImpl* CreateBasicVirtualViewportLayers(const gfx::Size& viewport_size, 373 LayerImpl* CreateBasicVirtualViewportLayers(const gfx::Size& viewport_size,
374 const gfx::Size& content_size) { 374 const gfx::Size& content_size) {
375 // CreateScrollAndContentsLayers makes the outer viewport unscrollable and 375 // CreateScrollAndContentsLayers makes the outer viewport unscrollable and
376 // the inner a different size from the outer. We'll reuse its layer 376 // the inner a different size from the outer. We'll reuse its layer
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, 741 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
742 status.main_thread_scrolling_reasons); 742 status.main_thread_scrolling_reasons);
743 } 743 }
744 744
745 TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) { 745 TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) {
746 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); 746 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100));
747 host_impl_->SetViewportSize(gfx::Size(50, 50)); 747 host_impl_->SetViewportSize(gfx::Size(50, 50));
748 DrawFrame(); 748 DrawFrame();
749 749
750 // We should not crash if the tree is replaced while we are scrolling. 750 // We should not crash if the tree is replaced while we are scrolling.
751 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 751 EXPECT_EQ(
752 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 752 InputHandler::SCROLL_ON_IMPL_THREAD,
753 InputHandler::WHEEL) 753 host_impl_
754 .thread); 754 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL)
755 .thread);
755 host_impl_->active_tree()->DetachLayers(); 756 host_impl_->active_tree()->DetachLayers();
756 757
757 scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); 758 scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100));
758 759
759 // We should still be scrolling, because the scrolled layer also exists in the 760 // We should still be scrolling, because the scrolled layer also exists in the
760 // new tree. 761 // new tree.
761 gfx::Vector2d scroll_delta(0, 10); 762 gfx::Vector2d scroll_delta(0, 10);
762 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 763 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
763 host_impl_->ScrollEnd(EndState().get()); 764 host_impl_->ScrollEnd(EndState().get());
764 std::unique_ptr<ScrollAndScaleSet> scroll_info = 765 std::unique_ptr<ScrollAndScaleSet> scroll_info =
765 host_impl_->ProcessScrollDeltas(); 766 host_impl_->ProcessScrollDeltas();
766 EXPECT_TRUE( 767 EXPECT_TRUE(
767 ScrollInfoContains(*scroll_info, scroll_layer->id(), scroll_delta)); 768 ScrollInfoContains(*scroll_info, scroll_layer->id(), scroll_delta));
768 } 769 }
769 770
770 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) { 771 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) {
771 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 772 SetupScrollAndContentsLayers(gfx::Size(100, 100));
772 host_impl_->SetViewportSize(gfx::Size(50, 50)); 773 host_impl_->SetViewportSize(gfx::Size(50, 50));
773 DrawFrame(); 774 DrawFrame();
774 775
775 // Wheel handlers determine whether mouse events block scroll. 776 // Wheel handlers determine whether mouse events block scroll.
776 host_impl_->active_tree()->set_event_listener_properties( 777 host_impl_->active_tree()->set_event_listener_properties(
777 EventListenerClass::kMouseWheel, EventListenerProperties::kBlocking); 778 EventListenerClass::kMouseWheel, EventListenerProperties::kBlocking);
778 EXPECT_EQ( 779 EXPECT_EQ(
779 EventListenerProperties::kBlocking, 780 EventListenerProperties::kBlocking,
780 host_impl_->GetEventListenerProperties(EventListenerClass::kMouseWheel)); 781 host_impl_->GetEventListenerProperties(EventListenerClass::kMouseWheel));
781 782
782 // But they don't influence the actual handling of the scroll gestures. 783 // But they don't influence the actual handling of the scroll gestures.
783 InputHandler::ScrollStatus status = 784 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
784 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 785 BeginState(gfx::Point()).get(), InputHandler::WHEEL);
785 InputHandler::WHEEL);
786 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 786 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
787 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, 787 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
788 status.main_thread_scrolling_reasons); 788 status.main_thread_scrolling_reasons);
789 host_impl_->ScrollEnd(EndState().get()); 789 host_impl_->ScrollEnd(EndState().get());
790 } 790 }
791 791
792 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) { 792 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) {
793 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); 793 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100));
794 host_impl_->SetViewportSize(gfx::Size(50, 50)); 794 host_impl_->SetViewportSize(gfx::Size(50, 50));
795 DrawFrame(); 795 DrawFrame();
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 DrawFrame(); 1123 DrawFrame();
1124 1124
1125 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 1125 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
1126 BeginState(gfx::Point()).get(), InputHandler::TOUCHSCREEN); 1126 BeginState(gfx::Point()).get(), InputHandler::TOUCHSCREEN);
1127 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 1127 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
1128 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, 1128 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
1129 status.main_thread_scrolling_reasons); 1129 status.main_thread_scrolling_reasons);
1130 1130
1131 // Trying to scroll to the left/top will not succeed. 1131 // Trying to scroll to the left/top will not succeed.
1132 EXPECT_FALSE( 1132 EXPECT_FALSE(
1133 host_impl_->ScrollBy( 1133 host_impl_
1134 UpdateState(gfx::Point(), gfx::Vector2d(-10, 0)).get()) 1134 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(-10, 0)).get())
1135 .did_scroll); 1135 .did_scroll);
1136 EXPECT_FALSE( 1136 EXPECT_FALSE(
1137 host_impl_->ScrollBy( 1137 host_impl_
1138 UpdateState(gfx::Point(), gfx::Vector2d(0, -10)).get()) 1138 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, -10)).get())
1139 .did_scroll); 1139 .did_scroll);
1140 EXPECT_FALSE( 1140 EXPECT_FALSE(
1141 host_impl_->ScrollBy( 1141 host_impl_
1142 UpdateState(gfx::Point(), gfx::Vector2d(-10, -10)).get()) 1142 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(-10, -10)).get())
1143 .did_scroll); 1143 .did_scroll);
1144 1144
1145 // Scrolling to the right/bottom will succeed. 1145 // Scrolling to the right/bottom will succeed.
1146 EXPECT_TRUE( 1146 EXPECT_TRUE(
1147 host_impl_->ScrollBy( 1147 host_impl_
1148 UpdateState(gfx::Point(), gfx::Vector2d(10, 0)).get()) 1148 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(10, 0)).get())
1149 .did_scroll); 1149 .did_scroll);
1150 EXPECT_TRUE( 1150 EXPECT_TRUE(
1151 host_impl_->ScrollBy( 1151 host_impl_
1152 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()) 1152 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get())
1153 .did_scroll); 1153 .did_scroll);
1154 EXPECT_TRUE( 1154 EXPECT_TRUE(
1155 host_impl_->ScrollBy( 1155 host_impl_
1156 UpdateState(gfx::Point(), gfx::Vector2d(10, 10)).get()) 1156 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(10, 10)).get())
1157 .did_scroll); 1157 .did_scroll);
1158 1158
1159 // Scrolling to left/top will now succeed. 1159 // Scrolling to left/top will now succeed.
1160 EXPECT_TRUE( 1160 EXPECT_TRUE(
1161 host_impl_->ScrollBy( 1161 host_impl_
1162 UpdateState(gfx::Point(), gfx::Vector2d(-10, 0)).get()) 1162 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(-10, 0)).get())
1163 .did_scroll); 1163 .did_scroll);
1164 EXPECT_TRUE( 1164 EXPECT_TRUE(
1165 host_impl_->ScrollBy( 1165 host_impl_
1166 UpdateState(gfx::Point(), gfx::Vector2d(0, -10)).get()) 1166 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, -10)).get())
1167 .did_scroll); 1167 .did_scroll);
1168 EXPECT_TRUE( 1168 EXPECT_TRUE(
1169 host_impl_->ScrollBy( 1169 host_impl_
1170 UpdateState(gfx::Point(), gfx::Vector2d(-10, -10)).get()) 1170 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(-10, -10)).get())
1171 .did_scroll); 1171 .did_scroll);
1172 1172
1173 // Scrolling diagonally against an edge will succeed. 1173 // Scrolling diagonally against an edge will succeed.
1174 EXPECT_TRUE( 1174 EXPECT_TRUE(
1175 host_impl_->ScrollBy( 1175 host_impl_
1176 UpdateState(gfx::Point(), gfx::Vector2d(10, -10)).get()) 1176 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(10, -10)).get())
1177 .did_scroll); 1177 .did_scroll);
1178 EXPECT_TRUE( 1178 EXPECT_TRUE(
1179 host_impl_->ScrollBy( 1179 host_impl_
1180 UpdateState(gfx::Point(), gfx::Vector2d(-10, 0)).get()) 1180 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(-10, 0)).get())
1181 .did_scroll); 1181 .did_scroll);
1182 EXPECT_TRUE( 1182 EXPECT_TRUE(
1183 host_impl_->ScrollBy( 1183 host_impl_
1184 UpdateState(gfx::Point(), gfx::Vector2d(-10, 10)).get()) 1184 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(-10, 10)).get())
1185 .did_scroll); 1185 .did_scroll);
1186 1186
1187 // Trying to scroll more than the available space will also succeed. 1187 // Trying to scroll more than the available space will also succeed.
1188 EXPECT_TRUE( 1188 EXPECT_TRUE(
1189 host_impl_->ScrollBy( 1189 host_impl_
1190 UpdateState(gfx::Point(), gfx::Vector2d(5000, 5000)).get()) 1190 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(5000, 5000)).get())
1191 .did_scroll); 1191 .did_scroll);
1192 } 1192 }
1193 1193
1194 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { 1194 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) {
1195 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); 1195 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200));
1196 host_impl_->SetViewportSize(gfx::Size(100, 100)); 1196 host_impl_->SetViewportSize(gfx::Size(100, 100));
1197 1197
1198 gfx::Size overflow_size(400, 400); 1198 gfx::Size overflow_size(400, 400);
1199 ASSERT_EQ(1u, scroll_layer->test_properties()->children.size()); 1199 ASSERT_EQ(1u, scroll_layer->test_properties()->children.size());
1200 LayerImpl* overflow = scroll_layer->test_properties()->children[0]; 1200 LayerImpl* overflow = scroll_layer->test_properties()->children[0];
1201 overflow->SetBounds(overflow_size); 1201 overflow->SetBounds(overflow_size);
1202 overflow->SetScrollClipLayer( 1202 overflow->SetScrollClipLayer(
1203 scroll_layer->test_properties()->parent->test_properties()->parent->id()); 1203 scroll_layer->test_properties()->parent->test_properties()->parent->id());
1204 overflow->layer_tree_impl() 1204 overflow->layer_tree_impl()
1205 ->property_trees() 1205 ->property_trees()
1206 ->scroll_tree.UpdateScrollOffsetBaseForTesting(overflow->id(), 1206 ->scroll_tree.UpdateScrollOffsetBaseForTesting(overflow->id(),
1207 gfx::ScrollOffset()); 1207 gfx::ScrollOffset());
1208 overflow->SetPosition(gfx::PointF()); 1208 overflow->SetPosition(gfx::PointF());
1209 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 1209 host_impl_->active_tree()->BuildPropertyTreesForTesting();
1210 1210
1211 DrawFrame(); 1211 DrawFrame();
1212 gfx::Point scroll_position(10, 10); 1212 gfx::Point scroll_position(10, 10);
1213 1213
1214 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 1214 EXPECT_EQ(
1215 host_impl_->ScrollBegin(BeginState(scroll_position).get(), 1215 InputHandler::SCROLL_ON_IMPL_THREAD,
1216 InputHandler::WHEEL) 1216 host_impl_
1217 .thread); 1217 ->ScrollBegin(BeginState(scroll_position).get(), InputHandler::WHEEL)
1218 .thread);
1218 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); 1219 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset());
1219 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->CurrentScrollOffset()); 1220 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->CurrentScrollOffset());
1220 1221
1221 gfx::Vector2dF scroll_delta(10, 10); 1222 gfx::Vector2dF scroll_delta(10, 10);
1222 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); 1223 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get());
1223 host_impl_->ScrollEnd(EndState().get()); 1224 host_impl_->ScrollEnd(EndState().get());
1224 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); 1225 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset());
1225 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); 1226 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset());
1226 1227
1227 overflow->set_user_scrollable_horizontal(false); 1228 overflow->set_user_scrollable_horizontal(false);
1228 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 1229 host_impl_->active_tree()->BuildPropertyTreesForTesting();
1229 1230
1230 DrawFrame(); 1231 DrawFrame();
1231 1232
1232 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 1233 EXPECT_EQ(
1233 host_impl_->ScrollBegin(BeginState(scroll_position).get(), 1234 InputHandler::SCROLL_ON_IMPL_THREAD,
1234 InputHandler::WHEEL) 1235 host_impl_
1235 .thread); 1236 ->ScrollBegin(BeginState(scroll_position).get(), InputHandler::WHEEL)
1237 .thread);
1236 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); 1238 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset());
1237 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); 1239 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset());
1238 1240
1239 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); 1241 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get());
1240 host_impl_->ScrollEnd(EndState().get()); 1242 host_impl_->ScrollEnd(EndState().get());
1241 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset()); 1243 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset());
1242 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); 1244 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset());
1243 1245
1244 overflow->set_user_scrollable_vertical(false); 1246 overflow->set_user_scrollable_vertical(false);
1245 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 1247 host_impl_->active_tree()->BuildPropertyTreesForTesting();
1246 DrawFrame(); 1248 DrawFrame();
1247 1249
1248 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 1250 EXPECT_EQ(
1249 host_impl_->ScrollBegin(BeginState(scroll_position).get(), 1251 InputHandler::SCROLL_ON_IMPL_THREAD,
1250 InputHandler::WHEEL) 1252 host_impl_
1251 .thread); 1253 ->ScrollBegin(BeginState(scroll_position).get(), InputHandler::WHEEL)
1254 .thread);
1252 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset()); 1255 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset());
1253 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); 1256 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset());
1254 1257
1255 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); 1258 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get());
1256 host_impl_->ScrollEnd(EndState().get()); 1259 host_impl_->ScrollEnd(EndState().get());
1257 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), scroll_layer->CurrentScrollOffset()); 1260 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), scroll_layer->CurrentScrollOffset());
1258 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); 1261 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset());
1259 } 1262 }
1260 1263
1261 TEST_F(LayerTreeHostImplTest, AnimationSchedulingPendingTree) { 1264 TEST_F(LayerTreeHostImplTest, AnimationSchedulingPendingTree) {
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 float page_scale_delta = 2.f; 1647 float page_scale_delta = 2.f;
1645 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 1648 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
1646 InputHandler::TOUCHSCREEN); 1649 InputHandler::TOUCHSCREEN);
1647 host_impl_->PinchGestureBegin(); 1650 host_impl_->PinchGestureBegin();
1648 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); 1651 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point());
1649 host_impl_->PinchGestureEnd(); 1652 host_impl_->PinchGestureEnd();
1650 host_impl_->ScrollEnd(EndState().get()); 1653 host_impl_->ScrollEnd(EndState().get());
1651 1654
1652 gfx::Vector2d scroll_delta(0, 10); 1655 gfx::Vector2d scroll_delta(0, 10);
1653 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 1656 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
1654 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), 1657 host_impl_
1655 InputHandler::WHEEL) 1658 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(),
1659 InputHandler::WHEEL)
1656 .thread); 1660 .thread);
1657 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 1661 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
1658 host_impl_->ScrollEnd(EndState().get()); 1662 host_impl_->ScrollEnd(EndState().get());
1659 1663
1660 std::unique_ptr<ScrollAndScaleSet> scroll_info = 1664 std::unique_ptr<ScrollAndScaleSet> scroll_info =
1661 host_impl_->ProcessScrollDeltas(); 1665 host_impl_->ProcessScrollDeltas();
1662 EXPECT_TRUE(ScrollInfoContains( 1666 EXPECT_TRUE(ScrollInfoContains(
1663 *scroll_info.get(), scroll_layer->id(), 1667 *scroll_info.get(), scroll_layer->id(),
1664 gfx::Vector2d(0, scroll_delta.y() / page_scale_delta))); 1668 gfx::Vector2d(0, scroll_delta.y() / page_scale_delta)));
1665 } 1669 }
1666 } 1670 }
1667 1671
1668 TEST_F(LayerTreeHostImplTest, ViewportScrollOrder) { 1672 TEST_F(LayerTreeHostImplTest, ViewportScrollOrder) {
1669 LayerTreeSettings settings = DefaultSettings(); 1673 LayerTreeSettings settings = DefaultSettings();
1670 CreateHostImpl(settings, CreateCompositorFrameSink()); 1674 CreateHostImpl(settings, CreateCompositorFrameSink());
1671 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.25f, 4.f); 1675 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.25f, 4.f);
1672 1676
1673 const gfx::Size content_size(1000, 1000); 1677 const gfx::Size content_size(1000, 1000);
1674 const gfx::Size viewport_size(500, 500); 1678 const gfx::Size viewport_size(500, 500);
1675 CreateBasicVirtualViewportLayers(viewport_size, content_size); 1679 CreateBasicVirtualViewportLayers(viewport_size, content_size);
1676 1680
1677 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); 1681 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer();
1678 outer_scroll_layer->SetDrawsContent(true); 1682 outer_scroll_layer->SetDrawsContent(true);
1679 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); 1683 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer();
1680 inner_scroll_layer->SetDrawsContent(true); 1684 inner_scroll_layer->SetDrawsContent(true);
1681 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 1685 host_impl_->active_tree()->BuildPropertyTreesForTesting();
1682 1686
1683 EXPECT_VECTOR_EQ( 1687 EXPECT_VECTOR_EQ(gfx::Vector2dF(500, 500),
1684 gfx::Vector2dF(500, 500), 1688 outer_scroll_layer->MaxScrollOffset());
1685 outer_scroll_layer->MaxScrollOffset());
1686 1689
1687 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), 1690 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(),
1688 InputHandler::TOUCHSCREEN); 1691 InputHandler::TOUCHSCREEN);
1689 host_impl_->PinchGestureBegin(); 1692 host_impl_->PinchGestureBegin();
1690 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); 1693 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0));
1691 host_impl_->PinchGestureEnd(); 1694 host_impl_->PinchGestureEnd();
1692 host_impl_->ScrollEnd(EndState().get()); 1695 host_impl_->ScrollEnd(EndState().get());
1693 1696
1694 // Sanity check - we're zoomed in, starting from the origin. 1697 // Sanity check - we're zoomed in, starting from the origin.
1695 EXPECT_VECTOR_EQ( 1698 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0),
1696 gfx::Vector2dF(0, 0), 1699 outer_scroll_layer->CurrentScrollOffset());
1697 outer_scroll_layer->CurrentScrollOffset()); 1700 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0),
1698 EXPECT_VECTOR_EQ( 1701 inner_scroll_layer->CurrentScrollOffset());
1699 gfx::Vector2dF(0, 0),
1700 inner_scroll_layer->CurrentScrollOffset());
1701 1702
1702 // Scroll down - only the inner viewport should scroll. 1703 // Scroll down - only the inner viewport should scroll.
1703 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), 1704 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(),
1704 InputHandler::TOUCHSCREEN); 1705 InputHandler::TOUCHSCREEN);
1705 host_impl_->ScrollBy( 1706 host_impl_->ScrollBy(
1706 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(100.f, 100.f)).get()); 1707 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(100.f, 100.f)).get());
1707 host_impl_->ScrollEnd(EndState().get()); 1708 host_impl_->ScrollEnd(EndState().get());
1708 1709
1709 EXPECT_VECTOR_EQ( 1710 EXPECT_VECTOR_EQ(gfx::Vector2dF(50, 50),
1710 gfx::Vector2dF(50, 50), 1711 inner_scroll_layer->CurrentScrollOffset());
1711 inner_scroll_layer->CurrentScrollOffset()); 1712 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0),
1712 EXPECT_VECTOR_EQ( 1713 outer_scroll_layer->CurrentScrollOffset());
1713 gfx::Vector2dF(0, 0),
1714 outer_scroll_layer->CurrentScrollOffset());
1715 1714
1716 // Scroll down - outer viewport should start scrolling after the inner is at 1715 // Scroll down - outer viewport should start scrolling after the inner is at
1717 // its maximum. 1716 // its maximum.
1718 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), 1717 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(),
1719 InputHandler::TOUCHSCREEN); 1718 InputHandler::TOUCHSCREEN);
1720 host_impl_->ScrollBy( 1719 host_impl_->ScrollBy(
1721 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(1000.f, 1000.f)).get()); 1720 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(1000.f, 1000.f)).get());
1722 host_impl_->ScrollEnd(EndState().get()); 1721 host_impl_->ScrollEnd(EndState().get());
1723 1722
1724 EXPECT_VECTOR_EQ( 1723 EXPECT_VECTOR_EQ(gfx::Vector2dF(250, 250),
1725 gfx::Vector2dF(250, 250), 1724 inner_scroll_layer->CurrentScrollOffset());
1726 inner_scroll_layer->CurrentScrollOffset()); 1725 EXPECT_VECTOR_EQ(gfx::Vector2dF(300, 300),
1727 EXPECT_VECTOR_EQ( 1726 outer_scroll_layer->CurrentScrollOffset());
1728 gfx::Vector2dF(300, 300),
1729 outer_scroll_layer->CurrentScrollOffset());
1730 } 1727 }
1731 1728
1732 // Make sure scrolls smaller than a unit applied to the viewport don't get 1729 // Make sure scrolls smaller than a unit applied to the viewport don't get
1733 // dropped. crbug.com/539334. 1730 // dropped. crbug.com/539334.
1734 TEST_F(LayerTreeHostImplTest, ScrollViewportWithFractionalAmounts) { 1731 TEST_F(LayerTreeHostImplTest, ScrollViewportWithFractionalAmounts) {
1735 LayerTreeSettings settings = DefaultSettings(); 1732 LayerTreeSettings settings = DefaultSettings();
1736 CreateHostImpl(settings, CreateCompositorFrameSink()); 1733 CreateHostImpl(settings, CreateCompositorFrameSink());
1737 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); 1734 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f);
1738 1735
1739 const gfx::Size content_size(1000, 1000); 1736 const gfx::Size content_size(1000, 1000);
1740 const gfx::Size viewport_size(500, 500); 1737 const gfx::Size viewport_size(500, 500);
1741 CreateBasicVirtualViewportLayers(viewport_size, content_size); 1738 CreateBasicVirtualViewportLayers(viewport_size, content_size);
1742 1739
1743 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); 1740 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer();
1744 outer_scroll_layer->SetDrawsContent(true); 1741 outer_scroll_layer->SetDrawsContent(true);
1745 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); 1742 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer();
1746 inner_scroll_layer->SetDrawsContent(true); 1743 inner_scroll_layer->SetDrawsContent(true);
1747 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 1744 host_impl_->active_tree()->BuildPropertyTreesForTesting();
1748 1745
1749 // Sanity checks. 1746 // Sanity checks.
1750 EXPECT_VECTOR_EQ( 1747 EXPECT_VECTOR_EQ(gfx::Vector2dF(500, 500),
1751 gfx::Vector2dF(500, 500), 1748 outer_scroll_layer->MaxScrollOffset());
1752 outer_scroll_layer->MaxScrollOffset());
1753 EXPECT_VECTOR_EQ(gfx::Vector2dF(), outer_scroll_layer->CurrentScrollOffset()); 1749 EXPECT_VECTOR_EQ(gfx::Vector2dF(), outer_scroll_layer->CurrentScrollOffset());
1754 EXPECT_VECTOR_EQ(gfx::Vector2dF(), inner_scroll_layer->CurrentScrollOffset()); 1750 EXPECT_VECTOR_EQ(gfx::Vector2dF(), inner_scroll_layer->CurrentScrollOffset());
1755 1751
1756 // Scroll only the layout viewport. 1752 // Scroll only the layout viewport.
1757 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), 1753 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(),
1758 InputHandler::TOUCHSCREEN); 1754 InputHandler::TOUCHSCREEN);
1759 host_impl_->ScrollBy( 1755 host_impl_->ScrollBy(
1760 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(0.125f, 0.125f)).get()); 1756 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(0.125f, 0.125f)).get());
1761 EXPECT_VECTOR2DF_EQ( 1757 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0.125f, 0.125f),
1762 gfx::Vector2dF(0.125f, 0.125f), 1758 outer_scroll_layer->CurrentScrollOffset());
1763 outer_scroll_layer->CurrentScrollOffset()); 1759 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0, 0),
1764 EXPECT_VECTOR2DF_EQ( 1760 inner_scroll_layer->CurrentScrollOffset());
1765 gfx::Vector2dF(0, 0),
1766 inner_scroll_layer->CurrentScrollOffset());
1767 host_impl_->ScrollEnd(EndState().get()); 1761 host_impl_->ScrollEnd(EndState().get());
1768 1762
1769 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f); 1763 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f);
1770 1764
1771 // Now that we zoomed in, the scroll should be applied to the inner viewport. 1765 // Now that we zoomed in, the scroll should be applied to the inner viewport.
1772 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), 1766 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(),
1773 InputHandler::TOUCHSCREEN); 1767 InputHandler::TOUCHSCREEN);
1774 host_impl_->ScrollBy( 1768 host_impl_->ScrollBy(
1775 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(0.5f, 0.5f)).get()); 1769 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(0.5f, 0.5f)).get());
1776 EXPECT_VECTOR2DF_EQ( 1770 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0.125f, 0.125f),
1777 gfx::Vector2dF(0.125f, 0.125f), 1771 outer_scroll_layer->CurrentScrollOffset());
1778 outer_scroll_layer->CurrentScrollOffset()); 1772 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0.25f, 0.25f),
1779 EXPECT_VECTOR2DF_EQ( 1773 inner_scroll_layer->CurrentScrollOffset());
1780 gfx::Vector2dF(0.25f, 0.25f),
1781 inner_scroll_layer->CurrentScrollOffset());
1782 host_impl_->ScrollEnd(EndState().get()); 1774 host_impl_->ScrollEnd(EndState().get());
1783 } 1775 }
1784 1776
1785 // Tests that scrolls during a pinch gesture (i.e. "two-finger" scrolls) work 1777 // Tests that scrolls during a pinch gesture (i.e. "two-finger" scrolls) work
1786 // as expected. That is, scrolling during a pinch should bubble from the inner 1778 // as expected. That is, scrolling during a pinch should bubble from the inner
1787 // to the outer viewport. 1779 // to the outer viewport.
1788 TEST_F(LayerTreeHostImplTest, ScrollDuringPinchGesture) { 1780 TEST_F(LayerTreeHostImplTest, ScrollDuringPinchGesture) {
1789 LayerTreeSettings settings = DefaultSettings(); 1781 LayerTreeSettings settings = DefaultSettings();
1790 CreateHostImpl(settings, CreateCompositorFrameSink()); 1782 CreateHostImpl(settings, CreateCompositorFrameSink());
1791 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); 1783 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f);
1792 1784
1793 const gfx::Size content_size(1000, 1000); 1785 const gfx::Size content_size(1000, 1000);
1794 const gfx::Size viewport_size(500, 500); 1786 const gfx::Size viewport_size(500, 500);
1795 CreateBasicVirtualViewportLayers(viewport_size, content_size); 1787 CreateBasicVirtualViewportLayers(viewport_size, content_size);
1796 1788
1797 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); 1789 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer();
1798 outer_scroll_layer->SetDrawsContent(true); 1790 outer_scroll_layer->SetDrawsContent(true);
1799 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); 1791 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer();
1800 inner_scroll_layer->SetDrawsContent(true); 1792 inner_scroll_layer->SetDrawsContent(true);
1801 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 1793 host_impl_->active_tree()->BuildPropertyTreesForTesting();
1802 1794
1803 EXPECT_VECTOR_EQ( 1795 EXPECT_VECTOR_EQ(gfx::Vector2dF(500, 500),
1804 gfx::Vector2dF(500, 500), 1796 outer_scroll_layer->MaxScrollOffset());
1805 outer_scroll_layer->MaxScrollOffset());
1806 1797
1807 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), 1798 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(),
1808 InputHandler::TOUCHSCREEN); 1799 InputHandler::TOUCHSCREEN);
1809 host_impl_->PinchGestureBegin(); 1800 host_impl_->PinchGestureBegin();
1810 1801
1811 host_impl_->PinchGestureUpdate(2, gfx::Point(250, 250)); 1802 host_impl_->PinchGestureUpdate(2, gfx::Point(250, 250));
1812 EXPECT_VECTOR_EQ( 1803 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0),
1813 gfx::Vector2dF(0, 0), 1804 outer_scroll_layer->CurrentScrollOffset());
1814 outer_scroll_layer->CurrentScrollOffset()); 1805 EXPECT_VECTOR_EQ(gfx::Vector2dF(125, 125),
1815 EXPECT_VECTOR_EQ( 1806 inner_scroll_layer->CurrentScrollOffset());
1816 gfx::Vector2dF(125, 125),
1817 inner_scroll_layer->CurrentScrollOffset());
1818 1807
1819 // Needed so that the pinch is accounted for in draw properties. 1808 // Needed so that the pinch is accounted for in draw properties.
1820 DrawFrame(); 1809 DrawFrame();
1821 1810
1822 host_impl_->ScrollBy( 1811 host_impl_->ScrollBy(
1823 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(10.f, 10.f)).get()); 1812 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(10.f, 10.f)).get());
1824 EXPECT_VECTOR_EQ( 1813 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0),
1825 gfx::Vector2dF(0, 0), 1814 outer_scroll_layer->CurrentScrollOffset());
1826 outer_scroll_layer->CurrentScrollOffset()); 1815 EXPECT_VECTOR_EQ(gfx::Vector2dF(130, 130),
1827 EXPECT_VECTOR_EQ( 1816 inner_scroll_layer->CurrentScrollOffset());
1828 gfx::Vector2dF(130, 130),
1829 inner_scroll_layer->CurrentScrollOffset());
1830 1817
1831 DrawFrame(); 1818 DrawFrame();
1832 1819
1833 host_impl_->ScrollBy( 1820 host_impl_->ScrollBy(
1834 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(400.f, 400.f)).get()); 1821 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(400.f, 400.f)).get());
1835 EXPECT_VECTOR_EQ( 1822 EXPECT_VECTOR_EQ(gfx::Vector2dF(80, 80),
1836 gfx::Vector2dF(80, 80), 1823 outer_scroll_layer->CurrentScrollOffset());
1837 outer_scroll_layer->CurrentScrollOffset()); 1824 EXPECT_VECTOR_EQ(gfx::Vector2dF(250, 250),
1838 EXPECT_VECTOR_EQ( 1825 inner_scroll_layer->CurrentScrollOffset());
1839 gfx::Vector2dF(250, 250),
1840 inner_scroll_layer->CurrentScrollOffset());
1841 1826
1842 host_impl_->PinchGestureEnd(); 1827 host_impl_->PinchGestureEnd();
1843 host_impl_->ScrollEnd(EndState().get()); 1828 host_impl_->ScrollEnd(EndState().get());
1844 } 1829 }
1845 1830
1846 // Tests the "snapping" of pinch-zoom gestures to the screen edge. That is, when 1831 // Tests the "snapping" of pinch-zoom gestures to the screen edge. That is, when
1847 // a pinch zoom is anchored within a certain margin of the screen edge, we 1832 // a pinch zoom is anchored within a certain margin of the screen edge, we
1848 // should assume the user means to scroll into the edge of the screen. 1833 // should assume the user means to scroll into the edge of the screen.
1849 TEST_F(LayerTreeHostImplTest, PinchZoomSnapsToScreenEdge) { 1834 TEST_F(LayerTreeHostImplTest, PinchZoomSnapsToScreenEdge) {
1850 LayerTreeSettings settings = DefaultSettings(); 1835 LayerTreeSettings settings = DefaultSettings();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); 1928 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
1944 1929
1945 // Scroll by a small amount, there should be no bubbling to the outer 1930 // Scroll by a small amount, there should be no bubbling to the outer
1946 // viewport. 1931 // viewport.
1947 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), 1932 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(),
1948 InputHandler::WHEEL); 1933 InputHandler::WHEEL);
1949 host_impl_->ScrollBy( 1934 host_impl_->ScrollBy(
1950 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(10.f, 20.f)).get()); 1935 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(10.f, 20.f)).get());
1951 host_impl_->ScrollEnd(EndState().get()); 1936 host_impl_->ScrollEnd(EndState().get());
1952 1937
1953 EXPECT_VECTOR_EQ( 1938 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 10),
1954 gfx::Vector2dF(5, 10), 1939 inner_scroll_layer->CurrentScrollOffset());
1955 inner_scroll_layer->CurrentScrollOffset()); 1940 EXPECT_VECTOR_EQ(gfx::Vector2dF(), outer_scroll_layer->CurrentScrollOffset());
1956 EXPECT_VECTOR_EQ(
1957 gfx::Vector2dF(),
1958 outer_scroll_layer->CurrentScrollOffset());
1959 1941
1960 // Scroll by the inner viewport's max scroll extent, the remainder 1942 // Scroll by the inner viewport's max scroll extent, the remainder
1961 // should bubble up to the outer viewport. 1943 // should bubble up to the outer viewport.
1962 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), 1944 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(),
1963 InputHandler::WHEEL); 1945 InputHandler::WHEEL);
1964 host_impl_->ScrollBy( 1946 host_impl_->ScrollBy(
1965 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(100.f, 100.f)).get()); 1947 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(100.f, 100.f)).get());
1966 host_impl_->ScrollEnd(EndState().get()); 1948 host_impl_->ScrollEnd(EndState().get());
1967 1949
1968 EXPECT_VECTOR_EQ( 1950 EXPECT_VECTOR_EQ(gfx::Vector2dF(50, 50),
1969 gfx::Vector2dF(50, 50), 1951 inner_scroll_layer->CurrentScrollOffset());
1970 inner_scroll_layer->CurrentScrollOffset()); 1952 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 10),
1971 EXPECT_VECTOR_EQ( 1953 outer_scroll_layer->CurrentScrollOffset());
1972 gfx::Vector2dF(5, 10),
1973 outer_scroll_layer->CurrentScrollOffset());
1974 1954
1975 // Scroll by the outer viewport's max scroll extent, it should all go to the 1955 // Scroll by the outer viewport's max scroll extent, it should all go to the
1976 // outer viewport. 1956 // outer viewport.
1977 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), 1957 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(),
1978 InputHandler::WHEEL); 1958 InputHandler::WHEEL);
1979 host_impl_->ScrollBy( 1959 host_impl_->ScrollBy(
1980 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(190.f, 180.f)).get()); 1960 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(190.f, 180.f)).get());
1981 host_impl_->ScrollEnd(EndState().get()); 1961 host_impl_->ScrollEnd(EndState().get());
1982 1962
1983 EXPECT_VECTOR_EQ( 1963 EXPECT_VECTOR_EQ(gfx::Vector2dF(100, 100),
1984 gfx::Vector2dF(100, 100), 1964 outer_scroll_layer->CurrentScrollOffset());
1985 outer_scroll_layer->CurrentScrollOffset()); 1965 EXPECT_VECTOR_EQ(gfx::Vector2dF(50, 50),
1986 EXPECT_VECTOR_EQ( 1966 inner_scroll_layer->CurrentScrollOffset());
1987 gfx::Vector2dF(50, 50),
1988 inner_scroll_layer->CurrentScrollOffset());
1989 } 1967 }
1990 1968
1991 TEST_F(LayerTreeHostImplTest, ScrollWithSwapPromises) { 1969 TEST_F(LayerTreeHostImplTest, ScrollWithSwapPromises) {
1992 ui::LatencyInfo latency_info; 1970 ui::LatencyInfo latency_info;
1993 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 1971 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0,
1994 1234); 1972 1234);
1995 std::unique_ptr<SwapPromise> swap_promise( 1973 std::unique_ptr<SwapPromise> swap_promise(
1996 new LatencyInfoSwapPromise(latency_info)); 1974 new LatencyInfoSwapPromise(latency_info));
1997 1975
1998 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 1976 SetupScrollAndContentsLayers(gfx::Size(100, 100));
(...skipping 15 matching lines...) Expand all
2014 1992
2015 // Test that scrolls targeting a layer with a non-null scroll_parent() don't 1993 // Test that scrolls targeting a layer with a non-null scroll_parent() don't
2016 // bubble up. 1994 // bubble up.
2017 TEST_F(LayerTreeHostImplTest, ScrollDoesntBubble) { 1995 TEST_F(LayerTreeHostImplTest, ScrollDoesntBubble) {
2018 LayerImpl* viewport_scroll = 1996 LayerImpl* viewport_scroll =
2019 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 1997 SetupScrollAndContentsLayers(gfx::Size(100, 100));
2020 host_impl_->SetViewportSize(gfx::Size(50, 50)); 1998 host_impl_->SetViewportSize(gfx::Size(50, 50));
2021 1999
2022 // Set up two scrolling children of the root, one of which is a scroll parent 2000 // Set up two scrolling children of the root, one of which is a scroll parent
2023 // to the other. Scrolls shouldn't bubbling from the child. 2001 // to the other. Scrolls shouldn't bubbling from the child.
2024 LayerImpl *parent; 2002 LayerImpl* parent;
2025 LayerImpl *child; 2003 LayerImpl* child;
2026 LayerImpl *child_clip; 2004 LayerImpl* child_clip;
2027 2005
2028 std::unique_ptr<LayerImpl> scroll_parent_clip = 2006 std::unique_ptr<LayerImpl> scroll_parent_clip =
2029 LayerImpl::Create(host_impl_->active_tree(), 6); 2007 LayerImpl::Create(host_impl_->active_tree(), 6);
2030 std::unique_ptr<LayerImpl> scroll_parent = 2008 std::unique_ptr<LayerImpl> scroll_parent =
2031 CreateScrollableLayer(7, gfx::Size(10, 10), scroll_parent_clip.get()); 2009 CreateScrollableLayer(7, gfx::Size(10, 10), scroll_parent_clip.get());
2032 parent = scroll_parent.get(); 2010 parent = scroll_parent.get();
2033 scroll_parent_clip->test_properties()->AddChild(std::move(scroll_parent)); 2011 scroll_parent_clip->test_properties()->AddChild(std::move(scroll_parent));
2034 2012
2035 viewport_scroll->test_properties()->AddChild(std::move(scroll_parent_clip)); 2013 viewport_scroll->test_properties()->AddChild(std::move(scroll_parent_clip));
2036 2014
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2097 // The viewport shouldn't receive any scroll delta. 2075 // The viewport shouldn't receive any scroll delta.
2098 EXPECT_VECTOR_EQ( 2076 EXPECT_VECTOR_EQ(
2099 gfx::Vector2dF(0, 0), 2077 gfx::Vector2dF(0, 0),
2100 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); 2078 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset());
2101 EXPECT_VECTOR_EQ( 2079 EXPECT_VECTOR_EQ(
2102 gfx::Vector2dF(0, 0), 2080 gfx::Vector2dF(0, 0),
2103 host_impl_->OuterViewportScrollLayer()->CurrentScrollOffset()); 2081 host_impl_->OuterViewportScrollLayer()->CurrentScrollOffset());
2104 } 2082 }
2105 } 2083 }
2106 2084
2107
2108 TEST_F(LayerTreeHostImplTest, PinchGesture) { 2085 TEST_F(LayerTreeHostImplTest, PinchGesture) {
2109 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 2086 SetupScrollAndContentsLayers(gfx::Size(100, 100));
2110 host_impl_->SetViewportSize(gfx::Size(50, 50)); 2087 host_impl_->SetViewportSize(gfx::Size(50, 50));
2111 DrawFrame(); 2088 DrawFrame();
2112 2089
2113 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); 2090 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer();
2114 DCHECK(scroll_layer); 2091 DCHECK(scroll_layer);
2115 2092
2116 float min_page_scale = 1.f; 2093 float min_page_scale = 1.f;
2117 float max_page_scale = 4.f; 2094 float max_page_scale = 4.f;
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
2329 TEST_F(LayerTreeHostImplTest, PageScaleAnimation) { 2306 TEST_F(LayerTreeHostImplTest, PageScaleAnimation) {
2330 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 2307 SetupScrollAndContentsLayers(gfx::Size(100, 100));
2331 host_impl_->SetViewportSize(gfx::Size(50, 50)); 2308 host_impl_->SetViewportSize(gfx::Size(50, 50));
2332 DrawFrame(); 2309 DrawFrame();
2333 2310
2334 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); 2311 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer();
2335 DCHECK(scroll_layer); 2312 DCHECK(scroll_layer);
2336 2313
2337 float min_page_scale = 0.5f; 2314 float min_page_scale = 0.5f;
2338 float max_page_scale = 4.f; 2315 float max_page_scale = 4.f;
2339 base::TimeTicks start_time = base::TimeTicks() + 2316 base::TimeTicks start_time =
2340 base::TimeDelta::FromSeconds(1); 2317 base::TimeTicks() + base::TimeDelta::FromSeconds(1);
2341 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); 2318 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
2342 base::TimeTicks halfway_through_animation = start_time + duration / 2; 2319 base::TimeTicks halfway_through_animation = start_time + duration / 2;
2343 base::TimeTicks end_time = start_time + duration; 2320 base::TimeTicks end_time = start_time + duration;
2344 2321
2345 BeginFrameArgs begin_frame_args = 2322 BeginFrameArgs begin_frame_args =
2346 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); 2323 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
2347 2324
2348 // Non-anchor zoom-in 2325 // Non-anchor zoom-in
2349 { 2326 {
2350 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2327 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
2454 TEST_F(LayerTreeHostImplTest, PageScaleAnimationNoOp) { 2431 TEST_F(LayerTreeHostImplTest, PageScaleAnimationNoOp) {
2455 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 2432 SetupScrollAndContentsLayers(gfx::Size(100, 100));
2456 host_impl_->SetViewportSize(gfx::Size(50, 50)); 2433 host_impl_->SetViewportSize(gfx::Size(50, 50));
2457 DrawFrame(); 2434 DrawFrame();
2458 2435
2459 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); 2436 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer();
2460 DCHECK(scroll_layer); 2437 DCHECK(scroll_layer);
2461 2438
2462 float min_page_scale = 0.5f; 2439 float min_page_scale = 0.5f;
2463 float max_page_scale = 4.f; 2440 float max_page_scale = 4.f;
2464 base::TimeTicks start_time = base::TimeTicks() + 2441 base::TimeTicks start_time =
2465 base::TimeDelta::FromSeconds(1); 2442 base::TimeTicks() + base::TimeDelta::FromSeconds(1);
2466 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); 2443 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
2467 base::TimeTicks halfway_through_animation = start_time + duration / 2; 2444 base::TimeTicks halfway_through_animation = start_time + duration / 2;
2468 base::TimeTicks end_time = start_time + duration; 2445 base::TimeTicks end_time = start_time + duration;
2469 2446
2470 BeginFrameArgs begin_frame_args = 2447 BeginFrameArgs begin_frame_args =
2471 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); 2448 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
2472 2449
2473 // Anchor zoom with unchanged page scale should not change scroll or scale. 2450 // Anchor zoom with unchanged page scale should not change scroll or scale.
2474 { 2451 {
2475 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2452 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
(...skipping 28 matching lines...) Expand all
2504 std::unique_ptr<ScrollAndScaleSet> scroll_info = 2481 std::unique_ptr<ScrollAndScaleSet> scroll_info =
2505 host_impl_->ProcessScrollDeltas(); 2482 host_impl_->ProcessScrollDeltas();
2506 EXPECT_EQ(scroll_info->page_scale_delta, 1); 2483 EXPECT_EQ(scroll_info->page_scale_delta, 1);
2507 ExpectNone(*scroll_info, scroll_layer->id()); 2484 ExpectNone(*scroll_info, scroll_layer->id());
2508 } 2485 }
2509 } 2486 }
2510 2487
2511 TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) { 2488 TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) {
2512 host_impl_->CreatePendingTree(); 2489 host_impl_->CreatePendingTree();
2513 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 2490 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
2514 CreateScrollAndContentsLayers( 2491 CreateScrollAndContentsLayers(host_impl_->pending_tree(),
2515 host_impl_->pending_tree(), 2492 gfx::Size(100, 100));
2516 gfx::Size(100, 100));
2517 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 2493 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
2518 host_impl_->ActivateSyncTree(); 2494 host_impl_->ActivateSyncTree();
2519 DrawFrame(); 2495 DrawFrame();
2520 2496
2521 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); 2497 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer();
2522 DCHECK(scroll_layer); 2498 DCHECK(scroll_layer);
2523 2499
2524 float min_page_scale = 0.5f; 2500 float min_page_scale = 0.5f;
2525 float max_page_scale = 4.f; 2501 float max_page_scale = 4.f;
2526 host_impl_->sync_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2502 host_impl_->sync_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
2527 max_page_scale); 2503 max_page_scale);
2528 host_impl_->ActivateSyncTree(); 2504 host_impl_->ActivateSyncTree();
2529 2505
2530 base::TimeTicks start_time = base::TimeTicks() + 2506 base::TimeTicks start_time =
2531 base::TimeDelta::FromSeconds(1); 2507 base::TimeTicks() + base::TimeDelta::FromSeconds(1);
2532 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); 2508 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
2533 base::TimeTicks third_through_animation = start_time + duration / 3; 2509 base::TimeTicks third_through_animation = start_time + duration / 3;
2534 base::TimeTicks halfway_through_animation = start_time + duration / 2; 2510 base::TimeTicks halfway_through_animation = start_time + duration / 2;
2535 base::TimeTicks end_time = start_time + duration; 2511 base::TimeTicks end_time = start_time + duration;
2536 float target_scale = 2.f; 2512 float target_scale = 2.f;
2537 2513
2538 BeginFrameArgs begin_frame_args = 2514 BeginFrameArgs begin_frame_args =
2539 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); 2515 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
2540 2516
2541 scroll_layer->layer_tree_impl() 2517 scroll_layer->layer_tree_impl()
(...skipping 23 matching lines...) Expand all
2565 host_impl_->WillBeginImplFrame(begin_frame_args); 2541 host_impl_->WillBeginImplFrame(begin_frame_args);
2566 host_impl_->Animate(); 2542 host_impl_->Animate();
2567 EXPECT_FALSE(did_request_next_frame_); 2543 EXPECT_FALSE(did_request_next_frame_);
2568 EXPECT_FALSE(did_request_redraw_); 2544 EXPECT_FALSE(did_request_redraw_);
2569 host_impl_->DidFinishImplFrame(); 2545 host_impl_->DidFinishImplFrame();
2570 2546
2571 // Activate the sync tree. This should cause the animation to become enabled. 2547 // Activate the sync tree. This should cause the animation to become enabled.
2572 // It should also clear the pointer on the sync tree. 2548 // It should also clear the pointer on the sync tree.
2573 host_impl_->ActivateSyncTree(); 2549 host_impl_->ActivateSyncTree();
2574 EXPECT_EQ(nullptr, 2550 EXPECT_EQ(nullptr,
2575 host_impl_->sync_tree()->TakePendingPageScaleAnimation().get()); 2551 host_impl_->sync_tree()->TakePendingPageScaleAnimation().get());
2576 EXPECT_FALSE(did_request_redraw_); 2552 EXPECT_FALSE(did_request_redraw_);
2577 EXPECT_TRUE(did_request_next_frame_); 2553 EXPECT_TRUE(did_request_next_frame_);
2578 2554
2579 start_time += base::TimeDelta::FromSeconds(10); 2555 start_time += base::TimeDelta::FromSeconds(10);
2580 third_through_animation += base::TimeDelta::FromSeconds(10); 2556 third_through_animation += base::TimeDelta::FromSeconds(10);
2581 halfway_through_animation += base::TimeDelta::FromSeconds(10); 2557 halfway_through_animation += base::TimeDelta::FromSeconds(10);
2582 end_time += base::TimeDelta::FromSeconds(10); 2558 end_time += base::TimeDelta::FromSeconds(10);
2583 2559
2584 // From here on, make sure the animation runs as normal. 2560 // From here on, make sure the animation runs as normal.
2585 did_request_redraw_ = false; 2561 did_request_redraw_ = false;
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
2990 host_impl_->active_tree()->LayerById(400); 2966 host_impl_->active_tree()->LayerById(400);
2991 2967
2992 EffectNode* active_tree_node = 2968 EffectNode* active_tree_node =
2993 host_impl_->active_tree()->property_trees()->effect_tree.Node( 2969 host_impl_->active_tree()->property_trees()->effect_tree.Node(
2994 active_scrollbar_layer->effect_tree_index()); 2970 active_scrollbar_layer->effect_tree_index());
2995 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(), 2971 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(),
2996 active_tree_node->opacity); 2972 active_tree_node->opacity);
2997 2973
2998 if (expecting_animations) { 2974 if (expecting_animations) {
2999 host_impl_->ScrollbarAnimationControllerForId(scroll->id()) 2975 host_impl_->ScrollbarAnimationControllerForId(scroll->id())
3000 ->DidMouseMoveNear(0); 2976 ->DidMouseMoveNear(VERTICAL, 0);
3001 } else { 2977 } else {
3002 EXPECT_EQ(nullptr, 2978 EXPECT_EQ(nullptr,
3003 host_impl_->ScrollbarAnimationControllerForId(scroll->id())); 2979 host_impl_->ScrollbarAnimationControllerForId(scroll->id()));
3004 } 2980 }
3005 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 2981 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
3006 InputHandler::WHEEL); 2982 InputHandler::WHEEL);
3007 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get()); 2983 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get());
3008 host_impl_->ScrollEnd(EndState().get()); 2984 host_impl_->ScrollEnd(EndState().get());
3009 host_impl_->CreatePendingTree(); 2985 host_impl_->CreatePendingTree();
3010 // To test the case where the effect tree index of scrollbar layer changes, 2986 // To test the case where the effect tree index of scrollbar layer changes,
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
3250 3226
3251 DrawFrame(); 3227 DrawFrame();
3252 host_impl_->active_tree()->UpdateDrawProperties(false); 3228 host_impl_->active_tree()->UpdateDrawProperties(false);
3253 3229
3254 ScrollbarAnimationControllerThinning* scrollbar_animation_controller = 3230 ScrollbarAnimationControllerThinning* scrollbar_animation_controller =
3255 static_cast<ScrollbarAnimationControllerThinning*>( 3231 static_cast<ScrollbarAnimationControllerThinning*>(
3256 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id())); 3232 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id()));
3257 scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f); 3233 scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f);
3258 3234
3259 host_impl_->MouseMoveAt(gfx::Point(200, 1)); 3235 host_impl_->MouseMoveAt(gfx::Point(200, 1));
3260 EXPECT_FALSE(scrollbar_animation_controller->mouse_is_near_scrollbar()); 3236 EXPECT_FALSE(
3237 scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL));
3261 3238
3262 host_impl_->MouseMoveAt(gfx::Point(100, 50)); 3239 host_impl_->MouseMoveAt(gfx::Point(100, 50));
3263 EXPECT_TRUE(scrollbar_animation_controller->mouse_is_near_scrollbar()); 3240 EXPECT_TRUE(
3241 scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL));
3264 3242
3265 host_impl_->MouseMoveAt(gfx::Point(116, 100)); 3243 host_impl_->MouseMoveAt(gfx::Point(116, 100));
3266 EXPECT_FALSE(scrollbar_animation_controller->mouse_is_near_scrollbar()); 3244 EXPECT_FALSE(
3245 scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL));
3267 3246
3268 scrollbar_animation_controller->set_mouse_move_distance_for_test(102.f); 3247 scrollbar_animation_controller->set_mouse_move_distance_for_test(102.f);
3269 host_impl_->MouseMoveAt(gfx::Point(116, 100)); 3248 host_impl_->MouseMoveAt(gfx::Point(116, 100));
3270 EXPECT_TRUE(scrollbar_animation_controller->mouse_is_near_scrollbar()); 3249 EXPECT_TRUE(
3250 scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL));
3271 3251
3272 did_request_redraw_ = false; 3252 did_request_redraw_ = false;
3273 EXPECT_FALSE(scrollbar_animation_controller->mouse_is_over_scrollbar()); 3253 EXPECT_FALSE(
3254 scrollbar_animation_controller->mouse_is_over_scrollbar(VERTICAL));
3274 host_impl_->MouseMoveAt(gfx::Point(10, 100)); 3255 host_impl_->MouseMoveAt(gfx::Point(10, 100));
3275 EXPECT_TRUE(scrollbar_animation_controller->mouse_is_over_scrollbar()); 3256 EXPECT_TRUE(
3257 scrollbar_animation_controller->mouse_is_over_scrollbar(VERTICAL));
3276 host_impl_->MouseMoveAt(gfx::Point(10, 120)); 3258 host_impl_->MouseMoveAt(gfx::Point(10, 120));
3277 EXPECT_TRUE(scrollbar_animation_controller->mouse_is_over_scrollbar()); 3259 EXPECT_TRUE(
3260 scrollbar_animation_controller->mouse_is_over_scrollbar(VERTICAL));
3278 host_impl_->MouseMoveAt(gfx::Point(150, 120)); 3261 host_impl_->MouseMoveAt(gfx::Point(150, 120));
3279 EXPECT_FALSE(scrollbar_animation_controller->mouse_is_over_scrollbar()); 3262 EXPECT_FALSE(
3263 scrollbar_animation_controller->mouse_is_over_scrollbar(VERTICAL));
3280 } 3264 }
3281 3265
3282 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf1) { 3266 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf1) {
3283 SetupMouseMoveAtWithDeviceScale(1.f); 3267 SetupMouseMoveAtWithDeviceScale(1.f);
3284 } 3268 }
3285 3269
3286 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf2) { 3270 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf2) {
3287 SetupMouseMoveAtWithDeviceScale(2.f); 3271 SetupMouseMoveAtWithDeviceScale(2.f);
3288 } 3272 }
3289 3273
3290 TEST_F(LayerTreeHostImplTest, CompositorFrameMetadata) { 3274 TEST_F(LayerTreeHostImplTest, CompositorFrameMetadata) {
3291 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 3275 SetupScrollAndContentsLayers(gfx::Size(100, 100));
3292 host_impl_->SetViewportSize(gfx::Size(50, 50)); 3276 host_impl_->SetViewportSize(gfx::Size(50, 50));
3293 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); 3277 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f);
3294 DrawFrame(); 3278 DrawFrame();
3295 { 3279 {
3296 CompositorFrameMetadata metadata = 3280 CompositorFrameMetadata metadata =
3297 host_impl_->MakeCompositorFrameMetadata(); 3281 host_impl_->MakeCompositorFrameMetadata();
3298 EXPECT_EQ(gfx::Vector2dF(), metadata.root_scroll_offset); 3282 EXPECT_EQ(gfx::Vector2dF(), metadata.root_scroll_offset);
3299 EXPECT_EQ(1.f, metadata.page_scale_factor); 3283 EXPECT_EQ(1.f, metadata.page_scale_factor);
3300 EXPECT_EQ(gfx::SizeF(50.f, 50.f), metadata.scrollable_viewport_size); 3284 EXPECT_EQ(gfx::SizeF(50.f, 50.f), metadata.scrollable_viewport_size);
3301 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size); 3285 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size);
3302 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); 3286 EXPECT_EQ(0.5f, metadata.min_page_scale_factor);
3303 EXPECT_EQ(4.f, metadata.max_page_scale_factor); 3287 EXPECT_EQ(4.f, metadata.max_page_scale_factor);
3304 EXPECT_FALSE(metadata.root_overflow_x_hidden); 3288 EXPECT_FALSE(metadata.root_overflow_x_hidden);
3305 EXPECT_FALSE(metadata.root_overflow_y_hidden); 3289 EXPECT_FALSE(metadata.root_overflow_y_hidden);
3306 } 3290 }
3307 3291
3308 // Scrolling should update metadata immediately. 3292 // Scrolling should update metadata immediately.
3309 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 3293 EXPECT_EQ(
3310 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 3294 InputHandler::SCROLL_ON_IMPL_THREAD,
3311 InputHandler::WHEEL) 3295 host_impl_
3312 .thread); 3296 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL)
3297 .thread);
3313 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); 3298 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get());
3314 { 3299 {
3315 CompositorFrameMetadata metadata = 3300 CompositorFrameMetadata metadata =
3316 host_impl_->MakeCompositorFrameMetadata(); 3301 host_impl_->MakeCompositorFrameMetadata();
3317 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); 3302 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset);
3318 } 3303 }
3319 host_impl_->ScrollEnd(EndState().get()); 3304 host_impl_->ScrollEnd(EndState().get());
3320 { 3305 {
3321 CompositorFrameMetadata metadata = 3306 CompositorFrameMetadata metadata =
3322 host_impl_->MakeCompositorFrameMetadata(); 3307 host_impl_->MakeCompositorFrameMetadata();
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after
4584 scroll_delta = gfx::Vector2dF(0.f, -25.f); 4569 scroll_delta = gfx::Vector2dF(0.f, -25.f);
4585 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 4570 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
4586 host_impl_ 4571 host_impl_
4587 ->ScrollBegin(BeginState(gfx::Point()).get(), 4572 ->ScrollBegin(BeginState(gfx::Point()).get(),
4588 InputHandler::TOUCHSCREEN) 4573 InputHandler::TOUCHSCREEN)
4589 .thread); 4574 .thread);
4590 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 4575 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
4591 host_impl_->ScrollEnd(EndState().get()); 4576 host_impl_->ScrollEnd(EndState().get());
4592 4577
4593 // The viewport offset shouldn't have changed. 4578 // The viewport offset shouldn't have changed.
4594 EXPECT_EQ(viewport_offset, 4579 EXPECT_EQ(viewport_offset, host_impl_->active_tree()->TotalScrollOffset());
4595 host_impl_->active_tree()->TotalScrollOffset());
4596 4580
4597 // Scroll the viewports to max scroll offset. 4581 // Scroll the viewports to max scroll offset.
4598 SetScrollOffsetDelta(outer_scroll, gfx::Vector2dF(0, 200.f)); 4582 SetScrollOffsetDelta(outer_scroll, gfx::Vector2dF(0, 200.f));
4599 SetScrollOffsetDelta(inner_scroll, gfx::Vector2dF(100, 100.f)); 4583 SetScrollOffsetDelta(inner_scroll, gfx::Vector2dF(100, 100.f));
4600 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), 4584 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(),
4601 host_impl_->active_tree()->TotalScrollOffset()); 4585 host_impl_->active_tree()->TotalScrollOffset());
4602 } 4586 }
4603 4587
4604 // Test that the browser controls coming in and out maintains the same aspect 4588 // Test that the browser controls coming in and out maintains the same aspect
4605 // ratio between the inner and outer viewports. 4589 // ratio between the inner and outer viewports.
(...skipping 16 matching lines...) Expand all
4622 host_impl_->ScrollEnd(EndState().get()); 4606 host_impl_->ScrollEnd(EndState().get());
4623 4607
4624 EXPECT_FLOAT_EQ( 4608 EXPECT_FLOAT_EQ(
4625 scroll_delta.y(), 4609 scroll_delta.y(),
4626 top_controls_height_ - 4610 top_controls_height_ -
4627 host_impl_->browser_controls_manager()->ContentTopOffset()); 4611 host_impl_->browser_controls_manager()->ContentTopOffset());
4628 4612
4629 // Browser controls were hidden by 25px so the inner viewport should have 4613 // Browser controls were hidden by 25px so the inner viewport should have
4630 // expanded by that much. 4614 // expanded by that much.
4631 LayerImpl* outer_container = 4615 LayerImpl* outer_container =
4632 host_impl_->active_tree()->OuterViewportContainerLayer(); 4616 host_impl_->active_tree()->OuterViewportContainerLayer();
4633 LayerImpl* inner_container = 4617 LayerImpl* inner_container =
4634 host_impl_->active_tree()->InnerViewportContainerLayer(); 4618 host_impl_->active_tree()->InnerViewportContainerLayer();
4635 EXPECT_EQ(gfx::SizeF(100.f, 100.f + 25.f), 4619 EXPECT_EQ(gfx::SizeF(100.f, 100.f + 25.f),
4636 inner_container->BoundsForScrolling()); 4620 inner_container->BoundsForScrolling());
4637 4621
4638 // Outer viewport should match inner's aspect ratio. The bounds are ceiled. 4622 // Outer viewport should match inner's aspect ratio. The bounds are ceiled.
4639 float aspect_ratio = inner_container->BoundsForScrolling().width() / 4623 float aspect_ratio = inner_container->BoundsForScrolling().width() /
4640 inner_container->BoundsForScrolling().height(); 4624 inner_container->BoundsForScrolling().height();
4641 gfx::SizeF expected = 4625 gfx::SizeF expected =
4642 gfx::SizeF(gfx::ToCeiledSize(gfx::SizeF(200, 200 / aspect_ratio))); 4626 gfx::SizeF(gfx::ToCeiledSize(gfx::SizeF(200, 200 / aspect_ratio)));
4643 EXPECT_EQ(expected, outer_container->BoundsForScrolling()); 4627 EXPECT_EQ(expected, outer_container->BoundsForScrolling());
4644 EXPECT_EQ(expected, 4628 EXPECT_EQ(expected,
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
4907 scroll_layer->SetPosition(gfx::PointF()); 4891 scroll_layer->SetPosition(gfx::PointF());
4908 scroll_layer->test_properties()->AddChild(std::move(content_layer)); 4892 scroll_layer->test_properties()->AddChild(std::move(content_layer));
4909 scroll_clip_layer->test_properties()->AddChild(std::move(scroll_layer)); 4893 scroll_clip_layer->test_properties()->AddChild(std::move(scroll_layer));
4910 4894
4911 scroll_clip_layer->test_properties()->force_render_surface = true; 4895 scroll_clip_layer->test_properties()->force_render_surface = true;
4912 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 4896 host_impl_->active_tree()->BuildPropertyTreesForTesting();
4913 4897
4914 host_impl_->SetViewportSize(surface_size); 4898 host_impl_->SetViewportSize(surface_size);
4915 DrawFrame(); 4899 DrawFrame();
4916 4900
4917 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 4901 EXPECT_EQ(
4918 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), 4902 InputHandler::SCROLL_ON_IMPL_THREAD,
4919 InputHandler::WHEEL) 4903 host_impl_
4920 .thread); 4904 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL)
4905 .thread);
4921 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); 4906 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get());
4922 host_impl_->ScrollEnd(EndState().get()); 4907 host_impl_->ScrollEnd(EndState().get());
4923 EXPECT_TRUE(did_request_redraw_); 4908 EXPECT_TRUE(did_request_redraw_);
4924 EXPECT_TRUE(did_request_commit_); 4909 EXPECT_TRUE(did_request_commit_);
4925 } 4910 }
4926 4911
4927 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { 4912 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) {
4928 gfx::Size surface_size(10, 10); 4913 gfx::Size surface_size(10, 10);
4929 gfx::Size contents_size(20, 20); 4914 gfx::Size contents_size(20, 20);
4930 4915
4931 LayerImpl* root = 4916 LayerImpl* root =
4932 CreateBasicVirtualViewportLayers(surface_size, surface_size); 4917 CreateBasicVirtualViewportLayers(surface_size, surface_size);
4933 4918
4934 root->test_properties()->AddChild( 4919 root->test_properties()->AddChild(
4935 CreateScrollableLayer(12, contents_size, root)); 4920 CreateScrollableLayer(12, contents_size, root));
4936 root->test_properties()->force_render_surface = true; 4921 root->test_properties()->force_render_surface = true;
4937 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 4922 host_impl_->active_tree()->BuildPropertyTreesForTesting();
4938 4923
4939 host_impl_->SetViewportSize(surface_size); 4924 host_impl_->SetViewportSize(surface_size);
4940 DrawFrame(); 4925 DrawFrame();
4941 4926
4942 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 4927 EXPECT_EQ(
4943 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), 4928 InputHandler::SCROLL_ON_IMPL_THREAD,
4944 InputHandler::WHEEL) 4929 host_impl_
4945 .thread); 4930 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL)
4931 .thread);
4946 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); 4932 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get());
4947 host_impl_->ScrollEnd(EndState().get()); 4933 host_impl_->ScrollEnd(EndState().get());
4948 EXPECT_TRUE(did_request_redraw_); 4934 EXPECT_TRUE(did_request_redraw_);
4949 EXPECT_TRUE(did_request_commit_); 4935 EXPECT_TRUE(did_request_commit_);
4950 } 4936 }
4951 4937
4952 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { 4938 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) {
4953 gfx::Size surface_size(10, 10); 4939 gfx::Size surface_size(10, 10);
4954 std::unique_ptr<LayerImpl> root = 4940 std::unique_ptr<LayerImpl> root =
4955 LayerImpl::Create(host_impl_->active_tree(), 1); 4941 LayerImpl::Create(host_impl_->active_tree(), 1);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
5057 5043
5058 LayerImpl* root_scroll = 5044 LayerImpl* root_scroll =
5059 host_impl_->active_tree()->OuterViewportScrollLayer(); 5045 host_impl_->active_tree()->OuterViewportScrollLayer();
5060 LayerImpl* inner_scroll = 5046 LayerImpl* inner_scroll =
5061 host_impl_->active_tree()->InnerViewportScrollLayer(); 5047 host_impl_->active_tree()->InnerViewportScrollLayer();
5062 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); 5048 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds());
5063 5049
5064 gfx::Vector2d scroll_delta(0, 10); 5050 gfx::Vector2d scroll_delta(0, 10);
5065 gfx::Vector2d expected_scroll_delta = scroll_delta; 5051 gfx::Vector2d expected_scroll_delta = scroll_delta;
5066 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); 5052 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset();
5067 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 5053 EXPECT_EQ(
5068 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), 5054 InputHandler::SCROLL_ON_IMPL_THREAD,
5069 InputHandler::WHEEL) 5055 host_impl_
5070 .thread); 5056 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL)
5057 .thread);
5071 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 5058 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
5072 host_impl_->ScrollEnd(EndState().get()); 5059 host_impl_->ScrollEnd(EndState().get());
5073 5060
5074 // Set new page scale from main thread. 5061 // Set new page scale from main thread.
5075 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 2.f); 5062 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 2.f);
5076 5063
5077 std::unique_ptr<ScrollAndScaleSet> scroll_info = 5064 std::unique_ptr<ScrollAndScaleSet> scroll_info =
5078 host_impl_->ProcessScrollDeltas(); 5065 host_impl_->ProcessScrollDeltas();
5079 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(), 5066 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(),
5080 expected_scroll_delta)); 5067 expected_scroll_delta));
(...skipping 26 matching lines...) Expand all
5107 5094
5108 LayerImpl* root_scroll = 5095 LayerImpl* root_scroll =
5109 host_impl_->active_tree()->OuterViewportScrollLayer(); 5096 host_impl_->active_tree()->OuterViewportScrollLayer();
5110 LayerImpl* inner_scroll = 5097 LayerImpl* inner_scroll =
5111 host_impl_->active_tree()->InnerViewportScrollLayer(); 5098 host_impl_->active_tree()->InnerViewportScrollLayer();
5112 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); 5099 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds());
5113 5100
5114 gfx::Vector2d scroll_delta(0, 10); 5101 gfx::Vector2d scroll_delta(0, 10);
5115 gfx::Vector2d expected_scroll_delta = scroll_delta; 5102 gfx::Vector2d expected_scroll_delta = scroll_delta;
5116 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); 5103 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset();
5117 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 5104 EXPECT_EQ(
5118 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), 5105 InputHandler::SCROLL_ON_IMPL_THREAD,
5119 InputHandler::WHEEL) 5106 host_impl_
5120 .thread); 5107 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL)
5108 .thread);
5121 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 5109 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
5122 host_impl_->ScrollEnd(EndState().get()); 5110 host_impl_->ScrollEnd(EndState().get());
5123 5111
5124 // Set new page scale on impl thread by pinching. 5112 // Set new page scale on impl thread by pinching.
5125 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 5113 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
5126 InputHandler::TOUCHSCREEN); 5114 InputHandler::TOUCHSCREEN);
5127 host_impl_->PinchGestureBegin(); 5115 host_impl_->PinchGestureBegin();
5128 host_impl_->PinchGestureUpdate(page_scale, gfx::Point()); 5116 host_impl_->PinchGestureUpdate(page_scale, gfx::Point());
5129 host_impl_->PinchGestureEnd(); 5117 host_impl_->PinchGestureEnd();
5130 host_impl_->ScrollEnd(EndState().get()); 5118 host_impl_->ScrollEnd(EndState().get());
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
5209 5197
5210 // Make the outer scroll layer scrollable. 5198 // Make the outer scroll layer scrollable.
5211 outer_scroll->SetBounds(gfx::Size(50, 50)); 5199 outer_scroll->SetBounds(gfx::Size(50, 50));
5212 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 5200 host_impl_->active_tree()->BuildPropertyTreesForTesting();
5213 5201
5214 DrawFrame(); 5202 DrawFrame();
5215 5203
5216 gfx::Vector2d scroll_delta(0, 10); 5204 gfx::Vector2d scroll_delta(0, 10);
5217 gfx::Vector2d expected_scroll_delta(scroll_delta); 5205 gfx::Vector2d expected_scroll_delta(scroll_delta);
5218 gfx::ScrollOffset expected_max_scroll(outer_scroll->MaxScrollOffset()); 5206 gfx::ScrollOffset expected_max_scroll(outer_scroll->MaxScrollOffset());
5219 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 5207 EXPECT_EQ(
5220 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), 5208 InputHandler::SCROLL_ON_IMPL_THREAD,
5221 InputHandler::WHEEL) 5209 host_impl_
5222 .thread); 5210 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL)
5211 .thread);
5223 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 5212 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
5224 host_impl_->ScrollEnd(EndState().get()); 5213 host_impl_->ScrollEnd(EndState().get());
5225 5214
5226 float page_scale = 2.f; 5215 float page_scale = 2.f;
5227 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 5216 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f,
5228 page_scale); 5217 page_scale);
5229 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 5218 host_impl_->active_tree()->BuildPropertyTreesForTesting();
5230 5219
5231 DrawOneFrame(); 5220 DrawOneFrame();
5232 5221
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
5272 gfx::ScrollOffset(0, 5)); 5261 gfx::ScrollOffset(0, 5));
5273 child_layer->layer_tree_impl() 5262 child_layer->layer_tree_impl()
5274 ->property_trees() 5263 ->property_trees()
5275 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), 5264 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(),
5276 gfx::ScrollOffset(3, 0)); 5265 gfx::ScrollOffset(3, 0));
5277 5266
5278 host_impl_->SetViewportSize(surface_size); 5267 host_impl_->SetViewportSize(surface_size);
5279 DrawFrame(); 5268 DrawFrame();
5280 { 5269 {
5281 gfx::Vector2d scroll_delta(-8, -7); 5270 gfx::Vector2d scroll_delta(-8, -7);
5282 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 5271 EXPECT_EQ(
5283 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 5272 InputHandler::SCROLL_ON_IMPL_THREAD,
5284 InputHandler::WHEEL) 5273 host_impl_
5285 .thread); 5274 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL)
5275 .thread);
5286 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 5276 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
5287 host_impl_->ScrollEnd(EndState().get()); 5277 host_impl_->ScrollEnd(EndState().get());
5288 5278
5289 std::unique_ptr<ScrollAndScaleSet> scroll_info = 5279 std::unique_ptr<ScrollAndScaleSet> scroll_info =
5290 host_impl_->ProcessScrollDeltas(); 5280 host_impl_->ProcessScrollDeltas();
5291 5281
5292 // The grand child should have scrolled up to its limit. 5282 // The grand child should have scrolled up to its limit.
5293 LayerImpl* child = host_impl_->active_tree() 5283 LayerImpl* child = host_impl_->active_tree()
5294 ->root_layer_for_testing() 5284 ->root_layer_for_testing()
5295 ->test_properties() 5285 ->test_properties()
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
5343 gfx::ScrollOffset(0, 2)); 5333 gfx::ScrollOffset(0, 2));
5344 child_layer->layer_tree_impl() 5334 child_layer->layer_tree_impl()
5345 ->property_trees() 5335 ->property_trees()
5346 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), 5336 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(),
5347 gfx::ScrollOffset(0, 3)); 5337 gfx::ScrollOffset(0, 3));
5348 5338
5349 DrawFrame(); 5339 DrawFrame();
5350 { 5340 {
5351 gfx::Vector2d scroll_delta(0, -10); 5341 gfx::Vector2d scroll_delta(0, -10);
5352 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 5342 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
5353 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 5343 host_impl_
5354 InputHandler::NON_BUBBLING_GESTURE) 5344 ->ScrollBegin(BeginState(gfx::Point()).get(),
5345 InputHandler::NON_BUBBLING_GESTURE)
5355 .thread); 5346 .thread);
5356 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 5347 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
5357 host_impl_->ScrollEnd(EndState().get()); 5348 host_impl_->ScrollEnd(EndState().get());
5358 5349
5359 std::unique_ptr<ScrollAndScaleSet> scroll_info = 5350 std::unique_ptr<ScrollAndScaleSet> scroll_info =
5360 host_impl_->ProcessScrollDeltas(); 5351 host_impl_->ProcessScrollDeltas();
5361 5352
5362 // The grand child should have scrolled up to its limit. 5353 // The grand child should have scrolled up to its limit.
5363 LayerImpl* child = host_impl_->active_tree() 5354 LayerImpl* child = host_impl_->active_tree()
5364 ->root_layer_for_testing() 5355 ->root_layer_for_testing()
5365 ->test_properties() 5356 ->test_properties()
5366 ->children[0] 5357 ->children[0]
5367 ->test_properties() 5358 ->test_properties()
5368 ->children[0] 5359 ->children[0]
5369 ->test_properties() 5360 ->test_properties()
5370 ->children[0]; 5361 ->children[0];
5371 LayerImpl* grand_child = child->test_properties()->children[0]; 5362 LayerImpl* grand_child = child->test_properties()->children[0];
5372 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), 5363 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(),
5373 gfx::Vector2d(0, -2))); 5364 gfx::Vector2d(0, -2)));
5374 5365
5375 // The child should not have scrolled. 5366 // The child should not have scrolled.
5376 ExpectNone(*scroll_info.get(), child->id()); 5367 ExpectNone(*scroll_info.get(), child->id());
5377 5368
5378 // The next time we scroll we should only scroll the parent. 5369 // The next time we scroll we should only scroll the parent.
5379 scroll_delta = gfx::Vector2d(0, -3); 5370 scroll_delta = gfx::Vector2d(0, -3);
5380 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 5371 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
5381 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), 5372 host_impl_
5382 InputHandler::NON_BUBBLING_GESTURE) 5373 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(),
5374 InputHandler::NON_BUBBLING_GESTURE)
5383 .thread); 5375 .thread);
5384 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); 5376 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child);
5385 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 5377 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
5386 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child); 5378 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child);
5387 host_impl_->ScrollEnd(EndState().get()); 5379 host_impl_->ScrollEnd(EndState().get());
5388 5380
5389 scroll_info = host_impl_->ProcessScrollDeltas(); 5381 scroll_info = host_impl_->ProcessScrollDeltas();
5390 5382
5391 // The child should have scrolled up to its limit. 5383 // The child should have scrolled up to its limit.
5392 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(), 5384 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(),
5393 gfx::Vector2d(0, -3))); 5385 gfx::Vector2d(0, -3)));
5394 5386
5395 // The grand child should not have scrolled. 5387 // The grand child should not have scrolled.
5396 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), 5388 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(),
5397 gfx::Vector2d(0, -2))); 5389 gfx::Vector2d(0, -2)));
5398 5390
5399 // After scrolling the parent, another scroll on the opposite direction 5391 // After scrolling the parent, another scroll on the opposite direction
5400 // should still scroll the child. 5392 // should still scroll the child.
5401 scroll_delta = gfx::Vector2d(0, 7); 5393 scroll_delta = gfx::Vector2d(0, 7);
5402 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 5394 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
5403 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), 5395 host_impl_
5404 InputHandler::NON_BUBBLING_GESTURE) 5396 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(),
5397 InputHandler::NON_BUBBLING_GESTURE)
5405 .thread); 5398 .thread);
5406 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); 5399 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child);
5407 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 5400 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
5408 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); 5401 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child);
5409 host_impl_->ScrollEnd(EndState().get()); 5402 host_impl_->ScrollEnd(EndState().get());
5410 5403
5411 scroll_info = host_impl_->ProcessScrollDeltas(); 5404 scroll_info = host_impl_->ProcessScrollDeltas();
5412 5405
5413 // The grand child should have scrolled. 5406 // The grand child should have scrolled.
5414 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), 5407 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(),
5415 gfx::Vector2d(0, 5))); 5408 gfx::Vector2d(0, 5)));
5416 5409
5417 // The child should not have scrolled. 5410 // The child should not have scrolled.
5418 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(), 5411 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(),
5419 gfx::Vector2d(0, -3))); 5412 gfx::Vector2d(0, -3)));
5420 5413
5421 // Scrolling should be adjusted from viewport space. 5414 // Scrolling should be adjusted from viewport space.
5422 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 2.f, 2.f); 5415 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 2.f, 2.f);
5423 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); 5416 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f);
5424 5417
5425 scroll_delta = gfx::Vector2d(0, -2); 5418 scroll_delta = gfx::Vector2d(0, -2);
5426 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 5419 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
5427 host_impl_->ScrollBegin(BeginState(gfx::Point(1, 1)).get(), 5420 host_impl_
5428 InputHandler::NON_BUBBLING_GESTURE) 5421 ->ScrollBegin(BeginState(gfx::Point(1, 1)).get(),
5422 InputHandler::NON_BUBBLING_GESTURE)
5429 .thread); 5423 .thread);
5430 EXPECT_EQ(grand_child, host_impl_->CurrentlyScrollingLayer()); 5424 EXPECT_EQ(grand_child, host_impl_->CurrentlyScrollingLayer());
5431 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 5425 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
5432 host_impl_->ScrollEnd(EndState().get()); 5426 host_impl_->ScrollEnd(EndState().get());
5433 5427
5434 scroll_info = host_impl_->ProcessScrollDeltas(); 5428 scroll_info = host_impl_->ProcessScrollDeltas();
5435 5429
5436 // Should have scrolled by half the amount in layer space (5 - 2/2) 5430 // Should have scrolled by half the amount in layer space (5 - 2/2)
5437 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), 5431 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(),
5438 gfx::Vector2d(0, 4))); 5432 gfx::Vector2d(0, 4)));
(...skipping 27 matching lines...) Expand all
5466 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 2, 5460 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 2,
5467 Layer::INVALID_ID); 5461 Layer::INVALID_ID);
5468 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 5462 host_impl_->active_tree()->BuildPropertyTreesForTesting();
5469 host_impl_->active_tree()->DidBecomeActive(); 5463 host_impl_->active_tree()->DidBecomeActive();
5470 5464
5471 host_impl_->SetViewportSize(surface_size); 5465 host_impl_->SetViewportSize(surface_size);
5472 DrawFrame(); 5466 DrawFrame();
5473 { 5467 {
5474 gfx::Vector2d scroll_delta(0, 4); 5468 gfx::Vector2d scroll_delta(0, 4);
5475 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 5469 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
5476 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), 5470 host_impl_
5477 InputHandler::WHEEL) 5471 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(),
5472 InputHandler::WHEEL)
5478 .thread); 5473 .thread);
5479 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 5474 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
5480 host_impl_->ScrollEnd(EndState().get()); 5475 host_impl_->ScrollEnd(EndState().get());
5481 5476
5482 std::unique_ptr<ScrollAndScaleSet> scroll_info = 5477 std::unique_ptr<ScrollAndScaleSet> scroll_info =
5483 host_impl_->ProcessScrollDeltas(); 5478 host_impl_->ProcessScrollDeltas();
5484 5479
5485 // Only the root scroll should have scrolled. 5480 // Only the root scroll should have scrolled.
5486 ASSERT_EQ(scroll_info->scrolls.size(), 1u); 5481 ASSERT_EQ(scroll_info->scrolls.size(), 1u);
5487 EXPECT_TRUE( 5482 EXPECT_TRUE(
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
5542 inner_clip2->test_properties()->AddChild(std::move(inner_scroll2)); 5537 inner_clip2->test_properties()->AddChild(std::move(inner_scroll2));
5543 inner_clip2->test_properties()->force_render_surface = true; 5538 inner_clip2->test_properties()->force_render_surface = true;
5544 root_ptr2->test_properties()->AddChild(std::move(inner_clip2)); 5539 root_ptr2->test_properties()->AddChild(std::move(inner_clip2));
5545 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr2)); 5540 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr2));
5546 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 5541 host_impl_->active_tree()->BuildPropertyTreesForTesting();
5547 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 6, 5542 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 6,
5548 10); 5543 10);
5549 host_impl_->active_tree()->DidBecomeActive(); 5544 host_impl_->active_tree()->DidBecomeActive();
5550 5545
5551 // Scrolling should still work even though we did not draw yet. 5546 // Scrolling should still work even though we did not draw yet.
5552 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 5547 EXPECT_EQ(
5553 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), 5548 InputHandler::SCROLL_ON_IMPL_THREAD,
5554 InputHandler::WHEEL) 5549 host_impl_
5555 .thread); 5550 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL)
5551 .thread);
5556 } 5552 }
5557 5553
5558 TEST_F(LayerTreeHostImplTest, ScrollAxisAlignedRotatedLayer) { 5554 TEST_F(LayerTreeHostImplTest, ScrollAxisAlignedRotatedLayer) {
5559 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); 5555 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100));
5560 scroll_layer->SetDrawsContent(true); 5556 scroll_layer->SetDrawsContent(true);
5561 5557
5562 // Rotate the root layer 90 degrees counter-clockwise about its center. 5558 // Rotate the root layer 90 degrees counter-clockwise about its center.
5563 gfx::Transform rotate_transform; 5559 gfx::Transform rotate_transform;
5564 rotate_transform.Rotate(-90.0); 5560 rotate_transform.Rotate(-90.0);
5565 host_impl_->active_tree() 5561 host_impl_->active_tree()
(...skipping 18 matching lines...) Expand all
5584 5580
5585 // The layer should have scrolled down in its local coordinates. 5581 // The layer should have scrolled down in its local coordinates.
5586 std::unique_ptr<ScrollAndScaleSet> scroll_info = 5582 std::unique_ptr<ScrollAndScaleSet> scroll_info =
5587 host_impl_->ProcessScrollDeltas(); 5583 host_impl_->ProcessScrollDeltas();
5588 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), 5584 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(),
5589 gfx::Vector2d(0, gesture_scroll_delta.x()))); 5585 gfx::Vector2d(0, gesture_scroll_delta.x())));
5590 5586
5591 // Reset and scroll down with the wheel. 5587 // Reset and scroll down with the wheel.
5592 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF()); 5588 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF());
5593 gfx::Vector2d wheel_scroll_delta(0, 10); 5589 gfx::Vector2d wheel_scroll_delta(0, 10);
5594 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 5590 EXPECT_EQ(
5595 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 5591 InputHandler::SCROLL_ON_IMPL_THREAD,
5596 InputHandler::WHEEL) 5592 host_impl_
5597 .thread); 5593 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL)
5594 .thread);
5598 host_impl_->ScrollBy(UpdateState(gfx::Point(), wheel_scroll_delta).get()); 5595 host_impl_->ScrollBy(UpdateState(gfx::Point(), wheel_scroll_delta).get());
5599 host_impl_->ScrollEnd(EndState().get()); 5596 host_impl_->ScrollEnd(EndState().get());
5600 5597
5601 // The layer should have scrolled down in its local coordinates. 5598 // The layer should have scrolled down in its local coordinates.
5602 scroll_info = host_impl_->ProcessScrollDeltas(); 5599 scroll_info = host_impl_->ProcessScrollDeltas();
5603 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), 5600 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(),
5604 wheel_scroll_delta)); 5601 wheel_scroll_delta));
5605 } 5602 }
5606 5603
5607 TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) { 5604 TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
5762 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id, 5759 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id,
5763 expected_scroll_deltas[i])); 5760 expected_scroll_deltas[i]));
5764 5761
5765 // The root scroll layer should not have scrolled, because the input delta 5762 // The root scroll layer should not have scrolled, because the input delta
5766 // was close to the layer's axis of movement. 5763 // was close to the layer's axis of movement.
5767 EXPECT_EQ(scroll_info->scrolls.size(), 1u); 5764 EXPECT_EQ(scroll_info->scrolls.size(), 1u);
5768 } 5765 }
5769 } 5766 }
5770 5767
5771 TEST_F(LayerTreeHostImplTest, ScrollScaledLayer) { 5768 TEST_F(LayerTreeHostImplTest, ScrollScaledLayer) {
5772 LayerImpl* scroll_layer = 5769 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100));
5773 SetupScrollAndContentsLayers(gfx::Size(100, 100));
5774 5770
5775 // Scale the layer to twice its normal size. 5771 // Scale the layer to twice its normal size.
5776 int scale = 2; 5772 int scale = 2;
5777 gfx::Transform scale_transform; 5773 gfx::Transform scale_transform;
5778 scale_transform.Scale(scale, scale); 5774 scale_transform.Scale(scale, scale);
5779 scroll_layer->test_properties()->parent->test_properties()->transform = 5775 scroll_layer->test_properties()->parent->test_properties()->transform =
5780 scale_transform; 5776 scale_transform;
5781 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 5777 host_impl_->active_tree()->BuildPropertyTreesForTesting();
5782 5778
5783 gfx::Size surface_size(50, 50); 5779 gfx::Size surface_size(50, 50);
(...skipping 13 matching lines...) Expand all
5797 // The layer should have scrolled down in its local coordinates, but half the 5793 // The layer should have scrolled down in its local coordinates, but half the
5798 // amount. 5794 // amount.
5799 std::unique_ptr<ScrollAndScaleSet> scroll_info = 5795 std::unique_ptr<ScrollAndScaleSet> scroll_info =
5800 host_impl_->ProcessScrollDeltas(); 5796 host_impl_->ProcessScrollDeltas();
5801 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), 5797 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(),
5802 gfx::Vector2d(0, scroll_delta.y() / scale))); 5798 gfx::Vector2d(0, scroll_delta.y() / scale)));
5803 5799
5804 // Reset and scroll down with the wheel. 5800 // Reset and scroll down with the wheel.
5805 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF()); 5801 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF());
5806 gfx::Vector2d wheel_scroll_delta(0, 10); 5802 gfx::Vector2d wheel_scroll_delta(0, 10);
5807 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 5803 EXPECT_EQ(
5808 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 5804 InputHandler::SCROLL_ON_IMPL_THREAD,
5809 InputHandler::WHEEL) 5805 host_impl_
5810 .thread); 5806 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL)
5807 .thread);
5811 host_impl_->ScrollBy(UpdateState(gfx::Point(), wheel_scroll_delta).get()); 5808 host_impl_->ScrollBy(UpdateState(gfx::Point(), wheel_scroll_delta).get());
5812 host_impl_->ScrollEnd(EndState().get()); 5809 host_impl_->ScrollEnd(EndState().get());
5813 5810
5814 // It should apply the scale factor to the scroll delta for the wheel event. 5811 // It should apply the scale factor to the scroll delta for the wheel event.
5815 scroll_info = host_impl_->ProcessScrollDeltas(); 5812 scroll_info = host_impl_->ProcessScrollDeltas();
5816 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), 5813 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(),
5817 wheel_scroll_delta)); 5814 wheel_scroll_delta));
5818 } 5815 }
5819 5816
5820 TEST_F(LayerTreeHostImplTest, ScrollViewportRounding) { 5817 TEST_F(LayerTreeHostImplTest, ScrollViewportRounding) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
5859 DCHECK(total_scroll_offset.y() <= max_scroll_offset.y()); 5856 DCHECK(total_scroll_offset.y() <= max_scroll_offset.y());
5860 last_set_scroll_offset_ = total_scroll_offset; 5857 last_set_scroll_offset_ = total_scroll_offset;
5861 max_scroll_offset_ = max_scroll_offset; 5858 max_scroll_offset_ = max_scroll_offset;
5862 scrollable_size_ = scrollable_size; 5859 scrollable_size_ = scrollable_size;
5863 page_scale_factor_ = page_scale_factor; 5860 page_scale_factor_ = page_scale_factor;
5864 min_page_scale_factor_ = min_page_scale_factor; 5861 min_page_scale_factor_ = min_page_scale_factor;
5865 max_page_scale_factor_ = max_page_scale_factor; 5862 max_page_scale_factor_ = max_page_scale_factor;
5866 } 5863 }
5867 void DeliverInputForBeginFrame() override {} 5864 void DeliverInputForBeginFrame() override {}
5868 5865
5869 gfx::ScrollOffset last_set_scroll_offset() { 5866 gfx::ScrollOffset last_set_scroll_offset() { return last_set_scroll_offset_; }
5870 return last_set_scroll_offset_;
5871 }
5872 5867
5873 gfx::ScrollOffset max_scroll_offset() const { 5868 gfx::ScrollOffset max_scroll_offset() const { return max_scroll_offset_; }
5874 return max_scroll_offset_;
5875 }
5876 5869
5877 gfx::SizeF scrollable_size() const { 5870 gfx::SizeF scrollable_size() const { return scrollable_size_; }
5878 return scrollable_size_;
5879 }
5880 5871
5881 float page_scale_factor() const { 5872 float page_scale_factor() const { return page_scale_factor_; }
5882 return page_scale_factor_;
5883 }
5884 5873
5885 float min_page_scale_factor() const { 5874 float min_page_scale_factor() const { return min_page_scale_factor_; }
5886 return min_page_scale_factor_;
5887 }
5888 5875
5889 float max_page_scale_factor() const { 5876 float max_page_scale_factor() const { return max_page_scale_factor_; }
5890 return max_page_scale_factor_;
5891 }
5892 5877
5893 private: 5878 private:
5894 gfx::ScrollOffset last_set_scroll_offset_; 5879 gfx::ScrollOffset last_set_scroll_offset_;
5895 gfx::ScrollOffset max_scroll_offset_; 5880 gfx::ScrollOffset max_scroll_offset_;
5896 gfx::SizeF scrollable_size_; 5881 gfx::SizeF scrollable_size_;
5897 float page_scale_factor_; 5882 float page_scale_factor_;
5898 float min_page_scale_factor_; 5883 float min_page_scale_factor_;
5899 float max_page_scale_factor_; 5884 float max_page_scale_factor_;
5900 }; 5885 };
5901 5886
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
6043 InputHandlerScrollResult scroll_result; 6028 InputHandlerScrollResult scroll_result;
6044 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 6029 SetupScrollAndContentsLayers(gfx::Size(100, 100));
6045 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6030 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6046 6031
6047 host_impl_->SetViewportSize(gfx::Size(50, 50)); 6032 host_impl_->SetViewportSize(gfx::Size(50, 50));
6048 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); 6033 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f);
6049 DrawFrame(); 6034 DrawFrame();
6050 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); 6035 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
6051 6036
6052 // In-bounds scrolling does not affect overscroll. 6037 // In-bounds scrolling does not affect overscroll.
6053 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 6038 EXPECT_EQ(
6054 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 6039 InputHandler::SCROLL_ON_IMPL_THREAD,
6055 InputHandler::WHEEL) 6040 host_impl_
6056 .thread); 6041 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL)
6042 .thread);
6057 scroll_result = host_impl_->ScrollBy( 6043 scroll_result = host_impl_->ScrollBy(
6058 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); 6044 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get());
6059 EXPECT_TRUE(scroll_result.did_scroll); 6045 EXPECT_TRUE(scroll_result.did_scroll);
6060 EXPECT_FALSE(scroll_result.did_overscroll_root); 6046 EXPECT_FALSE(scroll_result.did_overscroll_root);
6061 EXPECT_EQ(gfx::Vector2dF(), scroll_result.unused_scroll_delta); 6047 EXPECT_EQ(gfx::Vector2dF(), scroll_result.unused_scroll_delta);
6062 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); 6048 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
6063 6049
6064 // Overscroll events are reflected immediately. 6050 // Overscroll events are reflected immediately.
6065 scroll_result = host_impl_->ScrollBy( 6051 scroll_result = host_impl_->ScrollBy(
6066 UpdateState(gfx::Point(), gfx::Vector2d(0, 50)).get()); 6052 UpdateState(gfx::Point(), gfx::Vector2d(0, 50)).get());
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
6205 grand_child_layer->layer_tree_impl() 6191 grand_child_layer->layer_tree_impl()
6206 ->property_trees() 6192 ->property_trees()
6207 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), 6193 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(),
6208 gfx::ScrollOffset(0, 2)); 6194 gfx::ScrollOffset(0, 2));
6209 6195
6210 host_impl_->SetViewportSize(surface_size); 6196 host_impl_->SetViewportSize(surface_size);
6211 DrawFrame(); 6197 DrawFrame();
6212 { 6198 {
6213 gfx::Vector2d scroll_delta(0, -10); 6199 gfx::Vector2d scroll_delta(0, -10);
6214 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 6200 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
6215 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 6201 host_impl_
6216 InputHandler::NON_BUBBLING_GESTURE) 6202 ->ScrollBegin(BeginState(gfx::Point()).get(),
6203 InputHandler::NON_BUBBLING_GESTURE)
6217 .thread); 6204 .thread);
6218 scroll_result = 6205 scroll_result =
6219 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 6206 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
6220 EXPECT_TRUE(scroll_result.did_scroll); 6207 EXPECT_TRUE(scroll_result.did_scroll);
6221 EXPECT_FALSE(scroll_result.did_overscroll_root); 6208 EXPECT_FALSE(scroll_result.did_overscroll_root);
6222 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); 6209 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
6223 host_impl_->ScrollEnd(EndState().get()); 6210 host_impl_->ScrollEnd(EndState().get());
6224 6211
6225 // The next time we scroll we should only scroll the parent, but overscroll 6212 // The next time we scroll we should only scroll the parent, but overscroll
6226 // should still not reach the root layer. 6213 // should still not reach the root layer.
6227 scroll_delta = gfx::Vector2d(0, -30); 6214 scroll_delta = gfx::Vector2d(0, -30);
6228 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 6215 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
6229 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), 6216 host_impl_
6230 InputHandler::NON_BUBBLING_GESTURE) 6217 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(),
6218 InputHandler::NON_BUBBLING_GESTURE)
6231 .thread); 6219 .thread);
6232 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); 6220 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer);
6233 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); 6221 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
6234 host_impl_->ScrollEnd(EndState().get()); 6222 host_impl_->ScrollEnd(EndState().get());
6235 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 6223 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
6236 host_impl_ 6224 host_impl_
6237 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), 6225 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(),
6238 InputHandler::NON_BUBBLING_GESTURE) 6226 InputHandler::NON_BUBBLING_GESTURE)
6239 .thread); 6227 .thread);
6240 scroll_result = 6228 scroll_result =
6241 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 6229 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
6242 EXPECT_TRUE(scroll_result.did_scroll); 6230 EXPECT_TRUE(scroll_result.did_scroll);
6243 EXPECT_FALSE(scroll_result.did_overscroll_root); 6231 EXPECT_FALSE(scroll_result.did_overscroll_root);
6244 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer()->id(), child_layer->id()); 6232 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer()->id(), child_layer->id());
6245 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); 6233 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
6246 host_impl_->ScrollEnd(EndState().get()); 6234 host_impl_->ScrollEnd(EndState().get());
6247 6235
6248 // After scrolling the parent, another scroll on the opposite direction 6236 // After scrolling the parent, another scroll on the opposite direction
6249 // should scroll the child. 6237 // should scroll the child.
6250 scroll_delta = gfx::Vector2d(0, 70); 6238 scroll_delta = gfx::Vector2d(0, 70);
6251 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 6239 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
6252 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), 6240 host_impl_
6253 InputHandler::NON_BUBBLING_GESTURE) 6241 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(),
6242 InputHandler::NON_BUBBLING_GESTURE)
6254 .thread); 6243 .thread);
6255 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); 6244 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer);
6256 scroll_result = 6245 scroll_result =
6257 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 6246 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
6258 EXPECT_TRUE(scroll_result.did_scroll); 6247 EXPECT_TRUE(scroll_result.did_scroll);
6259 EXPECT_FALSE(scroll_result.did_overscroll_root); 6248 EXPECT_FALSE(scroll_result.did_overscroll_root);
6260 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); 6249 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer);
6261 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); 6250 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
6262 host_impl_->ScrollEnd(EndState().get()); 6251 host_impl_->ScrollEnd(EndState().get());
6263 } 6252 }
6264 } 6253 }
6265 6254
6266 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { 6255 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) {
6267 // When we try to scroll a non-scrollable child layer, the scroll delta 6256 // When we try to scroll a non-scrollable child layer, the scroll delta
6268 // should be applied to one of its ancestors if possible. Overscroll should 6257 // should be applied to one of its ancestors if possible. Overscroll should
6269 // be reflected only when it has bubbled up to the root scrolling layer. 6258 // be reflected only when it has bubbled up to the root scrolling layer.
6270 InputHandlerScrollResult scroll_result; 6259 InputHandlerScrollResult scroll_result;
6271 SetupScrollAndContentsLayers(gfx::Size(20, 20)); 6260 SetupScrollAndContentsLayers(gfx::Size(20, 20));
6272 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6261 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6273 6262
6274 DrawFrame(); 6263 DrawFrame();
6275 { 6264 {
6276 gfx::Vector2d scroll_delta(0, 8); 6265 gfx::Vector2d scroll_delta(0, 8);
6277 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 6266 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
6278 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), 6267 host_impl_
6279 InputHandler::WHEEL) 6268 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(),
6269 InputHandler::WHEEL)
6280 .thread); 6270 .thread);
6281 scroll_result = 6271 scroll_result =
6282 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 6272 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
6283 EXPECT_TRUE(scroll_result.did_scroll); 6273 EXPECT_TRUE(scroll_result.did_scroll);
6284 EXPECT_FALSE(scroll_result.did_overscroll_root); 6274 EXPECT_FALSE(scroll_result.did_overscroll_root);
6285 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); 6275 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
6286 scroll_result = 6276 scroll_result =
6287 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 6277 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
6288 EXPECT_TRUE(scroll_result.did_scroll); 6278 EXPECT_TRUE(scroll_result.did_scroll);
6289 EXPECT_TRUE(scroll_result.did_overscroll_root); 6279 EXPECT_TRUE(scroll_result.did_overscroll_root);
(...skipping 18 matching lines...) Expand all
6308 6298
6309 clip_layer->SetBounds(gfx::Size(50, 50)); 6299 clip_layer->SetBounds(gfx::Size(50, 50));
6310 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6300 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6311 6301
6312 host_impl_->SetViewportSize(gfx::Size(50, 50)); 6302 host_impl_->SetViewportSize(gfx::Size(50, 50));
6313 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); 6303 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f);
6314 DrawFrame(); 6304 DrawFrame();
6315 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); 6305 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
6316 6306
6317 // Even though the layer can't scroll the overscroll still happens. 6307 // Even though the layer can't scroll the overscroll still happens.
6318 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 6308 EXPECT_EQ(
6319 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 6309 InputHandler::SCROLL_ON_IMPL_THREAD,
6320 InputHandler::WHEEL) 6310 host_impl_
6321 .thread); 6311 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL)
6312 .thread);
6322 scroll_result = host_impl_->ScrollBy( 6313 scroll_result = host_impl_->ScrollBy(
6323 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); 6314 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get());
6324 EXPECT_FALSE(scroll_result.did_scroll); 6315 EXPECT_FALSE(scroll_result.did_scroll);
6325 EXPECT_TRUE(scroll_result.did_overscroll_root); 6316 EXPECT_TRUE(scroll_result.did_overscroll_root);
6326 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); 6317 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll());
6327 } 6318 }
6328 6319
6329 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { 6320 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) {
6330 InputHandlerScrollResult scroll_result; 6321 InputHandlerScrollResult scroll_result;
6331 gfx::Size viewport_size(100, 100); 6322 gfx::Size viewport_size(100, 100);
6332 gfx::Size content_size(200, 200); 6323 gfx::Size content_size(200, 200);
6333 LayerImpl* root_scroll_layer = 6324 LayerImpl* root_scroll_layer =
6334 CreateBasicVirtualViewportLayers(viewport_size, viewport_size); 6325 CreateBasicVirtualViewportLayers(viewport_size, viewport_size);
6335 host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds( 6326 host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds(
6336 content_size); 6327 content_size);
6337 root_scroll_layer->SetBounds(content_size); 6328 root_scroll_layer->SetBounds(content_size);
6338 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6329 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6339 6330
6340 DrawFrame(); 6331 DrawFrame();
6341 { 6332 {
6342 // Edge glow effect should be applicable only upon reaching Edges 6333 // Edge glow effect should be applicable only upon reaching Edges
6343 // of the content. unnecessary glow effect calls shouldn't be 6334 // of the content. unnecessary glow effect calls shouldn't be
6344 // called while scrolling up without reaching the edge of the content. 6335 // called while scrolling up without reaching the edge of the content.
6345 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 6336 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
6346 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), 6337 host_impl_
6347 InputHandler::WHEEL) 6338 ->ScrollBegin(BeginState(gfx::Point(0, 0)).get(),
6339 InputHandler::WHEEL)
6348 .thread); 6340 .thread);
6349 scroll_result = host_impl_->ScrollBy( 6341 scroll_result = host_impl_->ScrollBy(
6350 UpdateState(gfx::Point(), gfx::Vector2dF(0, 100)).get()); 6342 UpdateState(gfx::Point(), gfx::Vector2dF(0, 100)).get());
6351 EXPECT_TRUE(scroll_result.did_scroll); 6343 EXPECT_TRUE(scroll_result.did_scroll);
6352 EXPECT_FALSE(scroll_result.did_overscroll_root); 6344 EXPECT_FALSE(scroll_result.did_overscroll_root);
6353 EXPECT_EQ(gfx::Vector2dF().ToString(), 6345 EXPECT_EQ(gfx::Vector2dF().ToString(),
6354 host_impl_->accumulated_root_overscroll().ToString()); 6346 host_impl_->accumulated_root_overscroll().ToString());
6355 scroll_result = host_impl_->ScrollBy( 6347 scroll_result = host_impl_->ScrollBy(
6356 UpdateState(gfx::Point(), gfx::Vector2dF(0, -2.30f)).get()); 6348 UpdateState(gfx::Point(), gfx::Vector2dF(0, -2.30f)).get());
6357 EXPECT_TRUE(scroll_result.did_scroll); 6349 EXPECT_TRUE(scroll_result.did_scroll);
6358 EXPECT_FALSE(scroll_result.did_overscroll_root); 6350 EXPECT_FALSE(scroll_result.did_overscroll_root);
6359 EXPECT_EQ(gfx::Vector2dF().ToString(), 6351 EXPECT_EQ(gfx::Vector2dF().ToString(),
6360 host_impl_->accumulated_root_overscroll().ToString()); 6352 host_impl_->accumulated_root_overscroll().ToString());
6361 host_impl_->ScrollEnd(EndState().get()); 6353 host_impl_->ScrollEnd(EndState().get());
6362 // unusedrootDelta should be subtracted from applied delta so that 6354 // unusedrootDelta should be subtracted from applied delta so that
6363 // unwanted glow effect calls are not called. 6355 // unwanted glow effect calls are not called.
6364 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 6356 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
6365 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), 6357 host_impl_
6366 InputHandler::NON_BUBBLING_GESTURE) 6358 ->ScrollBegin(BeginState(gfx::Point(0, 0)).get(),
6359 InputHandler::NON_BUBBLING_GESTURE)
6367 .thread); 6360 .thread);
6368 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 6361 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
6369 host_impl_->FlingScrollBegin().thread); 6362 host_impl_->FlingScrollBegin().thread);
6370 scroll_result = host_impl_->ScrollBy( 6363 scroll_result = host_impl_->ScrollBy(
6371 UpdateState(gfx::Point(), gfx::Vector2dF(0, 20)).get()); 6364 UpdateState(gfx::Point(), gfx::Vector2dF(0, 20)).get());
6372 EXPECT_TRUE(scroll_result.did_scroll); 6365 EXPECT_TRUE(scroll_result.did_scroll);
6373 EXPECT_TRUE(scroll_result.did_overscroll_root); 6366 EXPECT_TRUE(scroll_result.did_overscroll_root);
6374 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0.000000f, 17.699997f), 6367 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0.000000f, 17.699997f),
6375 host_impl_->accumulated_root_overscroll()); 6368 host_impl_->accumulated_root_overscroll());
6376 6369
6377 scroll_result = host_impl_->ScrollBy( 6370 scroll_result = host_impl_->ScrollBy(
6378 UpdateState(gfx::Point(), gfx::Vector2dF(0.02f, -0.01f)).get()); 6371 UpdateState(gfx::Point(), gfx::Vector2dF(0.02f, -0.01f)).get());
6379 EXPECT_FALSE(scroll_result.did_scroll); 6372 EXPECT_FALSE(scroll_result.did_scroll);
6380 EXPECT_FALSE(scroll_result.did_overscroll_root); 6373 EXPECT_FALSE(scroll_result.did_overscroll_root);
6381 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0.000000f, 17.699997f), 6374 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0.000000f, 17.699997f),
6382 host_impl_->accumulated_root_overscroll()); 6375 host_impl_->accumulated_root_overscroll());
6383 host_impl_->ScrollEnd(EndState().get()); 6376 host_impl_->ScrollEnd(EndState().get());
6384 // TestCase to check kEpsilon, which prevents minute values to trigger 6377 // TestCase to check kEpsilon, which prevents minute values to trigger
6385 // gloweffect without reaching edge. 6378 // gloweffect without reaching edge.
6386 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 6379 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
6387 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), 6380 host_impl_
6388 InputHandler::WHEEL) 6381 ->ScrollBegin(BeginState(gfx::Point(0, 0)).get(),
6382 InputHandler::WHEEL)
6389 .thread); 6383 .thread);
6390 scroll_result = host_impl_->ScrollBy( 6384 scroll_result = host_impl_->ScrollBy(
6391 UpdateState(gfx::Point(), gfx::Vector2dF(-0.12f, 0.1f)).get()); 6385 UpdateState(gfx::Point(), gfx::Vector2dF(-0.12f, 0.1f)).get());
6392 EXPECT_FALSE(scroll_result.did_scroll); 6386 EXPECT_FALSE(scroll_result.did_scroll);
6393 EXPECT_FALSE(scroll_result.did_overscroll_root); 6387 EXPECT_FALSE(scroll_result.did_overscroll_root);
6394 EXPECT_EQ(gfx::Vector2dF().ToString(), 6388 EXPECT_EQ(gfx::Vector2dF().ToString(),
6395 host_impl_->accumulated_root_overscroll().ToString()); 6389 host_impl_->accumulated_root_overscroll().ToString());
6396 host_impl_->ScrollEnd(EndState().get()); 6390 host_impl_->ScrollEnd(EndState().get());
6397 } 6391 }
6398 } 6392 }
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
6891 else 6885 else
6892 opaque_rect = opaque_content_rect_; 6886 opaque_rect = opaque_content_rect_;
6893 gfx::Rect visible_quad_rect = quad_rect_; 6887 gfx::Rect visible_quad_rect = quad_rect_;
6894 6888
6895 SharedQuadState* shared_quad_state = 6889 SharedQuadState* shared_quad_state =
6896 render_pass->CreateAndAppendSharedQuadState(); 6890 render_pass->CreateAndAppendSharedQuadState();
6897 PopulateSharedQuadState(shared_quad_state); 6891 PopulateSharedQuadState(shared_quad_state);
6898 6892
6899 TileDrawQuad* test_blending_draw_quad = 6893 TileDrawQuad* test_blending_draw_quad =
6900 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); 6894 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>();
6901 test_blending_draw_quad->SetNew(shared_quad_state, 6895 test_blending_draw_quad->SetNew(shared_quad_state, quad_rect_, opaque_rect,
6902 quad_rect_, 6896 visible_quad_rect, resource_id_,
6903 opaque_rect,
6904 visible_quad_rect,
6905 resource_id_,
6906 gfx::RectF(0.f, 0.f, 1.f, 1.f), 6897 gfx::RectF(0.f, 0.f, 1.f, 1.f),
6907 gfx::Size(1, 1), 6898 gfx::Size(1, 1), false, false);
6908 false,
6909 false);
6910 test_blending_draw_quad->visible_rect = quad_visible_rect_; 6899 test_blending_draw_quad->visible_rect = quad_visible_rect_;
6911 EXPECT_EQ(blend_, test_blending_draw_quad->ShouldDrawWithBlending()); 6900 EXPECT_EQ(blend_, test_blending_draw_quad->ShouldDrawWithBlending());
6912 EXPECT_EQ(has_render_surface_, !!render_surface()); 6901 EXPECT_EQ(has_render_surface_, !!render_surface());
6913 } 6902 }
6914 6903
6915 void SetExpectation(bool blend, bool has_render_surface) { 6904 void SetExpectation(bool blend, bool has_render_surface) {
6916 blend_ = blend; 6905 blend_ = blend;
6917 has_render_surface_ = has_render_surface; 6906 has_render_surface_ = has_render_surface;
6918 quads_appended_ = false; 6907 quads_appended_ = false;
6919 } 6908 }
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
7247 video_layer->SetPosition(gfx::PointF(100.f, 100.f)); 7236 video_layer->SetPosition(gfx::PointF(100.f, 100.f));
7248 EXPECT_FALSE(MayContainVideoBitSetOnFrameData(host_impl_.get())); 7237 EXPECT_FALSE(MayContainVideoBitSetOnFrameData(host_impl_.get()));
7249 7238
7250 video_layer->SetPosition(gfx::PointF(0.f, 0.f)); 7239 video_layer->SetPosition(gfx::PointF(0.f, 0.f));
7251 video_layer->NoteLayerPropertyChanged(); 7240 video_layer->NoteLayerPropertyChanged();
7252 EXPECT_TRUE(MayContainVideoBitSetOnFrameData(host_impl_.get())); 7241 EXPECT_TRUE(MayContainVideoBitSetOnFrameData(host_impl_.get()));
7253 } 7242 }
7254 7243
7255 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { 7244 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest {
7256 protected: 7245 protected:
7257 LayerTreeHostImplViewportCoveredTest() : 7246 LayerTreeHostImplViewportCoveredTest()
7258 gutter_quad_material_(DrawQuad::SOLID_COLOR), 7247 : gutter_quad_material_(DrawQuad::SOLID_COLOR),
7259 child_(NULL), 7248 child_(NULL),
7260 did_activate_pending_tree_(false) {} 7249 did_activate_pending_tree_(false) {}
7261 7250
7262 std::unique_ptr<CompositorFrameSink> CreateFakeCompositorFrameSink( 7251 std::unique_ptr<CompositorFrameSink> CreateFakeCompositorFrameSink(
7263 bool software) { 7252 bool software) {
7264 if (software) 7253 if (software)
7265 return FakeCompositorFrameSink::CreateSoftware(); 7254 return FakeCompositorFrameSink::CreateSoftware();
7266 return FakeCompositorFrameSink::Create3d(); 7255 return FakeCompositorFrameSink::Create3d();
7267 } 7256 }
7268 7257
7269 void SetupActiveTreeLayers() { 7258 void SetupActiveTreeLayers() {
7270 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); 7259 host_impl_->active_tree()->set_background_color(SK_ColorGRAY);
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
7541 host_impl_->CreatePendingTree(); 7530 host_impl_->CreatePendingTree();
7542 host_impl_->SetViewportSize(DipSizeToPixelSize(viewport_size_)); 7531 host_impl_->SetViewportSize(DipSizeToPixelSize(viewport_size_));
7543 EXPECT_TRUE(host_impl_->active_tree()->ViewportSizeInvalid()); 7532 EXPECT_TRUE(host_impl_->active_tree()->ViewportSizeInvalid());
7544 7533
7545 SetupActiveTreeLayers(); 7534 SetupActiveTreeLayers();
7546 EXPECT_SCOPED(TestEmptyLayerWithOnDraw()); 7535 EXPECT_SCOPED(TestEmptyLayerWithOnDraw());
7547 EXPECT_SCOPED(TestLayerInMiddleOfViewportWithOnDraw()); 7536 EXPECT_SCOPED(TestLayerInMiddleOfViewportWithOnDraw());
7548 EXPECT_SCOPED(TestLayerIsLargerThanViewportWithOnDraw()); 7537 EXPECT_SCOPED(TestLayerIsLargerThanViewportWithOnDraw());
7549 } 7538 }
7550 7539
7551 class FakeDrawableLayerImpl: public LayerImpl { 7540 class FakeDrawableLayerImpl : public LayerImpl {
7552 public: 7541 public:
7553 static std::unique_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { 7542 static std::unique_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) {
7554 return base::WrapUnique(new FakeDrawableLayerImpl(tree_impl, id)); 7543 return base::WrapUnique(new FakeDrawableLayerImpl(tree_impl, id));
7555 } 7544 }
7545
7556 protected: 7546 protected:
7557 FakeDrawableLayerImpl(LayerTreeImpl* tree_impl, int id) 7547 FakeDrawableLayerImpl(LayerTreeImpl* tree_impl, int id)
7558 : LayerImpl(tree_impl, id) {} 7548 : LayerImpl(tree_impl, id) {}
7559 }; 7549 };
7560 7550
7561 // Make sure damage tracking propagates all the way to the graphics context, 7551 // Make sure damage tracking propagates all the way to the graphics context,
7562 // where it should request to swap only the sub-buffer that is damaged. 7552 // where it should request to swap only the sub-buffer that is damaged.
7563 TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) { 7553 TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) {
7564 scoped_refptr<TestContextProvider> context_provider( 7554 scoped_refptr<TestContextProvider> context_provider(
7565 TestContextProvider::Create()); 7555 TestContextProvider::Create());
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
7680 AppendQuadsData* append_quads_data) override { 7670 AppendQuadsData* append_quads_data) override {
7681 SharedQuadState* shared_quad_state = 7671 SharedQuadState* shared_quad_state =
7682 render_pass->CreateAndAppendSharedQuadState(); 7672 render_pass->CreateAndAppendSharedQuadState();
7683 PopulateSharedQuadState(shared_quad_state); 7673 PopulateSharedQuadState(shared_quad_state);
7684 7674
7685 SkColor gray = SkColorSetRGB(100, 100, 100); 7675 SkColor gray = SkColorSetRGB(100, 100, 100);
7686 gfx::Rect quad_rect(bounds()); 7676 gfx::Rect quad_rect(bounds());
7687 gfx::Rect visible_quad_rect(quad_rect); 7677 gfx::Rect visible_quad_rect(quad_rect);
7688 SolidColorDrawQuad* my_quad = 7678 SolidColorDrawQuad* my_quad =
7689 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 7679 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
7690 my_quad->SetNew( 7680 my_quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect, gray,
7691 shared_quad_state, quad_rect, visible_quad_rect, gray, false); 7681 false);
7692 } 7682 }
7693 7683
7694 private: 7684 private:
7695 FakeLayerWithQuads(LayerTreeImpl* tree_impl, int id) 7685 FakeLayerWithQuads(LayerTreeImpl* tree_impl, int id)
7696 : LayerImpl(tree_impl, id) {} 7686 : LayerImpl(tree_impl, id) {}
7697 }; 7687 };
7698 7688
7699 static std::unique_ptr<LayerTreeHostImpl> SetupLayersForOpacity( 7689 static std::unique_ptr<LayerTreeHostImpl> SetupLayersForOpacity(
7700 LayerTreeSettings settings, 7690 LayerTreeSettings settings,
7701 bool partial_swap, 7691 bool partial_swap,
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
7834 TestWebGraphicsContext3D* context3d = context.get(); 7824 TestWebGraphicsContext3D* context3d = context.get();
7835 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( 7825 std::unique_ptr<CompositorFrameSink> compositor_frame_sink(
7836 FakeCompositorFrameSink::Create3d(std::move(context))); 7826 FakeCompositorFrameSink::Create3d(std::move(context)));
7837 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); 7827 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink));
7838 7828
7839 std::unique_ptr<LayerImpl> root_layer = 7829 std::unique_ptr<LayerImpl> root_layer =
7840 LayerImpl::Create(host_impl_->active_tree(), 1); 7830 LayerImpl::Create(host_impl_->active_tree(), 1);
7841 root_layer->SetBounds(gfx::Size(10, 10)); 7831 root_layer->SetBounds(gfx::Size(10, 10));
7842 root_layer->test_properties()->force_render_surface = true; 7832 root_layer->test_properties()->force_render_surface = true;
7843 7833
7844 scoped_refptr<VideoFrame> softwareFrame = 7834 scoped_refptr<VideoFrame> softwareFrame = media::VideoFrame::CreateColorFrame(
7845 media::VideoFrame::CreateColorFrame( 7835 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta());
7846 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta());
7847 FakeVideoFrameProvider provider; 7836 FakeVideoFrameProvider provider;
7848 provider.set_frame(softwareFrame); 7837 provider.set_frame(softwareFrame);
7849 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( 7838 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create(
7850 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); 7839 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0);
7851 video_layer->SetBounds(gfx::Size(10, 10)); 7840 video_layer->SetBounds(gfx::Size(10, 10));
7852 video_layer->SetDrawsContent(true); 7841 video_layer->SetDrawsContent(true);
7853 root_layer->test_properties()->AddChild(std::move(video_layer)); 7842 root_layer->test_properties()->AddChild(std::move(video_layer));
7854 7843
7855 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_layer)); 7844 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_layer));
7856 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7845 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7857 7846
7858 EXPECT_EQ(0u, context3d->NumTextures()); 7847 EXPECT_EQ(0u, context3d->NumTextures());
7859 7848
7860 LayerTreeHostImpl::FrameData frame; 7849 LayerTreeHostImpl::FrameData frame;
7861 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7850 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7862 host_impl_->DrawLayers(&frame); 7851 host_impl_->DrawLayers(&frame);
7863 host_impl_->DidDrawAllLayers(frame); 7852 host_impl_->DidDrawAllLayers(frame);
7864 7853
7865 EXPECT_GT(context3d->NumTextures(), 0u); 7854 EXPECT_GT(context3d->NumTextures(), 0u);
7866 7855
7867 // Kill the layer tree. 7856 // Kill the layer tree.
7868 host_impl_->active_tree()->DetachLayers(); 7857 host_impl_->active_tree()->DetachLayers();
7869 // There should be no textures left in use after. 7858 // There should be no textures left in use after.
7870 EXPECT_EQ(0u, context3d->NumTextures()); 7859 EXPECT_EQ(0u, context3d->NumTextures());
7871 } 7860 }
7872 7861
7873 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D { 7862 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D {
7874 public: 7863 public:
7875 MOCK_METHOD1(useProgram, void(GLuint program)); 7864 MOCK_METHOD1(useProgram, void(GLuint program));
7876 MOCK_METHOD4(drawElements, void(GLenum mode, 7865 MOCK_METHOD4(drawElements,
7877 GLsizei count, 7866 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset));
7878 GLenum type,
7879 GLintptr offset));
7880 }; 7867 };
7881 7868
7882 TEST_F(LayerTreeHostImplTest, HasTransparentBackground) { 7869 TEST_F(LayerTreeHostImplTest, HasTransparentBackground) {
7883 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); 7870 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1));
7884 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7871 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7885 7872
7886 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); 7873 host_impl_->active_tree()->set_background_color(SK_ColorWHITE);
7887 7874
7888 // Verify one quad is drawn when transparent background set is not set. 7875 // Verify one quad is drawn when transparent background set is not set.
7889 host_impl_->active_tree()->set_has_transparent_background(false); 7876 host_impl_->active_tree()->set_has_transparent_background(false);
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
8605 8592
8606 root_scroll->test_properties()->AddChild(std::move(child)); 8593 root_scroll->test_properties()->AddChild(std::move(child));
8607 root_clip->test_properties()->AddChild(std::move(root_scroll)); 8594 root_clip->test_properties()->AddChild(std::move(root_scroll));
8608 8595
8609 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 8596 host_impl_->active_tree()->BuildPropertyTreesForTesting();
8610 host_impl_->active_tree()->DidBecomeActive(); 8597 host_impl_->active_tree()->DidBecomeActive();
8611 8598
8612 host_impl_->SetViewportSize(surface_size); 8599 host_impl_->SetViewportSize(surface_size);
8613 DrawFrame(); 8600 DrawFrame();
8614 { 8601 {
8615 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 8602 EXPECT_EQ(
8616 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 8603 InputHandler::SCROLL_ON_IMPL_THREAD,
8617 InputHandler::WHEEL) 8604 host_impl_
8618 .thread); 8605 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL)
8606 .thread);
8619 8607
8620 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 8608 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
8621 host_impl_->FlingScrollBegin().thread); 8609 host_impl_->FlingScrollBegin().thread);
8622 8610
8623 gfx::Vector2d scroll_delta(0, 100); 8611 gfx::Vector2d scroll_delta(0, 100);
8624 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 8612 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
8625 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 8613 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
8626 8614
8627 host_impl_->ScrollEnd(EndState().get()); 8615 host_impl_->ScrollEnd(EndState().get());
8628 8616
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
8728 CreateScrollableLayer(child_scroll_layer_id, content_size, root); 8716 CreateScrollableLayer(child_scroll_layer_id, content_size, root);
8729 child_scroll->SetDrawsContent(false); 8717 child_scroll->SetDrawsContent(false);
8730 8718
8731 scroll_layer->test_properties()->AddChild(std::move(child_scroll)); 8719 scroll_layer->test_properties()->AddChild(std::move(child_scroll));
8732 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 8720 host_impl_->active_tree()->BuildPropertyTreesForTesting();
8733 8721
8734 DrawFrame(); 8722 DrawFrame();
8735 8723
8736 // We should have scrolled |child_scroll| even though it does not move 8724 // We should have scrolled |child_scroll| even though it does not move
8737 // any layer that is a drawn RSLL member. 8725 // any layer that is a drawn RSLL member.
8738 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 8726 EXPECT_EQ(
8739 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 8727 InputHandler::SCROLL_ON_IMPL_THREAD,
8740 InputHandler::WHEEL) 8728 host_impl_
8741 .thread); 8729 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL)
8730 .thread);
8742 8731
8743 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); 8732 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id());
8744 } 8733 }
8745 8734
8746 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed 8735 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed
8747 // in CompositorFrameMetadata. 8736 // in CompositorFrameMetadata.
8748 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { 8737 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) {
8749 std::unique_ptr<SolidColorLayerImpl> root = 8738 std::unique_ptr<SolidColorLayerImpl> root =
8750 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); 8739 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1);
8751 root->SetPosition(gfx::PointF()); 8740 root->SetPosition(gfx::PointF());
8752 root->SetBounds(gfx::Size(10, 10)); 8741 root->SetBounds(gfx::Size(10, 10));
8753 root->SetDrawsContent(true); 8742 root->SetDrawsContent(true);
8754 root->test_properties()->force_render_surface = true; 8743 root->test_properties()->force_render_surface = true;
8755 8744
8756 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); 8745 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root));
8757 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 8746 host_impl_->active_tree()->BuildPropertyTreesForTesting();
8758 8747
8759 FakeCompositorFrameSink* fake_compositor_frame_sink = 8748 FakeCompositorFrameSink* fake_compositor_frame_sink =
8760 static_cast<FakeCompositorFrameSink*>( 8749 static_cast<FakeCompositorFrameSink*>(
8761 host_impl_->compositor_frame_sink()); 8750 host_impl_->compositor_frame_sink());
8762 8751
8763 ui::LatencyInfo latency_info; 8752 ui::LatencyInfo latency_info;
8764 latency_info.AddLatencyNumber( 8753 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0,
8765 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); 8754 0);
8766 std::unique_ptr<SwapPromise> swap_promise( 8755 std::unique_ptr<SwapPromise> swap_promise(
8767 new LatencyInfoSwapPromise(latency_info)); 8756 new LatencyInfoSwapPromise(latency_info));
8768 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise)); 8757 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise));
8769 8758
8770 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); 8759 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize());
8771 LayerTreeHostImpl::FrameData frame; 8760 LayerTreeHostImpl::FrameData frame;
8772 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 8761 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
8773 EXPECT_TRUE(host_impl_->DrawLayers(&frame)); 8762 EXPECT_TRUE(host_impl_->DrawLayers(&frame));
8774 host_impl_->DidDrawAllLayers(frame); 8763 host_impl_->DidDrawAllLayers(frame);
8775 8764
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
8918 &set_needs_redraw_count, &forward_to_main_count)); 8907 &set_needs_redraw_count, &forward_to_main_count));
8919 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 8908 SetupScrollAndContentsLayers(gfx::Size(100, 100));
8920 8909
8921 // Scrolling normally should not trigger any forwarding. 8910 // Scrolling normally should not trigger any forwarding.
8922 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 8911 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
8923 host_impl_ 8912 host_impl_
8924 ->ScrollBegin(BeginState(gfx::Point()).get(), 8913 ->ScrollBegin(BeginState(gfx::Point()).get(),
8925 InputHandler::TOUCHSCREEN) 8914 InputHandler::TOUCHSCREEN)
8926 .thread); 8915 .thread);
8927 EXPECT_TRUE( 8916 EXPECT_TRUE(
8928 host_impl_->ScrollBy( 8917 host_impl_
8929 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()) 8918 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get())
8930 .did_scroll); 8919 .did_scroll);
8931 host_impl_->ScrollEnd(EndState().get()); 8920 host_impl_->ScrollEnd(EndState().get());
8932 8921
8933 EXPECT_EQ(0, set_needs_commit_count); 8922 EXPECT_EQ(0, set_needs_commit_count);
8934 EXPECT_EQ(1, set_needs_redraw_count); 8923 EXPECT_EQ(1, set_needs_redraw_count);
8935 EXPECT_EQ(0, forward_to_main_count); 8924 EXPECT_EQ(0, forward_to_main_count);
8936 8925
8937 // Scrolling with a scroll handler should defer the swap to the main 8926 // Scrolling with a scroll handler should defer the swap to the main
8938 // thread. 8927 // thread.
8939 host_impl_->active_tree()->set_have_scroll_event_handlers(true); 8928 host_impl_->active_tree()->set_have_scroll_event_handlers(true);
8940 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 8929 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
8941 host_impl_ 8930 host_impl_
8942 ->ScrollBegin(BeginState(gfx::Point()).get(), 8931 ->ScrollBegin(BeginState(gfx::Point()).get(),
8943 InputHandler::TOUCHSCREEN) 8932 InputHandler::TOUCHSCREEN)
8944 .thread); 8933 .thread);
8945 EXPECT_TRUE( 8934 EXPECT_TRUE(
8946 host_impl_->ScrollBy( 8935 host_impl_
8947 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()) 8936 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get())
8948 .did_scroll); 8937 .did_scroll);
8949 host_impl_->ScrollEnd(EndState().get()); 8938 host_impl_->ScrollEnd(EndState().get());
8950 8939
8951 EXPECT_EQ(0, set_needs_commit_count); 8940 EXPECT_EQ(0, set_needs_commit_count);
8952 EXPECT_EQ(2, set_needs_redraw_count); 8941 EXPECT_EQ(2, set_needs_redraw_count);
8953 EXPECT_EQ(1, forward_to_main_count); 8942 EXPECT_EQ(1, forward_to_main_count);
8954 } 8943 }
8955 } 8944 }
8956 8945
8957 class LayerTreeHostImplWithBrowserControlsTest : public LayerTreeHostImplTest { 8946 class LayerTreeHostImplWithBrowserControlsTest : public LayerTreeHostImplTest {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
9103 WheelUnhandledByBrowserControls) { 9092 WheelUnhandledByBrowserControls) {
9104 SetupScrollAndContentsLayers(gfx::Size(100, 200)); 9093 SetupScrollAndContentsLayers(gfx::Size(100, 200));
9105 host_impl_->SetViewportSize(gfx::Size(50, 100)); 9094 host_impl_->SetViewportSize(gfx::Size(50, 100));
9106 host_impl_->active_tree()->set_browser_controls_shrink_blink_size(true); 9095 host_impl_->active_tree()->set_browser_controls_shrink_blink_size(true);
9107 host_impl_->browser_controls_manager()->UpdateBrowserControlsState( 9096 host_impl_->browser_controls_manager()->UpdateBrowserControlsState(
9108 BOTH, SHOWN, false); 9097 BOTH, SHOWN, false);
9109 DrawFrame(); 9098 DrawFrame();
9110 9099
9111 LayerImpl* viewport_layer = host_impl_->InnerViewportScrollLayer(); 9100 LayerImpl* viewport_layer = host_impl_->InnerViewportScrollLayer();
9112 9101
9113 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 9102 EXPECT_EQ(
9114 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 9103 InputHandler::SCROLL_ON_IMPL_THREAD,
9115 InputHandler::WHEEL) 9104 host_impl_
9116 .thread); 9105 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL)
9106 .thread);
9117 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); 9107 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset());
9118 EXPECT_VECTOR_EQ(gfx::Vector2dF(), viewport_layer->CurrentScrollOffset()); 9108 EXPECT_VECTOR_EQ(gfx::Vector2dF(), viewport_layer->CurrentScrollOffset());
9119 9109
9120 // Wheel scrolls should not affect the browser controls, and should pass 9110 // Wheel scrolls should not affect the browser controls, and should pass
9121 // directly through to the viewport. 9111 // directly through to the viewport.
9122 const float delta = top_controls_height_; 9112 const float delta = top_controls_height_;
9123 EXPECT_TRUE( 9113 EXPECT_TRUE(
9124 host_impl_->ScrollBy( 9114 host_impl_
9125 UpdateState(gfx::Point(), gfx::Vector2d(0, delta)).get()) 9115 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, delta)).get())
9126 .did_scroll); 9116 .did_scroll);
9127 EXPECT_FLOAT_EQ(0, 9117 EXPECT_FLOAT_EQ(0,
9128 host_impl_->browser_controls_manager()->ControlsTopOffset()); 9118 host_impl_->browser_controls_manager()->ControlsTopOffset());
9129 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, delta), 9119 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, delta),
9130 viewport_layer->CurrentScrollOffset()); 9120 viewport_layer->CurrentScrollOffset());
9131 9121
9132 EXPECT_TRUE( 9122 EXPECT_TRUE(
9133 host_impl_->ScrollBy( 9123 host_impl_
9134 UpdateState(gfx::Point(), gfx::Vector2d(0, delta)).get()) 9124 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, delta)).get())
9135 .did_scroll); 9125 .did_scroll);
9136 EXPECT_FLOAT_EQ(0, 9126 EXPECT_FLOAT_EQ(0,
9137 host_impl_->browser_controls_manager()->ControlsTopOffset()); 9127 host_impl_->browser_controls_manager()->ControlsTopOffset());
9138 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, delta * 2), 9128 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, delta * 2),
9139 viewport_layer->CurrentScrollOffset()); 9129 viewport_layer->CurrentScrollOffset());
9140 } 9130 }
9141 9131
9142 TEST_F(LayerTreeHostImplWithBrowserControlsTest, 9132 TEST_F(LayerTreeHostImplWithBrowserControlsTest,
9143 BrowserControlsAnimationAtOrigin) { 9133 BrowserControlsAnimationAtOrigin) {
9144 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); 9134 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200));
(...skipping 10 matching lines...) Expand all
9155 InputHandler::TOUCHSCREEN) 9145 InputHandler::TOUCHSCREEN)
9156 .thread); 9146 .thread);
9157 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); 9147 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset());
9158 EXPECT_EQ(gfx::Vector2dF().ToString(), 9148 EXPECT_EQ(gfx::Vector2dF().ToString(),
9159 scroll_layer->CurrentScrollOffset().ToString()); 9149 scroll_layer->CurrentScrollOffset().ToString());
9160 9150
9161 // Scroll the browser controls partially. 9151 // Scroll the browser controls partially.
9162 const float residue = 35; 9152 const float residue = 35;
9163 float offset = top_controls_height_ - residue; 9153 float offset = top_controls_height_ - residue;
9164 EXPECT_TRUE( 9154 EXPECT_TRUE(
9165 host_impl_->ScrollBy( 9155 host_impl_
9166 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) 9156 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get())
9167 .did_scroll); 9157 .did_scroll);
9168 EXPECT_FLOAT_EQ(-offset, 9158 EXPECT_FLOAT_EQ(-offset,
9169 host_impl_->browser_controls_manager()->ControlsTopOffset()); 9159 host_impl_->browser_controls_manager()->ControlsTopOffset());
9170 EXPECT_EQ(gfx::Vector2dF().ToString(), 9160 EXPECT_EQ(gfx::Vector2dF().ToString(),
9171 scroll_layer->CurrentScrollOffset().ToString()); 9161 scroll_layer->CurrentScrollOffset().ToString());
9172 9162
9173 did_request_redraw_ = false; 9163 did_request_redraw_ = false;
9174 did_request_next_frame_ = false; 9164 did_request_next_frame_ = false;
9175 did_request_commit_ = false; 9165 did_request_commit_ = false;
9176 9166
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
9239 InputHandler::TOUCHSCREEN) 9229 InputHandler::TOUCHSCREEN)
9240 .thread); 9230 .thread);
9241 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); 9231 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset());
9242 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), 9232 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(),
9243 scroll_layer->CurrentScrollOffset().ToString()); 9233 scroll_layer->CurrentScrollOffset().ToString());
9244 9234
9245 // Scroll the browser controls partially. 9235 // Scroll the browser controls partially.
9246 const float residue = 15; 9236 const float residue = 15;
9247 float offset = top_controls_height_ - residue; 9237 float offset = top_controls_height_ - residue;
9248 EXPECT_TRUE( 9238 EXPECT_TRUE(
9249 host_impl_->ScrollBy( 9239 host_impl_
9250 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) 9240 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get())
9251 .did_scroll); 9241 .did_scroll);
9252 EXPECT_FLOAT_EQ(-offset, 9242 EXPECT_FLOAT_EQ(-offset,
9253 host_impl_->browser_controls_manager()->ControlsTopOffset()); 9243 host_impl_->browser_controls_manager()->ControlsTopOffset());
9254 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), 9244 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(),
9255 scroll_layer->CurrentScrollOffset().ToString()); 9245 scroll_layer->CurrentScrollOffset().ToString());
9256 9246
9257 did_request_redraw_ = false; 9247 did_request_redraw_ = false;
9258 did_request_next_frame_ = false; 9248 did_request_next_frame_ = false;
9259 did_request_commit_ = false; 9249 did_request_commit_ = false;
9260 9250
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
9315 InputHandler::TOUCHSCREEN) 9305 InputHandler::TOUCHSCREEN)
9316 .thread); 9306 .thread);
9317 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); 9307 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset());
9318 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), 9308 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(),
9319 scroll_layer->CurrentScrollOffset().ToString()); 9309 scroll_layer->CurrentScrollOffset().ToString());
9320 9310
9321 // Scroll the browser controls partially. 9311 // Scroll the browser controls partially.
9322 const float residue = 15; 9312 const float residue = 15;
9323 float offset = top_controls_height_ - residue; 9313 float offset = top_controls_height_ - residue;
9324 EXPECT_TRUE( 9314 EXPECT_TRUE(
9325 host_impl_->ScrollBy( 9315 host_impl_
9326 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) 9316 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get())
9327 .did_scroll); 9317 .did_scroll);
9328 EXPECT_FLOAT_EQ(-offset, 9318 EXPECT_FLOAT_EQ(-offset,
9329 host_impl_->browser_controls_manager()->ControlsTopOffset()); 9319 host_impl_->browser_controls_manager()->ControlsTopOffset());
9330 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), 9320 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(),
9331 scroll_layer->CurrentScrollOffset().ToString()); 9321 scroll_layer->CurrentScrollOffset().ToString());
9332 9322
9333 did_request_redraw_ = false; 9323 did_request_redraw_ = false;
9334 did_request_next_frame_ = false; 9324 did_request_next_frame_ = false;
9335 did_request_commit_ = false; 9325 did_request_commit_ = false;
9336 9326
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
9384 9374
9385 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 9375 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
9386 host_impl_ 9376 host_impl_
9387 ->ScrollBegin(BeginState(gfx::Point()).get(), 9377 ->ScrollBegin(BeginState(gfx::Point()).get(),
9388 InputHandler::TOUCHSCREEN) 9378 InputHandler::TOUCHSCREEN)
9389 .thread); 9379 .thread);
9390 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); 9380 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset());
9391 9381
9392 float offset = 50; 9382 float offset = 50;
9393 EXPECT_TRUE( 9383 EXPECT_TRUE(
9394 host_impl_->ScrollBy( 9384 host_impl_
9395 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) 9385 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get())
9396 .did_scroll); 9386 .did_scroll);
9397 EXPECT_EQ(-offset, 9387 EXPECT_EQ(-offset,
9398 host_impl_->browser_controls_manager()->ControlsTopOffset()); 9388 host_impl_->browser_controls_manager()->ControlsTopOffset());
9399 EXPECT_EQ(gfx::Vector2dF().ToString(), 9389 EXPECT_EQ(gfx::Vector2dF().ToString(),
9400 scroll_layer->CurrentScrollOffset().ToString()); 9390 scroll_layer->CurrentScrollOffset().ToString());
9401 9391
9402 EXPECT_TRUE( 9392 EXPECT_TRUE(
9403 host_impl_->ScrollBy( 9393 host_impl_
9404 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) 9394 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get())
9405 .did_scroll); 9395 .did_scroll);
9406 EXPECT_EQ(gfx::Vector2dF(0, offset).ToString(), 9396 EXPECT_EQ(gfx::Vector2dF(0, offset).ToString(),
9407 scroll_layer->CurrentScrollOffset().ToString()); 9397 scroll_layer->CurrentScrollOffset().ToString());
9408 9398
9409 EXPECT_TRUE( 9399 EXPECT_TRUE(
9410 host_impl_->ScrollBy( 9400 host_impl_
9411 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) 9401 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get())
9412 .did_scroll); 9402 .did_scroll);
9413 9403
9414 // Should have fully scrolled 9404 // Should have fully scrolled
9415 EXPECT_EQ(gfx::Vector2dF(0, scroll_layer->MaxScrollOffset().y()).ToString(), 9405 EXPECT_EQ(gfx::Vector2dF(0, scroll_layer->MaxScrollOffset().y()).ToString(),
9416 scroll_layer->CurrentScrollOffset().ToString()); 9406 scroll_layer->CurrentScrollOffset().ToString());
9417 9407
9418 float overscrollamount = 10; 9408 float overscrollamount = 10;
9419 9409
9420 // Overscroll the content 9410 // Overscroll the content
9421 EXPECT_FALSE( 9411 EXPECT_FALSE(host_impl_
9422 host_impl_->ScrollBy(UpdateState(gfx::Point(), 9412 ->ScrollBy(UpdateState(gfx::Point(),
9423 gfx::Vector2d(0, overscrollamount)) 9413 gfx::Vector2d(0, overscrollamount))
9424 .get()) 9414 .get())
9425 .did_scroll); 9415 .did_scroll);
9426 EXPECT_EQ(gfx::Vector2dF(0, 2 * offset).ToString(), 9416 EXPECT_EQ(gfx::Vector2dF(0, 2 * offset).ToString(),
9427 scroll_layer->CurrentScrollOffset().ToString()); 9417 scroll_layer->CurrentScrollOffset().ToString());
9428 EXPECT_EQ(gfx::Vector2dF(0, overscrollamount).ToString(), 9418 EXPECT_EQ(gfx::Vector2dF(0, overscrollamount).ToString(),
9429 host_impl_->accumulated_root_overscroll().ToString()); 9419 host_impl_->accumulated_root_overscroll().ToString());
9430 9420
9431 EXPECT_TRUE(host_impl_->ScrollBy(UpdateState(gfx::Point(), 9421 EXPECT_TRUE(
9432 gfx::Vector2d(0, -2 * offset)) 9422 host_impl_
9433 .get()) 9423 ->ScrollBy(
9434 .did_scroll); 9424 UpdateState(gfx::Point(), gfx::Vector2d(0, -2 * offset)).get())
9425 .did_scroll);
9435 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), 9426 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(),
9436 scroll_layer->CurrentScrollOffset().ToString()); 9427 scroll_layer->CurrentScrollOffset().ToString());
9437 EXPECT_EQ(-offset, 9428 EXPECT_EQ(-offset,
9438 host_impl_->browser_controls_manager()->ControlsTopOffset()); 9429 host_impl_->browser_controls_manager()->ControlsTopOffset());
9439 9430
9440 EXPECT_TRUE( 9431 EXPECT_TRUE(
9441 host_impl_->ScrollBy( 9432 host_impl_
9442 UpdateState(gfx::Point(), gfx::Vector2d(0, -offset)).get()) 9433 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, -offset)).get())
9443 .did_scroll); 9434 .did_scroll);
9444 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), 9435 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(),
9445 scroll_layer->CurrentScrollOffset().ToString()); 9436 scroll_layer->CurrentScrollOffset().ToString());
9446 9437
9447 // Browser controls should be fully visible 9438 // Browser controls should be fully visible
9448 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); 9439 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset());
9449 9440
9450 host_impl_->ScrollEnd(EndState().get()); 9441 host_impl_->ScrollEnd(EndState().get());
9451 } 9442 }
9452 9443
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
10498 begin_frame_args.frame_time = 10489 begin_frame_args.frame_time =
10499 start_time + base::TimeDelta::FromMilliseconds(50); 10490 start_time + base::TimeDelta::FromMilliseconds(50);
10500 host_impl_->WillBeginImplFrame(begin_frame_args); 10491 host_impl_->WillBeginImplFrame(begin_frame_args);
10501 host_impl_->Animate(); 10492 host_impl_->Animate();
10502 host_impl_->UpdateAnimationState(true); 10493 host_impl_->UpdateAnimationState(true);
10503 10494
10504 float y = scrolling_layer->CurrentScrollOffset().y(); 10495 float y = scrolling_layer->CurrentScrollOffset().y();
10505 EXPECT_TRUE(y > 1 && y < 49); 10496 EXPECT_TRUE(y > 1 && y < 49);
10506 10497
10507 // Perform instant scroll. 10498 // Perform instant scroll.
10508 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 10499 EXPECT_EQ(
10509 host_impl_->ScrollBegin(BeginState(gfx::Point(0, y)).get(), 10500 InputHandler::SCROLL_ON_IMPL_THREAD,
10510 InputHandler::WHEEL) 10501 host_impl_
10511 .thread); 10502 ->ScrollBegin(BeginState(gfx::Point(0, y)).get(), InputHandler::WHEEL)
10503 .thread);
10512 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y), 10504 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y),
10513 InputHandler::WHEEL)); 10505 InputHandler::WHEEL));
10514 host_impl_->ScrollBy( 10506 host_impl_->ScrollBy(
10515 UpdateState(gfx::Point(0, y), gfx::Vector2d(0, 50)).get()); 10507 UpdateState(gfx::Point(0, y), gfx::Vector2d(0, 50)).get());
10516 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), 10508 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50),
10517 InputHandler::WHEEL)); 10509 InputHandler::WHEEL));
10518 std::unique_ptr<ScrollState> scroll_state_end = EndState(); 10510 std::unique_ptr<ScrollState> scroll_state_end = EndState();
10519 host_impl_->ScrollEnd(scroll_state_end.get()); 10511 host_impl_->ScrollEnd(scroll_state_end.get());
10520 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), 10512 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(),
10521 InputHandler::WHEEL)); 10513 InputHandler::WHEEL));
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
11009 11001
11010 float page_scale_delta = 2.f; 11002 float page_scale_delta = 2.f;
11011 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 11003 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
11012 InputHandler::TOUCHSCREEN); 11004 InputHandler::TOUCHSCREEN);
11013 host_impl_->PinchGestureBegin(); 11005 host_impl_->PinchGestureBegin();
11014 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); 11006 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point());
11015 host_impl_->PinchGestureEnd(); 11007 host_impl_->PinchGestureEnd();
11016 host_impl_->ScrollEnd(EndState().get()); 11008 host_impl_->ScrollEnd(EndState().get());
11017 11009
11018 gfx::Vector2dF scroll_delta(0, 5); 11010 gfx::Vector2dF scroll_delta(0, 5);
11019 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 11011 EXPECT_EQ(
11020 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 11012 InputHandler::SCROLL_ON_IMPL_THREAD,
11021 InputHandler::WHEEL) 11013 host_impl_
11022 .thread); 11014 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL)
11015 .thread);
11023 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); 11016 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset());
11024 11017
11025 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 11018 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
11026 host_impl_->ScrollEnd(EndState().get()); 11019 host_impl_->ScrollEnd(EndState().get());
11027 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 2.5), 11020 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 2.5),
11028 scroll_layer->CurrentScrollOffset()); 11021 scroll_layer->CurrentScrollOffset());
11029 } 11022 }
11030 } 11023 }
11031 11024
11032 class LayerTreeHostImplCountingLostSurfaces : public LayerTreeHostImplTest { 11025 class LayerTreeHostImplCountingLostSurfaces : public LayerTreeHostImplTest {
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
11668 11661
11669 ScrollbarAnimationControllerThinning* scrollbar_1_animation_controller = 11662 ScrollbarAnimationControllerThinning* scrollbar_1_animation_controller =
11670 static_cast<ScrollbarAnimationControllerThinning*>( 11663 static_cast<ScrollbarAnimationControllerThinning*>(
11671 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id())); 11664 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id()));
11672 EXPECT_TRUE(scrollbar_1_animation_controller); 11665 EXPECT_TRUE(scrollbar_1_animation_controller);
11673 scrollbar_1_animation_controller->set_mouse_move_distance_for_test(40.f); 11666 scrollbar_1_animation_controller->set_mouse_move_distance_for_test(40.f);
11674 11667
11675 // Mouse moves close to the scrollbar, goes over the scrollbar, and 11668 // Mouse moves close to the scrollbar, goes over the scrollbar, and
11676 // moves back to where it was. 11669 // moves back to where it was.
11677 host_impl_->MouseMoveAt(gfx::Point(100, 150)); 11670 host_impl_->MouseMoveAt(gfx::Point(100, 150));
11678 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); 11671 EXPECT_FALSE(
11679 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); 11672 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11673 EXPECT_FALSE(
11674 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11680 host_impl_->MouseMoveAt(gfx::Point(40, 150)); 11675 host_impl_->MouseMoveAt(gfx::Point(40, 150));
11681 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); 11676 EXPECT_TRUE(
11682 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); 11677 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11678 EXPECT_FALSE(
11679 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11683 host_impl_->MouseMoveAt(gfx::Point(10, 150)); 11680 host_impl_->MouseMoveAt(gfx::Point(10, 150));
11684 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); 11681 EXPECT_TRUE(
11685 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); 11682 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11683 EXPECT_TRUE(
11684 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11686 host_impl_->MouseMoveAt(gfx::Point(40, 150)); 11685 host_impl_->MouseMoveAt(gfx::Point(40, 150));
11687 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); 11686 EXPECT_TRUE(
11688 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); 11687 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11688 EXPECT_FALSE(
11689 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11689 host_impl_->MouseMoveAt(gfx::Point(100, 150)); 11690 host_impl_->MouseMoveAt(gfx::Point(100, 150));
11690 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); 11691 EXPECT_FALSE(
11691 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); 11692 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11693 EXPECT_FALSE(
11694 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11692 11695
11693 // scrollbar_2 on child. 11696 // scrollbar_2 on child.
11694 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_2 = 11697 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_2 =
11695 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 11698 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(),
11696 scrollbar_2_id, VERTICAL, 5, 5, true, 11699 scrollbar_2_id, VERTICAL, 5, 5, true,
11697 true); 11700 true);
11698 std::unique_ptr<LayerImpl> child_clip = 11701 std::unique_ptr<LayerImpl> child_clip =
11699 LayerImpl::Create(host_impl_->active_tree(), child_clip_id); 11702 LayerImpl::Create(host_impl_->active_tree(), child_clip_id);
11700 std::unique_ptr<LayerImpl> child = 11703 std::unique_ptr<LayerImpl> child =
11701 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id); 11704 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id);
(...skipping 15 matching lines...) Expand all
11717 11720
11718 ScrollbarAnimationControllerThinning* scrollbar_2_animation_controller = 11721 ScrollbarAnimationControllerThinning* scrollbar_2_animation_controller =
11719 static_cast<ScrollbarAnimationControllerThinning*>( 11722 static_cast<ScrollbarAnimationControllerThinning*>(
11720 host_impl_->ScrollbarAnimationControllerForId(child_scroll_id)); 11723 host_impl_->ScrollbarAnimationControllerForId(child_scroll_id));
11721 EXPECT_TRUE(scrollbar_2_animation_controller); 11724 EXPECT_TRUE(scrollbar_2_animation_controller);
11722 scrollbar_2_animation_controller->set_mouse_move_distance_for_test(40.f); 11725 scrollbar_2_animation_controller->set_mouse_move_distance_for_test(40.f);
11723 11726
11724 // Mouse goes over scrollbar_2, moves close to scrollbar_2, moves close to 11727 // Mouse goes over scrollbar_2, moves close to scrollbar_2, moves close to
11725 // scrollbar_1, goes over scrollbar_1. 11728 // scrollbar_1, goes over scrollbar_1.
11726 host_impl_->MouseMoveAt(gfx::Point(60, 150)); 11729 host_impl_->MouseMoveAt(gfx::Point(60, 150));
11727 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); 11730 EXPECT_FALSE(
11728 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); 11731 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11729 EXPECT_TRUE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); 11732 EXPECT_FALSE(
11730 EXPECT_TRUE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); 11733 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11734 EXPECT_TRUE(
11735 scrollbar_2_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11736 EXPECT_TRUE(
11737 scrollbar_2_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11731 host_impl_->MouseMoveAt(gfx::Point(100, 150)); 11738 host_impl_->MouseMoveAt(gfx::Point(100, 150));
11732 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); 11739 EXPECT_FALSE(
11733 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); 11740 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11734 EXPECT_TRUE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); 11741 EXPECT_FALSE(
11735 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); 11742 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11743 EXPECT_TRUE(
11744 scrollbar_2_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11745 EXPECT_FALSE(
11746 scrollbar_2_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11736 host_impl_->MouseMoveAt(gfx::Point(40, 150)); 11747 host_impl_->MouseMoveAt(gfx::Point(40, 150));
11737 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); 11748 EXPECT_TRUE(
11738 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); 11749 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11739 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); 11750 EXPECT_FALSE(
11740 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); 11751 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11752 EXPECT_FALSE(
11753 scrollbar_2_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11754 EXPECT_FALSE(
11755 scrollbar_2_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11741 host_impl_->MouseMoveAt(gfx::Point(10, 150)); 11756 host_impl_->MouseMoveAt(gfx::Point(10, 150));
11742 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); 11757 EXPECT_TRUE(
11743 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); 11758 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11744 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); 11759 EXPECT_TRUE(
11745 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); 11760 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11761 EXPECT_FALSE(
11762 scrollbar_2_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11763 EXPECT_FALSE(
11764 scrollbar_2_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11746 } 11765 }
11747 11766
11748 } // namespace 11767 } // namespace
11749 } // namespace cc 11768 } // namespace cc
OLDNEW
« cc/trees/layer_tree_host_impl.cc ('K') | « cc/trees/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698