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 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1418 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(-10, 10)).get()) | 1418 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(-10, 10)).get()) |
1419 .did_scroll); | 1419 .did_scroll); |
1420 | 1420 |
1421 // Trying to scroll more than the available space will also succeed. | 1421 // Trying to scroll more than the available space will also succeed. |
1422 EXPECT_TRUE( | 1422 EXPECT_TRUE( |
1423 host_impl_ | 1423 host_impl_ |
1424 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(5000, 5000)).get()) | 1424 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(5000, 5000)).get()) |
1425 .did_scroll); | 1425 .did_scroll); |
1426 } | 1426 } |
1427 | 1427 |
| 1428 TEST_F(LayerTreeHostImplTest, ScrollBoundaryBehaviorPreventsPropagation) { |
| 1429 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 1430 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 1431 |
| 1432 gfx::Size overflow_size(400, 400); |
| 1433 ASSERT_EQ(1u, scroll_layer->test_properties()->children.size()); |
| 1434 LayerImpl* overflow = scroll_layer->test_properties()->children[0]; |
| 1435 overflow->SetBounds(overflow_size); |
| 1436 overflow->SetScrollable(gfx::Size(100, 100)); |
| 1437 overflow->SetElementId(LayerIdToElementIdForTesting(overflow->id())); |
| 1438 overflow->layer_tree_impl() |
| 1439 ->property_trees() |
| 1440 ->scroll_tree.UpdateScrollOffsetBaseForTesting(overflow->element_id(), |
| 1441 gfx::ScrollOffset()); |
| 1442 overflow->SetPosition(gfx::PointF(40, 40)); |
| 1443 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1444 scroll_layer->SetCurrentScrollOffset(gfx::ScrollOffset(30, 30)); |
| 1445 |
| 1446 DrawFrame(); |
| 1447 gfx::Point scroll_position(50, 50); |
| 1448 |
| 1449 // ScrollBoundaryBehaviorTypeAuto shouldn't prevent scroll propagation. |
| 1450 EXPECT_EQ( |
| 1451 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 1452 host_impl_ |
| 1453 ->ScrollBegin(BeginState(scroll_position).get(), InputHandler::WHEEL) |
| 1454 .thread); |
| 1455 EXPECT_VECTOR_EQ(gfx::Vector2dF(30, 30), scroll_layer->CurrentScrollOffset()); |
| 1456 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->CurrentScrollOffset()); |
| 1457 |
| 1458 gfx::Vector2dF x_dominant_delta(-10, -5); |
| 1459 gfx::Vector2dF y_dominant_delta(-5, -10); |
| 1460 host_impl_->ScrollBy(UpdateState(scroll_position, x_dominant_delta).get()); |
| 1461 host_impl_->ScrollEnd(EndState().get()); |
| 1462 EXPECT_VECTOR_EQ(gfx::Vector2dF(20, 25), scroll_layer->CurrentScrollOffset()); |
| 1463 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), overflow->CurrentScrollOffset()); |
| 1464 |
| 1465 overflow->test_properties()->scroll_boundary_behavior = |
| 1466 ScrollBoundaryBehavior( |
| 1467 ScrollBoundaryBehavior::kScrollBoundaryBehaviorTypeNone, |
| 1468 ScrollBoundaryBehavior::kScrollBoundaryBehaviorTypeAuto); |
| 1469 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1470 |
| 1471 DrawFrame(); |
| 1472 |
| 1473 // ScrollBoundaryBehaviorNone on x should prevent x-dominant-scroll |
| 1474 // propagation. |
| 1475 EXPECT_EQ( |
| 1476 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 1477 host_impl_ |
| 1478 ->ScrollBegin(BeginState(scroll_position).get(), InputHandler::WHEEL) |
| 1479 .thread); |
| 1480 EXPECT_VECTOR_EQ(gfx::Vector2dF(20, 25), scroll_layer->CurrentScrollOffset()); |
| 1481 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), overflow->CurrentScrollOffset()); |
| 1482 |
| 1483 host_impl_->ScrollBy(UpdateState(scroll_position, x_dominant_delta).get()); |
| 1484 host_impl_->ScrollEnd(EndState().get()); |
| 1485 EXPECT_VECTOR_EQ(gfx::Vector2dF(20, 25), scroll_layer->CurrentScrollOffset()); |
| 1486 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), overflow->CurrentScrollOffset()); |
| 1487 |
| 1488 // ScrollBoundaryBehaviorNone on x shouldn't prevent y-dominant-scroll |
| 1489 // propagation. |
| 1490 EXPECT_EQ( |
| 1491 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 1492 host_impl_ |
| 1493 ->ScrollBegin(BeginState(scroll_position).get(), InputHandler::WHEEL) |
| 1494 .thread); |
| 1495 EXPECT_VECTOR_EQ(gfx::Vector2dF(20, 25), scroll_layer->CurrentScrollOffset()); |
| 1496 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), overflow->CurrentScrollOffset()); |
| 1497 |
| 1498 host_impl_->ScrollBy(UpdateState(scroll_position, y_dominant_delta).get()); |
| 1499 host_impl_->ScrollEnd(EndState().get()); |
| 1500 EXPECT_VECTOR_EQ(gfx::Vector2dF(15, 15), scroll_layer->CurrentScrollOffset()); |
| 1501 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), overflow->CurrentScrollOffset()); |
| 1502 |
| 1503 overflow->test_properties()->scroll_boundary_behavior = |
| 1504 ScrollBoundaryBehavior( |
| 1505 ScrollBoundaryBehavior::kScrollBoundaryBehaviorTypeAuto, |
| 1506 ScrollBoundaryBehavior::kScrollBoundaryBehaviorTypeNone); |
| 1507 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1508 |
| 1509 DrawFrame(); |
| 1510 |
| 1511 // ScrollBoundaryBehaviorNone on y shouldn't prevent x-dominant-scroll |
| 1512 // propagation. |
| 1513 EXPECT_EQ( |
| 1514 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 1515 host_impl_ |
| 1516 ->ScrollBegin(BeginState(scroll_position).get(), InputHandler::WHEEL) |
| 1517 .thread); |
| 1518 EXPECT_VECTOR_EQ(gfx::Vector2dF(15, 15), scroll_layer->CurrentScrollOffset()); |
| 1519 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), overflow->CurrentScrollOffset()); |
| 1520 |
| 1521 host_impl_->ScrollBy(UpdateState(scroll_position, x_dominant_delta).get()); |
| 1522 host_impl_->ScrollEnd(EndState().get()); |
| 1523 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 10), scroll_layer->CurrentScrollOffset()); |
| 1524 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), overflow->CurrentScrollOffset()); |
| 1525 |
| 1526 // ScrollBoundaryBehaviorNone on y should prevent y-dominant-scroll |
| 1527 // propagation. |
| 1528 EXPECT_EQ( |
| 1529 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 1530 host_impl_ |
| 1531 ->ScrollBegin(BeginState(scroll_position).get(), InputHandler::WHEEL) |
| 1532 .thread); |
| 1533 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 10), scroll_layer->CurrentScrollOffset()); |
| 1534 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), overflow->CurrentScrollOffset()); |
| 1535 |
| 1536 host_impl_->ScrollBy(UpdateState(scroll_position, y_dominant_delta).get()); |
| 1537 host_impl_->ScrollEnd(EndState().get()); |
| 1538 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 10), scroll_layer->CurrentScrollOffset()); |
| 1539 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), overflow->CurrentScrollOffset()); |
| 1540 } |
| 1541 |
1428 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { | 1542 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { |
1429 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1543 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
1430 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1544 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
1431 | 1545 |
1432 gfx::Size overflow_size(400, 400); | 1546 gfx::Size overflow_size(400, 400); |
1433 ASSERT_EQ(1u, scroll_layer->test_properties()->children.size()); | 1547 ASSERT_EQ(1u, scroll_layer->test_properties()->children.size()); |
1434 LayerImpl* overflow = scroll_layer->test_properties()->children[0]; | 1548 LayerImpl* overflow = scroll_layer->test_properties()->children[0]; |
1435 overflow->SetBounds(overflow_size); | 1549 overflow->SetBounds(overflow_size); |
1436 overflow->SetScrollable(gfx::Size(100, 100)); | 1550 overflow->SetScrollable(gfx::Size(100, 100)); |
1437 overflow->SetElementId(LayerIdToElementIdForTesting(overflow->id())); | 1551 overflow->SetElementId(LayerIdToElementIdForTesting(overflow->id())); |
(...skipping 11221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12659 // layer should be prioritized over the hidden layer. | 12773 // layer should be prioritized over the hidden layer. |
12660 hidden_layer->set_contributes_to_drawn_render_surface(false); | 12774 hidden_layer->set_contributes_to_drawn_render_surface(false); |
12661 hidden_layer->set_raster_even_if_not_drawn(true); | 12775 hidden_layer->set_raster_even_if_not_drawn(true); |
12662 queue = host_impl_->BuildRasterQueue(TreePriority::SMOOTHNESS_TAKES_PRIORITY, | 12776 queue = host_impl_->BuildRasterQueue(TreePriority::SMOOTHNESS_TAKES_PRIORITY, |
12663 RasterTilePriorityQueue::Type::ALL); | 12777 RasterTilePriorityQueue::Type::ALL); |
12664 EXPECT_EQ(queue->Top().tile()->layer_id(), 3); | 12778 EXPECT_EQ(queue->Top().tile()->layer_id(), 3); |
12665 } | 12779 } |
12666 | 12780 |
12667 } // namespace | 12781 } // namespace |
12668 } // namespace cc | 12782 } // namespace cc |
OLD | NEW |