summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbokan <bokan@chromium.org>2015-07-30 09:08:54 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-30 16:09:51 +0000
commit1f86d8fcaa3462def9e92722c0097a7b38c8fe1d (patch)
tree1b4d042fc90432b871d4890431368e79e8d477b7
parent3d44d0f1ab27508e2555b0bb7ce8e694103992b5 (diff)
downloadchromium_src-1f86d8fcaa3462def9e92722c0097a7b38c8fe1d.zip
chromium_src-1f86d8fcaa3462def9e92722c0097a7b38c8fe1d.tar.gz
chromium_src-1f86d8fcaa3462def9e92722c0097a7b38c8fe1d.tar.bz2
Assume outer viewport always exists in Viewport::ScrollBy.
The outer viewport should always exist in the layer hierarchy but this conditional exists because old unit tests were creating hierarchies from pre-virtual-viewport days. This patch fixes these tests and removes the check. BUG=425102 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1268623003 Cr-Commit-Position: refs/heads/master@{#341128}
-rw-r--r--cc/layers/viewport.cc8
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc139
2 files changed, 34 insertions, 113 deletions
diff --git a/cc/layers/viewport.cc b/cc/layers/viewport.cc
index 2b1a3e7..d9ae5f4 100644
--- a/cc/layers/viewport.cc
+++ b/cc/layers/viewport.cc
@@ -43,11 +43,9 @@ Viewport::ScrollResult Viewport::ScrollBy(const gfx::Vector2dF& delta,
gfx::Vector2dF pending_content_delta = content_delta;
- if (OuterScrollLayer()) {
- pending_content_delta -=
- host_impl_->ScrollLayer(OuterScrollLayer(), pending_content_delta,
- viewport_point, is_direct_manipulation);
- }
+ pending_content_delta -=
+ host_impl_->ScrollLayer(OuterScrollLayer(), pending_content_delta,
+ viewport_point, is_direct_manipulation);
ScrollResult result;
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 2f7da94..a99c7b4 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -1857,7 +1857,6 @@ class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl {
class LayerTreeHostImplTestScrollbarAnimation : public LayerTreeHostImplTest {
protected:
void SetupLayers(LayerTreeSettings settings) {
- gfx::Size viewport_size(10, 10);
gfx::Size content_size(100, 100);
LayerTreeHostImplOverridePhysicalTime* host_impl_override_time =
@@ -1866,39 +1865,22 @@ class LayerTreeHostImplTestScrollbarAnimation : public LayerTreeHostImplTest {
&task_graph_runner_, &stats_instrumentation_);
host_impl_ = make_scoped_ptr(host_impl_override_time);
host_impl_->InitializeRenderer(CreateOutputSurface());
- host_impl_->SetViewportSize(viewport_size);
-
- scoped_ptr<LayerImpl> root =
- LayerImpl::Create(host_impl_->active_tree(), 1);
- root->SetBounds(viewport_size);
-
- scoped_ptr<LayerImpl> scroll =
- LayerImpl::Create(host_impl_->active_tree(), 2);
- scroll->SetScrollClipLayer(root->id());
- scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset());
- root->SetBounds(viewport_size);
- scroll->SetBounds(content_size);
- scroll->SetIsContainerForFixedPositionLayers(true);
- scoped_ptr<LayerImpl> contents =
- LayerImpl::Create(host_impl_->active_tree(), 3);
- contents->SetDrawsContent(true);
- contents->SetBounds(content_size);
+ SetupScrollAndContentsLayers(content_size);
+ host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f);
+ host_impl_->SetViewportSize(
+ gfx::Size(content_size.width() / 2, content_size.height() / 2));
scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar =
- SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 4,
+ SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 400,
VERTICAL, 10, 0, false, true);
EXPECT_FLOAT_EQ(0.f, scrollbar->opacity());
- scroll->AddChild(contents.Pass());
- root->AddChild(scroll.Pass());
- root->SetHasRenderSurface(true);
- scrollbar->SetScrollLayerAndClipLayerByIds(2, 1);
+ LayerImpl* scroll = host_impl_->InnerViewportScrollLayer();
+ LayerImpl* root = scroll->parent()->parent();
+ scrollbar->SetScrollLayerAndClipLayerByIds(scroll->id(), root->id());
root->AddChild(scrollbar.Pass());
- host_impl_->active_tree()->SetRootLayer(root.Pass());
- host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2,
- Layer::INVALID_ID);
host_impl_->active_tree()->DidBecomeActive();
DrawFrame();
}
@@ -3486,30 +3468,21 @@ TEST_F(LayerTreeHostImplTest, ScrollBlockedByContentLayer) {
}
TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) {
- gfx::Size surface_size(20, 20);
gfx::Size viewport_size(10, 10);
float page_scale = 2.f;
- scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
- scoped_ptr<LayerImpl> root_clip =
- LayerImpl::Create(host_impl_->active_tree(), 2);
- scoped_ptr<LayerImpl> root_scrolling =
- CreateScrollableLayer(3, surface_size, root_clip.get());
- EXPECT_EQ(viewport_size, root_clip->bounds());
- root_scrolling->SetIsContainerForFixedPositionLayers(true);
- root_clip->AddChild(root_scrolling.Pass());
- root->AddChild(root_clip.Pass());
- root->SetHasRenderSurface(true);
- host_impl_->active_tree()->SetRootLayer(root.Pass());
- // The behaviour in this test assumes the page scale is applied at a layer
- // above the clip layer.
- host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3,
- Layer::INVALID_ID);
- host_impl_->active_tree()->DidBecomeActive();
- host_impl_->SetViewportSize(viewport_size);
+
+ SetupScrollAndContentsLayers(viewport_size);
+
+ // Setup the layers so that the outer viewport is scrollable.
+ host_impl_->active_tree()->InnerViewportScrollLayer()->parent()->SetBounds(
+ viewport_size);
+ host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds(
+ gfx::Size(20, 20));
+ host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f);
DrawFrame();
LayerImpl* root_scroll =
- host_impl_->active_tree()->InnerViewportScrollLayer();
+ host_impl_->active_tree()->OuterViewportScrollLayer();
EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds());
gfx::Vector2d scroll_delta(0, 10);
@@ -3521,8 +3494,7 @@ TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) {
host_impl_->ScrollEnd();
// Set new page scale from main thread.
- host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, page_scale,
- page_scale);
+ host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 2.f);
scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas();
EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), root_scroll->id(),
@@ -3537,31 +3509,21 @@ TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) {
}
TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnImplThread) {
- gfx::Size surface_size(20, 20);
gfx::Size viewport_size(10, 10);
float page_scale = 2.f;
- scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
- scoped_ptr<LayerImpl> root_clip =
- LayerImpl::Create(host_impl_->active_tree(), 2);
- scoped_ptr<LayerImpl> root_scrolling =
- CreateScrollableLayer(3, surface_size, root_clip.get());
- EXPECT_EQ(viewport_size, root_clip->bounds());
- root_scrolling->SetIsContainerForFixedPositionLayers(true);
- root_clip->AddChild(root_scrolling.Pass());
- root->AddChild(root_clip.Pass());
- root->SetHasRenderSurface(true);
- host_impl_->active_tree()->SetRootLayer(root.Pass());
- // The behaviour in this test assumes the page scale is applied at a layer
- // above the clip layer.
- host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3,
- Layer::INVALID_ID);
- host_impl_->active_tree()->DidBecomeActive();
- host_impl_->SetViewportSize(viewport_size);
- host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, page_scale);
+
+ SetupScrollAndContentsLayers(viewport_size);
+
+ // Setup the layers so that the outer viewport is scrollable.
+ host_impl_->active_tree()->InnerViewportScrollLayer()->parent()->SetBounds(
+ viewport_size);
+ host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds(
+ gfx::Size(20, 20));
+ host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f);
DrawFrame();
LayerImpl* root_scroll =
- host_impl_->active_tree()->InnerViewportScrollLayer();
+ host_impl_->active_tree()->OuterViewportScrollLayer();
EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds());
gfx::Vector2d scroll_delta(0, 10);
@@ -4581,27 +4543,7 @@ TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) {
// should be applied to one of its ancestors if possible. Overscroll should
// be reflected only when it has bubbled up to the root scrolling layer.
InputHandlerScrollResult scroll_result;
- gfx::Size surface_size(10, 10);
- gfx::Size content_size(20, 20);
- scoped_ptr<LayerImpl> root_clip =
- LayerImpl::Create(host_impl_->active_tree(), 3);
- root_clip->SetHasRenderSurface(true);
-
- scoped_ptr<LayerImpl> root =
- CreateScrollableLayer(1, content_size, root_clip.get());
- root->SetIsContainerForFixedPositionLayers(true);
- scoped_ptr<LayerImpl> child =
- CreateScrollableLayer(2, content_size, root_clip.get());
-
- child->SetScrollClipLayer(Layer::INVALID_ID);
- root->AddChild(child.Pass());
- root_clip->AddChild(root.Pass());
-
- host_impl_->SetViewportSize(surface_size);
- host_impl_->active_tree()->SetRootLayer(root_clip.Pass());
- host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 1,
- Layer::INVALID_ID);
- host_impl_->active_tree()->DidBecomeActive();
+ SetupScrollAndContentsLayers(gfx::Size(20, 20));
DrawFrame();
{
gfx::Vector2d scroll_delta(0, 8);
@@ -4647,27 +4589,8 @@ TEST_F(LayerTreeHostImplTest, OverscrollAlways) {
TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) {
InputHandlerScrollResult scroll_result;
- gfx::Size surface_size(100, 100);
- gfx::Size content_size(200, 200);
- scoped_ptr<LayerImpl> root_clip =
- LayerImpl::Create(host_impl_->active_tree(), 3);
- root_clip->SetHasRenderSurface(true);
-
- scoped_ptr<LayerImpl> root =
- CreateScrollableLayer(1, content_size, root_clip.get());
- root->SetIsContainerForFixedPositionLayers(true);
- scoped_ptr<LayerImpl> child =
- CreateScrollableLayer(2, content_size, root_clip.get());
-
- child->SetScrollClipLayer(Layer::INVALID_ID);
- root->AddChild(child.Pass());
- root_clip->AddChild(root.Pass());
+ SetupScrollAndContentsLayers(gfx::Size(200, 200));
- host_impl_->SetViewportSize(surface_size);
- host_impl_->active_tree()->SetRootLayer(root_clip.Pass());
- host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 1,
- Layer::INVALID_ID);
- host_impl_->active_tree()->DidBecomeActive();
DrawFrame();
{
// Edge glow effect should be applicable only upon reaching Edges