| OLD | NEW |
| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 scrollbar_fade_start_ = start_fade; | 153 scrollbar_fade_start_ = start_fade; |
| 154 requested_scrollbar_animation_delay_ = delay; | 154 requested_scrollbar_animation_delay_ = delay; |
| 155 } | 155 } |
| 156 void DidActivateSyncTree() override {} | 156 void DidActivateSyncTree() override {} |
| 157 void DidManageTiles() override {} | 157 void DidManageTiles() override {} |
| 158 | 158 |
| 159 void set_reduce_memory_result(bool reduce_memory_result) { | 159 void set_reduce_memory_result(bool reduce_memory_result) { |
| 160 reduce_memory_result_ = reduce_memory_result; | 160 reduce_memory_result_ = reduce_memory_result; |
| 161 } | 161 } |
| 162 | 162 |
| 163 bool CreateHostImpl(const LayerTreeSettings& settings, | 163 virtual bool CreateHostImpl(const LayerTreeSettings& settings, |
| 164 scoped_ptr<OutputSurface> output_surface) { | 164 scoped_ptr<OutputSurface> output_surface) { |
| 165 host_impl_ = LayerTreeHostImpl::Create(settings, | 165 host_impl_ = LayerTreeHostImpl::Create(settings, |
| 166 this, | 166 this, |
| 167 &proxy_, | 167 &proxy_, |
| 168 &stats_instrumentation_, | 168 &stats_instrumentation_, |
| 169 shared_bitmap_manager_.get(), | 169 shared_bitmap_manager_.get(), |
| 170 gpu_memory_buffer_manager_.get(), | 170 gpu_memory_buffer_manager_.get(), |
| 171 0); | 171 0); |
| 172 bool init = host_impl_->InitializeRenderer(output_surface.Pass()); | 172 bool init = host_impl_->InitializeRenderer(output_surface.Pass()); |
| 173 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 173 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 174 return init; | 174 return init; |
| (...skipping 2088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2263 EXPECT_FALSE(did_request_commit_); | 2263 EXPECT_FALSE(did_request_commit_); |
| 2264 } | 2264 } |
| 2265 | 2265 |
| 2266 // TODO(bokan): Convert these tests to create inner and outer viewports. | 2266 // TODO(bokan): Convert these tests to create inner and outer viewports. |
| 2267 class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest { | 2267 class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest { |
| 2268 public: | 2268 public: |
| 2269 LayerTreeHostImplTopControlsTest() | 2269 LayerTreeHostImplTopControlsTest() |
| 2270 // Make the clip size the same as the layer (content) size so the layer is | 2270 // Make the clip size the same as the layer (content) size so the layer is |
| 2271 // non-scrollable. | 2271 // non-scrollable. |
| 2272 : layer_size_(10, 10), | 2272 : layer_size_(10, 10), |
| 2273 clip_size_(layer_size_) { | 2273 clip_size_(layer_size_), |
| 2274 top_controls_height_(50) { |
| 2274 settings_.calculate_top_controls_position = true; | 2275 settings_.calculate_top_controls_position = true; |
| 2275 settings_.top_controls_height = 50; | |
| 2276 settings_.use_pinch_virtual_viewport = true; | 2276 settings_.use_pinch_virtual_viewport = true; |
| 2277 | 2277 |
| 2278 viewport_size_ = | 2278 viewport_size_ = gfx::Size(clip_size_.width(), |
| 2279 gfx::Size(clip_size_.width(), | 2279 clip_size_.height() + top_controls_height_); |
| 2280 clip_size_.height() + settings_.top_controls_height); | 2280 } |
| 2281 |
| 2282 bool CreateHostImpl(const LayerTreeSettings& settings, |
| 2283 scoped_ptr<OutputSurface> output_surface) override { |
| 2284 bool init = |
| 2285 LayerTreeHostImplTest::CreateHostImpl(settings, output_surface.Pass()); |
| 2286 if (init && settings.calculate_top_controls_position) { |
| 2287 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); |
| 2288 host_impl_->active_tree()->set_top_controls_delta(top_controls_height_); |
| 2289 host_impl_->top_controls_manager()->SetTopControlsHeight( |
| 2290 top_controls_height_); |
| 2291 host_impl_->UpdateViewportContainerSizes(); |
| 2292 } |
| 2293 return init; |
| 2281 } | 2294 } |
| 2282 | 2295 |
| 2283 void SetupTopControlsAndScrollLayer() { | 2296 void SetupTopControlsAndScrollLayer() { |
| 2284 scoped_ptr<LayerImpl> root = | 2297 scoped_ptr<LayerImpl> root = |
| 2285 LayerImpl::Create(host_impl_->active_tree(), 1); | 2298 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2286 scoped_ptr<LayerImpl> root_clip = | 2299 scoped_ptr<LayerImpl> root_clip = |
| 2287 LayerImpl::Create(host_impl_->active_tree(), 2); | 2300 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 2288 root_clip->SetBounds(clip_size_); | 2301 root_clip->SetBounds(clip_size_); |
| 2289 root->SetScrollClipLayer(root_clip->id()); | 2302 root->SetScrollClipLayer(root_clip->id()); |
| 2290 root->SetBounds(layer_size_); | 2303 root->SetBounds(layer_size_); |
| 2291 root->SetContentBounds(layer_size_); | 2304 root->SetContentBounds(layer_size_); |
| 2292 root->SetPosition(gfx::PointF()); | 2305 root->SetPosition(gfx::PointF()); |
| 2293 root->SetDrawsContent(false); | 2306 root->SetDrawsContent(false); |
| 2294 root->SetIsContainerForFixedPositionLayers(true); | 2307 root->SetIsContainerForFixedPositionLayers(true); |
| 2295 int inner_viewport_scroll_layer_id = root->id(); | 2308 int inner_viewport_scroll_layer_id = root->id(); |
| 2296 int page_scale_layer_id = root_clip->id(); | 2309 int page_scale_layer_id = root_clip->id(); |
| 2297 root_clip->AddChild(root.Pass()); | 2310 root_clip->AddChild(root.Pass()); |
| 2298 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 2311 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
| 2299 host_impl_->active_tree()->SetViewportLayersFromIds( | 2312 host_impl_->active_tree()->SetViewportLayersFromIds( |
| 2300 Layer::INVALID_ID, page_scale_layer_id, inner_viewport_scroll_layer_id, | 2313 Layer::INVALID_ID, page_scale_layer_id, inner_viewport_scroll_layer_id, |
| 2301 Layer::INVALID_ID); | 2314 Layer::INVALID_ID); |
| 2302 // Set a viewport size that is large enough to contain both the top controls | 2315 // Set a viewport size that is large enough to contain both the top controls |
| 2303 // and some content. | 2316 // and some content. |
| 2304 host_impl_->SetViewportSize(viewport_size_); | 2317 host_impl_->SetViewportSize(viewport_size_); |
| 2305 host_impl_->SetTopControlsLayoutHeight( | 2318 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); |
| 2306 settings_.top_controls_height); | 2319 |
| 2320 host_impl_->DidChangeTopControlsPosition(); |
| 2307 | 2321 |
| 2308 host_impl_->CreatePendingTree(); | 2322 host_impl_->CreatePendingTree(); |
| 2309 root = | 2323 root = |
| 2310 LayerImpl::Create(host_impl_->sync_tree(), 1); | 2324 LayerImpl::Create(host_impl_->sync_tree(), 1); |
| 2311 root_clip = | 2325 root_clip = |
| 2312 LayerImpl::Create(host_impl_->sync_tree(), 2); | 2326 LayerImpl::Create(host_impl_->sync_tree(), 2); |
| 2313 root_clip->SetBounds(clip_size_); | 2327 root_clip->SetBounds(clip_size_); |
| 2314 root->SetScrollClipLayer(root_clip->id()); | 2328 root->SetScrollClipLayer(root_clip->id()); |
| 2315 root->SetBounds(layer_size_); | 2329 root->SetBounds(layer_size_); |
| 2316 root->SetContentBounds(layer_size_); | 2330 root->SetContentBounds(layer_size_); |
| 2317 root->SetPosition(gfx::PointF()); | 2331 root->SetPosition(gfx::PointF()); |
| 2318 root->SetDrawsContent(false); | 2332 root->SetDrawsContent(false); |
| 2319 root->SetIsContainerForFixedPositionLayers(true); | 2333 root->SetIsContainerForFixedPositionLayers(true); |
| 2320 inner_viewport_scroll_layer_id = root->id(); | 2334 inner_viewport_scroll_layer_id = root->id(); |
| 2321 page_scale_layer_id = root_clip->id(); | 2335 page_scale_layer_id = root_clip->id(); |
| 2322 root_clip->AddChild(root.Pass()); | 2336 root_clip->AddChild(root.Pass()); |
| 2323 host_impl_->sync_tree()->SetRootLayer(root_clip.Pass()); | 2337 host_impl_->sync_tree()->SetRootLayer(root_clip.Pass()); |
| 2324 host_impl_->sync_tree()->SetViewportLayersFromIds( | 2338 host_impl_->sync_tree()->SetViewportLayersFromIds( |
| 2325 Layer::INVALID_ID, page_scale_layer_id, inner_viewport_scroll_layer_id, | 2339 Layer::INVALID_ID, page_scale_layer_id, inner_viewport_scroll_layer_id, |
| 2326 Layer::INVALID_ID); | 2340 Layer::INVALID_ID); |
| 2327 // Set a viewport size that is large enough to contain both the top controls | 2341 // Set a viewport size that is large enough to contain both the top controls |
| 2328 // and some content. | 2342 // and some content. |
| 2329 host_impl_->SetViewportSize(viewport_size_); | 2343 host_impl_->SetViewportSize(viewport_size_); |
| 2330 host_impl_->sync_tree()->set_top_controls_layout_height( | 2344 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); |
| 2331 settings_.top_controls_height); | 2345 host_impl_->DidChangeTopControlsPosition(); |
| 2332 } | 2346 } |
| 2333 | 2347 |
| 2334 void SetupTopControlsAndScrollLayerWithVirtualViewport( | 2348 void SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 2335 const gfx::Size& inner_viewport_size, | 2349 const gfx::Size& inner_viewport_size, |
| 2336 const gfx::Size& outer_viewport_size, | 2350 const gfx::Size& outer_viewport_size, |
| 2337 const gfx::Size& scroll_layer_size) { | 2351 const gfx::Size& scroll_layer_size) { |
| 2338 CreateHostImpl(settings_, CreateOutputSurface()); | 2352 CreateHostImpl(settings_, CreateOutputSurface()); |
| 2339 host_impl_->SetTopControlsLayoutHeight( | 2353 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); |
| 2340 settings_.top_controls_height); | 2354 host_impl_->DidChangeTopControlsPosition(); |
| 2341 | 2355 |
| 2342 scoped_ptr<LayerImpl> root = | 2356 scoped_ptr<LayerImpl> root = |
| 2343 LayerImpl::Create(host_impl_->active_tree(), 1); | 2357 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2344 scoped_ptr<LayerImpl> root_clip = | 2358 scoped_ptr<LayerImpl> root_clip = |
| 2345 LayerImpl::Create(host_impl_->active_tree(), 2); | 2359 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 2346 scoped_ptr<LayerImpl> page_scale = | 2360 scoped_ptr<LayerImpl> page_scale = |
| 2347 LayerImpl::Create(host_impl_->active_tree(), 3); | 2361 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 2348 | 2362 |
| 2349 scoped_ptr<LayerImpl> outer_scroll = | 2363 scoped_ptr<LayerImpl> outer_scroll = |
| 2350 LayerImpl::Create(host_impl_->active_tree(), 4); | 2364 LayerImpl::Create(host_impl_->active_tree(), 4); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2383 | 2397 |
| 2384 host_impl_->SetViewportSize(inner_viewport_size); | 2398 host_impl_->SetViewportSize(inner_viewport_size); |
| 2385 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); | 2399 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); |
| 2386 EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds()); | 2400 EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds()); |
| 2387 } | 2401 } |
| 2388 | 2402 |
| 2389 protected: | 2403 protected: |
| 2390 gfx::Size layer_size_; | 2404 gfx::Size layer_size_; |
| 2391 gfx::Size clip_size_; | 2405 gfx::Size clip_size_; |
| 2392 gfx::Size viewport_size_; | 2406 gfx::Size viewport_size_; |
| 2407 float top_controls_height_; |
| 2393 | 2408 |
| 2394 LayerTreeSettings settings_; | 2409 LayerTreeSettings settings_; |
| 2395 }; // class LayerTreeHostImplTopControlsTest | 2410 }; // class LayerTreeHostImplTopControlsTest |
| 2396 | 2411 |
| 2397 TEST_F(LayerTreeHostImplTopControlsTest, ScrollTopControlsByFractionalAmount) { | 2412 TEST_F(LayerTreeHostImplTopControlsTest, ScrollTopControlsByFractionalAmount) { |
| 2398 SetupTopControlsAndScrollLayerWithVirtualViewport( | 2413 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 2399 gfx::Size(10, 10), gfx::Size(10, 10), gfx::Size(10, 10)); | 2414 gfx::Size(10, 10), gfx::Size(10, 10), gfx::Size(10, 10)); |
| 2400 DrawFrame(); | 2415 DrawFrame(); |
| 2401 | 2416 |
| 2402 EXPECT_EQ(InputHandler::ScrollStarted, | 2417 EXPECT_EQ(InputHandler::ScrollStarted, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2494 } | 2509 } |
| 2495 | 2510 |
| 2496 // Test that the fixed position container delta is appropriately adjusted | 2511 // Test that the fixed position container delta is appropriately adjusted |
| 2497 // by the top controls showing/hiding and page scale doesn't affect it. | 2512 // by the top controls showing/hiding and page scale doesn't affect it. |
| 2498 TEST_F(LayerTreeHostImplTopControlsTest, FixedContainerDelta) { | 2513 TEST_F(LayerTreeHostImplTopControlsTest, FixedContainerDelta) { |
| 2499 SetupTopControlsAndScrollLayerWithVirtualViewport( | 2514 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 2500 gfx::Size(100, 100), gfx::Size(100, 100), gfx::Size(100, 100)); | 2515 gfx::Size(100, 100), gfx::Size(100, 100), gfx::Size(100, 100)); |
| 2501 DrawFrame(); | 2516 DrawFrame(); |
| 2502 | 2517 |
| 2503 float page_scale = 1.5f; | 2518 float page_scale = 1.5f; |
| 2504 float top_controls_height = settings_.top_controls_height; | |
| 2505 LayerImpl* outer_viewport_scroll_layer = | 2519 LayerImpl* outer_viewport_scroll_layer = |
| 2506 host_impl_->active_tree()->OuterViewportScrollLayer(); | 2520 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 2507 | 2521 |
| 2508 // Zoom in, since the fixed container is the outer viewport, the delta should | 2522 // Zoom in, since the fixed container is the outer viewport, the delta should |
| 2509 // not be scaled. | 2523 // not be scaled. |
| 2510 host_impl_->active_tree()->SetPageScaleFactorAndLimits(page_scale, 1.f, 2.f); | 2524 host_impl_->active_tree()->SetPageScaleFactorAndLimits(page_scale, 1.f, 2.f); |
| 2511 | 2525 |
| 2512 EXPECT_EQ(InputHandler::ScrollStarted, | 2526 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2513 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 2527 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 2514 | 2528 |
| 2515 // Scroll down, the top controls hiding should expand the viewport size so | 2529 // Scroll down, the top controls hiding should expand the viewport size so |
| 2516 // the delta should be equal to the scroll distance. | 2530 // the delta should be equal to the scroll distance. |
| 2517 gfx::Vector2dF top_controls_scroll_delta(0.f, 20.f); | 2531 gfx::Vector2dF top_controls_scroll_delta(0.f, 20.f); |
| 2518 host_impl_->top_controls_manager()->ScrollBegin(); | 2532 host_impl_->top_controls_manager()->ScrollBegin(); |
| 2519 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); | 2533 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); |
| 2520 EXPECT_EQ(top_controls_height - top_controls_scroll_delta.y(), | 2534 EXPECT_EQ(top_controls_height_ - top_controls_scroll_delta.y(), |
| 2521 host_impl_->top_controls_manager()->ContentTopOffset()); | 2535 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2522 EXPECT_VECTOR_EQ(top_controls_scroll_delta, | 2536 EXPECT_VECTOR_EQ(top_controls_scroll_delta, |
| 2523 outer_viewport_scroll_layer->FixedContainerSizeDelta()); | 2537 outer_viewport_scroll_layer->FixedContainerSizeDelta()); |
| 2524 host_impl_->ScrollEnd(); | 2538 host_impl_->ScrollEnd(); |
| 2525 | 2539 |
| 2526 // Scroll past the maximum extent. The delta shouldn't be greater than the | 2540 // Scroll past the maximum extent. The delta shouldn't be greater than the |
| 2527 // top controls height. | 2541 // top controls height. |
| 2528 host_impl_->top_controls_manager()->ScrollBegin(); | 2542 host_impl_->top_controls_manager()->ScrollBegin(); |
| 2529 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); | 2543 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); |
| 2530 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); | 2544 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); |
| 2531 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); | 2545 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); |
| 2532 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 2546 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2533 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, top_controls_height), | 2547 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, top_controls_height_), |
| 2534 outer_viewport_scroll_layer->FixedContainerSizeDelta()); | 2548 outer_viewport_scroll_layer->FixedContainerSizeDelta()); |
| 2535 host_impl_->ScrollEnd(); | 2549 host_impl_->ScrollEnd(); |
| 2536 | 2550 |
| 2537 // Scroll in the direction to make the top controls show. | 2551 // Scroll in the direction to make the top controls show. |
| 2538 host_impl_->top_controls_manager()->ScrollBegin(); | 2552 host_impl_->top_controls_manager()->ScrollBegin(); |
| 2539 host_impl_->top_controls_manager()->ScrollBy(-top_controls_scroll_delta); | 2553 host_impl_->top_controls_manager()->ScrollBy(-top_controls_scroll_delta); |
| 2540 EXPECT_EQ(top_controls_scroll_delta.y(), | 2554 EXPECT_EQ(top_controls_scroll_delta.y(), |
| 2541 host_impl_->top_controls_manager()->ContentTopOffset()); | 2555 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2542 EXPECT_VECTOR_EQ( | 2556 EXPECT_VECTOR_EQ( |
| 2543 gfx::Vector2dF(0, top_controls_height - top_controls_scroll_delta.y()), | 2557 gfx::Vector2dF(0, top_controls_height_ - top_controls_scroll_delta.y()), |
| 2544 outer_viewport_scroll_layer->FixedContainerSizeDelta()); | 2558 outer_viewport_scroll_layer->FixedContainerSizeDelta()); |
| 2545 host_impl_->top_controls_manager()->ScrollEnd(); | 2559 host_impl_->top_controls_manager()->ScrollEnd(); |
| 2546 } | 2560 } |
| 2547 | 2561 |
| 2548 // Ensure setting the top controls position explicitly using the setters on the | 2562 // Ensure setting the top controls position explicitly using the setters on the |
| 2549 // TreeImpl correctly affects the top controls manager and viewport bounds. | 2563 // TreeImpl correctly affects the top controls manager and viewport bounds. |
| 2550 TEST_F(LayerTreeHostImplTopControlsTest, PositionTopControlsExplicitly) { | 2564 TEST_F(LayerTreeHostImplTopControlsTest, PositionTopControlsExplicitly) { |
| 2551 CreateHostImpl(settings_, CreateOutputSurface()); | 2565 CreateHostImpl(settings_, CreateOutputSurface()); |
| 2552 SetupTopControlsAndScrollLayer(); | 2566 SetupTopControlsAndScrollLayer(); |
| 2553 DrawFrame(); | 2567 DrawFrame(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2604 | 2618 |
| 2605 // Test that changing the top controls layout height is correctly applied to | 2619 // Test that changing the top controls layout height is correctly applied to |
| 2606 // the inner viewport container bounds. That is, the top controls layout | 2620 // the inner viewport container bounds. That is, the top controls layout |
| 2607 // height is the amount that the inner viewport container was shrunk outside | 2621 // height is the amount that the inner viewport container was shrunk outside |
| 2608 // the compositor to accommodate the top controls. | 2622 // the compositor to accommodate the top controls. |
| 2609 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsLayoutHeightChanged) { | 2623 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsLayoutHeightChanged) { |
| 2610 CreateHostImpl(settings_, CreateOutputSurface()); | 2624 CreateHostImpl(settings_, CreateOutputSurface()); |
| 2611 SetupTopControlsAndScrollLayer(); | 2625 SetupTopControlsAndScrollLayer(); |
| 2612 DrawFrame(); | 2626 DrawFrame(); |
| 2613 | 2627 |
| 2614 host_impl_->sync_tree()->set_top_controls_content_offset(15.f); | 2628 host_impl_->sync_tree()->set_top_controls_content_offset(50.f); |
| 2615 host_impl_->sync_tree()->set_top_controls_layout_height(15.f); | 2629 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); |
| 2616 | 2630 |
| 2617 host_impl_->active_tree()->set_top_controls_content_offset(20.f); | 2631 host_impl_->active_tree()->set_top_controls_content_offset(50.f); |
| 2618 host_impl_->active_tree()->set_top_controls_delta(-20.f); | 2632 host_impl_->active_tree()->set_top_controls_delta(-50.f); |
| 2619 host_impl_->active_tree()->set_sent_top_controls_delta(-5.f); | |
| 2620 | 2633 |
| 2621 host_impl_->DidChangeTopControlsPosition(); | 2634 host_impl_->DidChangeTopControlsPosition(); |
| 2622 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); | 2635 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); |
| 2623 EXPECT_EQ(viewport_size_, root_clip_ptr->bounds()); | 2636 EXPECT_EQ(viewport_size_, root_clip_ptr->bounds()); |
| 2624 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 2637 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2625 | 2638 |
| 2626 host_impl_->sync_tree()->root_layer()->SetBounds( | 2639 host_impl_->sync_tree()->root_layer()->SetBounds( |
| 2627 gfx::Size(root_clip_ptr->bounds().width(), | 2640 gfx::Size(root_clip_ptr->bounds().width(), |
| 2628 root_clip_ptr->bounds().height() - 15.f)); | 2641 root_clip_ptr->bounds().height() - 50.f)); |
| 2629 | 2642 |
| 2630 host_impl_->ActivateSyncTree(); | 2643 host_impl_->ActivateSyncTree(); |
| 2631 | 2644 |
| 2632 root_clip_ptr = host_impl_->active_tree()->root_layer(); | 2645 root_clip_ptr = host_impl_->active_tree()->root_layer(); |
| 2633 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 2646 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2634 | 2647 |
| 2635 // The total bounds should remain unchanged since the bounds delta should | 2648 // The total bounds should remain unchanged since the bounds delta should |
| 2636 // account for the difference between the layout height and the current | 2649 // account for the difference between the layout height and the current |
| 2637 // top controls offset. | 2650 // top controls offset. |
| 2638 EXPECT_EQ(viewport_size_, root_clip_ptr->bounds()); | 2651 EXPECT_EQ(viewport_size_, root_clip_ptr->bounds()); |
| 2639 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 15.f), root_clip_ptr->bounds_delta()); | 2652 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 50.f), root_clip_ptr->bounds_delta()); |
| 2640 | 2653 |
| 2641 host_impl_->active_tree()->set_top_controls_delta(0.f); | 2654 host_impl_->active_tree()->set_top_controls_delta(0.f); |
| 2642 host_impl_->DidChangeTopControlsPosition(); | 2655 host_impl_->DidChangeTopControlsPosition(); |
| 2643 | 2656 |
| 2644 EXPECT_EQ(15.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 2657 EXPECT_EQ(50.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2645 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 0.f), root_clip_ptr->bounds_delta()); | 2658 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 0.f), root_clip_ptr->bounds_delta()); |
| 2646 EXPECT_EQ(gfx::Size(viewport_size_.width(), viewport_size_.height()-15.f), | 2659 EXPECT_EQ(gfx::Size(viewport_size_.width(), viewport_size_.height() - 50.f), |
| 2647 root_clip_ptr->bounds()); | 2660 root_clip_ptr->bounds()); |
| 2648 } | 2661 } |
| 2649 | 2662 |
| 2650 // Test that showing/hiding the top controls when the viewport is fully scrolled | 2663 // Test that showing/hiding the top controls when the viewport is fully scrolled |
| 2651 // doesn't incorrectly change the viewport offset due to clamping from changing | 2664 // doesn't incorrectly change the viewport offset due to clamping from changing |
| 2652 // viewport bounds. | 2665 // viewport bounds. |
| 2653 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsViewportOffsetClamping) { | 2666 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsViewportOffsetClamping) { |
| 2654 SetupTopControlsAndScrollLayerWithVirtualViewport( | 2667 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 2655 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); | 2668 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); |
| 2656 DrawFrame(); | 2669 DrawFrame(); |
| 2657 | 2670 |
| 2658 EXPECT_EQ(settings_.top_controls_height, | 2671 EXPECT_EQ(top_controls_height_, |
| 2659 host_impl_->active_tree()->total_top_controls_content_offset()); | 2672 host_impl_->active_tree()->total_top_controls_content_offset()); |
| 2660 | 2673 |
| 2661 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 2674 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
| 2662 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 2675 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
| 2663 | 2676 |
| 2664 // Scroll the viewports to max scroll offset. | 2677 // Scroll the viewports to max scroll offset. |
| 2665 outer_scroll->SetScrollDelta(gfx::Vector2dF(0, 200.f)); | 2678 outer_scroll->SetScrollDelta(gfx::Vector2dF(0, 200.f)); |
| 2666 inner_scroll->SetScrollDelta(gfx::Vector2dF(100, 100.f)); | 2679 inner_scroll->SetScrollDelta(gfx::Vector2dF(100, 100.f)); |
| 2667 | 2680 |
| 2668 gfx::ScrollOffset viewport_offset = | 2681 gfx::ScrollOffset viewport_offset = |
| 2669 host_impl_->active_tree()->TotalScrollOffset(); | 2682 host_impl_->active_tree()->TotalScrollOffset(); |
| 2670 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), viewport_offset); | 2683 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), viewport_offset); |
| 2671 | 2684 |
| 2672 // Hide the top controls by 25px. | 2685 // Hide the top controls by 25px. |
| 2673 gfx::Vector2dF scroll_delta(0.f, 25.f); | 2686 gfx::Vector2dF scroll_delta(0.f, 25.f); |
| 2674 EXPECT_EQ(InputHandler::ScrollStarted, | 2687 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2675 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 2688 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 2676 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2689 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 2677 | 2690 |
| 2678 // scrolling down at the max extents no longer hides the top controls | 2691 // scrolling down at the max extents no longer hides the top controls |
| 2679 EXPECT_EQ(0.f, | 2692 EXPECT_EQ(0.f, |
| 2680 settings_.top_controls_height - | 2693 top_controls_height_ - |
| 2681 host_impl_->active_tree()->total_top_controls_content_offset()); | 2694 host_impl_->active_tree()->total_top_controls_content_offset()); |
| 2682 | 2695 |
| 2683 // forcefully hide the top controls by 25px | 2696 // forcefully hide the top controls by 25px |
| 2684 host_impl_->top_controls_manager()->ScrollBy(scroll_delta); | 2697 host_impl_->top_controls_manager()->ScrollBy(scroll_delta); |
| 2685 host_impl_->ScrollEnd(); | 2698 host_impl_->ScrollEnd(); |
| 2686 | 2699 |
| 2687 EXPECT_EQ(scroll_delta.y(), | 2700 EXPECT_EQ(scroll_delta.y(), |
| 2688 settings_.top_controls_height - | 2701 top_controls_height_ - |
| 2689 host_impl_->active_tree()->total_top_controls_content_offset()); | 2702 host_impl_->active_tree()->total_top_controls_content_offset()); |
| 2690 | 2703 |
| 2691 inner_scroll->ClampScrollToMaxScrollOffset(); | 2704 inner_scroll->ClampScrollToMaxScrollOffset(); |
| 2692 outer_scroll->ClampScrollToMaxScrollOffset(); | 2705 outer_scroll->ClampScrollToMaxScrollOffset(); |
| 2693 | 2706 |
| 2694 // We should still be fully scrolled. | 2707 // We should still be fully scrolled. |
| 2695 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), | 2708 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), |
| 2696 host_impl_->active_tree()->TotalScrollOffset()); | 2709 host_impl_->active_tree()->TotalScrollOffset()); |
| 2697 | 2710 |
| 2698 viewport_offset = host_impl_->active_tree()->TotalScrollOffset(); | 2711 viewport_offset = host_impl_->active_tree()->TotalScrollOffset(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2715 host_impl_->active_tree()->TotalScrollOffset()); | 2728 host_impl_->active_tree()->TotalScrollOffset()); |
| 2716 } | 2729 } |
| 2717 | 2730 |
| 2718 // Test that the top controls coming in and out maintains the same aspect ratio | 2731 // Test that the top controls coming in and out maintains the same aspect ratio |
| 2719 // between the inner and outer viewports. | 2732 // between the inner and outer viewports. |
| 2720 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsAspectRatio) { | 2733 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsAspectRatio) { |
| 2721 SetupTopControlsAndScrollLayerWithVirtualViewport( | 2734 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 2722 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); | 2735 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); |
| 2723 DrawFrame(); | 2736 DrawFrame(); |
| 2724 | 2737 |
| 2725 EXPECT_EQ(settings_.top_controls_height, | 2738 EXPECT_EQ(top_controls_height_, |
| 2726 host_impl_->active_tree()->total_top_controls_content_offset()); | 2739 host_impl_->active_tree()->total_top_controls_content_offset()); |
| 2727 | 2740 |
| 2728 gfx::Vector2dF scroll_delta(0.f, 25.f); | 2741 gfx::Vector2dF scroll_delta(0.f, 25.f); |
| 2729 EXPECT_EQ(InputHandler::ScrollStarted, | 2742 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2730 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 2743 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 2731 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2744 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 2732 host_impl_->ScrollEnd(); | 2745 host_impl_->ScrollEnd(); |
| 2733 | 2746 |
| 2734 EXPECT_EQ(scroll_delta.y(), | 2747 EXPECT_EQ(scroll_delta.y(), |
| 2735 settings_.top_controls_height - | 2748 top_controls_height_ - |
| 2736 host_impl_->active_tree()->total_top_controls_content_offset()); | 2749 host_impl_->active_tree()->total_top_controls_content_offset()); |
| 2737 | 2750 |
| 2738 // Top controls were hidden by 25px so the inner viewport should have expanded | 2751 // Top controls were hidden by 25px so the inner viewport should have expanded |
| 2739 // by that much. | 2752 // by that much. |
| 2740 LayerImpl* outer_container = | 2753 LayerImpl* outer_container = |
| 2741 host_impl_->active_tree()->OuterViewportContainerLayer(); | 2754 host_impl_->active_tree()->OuterViewportContainerLayer(); |
| 2742 LayerImpl* inner_container = | 2755 LayerImpl* inner_container = |
| 2743 host_impl_->active_tree()->InnerViewportContainerLayer(); | 2756 host_impl_->active_tree()->InnerViewportContainerLayer(); |
| 2744 EXPECT_EQ(gfx::Size(100, 100+25), inner_container->BoundsForScrolling()); | 2757 EXPECT_EQ(gfx::Size(100, 100+25), inner_container->BoundsForScrolling()); |
| 2745 | 2758 |
| 2746 // Outer viewport should match inner's aspect ratio. The bounds are ceiled. | 2759 // Outer viewport should match inner's aspect ratio. The bounds are ceiled. |
| 2747 float aspect_ratio = inner_container->BoundsForScrolling().width() / | 2760 float aspect_ratio = inner_container->BoundsForScrolling().width() / |
| 2748 inner_container->BoundsForScrolling().height(); | 2761 inner_container->BoundsForScrolling().height(); |
| 2749 gfx::Size expected = gfx::ToCeiledSize(gfx::SizeF(200, 200 / aspect_ratio)); | 2762 gfx::Size expected = gfx::ToCeiledSize(gfx::SizeF(200, 200 / aspect_ratio)); |
| 2750 EXPECT_EQ(expected, outer_container->BoundsForScrolling()); | 2763 EXPECT_EQ(expected, outer_container->BoundsForScrolling()); |
| 2751 EXPECT_EQ(expected, | 2764 EXPECT_EQ(expected, |
| 2752 host_impl_->InnerViewportScrollLayer()->BoundsForScrolling()); | 2765 host_impl_->InnerViewportScrollLayer()->BoundsForScrolling()); |
| 2753 } | 2766 } |
| 2754 | 2767 |
| 2755 // Test that scrolling the outer viewport affects the top controls. | 2768 // Test that scrolling the outer viewport affects the top controls. |
| 2756 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsScrollOuterViewport) { | 2769 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsScrollOuterViewport) { |
| 2757 SetupTopControlsAndScrollLayerWithVirtualViewport( | 2770 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 2758 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); | 2771 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); |
| 2759 DrawFrame(); | 2772 DrawFrame(); |
| 2760 | 2773 |
| 2761 EXPECT_EQ(settings_.top_controls_height, | 2774 EXPECT_EQ(top_controls_height_, |
| 2762 host_impl_->active_tree()->total_top_controls_content_offset()); | 2775 host_impl_->active_tree()->total_top_controls_content_offset()); |
| 2763 | 2776 |
| 2764 // Send a gesture scroll that will scroll the outer viewport, make sure the | 2777 // Send a gesture scroll that will scroll the outer viewport, make sure the |
| 2765 // top controls get scrolled. | 2778 // top controls get scrolled. |
| 2766 gfx::Vector2dF scroll_delta(0.f, 15.f); | 2779 gfx::Vector2dF scroll_delta(0.f, 15.f); |
| 2767 EXPECT_EQ(InputHandler::ScrollStarted, | 2780 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2768 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 2781 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 2769 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2782 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 2770 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), | 2783 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), |
| 2771 host_impl_->CurrentlyScrollingLayer()); | 2784 host_impl_->CurrentlyScrollingLayer()); |
| 2772 host_impl_->ScrollEnd(); | 2785 host_impl_->ScrollEnd(); |
| 2773 | 2786 |
| 2774 EXPECT_EQ(scroll_delta.y(), | 2787 EXPECT_EQ(scroll_delta.y(), |
| 2775 settings_.top_controls_height - | 2788 top_controls_height_ - |
| 2776 host_impl_->active_tree()->total_top_controls_content_offset()); | 2789 host_impl_->active_tree()->total_top_controls_content_offset()); |
| 2777 | 2790 |
| 2778 scroll_delta = gfx::Vector2dF(0.f, 50.f); | 2791 scroll_delta = gfx::Vector2dF(0.f, 50.f); |
| 2779 EXPECT_EQ(InputHandler::ScrollStarted, | 2792 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2780 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 2793 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 2781 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2794 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 2782 | 2795 |
| 2783 EXPECT_EQ(0, host_impl_->active_tree()->total_top_controls_content_offset()); | 2796 EXPECT_EQ(0, host_impl_->active_tree()->total_top_controls_content_offset()); |
| 2784 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), | 2797 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), |
| 2785 host_impl_->CurrentlyScrollingLayer()); | 2798 host_impl_->CurrentlyScrollingLayer()); |
| 2786 | 2799 |
| 2787 host_impl_->ScrollEnd(); | 2800 host_impl_->ScrollEnd(); |
| 2788 | 2801 |
| 2789 // Position the viewports such that the inner viewport will be scrolled. | 2802 // Position the viewports such that the inner viewport will be scrolled. |
| 2790 gfx::Vector2dF inner_viewport_offset(0.f, 25.f); | 2803 gfx::Vector2dF inner_viewport_offset(0.f, 25.f); |
| 2791 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2dF()); | 2804 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2dF()); |
| 2792 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(inner_viewport_offset); | 2805 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(inner_viewport_offset); |
| 2793 | 2806 |
| 2794 scroll_delta = gfx::Vector2dF(0.f, -65.f); | 2807 scroll_delta = gfx::Vector2dF(0.f, -65.f); |
| 2795 EXPECT_EQ(InputHandler::ScrollStarted, | 2808 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2796 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 2809 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 2797 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2810 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 2798 | 2811 |
| 2799 EXPECT_EQ(settings_.top_controls_height, | 2812 EXPECT_EQ(top_controls_height_, |
| 2800 host_impl_->active_tree()->total_top_controls_content_offset()); | 2813 host_impl_->active_tree()->total_top_controls_content_offset()); |
| 2801 EXPECT_EQ(inner_viewport_offset.y() + | 2814 EXPECT_EQ( |
| 2802 (scroll_delta.y() + settings_.top_controls_height), | 2815 inner_viewport_offset.y() + (scroll_delta.y() + top_controls_height_), |
| 2803 host_impl_->InnerViewportScrollLayer()->ScrollDelta().y()); | 2816 host_impl_->InnerViewportScrollLayer()->ScrollDelta().y()); |
| 2804 | 2817 |
| 2805 host_impl_->ScrollEnd(); | 2818 host_impl_->ScrollEnd(); |
| 2806 } | 2819 } |
| 2807 | 2820 |
| 2808 TEST_F(LayerTreeHostImplTopControlsTest, | 2821 TEST_F(LayerTreeHostImplTopControlsTest, |
| 2809 ScrollNonScrollableRootWithTopControls) { | 2822 ScrollNonScrollableRootWithTopControls) { |
| 2810 CreateHostImpl(settings_, CreateOutputSurface()); | 2823 CreateHostImpl(settings_, CreateOutputSurface()); |
| 2811 SetupTopControlsAndScrollLayer(); | 2824 SetupTopControlsAndScrollLayer(); |
| 2812 DrawFrame(); | 2825 DrawFrame(); |
| 2813 | 2826 |
| (...skipping 4372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7186 EXPECT_EQ(2, set_needs_redraw_count); | 7199 EXPECT_EQ(2, set_needs_redraw_count); |
| 7187 EXPECT_EQ(1, forward_to_main_count); | 7200 EXPECT_EQ(1, forward_to_main_count); |
| 7188 } | 7201 } |
| 7189 } | 7202 } |
| 7190 | 7203 |
| 7191 class LayerTreeHostImplWithTopControlsTest : public LayerTreeHostImplTest { | 7204 class LayerTreeHostImplWithTopControlsTest : public LayerTreeHostImplTest { |
| 7192 public: | 7205 public: |
| 7193 void SetUp() override { | 7206 void SetUp() override { |
| 7194 LayerTreeSettings settings = DefaultSettings(); | 7207 LayerTreeSettings settings = DefaultSettings(); |
| 7195 settings.calculate_top_controls_position = true; | 7208 settings.calculate_top_controls_position = true; |
| 7196 settings.top_controls_height = top_controls_height_; | |
| 7197 CreateHostImpl(settings, CreateOutputSurface()); | 7209 CreateHostImpl(settings, CreateOutputSurface()); |
| 7210 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); |
| 7211 host_impl_->active_tree()->set_top_controls_delta(top_controls_height_); |
| 7212 host_impl_->top_controls_manager()->SetTopControlsHeight( |
| 7213 top_controls_height_); |
| 7198 } | 7214 } |
| 7199 | 7215 |
| 7200 protected: | 7216 protected: |
| 7201 static const int top_controls_height_; | 7217 static const int top_controls_height_; |
| 7202 }; | 7218 }; |
| 7203 | 7219 |
| 7204 const int LayerTreeHostImplWithTopControlsTest::top_controls_height_ = 50; | 7220 const int LayerTreeHostImplWithTopControlsTest::top_controls_height_ = 50; |
| 7205 | 7221 |
| 7206 TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) { | 7222 TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) { |
| 7207 SetupScrollAndContentsLayers(gfx::Size(100, 100)) | 7223 SetupScrollAndContentsLayers(gfx::Size(100, 100)) |
| 7208 ->SetScrollOffset(gfx::ScrollOffset(0, 10)); | 7224 ->SetScrollOffset(gfx::ScrollOffset(0, 10)); |
| 7209 host_impl_->Animate(base::TimeTicks()); | 7225 host_impl_->Animate(base::TimeTicks()); |
| 7210 EXPECT_FALSE(did_request_redraw_); | 7226 EXPECT_FALSE(did_request_redraw_); |
| 7211 } | 7227 } |
| 7212 | 7228 |
| 7229 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsHeightIsCommitted) { |
| 7230 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 7231 EXPECT_FALSE(did_request_redraw_); |
| 7232 host_impl_->CreatePendingTree(); |
| 7233 host_impl_->sync_tree()->set_top_controls_height(100); |
| 7234 host_impl_->ActivateSyncTree(); |
| 7235 EXPECT_EQ(100, host_impl_->top_controls_manager()->top_controls_height()); |
| 7236 } |
| 7237 |
| 7238 TEST_F(LayerTreeHostImplWithTopControlsTest, |
| 7239 TopControlsStayFullyVisibleOnHeightChange) { |
| 7240 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 7241 EXPECT_EQ(0.f, host_impl_->ControlsTopOffset()); |
| 7242 |
| 7243 host_impl_->CreatePendingTree(); |
| 7244 host_impl_->sync_tree()->set_top_controls_height(0); |
| 7245 host_impl_->ActivateSyncTree(); |
| 7246 EXPECT_EQ(0.f, host_impl_->ControlsTopOffset()); |
| 7247 |
| 7248 host_impl_->CreatePendingTree(); |
| 7249 host_impl_->sync_tree()->set_top_controls_height(50); |
| 7250 host_impl_->ActivateSyncTree(); |
| 7251 EXPECT_EQ(0.f, host_impl_->ControlsTopOffset()); |
| 7252 } |
| 7253 |
| 7213 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationScheduling) { | 7254 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationScheduling) { |
| 7214 SetupScrollAndContentsLayers(gfx::Size(100, 100)) | 7255 SetupScrollAndContentsLayers(gfx::Size(100, 100)) |
| 7215 ->SetScrollOffset(gfx::ScrollOffset(0, 10)); | 7256 ->SetScrollOffset(gfx::ScrollOffset(0, 10)); |
| 7216 host_impl_->DidChangeTopControlsPosition(); | 7257 host_impl_->DidChangeTopControlsPosition(); |
| 7217 EXPECT_TRUE(did_request_animate_); | 7258 EXPECT_TRUE(did_request_animate_); |
| 7218 EXPECT_TRUE(did_request_redraw_); | 7259 EXPECT_TRUE(did_request_redraw_); |
| 7219 } | 7260 } |
| 7220 | 7261 |
| 7221 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { | 7262 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { |
| 7222 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 7263 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7842 // surface. | 7883 // surface. |
| 7843 EXPECT_EQ(0, num_lost_surfaces_); | 7884 EXPECT_EQ(0, num_lost_surfaces_); |
| 7844 host_impl_->DidLoseOutputSurface(); | 7885 host_impl_->DidLoseOutputSurface(); |
| 7845 EXPECT_EQ(1, num_lost_surfaces_); | 7886 EXPECT_EQ(1, num_lost_surfaces_); |
| 7846 host_impl_->DidLoseOutputSurface(); | 7887 host_impl_->DidLoseOutputSurface(); |
| 7847 EXPECT_LE(1, num_lost_surfaces_); | 7888 EXPECT_LE(1, num_lost_surfaces_); |
| 7848 } | 7889 } |
| 7849 | 7890 |
| 7850 } // namespace | 7891 } // namespace |
| 7851 } // namespace cc | 7892 } // namespace cc |
| OLD | NEW |