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

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

Issue 2824693002: Refactor LayerTreeImpl's scrollbar map to be keyed on element ids (Closed)
Patch Set: rebase 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_host_unittest_damage.cc » ('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 3316 matching lines...) Expand 10 before | Expand all | Expand 10 after
3327 std::unique_ptr<LayerImpl> child = 3327 std::unique_ptr<LayerImpl> child =
3328 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id); 3328 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id);
3329 child->SetBounds(content_size); 3329 child->SetBounds(content_size);
3330 std::unique_ptr<LayerImpl> child_clip = 3330 std::unique_ptr<LayerImpl> child_clip =
3331 LayerImpl::Create(host_impl_->active_tree(), child_clip_id); 3331 LayerImpl::Create(host_impl_->active_tree(), child_clip_id);
3332 child->SetBounds(viewport_size); 3332 child->SetBounds(viewport_size);
3333 LayerImpl* child_ptr = child.get(); 3333 LayerImpl* child_ptr = child.get();
3334 LayerImpl* child_clip_ptr = child_clip.get(); 3334 LayerImpl* child_clip_ptr = child_clip.get();
3335 3335
3336 // Check scrollbar registration on the viewport layers. 3336 // Check scrollbar registration on the viewport layers.
3337 EXPECT_EQ(0ul, host_impl_->ScrollbarsFor(root_scroll->id()).size()); 3337 EXPECT_EQ(0ul, host_impl_->ScrollbarsFor(root_scroll->element_id()).size());
3338 EXPECT_EQ(nullptr, host_impl_->ScrollbarAnimationControllerForElementId( 3338 EXPECT_EQ(nullptr, host_impl_->ScrollbarAnimationControllerForElementId(
3339 root_scroll->element_id())); 3339 root_scroll->element_id()));
3340 vert_1_scrollbar->SetScrollInfo(root_scroll->id(), root_scroll->element_id()); 3340 vert_1_scrollbar->SetScrollInfo(root_scroll->id(), root_scroll->element_id());
3341 EXPECT_EQ(1ul, host_impl_->ScrollbarsFor(root_scroll->id()).size()); 3341 EXPECT_EQ(1ul, host_impl_->ScrollbarsFor(root_scroll->element_id()).size());
3342 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForElementId( 3342 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForElementId(
3343 root_scroll->element_id())); 3343 root_scroll->element_id()));
3344 horiz_1_scrollbar->SetScrollInfo(root_scroll->id(), 3344 horiz_1_scrollbar->SetScrollInfo(root_scroll->id(),
3345 root_scroll->element_id()); 3345 root_scroll->element_id());
3346 EXPECT_EQ(2ul, host_impl_->ScrollbarsFor(root_scroll->id()).size()); 3346 EXPECT_EQ(2ul, host_impl_->ScrollbarsFor(root_scroll->element_id()).size());
3347 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForElementId( 3347 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForElementId(
3348 root_scroll->element_id())); 3348 root_scroll->element_id()));
3349 3349
3350 // Changing one of the viewport layers should result in a scrollbar animation 3350 // Changing one of the viewport layers should result in a scrollbar animation
3351 // update. 3351 // update.
3352 animation_task_ = base::Closure(); 3352 animation_task_ = base::Closure();
3353 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBoundsDelta( 3353 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBoundsDelta(
3354 gfx::Vector2dF(10, 10)); 3354 gfx::Vector2dF(10, 10));
3355 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 3355 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
3356 animation_task_ = base::Closure(); 3356 animation_task_ = base::Closure();
3357 host_impl_->active_tree()->OuterViewportScrollLayer()->SetCurrentScrollOffset( 3357 host_impl_->active_tree()->OuterViewportScrollLayer()->SetCurrentScrollOffset(
3358 gfx::ScrollOffset(10, 10)); 3358 gfx::ScrollOffset(10, 10));
3359 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 3359 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
3360 animation_task_ = base::Closure(); 3360 animation_task_ = base::Closure();
3361 host_impl_->active_tree()->InnerViewportScrollLayer()->SetCurrentScrollOffset( 3361 host_impl_->active_tree()->InnerViewportScrollLayer()->SetCurrentScrollOffset(
3362 gfx::ScrollOffset(10, 10)); 3362 gfx::ScrollOffset(10, 10));
3363 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 3363 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
3364 animation_task_ = base::Closure(); 3364 animation_task_ = base::Closure();
3365 3365
3366 // Check scrollbar registration on a sublayer. 3366 // Check scrollbar registration on a sublayer.
3367 child->SetScrollClipLayer(child_clip->id()); 3367 child->SetScrollClipLayer(child_clip->id());
3368 child->SetElementId(LayerIdToElementIdForTesting(child->id())); 3368 child->SetElementId(LayerIdToElementIdForTesting(child->id()));
3369 ElementId child_scroll_element_id = child->element_id(); 3369 ElementId child_scroll_element_id = child->element_id();
3370 child_clip->test_properties()->AddChild(std::move(child)); 3370 child_clip->test_properties()->AddChild(std::move(child));
3371 root_scroll->test_properties()->AddChild(std::move(child_clip)); 3371 root_scroll->test_properties()->AddChild(std::move(child_clip));
3372 EXPECT_EQ(0ul, host_impl_->ScrollbarsFor(child_scroll_id).size()); 3372 EXPECT_EQ(0ul, host_impl_->ScrollbarsFor(child_scroll_element_id).size());
3373 EXPECT_EQ(nullptr, host_impl_->ScrollbarAnimationControllerForElementId( 3373 EXPECT_EQ(nullptr, host_impl_->ScrollbarAnimationControllerForElementId(
3374 child_scroll_element_id)); 3374 child_scroll_element_id));
3375 vert_2_scrollbar->SetScrollInfo(child_scroll_id, child_scroll_element_id); 3375 vert_2_scrollbar->SetScrollInfo(child_scroll_id, child_scroll_element_id);
3376 EXPECT_EQ(1ul, host_impl_->ScrollbarsFor(child_scroll_id).size()); 3376 EXPECT_EQ(1ul, host_impl_->ScrollbarsFor(child_scroll_element_id).size());
3377 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForElementId( 3377 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForElementId(
3378 child_scroll_element_id)); 3378 child_scroll_element_id));
3379 horiz_2_scrollbar->SetScrollInfo(child_scroll_id, child_scroll_element_id); 3379 horiz_2_scrollbar->SetScrollInfo(child_scroll_id, child_scroll_element_id);
3380 EXPECT_EQ(2ul, host_impl_->ScrollbarsFor(child_scroll_id).size()); 3380 EXPECT_EQ(2ul, host_impl_->ScrollbarsFor(child_scroll_element_id).size());
3381 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForElementId( 3381 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForElementId(
3382 child_scroll_element_id)); 3382 child_scroll_element_id));
3383 3383
3384 // Changing one of the child layers should result in a scrollbar animation 3384 // Changing one of the child layers should result in a scrollbar animation
3385 // update. 3385 // update.
3386 animation_task_ = base::Closure(); 3386 animation_task_ = base::Closure();
3387 child_clip_ptr->SetBounds(gfx::Size(200, 200)); 3387 child_clip_ptr->SetBounds(gfx::Size(200, 200));
3388 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 3388 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
3389 animation_task_ = base::Closure(); 3389 animation_task_ = base::Closure();
3390 child_ptr->SetCurrentScrollOffset(gfx::ScrollOffset(10, 10)); 3390 child_ptr->SetCurrentScrollOffset(gfx::ScrollOffset(10, 10));
3391 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 3391 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
3392 animation_task_ = base::Closure(); 3392 animation_task_ = base::Closure();
3393 3393
3394 // Check scrollbar unregistration. 3394 // Check scrollbar unregistration.
3395 vert_1_scrollbar.reset(); 3395 vert_1_scrollbar.reset();
3396 EXPECT_EQ(1ul, host_impl_->ScrollbarsFor(root_scroll->id()).size()); 3396 EXPECT_EQ(1ul, host_impl_->ScrollbarsFor(root_scroll->element_id()).size());
3397 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForElementId( 3397 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForElementId(
3398 root_scroll->element_id())); 3398 root_scroll->element_id()));
3399 horiz_1_scrollbar.reset(); 3399 horiz_1_scrollbar.reset();
3400 EXPECT_EQ(0ul, host_impl_->ScrollbarsFor(root_scroll->id()).size()); 3400 EXPECT_EQ(0ul, host_impl_->ScrollbarsFor(root_scroll->element_id()).size());
3401 EXPECT_EQ(nullptr, host_impl_->ScrollbarAnimationControllerForElementId( 3401 EXPECT_EQ(nullptr, host_impl_->ScrollbarAnimationControllerForElementId(
3402 root_scroll->element_id())); 3402 root_scroll->element_id()));
3403 3403
3404 EXPECT_EQ(2ul, host_impl_->ScrollbarsFor(child_scroll_id).size()); 3404 EXPECT_EQ(2ul, host_impl_->ScrollbarsFor(child_scroll_element_id).size());
3405 vert_2_scrollbar.reset(); 3405 vert_2_scrollbar.reset();
3406 EXPECT_EQ(1ul, host_impl_->ScrollbarsFor(child_scroll_id).size()); 3406 EXPECT_EQ(1ul, host_impl_->ScrollbarsFor(child_scroll_element_id).size());
3407 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForElementId( 3407 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForElementId(
3408 child_scroll_element_id)); 3408 child_scroll_element_id));
3409 horiz_2_scrollbar.reset(); 3409 horiz_2_scrollbar.reset();
3410 EXPECT_EQ(0ul, host_impl_->ScrollbarsFor(child_scroll_id).size()); 3410 EXPECT_EQ(0ul, host_impl_->ScrollbarsFor(child_scroll_element_id).size());
3411 EXPECT_EQ(nullptr, host_impl_->ScrollbarAnimationControllerForElementId( 3411 EXPECT_EQ(nullptr, host_impl_->ScrollbarAnimationControllerForElementId(
3412 root_scroll->element_id())); 3412 root_scroll->element_id()));
3413 3413
3414 // Changing scroll offset should no longer trigger any animation. 3414 // Changing scroll offset should no longer trigger any animation.
3415 host_impl_->active_tree()->InnerViewportScrollLayer()->SetCurrentScrollOffset( 3415 host_impl_->active_tree()->InnerViewportScrollLayer()->SetCurrentScrollOffset(
3416 gfx::ScrollOffset(20, 20)); 3416 gfx::ScrollOffset(20, 20));
3417 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 3417 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
3418 child_ptr->SetCurrentScrollOffset(gfx::ScrollOffset(20, 20)); 3418 child_ptr->SetCurrentScrollOffset(gfx::ScrollOffset(20, 20));
3419 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 3419 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
3420 } 3420 }
(...skipping 8896 matching lines...) Expand 10 before | Expand all | Expand 10 after
12317 else 12317 else
12318 EXPECT_FALSE(tile->HasRasterTask()); 12318 EXPECT_FALSE(tile->HasRasterTask());
12319 } 12319 }
12320 Region expected_invalidation( 12320 Region expected_invalidation(
12321 raster_source->GetRectForImage(checkerable_image->uniqueID())); 12321 raster_source->GetRectForImage(checkerable_image->uniqueID()));
12322 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); 12322 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation()));
12323 } 12323 }
12324 12324
12325 } // namespace 12325 } // namespace
12326 } // namespace cc 12326 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_damage.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698