| 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 d38f65e5c7ed62f7f47179f1614d15bf740f1696..37beda620eedd51d650a68e1420c85fd6dfc6687 100644
|
| --- a/cc/trees/layer_tree_host_impl_unittest.cc
|
| +++ b/cc/trees/layer_tree_host_impl_unittest.cc
|
| @@ -206,6 +206,9 @@ class LayerTreeHostImplTest : public testing::Test,
|
|
|
| LayerImpl* CreateScrollAndContentsLayers(LayerTreeImpl* layer_tree_impl,
|
| gfx::Size content_size) {
|
| + const int INNER_VIEWPORT_SCROLL_LAYER_ID = 2;
|
| + 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);
|
| @@ -214,12 +217,21 @@ 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);
|
| + // TODO(wjmaclean) Check that this new value of MaxScrollOffset doesn't
|
| + // throw off the rest of the tests.
|
| + 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());
|
| @@ -234,9 +246,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;
|
| }
|
|
|
| @@ -247,15 +264,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();
|
| }
|
|
|
| @@ -439,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;
|
|
|
| @@ -741,13 +767,13 @@ 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));
|
| }
|
| @@ -761,9 +787,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(),
|
| +// overflow_size.height()));
|
| overflow->SetScrollOffset(gfx::Vector2d());
|
| overflow->SetPosition(gfx::PointF());
|
| overflow->SetAnchorPoint(gfx::PointF());
|
| @@ -826,7 +852,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;
|
|
|
| @@ -840,6 +866,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();
|
| @@ -851,7 +878,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
|
| @@ -890,7 +917,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;
|
| @@ -1010,7 +1037,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();
|
| @@ -1033,7 +1059,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;
|
| @@ -1049,7 +1075,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));
|
|
|
| host_impl_->StartPageScaleAnimation(gfx::Vector2d(), false, 2.f, duration);
|
| did_request_redraw_ = false;
|
| @@ -1068,7 +1094,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
|
| @@ -1076,10 +1102,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_);
|
| @@ -1094,7 +1120,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));
|
| }
|
| }
|
|
|
| @@ -1103,7 +1129,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;
|
| @@ -1182,10 +1208,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);
|
|
|
| @@ -1197,13 +1222,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();
|
|
|
| @@ -1254,7 +1281,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_);
|
| @@ -1290,10 +1317,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);
|
|
|
| @@ -1310,17 +1335,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*>(
|
| @@ -1404,7 +1431,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);
|
| 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);
|
| @@ -1419,7 +1446,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);
|
| @@ -1771,7 +1798,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();
|
|
|
| @@ -1792,18 +1819,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,
|
| @@ -1823,6 +1855,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);
|
| @@ -1830,22 +1863,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();
|
|
|
| @@ -1860,10 +1895,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();
|
| @@ -1880,7 +1916,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();
|
| @@ -1897,7 +1933,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;
|
| @@ -1920,14 +1957,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();
|
|
|
| @@ -1939,21 +1983,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));
|
| @@ -1969,7 +2016,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.
|
| @@ -1977,22 +2024,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));
|
| @@ -2012,7 +2062,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());
|
| @@ -2033,9 +2083,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.
|
| @@ -2075,27 +2128,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));
|
| @@ -2114,7 +2169,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.
|
| @@ -2126,19 +2181,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);
|
| @@ -2164,22 +2227,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);
|
| @@ -2257,20 +2328,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();
|
| {
|
| @@ -2284,18 +2363,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);
|
|
|
| @@ -2303,8 +2385,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.
|
| @@ -2357,13 +2444,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.
|
| scoped_ptr<LayerImpl> child = CreateScrollableLayer(
|
| child_layer_id,
|
| - scroll_layer->content_bounds());
|
| + scroll_layer->content_bounds(), host_impl_->active_tree()->root_layer());
|
| gfx::Transform rotate_transform;
|
| rotate_transform.Translate(-50.0, -50.0);
|
| rotate_transform.Rotate(child_layer_angle);
|
| @@ -2371,7 +2458,7 @@ TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) {
|
| child->SetTransform(rotate_transform);
|
|
|
| // Only allow vertical scrolling.
|
| - child->SetMaxScrollOffset(gfx::Vector2d(0, child->content_bounds().height()));
|
| +// child->SetMaxScrollOffset(gfx::Vector2d(0, child->content_bounds().height())); // WJM
|
| scroll_layer->AddChild(child.Pass());
|
|
|
| gfx::Size surface_size(50, 50);
|
| @@ -2536,6 +2623,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);
|
| @@ -2659,17 +2748,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();
|
| @@ -2682,19 +2779,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();
|
|
|
| @@ -2706,9 +2800,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();
|
| @@ -2721,14 +2815,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();
|
| {
|
| @@ -2752,7 +2852,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();
|
| @@ -4924,8 +5026,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();
|
| @@ -5353,13 +5454,19 @@ 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_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();
|
| {
|
| @@ -5381,8 +5488,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_scroll_id);
|
| }
|
| }
|
|
|
| @@ -5392,13 +5498,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();
|
| {
|
| @@ -5415,9 +5529,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());
|
| @@ -5428,9 +5540,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));
|
| }
|
| }
|
|
|
| @@ -5439,13 +5549,20 @@ 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 =
|
| + 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();
|
| {
|
| @@ -5466,11 +5583,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_id, gfx::Vector2d(0, 10));
|
| }
|
| }
|
| -
|
| } // namespace
|
| } // namespace cc
|
|
|