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

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

Issue 2840433002: Move LayerImpl's bounds_delta to property trees (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 2812 matching lines...) Expand 10 before | Expand all | Expand 10 after
2823 host_impl_->DidFinishImplFrame(); 2823 host_impl_->DidFinishImplFrame();
2824 2824
2825 begin_frame_args.frame_time = end_time; 2825 begin_frame_args.frame_time = end_time;
2826 begin_frame_args.sequence_number++; 2826 begin_frame_args.sequence_number++;
2827 host_impl_->WillBeginImplFrame(begin_frame_args); 2827 host_impl_->WillBeginImplFrame(begin_frame_args);
2828 host_impl_->Animate(); 2828 host_impl_->Animate();
2829 EXPECT_TRUE(did_complete_page_scale_animation_); 2829 EXPECT_TRUE(did_complete_page_scale_animation_);
2830 host_impl_->DidFinishImplFrame(); 2830 host_impl_->DidFinishImplFrame();
2831 } 2831 }
2832 2832
2833 TEST_F(LayerTreeHostImplTest, MaxScrollOffsetAffectedByBoundsDelta) { 2833 TEST_F(LayerTreeHostImplTest, MaxScrollOffsetAffectedByViewportBoundsDelta) {
2834 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 2834 SetupScrollAndContentsLayers(gfx::Size(100, 100));
2835 host_impl_->SetViewportSize(gfx::Size(50, 50)); 2835 host_impl_->SetViewportSize(gfx::Size(50, 50));
2836 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); 2836 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f);
2837 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 2837 host_impl_->active_tree()->BuildPropertyTreesForTesting();
2838 DrawFrame(); 2838 DrawFrame();
2839 2839
2840 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); 2840 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer();
2841 LayerImpl* inner_container = inner_scroll->scroll_clip_layer(); 2841 LayerImpl* inner_container = inner_scroll->scroll_clip_layer();
2842 DCHECK(inner_scroll); 2842 DCHECK(inner_scroll);
2843 DCHECK(inner_container); 2843 DCHECK(inner_container);
2844 EXPECT_EQ(gfx::ScrollOffset(50, 50), inner_scroll->MaxScrollOffset()); 2844 EXPECT_EQ(gfx::ScrollOffset(50, 50), inner_scroll->MaxScrollOffset());
2845 2845
2846 inner_container->SetBoundsDelta(gfx::Vector2dF(15.f, 15.f)); 2846 inner_container->SetViewportBoundsDelta(gfx::Vector2dF(15.f, 15.f));
2847 inner_scroll->SetBoundsDelta(gfx::Vector2dF(7.f, 7.f)); 2847 inner_scroll->SetViewportBoundsDelta(gfx::Vector2dF(7.f, 7.f));
2848 EXPECT_EQ(gfx::ScrollOffset(42, 42), inner_scroll->MaxScrollOffset()); 2848 EXPECT_EQ(gfx::ScrollOffset(42, 42), inner_scroll->MaxScrollOffset());
2849 2849
2850 inner_container->SetBoundsDelta(gfx::Vector2dF()); 2850 inner_container->SetViewportBoundsDelta(gfx::Vector2dF());
2851 inner_scroll->SetBoundsDelta(gfx::Vector2dF()); 2851 inner_scroll->SetViewportBoundsDelta(gfx::Vector2dF());
2852 inner_scroll->SetBounds(gfx::Size()); 2852 inner_scroll->SetBounds(gfx::Size());
2853 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 2853 host_impl_->active_tree()->BuildPropertyTreesForTesting();
2854 DrawFrame(); 2854 DrawFrame();
2855 2855
2856 inner_scroll->SetBoundsDelta(gfx::Vector2dF(60.f, 60.f)); 2856 inner_scroll->SetViewportBoundsDelta(gfx::Vector2dF(60.f, 60.f));
2857 EXPECT_EQ(gfx::ScrollOffset(10, 10), inner_scroll->MaxScrollOffset()); 2857 EXPECT_EQ(gfx::ScrollOffset(10, 10), inner_scroll->MaxScrollOffset());
2858 } 2858 }
2859 2859
2860 class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl { 2860 class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl {
2861 public: 2861 public:
2862 LayerTreeHostImplOverridePhysicalTime( 2862 LayerTreeHostImplOverridePhysicalTime(
2863 const LayerTreeSettings& settings, 2863 const LayerTreeSettings& settings,
2864 LayerTreeHostImplClient* client, 2864 LayerTreeHostImplClient* client,
2865 TaskRunnerProvider* task_runner_provider, 2865 TaskRunnerProvider* task_runner_provider,
2866 TaskGraphRunner* task_graph_runner, 2866 TaskGraphRunner* task_graph_runner,
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
3403 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForElementId( 3403 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForElementId(
3404 root_scroll->element_id())); 3404 root_scroll->element_id()));
3405 horiz_1_scrollbar->SetScrollElementId(root_scroll->element_id()); 3405 horiz_1_scrollbar->SetScrollElementId(root_scroll->element_id());
3406 EXPECT_EQ(2ul, host_impl_->ScrollbarsFor(root_scroll->element_id()).size()); 3406 EXPECT_EQ(2ul, host_impl_->ScrollbarsFor(root_scroll->element_id()).size());
3407 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForElementId( 3407 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForElementId(
3408 root_scroll->element_id())); 3408 root_scroll->element_id()));
3409 3409
3410 // Changing one of the viewport layers should result in a scrollbar animation 3410 // Changing one of the viewport layers should result in a scrollbar animation
3411 // update. 3411 // update.
3412 animation_task_ = base::Closure(); 3412 animation_task_ = base::Closure();
3413 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBoundsDelta( 3413 host_impl_->active_tree()
3414 gfx::Vector2dF(10, 10)); 3414 ->InnerViewportContainerLayer()
3415 ->SetViewportBoundsDelta(gfx::Vector2dF(10, 10));
3415 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 3416 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
3416 animation_task_ = base::Closure(); 3417 animation_task_ = base::Closure();
3417 host_impl_->active_tree()->OuterViewportScrollLayer()->SetCurrentScrollOffset( 3418 host_impl_->active_tree()->OuterViewportScrollLayer()->SetCurrentScrollOffset(
3418 gfx::ScrollOffset(10, 10)); 3419 gfx::ScrollOffset(10, 10));
3419 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 3420 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
3420 animation_task_ = base::Closure(); 3421 animation_task_ = base::Closure();
3421 host_impl_->active_tree()->InnerViewportScrollLayer()->SetCurrentScrollOffset( 3422 host_impl_->active_tree()->InnerViewportScrollLayer()->SetCurrentScrollOffset(
3422 gfx::ScrollOffset(10, 10)); 3423 gfx::ScrollOffset(10, 10));
3423 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 3424 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
3424 animation_task_ = base::Closure(); 3425 animation_task_ = base::Closure();
(...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after
4819 inner_clip_ptr = host_impl_->InnerViewportScrollLayer() 4820 inner_clip_ptr = host_impl_->InnerViewportScrollLayer()
4820 ->test_properties() 4821 ->test_properties()
4821 ->parent->test_properties() 4822 ->parent->test_properties()
4822 ->parent; 4823 ->parent;
4823 EXPECT_EQ(0.f, host_impl_->browser_controls_manager()->ContentTopOffset()); 4824 EXPECT_EQ(0.f, host_impl_->browser_controls_manager()->ContentTopOffset());
4824 4825
4825 // The total bounds should remain unchanged since the bounds delta should 4826 // The total bounds should remain unchanged since the bounds delta should
4826 // account for the difference between the layout height and the current 4827 // account for the difference between the layout height and the current
4827 // browser controls offset. 4828 // browser controls offset.
4828 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); 4829 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds());
4829 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 50.f), inner_clip_ptr->bounds_delta()); 4830 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 50.f),
4831 inner_clip_ptr->ViewportBoundsDelta());
4830 4832
4831 host_impl_->active_tree()->SetCurrentBrowserControlsShownRatio(1.f); 4833 host_impl_->active_tree()->SetCurrentBrowserControlsShownRatio(1.f);
4832 host_impl_->DidChangeBrowserControlsPosition(); 4834 host_impl_->DidChangeBrowserControlsPosition();
4833 4835
4834 EXPECT_EQ(1.f, 4836 EXPECT_EQ(1.f,
4835 host_impl_->browser_controls_manager()->TopControlsShownRatio()); 4837 host_impl_->browser_controls_manager()->TopControlsShownRatio());
4836 EXPECT_EQ(50.f, host_impl_->browser_controls_manager()->TopControlsHeight()); 4838 EXPECT_EQ(50.f, host_impl_->browser_controls_manager()->TopControlsHeight());
4837 EXPECT_EQ(50.f, host_impl_->browser_controls_manager()->ContentTopOffset()); 4839 EXPECT_EQ(50.f, host_impl_->browser_controls_manager()->ContentTopOffset());
4838 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 0.f), inner_clip_ptr->bounds_delta()); 4840 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 0.f),
4841 inner_clip_ptr->ViewportBoundsDelta());
4839 EXPECT_EQ(gfx::Size(viewport_size_.width(), viewport_size_.height() - 50.f), 4842 EXPECT_EQ(gfx::Size(viewport_size_.width(), viewport_size_.height() - 50.f),
4840 inner_clip_ptr->bounds()); 4843 inner_clip_ptr->bounds());
4841 } 4844 }
4842 4845
4843 // Test that showing/hiding the browser controls when the viewport is fully 4846 // Test that showing/hiding the browser controls when the viewport is fully
4844 // scrolled doesn't incorrectly change the viewport offset due to clamping from 4847 // scrolled doesn't incorrectly change the viewport offset due to clamping from
4845 // changing viewport bounds. 4848 // changing viewport bounds.
4846 TEST_F(LayerTreeHostImplBrowserControlsTest, 4849 TEST_F(LayerTreeHostImplBrowserControlsTest,
4847 BrowserControlsViewportOffsetClamping) { 4850 BrowserControlsViewportOffsetClamping) {
4848 SetupBrowserControlsAndScrollLayerWithVirtualViewport( 4851 SetupBrowserControlsAndScrollLayerWithVirtualViewport(
(...skipping 7528 matching lines...) Expand 10 before | Expand all | Expand 10 after
12377 else 12380 else
12378 EXPECT_FALSE(tile->HasRasterTask()); 12381 EXPECT_FALSE(tile->HasRasterTask());
12379 } 12382 }
12380 Region expected_invalidation( 12383 Region expected_invalidation(
12381 raster_source->GetRectForImage(checkerable_image->uniqueID())); 12384 raster_source->GetRectForImage(checkerable_image->uniqueID()));
12382 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); 12385 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation()));
12383 } 12386 }
12384 12387
12385 } // namespace 12388 } // namespace
12386 } // namespace cc 12389 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698