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

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: Document ViewportBoundsDelta better 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 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 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after
4818 inner_clip_ptr = host_impl_->InnerViewportScrollLayer() 4819 inner_clip_ptr = host_impl_->InnerViewportScrollLayer()
4819 ->test_properties() 4820 ->test_properties()
4820 ->parent->test_properties() 4821 ->parent->test_properties()
4821 ->parent; 4822 ->parent;
4822 EXPECT_EQ(0.f, host_impl_->browser_controls_manager()->ContentTopOffset()); 4823 EXPECT_EQ(0.f, host_impl_->browser_controls_manager()->ContentTopOffset());
4823 4824
4824 // The total bounds should remain unchanged since the bounds delta should 4825 // The total bounds should remain unchanged since the bounds delta should
4825 // account for the difference between the layout height and the current 4826 // account for the difference between the layout height and the current
4826 // browser controls offset. 4827 // browser controls offset.
4827 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); 4828 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds());
4828 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 50.f), inner_clip_ptr->bounds_delta()); 4829 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 50.f),
4830 inner_clip_ptr->ViewportBoundsDelta());
4829 4831
4830 host_impl_->active_tree()->SetCurrentBrowserControlsShownRatio(1.f); 4832 host_impl_->active_tree()->SetCurrentBrowserControlsShownRatio(1.f);
4831 host_impl_->DidChangeBrowserControlsPosition(); 4833 host_impl_->DidChangeBrowserControlsPosition();
4832 4834
4833 EXPECT_EQ(1.f, 4835 EXPECT_EQ(1.f,
4834 host_impl_->browser_controls_manager()->TopControlsShownRatio()); 4836 host_impl_->browser_controls_manager()->TopControlsShownRatio());
4835 EXPECT_EQ(50.f, host_impl_->browser_controls_manager()->TopControlsHeight()); 4837 EXPECT_EQ(50.f, host_impl_->browser_controls_manager()->TopControlsHeight());
4836 EXPECT_EQ(50.f, host_impl_->browser_controls_manager()->ContentTopOffset()); 4838 EXPECT_EQ(50.f, host_impl_->browser_controls_manager()->ContentTopOffset());
4837 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 0.f), inner_clip_ptr->bounds_delta()); 4839 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 0.f),
4840 inner_clip_ptr->ViewportBoundsDelta());
4838 EXPECT_EQ(gfx::Size(viewport_size_.width(), viewport_size_.height() - 50.f), 4841 EXPECT_EQ(gfx::Size(viewport_size_.width(), viewport_size_.height() - 50.f),
4839 inner_clip_ptr->bounds()); 4842 inner_clip_ptr->bounds());
4840 } 4843 }
4841 4844
4842 // Test that showing/hiding the browser controls when the viewport is fully 4845 // Test that showing/hiding the browser controls when the viewport is fully
4843 // scrolled doesn't incorrectly change the viewport offset due to clamping from 4846 // scrolled doesn't incorrectly change the viewport offset due to clamping from
4844 // changing viewport bounds. 4847 // changing viewport bounds.
4845 TEST_F(LayerTreeHostImplBrowserControlsTest, 4848 TEST_F(LayerTreeHostImplBrowserControlsTest,
4846 BrowserControlsViewportOffsetClamping) { 4849 BrowserControlsViewportOffsetClamping) {
4847 SetupBrowserControlsAndScrollLayerWithVirtualViewport( 4850 SetupBrowserControlsAndScrollLayerWithVirtualViewport(
(...skipping 7527 matching lines...) Expand 10 before | Expand all | Expand 10 after
12375 else 12378 else
12376 EXPECT_FALSE(tile->HasRasterTask()); 12379 EXPECT_FALSE(tile->HasRasterTask());
12377 } 12380 }
12378 Region expected_invalidation( 12381 Region expected_invalidation(
12379 raster_source->GetRectForImage(checkerable_image->uniqueID())); 12382 raster_source->GetRectForImage(checkerable_image->uniqueID()));
12380 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); 12383 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation()));
12381 } 12384 }
12382 12385
12383 } // namespace 12386 } // namespace
12384 } // namespace cc 12387 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698