OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 if (scroll_info.scrolls[i].layer_id != id) | 198 if (scroll_info.scrolls[i].layer_id != id) |
199 continue; | 199 continue; |
200 times_encountered++; | 200 times_encountered++; |
201 } | 201 } |
202 | 202 |
203 ASSERT_EQ(0, times_encountered); | 203 ASSERT_EQ(0, times_encountered); |
204 } | 204 } |
205 | 205 |
206 LayerImpl* CreateScrollAndContentsLayers(LayerTreeImpl* layer_tree_impl, | 206 LayerImpl* CreateScrollAndContentsLayers(LayerTreeImpl* layer_tree_impl, |
207 gfx::Size content_size) { | 207 gfx::Size content_size) { |
208 const int kInnerViewportScrollLayerId = 2; | |
209 const int kInnerViewportClipLayerId = 4; | |
210 const int kPageScaleLayerId = 5; | |
211 scoped_ptr<LayerImpl> root = | 208 scoped_ptr<LayerImpl> root = |
212 LayerImpl::Create(layer_tree_impl, 1); | 209 LayerImpl::Create(layer_tree_impl, 1); |
213 root->SetBounds(content_size); | 210 root->SetBounds(content_size); |
214 root->SetContentBounds(content_size); | 211 root->SetContentBounds(content_size); |
215 root->SetPosition(gfx::PointF()); | 212 root->SetPosition(gfx::PointF()); |
216 root->SetAnchorPoint(gfx::PointF()); | 213 root->SetAnchorPoint(gfx::PointF()); |
217 | 214 |
218 scoped_ptr<LayerImpl> scroll = | 215 scoped_ptr<LayerImpl> scroll = |
219 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); | 216 LayerImpl::Create(layer_tree_impl, 2); |
220 LayerImpl* scroll_layer = scroll.get(); | 217 LayerImpl* scroll_layer = scroll.get(); |
221 scroll->SetIsContainerForFixedPositionLayers(true); | 218 scroll->SetScrollable(true); |
222 scroll->SetScrollOffset(gfx::Vector2d()); | 219 scroll->SetScrollOffset(gfx::Vector2d()); |
223 | 220 scroll->SetMaxScrollOffset(gfx::Vector2d(content_size.width(), |
224 scoped_ptr<LayerImpl> clip = | 221 content_size.height())); |
225 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); | |
226 clip->SetBounds( | |
227 gfx::Size(content_size.width() / 2, content_size.height() / 2)); | |
228 | |
229 scoped_ptr<LayerImpl> page_scale = | |
230 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); | |
231 | |
232 scroll->SetScrollClipLayer(clip->id()); | |
233 scroll->SetBounds(content_size); | 222 scroll->SetBounds(content_size); |
234 scroll->SetContentBounds(content_size); | 223 scroll->SetContentBounds(content_size); |
235 scroll->SetPosition(gfx::PointF()); | 224 scroll->SetPosition(gfx::PointF()); |
236 scroll->SetAnchorPoint(gfx::PointF()); | 225 scroll->SetAnchorPoint(gfx::PointF()); |
237 scroll->SetIsContainerForFixedPositionLayers(true); | |
238 | 226 |
239 scoped_ptr<LayerImpl> contents = | 227 scoped_ptr<LayerImpl> contents = |
240 LayerImpl::Create(layer_tree_impl, 3); | 228 LayerImpl::Create(layer_tree_impl, 3); |
241 contents->SetDrawsContent(true); | 229 contents->SetDrawsContent(true); |
242 contents->SetBounds(content_size); | 230 contents->SetBounds(content_size); |
243 contents->SetContentBounds(content_size); | 231 contents->SetContentBounds(content_size); |
244 contents->SetPosition(gfx::PointF()); | 232 contents->SetPosition(gfx::PointF()); |
245 contents->SetAnchorPoint(gfx::PointF()); | 233 contents->SetAnchorPoint(gfx::PointF()); |
246 | 234 |
247 scroll->AddChild(contents.Pass()); | 235 scroll->AddChild(contents.Pass()); |
248 page_scale->AddChild(scroll.Pass()); | 236 root->AddChild(scroll.Pass()); |
249 clip->AddChild(page_scale.Pass()); | |
250 root->AddChild(clip.Pass()); | |
251 | 237 |
252 layer_tree_impl->SetRootLayer(root.Pass()); | 238 layer_tree_impl->SetRootLayer(root.Pass()); |
253 layer_tree_impl->SetViewportLayersFromIds( | |
254 kPageScaleLayerId, kInnerViewportScrollLayerId, Layer::INVALID_ID); | |
255 | |
256 return scroll_layer; | 239 return scroll_layer; |
257 } | 240 } |
258 | 241 |
259 LayerImpl* SetupScrollAndContentsLayers(gfx::Size content_size) { | 242 LayerImpl* SetupScrollAndContentsLayers(gfx::Size content_size) { |
260 LayerImpl* scroll_layer = CreateScrollAndContentsLayers( | 243 LayerImpl* scroll_layer = CreateScrollAndContentsLayers( |
261 host_impl_->active_tree(), content_size); | 244 host_impl_->active_tree(), content_size); |
262 host_impl_->active_tree()->DidBecomeActive(); | 245 host_impl_->active_tree()->DidBecomeActive(); |
263 return scroll_layer; | 246 return scroll_layer; |
264 } | 247 } |
265 | 248 |
266 // TODO(wjmaclean) Add clip-layer pointer to parameters. | 249 scoped_ptr<LayerImpl> CreateScrollableLayer(int id, gfx::Size size) { |
267 scoped_ptr<LayerImpl> CreateScrollableLayer(int id, | |
268 gfx::Size size, | |
269 LayerImpl* clip_layer) { | |
270 DCHECK(clip_layer); | |
271 DCHECK(id != clip_layer->id()); | |
272 scoped_ptr<LayerImpl> layer = | 250 scoped_ptr<LayerImpl> layer = |
273 LayerImpl::Create(host_impl_->active_tree(), id); | 251 LayerImpl::Create(host_impl_->active_tree(), id); |
274 layer->SetScrollClipLayer(clip_layer->id()); | 252 layer->SetScrollable(true); |
275 layer->SetDrawsContent(true); | 253 layer->SetDrawsContent(true); |
276 layer->SetBounds(size); | 254 layer->SetBounds(size); |
277 layer->SetContentBounds(size); | 255 layer->SetContentBounds(size); |
278 clip_layer->SetBounds(gfx::Size(size.width() / 2, size.height() / 2)); | 256 layer->SetMaxScrollOffset(gfx::Vector2d(size.width() * 2, |
| 257 size.height() * 2)); |
279 return layer.Pass(); | 258 return layer.Pass(); |
280 } | 259 } |
281 | 260 |
282 void DrawFrame() { | 261 void DrawFrame() { |
283 LayerTreeHostImpl::FrameData frame; | 262 LayerTreeHostImpl::FrameData frame; |
284 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 263 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
285 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 264 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
286 host_impl_->DidDrawAllLayers(frame); | 265 host_impl_->DidDrawAllLayers(frame); |
287 } | 266 } |
288 | 267 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 | 415 |
437 scroll_info = host_impl_->ProcessScrollDeltas(); | 416 scroll_info = host_impl_->ProcessScrollDeltas(); |
438 ASSERT_EQ(scroll_info->scrolls.size(), 0u); | 417 ASSERT_EQ(scroll_info->scrolls.size(), 0u); |
439 ExpectClearedScrollDeltasRecursive(root); | 418 ExpectClearedScrollDeltasRecursive(root); |
440 } | 419 } |
441 | 420 |
442 TEST_F(LayerTreeHostImplTest, ScrollDeltaRepeatedScrolls) { | 421 TEST_F(LayerTreeHostImplTest, ScrollDeltaRepeatedScrolls) { |
443 gfx::Vector2d scroll_offset(20, 30); | 422 gfx::Vector2d scroll_offset(20, 30); |
444 gfx::Vector2d scroll_delta(11, -15); | 423 gfx::Vector2d scroll_delta(11, -15); |
445 { | 424 { |
446 scoped_ptr<LayerImpl> root_clip = | |
447 LayerImpl::Create(host_impl_->active_tree(), 2); | |
448 scoped_ptr<LayerImpl> root = | 425 scoped_ptr<LayerImpl> root = |
449 LayerImpl::Create(host_impl_->active_tree(), 1); | 426 LayerImpl::Create(host_impl_->active_tree(), 1); |
450 root_clip->SetBounds(gfx::Size(10, 10)); | 427 root->SetMaxScrollOffset(gfx::Vector2d(100, 100)); |
451 LayerImpl* root_layer = root.get(); | 428 root->SetScrollOffset(scroll_offset); |
452 root_clip->AddChild(root.Pass()); | 429 root->SetScrollable(true); |
453 root_layer->SetBounds(gfx::Size(110, 110)); | 430 root->ScrollBy(scroll_delta); |
454 root_layer->SetScrollClipLayer(root_clip->id()); | 431 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
455 root_layer->SetScrollOffset(scroll_offset); | |
456 root_layer->ScrollBy(scroll_delta); | |
457 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | |
458 } | 432 } |
459 LayerImpl* root = host_impl_->active_tree()->root_layer()->children()[0]; | 433 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
460 | 434 |
461 scoped_ptr<ScrollAndScaleSet> scroll_info; | 435 scoped_ptr<ScrollAndScaleSet> scroll_info; |
462 | 436 |
463 scroll_info = host_impl_->ProcessScrollDeltas(); | 437 scroll_info = host_impl_->ProcessScrollDeltas(); |
464 ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 438 ASSERT_EQ(scroll_info->scrolls.size(), 1u); |
465 EXPECT_VECTOR_EQ(root->sent_scroll_delta(), scroll_delta); | 439 EXPECT_VECTOR_EQ(root->sent_scroll_delta(), scroll_delta); |
466 ExpectContains(*scroll_info, root->id(), scroll_delta); | 440 ExpectContains(*scroll_info, root->id(), scroll_delta); |
467 | 441 |
468 gfx::Vector2d scroll_delta2(-5, 27); | 442 gfx::Vector2d scroll_delta2(-5, 27); |
469 root->ScrollBy(scroll_delta2); | 443 root->ScrollBy(scroll_delta2); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 gfx::Point(), SCROLL_FORWARD)); | 714 gfx::Point(), SCROLL_FORWARD)); |
741 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage( | 715 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage( |
742 gfx::Point(), SCROLL_BACKWARD)); | 716 gfx::Point(), SCROLL_BACKWARD)); |
743 | 717 |
744 scoped_ptr<PaintedScrollbarLayerImpl> vertical_scrollbar( | 718 scoped_ptr<PaintedScrollbarLayerImpl> vertical_scrollbar( |
745 PaintedScrollbarLayerImpl::Create( | 719 PaintedScrollbarLayerImpl::Create( |
746 host_impl_->active_tree(), | 720 host_impl_->active_tree(), |
747 20, | 721 20, |
748 VERTICAL)); | 722 VERTICAL)); |
749 vertical_scrollbar->SetBounds(gfx::Size(15, 1000)); | 723 vertical_scrollbar->SetBounds(gfx::Size(15, 1000)); |
750 host_impl_->InnerViewportScrollLayer()->AddScrollbar( | 724 host_impl_->RootScrollLayer()->SetVerticalScrollbarLayer( |
751 vertical_scrollbar.get()); | 725 vertical_scrollbar.get()); |
752 | 726 |
753 // Trying to scroll with a vertical scrollbar will succeed. | 727 // Trying to scroll with a vertical scrollbar will succeed. |
754 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( | 728 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( |
755 gfx::Point(), SCROLL_FORWARD)); | 729 gfx::Point(), SCROLL_FORWARD)); |
756 EXPECT_FLOAT_EQ(875.f, | 730 EXPECT_FLOAT_EQ(875.f, host_impl_->RootScrollLayer()->ScrollDelta().y()); |
757 host_impl_->InnerViewportScrollLayer()->ScrollDelta().y()); | |
758 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( | 731 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( |
759 gfx::Point(), SCROLL_BACKWARD)); | 732 gfx::Point(), SCROLL_BACKWARD)); |
760 } | 733 } |
761 | 734 |
762 // The user-scrollability breaks for zoomed-in pages. So disable this. | 735 // The user-scrollability breaks for zoomed-in pages. So disable this. |
763 // http://crbug.com/322223 | 736 // http://crbug.com/322223 |
764 TEST_F(LayerTreeHostImplTest, DISABLED_ScrollWithUserUnscrollableLayers) { | 737 TEST_F(LayerTreeHostImplTest, DISABLED_ScrollWithUserUnscrollableLayers) { |
765 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 738 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
766 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 739 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
767 | 740 |
768 gfx::Size overflow_size(400, 400); | 741 gfx::Size overflow_size(400, 400); |
769 ASSERT_EQ(1u, scroll_layer->children().size()); | 742 ASSERT_EQ(1u, scroll_layer->children().size()); |
770 LayerImpl* overflow = scroll_layer->children()[0]; | 743 LayerImpl* overflow = scroll_layer->children()[0]; |
771 overflow->SetBounds(overflow_size); | 744 overflow->SetBounds(overflow_size); |
772 overflow->SetContentBounds(overflow_size); | 745 overflow->SetContentBounds(overflow_size); |
773 overflow->SetScrollClipLayer(scroll_layer->parent()->id()); | 746 overflow->SetScrollable(true); |
| 747 overflow->SetMaxScrollOffset(gfx::Vector2d(overflow_size.width(), |
| 748 overflow_size.height())); |
774 overflow->SetScrollOffset(gfx::Vector2d()); | 749 overflow->SetScrollOffset(gfx::Vector2d()); |
775 overflow->SetPosition(gfx::PointF()); | 750 overflow->SetPosition(gfx::PointF()); |
776 overflow->SetAnchorPoint(gfx::PointF()); | 751 overflow->SetAnchorPoint(gfx::PointF()); |
777 | 752 |
778 DrawFrame(); | 753 DrawFrame(); |
779 gfx::Point scroll_position(10, 10); | 754 gfx::Point scroll_position(10, 10); |
780 | 755 |
781 EXPECT_EQ(InputHandler::ScrollStarted, | 756 EXPECT_EQ(InputHandler::ScrollStarted, |
782 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); | 757 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); |
783 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->TotalScrollOffset()); | 758 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->TotalScrollOffset()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 host_impl_->active_tree()->set_needs_update_draw_properties(); | 801 host_impl_->active_tree()->set_needs_update_draw_properties(); |
827 | 802 |
828 EXPECT_EQ(host_impl_->HaveTouchEventHandlersAt(gfx::Point()), false); | 803 EXPECT_EQ(host_impl_->HaveTouchEventHandlersAt(gfx::Point()), false); |
829 } | 804 } |
830 | 805 |
831 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { | 806 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { |
832 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 807 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
833 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 808 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
834 DrawFrame(); | 809 DrawFrame(); |
835 | 810 |
836 EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer()); | 811 EXPECT_EQ(scroll_layer, host_impl_->RootScrollLayer()); |
837 | 812 |
838 float min_page_scale = 1.f, max_page_scale = 4.f; | 813 float min_page_scale = 1.f, max_page_scale = 4.f; |
839 | 814 |
840 // The impl-based pinch zoom should adjust the max scroll position. | 815 // The impl-based pinch zoom should adjust the max scroll position. |
841 { | 816 { |
842 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, | 817 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, |
843 min_page_scale, | 818 min_page_scale, |
844 max_page_scale); | 819 max_page_scale); |
845 host_impl_->active_tree()->SetPageScaleDelta(1.f); | 820 host_impl_->active_tree()->SetPageScaleDelta(1.f); |
846 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 821 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
847 | 822 |
848 float page_scale_delta = 2.f; | 823 float page_scale_delta = 2.f; |
| 824 host_impl_->ScrollBegin(gfx::Point(50, 50), InputHandler::Gesture); |
| 825 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); |
| 826 host_impl_->PinchGestureEnd(); |
| 827 host_impl_->ScrollEnd(); |
| 828 EXPECT_TRUE(did_request_redraw_); |
| 829 EXPECT_TRUE(did_request_commit_); |
| 830 |
| 831 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 832 host_impl_->ProcessScrollDeltas(); |
| 833 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); |
| 834 |
| 835 EXPECT_EQ(gfx::Vector2d(75, 75).ToString(), |
| 836 scroll_layer->max_scroll_offset().ToString()); |
| 837 } |
| 838 |
| 839 // Scrolling after a pinch gesture should always be in local space. The |
| 840 // scroll deltas do not have the page scale factor applied. |
| 841 { |
| 842 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, |
| 843 min_page_scale, |
| 844 max_page_scale); |
| 845 host_impl_->active_tree()->SetPageScaleDelta(1.f); |
| 846 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 847 |
| 848 float page_scale_delta = 2.f; |
| 849 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); |
| 850 host_impl_->PinchGestureBegin(); |
| 851 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); |
| 852 host_impl_->PinchGestureEnd(); |
| 853 host_impl_->ScrollEnd(); |
| 854 |
| 855 gfx::Vector2d scroll_delta(0, 10); |
| 856 EXPECT_EQ(InputHandler::ScrollStarted, |
| 857 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 858 InputHandler::Wheel)); |
| 859 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 860 host_impl_->ScrollEnd(); |
| 861 |
| 862 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 863 host_impl_->ProcessScrollDeltas(); |
| 864 ExpectContains(*scroll_info.get(), |
| 865 scroll_layer->id(), |
| 866 scroll_delta); |
| 867 } |
| 868 } |
| 869 |
| 870 TEST_F(LayerTreeHostImplTest, PinchGesture) { |
| 871 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 872 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 873 DrawFrame(); |
| 874 |
| 875 LayerImpl* scroll_layer = host_impl_->RootScrollLayer(); |
| 876 DCHECK(scroll_layer); |
| 877 |
| 878 float min_page_scale = 1.f; |
| 879 float max_page_scale = 4.f; |
| 880 |
| 881 // Basic pinch zoom in gesture |
| 882 { |
| 883 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, |
| 884 min_page_scale, |
| 885 max_page_scale); |
| 886 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 887 |
| 888 float page_scale_delta = 2.f; |
849 host_impl_->ScrollBegin(gfx::Point(50, 50), InputHandler::Gesture); | 889 host_impl_->ScrollBegin(gfx::Point(50, 50), InputHandler::Gesture); |
850 host_impl_->PinchGestureBegin(); | 890 host_impl_->PinchGestureBegin(); |
851 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); | 891 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); |
852 host_impl_->PinchGestureEnd(); | 892 host_impl_->PinchGestureEnd(); |
853 host_impl_->ScrollEnd(); | 893 host_impl_->ScrollEnd(); |
854 EXPECT_TRUE(did_request_redraw_); | 894 EXPECT_TRUE(did_request_redraw_); |
855 EXPECT_TRUE(did_request_commit_); | 895 EXPECT_TRUE(did_request_commit_); |
856 | 896 |
857 scoped_ptr<ScrollAndScaleSet> scroll_info = | 897 scoped_ptr<ScrollAndScaleSet> scroll_info = |
858 host_impl_->ProcessScrollDeltas(); | 898 host_impl_->ProcessScrollDeltas(); |
859 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); | 899 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); |
860 | |
861 EXPECT_EQ(gfx::Vector2d(75, 75).ToString(), | |
862 scroll_layer->MaxScrollOffset().ToString()); | |
863 } | |
864 | |
865 // Scrolling after a pinch gesture should always be in local space. The | |
866 // scroll deltas do not have the page scale factor applied. | |
867 { | |
868 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, | |
869 min_page_scale, | |
870 max_page_scale); | |
871 host_impl_->active_tree()->SetPageScaleDelta(1.f); | |
872 scroll_layer->SetScrollDelta(gfx::Vector2d()); | |
873 | |
874 float page_scale_delta = 2.f; | |
875 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); | |
876 host_impl_->PinchGestureBegin(); | |
877 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); | |
878 host_impl_->PinchGestureEnd(); | |
879 host_impl_->ScrollEnd(); | |
880 | |
881 gfx::Vector2d scroll_delta(0, 10); | |
882 EXPECT_EQ(InputHandler::ScrollStarted, | |
883 host_impl_->ScrollBegin(gfx::Point(5, 5), | |
884 InputHandler::Wheel)); | |
885 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | |
886 host_impl_->ScrollEnd(); | |
887 | |
888 scoped_ptr<ScrollAndScaleSet> scroll_info = | |
889 host_impl_->ProcessScrollDeltas(); | |
890 ExpectContains(*scroll_info.get(), | |
891 scroll_layer->id(), | |
892 scroll_delta); | |
893 } | |
894 } | |
895 | |
896 TEST_F(LayerTreeHostImplTest, PinchGesture) { | |
897 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | |
898 host_impl_->SetViewportSize(gfx::Size(50, 50)); | |
899 DrawFrame(); | |
900 | |
901 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); | |
902 DCHECK(scroll_layer); | |
903 | |
904 float min_page_scale = 1.f; | |
905 float max_page_scale = 4.f; | |
906 | |
907 // Basic pinch zoom in gesture | |
908 { | |
909 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, | |
910 min_page_scale, | |
911 max_page_scale); | |
912 scroll_layer->SetScrollDelta(gfx::Vector2d()); | |
913 | |
914 float page_scale_delta = 2.f; | |
915 host_impl_->ScrollBegin(gfx::Point(50, 50), InputHandler::Gesture); | |
916 host_impl_->PinchGestureBegin(); | |
917 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); | |
918 host_impl_->PinchGestureEnd(); | |
919 host_impl_->ScrollEnd(); | |
920 EXPECT_TRUE(did_request_redraw_); | |
921 EXPECT_TRUE(did_request_commit_); | |
922 | |
923 scoped_ptr<ScrollAndScaleSet> scroll_info = | |
924 host_impl_->ProcessScrollDeltas(); | |
925 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); | |
926 } | 900 } |
927 | 901 |
928 // Zoom-in clamping | 902 // Zoom-in clamping |
929 { | 903 { |
930 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, | 904 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, |
931 min_page_scale, | 905 min_page_scale, |
932 max_page_scale); | 906 max_page_scale); |
933 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 907 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
934 float page_scale_delta = 10.f; | 908 float page_scale_delta = 10.f; |
935 | 909 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-10, -10)); | 985 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-10, -10)); |
1012 } | 986 } |
1013 | 987 |
1014 // Two-finger panning should work when starting fully zoomed out. | 988 // Two-finger panning should work when starting fully zoomed out. |
1015 { | 989 { |
1016 host_impl_->active_tree()->SetPageScaleFactorAndLimits(0.5f, | 990 host_impl_->active_tree()->SetPageScaleFactorAndLimits(0.5f, |
1017 0.5f, | 991 0.5f, |
1018 4.f); | 992 4.f); |
1019 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 993 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
1020 scroll_layer->SetScrollOffset(gfx::Vector2d(0, 0)); | 994 scroll_layer->SetScrollOffset(gfx::Vector2d(0, 0)); |
| 995 host_impl_->active_tree()->UpdateMaxScrollOffset(); |
1021 | 996 |
1022 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Gesture); | 997 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Gesture); |
1023 host_impl_->PinchGestureBegin(); | 998 host_impl_->PinchGestureBegin(); |
1024 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); | 999 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); |
1025 host_impl_->PinchGestureUpdate(1.f, gfx::Point(0, 0)); | 1000 host_impl_->PinchGestureUpdate(1.f, gfx::Point(0, 0)); |
1026 host_impl_->ScrollBy(gfx::Point(0, 0), gfx::Vector2d(10, 10)); | 1001 host_impl_->ScrollBy(gfx::Point(0, 0), gfx::Vector2d(10, 10)); |
1027 host_impl_->PinchGestureUpdate(1.f, gfx::Point(10, 10)); | 1002 host_impl_->PinchGestureUpdate(1.f, gfx::Point(10, 10)); |
1028 host_impl_->PinchGestureEnd(); | 1003 host_impl_->PinchGestureEnd(); |
1029 host_impl_->ScrollEnd(); | 1004 host_impl_->ScrollEnd(); |
1030 | 1005 |
1031 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1006 scoped_ptr<ScrollAndScaleSet> scroll_info = |
1032 host_impl_->ProcessScrollDeltas(); | 1007 host_impl_->ProcessScrollDeltas(); |
1033 EXPECT_EQ(scroll_info->page_scale_delta, 2.f); | 1008 EXPECT_EQ(scroll_info->page_scale_delta, 2.f); |
1034 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(20, 20)); | 1009 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(20, 20)); |
1035 } | 1010 } |
1036 } | 1011 } |
1037 | 1012 |
1038 TEST_F(LayerTreeHostImplTest, PageScaleAnimation) { | 1013 TEST_F(LayerTreeHostImplTest, PageScaleAnimation) { |
1039 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1014 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
1040 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1015 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
1041 DrawFrame(); | 1016 DrawFrame(); |
1042 | 1017 |
1043 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); | 1018 LayerImpl* scroll_layer = host_impl_->RootScrollLayer(); |
1044 DCHECK(scroll_layer); | 1019 DCHECK(scroll_layer); |
1045 | 1020 |
1046 float min_page_scale = 0.5f; | 1021 float min_page_scale = 0.5f; |
1047 float max_page_scale = 4.f; | 1022 float max_page_scale = 4.f; |
1048 base::TimeTicks start_time = base::TimeTicks() + | 1023 base::TimeTicks start_time = base::TimeTicks() + |
1049 base::TimeDelta::FromSeconds(1); | 1024 base::TimeDelta::FromSeconds(1); |
1050 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 1025 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
1051 base::TimeTicks halfway_through_animation = start_time + duration / 2; | 1026 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
1052 base::TimeTicks end_time = start_time + duration; | 1027 base::TimeTicks end_time = start_time + duration; |
1053 | 1028 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1103 // Pushed to (0,0) via clamping against contents layer size. | 1078 // Pushed to (0,0) via clamping against contents layer size. |
1104 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50)); | 1079 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50)); |
1105 } | 1080 } |
1106 } | 1081 } |
1107 | 1082 |
1108 TEST_F(LayerTreeHostImplTest, PageScaleAnimationNoOp) { | 1083 TEST_F(LayerTreeHostImplTest, PageScaleAnimationNoOp) { |
1109 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1084 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
1110 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1085 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
1111 DrawFrame(); | 1086 DrawFrame(); |
1112 | 1087 |
1113 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); | 1088 LayerImpl* scroll_layer = host_impl_->RootScrollLayer(); |
1114 DCHECK(scroll_layer); | 1089 DCHECK(scroll_layer); |
1115 | 1090 |
1116 float min_page_scale = 0.5f; | 1091 float min_page_scale = 0.5f; |
1117 float max_page_scale = 4.f; | 1092 float max_page_scale = 4.f; |
1118 base::TimeTicks start_time = base::TimeTicks() + | 1093 base::TimeTicks start_time = base::TimeTicks() + |
1119 base::TimeDelta::FromSeconds(1); | 1094 base::TimeDelta::FromSeconds(1); |
1120 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 1095 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
1121 base::TimeTicks halfway_through_animation = start_time + duration / 2; | 1096 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
1122 base::TimeTicks end_time = start_time + duration; | 1097 base::TimeTicks end_time = start_time + duration; |
1123 | 1098 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 host_impl_ = make_scoped_ptr(host_impl_override_time); | 1158 host_impl_ = make_scoped_ptr(host_impl_override_time); |
1184 host_impl_->InitializeRenderer(CreateOutputSurface()); | 1159 host_impl_->InitializeRenderer(CreateOutputSurface()); |
1185 host_impl_->SetViewportSize(viewport_size); | 1160 host_impl_->SetViewportSize(viewport_size); |
1186 | 1161 |
1187 scoped_ptr<LayerImpl> root = | 1162 scoped_ptr<LayerImpl> root = |
1188 LayerImpl::Create(host_impl_->active_tree(), 1); | 1163 LayerImpl::Create(host_impl_->active_tree(), 1); |
1189 root->SetBounds(viewport_size); | 1164 root->SetBounds(viewport_size); |
1190 | 1165 |
1191 scoped_ptr<LayerImpl> scroll = | 1166 scoped_ptr<LayerImpl> scroll = |
1192 LayerImpl::Create(host_impl_->active_tree(), 2); | 1167 LayerImpl::Create(host_impl_->active_tree(), 2); |
1193 scroll->SetScrollClipLayer(root->id()); | 1168 scroll->SetScrollable(true); |
1194 scroll->SetScrollOffset(gfx::Vector2d()); | 1169 scroll->SetScrollOffset(gfx::Vector2d()); |
1195 root->SetBounds(viewport_size); | 1170 scroll->SetMaxScrollOffset(gfx::Vector2d(content_size.width(), |
| 1171 content_size.height())); |
1196 scroll->SetBounds(content_size); | 1172 scroll->SetBounds(content_size); |
1197 scroll->SetContentBounds(content_size); | 1173 scroll->SetContentBounds(content_size); |
1198 scroll->SetIsContainerForFixedPositionLayers(true); | |
1199 | 1174 |
1200 scoped_ptr<LayerImpl> contents = | 1175 scoped_ptr<LayerImpl> contents = |
1201 LayerImpl::Create(host_impl_->active_tree(), 3); | 1176 LayerImpl::Create(host_impl_->active_tree(), 3); |
1202 contents->SetDrawsContent(true); | 1177 contents->SetDrawsContent(true); |
1203 contents->SetBounds(content_size); | 1178 contents->SetBounds(content_size); |
1204 contents->SetContentBounds(content_size); | 1179 contents->SetContentBounds(content_size); |
1205 | 1180 |
1206 scoped_ptr<PaintedScrollbarLayerImpl> scrollbar = | 1181 scoped_ptr<PaintedScrollbarLayerImpl> scrollbar = |
1207 PaintedScrollbarLayerImpl::Create(host_impl_->active_tree(), 4, VERTICAL); | 1182 PaintedScrollbarLayerImpl::Create(host_impl_->active_tree(), 4, VERTICAL); |
1208 scrollbar->SetScrollLayerById(2); | 1183 scroll->SetVerticalScrollbarLayer(scrollbar.get()); |
1209 scrollbar->SetClipLayerById(1); | |
1210 | 1184 |
1211 scroll->AddChild(contents.Pass()); | 1185 scroll->AddChild(contents.Pass()); |
1212 root->AddChild(scroll.Pass()); | 1186 root->AddChild(scroll.Pass()); |
1213 root->AddChild(scrollbar.PassAs<LayerImpl>()); | 1187 root->AddChild(scrollbar.PassAs<LayerImpl>()); |
1214 | 1188 |
1215 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 1189 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
1216 host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID); | |
1217 host_impl_->active_tree()->DidBecomeActive(); | 1190 host_impl_->active_tree()->DidBecomeActive(); |
1218 DrawFrame(); | 1191 DrawFrame(); |
1219 | 1192 |
1220 base::TimeTicks fake_now = gfx::FrameTime::Now(); | 1193 base::TimeTicks fake_now = gfx::FrameTime::Now(); |
1221 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); | 1194 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); |
1222 | 1195 |
1223 // If no scroll happened recently, StartScrollbarAnimation should have no | 1196 // If no scroll happened recently, StartScrollbarAnimation should have no |
1224 // effect. | 1197 // effect. |
1225 host_impl_->StartScrollbarAnimation(); | 1198 host_impl_->StartScrollbarAnimation(); |
1226 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); | 1199 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); |
(...skipping 30 matching lines...) Expand all Loading... |
1257 // If no scroll happened recently, StartScrollbarAnimation should have no | 1230 // If no scroll happened recently, StartScrollbarAnimation should have no |
1258 // effect. | 1231 // effect. |
1259 fake_now += base::TimeDelta::FromMilliseconds(25); | 1232 fake_now += base::TimeDelta::FromMilliseconds(25); |
1260 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); | 1233 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); |
1261 host_impl_->StartScrollbarAnimation(); | 1234 host_impl_->StartScrollbarAnimation(); |
1262 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); | 1235 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); |
1263 EXPECT_FALSE(did_request_redraw_); | 1236 EXPECT_FALSE(did_request_redraw_); |
1264 | 1237 |
1265 // Setting the scroll offset outside a scroll should also cause the scrollbar | 1238 // Setting the scroll offset outside a scroll should also cause the scrollbar |
1266 // to appear and to schedule a fade. | 1239 // to appear and to schedule a fade. |
1267 host_impl_->InnerViewportScrollLayer()->SetScrollOffset(gfx::Vector2d(5, 5)); | 1240 host_impl_->RootScrollLayer()->SetScrollOffset(gfx::Vector2d(5, 5)); |
1268 host_impl_->StartScrollbarAnimation(); | 1241 host_impl_->StartScrollbarAnimation(); |
1269 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), | 1242 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), |
1270 requested_scrollbar_animation_delay_); | 1243 requested_scrollbar_animation_delay_); |
1271 EXPECT_FALSE(did_request_redraw_); | 1244 EXPECT_FALSE(did_request_redraw_); |
1272 requested_scrollbar_animation_delay_ = base::TimeDelta(); | 1245 requested_scrollbar_animation_delay_ = base::TimeDelta(); |
1273 | 1246 |
1274 // None of the above should have called CurrentFrameTimeTicks, so if we call | 1247 // None of the above should have called CurrentFrameTimeTicks, so if we call |
1275 // it now we should get the current time. | 1248 // it now we should get the current time. |
1276 fake_now += base::TimeDelta::FromMilliseconds(10); | 1249 fake_now += base::TimeDelta::FromMilliseconds(10); |
1277 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); | 1250 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); |
(...skipping 13 matching lines...) Expand all Loading... |
1291 CreateHostImpl(settings, CreateOutputSurface()); | 1264 CreateHostImpl(settings, CreateOutputSurface()); |
1292 host_impl_->SetDeviceScaleFactor(device_scale_factor); | 1265 host_impl_->SetDeviceScaleFactor(device_scale_factor); |
1293 host_impl_->SetViewportSize(device_viewport_size); | 1266 host_impl_->SetViewportSize(device_viewport_size); |
1294 | 1267 |
1295 scoped_ptr<LayerImpl> root = | 1268 scoped_ptr<LayerImpl> root = |
1296 LayerImpl::Create(host_impl_->active_tree(), 1); | 1269 LayerImpl::Create(host_impl_->active_tree(), 1); |
1297 root->SetBounds(viewport_size); | 1270 root->SetBounds(viewport_size); |
1298 | 1271 |
1299 scoped_ptr<LayerImpl> scroll = | 1272 scoped_ptr<LayerImpl> scroll = |
1300 LayerImpl::Create(host_impl_->active_tree(), 2); | 1273 LayerImpl::Create(host_impl_->active_tree(), 2); |
1301 scroll->SetScrollClipLayer(root->id()); | 1274 scroll->SetScrollable(true); |
1302 scroll->SetScrollOffset(gfx::Vector2d()); | 1275 scroll->SetScrollOffset(gfx::Vector2d()); |
| 1276 scroll->SetMaxScrollOffset(gfx::Vector2d(content_size.width(), |
| 1277 content_size.height())); |
1303 scroll->SetBounds(content_size); | 1278 scroll->SetBounds(content_size); |
1304 scroll->SetContentBounds(content_size); | 1279 scroll->SetContentBounds(content_size); |
1305 scroll->SetIsContainerForFixedPositionLayers(true); | |
1306 | 1280 |
1307 scoped_ptr<LayerImpl> contents = | 1281 scoped_ptr<LayerImpl> contents = |
1308 LayerImpl::Create(host_impl_->active_tree(), 3); | 1282 LayerImpl::Create(host_impl_->active_tree(), 3); |
1309 contents->SetDrawsContent(true); | 1283 contents->SetDrawsContent(true); |
1310 contents->SetBounds(content_size); | 1284 contents->SetBounds(content_size); |
1311 contents->SetContentBounds(content_size); | 1285 contents->SetContentBounds(content_size); |
1312 | 1286 |
1313 // The scrollbar is on the right side. | 1287 // The scrollbar is on the right side. |
1314 scoped_ptr<PaintedScrollbarLayerImpl> scrollbar = | 1288 scoped_ptr<PaintedScrollbarLayerImpl> scrollbar = |
1315 PaintedScrollbarLayerImpl::Create(host_impl_->active_tree(), 5, VERTICAL); | 1289 PaintedScrollbarLayerImpl::Create(host_impl_->active_tree(), 5, VERTICAL); |
1316 scrollbar->SetDrawsContent(true); | 1290 scrollbar->SetDrawsContent(true); |
1317 scrollbar->SetBounds(gfx::Size(15, viewport_size.height())); | 1291 scrollbar->SetBounds(gfx::Size(15, viewport_size.height())); |
1318 scrollbar->SetContentBounds(gfx::Size(15, viewport_size.height())); | 1292 scrollbar->SetContentBounds(gfx::Size(15, viewport_size.height())); |
1319 scrollbar->SetPosition(gfx::Point(285, 0)); | 1293 scrollbar->SetPosition(gfx::Point(285, 0)); |
1320 scrollbar->SetScrollLayerById(2); | 1294 scroll->SetVerticalScrollbarLayer(scrollbar.get()); |
1321 | 1295 |
1322 scroll->AddChild(contents.Pass()); | 1296 scroll->AddChild(contents.Pass()); |
1323 root->AddChild(scroll.Pass()); | 1297 root->AddChild(scroll.Pass()); |
1324 root->AddChild(scrollbar.PassAs<LayerImpl>()); | 1298 root->AddChild(scrollbar.PassAs<LayerImpl>()); |
1325 | 1299 |
1326 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 1300 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
1327 host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID); | |
1328 host_impl_->active_tree()->DidBecomeActive(); | 1301 host_impl_->active_tree()->DidBecomeActive(); |
1329 DrawFrame(); | 1302 DrawFrame(); |
1330 | 1303 |
1331 LayerImpl* root_scroll = | 1304 LayerImpl* root_scroll = host_impl_->active_tree()->RootScrollLayer(); |
1332 host_impl_->active_tree()->InnerViewportScrollLayer(); | |
1333 ASSERT_TRUE(root_scroll->scrollbar_animation_controller()); | 1305 ASSERT_TRUE(root_scroll->scrollbar_animation_controller()); |
1334 ScrollbarAnimationControllerThinning* scrollbar_animation_controller = | 1306 ScrollbarAnimationControllerThinning* scrollbar_animation_controller = |
1335 static_cast<ScrollbarAnimationControllerThinning*>( | 1307 static_cast<ScrollbarAnimationControllerThinning*>( |
1336 root_scroll->scrollbar_animation_controller()); | 1308 root_scroll->scrollbar_animation_controller()); |
1337 scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f); | 1309 scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f); |
1338 | 1310 |
1339 host_impl_->MouseMoveAt(gfx::Point(1, 1)); | 1311 host_impl_->MouseMoveAt(gfx::Point(1, 1)); |
1340 EXPECT_FALSE(scrollbar_animation_controller->mouse_is_near_scrollbar()); | 1312 EXPECT_FALSE(scrollbar_animation_controller->mouse_is_near_scrollbar()); |
1341 | 1313 |
1342 host_impl_->MouseMoveAt(gfx::Point(200, 50)); | 1314 host_impl_->MouseMoveAt(gfx::Point(200, 50)); |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1770 true, | 1742 true, |
1771 host_impl_->resource_provider())); | 1743 host_impl_->resource_provider())); |
1772 | 1744 |
1773 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 1745 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
1774 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1746 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
1775 host_impl_->DidDrawAllLayers(frame); | 1747 host_impl_->DidDrawAllLayers(frame); |
1776 } | 1748 } |
1777 | 1749 |
1778 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { | 1750 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { |
1779 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 1751 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
1780 root->SetScrollClipLayer(Layer::INVALID_ID); | 1752 root->SetScrollable(false); |
1781 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 1753 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
1782 DrawFrame(); | 1754 DrawFrame(); |
1783 | 1755 |
1784 // Scroll event is ignored because layer is not scrollable. | 1756 // Scroll event is ignored because layer is not scrollable. |
1785 EXPECT_EQ(InputHandler::ScrollIgnored, | 1757 EXPECT_EQ(InputHandler::ScrollIgnored, |
1786 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 1758 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
1787 EXPECT_FALSE(did_request_redraw_); | 1759 EXPECT_FALSE(did_request_redraw_); |
1788 EXPECT_FALSE(did_request_commit_); | 1760 EXPECT_FALSE(did_request_commit_); |
1789 } | 1761 } |
1790 | 1762 |
1791 TEST_F(LayerTreeHostImplTest, ScrollNonScrollableRootWithTopControls) { | 1763 TEST_F(LayerTreeHostImplTest, ScrollNonScrollableRootWithTopControls) { |
1792 LayerTreeSettings settings; | 1764 LayerTreeSettings settings; |
1793 settings.calculate_top_controls_position = true; | 1765 settings.calculate_top_controls_position = true; |
1794 settings.top_controls_height = 50; | 1766 settings.top_controls_height = 50; |
1795 | 1767 |
1796 CreateHostImpl(settings, CreateOutputSurface()); | 1768 CreateHostImpl(settings, CreateOutputSurface()); |
1797 | 1769 |
1798 gfx::Size layer_size(10, 10); | 1770 gfx::Size layer_size(5, 5); |
1799 gfx::Size clip_size(5, 5); | |
1800 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 1771 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
1801 scoped_ptr<LayerImpl> root_clip = | 1772 root->SetScrollable(true); |
1802 LayerImpl::Create(host_impl_->active_tree(), 2); | 1773 root->SetMaxScrollOffset(gfx::Vector2d(layer_size.width(), |
1803 root_clip->SetBounds(clip_size); | 1774 layer_size.height())); |
1804 root->SetScrollClipLayer(root_clip->id()); | |
1805 root->SetBounds(layer_size); | 1775 root->SetBounds(layer_size); |
1806 root->SetContentBounds(layer_size); | 1776 root->SetContentBounds(layer_size); |
1807 root->SetPosition(gfx::PointF()); | 1777 root->SetPosition(gfx::PointF()); |
1808 root->SetAnchorPoint(gfx::PointF()); | 1778 root->SetAnchorPoint(gfx::PointF()); |
1809 root->SetDrawsContent(false); | 1779 root->SetDrawsContent(false); |
1810 int root_id = root->id(); | 1780 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
1811 root_clip->AddChild(root.Pass()); | 1781 host_impl_->active_tree()->FindRootScrollLayer(); |
1812 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | |
1813 host_impl_->active_tree()->SetViewportLayersFromIds( | |
1814 root_id, root_id, Layer::INVALID_ID); | |
1815 DrawFrame(); | 1782 DrawFrame(); |
1816 | 1783 |
1817 EXPECT_EQ(InputHandler::ScrollStarted, | 1784 EXPECT_EQ(InputHandler::ScrollStarted, |
1818 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 1785 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
1819 | 1786 |
1820 host_impl_->top_controls_manager()->ScrollBegin(); | 1787 host_impl_->top_controls_manager()->ScrollBegin(); |
1821 host_impl_->top_controls_manager()->ScrollBy(gfx::Vector2dF(0.f, 50.f)); | 1788 host_impl_->top_controls_manager()->ScrollBy(gfx::Vector2dF(0.f, 50.f)); |
1822 host_impl_->top_controls_manager()->ScrollEnd(); | 1789 host_impl_->top_controls_manager()->ScrollEnd(); |
1823 EXPECT_EQ(host_impl_->top_controls_manager()->content_top_offset(), 0.f); | 1790 EXPECT_EQ(host_impl_->top_controls_manager()->content_top_offset(), 0.f); |
1824 | 1791 |
1825 host_impl_->ScrollEnd(); | 1792 host_impl_->ScrollEnd(); |
1826 | 1793 |
1827 EXPECT_EQ(InputHandler::ScrollStarted, | 1794 EXPECT_EQ(InputHandler::ScrollStarted, |
1828 host_impl_->ScrollBegin(gfx::Point(), | 1795 host_impl_->ScrollBegin(gfx::Point(), |
1829 InputHandler::Gesture)); | 1796 InputHandler::Gesture)); |
1830 } | 1797 } |
1831 | 1798 |
1832 TEST_F(LayerTreeHostImplTest, ScrollNonCompositedRoot) { | 1799 TEST_F(LayerTreeHostImplTest, ScrollNonCompositedRoot) { |
1833 // Test the configuration where a non-composited root layer is embedded in a | 1800 // Test the configuration where a non-composited root layer is embedded in a |
1834 // scrollable outer layer. | 1801 // scrollable outer layer. |
1835 gfx::Size surface_size(10, 10); | 1802 gfx::Size surface_size(10, 10); |
1836 gfx::Size contents_size(20, 20); | |
1837 | 1803 |
1838 scoped_ptr<LayerImpl> content_layer = | 1804 scoped_ptr<LayerImpl> content_layer = |
1839 LayerImpl::Create(host_impl_->active_tree(), 1); | 1805 LayerImpl::Create(host_impl_->active_tree(), 1); |
1840 content_layer->SetDrawsContent(true); | 1806 content_layer->SetDrawsContent(true); |
1841 content_layer->SetPosition(gfx::PointF()); | 1807 content_layer->SetPosition(gfx::PointF()); |
1842 content_layer->SetAnchorPoint(gfx::PointF()); | 1808 content_layer->SetAnchorPoint(gfx::PointF()); |
1843 content_layer->SetBounds(contents_size); | 1809 content_layer->SetBounds(surface_size); |
1844 content_layer->SetContentBounds(contents_size); | 1810 content_layer->SetContentBounds(gfx::Size(surface_size.width() * 2, |
| 1811 surface_size.height() * 2)); |
1845 content_layer->SetContentsScale(2.f, 2.f); | 1812 content_layer->SetContentsScale(2.f, 2.f); |
1846 | 1813 |
1847 scoped_ptr<LayerImpl> scroll_clip_layer = | |
1848 LayerImpl::Create(host_impl_->active_tree(), 3); | |
1849 scroll_clip_layer->SetBounds(surface_size); | |
1850 | |
1851 scoped_ptr<LayerImpl> scroll_layer = | 1814 scoped_ptr<LayerImpl> scroll_layer = |
1852 LayerImpl::Create(host_impl_->active_tree(), 2); | 1815 LayerImpl::Create(host_impl_->active_tree(), 2); |
1853 scroll_layer->SetScrollClipLayer(3); | 1816 scroll_layer->SetScrollable(true); |
1854 scroll_layer->SetBounds(contents_size); | 1817 scroll_layer->SetMaxScrollOffset(gfx::Vector2d(surface_size.width(), |
1855 scroll_layer->SetContentBounds(contents_size); | 1818 surface_size.height())); |
| 1819 scroll_layer->SetBounds(surface_size); |
| 1820 scroll_layer->SetContentBounds(surface_size); |
1856 scroll_layer->SetPosition(gfx::PointF()); | 1821 scroll_layer->SetPosition(gfx::PointF()); |
1857 scroll_layer->SetAnchorPoint(gfx::PointF()); | 1822 scroll_layer->SetAnchorPoint(gfx::PointF()); |
1858 scroll_layer->AddChild(content_layer.Pass()); | 1823 scroll_layer->AddChild(content_layer.Pass()); |
1859 scroll_clip_layer->AddChild(scroll_layer.Pass()); | |
1860 | 1824 |
1861 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass()); | 1825 host_impl_->active_tree()->SetRootLayer(scroll_layer.Pass()); |
1862 host_impl_->SetViewportSize(surface_size); | 1826 host_impl_->SetViewportSize(surface_size); |
1863 DrawFrame(); | 1827 DrawFrame(); |
1864 | 1828 |
1865 EXPECT_EQ(InputHandler::ScrollStarted, | 1829 EXPECT_EQ(InputHandler::ScrollStarted, |
1866 host_impl_->ScrollBegin(gfx::Point(5, 5), | 1830 host_impl_->ScrollBegin(gfx::Point(5, 5), |
1867 InputHandler::Wheel)); | 1831 InputHandler::Wheel)); |
1868 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 1832 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
1869 host_impl_->ScrollEnd(); | 1833 host_impl_->ScrollEnd(); |
1870 EXPECT_TRUE(did_request_redraw_); | 1834 EXPECT_TRUE(did_request_redraw_); |
1871 EXPECT_TRUE(did_request_commit_); | 1835 EXPECT_TRUE(did_request_commit_); |
1872 } | 1836 } |
1873 | 1837 |
1874 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { | 1838 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { |
1875 gfx::Size surface_size(10, 10); | 1839 gfx::Size surface_size(10, 10); |
1876 gfx::Size contents_size(20, 20); | |
1877 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 1840 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
1878 root->SetBounds(surface_size); | 1841 root->SetBounds(surface_size); |
1879 root->SetContentBounds(contents_size); | 1842 root->SetContentBounds(surface_size); |
1880 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); | 1843 root->AddChild(CreateScrollableLayer(2, surface_size)); |
1881 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 1844 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
1882 host_impl_->SetViewportSize(surface_size); | 1845 host_impl_->SetViewportSize(surface_size); |
1883 DrawFrame(); | 1846 DrawFrame(); |
1884 | 1847 |
1885 EXPECT_EQ(InputHandler::ScrollStarted, | 1848 EXPECT_EQ(InputHandler::ScrollStarted, |
1886 host_impl_->ScrollBegin(gfx::Point(5, 5), | 1849 host_impl_->ScrollBegin(gfx::Point(5, 5), |
1887 InputHandler::Wheel)); | 1850 InputHandler::Wheel)); |
1888 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 1851 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
1889 host_impl_->ScrollEnd(); | 1852 host_impl_->ScrollEnd(); |
1890 EXPECT_TRUE(did_request_redraw_); | 1853 EXPECT_TRUE(did_request_redraw_); |
1891 EXPECT_TRUE(did_request_commit_); | 1854 EXPECT_TRUE(did_request_commit_); |
1892 } | 1855 } |
1893 | 1856 |
1894 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { | 1857 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { |
1895 gfx::Size surface_size(10, 10); | 1858 gfx::Size surface_size(10, 10); |
1896 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 1859 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
1897 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); | 1860 root->AddChild(CreateScrollableLayer(2, surface_size)); |
1898 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 1861 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
1899 host_impl_->SetViewportSize(surface_size); | 1862 host_impl_->SetViewportSize(surface_size); |
1900 DrawFrame(); | 1863 DrawFrame(); |
1901 | 1864 |
1902 // Scroll event is ignored because the input coordinate is outside the layer | 1865 // Scroll event is ignored because the input coordinate is outside the layer |
1903 // boundaries. | 1866 // boundaries. |
1904 EXPECT_EQ(InputHandler::ScrollIgnored, | 1867 EXPECT_EQ(InputHandler::ScrollIgnored, |
1905 host_impl_->ScrollBegin(gfx::Point(15, 5), | 1868 host_impl_->ScrollBegin(gfx::Point(15, 5), |
1906 InputHandler::Wheel)); | 1869 InputHandler::Wheel)); |
1907 EXPECT_FALSE(did_request_redraw_); | 1870 EXPECT_FALSE(did_request_redraw_); |
1908 EXPECT_FALSE(did_request_commit_); | 1871 EXPECT_FALSE(did_request_commit_); |
1909 } | 1872 } |
1910 | 1873 |
1911 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { | 1874 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { |
1912 gfx::Size surface_size(10, 10); | 1875 gfx::Size surface_size(10, 10); |
1913 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 1876 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
1914 scoped_ptr<LayerImpl> child = | 1877 scoped_ptr<LayerImpl> child = CreateScrollableLayer(2, surface_size); |
1915 CreateScrollableLayer(2, surface_size, root.get()); | |
1916 host_impl_->SetViewportSize(surface_size); | 1878 host_impl_->SetViewportSize(surface_size); |
1917 | 1879 |
1918 gfx::Transform matrix; | 1880 gfx::Transform matrix; |
1919 matrix.RotateAboutXAxis(180.0); | 1881 matrix.RotateAboutXAxis(180.0); |
1920 child->SetTransform(matrix); | 1882 child->SetTransform(matrix); |
1921 child->SetDoubleSided(false); | 1883 child->SetDoubleSided(false); |
1922 | 1884 |
1923 root->AddChild(child.Pass()); | 1885 root->AddChild(child.Pass()); |
1924 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 1886 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
1925 DrawFrame(); | 1887 DrawFrame(); |
1926 | 1888 |
1927 // Scroll event is ignored because the scrollable layer is not facing the | 1889 // Scroll event is ignored because the scrollable layer is not facing the |
1928 // viewer and there is nothing scrollable behind it. | 1890 // viewer and there is nothing scrollable behind it. |
1929 EXPECT_EQ(InputHandler::ScrollIgnored, | 1891 EXPECT_EQ(InputHandler::ScrollIgnored, |
1930 host_impl_->ScrollBegin(gfx::Point(5, 5), | 1892 host_impl_->ScrollBegin(gfx::Point(5, 5), |
1931 InputHandler::Wheel)); | 1893 InputHandler::Wheel)); |
1932 EXPECT_FALSE(did_request_redraw_); | 1894 EXPECT_FALSE(did_request_redraw_); |
1933 EXPECT_FALSE(did_request_commit_); | 1895 EXPECT_FALSE(did_request_commit_); |
1934 } | 1896 } |
1935 | 1897 |
1936 TEST_F(LayerTreeHostImplTest, ScrollBlockedByContentLayer) { | 1898 TEST_F(LayerTreeHostImplTest, ScrollBlockedByContentLayer) { |
1937 gfx::Size surface_size(10, 10); | 1899 gfx::Size surface_size(10, 10); |
1938 scoped_ptr<LayerImpl> clip_layer = | 1900 scoped_ptr<LayerImpl> content_layer = CreateScrollableLayer(1, surface_size); |
1939 LayerImpl::Create(host_impl_->active_tree(), 3); | |
1940 scoped_ptr<LayerImpl> content_layer = | |
1941 CreateScrollableLayer(1, surface_size, clip_layer.get()); | |
1942 content_layer->SetShouldScrollOnMainThread(true); | 1901 content_layer->SetShouldScrollOnMainThread(true); |
1943 content_layer->SetScrollClipLayer(Layer::INVALID_ID); | 1902 content_layer->SetScrollable(false); |
1944 | 1903 |
1945 // Note: we can use the same clip layer for both since both calls to | 1904 scoped_ptr<LayerImpl> scroll_layer = CreateScrollableLayer(2, surface_size); |
1946 // CreateScrollableLayer() use the same surface size. | |
1947 scoped_ptr<LayerImpl> scroll_layer = | |
1948 CreateScrollableLayer(2, surface_size, clip_layer.get()); | |
1949 scroll_layer->AddChild(content_layer.Pass()); | 1905 scroll_layer->AddChild(content_layer.Pass()); |
1950 clip_layer->AddChild(scroll_layer.Pass()); | |
1951 | 1906 |
1952 host_impl_->active_tree()->SetRootLayer(clip_layer.Pass()); | 1907 host_impl_->active_tree()->SetRootLayer(scroll_layer.Pass()); |
1953 host_impl_->SetViewportSize(surface_size); | 1908 host_impl_->SetViewportSize(surface_size); |
1954 DrawFrame(); | 1909 DrawFrame(); |
1955 | 1910 |
1956 // Scrolling fails because the content layer is asking to be scrolled on the | 1911 // Scrolling fails because the content layer is asking to be scrolled on the |
1957 // main thread. | 1912 // main thread. |
1958 EXPECT_EQ(InputHandler::ScrollOnMainThread, | 1913 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
1959 host_impl_->ScrollBegin(gfx::Point(5, 5), | 1914 host_impl_->ScrollBegin(gfx::Point(5, 5), |
1960 InputHandler::Wheel)); | 1915 InputHandler::Wheel)); |
1961 } | 1916 } |
1962 | 1917 |
1963 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { | 1918 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { |
1964 gfx::Size surface_size(20, 20); | 1919 gfx::Size surface_size(10, 10); |
1965 float page_scale = 2.f; | 1920 float page_scale = 2.f; |
1966 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 1921 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
1967 scoped_ptr<LayerImpl> root_clip = | 1922 scoped_ptr<LayerImpl> root_scrolling = CreateScrollableLayer(2, surface_size); |
1968 LayerImpl::Create(host_impl_->active_tree(), 2); | 1923 root->AddChild(root_scrolling.Pass()); |
1969 scoped_ptr<LayerImpl> root_scrolling = | |
1970 CreateScrollableLayer(3, surface_size, root_clip.get()); | |
1971 root_scrolling->SetIsContainerForFixedPositionLayers(true); | |
1972 root_clip->AddChild(root_scrolling.Pass()); | |
1973 root->AddChild(root_clip.Pass()); | |
1974 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 1924 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
1975 // The behaviour in this test assumes the page scale is applied at a layer | |
1976 // above the clip layer. | |
1977 host_impl_->active_tree()->SetViewportLayersFromIds(1, 3, Layer::INVALID_ID); | |
1978 host_impl_->active_tree()->DidBecomeActive(); | 1925 host_impl_->active_tree()->DidBecomeActive(); |
1979 host_impl_->SetViewportSize(surface_size); | 1926 host_impl_->SetViewportSize(surface_size); |
1980 DrawFrame(); | 1927 DrawFrame(); |
1981 | 1928 |
1982 LayerImpl* root_scroll = | 1929 LayerImpl* root_scroll = host_impl_->active_tree()->RootScrollLayer(); |
1983 host_impl_->active_tree()->InnerViewportScrollLayer(); | |
1984 | 1930 |
1985 gfx::Vector2d scroll_delta(0, 10); | 1931 gfx::Vector2d scroll_delta(0, 10); |
1986 gfx::Vector2d expected_scroll_delta = scroll_delta; | 1932 gfx::Vector2d expected_scroll_delta = scroll_delta; |
1987 gfx::Vector2d expected_max_scroll = root_scroll->MaxScrollOffset(); | 1933 gfx::Vector2d expected_max_scroll = root_scroll->max_scroll_offset(); |
1988 EXPECT_EQ(InputHandler::ScrollStarted, | 1934 EXPECT_EQ(InputHandler::ScrollStarted, |
1989 host_impl_->ScrollBegin(gfx::Point(5, 5), | 1935 host_impl_->ScrollBegin(gfx::Point(5, 5), |
1990 InputHandler::Wheel)); | 1936 InputHandler::Wheel)); |
1991 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 1937 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
1992 host_impl_->ScrollEnd(); | 1938 host_impl_->ScrollEnd(); |
1993 | 1939 |
1994 // Set new page scale from main thread. | 1940 // Set new page scale from main thread. |
1995 host_impl_->active_tree()->SetPageScaleFactorAndLimits(page_scale, | 1941 host_impl_->active_tree()->SetPageScaleFactorAndLimits(page_scale, |
1996 page_scale, | 1942 page_scale, |
1997 page_scale); | 1943 page_scale); |
1998 | 1944 |
1999 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 1945 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
2000 ExpectContains(*scroll_info.get(), root_scroll->id(), expected_scroll_delta); | 1946 ExpectContains(*scroll_info.get(), root_scroll->id(), expected_scroll_delta); |
2001 | 1947 |
2002 // The scroll range should also have been updated. | 1948 // The scroll range should also have been updated. |
2003 EXPECT_EQ(expected_max_scroll, root_scroll->MaxScrollOffset()); | 1949 EXPECT_EQ(expected_max_scroll, root_scroll->max_scroll_offset()); |
2004 | 1950 |
2005 // The page scale delta remains constant because the impl thread did not | 1951 // The page scale delta remains constant because the impl thread did not |
2006 // scale. | 1952 // scale. |
2007 EXPECT_EQ(1.f, host_impl_->active_tree()->page_scale_delta()); | 1953 EXPECT_EQ(1.f, host_impl_->active_tree()->page_scale_delta()); |
2008 } | 1954 } |
2009 | 1955 |
2010 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnImplThread) { | 1956 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnImplThread) { |
2011 gfx::Size surface_size(20, 20); | 1957 gfx::Size surface_size(10, 10); |
2012 float page_scale = 2.f; | 1958 float page_scale = 2.f; |
2013 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 1959 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
2014 scoped_ptr<LayerImpl> root_clip = | 1960 scoped_ptr<LayerImpl> root_scrolling = CreateScrollableLayer(2, surface_size); |
2015 LayerImpl::Create(host_impl_->active_tree(), 2); | 1961 root->AddChild(root_scrolling.Pass()); |
2016 scoped_ptr<LayerImpl> root_scrolling = | |
2017 CreateScrollableLayer(3, surface_size, root_clip.get()); | |
2018 root_scrolling->SetIsContainerForFixedPositionLayers(true); | |
2019 root_clip->AddChild(root_scrolling.Pass()); | |
2020 root->AddChild(root_clip.Pass()); | |
2021 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 1962 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
2022 // The behaviour in this test assumes the page scale is applied at a layer | |
2023 // above the clip layer. | |
2024 host_impl_->active_tree()->SetViewportLayersFromIds(1, 3, Layer::INVALID_ID); | |
2025 host_impl_->active_tree()->DidBecomeActive(); | 1963 host_impl_->active_tree()->DidBecomeActive(); |
2026 host_impl_->SetViewportSize(surface_size); | 1964 host_impl_->SetViewportSize(surface_size); |
2027 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, page_scale); | 1965 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, page_scale); |
2028 DrawFrame(); | 1966 DrawFrame(); |
2029 | 1967 |
2030 LayerImpl* root_scroll = | 1968 LayerImpl* root_scroll = host_impl_->active_tree()->RootScrollLayer(); |
2031 host_impl_->active_tree()->InnerViewportScrollLayer(); | |
2032 | 1969 |
2033 gfx::Vector2d scroll_delta(0, 10); | 1970 gfx::Vector2d scroll_delta(0, 10); |
2034 gfx::Vector2d expected_scroll_delta = scroll_delta; | 1971 gfx::Vector2d expected_scroll_delta = scroll_delta; |
2035 gfx::Vector2d expected_max_scroll = root_scroll->MaxScrollOffset(); | 1972 gfx::Vector2d expected_max_scroll = root_scroll->max_scroll_offset(); |
2036 EXPECT_EQ(InputHandler::ScrollStarted, | 1973 EXPECT_EQ(InputHandler::ScrollStarted, |
2037 host_impl_->ScrollBegin(gfx::Point(5, 5), | 1974 host_impl_->ScrollBegin(gfx::Point(5, 5), |
2038 InputHandler::Wheel)); | 1975 InputHandler::Wheel)); |
2039 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 1976 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
2040 host_impl_->ScrollEnd(); | 1977 host_impl_->ScrollEnd(); |
2041 | 1978 |
2042 // Set new page scale on impl thread by pinching. | 1979 // Set new page scale on impl thread by pinching. |
2043 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); | 1980 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); |
2044 host_impl_->PinchGestureBegin(); | 1981 host_impl_->PinchGestureBegin(); |
2045 host_impl_->PinchGestureUpdate(page_scale, gfx::Point()); | 1982 host_impl_->PinchGestureUpdate(page_scale, gfx::Point()); |
2046 host_impl_->PinchGestureEnd(); | 1983 host_impl_->PinchGestureEnd(); |
2047 host_impl_->ScrollEnd(); | 1984 host_impl_->ScrollEnd(); |
2048 DrawOneFrame(); | 1985 DrawOneFrame(); |
2049 | 1986 |
2050 // The scroll delta is not scaled because the main thread did not scale. | 1987 // The scroll delta is not scaled because the main thread did not scale. |
2051 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 1988 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
2052 ExpectContains(*scroll_info.get(), root_scroll->id(), expected_scroll_delta); | 1989 ExpectContains(*scroll_info.get(), root_scroll->id(), expected_scroll_delta); |
2053 | 1990 |
2054 // The scroll range should also have been updated. | 1991 // The scroll range should also have been updated. |
2055 EXPECT_EQ(expected_max_scroll, root_scroll->MaxScrollOffset()); | 1992 EXPECT_EQ(expected_max_scroll, root_scroll->max_scroll_offset()); |
2056 | 1993 |
2057 // The page scale delta should match the new scale on the impl side. | 1994 // The page scale delta should match the new scale on the impl side. |
2058 EXPECT_EQ(page_scale, host_impl_->active_tree()->total_page_scale_factor()); | 1995 EXPECT_EQ(page_scale, host_impl_->active_tree()->total_page_scale_factor()); |
2059 } | 1996 } |
2060 | 1997 |
2061 TEST_F(LayerTreeHostImplTest, PageScaleDeltaAppliedToRootScrollLayerOnly) { | 1998 TEST_F(LayerTreeHostImplTest, PageScaleDeltaAppliedToRootScrollLayerOnly) { |
2062 gfx::Size surface_size(10, 10); | 1999 gfx::Size surface_size(10, 10); |
2063 float default_page_scale = 1.f; | 2000 float default_page_scale = 1.f; |
2064 gfx::Transform default_page_scale_matrix; | 2001 gfx::Transform default_page_scale_matrix; |
2065 default_page_scale_matrix.Scale(default_page_scale, default_page_scale); | 2002 default_page_scale_matrix.Scale(default_page_scale, default_page_scale); |
2066 | 2003 |
2067 float new_page_scale = 2.f; | 2004 float new_page_scale = 2.f; |
2068 gfx::Transform new_page_scale_matrix; | 2005 gfx::Transform new_page_scale_matrix; |
2069 new_page_scale_matrix.Scale(new_page_scale, new_page_scale); | 2006 new_page_scale_matrix.Scale(new_page_scale, new_page_scale); |
2070 | 2007 |
2071 // Create a normal scrollable root layer and another scrollable child layer. | 2008 // Create a normal scrollable root layer and another scrollable child layer. |
2072 LayerImpl* scroll = SetupScrollAndContentsLayers(surface_size); | 2009 LayerImpl* scroll = SetupScrollAndContentsLayers(surface_size); |
2073 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 2010 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
2074 LayerImpl* child = scroll->children()[0]; | 2011 LayerImpl* child = scroll->children()[0]; |
2075 | 2012 |
2076 scoped_ptr<LayerImpl> scrollable_child_clip = | |
2077 LayerImpl::Create(host_impl_->active_tree(), 6); | |
2078 scoped_ptr<LayerImpl> scrollable_child = | 2013 scoped_ptr<LayerImpl> scrollable_child = |
2079 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get()); | 2014 CreateScrollableLayer(4, surface_size); |
2080 scrollable_child_clip->AddChild(scrollable_child.Pass()); | 2015 child->AddChild(scrollable_child.Pass()); |
2081 child->AddChild(scrollable_child_clip.Pass()); | |
2082 LayerImpl* grand_child = child->children()[0]; | 2016 LayerImpl* grand_child = child->children()[0]; |
2083 | 2017 |
2084 // Set new page scale on impl thread by pinching. | 2018 // Set new page scale on impl thread by pinching. |
2085 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); | 2019 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); |
2086 host_impl_->PinchGestureBegin(); | 2020 host_impl_->PinchGestureBegin(); |
2087 host_impl_->PinchGestureUpdate(new_page_scale, gfx::Point()); | 2021 host_impl_->PinchGestureUpdate(new_page_scale, gfx::Point()); |
2088 host_impl_->PinchGestureEnd(); | 2022 host_impl_->PinchGestureEnd(); |
2089 host_impl_->ScrollEnd(); | 2023 host_impl_->ScrollEnd(); |
2090 DrawOneFrame(); | 2024 DrawOneFrame(); |
2091 | 2025 |
(...skipping 19 matching lines...) Expand all Loading... |
2111 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(1, 1)); | 2045 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(1, 1)); |
2112 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(0, 0)); | 2046 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(0, 0)); |
2113 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(1, 1)); | 2047 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(1, 1)); |
2114 EXPECT_EQ(new_page_scale, | 2048 EXPECT_EQ(new_page_scale, |
2115 grand_child->draw_transform().matrix().getDouble(0, 0)); | 2049 grand_child->draw_transform().matrix().getDouble(0, 0)); |
2116 EXPECT_EQ(new_page_scale, | 2050 EXPECT_EQ(new_page_scale, |
2117 grand_child->draw_transform().matrix().getDouble(1, 1)); | 2051 grand_child->draw_transform().matrix().getDouble(1, 1)); |
2118 } | 2052 } |
2119 | 2053 |
2120 TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) { | 2054 TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) { |
2121 gfx::Size surface_size(30, 30); | 2055 gfx::Size surface_size(10, 10); |
2122 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2056 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
2123 root->SetBounds(gfx::Size(5, 5)); | |
2124 scoped_ptr<LayerImpl> root_scrolling = | 2057 scoped_ptr<LayerImpl> root_scrolling = |
2125 LayerImpl::Create(host_impl_->active_tree(), 2); | 2058 LayerImpl::Create(host_impl_->active_tree(), 2); |
2126 root_scrolling->SetBounds(surface_size); | 2059 root_scrolling->SetBounds(surface_size); |
2127 root_scrolling->SetContentBounds(surface_size); | 2060 root_scrolling->SetContentBounds(surface_size); |
2128 root_scrolling->SetScrollClipLayer(root->id()); | 2061 root_scrolling->SetScrollable(true); |
2129 root_scrolling->SetIsContainerForFixedPositionLayers(true); | |
2130 LayerImpl* root_scrolling_ptr = root_scrolling.get(); | |
2131 root->AddChild(root_scrolling.Pass()); | 2062 root->AddChild(root_scrolling.Pass()); |
2132 int child_scroll_layer_id = 3; | 2063 int child_scroll_layer_id = 3; |
2133 scoped_ptr<LayerImpl> child_scrolling = CreateScrollableLayer( | 2064 scoped_ptr<LayerImpl> child_scrolling = |
2134 child_scroll_layer_id, surface_size, root_scrolling_ptr); | 2065 CreateScrollableLayer(child_scroll_layer_id, surface_size); |
2135 LayerImpl* child = child_scrolling.get(); | 2066 LayerImpl* child = child_scrolling.get(); |
2136 root_scrolling_ptr->AddChild(child_scrolling.Pass()); | 2067 root->AddChild(child_scrolling.Pass()); |
2137 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2068 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
2138 host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID); | |
2139 host_impl_->active_tree()->DidBecomeActive(); | 2069 host_impl_->active_tree()->DidBecomeActive(); |
2140 host_impl_->SetViewportSize(surface_size); | 2070 host_impl_->SetViewportSize(surface_size); |
2141 DrawFrame(); | 2071 DrawFrame(); |
2142 | 2072 |
2143 gfx::Vector2d scroll_delta(0, 10); | 2073 gfx::Vector2d scroll_delta(0, 10); |
2144 gfx::Vector2d expected_scroll_delta(scroll_delta); | 2074 gfx::Vector2d expected_scroll_delta(scroll_delta); |
2145 gfx::Vector2d expected_max_scroll(child->MaxScrollOffset()); | 2075 gfx::Vector2d expected_max_scroll(child->max_scroll_offset()); |
2146 EXPECT_EQ(InputHandler::ScrollStarted, | 2076 EXPECT_EQ(InputHandler::ScrollStarted, |
2147 host_impl_->ScrollBegin(gfx::Point(5, 5), | 2077 host_impl_->ScrollBegin(gfx::Point(5, 5), |
2148 InputHandler::Wheel)); | 2078 InputHandler::Wheel)); |
2149 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2079 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
2150 host_impl_->ScrollEnd(); | 2080 host_impl_->ScrollEnd(); |
2151 | 2081 |
2152 float page_scale = 2.f; | 2082 float page_scale = 2.f; |
2153 host_impl_->active_tree()->SetPageScaleFactorAndLimits(page_scale, | 2083 host_impl_->active_tree()->SetPageScaleFactorAndLimits(page_scale, |
2154 1.f, | 2084 1.f, |
2155 page_scale); | 2085 page_scale); |
2156 | 2086 |
2157 DrawOneFrame(); | 2087 DrawOneFrame(); |
2158 | 2088 |
2159 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 2089 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
2160 ExpectContains( | 2090 ExpectContains( |
2161 *scroll_info.get(), child_scroll_layer_id, expected_scroll_delta); | 2091 *scroll_info.get(), child_scroll_layer_id, expected_scroll_delta); |
2162 | 2092 |
2163 // The scroll range should not have changed. | 2093 // The scroll range should not have changed. |
2164 EXPECT_EQ(child->MaxScrollOffset(), expected_max_scroll); | 2094 EXPECT_EQ(child->max_scroll_offset(), expected_max_scroll); |
2165 | 2095 |
2166 // The page scale delta remains constant because the impl thread did not | 2096 // The page scale delta remains constant because the impl thread did not |
2167 // scale. | 2097 // scale. |
2168 EXPECT_EQ(1.f, host_impl_->active_tree()->page_scale_delta()); | 2098 EXPECT_EQ(1.f, host_impl_->active_tree()->page_scale_delta()); |
2169 } | 2099 } |
2170 | 2100 |
2171 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { | 2101 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { |
2172 // Scroll a child layer beyond its maximum scroll range and make sure the | 2102 // Scroll a child layer beyond its maximum scroll range and make sure the |
2173 // parent layer is scrolled on the axis on which the child was unable to | 2103 // parent layer is scrolled on the axis on which the child was unable to |
2174 // scroll. | 2104 // scroll. |
2175 gfx::Size surface_size(10, 10); | 2105 gfx::Size surface_size(10, 10); |
2176 gfx::Size content_size(20, 20); | 2106 scoped_ptr<LayerImpl> root = CreateScrollableLayer(1, surface_size); |
2177 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | |
2178 root->SetBounds(surface_size); | |
2179 | 2107 |
2180 scoped_ptr<LayerImpl> grand_child = | 2108 scoped_ptr<LayerImpl> grand_child = CreateScrollableLayer(3, surface_size); |
2181 CreateScrollableLayer(3, content_size, root.get()); | 2109 grand_child->SetScrollOffset(gfx::Vector2d(0, 5)); |
2182 | 2110 |
2183 scoped_ptr<LayerImpl> child = | 2111 scoped_ptr<LayerImpl> child = CreateScrollableLayer(2, surface_size); |
2184 CreateScrollableLayer(2, content_size, root.get()); | 2112 child->SetScrollOffset(gfx::Vector2d(3, 0)); |
2185 LayerImpl* grand_child_layer = grand_child.get(); | |
2186 child->AddChild(grand_child.Pass()); | 2113 child->AddChild(grand_child.Pass()); |
2187 | 2114 |
2188 LayerImpl* child_layer = child.get(); | |
2189 root->AddChild(child.Pass()); | 2115 root->AddChild(child.Pass()); |
2190 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2116 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
2191 host_impl_->active_tree()->DidBecomeActive(); | 2117 host_impl_->active_tree()->DidBecomeActive(); |
2192 host_impl_->SetViewportSize(surface_size); | 2118 host_impl_->SetViewportSize(surface_size); |
2193 grand_child_layer->SetScrollOffset(gfx::Vector2d(0, 5)); | |
2194 child_layer->SetScrollOffset(gfx::Vector2d(3, 0)); | |
2195 | |
2196 DrawFrame(); | 2119 DrawFrame(); |
2197 { | 2120 { |
2198 gfx::Vector2d scroll_delta(-8, -7); | 2121 gfx::Vector2d scroll_delta(-8, -7); |
2199 EXPECT_EQ(InputHandler::ScrollStarted, | 2122 EXPECT_EQ(InputHandler::ScrollStarted, |
2200 host_impl_->ScrollBegin(gfx::Point(), | 2123 host_impl_->ScrollBegin(gfx::Point(), |
2201 InputHandler::Wheel)); | 2124 InputHandler::Wheel)); |
2202 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2125 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
2203 host_impl_->ScrollEnd(); | 2126 host_impl_->ScrollEnd(); |
2204 | 2127 |
2205 scoped_ptr<ScrollAndScaleSet> scroll_info = | 2128 scoped_ptr<ScrollAndScaleSet> scroll_info = |
2206 host_impl_->ProcessScrollDeltas(); | 2129 host_impl_->ProcessScrollDeltas(); |
2207 | 2130 |
2208 // The grand child should have scrolled up to its limit. | 2131 // The grand child should have scrolled up to its limit. |
2209 LayerImpl* child = host_impl_->active_tree()->root_layer()->children()[0]; | 2132 LayerImpl* child = host_impl_->active_tree()->root_layer()->children()[0]; |
2210 LayerImpl* grand_child = child->children()[0]; | 2133 LayerImpl* grand_child = child->children()[0]; |
2211 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, -5)); | 2134 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, -5)); |
2212 | 2135 |
2213 // The child should have only scrolled on the other axis. | 2136 // The child should have only scrolled on the other axis. |
2214 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(-3, 0)); | 2137 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(-3, 0)); |
2215 } | 2138 } |
2216 } | 2139 } |
2217 | 2140 |
2218 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { | 2141 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { |
2219 // Scroll a child layer beyond its maximum scroll range and make sure the | 2142 // Scroll a child layer beyond its maximum scroll range and make sure the |
2220 // the scroll doesn't bubble up to the parent layer. | 2143 // the scroll doesn't bubble up to the parent layer. |
2221 gfx::Size surface_size(20, 20); | 2144 gfx::Size surface_size(10, 10); |
2222 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2145 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
2223 scoped_ptr<LayerImpl> root_scrolling = | 2146 scoped_ptr<LayerImpl> root_scrolling = CreateScrollableLayer(2, surface_size); |
2224 CreateScrollableLayer(2, surface_size, root.get()); | |
2225 root_scrolling->SetIsContainerForFixedPositionLayers(true); | |
2226 | 2147 |
2227 scoped_ptr<LayerImpl> grand_child = | 2148 scoped_ptr<LayerImpl> grand_child = CreateScrollableLayer(4, surface_size); |
2228 CreateScrollableLayer(4, surface_size, root.get()); | 2149 grand_child->SetScrollOffset(gfx::Vector2d(0, 2)); |
2229 | 2150 |
2230 scoped_ptr<LayerImpl> child = | 2151 scoped_ptr<LayerImpl> child = CreateScrollableLayer(3, surface_size); |
2231 CreateScrollableLayer(3, surface_size, root.get()); | 2152 child->SetScrollOffset(gfx::Vector2d(0, 3)); |
2232 LayerImpl* grand_child_layer = grand_child.get(); | |
2233 child->AddChild(grand_child.Pass()); | 2153 child->AddChild(grand_child.Pass()); |
2234 | 2154 |
2235 LayerImpl* child_layer = child.get(); | |
2236 root_scrolling->AddChild(child.Pass()); | 2155 root_scrolling->AddChild(child.Pass()); |
2237 root->AddChild(root_scrolling.Pass()); | 2156 root->AddChild(root_scrolling.Pass()); |
2238 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2157 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
2239 host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID); | |
2240 host_impl_->active_tree()->DidBecomeActive(); | 2158 host_impl_->active_tree()->DidBecomeActive(); |
2241 host_impl_->SetViewportSize(surface_size); | 2159 host_impl_->SetViewportSize(surface_size); |
2242 | |
2243 grand_child_layer->SetScrollOffset(gfx::Vector2d(0, 2)); | |
2244 child_layer->SetScrollOffset(gfx::Vector2d(0, 3)); | |
2245 | |
2246 DrawFrame(); | 2160 DrawFrame(); |
2247 { | 2161 { |
2248 gfx::Vector2d scroll_delta(0, -10); | 2162 gfx::Vector2d scroll_delta(0, -10); |
2249 EXPECT_EQ(InputHandler::ScrollStarted, | 2163 EXPECT_EQ(InputHandler::ScrollStarted, |
2250 host_impl_->ScrollBegin(gfx::Point(), | 2164 host_impl_->ScrollBegin(gfx::Point(), |
2251 InputHandler::NonBubblingGesture)); | 2165 InputHandler::NonBubblingGesture)); |
2252 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2166 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
2253 host_impl_->ScrollEnd(); | 2167 host_impl_->ScrollEnd(); |
2254 | 2168 |
2255 scoped_ptr<ScrollAndScaleSet> scroll_info = | 2169 scoped_ptr<ScrollAndScaleSet> scroll_info = |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2313 EXPECT_EQ(grand_child, host_impl_->CurrentlyScrollingLayer()); | 2227 EXPECT_EQ(grand_child, host_impl_->CurrentlyScrollingLayer()); |
2314 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2228 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
2315 host_impl_->ScrollEnd(); | 2229 host_impl_->ScrollEnd(); |
2316 | 2230 |
2317 scroll_info = host_impl_->ProcessScrollDeltas(); | 2231 scroll_info = host_impl_->ProcessScrollDeltas(); |
2318 | 2232 |
2319 // Should have scrolled by half the amount in layer space (5 - 2/2) | 2233 // Should have scrolled by half the amount in layer space (5 - 2/2) |
2320 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 4)); | 2234 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 4)); |
2321 } | 2235 } |
2322 } | 2236 } |
| 2237 |
2323 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { | 2238 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { |
2324 // When we try to scroll a non-scrollable child layer, the scroll delta | 2239 // When we try to scroll a non-scrollable child layer, the scroll delta |
2325 // should be applied to one of its ancestors if possible. | 2240 // should be applied to one of its ancestors if possible. |
2326 gfx::Size surface_size(10, 10); | 2241 gfx::Size surface_size(10, 10); |
2327 gfx::Size content_size(20, 20); | 2242 gfx::Size content_size(20, 20); |
2328 scoped_ptr<LayerImpl> root_clip = | 2243 scoped_ptr<LayerImpl> root = CreateScrollableLayer(1, content_size); |
2329 LayerImpl::Create(host_impl_->active_tree(), 3); | 2244 scoped_ptr<LayerImpl> child = CreateScrollableLayer(2, content_size); |
2330 scoped_ptr<LayerImpl> root = | |
2331 CreateScrollableLayer(1, content_size, root_clip.get()); | |
2332 // Make 'root' the clip layer for child: since they have the same sizes the | |
2333 // child will have zero max_scroll_offset and scrolls will bubble. | |
2334 scoped_ptr<LayerImpl> child = | |
2335 CreateScrollableLayer(2, content_size, root.get()); | |
2336 child->SetIsContainerForFixedPositionLayers(true); | |
2337 root->SetBounds(content_size); | |
2338 | 2245 |
2339 int root_scroll_id = root->id(); | 2246 child->SetScrollable(false); |
2340 root->AddChild(child.Pass()); | 2247 root->AddChild(child.Pass()); |
2341 root_clip->AddChild(root.Pass()); | |
2342 | 2248 |
2343 host_impl_->SetViewportSize(surface_size); | 2249 host_impl_->SetViewportSize(surface_size); |
2344 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 2250 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
2345 host_impl_->active_tree()->SetViewportLayersFromIds(3, 2, Layer::INVALID_ID); | |
2346 host_impl_->active_tree()->DidBecomeActive(); | 2251 host_impl_->active_tree()->DidBecomeActive(); |
2347 DrawFrame(); | 2252 DrawFrame(); |
2348 { | 2253 { |
2349 gfx::Vector2d scroll_delta(0, 4); | 2254 gfx::Vector2d scroll_delta(0, 4); |
2350 EXPECT_EQ(InputHandler::ScrollStarted, | 2255 EXPECT_EQ(InputHandler::ScrollStarted, |
2351 host_impl_->ScrollBegin(gfx::Point(5, 5), | 2256 host_impl_->ScrollBegin(gfx::Point(5, 5), |
2352 InputHandler::Wheel)); | 2257 InputHandler::Wheel)); |
2353 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2258 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
2354 host_impl_->ScrollEnd(); | 2259 host_impl_->ScrollEnd(); |
2355 | 2260 |
2356 scoped_ptr<ScrollAndScaleSet> scroll_info = | 2261 scoped_ptr<ScrollAndScaleSet> scroll_info = |
2357 host_impl_->ProcessScrollDeltas(); | 2262 host_impl_->ProcessScrollDeltas(); |
2358 | 2263 |
2359 // Only the root scroll should have scrolled. | 2264 // Only the root should have scrolled. |
2360 ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 2265 ASSERT_EQ(scroll_info->scrolls.size(), 1u); |
2361 ExpectContains(*scroll_info.get(), root_scroll_id, scroll_delta); | 2266 ExpectContains(*scroll_info.get(), |
| 2267 host_impl_->active_tree()->root_layer()->id(), |
| 2268 scroll_delta); |
2362 } | 2269 } |
2363 } | 2270 } |
2364 | 2271 |
2365 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { | 2272 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { |
2366 gfx::Size surface_size(10, 10); | 2273 gfx::Size surface_size(10, 10); |
2367 scoped_ptr<LayerImpl> root_clip = | 2274 host_impl_->active_tree()->SetRootLayer( |
2368 LayerImpl::Create(host_impl_->active_tree(), 1); | 2275 CreateScrollableLayer(1, surface_size)); |
2369 scoped_ptr<LayerImpl> root_scroll = | |
2370 CreateScrollableLayer(2, surface_size, root_clip.get()); | |
2371 root_scroll->SetIsContainerForFixedPositionLayers(true); | |
2372 root_clip->AddChild(root_scroll.Pass()); | |
2373 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | |
2374 host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID); | |
2375 host_impl_->active_tree()->DidBecomeActive(); | 2276 host_impl_->active_tree()->DidBecomeActive(); |
2376 host_impl_->SetViewportSize(surface_size); | 2277 host_impl_->SetViewportSize(surface_size); |
2377 | 2278 |
2378 // Draw one frame and then immediately rebuild the layer tree to mimic a tree | 2279 // Draw one frame and then immediately rebuild the layer tree to mimic a tree |
2379 // synchronization. | 2280 // synchronization. |
2380 DrawFrame(); | 2281 DrawFrame(); |
2381 host_impl_->active_tree()->DetachLayerTree(); | 2282 host_impl_->active_tree()->DetachLayerTree(); |
2382 scoped_ptr<LayerImpl> root_clip2 = | 2283 host_impl_->active_tree()->SetRootLayer( |
2383 LayerImpl::Create(host_impl_->active_tree(), 3); | 2284 CreateScrollableLayer(2, surface_size)); |
2384 scoped_ptr<LayerImpl> root_scroll2 = | |
2385 CreateScrollableLayer(4, surface_size, root_clip2.get()); | |
2386 root_scroll2->SetIsContainerForFixedPositionLayers(true); | |
2387 root_clip2->AddChild(root_scroll2.Pass()); | |
2388 host_impl_->active_tree()->SetRootLayer(root_clip2.Pass()); | |
2389 host_impl_->active_tree()->SetViewportLayersFromIds(3, 4, Layer::INVALID_ID); | |
2390 host_impl_->active_tree()->DidBecomeActive(); | 2285 host_impl_->active_tree()->DidBecomeActive(); |
2391 | 2286 |
2392 // Scrolling should still work even though we did not draw yet. | 2287 // Scrolling should still work even though we did not draw yet. |
2393 EXPECT_EQ(InputHandler::ScrollStarted, | 2288 EXPECT_EQ(InputHandler::ScrollStarted, |
2394 host_impl_->ScrollBegin(gfx::Point(5, 5), | 2289 host_impl_->ScrollBegin(gfx::Point(5, 5), |
2395 InputHandler::Wheel)); | 2290 InputHandler::Wheel)); |
2396 } | 2291 } |
2397 | 2292 |
2398 TEST_F(LayerTreeHostImplTest, ScrollAxisAlignedRotatedLayer) { | 2293 TEST_F(LayerTreeHostImplTest, ScrollAxisAlignedRotatedLayer) { |
2399 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 2294 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2432 | 2327 |
2433 // The layer should have scrolled down in its local coordinates. | 2328 // The layer should have scrolled down in its local coordinates. |
2434 scroll_info = host_impl_->ProcessScrollDeltas(); | 2329 scroll_info = host_impl_->ProcessScrollDeltas(); |
2435 ExpectContains(*scroll_info.get(), | 2330 ExpectContains(*scroll_info.get(), |
2436 scroll_layer->id(), | 2331 scroll_layer->id(), |
2437 wheel_scroll_delta); | 2332 wheel_scroll_delta); |
2438 } | 2333 } |
2439 | 2334 |
2440 TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) { | 2335 TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) { |
2441 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 2336 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
2442 int child_clip_layer_id = 6; | 2337 int child_layer_id = 4; |
2443 int child_layer_id = 7; | |
2444 float child_layer_angle = -20.f; | 2338 float child_layer_angle = -20.f; |
2445 | 2339 |
2446 // Create a child layer that is rotated to a non-axis-aligned angle. | 2340 // Create a child layer that is rotated to a non-axis-aligned angle. |
2447 scoped_ptr<LayerImpl> clip_layer = | |
2448 LayerImpl::Create(host_impl_->active_tree(), child_clip_layer_id); | |
2449 scoped_ptr<LayerImpl> child = CreateScrollableLayer( | 2341 scoped_ptr<LayerImpl> child = CreateScrollableLayer( |
2450 child_layer_id, scroll_layer->content_bounds(), clip_layer.get()); | 2342 child_layer_id, |
| 2343 scroll_layer->content_bounds()); |
2451 gfx::Transform rotate_transform; | 2344 gfx::Transform rotate_transform; |
2452 rotate_transform.Translate(-50.0, -50.0); | 2345 rotate_transform.Translate(-50.0, -50.0); |
2453 rotate_transform.Rotate(child_layer_angle); | 2346 rotate_transform.Rotate(child_layer_angle); |
2454 rotate_transform.Translate(50.0, 50.0); | 2347 rotate_transform.Translate(50.0, 50.0); |
2455 clip_layer->SetTransform(rotate_transform); | 2348 child->SetTransform(rotate_transform); |
2456 | 2349 |
2457 // Only allow vertical scrolling. | 2350 // Only allow vertical scrolling. |
2458 clip_layer->SetBounds( | 2351 child->SetMaxScrollOffset(gfx::Vector2d(0, child->content_bounds().height())); |
2459 gfx::Size(child->bounds().width(), child->bounds().height() / 2)); | 2352 scroll_layer->AddChild(child.Pass()); |
2460 // The rotation depends on the layer's anchor point, and the child layer is a | |
2461 // different size than the clip, so make sure the clip layer's anchor lines | |
2462 // up over the child. | |
2463 clip_layer->SetAnchorPoint(gfx::PointF(0.5, 1.0)); | |
2464 LayerImpl* child_ptr = child.get(); | |
2465 clip_layer->AddChild(child.Pass()); | |
2466 scroll_layer->AddChild(clip_layer.Pass()); | |
2467 | 2353 |
2468 gfx::Size surface_size(50, 50); | 2354 gfx::Size surface_size(50, 50); |
2469 host_impl_->SetViewportSize(surface_size); | 2355 host_impl_->SetViewportSize(surface_size); |
2470 DrawFrame(); | 2356 DrawFrame(); |
2471 { | 2357 { |
2472 // Scroll down in screen coordinates with a gesture. | 2358 // Scroll down in screen coordinates with a gesture. |
2473 gfx::Vector2d gesture_scroll_delta(0, 10); | 2359 gfx::Vector2d gesture_scroll_delta(0, 10); |
2474 EXPECT_EQ(InputHandler::ScrollStarted, | 2360 EXPECT_EQ(InputHandler::ScrollStarted, |
2475 host_impl_->ScrollBegin(gfx::Point(1, 1), | 2361 host_impl_->ScrollBegin(gfx::Point(1, 1), |
2476 InputHandler::Gesture)); | 2362 InputHandler::Gesture)); |
2477 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); | 2363 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); |
2478 host_impl_->ScrollEnd(); | 2364 host_impl_->ScrollEnd(); |
2479 | 2365 |
2480 // The child layer should have scrolled down in its local coordinates an | 2366 // The child layer should have scrolled down in its local coordinates an |
2481 // amount proportional to the angle between it and the input scroll delta. | 2367 // amount proportional to the angle between it and the input scroll delta. |
2482 gfx::Vector2d expected_scroll_delta( | 2368 gfx::Vector2d expected_scroll_delta( |
2483 0, | 2369 0, |
2484 gesture_scroll_delta.y() * | 2370 gesture_scroll_delta.y() * |
2485 std::cos(MathUtil::Deg2Rad(child_layer_angle))); | 2371 std::cos(MathUtil::Deg2Rad(child_layer_angle))); |
2486 scoped_ptr<ScrollAndScaleSet> scroll_info = | 2372 scoped_ptr<ScrollAndScaleSet> scroll_info = |
2487 host_impl_->ProcessScrollDeltas(); | 2373 host_impl_->ProcessScrollDeltas(); |
2488 ExpectContains(*scroll_info.get(), child_layer_id, expected_scroll_delta); | 2374 ExpectContains(*scroll_info.get(), child_layer_id, expected_scroll_delta); |
2489 | 2375 |
2490 // The root scroll layer should not have scrolled, because the input delta | 2376 // The root scroll layer should not have scrolled, because the input delta |
2491 // was close to the layer's axis of movement. | 2377 // was close to the layer's axis of movement. |
2492 EXPECT_EQ(scroll_info->scrolls.size(), 1u); | 2378 EXPECT_EQ(scroll_info->scrolls.size(), 1u); |
2493 } | 2379 } |
2494 { | 2380 { |
2495 // Now reset and scroll the same amount horizontally. | 2381 // Now reset and scroll the same amount horizontally. |
2496 child_ptr->SetScrollDelta( | 2382 scroll_layer->children()[1]->SetScrollDelta( |
2497 gfx::Vector2dF()); | 2383 gfx::Vector2dF()); |
2498 gfx::Vector2d gesture_scroll_delta(10, 0); | 2384 gfx::Vector2d gesture_scroll_delta(10, 0); |
2499 EXPECT_EQ(InputHandler::ScrollStarted, | 2385 EXPECT_EQ(InputHandler::ScrollStarted, |
2500 host_impl_->ScrollBegin(gfx::Point(1, 1), | 2386 host_impl_->ScrollBegin(gfx::Point(1, 1), |
2501 InputHandler::Gesture)); | 2387 InputHandler::Gesture)); |
2502 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); | 2388 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); |
2503 host_impl_->ScrollEnd(); | 2389 host_impl_->ScrollEnd(); |
2504 | 2390 |
2505 // The child layer should have scrolled down in its local coordinates an | 2391 // The child layer should have scrolled down in its local coordinates an |
2506 // amount proportional to the angle between it and the input scroll delta. | 2392 // amount proportional to the angle between it and the input scroll delta. |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2621 gfx::Vector2dF getter_return_value_; | 2507 gfx::Vector2dF getter_return_value_; |
2622 gfx::Vector2dF max_scroll_offset_; | 2508 gfx::Vector2dF max_scroll_offset_; |
2623 gfx::SizeF scrollable_size_; | 2509 gfx::SizeF scrollable_size_; |
2624 float page_scale_factor_; | 2510 float page_scale_factor_; |
2625 }; | 2511 }; |
2626 | 2512 |
2627 TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) { | 2513 TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) { |
2628 TestScrollOffsetDelegate scroll_delegate; | 2514 TestScrollOffsetDelegate scroll_delegate; |
2629 host_impl_->SetViewportSize(gfx::Size(10, 20)); | 2515 host_impl_->SetViewportSize(gfx::Size(10, 20)); |
2630 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 2516 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
2631 LayerImpl* clip_layer = scroll_layer->parent()->parent(); | |
2632 clip_layer->SetBounds(gfx::Size(10, 20)); | |
2633 | 2517 |
2634 // Setting the delegate results in the current scroll offset being set. | 2518 // Setting the delegate results in the current scroll offset being set. |
2635 gfx::Vector2dF initial_scroll_delta(10.f, 10.f); | 2519 gfx::Vector2dF initial_scroll_delta(10.f, 10.f); |
2636 scroll_layer->SetScrollOffset(gfx::Vector2d()); | 2520 scroll_layer->SetScrollOffset(gfx::Vector2d()); |
2637 scroll_layer->SetScrollDelta(initial_scroll_delta); | 2521 scroll_layer->SetScrollDelta(initial_scroll_delta); |
2638 host_impl_->SetRootLayerScrollOffsetDelegate(&scroll_delegate); | 2522 host_impl_->SetRootLayerScrollOffsetDelegate(&scroll_delegate); |
2639 EXPECT_EQ(initial_scroll_delta.ToString(), | 2523 EXPECT_EQ(initial_scroll_delta.ToString(), |
2640 scroll_delegate.last_set_scroll_offset().ToString()); | 2524 scroll_delegate.last_set_scroll_offset().ToString()); |
2641 | 2525 |
2642 // Setting the delegate results in the scrollable_size, max_scroll_offset and | 2526 // Setting the delegate results in the scrollable_size, max_scroll_offset and |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2746 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20)); | 2630 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20)); |
2747 EXPECT_EQ(gfx::Vector2dF(0, -20), host_impl_->accumulated_root_overscroll()); | 2631 EXPECT_EQ(gfx::Vector2dF(0, -20), host_impl_->accumulated_root_overscroll()); |
2748 EXPECT_EQ(gfx::Vector2dF(10, 0), host_impl_->current_fling_velocity()); | 2632 EXPECT_EQ(gfx::Vector2dF(10, 0), host_impl_->current_fling_velocity()); |
2749 } | 2633 } |
2750 | 2634 |
2751 | 2635 |
2752 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) { | 2636 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) { |
2753 // Scroll child layers beyond their maximum scroll range and make sure root | 2637 // Scroll child layers beyond their maximum scroll range and make sure root |
2754 // overscroll does not accumulate. | 2638 // overscroll does not accumulate. |
2755 gfx::Size surface_size(10, 10); | 2639 gfx::Size surface_size(10, 10); |
2756 scoped_ptr<LayerImpl> root_clip = | 2640 scoped_ptr<LayerImpl> root = CreateScrollableLayer(1, surface_size); |
2757 LayerImpl::Create(host_impl_->active_tree(), 4); | |
2758 scoped_ptr<LayerImpl> root = | |
2759 CreateScrollableLayer(1, surface_size, root_clip.get()); | |
2760 | 2641 |
2761 scoped_ptr<LayerImpl> grand_child = | 2642 scoped_ptr<LayerImpl> grand_child = CreateScrollableLayer(3, surface_size); |
2762 CreateScrollableLayer(3, surface_size, root_clip.get()); | 2643 grand_child->SetScrollOffset(gfx::Vector2d(0, 2)); |
2763 | 2644 |
2764 scoped_ptr<LayerImpl> child = | 2645 scoped_ptr<LayerImpl> child = CreateScrollableLayer(2, surface_size); |
2765 CreateScrollableLayer(2, surface_size, root_clip.get()); | 2646 child->SetScrollOffset(gfx::Vector2d(0, 3)); |
2766 LayerImpl* grand_child_layer = grand_child.get(); | |
2767 child->AddChild(grand_child.Pass()); | 2647 child->AddChild(grand_child.Pass()); |
2768 | 2648 |
2769 LayerImpl* child_layer = child.get(); | |
2770 root->AddChild(child.Pass()); | 2649 root->AddChild(child.Pass()); |
2771 root_clip->AddChild(root.Pass()); | 2650 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
2772 child_layer->SetScrollOffset(gfx::Vector2d(0, 3)); | |
2773 grand_child_layer->SetScrollOffset(gfx::Vector2d(0, 2)); | |
2774 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | |
2775 host_impl_->active_tree()->DidBecomeActive(); | 2651 host_impl_->active_tree()->DidBecomeActive(); |
2776 host_impl_->SetViewportSize(surface_size); | 2652 host_impl_->SetViewportSize(surface_size); |
2777 DrawFrame(); | 2653 DrawFrame(); |
2778 { | 2654 { |
2779 gfx::Vector2d scroll_delta(0, -10); | 2655 gfx::Vector2d scroll_delta(0, -10); |
2780 EXPECT_EQ(InputHandler::ScrollStarted, | 2656 EXPECT_EQ(InputHandler::ScrollStarted, |
2781 host_impl_->ScrollBegin(gfx::Point(), | 2657 host_impl_->ScrollBegin(gfx::Point(), |
2782 InputHandler::NonBubblingGesture)); | 2658 InputHandler::NonBubblingGesture)); |
2783 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2659 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
2784 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 2660 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
2785 host_impl_->ScrollEnd(); | 2661 host_impl_->ScrollEnd(); |
2786 | 2662 |
| 2663 LayerImpl* child = host_impl_->active_tree()->root_layer()->children()[0]; |
| 2664 LayerImpl* grand_child = child->children()[0]; |
| 2665 |
2787 // The next time we scroll we should only scroll the parent, but overscroll | 2666 // The next time we scroll we should only scroll the parent, but overscroll |
2788 // should still not reach the root layer. | 2667 // should still not reach the root layer. |
2789 scroll_delta = gfx::Vector2d(0, -30); | 2668 scroll_delta = gfx::Vector2d(0, -30); |
2790 EXPECT_EQ(InputHandler::ScrollStarted, | 2669 EXPECT_EQ(InputHandler::ScrollStarted, |
2791 host_impl_->ScrollBegin(gfx::Point(5, 5), | 2670 host_impl_->ScrollBegin(gfx::Point(5, 5), |
2792 InputHandler::NonBubblingGesture)); | 2671 InputHandler::NonBubblingGesture)); |
2793 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); | 2672 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
2794 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 2673 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
2795 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2674 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
2796 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_layer); | 2675 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child); |
2797 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 2676 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
2798 host_impl_->ScrollEnd(); | 2677 host_impl_->ScrollEnd(); |
2799 | 2678 |
2800 // After scrolling the parent, another scroll on the opposite direction | 2679 // After scrolling the parent, another scroll on the opposite direction |
2801 // should scroll the child, resetting the fling velocity. | 2680 // should scroll the child, resetting the fling velocity. |
2802 scroll_delta = gfx::Vector2d(0, 70); | 2681 scroll_delta = gfx::Vector2d(0, 70); |
2803 host_impl_->NotifyCurrentFlingVelocity(gfx::Vector2dF(10, 0)); | 2682 host_impl_->NotifyCurrentFlingVelocity(gfx::Vector2dF(10, 0)); |
2804 EXPECT_EQ(gfx::Vector2dF(10, 0), host_impl_->current_fling_velocity()); | 2683 EXPECT_EQ(gfx::Vector2dF(10, 0), host_impl_->current_fling_velocity()); |
2805 EXPECT_EQ(InputHandler::ScrollStarted, | 2684 EXPECT_EQ(InputHandler::ScrollStarted, |
2806 host_impl_->ScrollBegin(gfx::Point(5, 5), | 2685 host_impl_->ScrollBegin(gfx::Point(5, 5), |
2807 InputHandler::NonBubblingGesture)); | 2686 InputHandler::NonBubblingGesture)); |
2808 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); | 2687 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
2809 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2688 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
2810 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); | 2689 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
2811 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 2690 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
2812 EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity()); | 2691 EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity()); |
2813 host_impl_->ScrollEnd(); | 2692 host_impl_->ScrollEnd(); |
2814 } | 2693 } |
2815 } | 2694 } |
2816 | 2695 |
2817 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { | 2696 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { |
2818 // When we try to scroll a non-scrollable child layer, the scroll delta | 2697 // When we try to scroll a non-scrollable child layer, the scroll delta |
2819 // should be applied to one of its ancestors if possible. Overscroll should | 2698 // should be applied to one of its ancestors if possible. Overscroll should |
2820 // be reflected only when it has bubbled up to the root scrolling layer. | 2699 // be reflected only when it has bubbled up to the root scrolling layer. |
2821 gfx::Size surface_size(10, 10); | 2700 gfx::Size surface_size(10, 10); |
2822 gfx::Size content_size(20, 20); | 2701 gfx::Size content_size(20, 20); |
2823 scoped_ptr<LayerImpl> root_clip = | 2702 scoped_ptr<LayerImpl> root = CreateScrollableLayer(1, content_size); |
2824 LayerImpl::Create(host_impl_->active_tree(), 3); | 2703 scoped_ptr<LayerImpl> child = CreateScrollableLayer(2, content_size); |
2825 scoped_ptr<LayerImpl> root = | |
2826 CreateScrollableLayer(1, content_size, root_clip.get()); | |
2827 root->SetIsContainerForFixedPositionLayers(true); | |
2828 scoped_ptr<LayerImpl> child = | |
2829 CreateScrollableLayer(2, content_size, root_clip.get()); | |
2830 | 2704 |
2831 child->SetScrollClipLayer(Layer::INVALID_ID); | 2705 child->SetScrollable(false); |
2832 root->AddChild(child.Pass()); | 2706 root->AddChild(child.Pass()); |
2833 root_clip->AddChild(root.Pass()); | |
2834 | 2707 |
2835 host_impl_->SetViewportSize(surface_size); | 2708 host_impl_->SetViewportSize(surface_size); |
2836 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 2709 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
2837 host_impl_->active_tree()->SetViewportLayersFromIds(3, 1, Layer::INVALID_ID); | |
2838 host_impl_->active_tree()->DidBecomeActive(); | 2710 host_impl_->active_tree()->DidBecomeActive(); |
2839 DrawFrame(); | 2711 DrawFrame(); |
2840 { | 2712 { |
2841 gfx::Vector2d scroll_delta(0, 8); | 2713 gfx::Vector2d scroll_delta(0, 8); |
2842 EXPECT_EQ(InputHandler::ScrollStarted, | 2714 EXPECT_EQ(InputHandler::ScrollStarted, |
2843 host_impl_->ScrollBegin(gfx::Point(5, 5), | 2715 host_impl_->ScrollBegin(gfx::Point(5, 5), |
2844 InputHandler::Wheel)); | 2716 InputHandler::Wheel)); |
2845 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2717 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
2846 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 2718 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
2847 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2719 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
2848 EXPECT_EQ(gfx::Vector2dF(0, 6), host_impl_->accumulated_root_overscroll()); | 2720 EXPECT_EQ(gfx::Vector2dF(0, 6), host_impl_->accumulated_root_overscroll()); |
2849 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2721 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
2850 EXPECT_EQ(gfx::Vector2dF(0, 14), host_impl_->accumulated_root_overscroll()); | 2722 EXPECT_EQ(gfx::Vector2dF(0, 14), host_impl_->accumulated_root_overscroll()); |
2851 host_impl_->ScrollEnd(); | 2723 host_impl_->ScrollEnd(); |
2852 } | 2724 } |
2853 } | 2725 } |
2854 | 2726 |
2855 TEST_F(LayerTreeHostImplTest, OverscrollAlways) { | 2727 TEST_F(LayerTreeHostImplTest, OverscrollAlways) { |
2856 LayerTreeSettings settings; | 2728 LayerTreeSettings settings; |
2857 CreateHostImpl(settings, CreateOutputSurface()); | 2729 CreateHostImpl(settings, CreateOutputSurface()); |
2858 | 2730 |
2859 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(50, 50)); | 2731 SetupScrollAndContentsLayers(gfx::Size(50, 50)); |
2860 LayerImpl* clip_layer = scroll_layer->parent()->parent(); | |
2861 clip_layer->SetBounds(gfx::Size(50, 50)); | |
2862 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 2732 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
2863 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f); | 2733 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f); |
2864 DrawFrame(); | 2734 DrawFrame(); |
2865 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 2735 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
2866 EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity()); | 2736 EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity()); |
2867 | 2737 |
2868 // Even though the layer can't scroll the overscroll still happens. | 2738 // Even though the layer can't scroll the overscroll still happens. |
2869 EXPECT_EQ(InputHandler::ScrollStarted, | 2739 EXPECT_EQ(InputHandler::ScrollStarted, |
2870 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 2740 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
2871 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 2741 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
(...skipping 2010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4882 scoped_ptr<FakePictureLayerImpl> scoped_content_layer = | 4752 scoped_ptr<FakePictureLayerImpl> scoped_content_layer = |
4883 FakePictureLayerImpl::CreateWithPile(host_impl_->pending_tree(), 3, pile); | 4753 FakePictureLayerImpl::CreateWithPile(host_impl_->pending_tree(), 3, pile); |
4884 LayerImpl* content_layer = scoped_content_layer.get(); | 4754 LayerImpl* content_layer = scoped_content_layer.get(); |
4885 scrolling_layer->AddChild(scoped_content_layer.PassAs<LayerImpl>()); | 4755 scrolling_layer->AddChild(scoped_content_layer.PassAs<LayerImpl>()); |
4886 content_layer->SetBounds(content_layer_bounds); | 4756 content_layer->SetBounds(content_layer_bounds); |
4887 content_layer->SetDrawsContent(true); | 4757 content_layer->SetDrawsContent(true); |
4888 | 4758 |
4889 root->SetBounds(root_size); | 4759 root->SetBounds(root_size); |
4890 | 4760 |
4891 gfx::Vector2d scroll_offset(100000, 0); | 4761 gfx::Vector2d scroll_offset(100000, 0); |
4892 scrolling_layer->SetScrollClipLayer(root->id()); | 4762 scrolling_layer->SetScrollable(true); |
| 4763 scrolling_layer->SetMaxScrollOffset(scroll_offset); |
4893 scrolling_layer->SetScrollOffset(scroll_offset); | 4764 scrolling_layer->SetScrollOffset(scroll_offset); |
4894 | 4765 |
4895 host_impl_->ActivatePendingTree(); | 4766 host_impl_->ActivatePendingTree(); |
4896 | 4767 |
4897 host_impl_->active_tree()->UpdateDrawProperties(); | 4768 host_impl_->active_tree()->UpdateDrawProperties(); |
4898 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); | 4769 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); |
4899 | 4770 |
4900 LayerTreeHostImpl::FrameData frame; | 4771 LayerTreeHostImpl::FrameData frame; |
4901 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 4772 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
4902 | 4773 |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5332 // released, and the texture deleted. | 5203 // released, and the texture deleted. |
5333 EXPECT_TRUE(context_provider->HasOneRef()); | 5204 EXPECT_TRUE(context_provider->HasOneRef()); |
5334 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); | 5205 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); |
5335 } | 5206 } |
5336 | 5207 |
5337 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { | 5208 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { |
5338 // When flinging via touch, only the child should scroll (we should not | 5209 // When flinging via touch, only the child should scroll (we should not |
5339 // bubble). | 5210 // bubble). |
5340 gfx::Size surface_size(10, 10); | 5211 gfx::Size surface_size(10, 10); |
5341 gfx::Size content_size(20, 20); | 5212 gfx::Size content_size(20, 20); |
5342 scoped_ptr<LayerImpl> root_clip = | 5213 scoped_ptr<LayerImpl> root = CreateScrollableLayer(1, content_size); |
5343 LayerImpl::Create(host_impl_->active_tree(), 3); | 5214 scoped_ptr<LayerImpl> child = CreateScrollableLayer(2, content_size); |
5344 scoped_ptr<LayerImpl> root = | |
5345 CreateScrollableLayer(1, content_size, root_clip.get()); | |
5346 root->SetIsContainerForFixedPositionLayers(true); | |
5347 scoped_ptr<LayerImpl> child = | |
5348 CreateScrollableLayer(2, content_size, root_clip.get()); | |
5349 | 5215 |
5350 root->AddChild(child.Pass()); | 5216 root->AddChild(child.Pass()); |
5351 int root_id = root->id(); | |
5352 root_clip->AddChild(root.Pass()); | |
5353 | 5217 |
5354 host_impl_->SetViewportSize(surface_size); | 5218 host_impl_->SetViewportSize(surface_size); |
5355 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 5219 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
5356 host_impl_->active_tree()->SetViewportLayersFromIds(3, 1, Layer::INVALID_ID); | |
5357 host_impl_->active_tree()->DidBecomeActive(); | 5220 host_impl_->active_tree()->DidBecomeActive(); |
5358 DrawFrame(); | 5221 DrawFrame(); |
5359 { | 5222 { |
5360 EXPECT_EQ(InputHandler::ScrollStarted, | 5223 EXPECT_EQ(InputHandler::ScrollStarted, |
5361 host_impl_->ScrollBegin(gfx::Point(), | 5224 host_impl_->ScrollBegin(gfx::Point(), |
5362 InputHandler::Gesture)); | 5225 InputHandler::Gesture)); |
5363 | 5226 |
5364 EXPECT_EQ(InputHandler::ScrollStarted, | 5227 EXPECT_EQ(InputHandler::ScrollStarted, |
5365 host_impl_->FlingScrollBegin()); | 5228 host_impl_->FlingScrollBegin()); |
5366 | 5229 |
5367 gfx::Vector2d scroll_delta(0, 100); | 5230 gfx::Vector2d scroll_delta(0, 100); |
5368 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 5231 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
5369 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 5232 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
5370 | 5233 |
5371 host_impl_->ScrollEnd(); | 5234 host_impl_->ScrollEnd(); |
5372 | 5235 |
5373 scoped_ptr<ScrollAndScaleSet> scroll_info = | 5236 scoped_ptr<ScrollAndScaleSet> scroll_info = |
5374 host_impl_->ProcessScrollDeltas(); | 5237 host_impl_->ProcessScrollDeltas(); |
5375 | 5238 |
5376 // Only the child should have scrolled. | 5239 // Only the child should have scrolled. |
5377 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 5240 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
5378 ExpectNone(*scroll_info.get(), root_id); | 5241 ExpectNone(*scroll_info.get(), |
| 5242 host_impl_->active_tree()->root_layer()->id()); |
5379 } | 5243 } |
5380 } | 5244 } |
5381 | 5245 |
5382 TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) { | 5246 TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) { |
5383 // Scroll a child layer beyond its maximum scroll range and make sure the | 5247 // Scroll a child layer beyond its maximum scroll range and make sure the |
5384 // the scroll doesn't bubble up to the parent layer. | 5248 // the scroll doesn't bubble up to the parent layer. |
5385 gfx::Size surface_size(10, 10); | 5249 gfx::Size surface_size(10, 10); |
5386 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 5250 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
5387 scoped_ptr<LayerImpl> root_scrolling = | 5251 scoped_ptr<LayerImpl> root_scrolling = CreateScrollableLayer(2, surface_size); |
5388 CreateScrollableLayer(2, surface_size, root.get()); | |
5389 | 5252 |
5390 scoped_ptr<LayerImpl> grand_child = | 5253 scoped_ptr<LayerImpl> grand_child = CreateScrollableLayer(4, surface_size); |
5391 CreateScrollableLayer(4, surface_size, root.get()); | |
5392 grand_child->SetScrollOffset(gfx::Vector2d(0, 2)); | 5254 grand_child->SetScrollOffset(gfx::Vector2d(0, 2)); |
5393 | 5255 |
5394 scoped_ptr<LayerImpl> child = | 5256 scoped_ptr<LayerImpl> child = CreateScrollableLayer(3, surface_size); |
5395 CreateScrollableLayer(3, surface_size, root.get()); | |
5396 child->SetScrollOffset(gfx::Vector2d(0, 4)); | 5257 child->SetScrollOffset(gfx::Vector2d(0, 4)); |
5397 child->AddChild(grand_child.Pass()); | 5258 child->AddChild(grand_child.Pass()); |
5398 | 5259 |
5399 root_scrolling->AddChild(child.Pass()); | 5260 root_scrolling->AddChild(child.Pass()); |
5400 root->AddChild(root_scrolling.Pass()); | 5261 root->AddChild(root_scrolling.Pass()); |
5401 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 5262 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
5402 host_impl_->active_tree()->DidBecomeActive(); | 5263 host_impl_->active_tree()->DidBecomeActive(); |
5403 host_impl_->SetViewportSize(surface_size); | 5264 host_impl_->SetViewportSize(surface_size); |
5404 DrawFrame(); | 5265 DrawFrame(); |
5405 { | 5266 { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5445 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child); | 5306 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child); |
5446 host_impl_->ScrollEnd(); | 5307 host_impl_->ScrollEnd(); |
5447 } | 5308 } |
5448 } | 5309 } |
5449 | 5310 |
5450 TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) { | 5311 TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) { |
5451 // When flinging via wheel, the root should eventually scroll (we should | 5312 // When flinging via wheel, the root should eventually scroll (we should |
5452 // bubble). | 5313 // bubble). |
5453 gfx::Size surface_size(10, 10); | 5314 gfx::Size surface_size(10, 10); |
5454 gfx::Size content_size(20, 20); | 5315 gfx::Size content_size(20, 20); |
5455 scoped_ptr<LayerImpl> root_clip = | 5316 scoped_ptr<LayerImpl> root = CreateScrollableLayer(1, content_size); |
5456 LayerImpl::Create(host_impl_->active_tree(), 3); | 5317 scoped_ptr<LayerImpl> child = CreateScrollableLayer(2, content_size); |
5457 scoped_ptr<LayerImpl> root_scroll = | |
5458 CreateScrollableLayer(1, content_size, root_clip.get()); | |
5459 int root_scroll_id = root_scroll->id(); | |
5460 scoped_ptr<LayerImpl> child = | |
5461 CreateScrollableLayer(2, content_size, root_clip.get()); | |
5462 | 5318 |
5463 root_scroll->AddChild(child.Pass()); | 5319 root->AddChild(child.Pass()); |
5464 root_clip->AddChild(root_scroll.Pass()); | |
5465 | 5320 |
5466 host_impl_->SetViewportSize(surface_size); | 5321 host_impl_->SetViewportSize(surface_size); |
5467 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 5322 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
5468 host_impl_->active_tree()->DidBecomeActive(); | 5323 host_impl_->active_tree()->DidBecomeActive(); |
5469 DrawFrame(); | 5324 DrawFrame(); |
5470 { | 5325 { |
5471 EXPECT_EQ(InputHandler::ScrollStarted, | 5326 EXPECT_EQ(InputHandler::ScrollStarted, |
5472 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 5327 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
5473 | 5328 |
5474 EXPECT_EQ(InputHandler::ScrollStarted, | 5329 EXPECT_EQ(InputHandler::ScrollStarted, |
5475 host_impl_->FlingScrollBegin()); | 5330 host_impl_->FlingScrollBegin()); |
5476 | 5331 |
5477 gfx::Vector2d scroll_delta(0, 100); | 5332 gfx::Vector2d scroll_delta(0, 100); |
5478 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 5333 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
5479 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 5334 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
5480 | 5335 |
5481 host_impl_->ScrollEnd(); | 5336 host_impl_->ScrollEnd(); |
5482 | 5337 |
5483 scoped_ptr<ScrollAndScaleSet> scroll_info = | 5338 scoped_ptr<ScrollAndScaleSet> scroll_info = |
5484 host_impl_->ProcessScrollDeltas(); | 5339 host_impl_->ProcessScrollDeltas(); |
5485 | 5340 |
5486 // The root should have scrolled. | 5341 // The root should have scrolled. |
5487 ASSERT_EQ(2u, scroll_info->scrolls.size()); | 5342 ASSERT_EQ(2u, scroll_info->scrolls.size()); |
5488 ExpectContains(*scroll_info.get(), root_scroll_id, gfx::Vector2d(0, 10)); | 5343 ExpectContains(*scroll_info.get(), |
| 5344 host_impl_->active_tree()->root_layer()->id(), |
| 5345 gfx::Vector2d(0, 10)); |
5489 } | 5346 } |
5490 } | 5347 } |
5491 | 5348 |
5492 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed | 5349 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed |
5493 // to CompositorFrameMetadata after SwapBuffers(); | 5350 // to CompositorFrameMetadata after SwapBuffers(); |
5494 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { | 5351 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { |
5495 scoped_ptr<SolidColorLayerImpl> root = | 5352 scoped_ptr<SolidColorLayerImpl> root = |
5496 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 5353 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
5497 root->SetAnchorPoint(gfx::PointF()); | 5354 root->SetAnchorPoint(gfx::PointF()); |
5498 root->SetPosition(gfx::PointF()); | 5355 root->SetPosition(gfx::PointF()); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5596 &set_needs_redraw_count)); | 5453 &set_needs_redraw_count)); |
5597 // Empty damage rect won't signal the monitor. | 5454 // Empty damage rect won't signal the monitor. |
5598 host_impl_->SetNeedsRedrawRect(gfx::Rect()); | 5455 host_impl_->SetNeedsRedrawRect(gfx::Rect()); |
5599 EXPECT_EQ(0, set_needs_commit_count); | 5456 EXPECT_EQ(0, set_needs_commit_count); |
5600 EXPECT_EQ(2, set_needs_redraw_count); | 5457 EXPECT_EQ(2, set_needs_redraw_count); |
5601 } | 5458 } |
5602 } | 5459 } |
5603 | 5460 |
5604 } // namespace | 5461 } // namespace |
5605 } // namespace cc | 5462 } // namespace cc |
OLD | NEW |