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

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

Issue 2839533002: Remove Layer/LayerImpl's FixedContainerSizeDelta (Closed)
Patch Set: Remove FixedContainerSizeDelta Created 3 years, 8 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
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 4426 matching lines...) Expand 10 before | Expand all | Expand 10 after
4437 .thread); 4437 .thread);
4438 4438
4439 // Make the test scroll delta a fractional amount, to verify that the 4439 // Make the test scroll delta a fractional amount, to verify that the
4440 // fixed container size delta is (1) non-zero, and (2) fractional, and 4440 // fixed container size delta is (1) non-zero, and (2) fractional, and
4441 // (3) matches the movement of the browser controls. 4441 // (3) matches the movement of the browser controls.
4442 gfx::Vector2dF top_controls_scroll_delta(0.f, 5.25f); 4442 gfx::Vector2dF top_controls_scroll_delta(0.f, 5.25f);
4443 host_impl_->browser_controls_manager()->ScrollBegin(); 4443 host_impl_->browser_controls_manager()->ScrollBegin();
4444 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta); 4444 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta);
4445 host_impl_->browser_controls_manager()->ScrollEnd(); 4445 host_impl_->browser_controls_manager()->ScrollEnd();
4446 4446
4447 LayerImpl* inner_viewport_scroll_layer =
4448 host_impl_->active_tree()->InnerViewportScrollLayer();
4449 DCHECK(inner_viewport_scroll_layer);
4450 host_impl_->ScrollEnd(EndState().get()); 4447 host_impl_->ScrollEnd(EndState().get());
4448 auto* property_trees = host_impl_->active_tree()->property_trees();
4451 EXPECT_FLOAT_EQ(top_controls_scroll_delta.y(), 4449 EXPECT_FLOAT_EQ(top_controls_scroll_delta.y(),
4452 inner_viewport_scroll_layer->FixedContainerSizeDelta().y()); 4450 property_trees->inner_viewport_container_bounds_delta().y());
4453 } 4451 }
4454 4452
4455 // In this test, the outer viewport is initially unscrollable. We test that a 4453 // In this test, the outer viewport is initially unscrollable. We test that a
4456 // scroll initiated on the inner viewport, causing the browser controls to show 4454 // scroll initiated on the inner viewport, causing the browser controls to show
4457 // and thus making the outer viewport scrollable, still scrolls the outer 4455 // and thus making the outer viewport scrollable, still scrolls the outer
4458 // viewport. 4456 // viewport.
4459 TEST_F(LayerTreeHostImplBrowserControlsTest, 4457 TEST_F(LayerTreeHostImplBrowserControlsTest,
4460 BrowserControlsOuterViewportBecomesScrollable) { 4458 BrowserControlsOuterViewportBecomesScrollable) {
4461 SetupBrowserControlsAndScrollLayerWithVirtualViewport( 4459 SetupBrowserControlsAndScrollLayerWithVirtualViewport(
4462 gfx::Size(10, 50), gfx::Size(10, 50), gfx::Size(10, 100)); 4460 gfx::Size(10, 50), gfx::Size(10, 50), gfx::Size(10, 100));
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
4543 4541
4544 // Test that the fixed position container delta is appropriately adjusted 4542 // Test that the fixed position container delta is appropriately adjusted
4545 // by the browser controls showing/hiding and page scale doesn't affect it. 4543 // by the browser controls showing/hiding and page scale doesn't affect it.
4546 TEST_F(LayerTreeHostImplBrowserControlsTest, FixedContainerDelta) { 4544 TEST_F(LayerTreeHostImplBrowserControlsTest, FixedContainerDelta) {
4547 SetupBrowserControlsAndScrollLayerWithVirtualViewport( 4545 SetupBrowserControlsAndScrollLayerWithVirtualViewport(
4548 gfx::Size(100, 100), gfx::Size(100, 100), gfx::Size(100, 100)); 4546 gfx::Size(100, 100), gfx::Size(100, 100), gfx::Size(100, 100));
4549 DrawFrame(); 4547 DrawFrame();
4550 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); 4548 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f);
4551 4549
4552 float page_scale = 1.5f; 4550 float page_scale = 1.5f;
4553 LayerImpl* outer_viewport_scroll_layer =
4554 host_impl_->active_tree()->OuterViewportScrollLayer();
4555
4556 // Zoom in, since the fixed container is the outer viewport, the delta should 4551 // Zoom in, since the fixed container is the outer viewport, the delta should
4557 // not be scaled. 4552 // not be scaled.
4558 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 2.f); 4553 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 2.f);
4559 4554
4560 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 4555 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
4561 host_impl_ 4556 host_impl_
4562 ->ScrollBegin(BeginState(gfx::Point()).get(), 4557 ->ScrollBegin(BeginState(gfx::Point()).get(),
4563 InputHandler::TOUCHSCREEN) 4558 InputHandler::TOUCHSCREEN)
4564 .thread); 4559 .thread);
4565 4560
4566 // Scroll down, the browser controls hiding should expand the viewport size so 4561 // Scroll down, the browser controls hiding should expand the viewport size so
4567 // the delta should be equal to the scroll distance. 4562 // the delta should be equal to the scroll distance.
4568 gfx::Vector2dF top_controls_scroll_delta(0.f, 20.f); 4563 gfx::Vector2dF top_controls_scroll_delta(0.f, 20.f);
4569 host_impl_->browser_controls_manager()->ScrollBegin(); 4564 host_impl_->browser_controls_manager()->ScrollBegin();
4570 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta); 4565 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta);
4571 EXPECT_FLOAT_EQ(top_controls_height_ - top_controls_scroll_delta.y(), 4566 EXPECT_FLOAT_EQ(top_controls_height_ - top_controls_scroll_delta.y(),
4572 host_impl_->browser_controls_manager()->ContentTopOffset()); 4567 host_impl_->browser_controls_manager()->ContentTopOffset());
4568
4569 auto* property_trees = host_impl_->active_tree()->property_trees();
4573 EXPECT_FLOAT_EQ(top_controls_scroll_delta.y(), 4570 EXPECT_FLOAT_EQ(top_controls_scroll_delta.y(),
4574 outer_viewport_scroll_layer->FixedContainerSizeDelta().y()); 4571 property_trees->outer_viewport_container_bounds_delta().y());
4575 host_impl_->ScrollEnd(EndState().get()); 4572 host_impl_->ScrollEnd(EndState().get());
4576 4573
4577 // Scroll past the maximum extent. The delta shouldn't be greater than the 4574 // Scroll past the maximum extent. The delta shouldn't be greater than the
4578 // browser controls height. 4575 // browser controls height.
4579 host_impl_->browser_controls_manager()->ScrollBegin(); 4576 host_impl_->browser_controls_manager()->ScrollBegin();
4580 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta); 4577 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta);
4581 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta); 4578 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta);
4582 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta); 4579 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta);
4583 EXPECT_EQ(0.f, host_impl_->browser_controls_manager()->ContentTopOffset()); 4580 EXPECT_EQ(0.f, host_impl_->browser_controls_manager()->ContentTopOffset());
4584 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, top_controls_height_), 4581 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, top_controls_height_),
4585 outer_viewport_scroll_layer->FixedContainerSizeDelta()); 4582 property_trees->outer_viewport_container_bounds_delta());
4586 host_impl_->ScrollEnd(EndState().get()); 4583 host_impl_->ScrollEnd(EndState().get());
4587 4584
4588 // Scroll in the direction to make the browser controls show. 4585 // Scroll in the direction to make the browser controls show.
4589 host_impl_->browser_controls_manager()->ScrollBegin(); 4586 host_impl_->browser_controls_manager()->ScrollBegin();
4590 host_impl_->browser_controls_manager()->ScrollBy(-top_controls_scroll_delta); 4587 host_impl_->browser_controls_manager()->ScrollBy(-top_controls_scroll_delta);
4591 EXPECT_EQ(top_controls_scroll_delta.y(), 4588 EXPECT_EQ(top_controls_scroll_delta.y(),
4592 host_impl_->browser_controls_manager()->ContentTopOffset()); 4589 host_impl_->browser_controls_manager()->ContentTopOffset());
4593 EXPECT_VECTOR_EQ( 4590 EXPECT_VECTOR_EQ(
4594 gfx::Vector2dF(0, top_controls_height_ - top_controls_scroll_delta.y()), 4591 gfx::Vector2dF(0, top_controls_height_ - top_controls_scroll_delta.y()),
4595 outer_viewport_scroll_layer->FixedContainerSizeDelta()); 4592 property_trees->outer_viewport_container_bounds_delta());
4596 host_impl_->browser_controls_manager()->ScrollEnd(); 4593 host_impl_->browser_controls_manager()->ScrollEnd();
4597 } 4594 }
4598 4595
4599 // Push a browser controls ratio from the main thread that we didn't send as a 4596 // Push a browser controls ratio from the main thread that we didn't send as a
4600 // delta and make sure that the ratio is clamped to the [0, 1] range. 4597 // delta and make sure that the ratio is clamped to the [0, 1] range.
4601 TEST_F(LayerTreeHostImplBrowserControlsTest, BrowserControlsPushUnsentRatio) { 4598 TEST_F(LayerTreeHostImplBrowserControlsTest, BrowserControlsPushUnsentRatio) {
4602 SetupBrowserControlsAndScrollLayerWithVirtualViewport( 4599 SetupBrowserControlsAndScrollLayerWithVirtualViewport(
4603 gfx::Size(10, 50), gfx::Size(10, 50), gfx::Size(10, 100)); 4600 gfx::Size(10, 50), gfx::Size(10, 50), gfx::Size(10, 100));
4604 DrawFrame(); 4601 DrawFrame();
4605 4602
(...skipping 7772 matching lines...) Expand 10 before | Expand all | Expand 10 after
12378 else 12375 else
12379 EXPECT_FALSE(tile->HasRasterTask()); 12376 EXPECT_FALSE(tile->HasRasterTask());
12380 } 12377 }
12381 Region expected_invalidation( 12378 Region expected_invalidation(
12382 raster_source->GetRectForImage(checkerable_image->uniqueID())); 12379 raster_source->GetRectForImage(checkerable_image->uniqueID()));
12383 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); 12380 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation()));
12384 } 12381 }
12385 12382
12386 } // namespace 12383 } // namespace
12387 } // namespace cc 12384 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698