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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 4407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4418 ASSERT_EQ(gfx::Size(50, 100), inner_container->bounds()); | 4418 ASSERT_EQ(gfx::Size(50, 100), inner_container->bounds()); |
4419 ASSERT_EQ(gfx::Size(50, 100), outer_container->bounds()); | 4419 ASSERT_EQ(gfx::Size(50, 100), outer_container->bounds()); |
4420 EXPECT_EQ(gfx::SizeF(50, 100), active_tree->ScrollableSize()); | 4420 EXPECT_EQ(gfx::SizeF(50, 100), active_tree->ScrollableSize()); |
4421 EXPECT_EQ(gfx::SizeF(50, 50), content->BoundsForScrolling()); | 4421 EXPECT_EQ(gfx::SizeF(50, 50), content->BoundsForScrolling()); |
4422 } | 4422 } |
4423 | 4423 |
4424 host_impl_->browser_controls_manager()->ScrollEnd(); | 4424 host_impl_->browser_controls_manager()->ScrollEnd(); |
4425 host_impl_->ScrollEnd(EndState().get()); | 4425 host_impl_->ScrollEnd(EndState().get()); |
4426 } | 4426 } |
4427 | 4427 |
4428 namespace { | |
4429 | |
4430 gfx::Vector2dF FixedContainerSizeDelta(LayerImpl* scroll_layer) { | |
4431 auto* layer_tree_impl = scroll_layer->layer_tree_impl(); | |
4432 auto* property_trees = layer_tree_impl->property_trees(); | |
4433 if (auto* inner = layer_tree_impl->InnerViewportContainerLayer()) { | |
4434 if (inner->element_id() == scroll_layer->scroll_clip_layer()->element_id()) | |
4435 return property_trees->inner_viewport_container_bounds_delta(); | |
4436 } | |
4437 if (auto* outer = layer_tree_impl->OuterViewportContainerLayer()) { | |
4438 if (outer->element_id() == scroll_layer->scroll_clip_layer()->element_id()) | |
4439 return property_trees->outer_viewport_container_bounds_delta(); | |
4440 } | |
4441 | |
4442 return gfx::Vector2dF(); | |
4443 } | |
4444 | |
4445 }; // namespace | |
enne (OOO)
2017/04/25 00:52:20
s/;//
pdr.
2017/04/26 21:29:01
Done, kinda. And more!
| |
4446 | |
4428 TEST_F(LayerTreeHostImplBrowserControlsTest, | 4447 TEST_F(LayerTreeHostImplBrowserControlsTest, |
4429 ScrollBrowserControlsByFractionalAmount) { | 4448 ScrollBrowserControlsByFractionalAmount) { |
4430 SetupBrowserControlsAndScrollLayerWithVirtualViewport( | 4449 SetupBrowserControlsAndScrollLayerWithVirtualViewport( |
4431 gfx::Size(10, 10), gfx::Size(10, 10), gfx::Size(10, 10)); | 4450 gfx::Size(10, 10), gfx::Size(10, 10), gfx::Size(10, 10)); |
4432 DrawFrame(); | 4451 DrawFrame(); |
4433 | 4452 |
4434 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4453 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
4435 host_impl_ | 4454 host_impl_ |
4436 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4455 ->ScrollBegin(BeginState(gfx::Point()).get(), |
4437 InputHandler::TOUCHSCREEN) | 4456 InputHandler::TOUCHSCREEN) |
4438 .thread); | 4457 .thread); |
4439 | 4458 |
4440 // Make the test scroll delta a fractional amount, to verify that the | 4459 // Make the test scroll delta a fractional amount, to verify that the |
4441 // fixed container size delta is (1) non-zero, and (2) fractional, and | 4460 // fixed container size delta is (1) non-zero, and (2) fractional, and |
4442 // (3) matches the movement of the browser controls. | 4461 // (3) matches the movement of the browser controls. |
4443 gfx::Vector2dF top_controls_scroll_delta(0.f, 5.25f); | 4462 gfx::Vector2dF top_controls_scroll_delta(0.f, 5.25f); |
4444 host_impl_->browser_controls_manager()->ScrollBegin(); | 4463 host_impl_->browser_controls_manager()->ScrollBegin(); |
4445 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta); | 4464 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta); |
4446 host_impl_->browser_controls_manager()->ScrollEnd(); | 4465 host_impl_->browser_controls_manager()->ScrollEnd(); |
4447 | 4466 |
4448 LayerImpl* inner_viewport_scroll_layer = | 4467 LayerImpl* inner_viewport_scroll_layer = |
4449 host_impl_->active_tree()->InnerViewportScrollLayer(); | 4468 host_impl_->active_tree()->InnerViewportScrollLayer(); |
4450 DCHECK(inner_viewport_scroll_layer); | 4469 DCHECK(inner_viewport_scroll_layer); |
4451 host_impl_->ScrollEnd(EndState().get()); | 4470 host_impl_->ScrollEnd(EndState().get()); |
4452 EXPECT_FLOAT_EQ(top_controls_scroll_delta.y(), | 4471 EXPECT_FLOAT_EQ(top_controls_scroll_delta.y(), |
4453 inner_viewport_scroll_layer->FixedContainerSizeDelta().y()); | 4472 FixedContainerSizeDelta(inner_viewport_scroll_layer).y()); |
enne (OOO)
2017/04/25 00:52:20
Can you remove the helper and just say property_tr
pdr.
2017/04/26 21:29:01
This is a real good idea. I was focused on the goa
| |
4454 } | 4473 } |
4455 | 4474 |
4456 // In this test, the outer viewport is initially unscrollable. We test that a | 4475 // In this test, the outer viewport is initially unscrollable. We test that a |
4457 // scroll initiated on the inner viewport, causing the browser controls to show | 4476 // scroll initiated on the inner viewport, causing the browser controls to show |
4458 // and thus making the outer viewport scrollable, still scrolls the outer | 4477 // and thus making the outer viewport scrollable, still scrolls the outer |
4459 // viewport. | 4478 // viewport. |
4460 TEST_F(LayerTreeHostImplBrowserControlsTest, | 4479 TEST_F(LayerTreeHostImplBrowserControlsTest, |
4461 BrowserControlsOuterViewportBecomesScrollable) { | 4480 BrowserControlsOuterViewportBecomesScrollable) { |
4462 SetupBrowserControlsAndScrollLayerWithVirtualViewport( | 4481 SetupBrowserControlsAndScrollLayerWithVirtualViewport( |
4463 gfx::Size(10, 50), gfx::Size(10, 50), gfx::Size(10, 100)); | 4482 gfx::Size(10, 50), gfx::Size(10, 50), gfx::Size(10, 100)); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4565 .thread); | 4584 .thread); |
4566 | 4585 |
4567 // Scroll down, the browser controls hiding should expand the viewport size so | 4586 // Scroll down, the browser controls hiding should expand the viewport size so |
4568 // the delta should be equal to the scroll distance. | 4587 // the delta should be equal to the scroll distance. |
4569 gfx::Vector2dF top_controls_scroll_delta(0.f, 20.f); | 4588 gfx::Vector2dF top_controls_scroll_delta(0.f, 20.f); |
4570 host_impl_->browser_controls_manager()->ScrollBegin(); | 4589 host_impl_->browser_controls_manager()->ScrollBegin(); |
4571 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta); | 4590 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta); |
4572 EXPECT_FLOAT_EQ(top_controls_height_ - top_controls_scroll_delta.y(), | 4591 EXPECT_FLOAT_EQ(top_controls_height_ - top_controls_scroll_delta.y(), |
4573 host_impl_->browser_controls_manager()->ContentTopOffset()); | 4592 host_impl_->browser_controls_manager()->ContentTopOffset()); |
4574 EXPECT_FLOAT_EQ(top_controls_scroll_delta.y(), | 4593 EXPECT_FLOAT_EQ(top_controls_scroll_delta.y(), |
4575 outer_viewport_scroll_layer->FixedContainerSizeDelta().y()); | 4594 FixedContainerSizeDelta(outer_viewport_scroll_layer).y()); |
4576 host_impl_->ScrollEnd(EndState().get()); | 4595 host_impl_->ScrollEnd(EndState().get()); |
4577 | 4596 |
4578 // Scroll past the maximum extent. The delta shouldn't be greater than the | 4597 // Scroll past the maximum extent. The delta shouldn't be greater than the |
4579 // browser controls height. | 4598 // browser controls height. |
4580 host_impl_->browser_controls_manager()->ScrollBegin(); | 4599 host_impl_->browser_controls_manager()->ScrollBegin(); |
4581 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta); | 4600 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta); |
4582 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta); | 4601 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta); |
4583 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta); | 4602 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta); |
4584 EXPECT_EQ(0.f, host_impl_->browser_controls_manager()->ContentTopOffset()); | 4603 EXPECT_EQ(0.f, host_impl_->browser_controls_manager()->ContentTopOffset()); |
4585 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, top_controls_height_), | 4604 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, top_controls_height_), |
4586 outer_viewport_scroll_layer->FixedContainerSizeDelta()); | 4605 FixedContainerSizeDelta(outer_viewport_scroll_layer)); |
4587 host_impl_->ScrollEnd(EndState().get()); | 4606 host_impl_->ScrollEnd(EndState().get()); |
4588 | 4607 |
4589 // Scroll in the direction to make the browser controls show. | 4608 // Scroll in the direction to make the browser controls show. |
4590 host_impl_->browser_controls_manager()->ScrollBegin(); | 4609 host_impl_->browser_controls_manager()->ScrollBegin(); |
4591 host_impl_->browser_controls_manager()->ScrollBy(-top_controls_scroll_delta); | 4610 host_impl_->browser_controls_manager()->ScrollBy(-top_controls_scroll_delta); |
4592 EXPECT_EQ(top_controls_scroll_delta.y(), | 4611 EXPECT_EQ(top_controls_scroll_delta.y(), |
4593 host_impl_->browser_controls_manager()->ContentTopOffset()); | 4612 host_impl_->browser_controls_manager()->ContentTopOffset()); |
4594 EXPECT_VECTOR_EQ( | 4613 EXPECT_VECTOR_EQ( |
4595 gfx::Vector2dF(0, top_controls_height_ - top_controls_scroll_delta.y()), | 4614 gfx::Vector2dF(0, top_controls_height_ - top_controls_scroll_delta.y()), |
4596 outer_viewport_scroll_layer->FixedContainerSizeDelta()); | 4615 FixedContainerSizeDelta(outer_viewport_scroll_layer)); |
4597 host_impl_->browser_controls_manager()->ScrollEnd(); | 4616 host_impl_->browser_controls_manager()->ScrollEnd(); |
4598 } | 4617 } |
4599 | 4618 |
4600 // Push a browser controls ratio from the main thread that we didn't send as a | 4619 // Push a browser controls ratio from the main thread that we didn't send as a |
4601 // delta and make sure that the ratio is clamped to the [0, 1] range. | 4620 // delta and make sure that the ratio is clamped to the [0, 1] range. |
4602 TEST_F(LayerTreeHostImplBrowserControlsTest, BrowserControlsPushUnsentRatio) { | 4621 TEST_F(LayerTreeHostImplBrowserControlsTest, BrowserControlsPushUnsentRatio) { |
4603 SetupBrowserControlsAndScrollLayerWithVirtualViewport( | 4622 SetupBrowserControlsAndScrollLayerWithVirtualViewport( |
4604 gfx::Size(10, 50), gfx::Size(10, 50), gfx::Size(10, 100)); | 4623 gfx::Size(10, 50), gfx::Size(10, 50), gfx::Size(10, 100)); |
4605 DrawFrame(); | 4624 DrawFrame(); |
4606 | 4625 |
(...skipping 7773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12380 else | 12399 else |
12381 EXPECT_FALSE(tile->HasRasterTask()); | 12400 EXPECT_FALSE(tile->HasRasterTask()); |
12382 } | 12401 } |
12383 Region expected_invalidation( | 12402 Region expected_invalidation( |
12384 raster_source->GetRectForImage(checkerable_image->uniqueID())); | 12403 raster_source->GetRectForImage(checkerable_image->uniqueID())); |
12385 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); | 12404 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); |
12386 } | 12405 } |
12387 | 12406 |
12388 } // namespace | 12407 } // namespace |
12389 } // namespace cc | 12408 } // namespace cc |
OLD | NEW |