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

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

Issue 868363004: Compositor hit-testing considers scrollable layers that scroll a drawn RSLL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use IsDawnRSLL instead of DrawsContent Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 7127 matching lines...) Expand 10 before | Expand all | Expand 10 after
7138 7138
7139 child_scroll->AddChild(occluder_layer.Pass()); 7139 child_scroll->AddChild(occluder_layer.Pass());
7140 scroll_layer->AddChild(child_scroll.Pass()); 7140 scroll_layer->AddChild(child_scroll.Pass());
7141 7141
7142 DrawFrame(); 7142 DrawFrame();
7143 7143
7144 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, 7144 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN,
7145 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); 7145 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL));
7146 } 7146 }
7147 7147
7148 TEST_F(LayerTreeHostImplTest, ScrollInvisibleScroller) { 7148 TEST_F(LayerTreeHostImplTest, NotScrollInvisibleScroller) {
7149 gfx::Size content_size(100, 100); 7149 gfx::Size content_size(100, 100);
7150 SetupScrollAndContentsLayers(content_size); 7150 SetupScrollAndContentsLayers(content_size);
7151 7151
7152 LayerImpl* root = host_impl_->active_tree()->LayerById(1); 7152 LayerImpl* root = host_impl_->active_tree()->LayerById(1);
7153 7153
7154 int scroll_layer_id = 2; 7154 int scroll_layer_id = 2;
7155 LayerImpl* scroll_layer = 7155 LayerImpl* scroll_layer =
7156 host_impl_->active_tree()->LayerById(scroll_layer_id); 7156 host_impl_->active_tree()->LayerById(scroll_layer_id);
7157 7157
7158 int child_scroll_layer_id = 7; 7158 int child_scroll_layer_id = 7;
7159 scoped_ptr<LayerImpl> child_scroll = 7159 scoped_ptr<LayerImpl> child_scroll =
7160 CreateScrollableLayer(child_scroll_layer_id, content_size, root); 7160 CreateScrollableLayer(child_scroll_layer_id, content_size, root);
7161 child_scroll->SetDrawsContent(false); 7161 child_scroll->SetDrawsContent(false);
7162 7162
7163 scroll_layer->AddChild(child_scroll.Pass()); 7163 scroll_layer->AddChild(child_scroll.Pass());
7164 7164
7165 DrawFrame(); 7165 DrawFrame();
7166 7166
7167 // We should not have scrolled |child_scroll| even though we technically "hit" 7167 // We should not have scrolled |child_scroll| even though we technically "hit"
7168 // it. The reason for this is that if the scrolling the scroll would not move 7168 // it. The reason for this is that if the scrolling the scroll would not move
7169 // any layer that is a drawn RSLL member, then we can ignore the hit. 7169 // any layer that is a drawn RSLL member, then we can ignore the hit.
7170 // 7170 //
7171 // Why SCROLL_STARTED? In this case, it's because we've bubbled out and 7171 // Why SCROLL_STARTED? In this case, it's because we've bubbled out and
7172 // started overscrolling the inner viewport. 7172 // started scrolling the inner viewport.
7173 EXPECT_EQ(InputHandler::SCROLL_STARTED, 7173 EXPECT_EQ(InputHandler::SCROLL_STARTED,
7174 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); 7174 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL));
7175 7175
7176 EXPECT_EQ(2, host_impl_->CurrentlyScrollingLayer()->id()); 7176 EXPECT_EQ(2, host_impl_->CurrentlyScrollingLayer()->id());
7177 } 7177 }
7178 7178
7179 TEST_F(LayerTreeHostImplTest, ScrollInvisibleScrollerWithVisibleDescendent) {
7180 gfx::Size content_size(100, 100);
7181 SetupScrollAndContentsLayers(content_size);
7182
7183 LayerImpl* root = host_impl_->active_tree()->LayerById(1);
7184 LayerImpl* root_scroll_layer = host_impl_->active_tree()->LayerById(2);
7185
7186 scoped_ptr<LayerImpl> invisible_scroll_layer =
7187 CreateScrollableLayer(7, content_size, root);
7188 invisible_scroll_layer->SetDrawsContent(false);
7189
7190 scoped_ptr<LayerImpl> child_layer =
7191 LayerImpl::Create(host_impl_->active_tree(), 8);
7192 child_layer->SetDrawsContent(false);
7193
7194 scoped_ptr<LayerImpl> grand_child_layer =
7195 LayerImpl::Create(host_impl_->active_tree(), 9);
7196 grand_child_layer->SetDrawsContent(true);
7197 grand_child_layer->SetBounds(content_size);
7198 grand_child_layer->SetContentBounds(content_size);
7199 // Move the grand child so it's not hit by our test point.
7200 grand_child_layer->SetPosition(gfx::PointF(10.f, 10.f));
7201
7202 child_layer->AddChild(grand_child_layer.Pass());
7203 invisible_scroll_layer->AddChild(child_layer.Pass());
7204 root_scroll_layer->AddChild(invisible_scroll_layer.Pass());
7205
7206 DrawFrame();
7207
7208 // We should have scrolled |invisible_scroll_layer| as it was hit and it has
7209 // a descendant which is a drawn RSLL member.
7210 EXPECT_EQ(InputHandler::SCROLL_STARTED,
7211 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL));
7212
7213 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id());
7214 }
7215
7179 TEST_F(LayerTreeHostImplTest, ScrollInvisibleScrollerWithVisibleScrollChild) { 7216 TEST_F(LayerTreeHostImplTest, ScrollInvisibleScrollerWithVisibleScrollChild) {
7180 // This test case is very similar to the one above with one key difference: 7217 // This test case is very similar to the one above with one key difference:
7181 // the invisible scroller has a scroll child that is indeed draw contents. 7218 // the invisible scroller has a scroll child that is indeed draw contents.
7182 // If we attempt to initiate a gesture scroll off of the visible scroll child 7219 // If we attempt to initiate a gesture scroll off of the visible scroll child
7183 // we should still start the scroll child. 7220 // we should still start the scroll child.
7184 gfx::Size content_size(100, 100); 7221 gfx::Size content_size(100, 100);
7185 SetupScrollAndContentsLayers(content_size); 7222 SetupScrollAndContentsLayers(content_size);
7186 7223
7187 LayerImpl* root = host_impl_->active_tree()->LayerById(1); 7224 LayerImpl* root = host_impl_->active_tree()->LayerById(1);
7188 7225
(...skipping 25 matching lines...) Expand all
7214 7251
7215 scroll_child->SetScrollParent(invisible_scroll.get()); 7252 scroll_child->SetScrollParent(invisible_scroll.get());
7216 7253
7217 container->AddChild(invisible_scroll.Pass()); 7254 container->AddChild(invisible_scroll.Pass());
7218 container->AddChild(scroll_child.Pass()); 7255 container->AddChild(scroll_child.Pass());
7219 7256
7220 scroll_layer->AddChild(container.Pass()); 7257 scroll_layer->AddChild(container.Pass());
7221 7258
7222 DrawFrame(); 7259 DrawFrame();
7223 7260
7224 // We should not have scrolled |child_scroll| even though we technically "hit" 7261 // We should have scrolled |child_scroll| even though it is invisible.
7225 // it. The reason for this is that if the scrolling the scroll would not move 7262 // The reason for this is that if the scrolling the scroll would move a layer
7226 // any layer that is a drawn RSLL member, then we can ignore the hit. 7263 // that is a drawn RSLL member, then we should accept this hit.
7227 //
7228 // Why SCROLL_STARTED? In this case, it's because we've bubbled out and
7229 // started overscrolling the inner viewport.
7230 EXPECT_EQ(InputHandler::SCROLL_STARTED, 7264 EXPECT_EQ(InputHandler::SCROLL_STARTED,
7231 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); 7265 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL));
7232 7266
7233 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); 7267 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id());
7234 } 7268 }
7235 7269
7236 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed 7270 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed
7237 // to CompositorFrameMetadata after SwapBuffers(); 7271 // to CompositorFrameMetadata after SwapBuffers();
7238 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { 7272 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) {
7239 scoped_ptr<SolidColorLayerImpl> root = 7273 scoped_ptr<SolidColorLayerImpl> root =
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after
8475 // surface. 8509 // surface.
8476 EXPECT_EQ(0, num_lost_surfaces_); 8510 EXPECT_EQ(0, num_lost_surfaces_);
8477 host_impl_->DidLoseOutputSurface(); 8511 host_impl_->DidLoseOutputSurface();
8478 EXPECT_EQ(1, num_lost_surfaces_); 8512 EXPECT_EQ(1, num_lost_surfaces_);
8479 host_impl_->DidLoseOutputSurface(); 8513 host_impl_->DidLoseOutputSurface();
8480 EXPECT_LE(1, num_lost_surfaces_); 8514 EXPECT_LE(1, num_lost_surfaces_);
8481 } 8515 }
8482 8516
8483 } // namespace 8517 } // namespace
8484 } // namespace cc 8518 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698