| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 outer_scroll->test_properties()->AddChild(std::move(contents)); | 375 outer_scroll->test_properties()->AddChild(std::move(contents)); |
| 376 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); | 376 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); |
| 377 inner_scroll->test_properties()->AddChild(std::move(outer_clip)); | 377 inner_scroll->test_properties()->AddChild(std::move(outer_clip)); |
| 378 page_scale->test_properties()->AddChild(std::move(inner_scroll)); | 378 page_scale->test_properties()->AddChild(std::move(inner_scroll)); |
| 379 inner_clip->test_properties()->AddChild(std::move(page_scale)); | 379 inner_clip->test_properties()->AddChild(std::move(page_scale)); |
| 380 root->test_properties()->AddChild(std::move(inner_clip)); | 380 root->test_properties()->AddChild(std::move(inner_clip)); |
| 381 | 381 |
| 382 layer_tree_impl->SetRootLayerForTesting(std::move(root)); | 382 layer_tree_impl->SetRootLayerForTesting(std::move(root)); |
| 383 layer_tree_impl->BuildPropertyTreesForTesting(); | 383 layer_tree_impl->BuildPropertyTreesForTesting(); |
| 384 layer_tree_impl->SetViewportLayersFromIds( | 384 layer_tree_impl->SetViewportLayersFromIds( |
| 385 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, | 385 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportClipLayerId, |
| 386 kOuterViewportClipLayerId, kInnerViewportScrollLayerId, |
| 386 kOuterViewportScrollLayerId); | 387 kOuterViewportScrollLayerId); |
| 387 | 388 |
| 388 layer_tree_impl->DidBecomeActive(); | 389 layer_tree_impl->DidBecomeActive(); |
| 389 return layer_tree_impl->InnerViewportScrollLayer(); | 390 return layer_tree_impl->InnerViewportScrollLayer(); |
| 390 } | 391 } |
| 391 | 392 |
| 392 LayerImpl* SetupScrollAndContentsLayers(const gfx::Size& content_size) { | 393 LayerImpl* SetupScrollAndContentsLayers(const gfx::Size& content_size) { |
| 393 LayerImpl* scroll_layer = | 394 LayerImpl* scroll_layer = |
| 394 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); | 395 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); |
| 395 host_impl_->active_tree()->DidBecomeActive(); | 396 host_impl_->active_tree()->DidBecomeActive(); |
| (...skipping 3895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4291 outer_clip->SetBounds(outer_viewport_size); | 4292 outer_clip->SetBounds(outer_viewport_size); |
| 4292 outer_scroll->SetScrollClipLayer(outer_clip->id()); | 4293 outer_scroll->SetScrollClipLayer(outer_clip->id()); |
| 4293 outer_scroll->SetElementId( | 4294 outer_scroll->SetElementId( |
| 4294 LayerIdToElementIdForTesting(outer_scroll->id())); | 4295 LayerIdToElementIdForTesting(outer_scroll->id())); |
| 4295 outer_scroll->SetBounds(scroll_layer_size); | 4296 outer_scroll->SetBounds(scroll_layer_size); |
| 4296 outer_scroll->SetPosition(gfx::PointF()); | 4297 outer_scroll->SetPosition(gfx::PointF()); |
| 4297 outer_scroll->SetDrawsContent(false); | 4298 outer_scroll->SetDrawsContent(false); |
| 4298 outer_scroll->test_properties()->is_container_for_fixed_position_layers = | 4299 outer_scroll->test_properties()->is_container_for_fixed_position_layers = |
| 4299 true; | 4300 true; |
| 4300 | 4301 |
| 4302 int inner_viewport_container_layer_id = root_clip->id(); |
| 4303 int outer_viewport_container_layer_id = outer_clip->id(); |
| 4301 int inner_viewport_scroll_layer_id = root->id(); | 4304 int inner_viewport_scroll_layer_id = root->id(); |
| 4302 int outer_viewport_scroll_layer_id = outer_scroll->id(); | 4305 int outer_viewport_scroll_layer_id = outer_scroll->id(); |
| 4303 int page_scale_layer_id = page_scale->id(); | 4306 int page_scale_layer_id = page_scale->id(); |
| 4304 | 4307 |
| 4305 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); | 4308 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); |
| 4306 root->test_properties()->AddChild(std::move(outer_clip)); | 4309 root->test_properties()->AddChild(std::move(outer_clip)); |
| 4307 page_scale->test_properties()->AddChild(std::move(root)); | 4310 page_scale->test_properties()->AddChild(std::move(root)); |
| 4308 root_clip->test_properties()->AddChild(std::move(page_scale)); | 4311 root_clip->test_properties()->AddChild(std::move(page_scale)); |
| 4309 | 4312 |
| 4310 tree_impl->SetRootLayerForTesting(std::move(root_clip)); | 4313 tree_impl->SetRootLayerForTesting(std::move(root_clip)); |
| 4311 tree_impl->SetViewportLayersFromIds(Layer::INVALID_ID, page_scale_layer_id, | 4314 tree_impl->SetViewportLayersFromIds( |
| 4312 inner_viewport_scroll_layer_id, | 4315 Layer::INVALID_ID, page_scale_layer_id, |
| 4313 outer_viewport_scroll_layer_id); | 4316 inner_viewport_container_layer_id, outer_viewport_container_layer_id, |
| 4317 inner_viewport_scroll_layer_id, outer_viewport_scroll_layer_id); |
| 4314 tree_impl->BuildPropertyTreesForTesting(); | 4318 tree_impl->BuildPropertyTreesForTesting(); |
| 4315 | 4319 |
| 4316 host_impl_->SetViewportSize(inner_viewport_size); | 4320 host_impl_->SetViewportSize(inner_viewport_size); |
| 4317 LayerImpl* root_clip_ptr = tree_impl->root_layer_for_testing(); | 4321 LayerImpl* root_clip_ptr = tree_impl->root_layer_for_testing(); |
| 4318 EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds()); | 4322 EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds()); |
| 4319 } | 4323 } |
| 4320 | 4324 |
| 4321 protected: | 4325 protected: |
| 4322 gfx::Size layer_size_; | 4326 gfx::Size layer_size_; |
| 4323 gfx::Size clip_size_; | 4327 gfx::Size clip_size_; |
| (...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5720 LayerImpl* grand_child_layer = grand_child.get(); | 5724 LayerImpl* grand_child_layer = grand_child.get(); |
| 5721 child->test_properties()->AddChild(std::move(grand_child)); | 5725 child->test_properties()->AddChild(std::move(grand_child)); |
| 5722 | 5726 |
| 5723 LayerImpl* child_layer = child.get(); | 5727 LayerImpl* child_layer = child.get(); |
| 5724 root_scrolling->test_properties()->AddChild(std::move(child)); | 5728 root_scrolling->test_properties()->AddChild(std::move(child)); |
| 5725 root_clip->test_properties()->AddChild(std::move(root_scrolling)); | 5729 root_clip->test_properties()->AddChild(std::move(root_scrolling)); |
| 5726 EXPECT_EQ(viewport_size, root_clip->bounds()); | 5730 EXPECT_EQ(viewport_size, root_clip->bounds()); |
| 5727 root_ptr->test_properties()->AddChild(std::move(root_clip)); | 5731 root_ptr->test_properties()->AddChild(std::move(root_clip)); |
| 5728 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); | 5732 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); |
| 5729 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 5733 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5730 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, | 5734 host_impl_->active_tree()->SetViewportLayersFromIds( |
| 5731 Layer::INVALID_ID); | 5735 Layer::INVALID_ID, 1, Layer::INVALID_ID, Layer::INVALID_ID, 3, |
| 5736 Layer::INVALID_ID); |
| 5732 host_impl_->active_tree()->DidBecomeActive(); | 5737 host_impl_->active_tree()->DidBecomeActive(); |
| 5733 host_impl_->SetViewportSize(viewport_size); | 5738 host_impl_->SetViewportSize(viewport_size); |
| 5734 | 5739 |
| 5735 grand_child_layer->layer_tree_impl() | 5740 grand_child_layer->layer_tree_impl() |
| 5736 ->property_trees() | 5741 ->property_trees() |
| 5737 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), | 5742 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), |
| 5738 gfx::ScrollOffset(0, 2)); | 5743 gfx::ScrollOffset(0, 2)); |
| 5739 child_layer->layer_tree_impl() | 5744 child_layer->layer_tree_impl() |
| 5740 ->property_trees() | 5745 ->property_trees() |
| 5741 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), | 5746 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5860 CreateScrollableLayer(2, content_size, root_scroll.get()); | 5865 CreateScrollableLayer(2, content_size, root_scroll.get()); |
| 5861 child->test_properties()->is_container_for_fixed_position_layers = true; | 5866 child->test_properties()->is_container_for_fixed_position_layers = true; |
| 5862 root_scroll->SetBounds(content_size); | 5867 root_scroll->SetBounds(content_size); |
| 5863 | 5868 |
| 5864 int root_scroll_id = root_scroll->id(); | 5869 int root_scroll_id = root_scroll->id(); |
| 5865 root_scroll->test_properties()->AddChild(std::move(child)); | 5870 root_scroll->test_properties()->AddChild(std::move(child)); |
| 5866 root_clip->test_properties()->AddChild(std::move(root_scroll)); | 5871 root_clip->test_properties()->AddChild(std::move(root_scroll)); |
| 5867 root_ptr->test_properties()->AddChild(std::move(root_clip)); | 5872 root_ptr->test_properties()->AddChild(std::move(root_clip)); |
| 5868 | 5873 |
| 5869 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); | 5874 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); |
| 5870 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 2, | 5875 host_impl_->active_tree()->SetViewportLayersFromIds( |
| 5871 Layer::INVALID_ID); | 5876 Layer::INVALID_ID, 4, Layer::INVALID_ID, Layer::INVALID_ID, 2, |
| 5877 Layer::INVALID_ID); |
| 5872 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 5878 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5873 host_impl_->active_tree()->DidBecomeActive(); | 5879 host_impl_->active_tree()->DidBecomeActive(); |
| 5874 | 5880 |
| 5875 host_impl_->SetViewportSize(surface_size); | 5881 host_impl_->SetViewportSize(surface_size); |
| 5876 DrawFrame(); | 5882 DrawFrame(); |
| 5877 { | 5883 { |
| 5878 gfx::Vector2d scroll_delta(0, 4); | 5884 gfx::Vector2d scroll_delta(0, 4); |
| 5879 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5885 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5880 host_impl_ | 5886 host_impl_ |
| 5881 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5887 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 5909 inner_clip->test_properties()->force_render_surface = true; | 5915 inner_clip->test_properties()->force_render_surface = true; |
| 5910 inner_scroll->test_properties()->is_container_for_fixed_position_layers = | 5916 inner_scroll->test_properties()->is_container_for_fixed_position_layers = |
| 5911 true; | 5917 true; |
| 5912 outer_scroll->test_properties()->is_container_for_fixed_position_layers = | 5918 outer_scroll->test_properties()->is_container_for_fixed_position_layers = |
| 5913 true; | 5919 true; |
| 5914 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); | 5920 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); |
| 5915 inner_scroll->test_properties()->AddChild(std::move(outer_clip)); | 5921 inner_scroll->test_properties()->AddChild(std::move(outer_clip)); |
| 5916 inner_clip->test_properties()->AddChild(std::move(inner_scroll)); | 5922 inner_clip->test_properties()->AddChild(std::move(inner_scroll)); |
| 5917 root_ptr->test_properties()->AddChild(std::move(inner_clip)); | 5923 root_ptr->test_properties()->AddChild(std::move(inner_clip)); |
| 5918 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); | 5924 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); |
| 5919 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, | 5925 host_impl_->active_tree()->SetViewportLayersFromIds( |
| 5920 8); | 5926 Layer::INVALID_ID, 1, Layer::INVALID_ID, Layer::INVALID_ID, 3, 8); |
| 5921 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 5927 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5922 host_impl_->active_tree()->DidBecomeActive(); | 5928 host_impl_->active_tree()->DidBecomeActive(); |
| 5923 | 5929 |
| 5924 host_impl_->SetViewportSize(surface_size); | 5930 host_impl_->SetViewportSize(surface_size); |
| 5925 | 5931 |
| 5926 // Draw one frame and then immediately rebuild the layer tree to mimic a tree | 5932 // Draw one frame and then immediately rebuild the layer tree to mimic a tree |
| 5927 // synchronization. | 5933 // synchronization. |
| 5928 DrawFrame(); | 5934 DrawFrame(); |
| 5929 | 5935 |
| 5930 host_impl_->active_tree()->DetachLayers(); | 5936 host_impl_->active_tree()->DetachLayers(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 5942 true; | 5948 true; |
| 5943 outer_scroll2->test_properties()->is_container_for_fixed_position_layers = | 5949 outer_scroll2->test_properties()->is_container_for_fixed_position_layers = |
| 5944 true; | 5950 true; |
| 5945 outer_clip2->test_properties()->AddChild(std::move(outer_scroll2)); | 5951 outer_clip2->test_properties()->AddChild(std::move(outer_scroll2)); |
| 5946 inner_scroll2->test_properties()->AddChild(std::move(outer_clip2)); | 5952 inner_scroll2->test_properties()->AddChild(std::move(outer_clip2)); |
| 5947 inner_clip2->test_properties()->AddChild(std::move(inner_scroll2)); | 5953 inner_clip2->test_properties()->AddChild(std::move(inner_scroll2)); |
| 5948 inner_clip2->test_properties()->force_render_surface = true; | 5954 inner_clip2->test_properties()->force_render_surface = true; |
| 5949 root_ptr2->test_properties()->AddChild(std::move(inner_clip2)); | 5955 root_ptr2->test_properties()->AddChild(std::move(inner_clip2)); |
| 5950 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr2)); | 5956 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr2)); |
| 5951 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 5957 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5952 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 6, | 5958 host_impl_->active_tree()->SetViewportLayersFromIds( |
| 5953 10); | 5959 Layer::INVALID_ID, 4, Layer::INVALID_ID, Layer::INVALID_ID, 6, 10); |
| 5954 host_impl_->active_tree()->DidBecomeActive(); | 5960 host_impl_->active_tree()->DidBecomeActive(); |
| 5955 | 5961 |
| 5956 // Scrolling should still work even though we did not draw yet. | 5962 // Scrolling should still work even though we did not draw yet. |
| 5957 EXPECT_EQ( | 5963 EXPECT_EQ( |
| 5958 InputHandler::SCROLL_ON_IMPL_THREAD, | 5964 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5959 host_impl_ | 5965 host_impl_ |
| 5960 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL) | 5966 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL) |
| 5961 .thread); | 5967 .thread); |
| 5962 } | 5968 } |
| 5963 | 5969 |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6526 | 6532 |
| 6527 std::unique_ptr<LayerImpl> grand_child = | 6533 std::unique_ptr<LayerImpl> grand_child = |
| 6528 CreateScrollableLayer(3, surface_size, root_clip.get()); | 6534 CreateScrollableLayer(3, surface_size, root_clip.get()); |
| 6529 | 6535 |
| 6530 std::unique_ptr<LayerImpl> child = | 6536 std::unique_ptr<LayerImpl> child = |
| 6531 CreateScrollableLayer(2, surface_size, root_clip.get()); | 6537 CreateScrollableLayer(2, surface_size, root_clip.get()); |
| 6532 LayerImpl* grand_child_layer = grand_child.get(); | 6538 LayerImpl* grand_child_layer = grand_child.get(); |
| 6533 child->test_properties()->AddChild(std::move(grand_child)); | 6539 child->test_properties()->AddChild(std::move(grand_child)); |
| 6534 | 6540 |
| 6535 host_impl_->active_tree()->SetViewportLayersFromIds( | 6541 host_impl_->active_tree()->SetViewportLayersFromIds( |
| 6536 Layer::INVALID_ID, Layer::INVALID_ID, root->id(), Layer::INVALID_ID); | 6542 Layer::INVALID_ID, Layer::INVALID_ID, Layer::INVALID_ID, |
| 6543 Layer::INVALID_ID, root->id(), Layer::INVALID_ID); |
| 6537 | 6544 |
| 6538 LayerImpl* child_layer = child.get(); | 6545 LayerImpl* child_layer = child.get(); |
| 6539 root->test_properties()->AddChild(std::move(child)); | 6546 root->test_properties()->AddChild(std::move(child)); |
| 6540 root_clip->test_properties()->AddChild(std::move(root)); | 6547 root_clip->test_properties()->AddChild(std::move(root)); |
| 6541 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_clip)); | 6548 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_clip)); |
| 6542 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6549 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6543 host_impl_->active_tree()->DidBecomeActive(); | 6550 host_impl_->active_tree()->DidBecomeActive(); |
| 6544 | 6551 |
| 6545 child_layer->layer_tree_impl() | 6552 child_layer->layer_tree_impl() |
| 6546 ->property_trees() | 6553 ->property_trees() |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6931 scroll_layer = scroll.get(); | 6938 scroll_layer = scroll.get(); |
| 6932 child_scroll_layer = scroll2.get(); | 6939 child_scroll_layer = scroll2.get(); |
| 6933 | 6940 |
| 6934 clip2->test_properties()->AddChild(std::move(scroll2)); | 6941 clip2->test_properties()->AddChild(std::move(scroll2)); |
| 6935 scroll->test_properties()->AddChild(std::move(clip2)); | 6942 scroll->test_properties()->AddChild(std::move(clip2)); |
| 6936 | 6943 |
| 6937 clip->test_properties()->AddChild(std::move(scroll)); | 6944 clip->test_properties()->AddChild(std::move(scroll)); |
| 6938 content_layer->test_properties()->AddChild(std::move(clip)); | 6945 content_layer->test_properties()->AddChild(std::move(clip)); |
| 6939 layer_tree_impl->SetViewportLayersFromIds( | 6946 layer_tree_impl->SetViewportLayersFromIds( |
| 6940 Layer::INVALID_ID, layer_tree_impl->PageScaleLayer()->id(), | 6947 Layer::INVALID_ID, layer_tree_impl->PageScaleLayer()->id(), |
| 6941 inner_scroll_layer->id(), scroll_layer->id()); | 6948 Layer::INVALID_ID, Layer::INVALID_ID, inner_scroll_layer->id(), |
| 6949 scroll_layer->id()); |
| 6942 layer_tree_impl->BuildPropertyTreesForTesting(); | 6950 layer_tree_impl->BuildPropertyTreesForTesting(); |
| 6943 } | 6951 } |
| 6944 | 6952 |
| 6945 // Scroll should target the nested scrolling layer in the content and then | 6953 // Scroll should target the nested scrolling layer in the content and then |
| 6946 // chain to the parent scrolling layer which is now set as the outer | 6954 // chain to the parent scrolling layer which is now set as the outer |
| 6947 // viewport. The original outer viewport layer shouldn't get any scroll here. | 6955 // viewport. The original outer viewport layer shouldn't get any scroll here. |
| 6948 { | 6956 { |
| 6949 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 6957 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
| 6950 InputHandler::TOUCHSCREEN); | 6958 InputHandler::TOUCHSCREEN); |
| 6951 host_impl_->ScrollBy( | 6959 host_impl_->ScrollBy( |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7064 scroll2->SetBounds(gfx::Size(1200, 1200)); | 7072 scroll2->SetBounds(gfx::Size(1200, 1200)); |
| 7065 scroll2->SetScrollClipLayer(clip2->id()); | 7073 scroll2->SetScrollClipLayer(clip2->id()); |
| 7066 scroll2->SetElementId(LayerIdToElementIdForTesting(scroll2->id())); | 7074 scroll2->SetElementId(LayerIdToElementIdForTesting(scroll2->id())); |
| 7067 scroll2->SetDrawsContent(true); | 7075 scroll2->SetDrawsContent(true); |
| 7068 | 7076 |
| 7069 sibling_scroll_layer = scroll2.get(); | 7077 sibling_scroll_layer = scroll2.get(); |
| 7070 | 7078 |
| 7071 clip2->test_properties()->AddChild(std::move(scroll2)); | 7079 clip2->test_properties()->AddChild(std::move(scroll2)); |
| 7072 content_layer->test_properties()->AddChild(std::move(clip2)); | 7080 content_layer->test_properties()->AddChild(std::move(clip2)); |
| 7073 | 7081 |
| 7082 LayerImpl* inner_container = |
| 7083 host_impl_->active_tree()->InnerViewportContainerLayer(); |
| 7074 layer_tree_impl->SetViewportLayersFromIds( | 7084 layer_tree_impl->SetViewportLayersFromIds( |
| 7075 Layer::INVALID_ID, layer_tree_impl->PageScaleLayer()->id(), | 7085 Layer::INVALID_ID, layer_tree_impl->PageScaleLayer()->id(), |
| 7076 inner_scroll_layer->id(), outer_scroll_layer->id()); | 7086 inner_container->id(), Layer::INVALID_ID, inner_scroll_layer->id(), |
| 7087 outer_scroll_layer->id()); |
| 7077 layer_tree_impl->BuildPropertyTreesForTesting(); | 7088 layer_tree_impl->BuildPropertyTreesForTesting(); |
| 7078 | 7089 |
| 7079 ASSERT_EQ(outer_scroll_layer, layer_tree_impl->OuterViewportScrollLayer()); | 7090 ASSERT_EQ(outer_scroll_layer, layer_tree_impl->OuterViewportScrollLayer()); |
| 7080 } | 7091 } |
| 7081 | 7092 |
| 7082 // Scrolls should target the non-descendant scroller. Chaining should not | 7093 // Scrolls should target the non-descendant scroller. Chaining should not |
| 7083 // propagate to the outer viewport scroll layer. | 7094 // propagate to the outer viewport scroll layer. |
| 7084 { | 7095 { |
| 7085 // This should fully scroll the layer. | 7096 // This should fully scroll the layer. |
| 7086 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 7097 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
| (...skipping 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8836 std::unique_ptr<LayerImpl> child = | 8847 std::unique_ptr<LayerImpl> child = |
| 8837 CreateScrollableLayer(2, content_size, root_clip.get()); | 8848 CreateScrollableLayer(2, content_size, root_clip.get()); |
| 8838 | 8849 |
| 8839 root_scroll->test_properties()->AddChild(std::move(child)); | 8850 root_scroll->test_properties()->AddChild(std::move(child)); |
| 8840 int root_id = root_scroll->id(); | 8851 int root_id = root_scroll->id(); |
| 8841 root_clip->test_properties()->AddChild(std::move(root_scroll)); | 8852 root_clip->test_properties()->AddChild(std::move(root_scroll)); |
| 8842 root_ptr->test_properties()->AddChild(std::move(root_clip)); | 8853 root_ptr->test_properties()->AddChild(std::move(root_clip)); |
| 8843 | 8854 |
| 8844 host_impl_->SetViewportSize(surface_size); | 8855 host_impl_->SetViewportSize(surface_size); |
| 8845 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); | 8856 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); |
| 8846 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 1, | 8857 host_impl_->active_tree()->SetViewportLayersFromIds( |
| 8847 Layer::INVALID_ID); | 8858 Layer::INVALID_ID, 4, Layer::INVALID_ID, Layer::INVALID_ID, 1, |
| 8859 Layer::INVALID_ID); |
| 8848 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 8860 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8849 host_impl_->active_tree()->DidBecomeActive(); | 8861 host_impl_->active_tree()->DidBecomeActive(); |
| 8850 DrawFrame(); | 8862 DrawFrame(); |
| 8851 { | 8863 { |
| 8852 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8864 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8853 host_impl_ | 8865 host_impl_ |
| 8854 ->ScrollBegin(BeginState(gfx::Point()).get(), | 8866 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8855 InputHandler::TOUCHSCREEN) | 8867 InputHandler::TOUCHSCREEN) |
| 8856 .thread); | 8868 .thread); |
| 8857 | 8869 |
| (...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9863 std::unique_ptr<LayerImpl> scroll = LayerImpl::Create(layer_tree_impl, 11); | 9875 std::unique_ptr<LayerImpl> scroll = LayerImpl::Create(layer_tree_impl, 11); |
| 9864 scroll->SetBounds(scroll_content_size); | 9876 scroll->SetBounds(scroll_content_size); |
| 9865 scroll->SetScrollClipLayer(clip->id()); | 9877 scroll->SetScrollClipLayer(clip->id()); |
| 9866 scroll->SetElementId(LayerIdToElementIdForTesting(scroll->id())); | 9878 scroll->SetElementId(LayerIdToElementIdForTesting(scroll->id())); |
| 9867 scroll->SetDrawsContent(true); | 9879 scroll->SetDrawsContent(true); |
| 9868 | 9880 |
| 9869 scroll_layer = scroll.get(); | 9881 scroll_layer = scroll.get(); |
| 9870 | 9882 |
| 9871 clip->test_properties()->AddChild(std::move(scroll)); | 9883 clip->test_properties()->AddChild(std::move(scroll)); |
| 9872 outer_scroll->test_properties()->AddChild(std::move(clip)); | 9884 outer_scroll->test_properties()->AddChild(std::move(clip)); |
| 9885 |
| 9873 layer_tree_impl->SetViewportLayersFromIds( | 9886 layer_tree_impl->SetViewportLayersFromIds( |
| 9874 Layer::INVALID_ID, layer_tree_impl->PageScaleLayer()->id(), | 9887 Layer::INVALID_ID, layer_tree_impl->PageScaleLayer()->id(), |
| 9875 inner_scroll->id(), scroll_layer->id()); | 9888 Layer::INVALID_ID, Layer::INVALID_ID, inner_scroll->id(), |
| 9889 scroll_layer->id()); |
| 9876 layer_tree_impl->BuildPropertyTreesForTesting(); | 9890 layer_tree_impl->BuildPropertyTreesForTesting(); |
| 9877 DrawFrame(); | 9891 DrawFrame(); |
| 9878 } | 9892 } |
| 9879 | 9893 |
| 9880 ASSERT_EQ(1.f, host_impl_->active_tree()->CurrentBrowserControlsShownRatio()); | 9894 ASSERT_EQ(1.f, host_impl_->active_tree()->CurrentBrowserControlsShownRatio()); |
| 9881 | 9895 |
| 9882 // Scrolling should scroll the child content and the browser controls. The | 9896 // Scrolling should scroll the child content and the browser controls. The |
| 9883 // original outer viewport should get no scroll. | 9897 // original outer viewport should get no scroll. |
| 9884 { | 9898 { |
| 9885 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 9899 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9955 | 9969 |
| 9956 outer_scroll->test_properties()->AddChild(std::move(contents)); | 9970 outer_scroll->test_properties()->AddChild(std::move(contents)); |
| 9957 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); | 9971 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); |
| 9958 inner_scroll->test_properties()->AddChild(std::move(outer_clip)); | 9972 inner_scroll->test_properties()->AddChild(std::move(outer_clip)); |
| 9959 page_scale->test_properties()->AddChild(std::move(inner_scroll)); | 9973 page_scale->test_properties()->AddChild(std::move(inner_scroll)); |
| 9960 inner_clip->test_properties()->AddChild(std::move(page_scale)); | 9974 inner_clip->test_properties()->AddChild(std::move(page_scale)); |
| 9961 | 9975 |
| 9962 inner_clip->test_properties()->force_render_surface = true; | 9976 inner_clip->test_properties()->force_render_surface = true; |
| 9963 layer_tree_impl->SetRootLayerForTesting(std::move(inner_clip)); | 9977 layer_tree_impl->SetRootLayerForTesting(std::move(inner_clip)); |
| 9964 layer_tree_impl->SetViewportLayersFromIds( | 9978 layer_tree_impl->SetViewportLayersFromIds( |
| 9965 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, | 9979 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportClipLayerId, |
| 9980 kOuterViewportClipLayerId, kInnerViewportScrollLayerId, |
| 9966 kOuterViewportScrollLayerId); | 9981 kOuterViewportScrollLayerId); |
| 9967 | 9982 |
| 9968 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 9983 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 9969 host_impl_->active_tree()->DidBecomeActive(); | 9984 host_impl_->active_tree()->DidBecomeActive(); |
| 9970 } | 9985 } |
| 9971 }; | 9986 }; |
| 9972 | 9987 |
| 9973 TEST_F(LayerTreeHostImplVirtualViewportTest, ScrollBothInnerAndOuterLayer) { | 9988 TEST_F(LayerTreeHostImplVirtualViewportTest, ScrollBothInnerAndOuterLayer) { |
| 9974 gfx::Size content_size = gfx::Size(100, 160); | 9989 gfx::Size content_size = gfx::Size(100, 160); |
| 9975 gfx::Size outer_viewport = gfx::Size(50, 80); | 9990 gfx::Size outer_viewport = gfx::Size(50, 80); |
| (...skipping 2414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12390 else | 12405 else |
| 12391 EXPECT_FALSE(tile->HasRasterTask()); | 12406 EXPECT_FALSE(tile->HasRasterTask()); |
| 12392 } | 12407 } |
| 12393 Region expected_invalidation( | 12408 Region expected_invalidation( |
| 12394 raster_source->GetRectForImage(checkerable_image.stable_id())); | 12409 raster_source->GetRectForImage(checkerable_image.stable_id())); |
| 12395 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); | 12410 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); |
| 12396 } | 12411 } |
| 12397 | 12412 |
| 12398 } // namespace | 12413 } // namespace |
| 12399 } // namespace cc | 12414 } // namespace cc |
| OLD | NEW |