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

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 23983047: Pinch/Zoom Infrastructure & Plumbing CL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Draft for review. Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: cc/trees/layer_tree_host_impl_unittest.cc
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 19a11f90fff9639c5c30ebdc4e8d70755c028d4e..26bb073be77926379cba31e92be104b2cc7e0183 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -210,6 +210,9 @@ class LayerTreeHostImplTest : public testing::Test,
LayerImpl* CreateScrollAndContentsLayers(LayerTreeImpl* layer_tree_impl,
gfx::Size content_size) {
+ const int INNER_VIEWPORT_SCROLL_LAYER_ID = 2;
enne (OOO) 2013/11/19 19:30:22 kInnerViewportScrollLayerId
wjmaclean 2013/12/24 21:03:49 Done.
+ const int INNER_VIEWPORT_CLIP_LAYER_ID = 4;
+ const int PAGE_SCALE_ID = 5;
scoped_ptr<LayerImpl> root =
LayerImpl::Create(layer_tree_impl, 1);
root->SetBounds(content_size);
@@ -218,12 +221,19 @@ class LayerTreeHostImplTest : public testing::Test,
root->SetAnchorPoint(gfx::PointF());
scoped_ptr<LayerImpl> scroll =
- LayerImpl::Create(layer_tree_impl, 2);
+ LayerImpl::Create(layer_tree_impl, INNER_VIEWPORT_SCROLL_LAYER_ID);
LayerImpl* scroll_layer = scroll.get();
- scroll->SetScrollable(true);
scroll->SetScrollOffset(gfx::Vector2d());
- scroll->SetMaxScrollOffset(gfx::Vector2d(content_size.width(),
- content_size.height()));
+
+ scoped_ptr<LayerImpl> clip =
+ LayerImpl::Create(layer_tree_impl, INNER_VIEWPORT_CLIP_LAYER_ID);
+ clip->SetBounds(
+ gfx::Size(content_size.width() / 2, content_size.height() / 2));
+
+ scoped_ptr<LayerImpl> page_scale =
+ LayerImpl::Create(layer_tree_impl, PAGE_SCALE_ID);
+
+ scroll->SetScrollable(clip->id());
scroll->SetBounds(content_size);
scroll->SetContentBounds(content_size);
scroll->SetPosition(gfx::PointF());
@@ -238,9 +248,14 @@ class LayerTreeHostImplTest : public testing::Test,
contents->SetAnchorPoint(gfx::PointF());
scroll->AddChild(contents.Pass());
- root->AddChild(scroll.Pass());
+ page_scale->AddChild(scroll.Pass());
+ clip->AddChild(page_scale.Pass());
+ root->AddChild(clip.Pass());
layer_tree_impl->SetRootLayer(root.Pass());
+ layer_tree_impl->SetViewportLayersFromIds(
+ PAGE_SCALE_ID, INNER_VIEWPORT_SCROLL_LAYER_ID, Layer::INVALID_ID);
+
return scroll_layer;
}
@@ -251,15 +266,19 @@ class LayerTreeHostImplTest : public testing::Test,
return scroll_layer;
}
- scoped_ptr<LayerImpl> CreateScrollableLayer(int id, gfx::Size size) {
+ // TODO(wjmaclean) Add clip-layer pointer to parameters.
+ scoped_ptr<LayerImpl> CreateScrollableLayer(int id,
+ gfx::Size size,
+ LayerImpl* clip_layer) {
+ DCHECK(clip_layer);
+ DCHECK(id != clip_layer->id());
scoped_ptr<LayerImpl> layer =
LayerImpl::Create(host_impl_->active_tree(), id);
- layer->SetScrollable(true);
+ layer->SetScrollable(clip_layer->id());
layer->SetDrawsContent(true);
layer->SetBounds(size);
layer->SetContentBounds(size);
- layer->SetMaxScrollOffset(gfx::Vector2d(size.width() * 2,
- size.height() * 2));
+ clip_layer->SetBounds(gfx::Size(size.width() / 2, size.height() / 2));
return layer.Pass();
}
@@ -441,15 +460,20 @@ TEST_F(LayerTreeHostImplTest, ScrollDeltaRepeatedScrolls) {
gfx::Vector2d scroll_offset(20, 30);
gfx::Vector2d scroll_delta(11, -15);
{
+ scoped_ptr<LayerImpl> root_clip =
+ LayerImpl::Create(host_impl_->active_tree(), 2);
scoped_ptr<LayerImpl> root =
LayerImpl::Create(host_impl_->active_tree(), 1);
- root->SetMaxScrollOffset(gfx::Vector2d(100, 100));
- root->SetScrollOffset(scroll_offset);
- root->SetScrollable(true);
- root->ScrollBy(scroll_delta);
- host_impl_->active_tree()->SetRootLayer(root.Pass());
+ root_clip->SetBounds(gfx::Size(10, 10));
+ LayerImpl* root_layer = root.get();
+ root_clip->AddChild(root.Pass());
+ root_layer->SetBounds(gfx::Size(110, 110));
+ root_layer->SetScrollable(root_clip->id());
+ root_layer->SetScrollOffset(scroll_offset);
+ root_layer->ScrollBy(scroll_delta);
+ host_impl_->active_tree()->SetRootLayer(root_clip.Pass());
}
- LayerImpl* root = host_impl_->active_tree()->root_layer();
+ LayerImpl* root = host_impl_->active_tree()->root_layer()->children()[0];
scoped_ptr<ScrollAndScaleSet> scroll_info;
@@ -743,13 +767,14 @@ TEST_F(LayerTreeHostImplTest, ScrollVerticallyByPageReturnsCorrectValue) {
20,
VERTICAL));
vertical_scrollbar->SetBounds(gfx::Size(15, 1000));
- host_impl_->RootScrollLayer()->SetVerticalScrollbarLayer(
+ host_impl_->InnerViewportScrollLayer()->AddScrollbar(
vertical_scrollbar.get());
// Trying to scroll with a vertical scrollbar will succeed.
EXPECT_TRUE(host_impl_->ScrollVerticallyByPage(
gfx::Point(), SCROLL_FORWARD));
- EXPECT_FLOAT_EQ(875.f, host_impl_->RootScrollLayer()->ScrollDelta().y());
+ EXPECT_FLOAT_EQ(875.f,
+ host_impl_->InnerViewportScrollLayer()->ScrollDelta().y());
EXPECT_TRUE(host_impl_->ScrollVerticallyByPage(
gfx::Point(), SCROLL_BACKWARD));
}
@@ -763,9 +788,9 @@ TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) {
LayerImpl* overflow = scroll_layer->children()[0];
overflow->SetBounds(overflow_size);
overflow->SetContentBounds(overflow_size);
- overflow->SetScrollable(true);
- overflow->SetMaxScrollOffset(gfx::Vector2d(overflow_size.width(),
- overflow_size.height()));
+ overflow->SetScrollable(scroll_layer->parent()->id());
+// overflow->SetMaxScrollOffset(gfx::Vector2d(overflow_size.width(),
enne (OOO) 2013/11/19 19:30:22 Remove this?
wjmaclean 2013/12/24 21:03:49 Done.
+// overflow_size.height()));
overflow->SetScrollOffset(gfx::Vector2d());
overflow->SetPosition(gfx::PointF());
overflow->SetAnchorPoint(gfx::PointF());
@@ -828,7 +853,7 @@ TEST_F(LayerTreeHostImplTest, ImplPinchZoom) {
host_impl_->SetViewportSize(gfx::Size(50, 50));
InitializeRendererAndDrawFrame();
- EXPECT_EQ(scroll_layer, host_impl_->RootScrollLayer());
+ EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer());
float min_page_scale = 1.f, max_page_scale = 4.f;
@@ -842,6 +867,7 @@ TEST_F(LayerTreeHostImplTest, ImplPinchZoom) {
float page_scale_delta = 2.f;
host_impl_->ScrollBegin(gfx::Point(50, 50), InputHandler::Gesture);
+ host_impl_->PinchGestureBegin();
host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50));
host_impl_->PinchGestureEnd();
host_impl_->ScrollEnd();
@@ -853,7 +879,7 @@ TEST_F(LayerTreeHostImplTest, ImplPinchZoom) {
EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta);
EXPECT_EQ(gfx::Vector2d(75, 75).ToString(),
- scroll_layer->max_scroll_offset().ToString());
+ scroll_layer->MaxScrollOffset().ToString());
}
// Scrolling after a pinch gesture should always be in local space. The
@@ -892,7 +918,7 @@ TEST_F(LayerTreeHostImplTest, PinchGesture) {
host_impl_->SetViewportSize(gfx::Size(50, 50));
InitializeRendererAndDrawFrame();
- LayerImpl* scroll_layer = host_impl_->RootScrollLayer();
+ LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer();
DCHECK(scroll_layer);
float min_page_scale = 1.f;
@@ -1012,7 +1038,6 @@ TEST_F(LayerTreeHostImplTest, PinchGesture) {
4.f);
scroll_layer->SetScrollDelta(gfx::Vector2d());
scroll_layer->SetScrollOffset(gfx::Vector2d(0, 0));
- host_impl_->active_tree()->UpdateMaxScrollOffset();
host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Gesture);
host_impl_->PinchGestureBegin();
@@ -1035,7 +1060,7 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimation) {
host_impl_->SetViewportSize(gfx::Size(50, 50));
InitializeRendererAndDrawFrame();
- LayerImpl* scroll_layer = host_impl_->RootScrollLayer();
+ LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer();
DCHECK(scroll_layer);
float min_page_scale = 0.5f;
@@ -1051,7 +1076,7 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimation) {
host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f,
min_page_scale,
max_page_scale);
- scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50));
+ scroll_layer->SetScrollOffset(gfx::Vector2d(10, 10));
enne (OOO) 2013/11/19 19:30:22 Why do these numbers need to change?
wjmaclean 2013/12/24 21:03:49 They don't, I guess. It's just they were set to a
host_impl_->StartPageScaleAnimation(gfx::Vector2d(), false, 2.f, duration);
did_request_redraw_ = false;
@@ -1070,7 +1095,7 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimation) {
scoped_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
EXPECT_EQ(scroll_info->page_scale_delta, 2);
- ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50));
+ ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-10, -10));
}
// Anchor zoom-out
@@ -1078,10 +1103,10 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimation) {
host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f,
min_page_scale,
max_page_scale);
- scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50));
+ scroll_layer->SetScrollOffset(gfx::Vector2d(10, 10));
host_impl_->StartPageScaleAnimation(
- gfx::Vector2d(25, 25), true, min_page_scale, duration);
+ gfx::Vector2d(5, 5), true, min_page_scale, duration);
did_request_redraw_ = false;
host_impl_->Animate(start_time, base::Time());
EXPECT_TRUE(did_request_redraw_);
@@ -1096,7 +1121,7 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimation) {
host_impl_->ProcessScrollDeltas();
EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale);
// Pushed to (0,0) via clamping against contents layer size.
- ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50));
+ ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-10, -10));
}
}
@@ -1105,7 +1130,7 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimationNoOp) {
host_impl_->SetViewportSize(gfx::Size(50, 50));
InitializeRendererAndDrawFrame();
- LayerImpl* scroll_layer = host_impl_->RootScrollLayer();
+ LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer();
DCHECK(scroll_layer);
float min_page_scale = 0.5f;
@@ -1184,10 +1209,9 @@ TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) {
scoped_ptr<LayerImpl> scroll =
LayerImpl::Create(host_impl_->active_tree(), 2);
- scroll->SetScrollable(true);
+ scroll->SetScrollable(root->id());
scroll->SetScrollOffset(gfx::Vector2d());
- scroll->SetMaxScrollOffset(gfx::Vector2d(content_size.width(),
- content_size.height()));
+ root->SetBounds(viewport_size);
scroll->SetBounds(content_size);
scroll->SetContentBounds(content_size);
@@ -1199,13 +1223,15 @@ TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) {
scoped_ptr<PaintedScrollbarLayerImpl> scrollbar =
PaintedScrollbarLayerImpl::Create(host_impl_->active_tree(), 4, VERTICAL);
- scroll->SetVerticalScrollbarLayer(scrollbar.get());
+ scrollbar->SetScrollLayerById(2);
+ scrollbar->SetClipLayerById(1);
scroll->AddChild(contents.Pass());
root->AddChild(scroll.Pass());
root->AddChild(scrollbar.PassAs<LayerImpl>());
host_impl_->active_tree()->SetRootLayer(root.Pass());
+ host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID);
host_impl_->active_tree()->DidBecomeActive();
InitializeRendererAndDrawFrame();
@@ -1256,7 +1282,7 @@ TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) {
// Setting the scroll offset outside a scroll should also cause the scrollbar
// to appear and to schedule a fade.
- host_impl_->RootScrollLayer()->SetScrollOffset(gfx::Vector2d(5, 5));
+ host_impl_->InnerViewportScrollLayer()->SetScrollOffset(gfx::Vector2d(5, 5));
host_impl_->StartScrollbarAnimation();
EXPECT_LT(base::TimeDelta::FromMilliseconds(19),
requested_scrollbar_animation_delay_);
@@ -1292,10 +1318,8 @@ void LayerTreeHostImplTest::SetupMouseMoveAtWithDeviceScale(
scoped_ptr<LayerImpl> scroll =
LayerImpl::Create(host_impl_->active_tree(), 2);
- scroll->SetScrollable(true);
+ scroll->SetScrollable(root->id());
scroll->SetScrollOffset(gfx::Vector2d());
- scroll->SetMaxScrollOffset(gfx::Vector2d(content_size.width(),
- content_size.height()));
scroll->SetBounds(content_size);
scroll->SetContentBounds(content_size);
@@ -1312,17 +1336,19 @@ void LayerTreeHostImplTest::SetupMouseMoveAtWithDeviceScale(
scrollbar->SetBounds(gfx::Size(15, viewport_size.height()));
scrollbar->SetContentBounds(gfx::Size(15, viewport_size.height()));
scrollbar->SetPosition(gfx::Point(285, 0));
- scroll->SetVerticalScrollbarLayer(scrollbar.get());
+ scrollbar->SetScrollLayerById(2);
scroll->AddChild(contents.Pass());
root->AddChild(scroll.Pass());
root->AddChild(scrollbar.PassAs<LayerImpl>());
host_impl_->active_tree()->SetRootLayer(root.Pass());
+ host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID);
host_impl_->active_tree()->DidBecomeActive();
InitializeRendererAndDrawFrame();
- LayerImpl* root_scroll = host_impl_->active_tree()->RootScrollLayer();
+ LayerImpl* root_scroll =
+ host_impl_->active_tree()->InnerViewportScrollLayer();
ASSERT_TRUE(root_scroll->scrollbar_animation_controller());
ScrollbarAnimationControllerThinning* scrollbar_animation_controller =
static_cast<ScrollbarAnimationControllerThinning*>(
@@ -1403,7 +1429,7 @@ TEST_F(LayerTreeHostImplTest, CompositorFrameMetadata) {
host_impl_->MakeCompositorFrameMetadata();
EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset);
EXPECT_EQ(2.f, metadata.page_scale_factor);
- EXPECT_EQ(gfx::SizeF(25.f, 25.f), metadata.viewport_size);
+ EXPECT_EQ(gfx::SizeF(50.f, 50.f), metadata.viewport_size);
enne (OOO) 2013/11/19 19:30:22 Why change these numbers?
wjmaclean 2013/12/24 21:03:49 Hmm, I don't think I *should* have changed these .
EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size);
EXPECT_EQ(0.5f, metadata.min_page_scale_factor);
EXPECT_EQ(4.f, metadata.max_page_scale_factor);
@@ -1418,7 +1444,7 @@ TEST_F(LayerTreeHostImplTest, CompositorFrameMetadata) {
host_impl_->MakeCompositorFrameMetadata();
EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset);
EXPECT_EQ(4.f, metadata.page_scale_factor);
- EXPECT_EQ(gfx::SizeF(12.5f, 12.5f), metadata.viewport_size);
+ EXPECT_EQ(gfx::SizeF(50.f, 50.f), metadata.viewport_size);
EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size);
EXPECT_EQ(0.5f, metadata.min_page_scale_factor);
EXPECT_EQ(4.f, metadata.max_page_scale_factor);
@@ -1770,7 +1796,7 @@ TEST_F(LayerTreeHostImplTest, PrepareToDrawFailsWhenAnimationUsesCheckerboard) {
TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) {
scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
- root->SetScrollable(false);
+ root->SetScrollable(Layer::INVALID_ID);
host_impl_->active_tree()->SetRootLayer(root.Pass());
InitializeRendererAndDrawFrame();
@@ -1791,18 +1817,23 @@ TEST_F(LayerTreeHostImplTest, ScrollNonScrollableRootWithTopControls) {
host_impl_->InitializeRenderer(CreateOutputSurface());
host_impl_->SetViewportSize(gfx::Size(10, 10));
- gfx::Size layer_size(5, 5);
+ gfx::Size layer_size(10, 10);
+ gfx::Size clip_size(5, 5);
scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
- root->SetScrollable(true);
- root->SetMaxScrollOffset(gfx::Vector2d(layer_size.width(),
- layer_size.height()));
+ scoped_ptr<LayerImpl> root_clip =
+ LayerImpl::Create(host_impl_->active_tree(), 2);
+ root_clip->SetBounds(clip_size);
+ root->SetScrollable(root_clip->id());
root->SetBounds(layer_size);
root->SetContentBounds(layer_size);
root->SetPosition(gfx::PointF());
root->SetAnchorPoint(gfx::PointF());
root->SetDrawsContent(false);
- host_impl_->active_tree()->SetRootLayer(root.Pass());
- host_impl_->active_tree()->FindRootScrollLayer();
+ int root_id = root->id();
+ root_clip->AddChild(root.Pass());
+ host_impl_->active_tree()->SetRootLayer(root_clip.Pass());
+ host_impl_->active_tree()->SetViewportLayersFromIds(
+ root_id, root_id, Layer::INVALID_ID);
InitializeRendererAndDrawFrame();
EXPECT_EQ(InputHandler::ScrollIgnored,
@@ -1822,6 +1853,7 @@ TEST_F(LayerTreeHostImplTest, ScrollNonCompositedRoot) {
// Test the configuration where a non-composited root layer is embedded in a
// scrollable outer layer.
gfx::Size surface_size(10, 10);
+ gfx::Size contents_size(20, 20);
scoped_ptr<LayerImpl> content_layer =
LayerImpl::Create(host_impl_->active_tree(), 1);
@@ -1829,22 +1861,24 @@ TEST_F(LayerTreeHostImplTest, ScrollNonCompositedRoot) {
content_layer->SetPosition(gfx::PointF());
content_layer->SetAnchorPoint(gfx::PointF());
content_layer->SetBounds(surface_size);
- content_layer->SetContentBounds(gfx::Size(surface_size.width() * 2,
- surface_size.height() * 2));
+ content_layer->SetContentBounds(contents_size);
content_layer->SetContentsScale(2.f, 2.f);
+ scoped_ptr<LayerImpl> scroll_clip_layer =
+ LayerImpl::Create(host_impl_->active_tree(), 3);
+ scroll_clip_layer->SetBounds(surface_size);
+
scoped_ptr<LayerImpl> scroll_layer =
LayerImpl::Create(host_impl_->active_tree(), 2);
- scroll_layer->SetScrollable(true);
- scroll_layer->SetMaxScrollOffset(gfx::Vector2d(surface_size.width(),
- surface_size.height()));
- scroll_layer->SetBounds(surface_size);
- scroll_layer->SetContentBounds(surface_size);
+ scroll_layer->SetScrollable(3);
+ scroll_layer->SetBounds(contents_size);
+ scroll_layer->SetContentBounds(contents_size);
scroll_layer->SetPosition(gfx::PointF());
scroll_layer->SetAnchorPoint(gfx::PointF());
scroll_layer->AddChild(content_layer.Pass());
+ scroll_clip_layer->AddChild(scroll_layer.Pass());
- host_impl_->active_tree()->SetRootLayer(scroll_layer.Pass());
+ host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass());
host_impl_->SetViewportSize(surface_size);
InitializeRendererAndDrawFrame();
@@ -1859,10 +1893,11 @@ TEST_F(LayerTreeHostImplTest, ScrollNonCompositedRoot) {
TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) {
gfx::Size surface_size(10, 10);
+ gfx::Size contents_size(20, 20);
scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
root->SetBounds(surface_size);
- root->SetContentBounds(surface_size);
- root->AddChild(CreateScrollableLayer(2, surface_size));
+ root->SetContentBounds(contents_size);
+ root->AddChild(CreateScrollableLayer(2, contents_size, root.get()));
host_impl_->active_tree()->SetRootLayer(root.Pass());
host_impl_->SetViewportSize(surface_size);
InitializeRendererAndDrawFrame();
@@ -1879,7 +1914,7 @@ TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) {
TEST_F(LayerTreeHostImplTest, ScrollMissesChild) {
gfx::Size surface_size(10, 10);
scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
- root->AddChild(CreateScrollableLayer(2, surface_size));
+ root->AddChild(CreateScrollableLayer(2, surface_size, root.get()));
host_impl_->active_tree()->SetRootLayer(root.Pass());
host_impl_->SetViewportSize(surface_size);
InitializeRendererAndDrawFrame();
@@ -1896,7 +1931,8 @@ TEST_F(LayerTreeHostImplTest, ScrollMissesChild) {
TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) {
gfx::Size surface_size(10, 10);
scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
- scoped_ptr<LayerImpl> child = CreateScrollableLayer(2, surface_size);
+ scoped_ptr<LayerImpl> child =
+ CreateScrollableLayer(2, surface_size, root.get());
host_impl_->SetViewportSize(surface_size);
gfx::Transform matrix;
@@ -1919,14 +1955,21 @@ TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) {
TEST_F(LayerTreeHostImplTest, ScrollBlockedByContentLayer) {
gfx::Size surface_size(10, 10);
- scoped_ptr<LayerImpl> content_layer = CreateScrollableLayer(1, surface_size);
+ scoped_ptr<LayerImpl> clip_layer =
+ LayerImpl::Create(host_impl_->active_tree(), 3);
+ scoped_ptr<LayerImpl> content_layer =
+ CreateScrollableLayer(1, surface_size, clip_layer.get());
content_layer->SetShouldScrollOnMainThread(true);
- content_layer->SetScrollable(false);
+ content_layer->SetScrollable(Layer::INVALID_ID);
- scoped_ptr<LayerImpl> scroll_layer = CreateScrollableLayer(2, surface_size);
+ // Note: we can use the same clip layer for both since both calls to
+ // CreateScrollableLayer() use the same surface size.
+ scoped_ptr<LayerImpl> scroll_layer =
+ CreateScrollableLayer(2, surface_size, clip_layer.get());
scroll_layer->AddChild(content_layer.Pass());
+ clip_layer->AddChild(scroll_layer.Pass());
- host_impl_->active_tree()->SetRootLayer(scroll_layer.Pass());
+ host_impl_->active_tree()->SetRootLayer(clip_layer.Pass());
host_impl_->SetViewportSize(surface_size);
InitializeRendererAndDrawFrame();
@@ -1938,21 +1981,24 @@ TEST_F(LayerTreeHostImplTest, ScrollBlockedByContentLayer) {
}
TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) {
- gfx::Size surface_size(10, 10);
+ gfx::Size surface_size(20, 20);
float page_scale = 2.f;
scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
- scoped_ptr<LayerImpl> root_scrolling = CreateScrollableLayer(2, surface_size);
+ scoped_ptr<LayerImpl> root_scrolling =
+ CreateScrollableLayer(2, surface_size, root.get());
root->AddChild(root_scrolling.Pass());
host_impl_->active_tree()->SetRootLayer(root.Pass());
+ host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID);
host_impl_->active_tree()->DidBecomeActive();
host_impl_->SetViewportSize(surface_size);
InitializeRendererAndDrawFrame();
- LayerImpl* root_scroll = host_impl_->active_tree()->RootScrollLayer();
+ LayerImpl* root_scroll =
+ host_impl_->active_tree()->InnerViewportScrollLayer();
gfx::Vector2d scroll_delta(0, 10);
gfx::Vector2d expected_scroll_delta = scroll_delta;
- gfx::Vector2d expected_max_scroll = root_scroll->max_scroll_offset();
+ gfx::Vector2d expected_max_scroll = root_scroll->MaxScrollOffset();
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(5, 5),
InputHandler::Wheel));
@@ -1968,7 +2014,7 @@ TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) {
ExpectContains(*scroll_info.get(), root_scroll->id(), expected_scroll_delta);
// The scroll range should also have been updated.
- EXPECT_EQ(expected_max_scroll, root_scroll->max_scroll_offset());
+ EXPECT_EQ(expected_max_scroll, root_scroll->MaxScrollOffset());
// The page scale delta remains constant because the impl thread did not
// scale.
@@ -1976,22 +2022,25 @@ TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) {
}
TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnImplThread) {
- gfx::Size surface_size(10, 10);
+ gfx::Size surface_size(20, 20);
float page_scale = 2.f;
scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
- scoped_ptr<LayerImpl> root_scrolling = CreateScrollableLayer(2, surface_size);
+ scoped_ptr<LayerImpl> root_scrolling =
+ CreateScrollableLayer(2, surface_size, root.get());
root->AddChild(root_scrolling.Pass());
host_impl_->active_tree()->SetRootLayer(root.Pass());
+ host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID);
host_impl_->active_tree()->DidBecomeActive();
host_impl_->SetViewportSize(surface_size);
host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, page_scale);
InitializeRendererAndDrawFrame();
- LayerImpl* root_scroll = host_impl_->active_tree()->RootScrollLayer();
+ LayerImpl* root_scroll =
+ host_impl_->active_tree()->InnerViewportScrollLayer();
gfx::Vector2d scroll_delta(0, 10);
gfx::Vector2d expected_scroll_delta = scroll_delta;
- gfx::Vector2d expected_max_scroll = root_scroll->max_scroll_offset();
+ gfx::Vector2d expected_max_scroll = root_scroll->MaxScrollOffset();
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(5, 5),
InputHandler::Wheel));
@@ -2011,7 +2060,7 @@ TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnImplThread) {
ExpectContains(*scroll_info.get(), root_scroll->id(), expected_scroll_delta);
// The scroll range should also have been updated.
- EXPECT_EQ(expected_max_scroll, root_scroll->max_scroll_offset());
+ EXPECT_EQ(expected_max_scroll, root_scroll->MaxScrollOffset());
// The page scale delta should match the new scale on the impl side.
EXPECT_EQ(page_scale, host_impl_->active_tree()->total_page_scale_factor());
@@ -2032,9 +2081,12 @@ TEST_F(LayerTreeHostImplTest, PageScaleDeltaAppliedToRootScrollLayerOnly) {
LayerImpl* root = host_impl_->active_tree()->root_layer();
LayerImpl* child = scroll->children()[0];
+ scoped_ptr<LayerImpl> scrollable_child_clip =
+ LayerImpl::Create(host_impl_->active_tree(), 6);
scoped_ptr<LayerImpl> scrollable_child =
- CreateScrollableLayer(4, surface_size);
- child->AddChild(scrollable_child.Pass());
+ CreateScrollableLayer(7, surface_size, scrollable_child_clip.get());
+ scrollable_child_clip->AddChild(scrollable_child.Pass());
+ child->AddChild(scrollable_child_clip.Pass());
LayerImpl* grand_child = child->children()[0];
// Set new page scale on impl thread by pinching.
@@ -2074,27 +2126,29 @@ TEST_F(LayerTreeHostImplTest, PageScaleDeltaAppliedToRootScrollLayerOnly) {
}
TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) {
- gfx::Size surface_size(10, 10);
+ gfx::Size surface_size(30, 30);
scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
+ root->SetBounds(gfx::Size(5, 5));
scoped_ptr<LayerImpl> root_scrolling =
LayerImpl::Create(host_impl_->active_tree(), 2);
root_scrolling->SetBounds(surface_size);
root_scrolling->SetContentBounds(surface_size);
- root_scrolling->SetScrollable(true);
+ root_scrolling->SetScrollable(root->id());
root->AddChild(root_scrolling.Pass());
int child_scroll_layer_id = 3;
scoped_ptr<LayerImpl> child_scrolling =
- CreateScrollableLayer(child_scroll_layer_id, surface_size);
+ CreateScrollableLayer(child_scroll_layer_id, surface_size, root.get());
LayerImpl* child = child_scrolling.get();
root->AddChild(child_scrolling.Pass());
host_impl_->active_tree()->SetRootLayer(root.Pass());
+ host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID);
host_impl_->active_tree()->DidBecomeActive();
host_impl_->SetViewportSize(surface_size);
InitializeRendererAndDrawFrame();
gfx::Vector2d scroll_delta(0, 10);
gfx::Vector2d expected_scroll_delta(scroll_delta);
- gfx::Vector2d expected_max_scroll(child->max_scroll_offset());
+ gfx::Vector2d expected_max_scroll(child->MaxScrollOffset());
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(5, 5),
InputHandler::Wheel));
@@ -2113,7 +2167,7 @@ TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) {
*scroll_info.get(), child_scroll_layer_id, expected_scroll_delta);
// The scroll range should not have changed.
- EXPECT_EQ(child->max_scroll_offset(), expected_max_scroll);
+ EXPECT_EQ(child->MaxScrollOffset(), expected_max_scroll);
// The page scale delta remains constant because the impl thread did not
// scale.
@@ -2125,19 +2179,27 @@ TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) {
// parent layer is scrolled on the axis on which the child was unable to
// scroll.
gfx::Size surface_size(10, 10);
- scoped_ptr<LayerImpl> root = CreateScrollableLayer(1, surface_size);
+ gfx::Size content_size(20, 20);
+ scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
+ root->SetBounds(surface_size);
- scoped_ptr<LayerImpl> grand_child = CreateScrollableLayer(3, surface_size);
- grand_child->SetScrollOffset(gfx::Vector2d(0, 5));
+ scoped_ptr<LayerImpl> grand_child =
+ CreateScrollableLayer(3, content_size, root.get());
- scoped_ptr<LayerImpl> child = CreateScrollableLayer(2, surface_size);
- child->SetScrollOffset(gfx::Vector2d(3, 0));
+ scoped_ptr<LayerImpl> child =
+ CreateScrollableLayer(2, content_size, root.get());
+ LayerImpl* grand_child_layer = grand_child.get();
child->AddChild(grand_child.Pass());
+ LayerImpl* child_layer = child.get();
root->AddChild(child.Pass());
host_impl_->active_tree()->SetRootLayer(root.Pass());
host_impl_->active_tree()->DidBecomeActive();
host_impl_->SetViewportSize(surface_size);
+
+ grand_child_layer->SetScrollOffset(gfx::Vector2d(0, 5));
+ child_layer->SetScrollOffset(gfx::Vector2d(3, 0));
+
InitializeRendererAndDrawFrame();
{
gfx::Vector2d scroll_delta(-8, -7);
@@ -2163,22 +2225,30 @@ TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) {
TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) {
// Scroll a child layer beyond its maximum scroll range and make sure the
// the scroll doesn't bubble up to the parent layer.
- gfx::Size surface_size(10, 10);
+ gfx::Size surface_size(20, 20);
scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
- scoped_ptr<LayerImpl> root_scrolling = CreateScrollableLayer(2, surface_size);
+ scoped_ptr<LayerImpl> root_scrolling =
+ CreateScrollableLayer(2, surface_size, root.get());
- scoped_ptr<LayerImpl> grand_child = CreateScrollableLayer(4, surface_size);
- grand_child->SetScrollOffset(gfx::Vector2d(0, 2));
+ scoped_ptr<LayerImpl> grand_child =
+ CreateScrollableLayer(4, surface_size, root.get());
- scoped_ptr<LayerImpl> child = CreateScrollableLayer(3, surface_size);
- child->SetScrollOffset(gfx::Vector2d(0, 3));
+ scoped_ptr<LayerImpl> child =
+ CreateScrollableLayer(3, surface_size, root.get());
+ LayerImpl* grand_child_layer = grand_child.get();
child->AddChild(grand_child.Pass());
+ LayerImpl* child_layer = child.get();
root_scrolling->AddChild(child.Pass());
root->AddChild(root_scrolling.Pass());
host_impl_->active_tree()->SetRootLayer(root.Pass());
+ host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID);
host_impl_->active_tree()->DidBecomeActive();
host_impl_->SetViewportSize(surface_size);
+
+ grand_child_layer->SetScrollOffset(gfx::Vector2d(0, 2));
+ child_layer->SetScrollOffset(gfx::Vector2d(0, 3));
+
InitializeRendererAndDrawFrame();
{
gfx::Vector2d scroll_delta(0, -10);
@@ -2256,20 +2326,28 @@ TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) {
ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 4));
}
}
-
TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) {
// When we try to scroll a non-scrollable child layer, the scroll delta
// should be applied to one of its ancestors if possible.
gfx::Size surface_size(10, 10);
gfx::Size content_size(20, 20);
- scoped_ptr<LayerImpl> root = CreateScrollableLayer(1, content_size);
- scoped_ptr<LayerImpl> child = CreateScrollableLayer(2, content_size);
+ scoped_ptr<LayerImpl> root_clip =
+ LayerImpl::Create(host_impl_->active_tree(), 3);
+ scoped_ptr<LayerImpl> root =
+ CreateScrollableLayer(1, content_size, root_clip.get());
+ // Make 'root' the clip layer for child: since they have the same sizes the
+ // child will have zero max_scroll_offset and scrolls will bubble.
+ scoped_ptr<LayerImpl> child =
+ CreateScrollableLayer(2, content_size, root.get());
+ root->SetBounds(content_size);
- child->SetScrollable(false);
+ int root_scroll_id = root->id();
root->AddChild(child.Pass());
+ root_clip->AddChild(root.Pass());
host_impl_->SetViewportSize(surface_size);
- host_impl_->active_tree()->SetRootLayer(root.Pass());
+ host_impl_->active_tree()->SetRootLayer(root_clip.Pass());
+ host_impl_->active_tree()->SetViewportLayersFromIds(3, 2, Layer::INVALID_ID);
host_impl_->active_tree()->DidBecomeActive();
InitializeRendererAndDrawFrame();
{
@@ -2283,18 +2361,21 @@ TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) {
scoped_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
- // Only the root should have scrolled.
+ // Only the root scroll should have scrolled.
ASSERT_EQ(scroll_info->scrolls.size(), 1u);
- ExpectContains(*scroll_info.get(),
- host_impl_->active_tree()->root_layer()->id(),
- scroll_delta);
+ ExpectContains(*scroll_info.get(), root_scroll_id, scroll_delta);
}
}
TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) {
gfx::Size surface_size(10, 10);
- host_impl_->active_tree()->SetRootLayer(
- CreateScrollableLayer(1, surface_size));
+ scoped_ptr<LayerImpl> root_clip =
+ LayerImpl::Create(host_impl_->active_tree(), 1);
+ scoped_ptr<LayerImpl> root_scroll =
+ CreateScrollableLayer(2, surface_size, root_clip.get());
+ root_clip->AddChild(root_scroll.Pass());
+ host_impl_->active_tree()->SetRootLayer(root_clip.Pass());
+ host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID);
host_impl_->active_tree()->DidBecomeActive();
host_impl_->SetViewportSize(surface_size);
@@ -2302,8 +2383,13 @@ TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) {
// synchronization.
InitializeRendererAndDrawFrame();
host_impl_->active_tree()->DetachLayerTree();
- host_impl_->active_tree()->SetRootLayer(
- CreateScrollableLayer(2, surface_size));
+ scoped_ptr<LayerImpl> root_clip2 =
+ LayerImpl::Create(host_impl_->active_tree(), 3);
+ scoped_ptr<LayerImpl> root_scroll2 =
+ CreateScrollableLayer(4, surface_size, root_clip2.get());
+ root_clip2->AddChild(root_scroll2.Pass());
+ host_impl_->active_tree()->SetRootLayer(root_clip2.Pass());
+ host_impl_->active_tree()->SetViewportLayersFromIds(3, 4, Layer::INVALID_ID);
host_impl_->active_tree()->DidBecomeActive();
// Scrolling should still work even though we did not draw yet.
@@ -2356,13 +2442,13 @@ TEST_F(LayerTreeHostImplTest, ScrollAxisAlignedRotatedLayer) {
TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) {
LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100));
- int child_layer_id = 4;
+ int child_layer_id = 6;
float child_layer_angle = -20.f;
// Create a child layer that is rotated to a non-axis-aligned angle.
+ LayerImpl* clip_layer = host_impl_->active_tree()->root_layer();
scoped_ptr<LayerImpl> child = CreateScrollableLayer(
- child_layer_id,
- scroll_layer->content_bounds());
+ child_layer_id, scroll_layer->content_bounds(), clip_layer);
gfx::Transform rotate_transform;
rotate_transform.Translate(-50.0, -50.0);
rotate_transform.Rotate(child_layer_angle);
@@ -2370,7 +2456,7 @@ TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) {
child->SetTransform(rotate_transform);
// Only allow vertical scrolling.
- child->SetMaxScrollOffset(gfx::Vector2d(0, child->content_bounds().height()));
+ clip_layer->SetBounds(gfx::Size(child->bounds().width(), 0));
scroll_layer->AddChild(child.Pass());
gfx::Size surface_size(50, 50);
@@ -2535,6 +2621,8 @@ TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) {
TestScrollOffsetDelegate scroll_delegate;
host_impl_->SetViewportSize(gfx::Size(10, 20));
LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100));
+ LayerImpl* clip_layer = scroll_layer->parent()->parent();
+ clip_layer->SetBounds(gfx::Size(10, 20));
// Setting the delegate results in the current scroll offset being set.
gfx::Vector2dF initial_scroll_delta(10.f, 10.f);
@@ -2658,17 +2746,25 @@ TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) {
// Scroll child layers beyond their maximum scroll range and make sure root
// overscroll does not accumulate.
gfx::Size surface_size(10, 10);
- scoped_ptr<LayerImpl> root = CreateScrollableLayer(1, surface_size);
+ scoped_ptr<LayerImpl> root_clip =
+ LayerImpl::Create(host_impl_->active_tree(), 4);
+ scoped_ptr<LayerImpl> root =
+ CreateScrollableLayer(1, surface_size, root_clip.get());
- scoped_ptr<LayerImpl> grand_child = CreateScrollableLayer(3, surface_size);
- grand_child->SetScrollOffset(gfx::Vector2d(0, 2));
+ scoped_ptr<LayerImpl> grand_child =
+ CreateScrollableLayer(3, surface_size, root_clip.get());
- scoped_ptr<LayerImpl> child = CreateScrollableLayer(2, surface_size);
- child->SetScrollOffset(gfx::Vector2d(0, 3));
+ scoped_ptr<LayerImpl> child =
+ CreateScrollableLayer(2, surface_size, root_clip.get());
+ LayerImpl* grand_child_layer = grand_child.get();
child->AddChild(grand_child.Pass());
+ LayerImpl* child_layer = child.get();
root->AddChild(child.Pass());
- host_impl_->active_tree()->SetRootLayer(root.Pass());
+ root_clip->AddChild(root.Pass());
+ child_layer->SetScrollOffset(gfx::Vector2d(0, 3));
+ grand_child_layer->SetScrollOffset(gfx::Vector2d(0, 2));
+ host_impl_->active_tree()->SetRootLayer(root_clip.Pass());
host_impl_->active_tree()->DidBecomeActive();
host_impl_->SetViewportSize(surface_size);
InitializeRendererAndDrawFrame();
@@ -2681,19 +2777,16 @@ TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) {
EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
host_impl_->ScrollEnd();
- LayerImpl* child = host_impl_->active_tree()->root_layer()->children()[0];
- LayerImpl* grand_child = child->children()[0];
-
// The next time we scroll we should only scroll the parent, but overscroll
// should still not reach the root layer.
scroll_delta = gfx::Vector2d(0, -30);
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(5, 5),
InputHandler::NonBubblingGesture));
- EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child);
+ EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer);
EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
host_impl_->ScrollBy(gfx::Point(), scroll_delta);
- EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child);
+ EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_layer);
EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
host_impl_->ScrollEnd();
@@ -2705,9 +2798,9 @@ TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) {
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(5, 5),
InputHandler::NonBubblingGesture));
- EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child);
+ EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer);
host_impl_->ScrollBy(gfx::Point(), scroll_delta);
- EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child);
+ EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer);
EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity());
host_impl_->ScrollEnd();
@@ -2720,14 +2813,20 @@ TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) {
// be reflected only when it has bubbled up to the root scrolling layer.
gfx::Size surface_size(10, 10);
gfx::Size content_size(20, 20);
- scoped_ptr<LayerImpl> root = CreateScrollableLayer(1, content_size);
- scoped_ptr<LayerImpl> child = CreateScrollableLayer(2, content_size);
+ scoped_ptr<LayerImpl> root_clip =
+ LayerImpl::Create(host_impl_->active_tree(), 3);
+ scoped_ptr<LayerImpl> root =
+ CreateScrollableLayer(1, content_size, root_clip.get());
+ scoped_ptr<LayerImpl> child =
+ CreateScrollableLayer(2, content_size, root_clip.get());
- child->SetScrollable(false);
+ child->SetScrollable(Layer::INVALID_ID);
root->AddChild(child.Pass());
+ root_clip->AddChild(root.Pass());
host_impl_->SetViewportSize(surface_size);
- host_impl_->active_tree()->SetRootLayer(root.Pass());
+ host_impl_->active_tree()->SetRootLayer(root_clip.Pass());
+ host_impl_->active_tree()->SetViewportLayersFromIds(3, 1, Layer::INVALID_ID);
host_impl_->active_tree()->DidBecomeActive();
InitializeRendererAndDrawFrame();
{
@@ -2751,7 +2850,9 @@ TEST_F(LayerTreeHostImplTest, OverscrollAlways) {
host_impl_ = LayerTreeHostImpl::Create(
settings, this, &proxy_, &stats_instrumentation_, NULL);
- SetupScrollAndContentsLayers(gfx::Size(50, 50));
+ LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(50, 50));
+ LayerImpl* clip_layer = scroll_layer->parent()->parent();
+ clip_layer->SetBounds(gfx::Size(50, 50));
host_impl_->SetViewportSize(gfx::Size(50, 50));
host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f);
InitializeRendererAndDrawFrame();
@@ -4789,8 +4890,7 @@ TEST_F(LayerTreeHostImplTest, FarAwayQuadsDontNeedAA) {
root->SetBounds(root_size);
gfx::Vector2d scroll_offset(100000, 0);
- scrolling_layer->SetScrollable(true);
- scrolling_layer->SetMaxScrollOffset(scroll_offset);
+ scrolling_layer->SetScrollable(root->id());
scrolling_layer->SetScrollOffset(scroll_offset);
host_impl_->ActivatePendingTree();
@@ -5239,13 +5339,20 @@ TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) {
// bubble).
gfx::Size surface_size(10, 10);
gfx::Size content_size(20, 20);
- scoped_ptr<LayerImpl> root = CreateScrollableLayer(1, content_size);
- scoped_ptr<LayerImpl> child = CreateScrollableLayer(2, content_size);
+ scoped_ptr<LayerImpl> root_clip =
+ LayerImpl::Create(host_impl_->active_tree(), 3);
+ scoped_ptr<LayerImpl> root =
+ CreateScrollableLayer(1, content_size, root_clip.get());
+ scoped_ptr<LayerImpl> child =
+ CreateScrollableLayer(2, content_size, root_clip.get());
root->AddChild(child.Pass());
+ int root_id = root->id();
+ root_clip->AddChild(root.Pass());
host_impl_->SetViewportSize(surface_size);
- host_impl_->active_tree()->SetRootLayer(root.Pass());
+ host_impl_->active_tree()->SetRootLayer(root_clip.Pass());
+ host_impl_->active_tree()->SetViewportLayersFromIds(3, 1, Layer::INVALID_ID);
host_impl_->active_tree()->DidBecomeActive();
InitializeRendererAndDrawFrame();
{
@@ -5267,8 +5374,7 @@ TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) {
// Only the child should have scrolled.
ASSERT_EQ(1u, scroll_info->scrolls.size());
- ExpectNone(*scroll_info.get(),
- host_impl_->active_tree()->root_layer()->id());
+ ExpectNone(*scroll_info.get(), root_id);
}
}
@@ -5278,13 +5384,21 @@ TEST_F(LayerTreeHostImplTest, TouchFlingShouldBubbleIfPrecedingScrollBubbled) {
gfx::Size surface_size(10, 10);
gfx::Size root_content_size(10, 20);
gfx::Size child_content_size(40, 40);
- scoped_ptr<LayerImpl> root = CreateScrollableLayer(1, root_content_size);
- scoped_ptr<LayerImpl> child = CreateScrollableLayer(2, child_content_size);
- root->AddChild(child.Pass());
+ scoped_ptr<LayerImpl> root_clip =
+ LayerImpl::Create(host_impl_->active_tree(), 3);
+ scoped_ptr<LayerImpl> root_scroll =
+ CreateScrollableLayer(1, root_content_size, root_clip.get());
+ int root_scroll_id = root_scroll->id();
+ scoped_ptr<LayerImpl> child =
+ CreateScrollableLayer(2, child_content_size, root_clip.get());
+ root_clip->SetBounds(surface_size);
+
+ root_scroll->AddChild(child.Pass());
+ root_clip->AddChild(root_scroll.Pass());
host_impl_->SetViewportSize(surface_size);
- host_impl_->active_tree()->SetRootLayer(root.Pass());
+ host_impl_->active_tree()->SetRootLayer(root_clip.Pass());
host_impl_->active_tree()->DidBecomeActive();
InitializeRendererAndDrawFrame();
{
@@ -5301,9 +5415,7 @@ TEST_F(LayerTreeHostImplTest, TouchFlingShouldBubbleIfPrecedingScrollBubbled) {
// The root should have (partially) scrolled.
EXPECT_EQ(2u, scroll_info->scrolls.size());
- ExpectContains(*scroll_info.get(),
- host_impl_->active_tree()->root_layer()->id(),
- gfx::Vector2d(0, 5));
+ ExpectContains(*scroll_info.get(), root_scroll_id, gfx::Vector2d(0, 5));
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->FlingScrollBegin());
@@ -5314,9 +5426,7 @@ TEST_F(LayerTreeHostImplTest, TouchFlingShouldBubbleIfPrecedingScrollBubbled) {
// The root should have (fully) scrolled from the fling.
scroll_info = host_impl_->ProcessScrollDeltas();
EXPECT_EQ(2u, scroll_info->scrolls.size());
- ExpectContains(*scroll_info.get(),
- host_impl_->active_tree()->root_layer()->id(),
- gfx::Vector2d(0, 10));
+ ExpectContains(*scroll_info.get(), root_scroll_id, gfx::Vector2d(0, 10));
}
}
@@ -5325,13 +5435,19 @@ TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) {
// bubble).
gfx::Size surface_size(10, 10);
gfx::Size content_size(20, 20);
- scoped_ptr<LayerImpl> root = CreateScrollableLayer(1, content_size);
- scoped_ptr<LayerImpl> child = CreateScrollableLayer(2, content_size);
+ scoped_ptr<LayerImpl> root_clip =
+ LayerImpl::Create(host_impl_->active_tree(), 3);
+ scoped_ptr<LayerImpl> root_scroll =
+ CreateScrollableLayer(1, content_size, root_clip.get());
+ int root_scroll_id = root_scroll->id();
+ scoped_ptr<LayerImpl> child =
+ CreateScrollableLayer(2, content_size, root_clip.get());
- root->AddChild(child.Pass());
+ root_scroll->AddChild(child.Pass());
+ root_clip->AddChild(root_scroll.Pass());
host_impl_->SetViewportSize(surface_size);
- host_impl_->active_tree()->SetRootLayer(root.Pass());
+ host_impl_->active_tree()->SetRootLayer(root_clip.Pass());
host_impl_->active_tree()->DidBecomeActive();
InitializeRendererAndDrawFrame();
{
@@ -5352,11 +5468,8 @@ TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) {
// The root should have scrolled.
ASSERT_EQ(2u, scroll_info->scrolls.size());
- ExpectContains(*scroll_info.get(),
- host_impl_->active_tree()->root_layer()->id(),
- gfx::Vector2d(0, 10));
+ ExpectContains(*scroll_info.get(), root_scroll_id, gfx::Vector2d(0, 10));
}
}
-
} // namespace
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698