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

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

Issue 2729253003: Make LayerTreeImpl::SetCurrentlyScrollingNode use element ids over layer ids (Closed)
Patch Set: Created 3 years, 9 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 scroll_amount_(2, -1), 563 scroll_amount_(2, -1),
564 num_scrolls_(0) {} 564 num_scrolls_(0) {}
565 565
566 void SetupTree() override { 566 void SetupTree() override {
567 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_); 567 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_);
568 568
569 scoped_refptr<Layer> root_layer = Layer::Create(); 569 scoped_refptr<Layer> root_layer = Layer::Create();
570 root_layer->SetBounds(gfx::Size(10, 10)); 570 root_layer->SetBounds(gfx::Size(10, 10));
571 571
572 root_scroll_layer_ = FakePictureLayer::Create(&fake_content_layer_client_); 572 root_scroll_layer_ = FakePictureLayer::Create(&fake_content_layer_client_);
573 root_scroll_layer_->SetElementId(
574 LayerIdToElementIdForTesting(root_scroll_layer_->id()));
573 root_scroll_layer_->SetBounds(gfx::Size(110, 110)); 575 root_scroll_layer_->SetBounds(gfx::Size(110, 110));
574 root_scroll_layer_->SetPosition(gfx::PointF()); 576 root_scroll_layer_->SetPosition(gfx::PointF());
575 root_scroll_layer_->SetIsDrawable(true); 577 root_scroll_layer_->SetIsDrawable(true);
576 578
577 CreateVirtualViewportLayers(root_layer.get(), root_scroll_layer_, 579 CreateVirtualViewportLayers(root_layer.get(), root_scroll_layer_,
578 root_layer->bounds(), root_layer->bounds(), 580 root_layer->bounds(), root_layer->bounds(),
579 layer_tree_host()); 581 layer_tree_host());
580 582
581 child_layer_ = FakePictureLayer::Create(&fake_content_layer_client_); 583 child_layer_ = FakePictureLayer::Create(&fake_content_layer_client_);
582 child_layer_->set_did_scroll_callback( 584 child_layer_->set_did_scroll_callback(
583 base::Bind(&LayerTreeHostScrollTestCaseWithChild::DidScroll, 585 base::Bind(&LayerTreeHostScrollTestCaseWithChild::DidScroll,
584 base::Unretained(this))); 586 base::Unretained(this)));
587 child_layer_->SetElementId(
588 LayerIdToElementIdForTesting(child_layer_->id()));
585 child_layer_->SetBounds(gfx::Size(110, 110)); 589 child_layer_->SetBounds(gfx::Size(110, 110));
586 590
587 if (scroll_child_layer_) { 591 if (scroll_child_layer_) {
588 // Scrolls on the child layer will happen at 5, 5. If they are treated 592 // Scrolls on the child layer will happen at 5, 5. If they are treated
589 // like device pixels, and device scale factor is 2, then they will 593 // like device pixels, and device scale factor is 2, then they will
590 // be considered at 2.5, 2.5 in logical pixels, and will miss this layer. 594 // be considered at 2.5, 2.5 in logical pixels, and will miss this layer.
591 child_layer_->SetPosition(gfx::PointF(5.f, 5.f)); 595 child_layer_->SetPosition(gfx::PointF(5.f, 5.f));
592 } else { 596 } else {
593 // Adjust the child layer horizontally so that scrolls will never hit it. 597 // Adjust the child layer horizontally so that scrolls will never hit it.
594 child_layer_->SetPosition(gfx::PointF(60.f, 5.f)); 598 child_layer_->SetPosition(gfx::PointF(60.f, 5.f));
595 } 599 }
596 600
597 scoped_refptr<Layer> outer_container_layer = 601 scoped_refptr<Layer> outer_container_layer =
598 layer_tree_host()->outer_viewport_scroll_layer()->parent(); 602 layer_tree_host()->outer_viewport_scroll_layer()->parent();
599 603
600 child_layer_->SetIsDrawable(true); 604 child_layer_->SetIsDrawable(true);
601 child_layer_->SetScrollClipLayerId(outer_container_layer->id()); 605 child_layer_->SetScrollClipLayerId(outer_container_layer->id());
606 child_layer_->SetElementId(
607 LayerIdToElementIdForTesting(child_layer_->id()));
602 child_layer_->SetBounds(root_scroll_layer_->bounds()); 608 child_layer_->SetBounds(root_scroll_layer_->bounds());
603 root_scroll_layer_->AddChild(child_layer_); 609 root_scroll_layer_->AddChild(child_layer_);
604 610
605 if (scroll_child_layer_) { 611 if (scroll_child_layer_) {
606 expected_scroll_layer_ = child_layer_; 612 expected_scroll_layer_ = child_layer_;
607 expected_no_scroll_layer_ = root_scroll_layer_; 613 expected_no_scroll_layer_ = root_scroll_layer_;
608 } else { 614 } else {
609 expected_scroll_layer_ = root_scroll_layer_; 615 expected_scroll_layer_ = root_scroll_layer_;
610 expected_no_scroll_layer_ = child_layer_; 616 expected_no_scroll_layer_ = child_layer_;
611 } 617 }
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 Layer* layer_; 1434 Layer* layer_;
1429 }; 1435 };
1430 1436
1431 Layer* CreateScrollLayer(Layer* parent, FakeLayerScrollClient* client) { 1437 Layer* CreateScrollLayer(Layer* parent, FakeLayerScrollClient* client) {
1432 scoped_refptr<PictureLayer> scroll_layer = 1438 scoped_refptr<PictureLayer> scroll_layer =
1433 PictureLayer::Create(&fake_content_layer_client_); 1439 PictureLayer::Create(&fake_content_layer_client_);
1434 scroll_layer->SetBounds(gfx::Size(110, 110)); 1440 scroll_layer->SetBounds(gfx::Size(110, 110));
1435 scroll_layer->SetPosition(gfx::PointF()); 1441 scroll_layer->SetPosition(gfx::PointF());
1436 scroll_layer->SetIsDrawable(true); 1442 scroll_layer->SetIsDrawable(true);
1437 scroll_layer->SetScrollClipLayerId(parent->id()); 1443 scroll_layer->SetScrollClipLayerId(parent->id());
1444 scroll_layer->SetElementId(
1445 LayerIdToElementIdForTesting(scroll_layer->id()));
1438 scroll_layer->SetBounds(gfx::Size(parent->bounds().width() + 100, 1446 scroll_layer->SetBounds(gfx::Size(parent->bounds().width() + 100,
1439 parent->bounds().height() + 100)); 1447 parent->bounds().height() + 100));
1440 scroll_layer->set_did_scroll_callback(base::Bind( 1448 scroll_layer->set_did_scroll_callback(base::Bind(
1441 &FakeLayerScrollClient::DidScroll, base::Unretained(client))); 1449 &FakeLayerScrollClient::DidScroll, base::Unretained(client)));
1442 client->owner_ = this; 1450 client->owner_ = this;
1443 client->layer_ = scroll_layer.get(); 1451 client->layer_ = scroll_layer.get();
1444 parent->AddChild(scroll_layer); 1452 parent->AddChild(scroll_layer);
1445 return scroll_layer.get(); 1453 return scroll_layer.get();
1446 } 1454 }
1447 1455
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
2246 CompletionEvent* impl_side_invalidation_event_ = nullptr; 2254 CompletionEvent* impl_side_invalidation_event_ = nullptr;
2247 2255
2248 // Main thread. 2256 // Main thread.
2249 int num_of_deltas_ = 0; 2257 int num_of_deltas_ = 0;
2250 }; 2258 };
2251 2259
2252 MULTI_THREAD_TEST_F(MAYBE_LayerTreeHostScrollTestImplSideInvalidation); 2260 MULTI_THREAD_TEST_F(MAYBE_LayerTreeHostScrollTestImplSideInvalidation);
2253 2261
2254 } // namespace 2262 } // namespace
2255 } // namespace cc 2263 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698