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

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

Issue 2877033002: Fix cc scrollbar layer issues with initialization, and use element ids throughout. (Closed)
Patch Set: none Created 3 years, 7 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 3150 matching lines...) Expand 10 before | Expand all | Expand 10 after
3161 container->test_properties()->force_render_surface = true; 3161 container->test_properties()->force_render_surface = true;
3162 container->SetBounds(gfx::Size(10, 10)); 3162 container->SetBounds(gfx::Size(10, 10));
3163 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 3163 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
3164 3164
3165 LayerImpl* pending_scrollbar_layer = 3165 LayerImpl* pending_scrollbar_layer =
3166 host_impl_->pending_tree()->LayerById(400); 3166 host_impl_->pending_tree()->LayerById(400);
3167 pending_scrollbar_layer->SetNeedsPushProperties(); 3167 pending_scrollbar_layer->SetNeedsPushProperties();
3168 EffectNode* pending_tree_node = 3168 EffectNode* pending_tree_node =
3169 host_impl_->pending_tree()->property_trees()->effect_tree.Node( 3169 host_impl_->pending_tree()->property_trees()->effect_tree.Node(
3170 pending_scrollbar_layer->effect_tree_index()); 3170 pending_scrollbar_layer->effect_tree_index());
3171 host_impl_->pending_tree()
3172 ->property_trees()
3173 ->always_use_active_tree_opacity_effect_ids.push_back(400);
3174 if (expecting_animations) { 3171 if (expecting_animations) {
3175 EXPECT_FLOAT_EQ(1.f, active_tree_node->opacity); 3172 EXPECT_FLOAT_EQ(1.f, active_tree_node->opacity);
3176 EXPECT_FLOAT_EQ(1.f, active_scrollbar_layer->Opacity()); 3173 EXPECT_FLOAT_EQ(1.f, active_scrollbar_layer->Opacity());
3177 } else { 3174 } else {
3178 EXPECT_FLOAT_EQ(0.f, active_tree_node->opacity); 3175 EXPECT_FLOAT_EQ(0.f, active_tree_node->opacity);
3179 EXPECT_FLOAT_EQ(0.f, active_scrollbar_layer->Opacity()); 3176 EXPECT_FLOAT_EQ(0.f, active_scrollbar_layer->Opacity());
3180 } 3177 }
3181 EXPECT_FLOAT_EQ(0.f, pending_tree_node->opacity); 3178 EXPECT_FLOAT_EQ(0.f, pending_tree_node->opacity);
3182 host_impl_->ActivateSyncTree(); 3179 host_impl_->ActivateSyncTree();
3183 active_tree_node = 3180 active_tree_node =
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
3322 gfx::Size content_size(1000, 1000); 3319 gfx::Size content_size(1000, 1000);
3323 3320
3324 const int vert_1_id = 10; 3321 const int vert_1_id = 10;
3325 const int horiz_1_id = 11; 3322 const int horiz_1_id = 11;
3326 const int vert_2_id = 12; 3323 const int vert_2_id = 12;
3327 const int horiz_2_id = 13; 3324 const int horiz_2_id = 13;
3328 const int child_clip_id = 14; 3325 const int child_clip_id = 14;
3329 const int child_scroll_id = 15; 3326 const int child_scroll_id = 15;
3330 3327
3331 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); 3328 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size);
3332 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( 3329 LayerImpl* container =
3333 viewport_size); 3330 host_impl_->active_tree()->InnerViewportContainerLayer();
3331 container->SetBounds(viewport_size);
3334 LayerImpl* root_scroll = 3332 LayerImpl* root_scroll =
3335 host_impl_->active_tree()->OuterViewportScrollLayer(); 3333 host_impl_->active_tree()->OuterViewportScrollLayer();
3336 std::unique_ptr<SolidColorScrollbarLayerImpl> vert_1_scrollbar = 3334
3337 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), vert_1_id, 3335 container->test_properties()->AddChild(SolidColorScrollbarLayerImpl::Create(
3338 VERTICAL, 5, 5, true, true); 3336 host_impl_->active_tree(), vert_1_id, VERTICAL, 5, 5, true, true));
3339 std::unique_ptr<SolidColorScrollbarLayerImpl> horiz_1_scrollbar = 3337 SolidColorScrollbarLayerImpl* vert_1_scrollbar =
3340 SolidColorScrollbarLayerImpl::Create( 3338 static_cast<SolidColorScrollbarLayerImpl*>(
3341 host_impl_->active_tree(), horiz_1_id, HORIZONTAL, 5, 5, true, true); 3339 container->test_properties()->children[1]);
3342 std::unique_ptr<SolidColorScrollbarLayerImpl> vert_2_scrollbar = 3340
3343 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), vert_2_id, 3341 container->test_properties()->AddChild(SolidColorScrollbarLayerImpl::Create(
3344 VERTICAL, 5, 5, true, true); 3342 host_impl_->active_tree(), horiz_1_id, HORIZONTAL, 5, 5, true, true));
3345 std::unique_ptr<SolidColorScrollbarLayerImpl> horiz_2_scrollbar = 3343 SolidColorScrollbarLayerImpl* horiz_1_scrollbar =
3346 SolidColorScrollbarLayerImpl::Create( 3344 static_cast<SolidColorScrollbarLayerImpl*>(
3347 host_impl_->active_tree(), horiz_2_id, HORIZONTAL, 5, 5, true, true); 3345 container->test_properties()->children[2]);
3346
3347 container->test_properties()->AddChild(SolidColorScrollbarLayerImpl::Create(
3348 host_impl_->active_tree(), vert_2_id, VERTICAL, 5, 5, true, true));
3349 SolidColorScrollbarLayerImpl* vert_2_scrollbar =
3350 static_cast<SolidColorScrollbarLayerImpl*>(
3351 container->test_properties()->children[3]);
3352
3353 container->test_properties()->AddChild(SolidColorScrollbarLayerImpl::Create(
3354 host_impl_->active_tree(), horiz_2_id, HORIZONTAL, 5, 5, true, true));
3355 SolidColorScrollbarLayerImpl* horiz_2_scrollbar =
3356 static_cast<SolidColorScrollbarLayerImpl*>(
3357 container->test_properties()->children[4]);
3358
3348 std::unique_ptr<LayerImpl> child = 3359 std::unique_ptr<LayerImpl> child =
3349 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id); 3360 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id);
3350 child->SetBounds(content_size); 3361 child->SetBounds(content_size);
3351 std::unique_ptr<LayerImpl> child_clip = 3362 std::unique_ptr<LayerImpl> child_clip =
3352 LayerImpl::Create(host_impl_->active_tree(), child_clip_id); 3363 LayerImpl::Create(host_impl_->active_tree(), child_clip_id);
3353 child->SetBounds(viewport_size); 3364 child->SetBounds(viewport_size);
3354 LayerImpl* child_ptr = child.get(); 3365 LayerImpl* child_ptr = child.get();
3355 LayerImpl* child_clip_ptr = child_clip.get(); 3366 LayerImpl* child_clip_ptr = child_clip.get();
3356 3367
3368 host_impl_->active_tree()->BuildPropertyTreesForTesting();
3369
3357 // Check scrollbar registration on the viewport layers. 3370 // Check scrollbar registration on the viewport layers.
3358 EXPECT_EQ(0ul, host_impl_->ScrollbarsFor(root_scroll->element_id()).size()); 3371 EXPECT_EQ(0ul, host_impl_->ScrollbarsFor(root_scroll->element_id()).size());
3359 EXPECT_EQ(nullptr, host_impl_->ScrollbarAnimationControllerForElementId( 3372 EXPECT_EQ(nullptr, host_impl_->ScrollbarAnimationControllerForElementId(
3360 root_scroll->element_id())); 3373 root_scroll->element_id()));
3361 vert_1_scrollbar->SetScrollElementId(root_scroll->element_id()); 3374 vert_1_scrollbar->SetScrollElementId(root_scroll->element_id());
3362 EXPECT_EQ(1ul, host_impl_->ScrollbarsFor(root_scroll->element_id()).size()); 3375 EXPECT_EQ(1ul, host_impl_->ScrollbarsFor(root_scroll->element_id()).size());
3363 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForElementId( 3376 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForElementId(
3364 root_scroll->element_id())); 3377 root_scroll->element_id()));
3365 horiz_1_scrollbar->SetScrollElementId(root_scroll->element_id()); 3378 horiz_1_scrollbar->SetScrollElementId(root_scroll->element_id());
3366 EXPECT_EQ(2ul, host_impl_->ScrollbarsFor(root_scroll->element_id()).size()); 3379 EXPECT_EQ(2ul, host_impl_->ScrollbarsFor(root_scroll->element_id()).size());
(...skipping 29 matching lines...) Expand all
3396 // Changing one of the child layers should result in a scrollbar animation 3409 // Changing one of the child layers should result in a scrollbar animation
3397 // update. 3410 // update.
3398 animation_task_ = base::Closure(); 3411 animation_task_ = base::Closure();
3399 child_clip_ptr->SetBounds(gfx::Size(200, 200)); 3412 child_clip_ptr->SetBounds(gfx::Size(200, 200));
3400 child_ptr->set_needs_show_scrollbars(true); 3413 child_ptr->set_needs_show_scrollbars(true);
3401 host_impl_->active_tree()->HandleScrollbarShowRequestsFromMain(); 3414 host_impl_->active_tree()->HandleScrollbarShowRequestsFromMain();
3402 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 3415 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
3403 animation_task_ = base::Closure(); 3416 animation_task_ = base::Closure();
3404 3417
3405 // Check scrollbar unregistration. 3418 // Check scrollbar unregistration.
3406 vert_1_scrollbar.reset(); 3419 container->test_properties()->RemoveChild(vert_1_scrollbar);
3407 EXPECT_EQ(1ul, host_impl_->ScrollbarsFor(root_scroll->element_id()).size()); 3420 EXPECT_EQ(1ul, host_impl_->ScrollbarsFor(root_scroll->element_id()).size());
3408 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForElementId( 3421 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForElementId(
3409 root_scroll->element_id())); 3422 root_scroll->element_id()));
3410 horiz_1_scrollbar.reset(); 3423 container->test_properties()->RemoveChild(horiz_1_scrollbar);
3411 EXPECT_EQ(0ul, host_impl_->ScrollbarsFor(root_scroll->element_id()).size()); 3424 EXPECT_EQ(0ul, host_impl_->ScrollbarsFor(root_scroll->element_id()).size());
3412 EXPECT_EQ(nullptr, host_impl_->ScrollbarAnimationControllerForElementId( 3425 EXPECT_EQ(nullptr, host_impl_->ScrollbarAnimationControllerForElementId(
3413 root_scroll->element_id())); 3426 root_scroll->element_id()));
3414 3427
3415 EXPECT_EQ(2ul, host_impl_->ScrollbarsFor(child_scroll_element_id).size()); 3428 EXPECT_EQ(2ul, host_impl_->ScrollbarsFor(child_scroll_element_id).size());
3416 vert_2_scrollbar.reset(); 3429 container->test_properties()->RemoveChild(vert_2_scrollbar);
3417 EXPECT_EQ(1ul, host_impl_->ScrollbarsFor(child_scroll_element_id).size()); 3430 EXPECT_EQ(1ul, host_impl_->ScrollbarsFor(child_scroll_element_id).size());
3418 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForElementId( 3431 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForElementId(
3419 child_scroll_element_id)); 3432 child_scroll_element_id));
3420 horiz_2_scrollbar.reset(); 3433 container->test_properties()->RemoveChild(horiz_2_scrollbar);
3421 EXPECT_EQ(0ul, host_impl_->ScrollbarsFor(child_scroll_element_id).size()); 3434 EXPECT_EQ(0ul, host_impl_->ScrollbarsFor(child_scroll_element_id).size());
3422 EXPECT_EQ(nullptr, host_impl_->ScrollbarAnimationControllerForElementId( 3435 EXPECT_EQ(nullptr, host_impl_->ScrollbarAnimationControllerForElementId(
3423 root_scroll->element_id())); 3436 root_scroll->element_id()));
3424 3437
3425 // Changing scroll offset should no longer trigger any animation. 3438 // Changing scroll offset should no longer trigger any animation.
3426 host_impl_->active_tree()->InnerViewportScrollLayer()->SetCurrentScrollOffset( 3439 host_impl_->active_tree()->InnerViewportScrollLayer()->SetCurrentScrollOffset(
3427 gfx::ScrollOffset(20, 20)); 3440 gfx::ScrollOffset(20, 20));
3428 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 3441 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
3429 child_ptr->SetCurrentScrollOffset(gfx::ScrollOffset(20, 20)); 3442 child_ptr->SetCurrentScrollOffset(gfx::ScrollOffset(20, 20));
3430 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 3443 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
(...skipping 8939 matching lines...) Expand 10 before | Expand all | Expand 10 after
12370 else 12383 else
12371 EXPECT_FALSE(tile->HasRasterTask()); 12384 EXPECT_FALSE(tile->HasRasterTask());
12372 } 12385 }
12373 Region expected_invalidation( 12386 Region expected_invalidation(
12374 raster_source->GetRectForImage(checkerable_image->uniqueID())); 12387 raster_source->GetRectForImage(checkerable_image->uniqueID()));
12375 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); 12388 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation()));
12376 } 12389 }
12377 12390
12378 } // namespace 12391 } // namespace
12379 } // namespace cc 12392 } // 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