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

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

Issue 1766053002: Clean LayerImpl's scroll offset callers in unit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove transform tree update setting Created 4 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 220
221 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { 221 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) {
222 root->SetPosition(gfx::PointF()); 222 root->SetPosition(gfx::PointF());
223 root->SetBounds(gfx::Size(10, 10)); 223 root->SetBounds(gfx::Size(10, 10));
224 root->SetDrawsContent(true); 224 root->SetDrawsContent(true);
225 root->draw_properties().visible_layer_rect = gfx::Rect(0, 0, 10, 10); 225 root->draw_properties().visible_layer_rect = gfx::Rect(0, 0, 10, 10);
226 root->SetForceRenderSurface(true); 226 root->SetForceRenderSurface(true);
227 host_impl_->active_tree()->SetRootLayer(std::move(root)); 227 host_impl_->active_tree()->SetRootLayer(std::move(root));
228 } 228 }
229 229
230 static gfx::Vector2dF ScrollDelta(LayerImpl* layer_impl) {
231 if (layer_impl->IsActive())
232 return gfx::Vector2dF(layer_impl->synced_scroll_offset()->Delta().x(),
233 layer_impl->synced_scroll_offset()->Delta().y());
234 else
235 return gfx::Vector2dF(
236 layer_impl->synced_scroll_offset()->PendingDelta().get().x(),
237 layer_impl->synced_scroll_offset()->PendingDelta().get().y());
238 }
239
230 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) { 240 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) {
231 ASSERT_EQ(layer->ScrollDelta(), gfx::Vector2d()); 241 ASSERT_EQ(ScrollDelta(layer), gfx::Vector2d());
232 for (size_t i = 0; i < layer->children().size(); ++i) 242 for (size_t i = 0; i < layer->children().size(); ++i)
233 ExpectClearedScrollDeltasRecursive(layer->children()[i].get()); 243 ExpectClearedScrollDeltasRecursive(layer->children()[i].get());
234 } 244 }
235 245
236 static ::testing::AssertionResult ScrollInfoContains( 246 static ::testing::AssertionResult ScrollInfoContains(
237 const ScrollAndScaleSet& scroll_info, 247 const ScrollAndScaleSet& scroll_info,
238 int id, 248 int id,
239 const gfx::Vector2d& scroll_delta) { 249 const gfx::Vector2d& scroll_delta) {
240 int times_encountered = 0; 250 int times_encountered = 0;
241 251
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 292
283 scoped_ptr<LayerImpl> root = 293 scoped_ptr<LayerImpl> root =
284 LayerImpl::Create(layer_tree_impl, 1); 294 LayerImpl::Create(layer_tree_impl, 1);
285 root->SetBounds(content_size); 295 root->SetBounds(content_size);
286 root->SetPosition(gfx::PointF()); 296 root->SetPosition(gfx::PointF());
287 root->SetForceRenderSurface(true); 297 root->SetForceRenderSurface(true);
288 298
289 scoped_ptr<LayerImpl> inner_scroll = 299 scoped_ptr<LayerImpl> inner_scroll =
290 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); 300 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId);
291 inner_scroll->SetIsContainerForFixedPositionLayers(true); 301 inner_scroll->SetIsContainerForFixedPositionLayers(true);
292 inner_scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); 302 inner_scroll->layer_tree_impl()
303 ->property_trees()
304 ->scroll_tree.UpdateScrollOffsetBaseForTesting(inner_scroll->id(),
305 gfx::ScrollOffset());
293 306
294 scoped_ptr<LayerImpl> inner_clip = 307 scoped_ptr<LayerImpl> inner_clip =
295 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); 308 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId);
296 inner_clip->SetBounds( 309 inner_clip->SetBounds(
297 gfx::Size(content_size.width() / 2, content_size.height() / 2)); 310 gfx::Size(content_size.width() / 2, content_size.height() / 2));
298 311
299 scoped_ptr<LayerImpl> page_scale = 312 scoped_ptr<LayerImpl> page_scale =
300 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); 313 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId);
301 314
302 inner_scroll->SetScrollClipLayer(inner_clip->id()); 315 inner_scroll->SetScrollClipLayer(inner_clip->id());
303 inner_scroll->SetBounds(content_size); 316 inner_scroll->SetBounds(content_size);
304 inner_scroll->SetPosition(gfx::PointF()); 317 inner_scroll->SetPosition(gfx::PointF());
305 318
306 scoped_ptr<LayerImpl> outer_clip = 319 scoped_ptr<LayerImpl> outer_clip =
307 LayerImpl::Create(layer_tree_impl, kOuterViewportClipLayerId); 320 LayerImpl::Create(layer_tree_impl, kOuterViewportClipLayerId);
308 outer_clip->SetBounds(content_size); 321 outer_clip->SetBounds(content_size);
309 outer_clip->SetIsContainerForFixedPositionLayers(true); 322 outer_clip->SetIsContainerForFixedPositionLayers(true);
310 323
311 scoped_ptr<LayerImpl> outer_scroll = 324 scoped_ptr<LayerImpl> outer_scroll =
312 LayerImpl::Create(layer_tree_impl, kOuterViewportScrollLayerId); 325 LayerImpl::Create(layer_tree_impl, kOuterViewportScrollLayerId);
313 outer_scroll->SetScrollClipLayer(outer_clip->id()); 326 outer_scroll->SetScrollClipLayer(outer_clip->id());
314 outer_scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); 327 outer_scroll->layer_tree_impl()
328 ->property_trees()
329 ->scroll_tree.UpdateScrollOffsetBaseForTesting(outer_scroll->id(),
330 gfx::ScrollOffset());
315 outer_scroll->SetBounds(content_size); 331 outer_scroll->SetBounds(content_size);
316 outer_scroll->SetPosition(gfx::PointF()); 332 outer_scroll->SetPosition(gfx::PointF());
317 333
318 scoped_ptr<LayerImpl> contents = 334 scoped_ptr<LayerImpl> contents =
319 LayerImpl::Create(layer_tree_impl, kContentLayerId); 335 LayerImpl::Create(layer_tree_impl, kContentLayerId);
320 contents->SetDrawsContent(true); 336 contents->SetDrawsContent(true);
321 contents->SetBounds(content_size); 337 contents->SetBounds(content_size);
322 contents->SetPosition(gfx::PointF()); 338 contents->SetPosition(gfx::PointF());
323 339
324 outer_scroll->AddChild(std::move(contents)); 340 outer_scroll->AddChild(std::move(contents));
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 virtual scoped_ptr<OutputSurface> CreateOutputSurface() { 468 virtual scoped_ptr<OutputSurface> CreateOutputSurface() {
453 return FakeOutputSurface::Create3d(); 469 return FakeOutputSurface::Create3d();
454 } 470 }
455 471
456 void DrawOneFrame() { 472 void DrawOneFrame() {
457 LayerTreeHostImpl::FrameData frame_data; 473 LayerTreeHostImpl::FrameData frame_data;
458 PrepareToDrawFrame(&frame_data); 474 PrepareToDrawFrame(&frame_data);
459 host_impl_->DidDrawAllLayers(frame_data); 475 host_impl_->DidDrawAllLayers(frame_data);
460 } 476 }
461 477
478 static void SetScrollOffsetDelta(LayerImpl* layer_impl,
479 const gfx::Vector2dF& delta) {
480 layer_impl->SetCurrentScrollOffset(
481 layer_impl->synced_scroll_offset()->ActiveBase() +
482 gfx::ScrollOffset(delta));
483 }
484
462 FakeImplTaskRunnerProvider task_runner_provider_; 485 FakeImplTaskRunnerProvider task_runner_provider_;
463 DebugScopedSetMainThreadBlocked always_main_thread_blocked_; 486 DebugScopedSetMainThreadBlocked always_main_thread_blocked_;
464 487
465 TestSharedBitmapManager shared_bitmap_manager_; 488 TestSharedBitmapManager shared_bitmap_manager_;
466 TestGpuMemoryBufferManager gpu_memory_buffer_manager_; 489 TestGpuMemoryBufferManager gpu_memory_buffer_manager_;
467 TestTaskGraphRunner task_graph_runner_; 490 TestTaskGraphRunner task_graph_runner_;
468 scoped_ptr<OutputSurface> output_surface_; 491 scoped_ptr<OutputSurface> output_surface_;
469 scoped_ptr<LayerTreeHostImpl> host_impl_; 492 scoped_ptr<LayerTreeHostImpl> host_impl_;
470 FakeRenderingStatsInstrumentation stats_instrumentation_; 493 FakeRenderingStatsInstrumentation stats_instrumentation_;
471 bool on_can_draw_state_changed_called_; 494 bool on_can_draw_state_changed_called_;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 { 616 {
594 scoped_ptr<LayerImpl> root_clip = 617 scoped_ptr<LayerImpl> root_clip =
595 LayerImpl::Create(host_impl_->active_tree(), 2); 618 LayerImpl::Create(host_impl_->active_tree(), 2);
596 scoped_ptr<LayerImpl> root = 619 scoped_ptr<LayerImpl> root =
597 LayerImpl::Create(host_impl_->active_tree(), 1); 620 LayerImpl::Create(host_impl_->active_tree(), 1);
598 root_clip->SetBounds(gfx::Size(10, 10)); 621 root_clip->SetBounds(gfx::Size(10, 10));
599 LayerImpl* root_layer = root.get(); 622 LayerImpl* root_layer = root.get();
600 root_clip->AddChild(std::move(root)); 623 root_clip->AddChild(std::move(root));
601 root_layer->SetBounds(gfx::Size(110, 110)); 624 root_layer->SetBounds(gfx::Size(110, 110));
602 root_layer->SetScrollClipLayer(root_clip->id()); 625 root_layer->SetScrollClipLayer(root_clip->id());
603 root_layer->PushScrollOffsetFromMainThread(scroll_offset); 626 root_layer->layer_tree_impl()
627 ->property_trees()
628 ->scroll_tree.UpdateScrollOffsetBaseForTesting(root_layer->id(),
629 scroll_offset);
604 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); 630 host_impl_->active_tree()->SetRootLayer(std::move(root_clip));
605 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 631 host_impl_->active_tree()->BuildPropertyTreesForTesting();
606 root_layer->ScrollBy(scroll_delta); 632 root_layer->ScrollBy(scroll_delta);
607 } 633 }
608 634
609 LayerImpl* root = 635 LayerImpl* root =
610 host_impl_->active_tree()->root_layer()->children()[0].get(); 636 host_impl_->active_tree()->root_layer()->children()[0].get();
611 637
612 scoped_ptr<ScrollAndScaleSet> scroll_info; 638 scoped_ptr<ScrollAndScaleSet> scroll_info;
613 639
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 host_impl_->InnerViewportScrollLayer()->set_user_scrollable_vertical(false); 1137 host_impl_->InnerViewportScrollLayer()->set_user_scrollable_vertical(false);
1112 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage( 1138 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage(
1113 gfx::Point(), SCROLL_FORWARD)); 1139 gfx::Point(), SCROLL_FORWARD));
1114 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage( 1140 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage(
1115 gfx::Point(), SCROLL_BACKWARD)); 1141 gfx::Point(), SCROLL_BACKWARD));
1116 1142
1117 host_impl_->InnerViewportScrollLayer()->set_user_scrollable_vertical(true); 1143 host_impl_->InnerViewportScrollLayer()->set_user_scrollable_vertical(true);
1118 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( 1144 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage(
1119 gfx::Point(), SCROLL_FORWARD)); 1145 gfx::Point(), SCROLL_FORWARD));
1120 EXPECT_FLOAT_EQ(875.f, 1146 EXPECT_FLOAT_EQ(875.f,
1121 host_impl_->InnerViewportScrollLayer()->ScrollDelta().y()); 1147 ScrollDelta(host_impl_->InnerViewportScrollLayer()).y());
1122 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( 1148 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage(
1123 gfx::Point(), SCROLL_BACKWARD)); 1149 gfx::Point(), SCROLL_BACKWARD));
1124 } 1150 }
1125 1151
1126 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { 1152 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) {
1127 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); 1153 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200));
1128 host_impl_->SetViewportSize(gfx::Size(100, 100)); 1154 host_impl_->SetViewportSize(gfx::Size(100, 100));
1129 1155
1130 gfx::Size overflow_size(400, 400); 1156 gfx::Size overflow_size(400, 400);
1131 ASSERT_EQ(1u, scroll_layer->children().size()); 1157 ASSERT_EQ(1u, scroll_layer->children().size());
1132 LayerImpl* overflow = scroll_layer->children()[0].get(); 1158 LayerImpl* overflow = scroll_layer->children()[0].get();
1133 overflow->SetBounds(overflow_size); 1159 overflow->SetBounds(overflow_size);
1134 overflow->SetScrollClipLayer(scroll_layer->parent()->parent()->id()); 1160 overflow->SetScrollClipLayer(scroll_layer->parent()->parent()->id());
1135 overflow->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); 1161 overflow->layer_tree_impl()
1162 ->property_trees()
1163 ->scroll_tree.UpdateScrollOffsetBaseForTesting(overflow->id(),
1164 gfx::ScrollOffset());
1136 overflow->SetPosition(gfx::PointF()); 1165 overflow->SetPosition(gfx::PointF());
1137 1166
1138 SetNeedsRebuildPropertyTrees(); 1167 SetNeedsRebuildPropertyTrees();
1139 DrawFrame(); 1168 DrawFrame();
1140 gfx::Point scroll_position(10, 10); 1169 gfx::Point scroll_position(10, 10);
1141 1170
1142 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 1171 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
1143 host_impl_->ScrollBegin(BeginState(scroll_position).get(), 1172 host_impl_->ScrollBegin(BeginState(scroll_position).get(),
1144 InputHandler::WHEEL) 1173 InputHandler::WHEEL)
1145 .thread); 1174 .thread);
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); 1500 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds());
1472 1501
1473 float min_page_scale = 1.f, max_page_scale = 4.f; 1502 float min_page_scale = 1.f, max_page_scale = 4.f;
1474 float page_scale_factor = 1.f; 1503 float page_scale_factor = 1.f;
1475 1504
1476 // The impl-based pinch zoom should adjust the max scroll position. 1505 // The impl-based pinch zoom should adjust the max scroll position.
1477 { 1506 {
1478 host_impl_->active_tree()->PushPageScaleFromMainThread( 1507 host_impl_->active_tree()->PushPageScaleFromMainThread(
1479 page_scale_factor, min_page_scale, max_page_scale); 1508 page_scale_factor, min_page_scale, max_page_scale);
1480 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); 1509 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
1481 scroll_layer->SetScrollDelta(gfx::Vector2d()); 1510 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d());
1482 1511
1483 float page_scale_delta = 2.f; 1512 float page_scale_delta = 2.f;
1484 1513
1485 host_impl_->ScrollBegin(BeginState(gfx::Point(50, 50)).get(), 1514 host_impl_->ScrollBegin(BeginState(gfx::Point(50, 50)).get(),
1486 InputHandler::GESTURE); 1515 InputHandler::GESTURE);
1487 host_impl_->PinchGestureBegin(); 1516 host_impl_->PinchGestureBegin();
1488 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); 1517 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50));
1489 host_impl_->PinchGestureEnd(); 1518 host_impl_->PinchGestureEnd();
1490 host_impl_->ScrollEnd(EndState().get()); 1519 host_impl_->ScrollEnd(EndState().get());
1491 EXPECT_FALSE(did_request_next_frame_); 1520 EXPECT_FALSE(did_request_next_frame_);
1492 EXPECT_TRUE(did_request_redraw_); 1521 EXPECT_TRUE(did_request_redraw_);
1493 EXPECT_TRUE(did_request_commit_); 1522 EXPECT_TRUE(did_request_commit_);
1494 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); 1523 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds());
1495 1524
1496 scoped_ptr<ScrollAndScaleSet> scroll_info = 1525 scoped_ptr<ScrollAndScaleSet> scroll_info =
1497 host_impl_->ProcessScrollDeltas(); 1526 host_impl_->ProcessScrollDeltas();
1498 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); 1527 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta);
1499 1528
1500 EXPECT_EQ(gfx::ScrollOffset(75.0, 75.0).ToString(), 1529 EXPECT_EQ(gfx::ScrollOffset(75.0, 75.0).ToString(),
1501 scroll_layer->MaxScrollOffset().ToString()); 1530 scroll_layer->MaxScrollOffset().ToString());
1502 } 1531 }
1503 1532
1504 // Scrolling after a pinch gesture should always be in local space. The 1533 // Scrolling after a pinch gesture should always be in local space. The
1505 // scroll deltas have the page scale factor applied. 1534 // scroll deltas have the page scale factor applied.
1506 { 1535 {
1507 host_impl_->active_tree()->PushPageScaleFromMainThread( 1536 host_impl_->active_tree()->PushPageScaleFromMainThread(
1508 page_scale_factor, min_page_scale, max_page_scale); 1537 page_scale_factor, min_page_scale, max_page_scale);
1509 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); 1538 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
1510 scroll_layer->SetScrollDelta(gfx::Vector2d()); 1539 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d());
1511 1540
1512 float page_scale_delta = 2.f; 1541 float page_scale_delta = 2.f;
1513 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 1542 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
1514 InputHandler::GESTURE); 1543 InputHandler::GESTURE);
1515 host_impl_->PinchGestureBegin(); 1544 host_impl_->PinchGestureBegin();
1516 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); 1545 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point());
1517 host_impl_->PinchGestureEnd(); 1546 host_impl_->PinchGestureEnd();
1518 host_impl_->ScrollEnd(EndState().get()); 1547 host_impl_->ScrollEnd(EndState().get());
1519 1548
1520 gfx::Vector2d scroll_delta(0, 10); 1549 gfx::Vector2d scroll_delta(0, 10);
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 host_impl_->PinchGestureUpdate(2, anchor); 1768 host_impl_->PinchGestureUpdate(2, anchor);
1740 host_impl_->PinchGestureEnd(); 1769 host_impl_->PinchGestureEnd();
1741 host_impl_->ScrollEnd(EndState().get()); 1770 host_impl_->ScrollEnd(EndState().get());
1742 1771
1743 EXPECT_VECTOR_EQ( 1772 EXPECT_VECTOR_EQ(
1744 gfx::Vector2dF(250, 250), 1773 gfx::Vector2dF(250, 250),
1745 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); 1774 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset());
1746 1775
1747 // Reset. 1776 // Reset.
1748 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.f); 1777 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.f);
1749 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(gfx::Vector2d()); 1778 SetScrollOffsetDelta(host_impl_->InnerViewportScrollLayer(), gfx::Vector2d());
1750 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2d()); 1779 SetScrollOffsetDelta(host_impl_->OuterViewportScrollLayer(), gfx::Vector2d());
1751 1780
1752 // Pinch in within the margins. The scroll should stay exactly locked to the 1781 // Pinch in within the margins. The scroll should stay exactly locked to the
1753 // top and left. 1782 // top and left.
1754 anchor = gfx::Point(offsetFromEdge, offsetFromEdge); 1783 anchor = gfx::Point(offsetFromEdge, offsetFromEdge);
1755 host_impl_->ScrollBegin(BeginState(anchor).get(), InputHandler::GESTURE); 1784 host_impl_->ScrollBegin(BeginState(anchor).get(), InputHandler::GESTURE);
1756 host_impl_->PinchGestureBegin(); 1785 host_impl_->PinchGestureBegin();
1757 host_impl_->PinchGestureUpdate(2, anchor); 1786 host_impl_->PinchGestureUpdate(2, anchor);
1758 host_impl_->PinchGestureEnd(); 1787 host_impl_->PinchGestureEnd();
1759 host_impl_->ScrollEnd(EndState().get()); 1788 host_impl_->ScrollEnd(EndState().get());
1760 1789
1761 EXPECT_VECTOR_EQ( 1790 EXPECT_VECTOR_EQ(
1762 gfx::Vector2dF(0, 0), 1791 gfx::Vector2dF(0, 0),
1763 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); 1792 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset());
1764 1793
1765 // Reset. 1794 // Reset.
1766 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.f); 1795 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.f);
1767 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(gfx::Vector2d()); 1796 SetScrollOffsetDelta(host_impl_->InnerViewportScrollLayer(), gfx::Vector2d());
1768 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2d()); 1797 SetScrollOffsetDelta(host_impl_->OuterViewportScrollLayer(), gfx::Vector2d());
1769 1798
1770 // Pinch in just outside the margin. There should be no snapping. 1799 // Pinch in just outside the margin. There should be no snapping.
1771 offsetFromEdge = Viewport::kPinchZoomSnapMarginDips; 1800 offsetFromEdge = Viewport::kPinchZoomSnapMarginDips;
1772 anchor = gfx::Point(offsetFromEdge, offsetFromEdge); 1801 anchor = gfx::Point(offsetFromEdge, offsetFromEdge);
1773 host_impl_->ScrollBegin(BeginState(anchor).get(), InputHandler::GESTURE); 1802 host_impl_->ScrollBegin(BeginState(anchor).get(), InputHandler::GESTURE);
1774 host_impl_->PinchGestureBegin(); 1803 host_impl_->PinchGestureBegin();
1775 host_impl_->PinchGestureUpdate(2, anchor); 1804 host_impl_->PinchGestureUpdate(2, anchor);
1776 host_impl_->PinchGestureEnd(); 1805 host_impl_->PinchGestureEnd();
1777 host_impl_->ScrollEnd(EndState().get()); 1806 host_impl_->ScrollEnd(EndState().get());
1778 1807
1779 EXPECT_VECTOR_EQ( 1808 EXPECT_VECTOR_EQ(
1780 gfx::Vector2dF(50, 50), 1809 gfx::Vector2dF(50, 50),
1781 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); 1810 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset());
1782 1811
1783 // Reset. 1812 // Reset.
1784 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.f); 1813 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.f);
1785 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(gfx::Vector2d()); 1814 SetScrollOffsetDelta(host_impl_->InnerViewportScrollLayer(), gfx::Vector2d());
1786 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2d()); 1815 SetScrollOffsetDelta(host_impl_->OuterViewportScrollLayer(), gfx::Vector2d());
1787 1816
1788 // Pinch in just outside the margin. There should be no snapping. 1817 // Pinch in just outside the margin. There should be no snapping.
1789 offsetFromEdge = Viewport::kPinchZoomSnapMarginDips; 1818 offsetFromEdge = Viewport::kPinchZoomSnapMarginDips;
1790 anchor = gfx::Point(viewport_size.width() - offsetFromEdge, 1819 anchor = gfx::Point(viewport_size.width() - offsetFromEdge,
1791 viewport_size.height() - offsetFromEdge); 1820 viewport_size.height() - offsetFromEdge);
1792 host_impl_->ScrollBegin(BeginState(anchor).get(), InputHandler::GESTURE); 1821 host_impl_->ScrollBegin(BeginState(anchor).get(), InputHandler::GESTURE);
1793 host_impl_->PinchGestureBegin(); 1822 host_impl_->PinchGestureBegin();
1794 host_impl_->PinchGestureUpdate(2, anchor); 1823 host_impl_->PinchGestureUpdate(2, anchor);
1795 host_impl_->PinchGestureEnd(); 1824 host_impl_->PinchGestureEnd();
1796 host_impl_->ScrollEnd(EndState().get()); 1825 host_impl_->ScrollEnd(EndState().get());
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1984 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); 2013 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer();
1985 DCHECK(scroll_layer); 2014 DCHECK(scroll_layer);
1986 2015
1987 float min_page_scale = 1.f; 2016 float min_page_scale = 1.f;
1988 float max_page_scale = 4.f; 2017 float max_page_scale = 4.f;
1989 2018
1990 // Basic pinch zoom in gesture 2019 // Basic pinch zoom in gesture
1991 { 2020 {
1992 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2021 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
1993 max_page_scale); 2022 max_page_scale);
1994 scroll_layer->SetScrollDelta(gfx::Vector2d()); 2023 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d());
1995 2024
1996 float page_scale_delta = 2.f; 2025 float page_scale_delta = 2.f;
1997 host_impl_->ScrollBegin(BeginState(gfx::Point(50, 50)).get(), 2026 host_impl_->ScrollBegin(BeginState(gfx::Point(50, 50)).get(),
1998 InputHandler::GESTURE); 2027 InputHandler::GESTURE);
1999 host_impl_->PinchGestureBegin(); 2028 host_impl_->PinchGestureBegin();
2000 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); 2029 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50));
2001 host_impl_->PinchGestureEnd(); 2030 host_impl_->PinchGestureEnd();
2002 host_impl_->ScrollEnd(EndState().get()); 2031 host_impl_->ScrollEnd(EndState().get());
2003 EXPECT_FALSE(did_request_next_frame_); 2032 EXPECT_FALSE(did_request_next_frame_);
2004 EXPECT_TRUE(did_request_redraw_); 2033 EXPECT_TRUE(did_request_redraw_);
2005 EXPECT_TRUE(did_request_commit_); 2034 EXPECT_TRUE(did_request_commit_);
2006 2035
2007 scoped_ptr<ScrollAndScaleSet> scroll_info = 2036 scoped_ptr<ScrollAndScaleSet> scroll_info =
2008 host_impl_->ProcessScrollDeltas(); 2037 host_impl_->ProcessScrollDeltas();
2009 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); 2038 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta);
2010 } 2039 }
2011 2040
2012 // Zoom-in clamping 2041 // Zoom-in clamping
2013 { 2042 {
2014 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2043 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
2015 max_page_scale); 2044 max_page_scale);
2016 scroll_layer->SetScrollDelta(gfx::Vector2d()); 2045 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d());
2017 float page_scale_delta = 10.f; 2046 float page_scale_delta = 10.f;
2018 2047
2019 host_impl_->ScrollBegin(BeginState(gfx::Point(50, 50)).get(), 2048 host_impl_->ScrollBegin(BeginState(gfx::Point(50, 50)).get(),
2020 InputHandler::GESTURE); 2049 InputHandler::GESTURE);
2021 host_impl_->PinchGestureBegin(); 2050 host_impl_->PinchGestureBegin();
2022 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); 2051 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50));
2023 host_impl_->PinchGestureEnd(); 2052 host_impl_->PinchGestureEnd();
2024 host_impl_->ScrollEnd(EndState().get()); 2053 host_impl_->ScrollEnd(EndState().get());
2025 2054
2026 scoped_ptr<ScrollAndScaleSet> scroll_info = 2055 scoped_ptr<ScrollAndScaleSet> scroll_info =
2027 host_impl_->ProcessScrollDeltas(); 2056 host_impl_->ProcessScrollDeltas();
2028 EXPECT_EQ(scroll_info->page_scale_delta, max_page_scale); 2057 EXPECT_EQ(scroll_info->page_scale_delta, max_page_scale);
2029 } 2058 }
2030 2059
2031 // Zoom-out clamping 2060 // Zoom-out clamping
2032 { 2061 {
2033 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2062 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
2034 max_page_scale); 2063 max_page_scale);
2035 scroll_layer->SetScrollDelta(gfx::Vector2d()); 2064 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d());
2036 scroll_layer->synced_scroll_offset()->PullDeltaForMainThread(); 2065 scroll_layer->synced_scroll_offset()->PullDeltaForMainThread();
2037 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); 2066 scroll_layer->layer_tree_impl()
2067 ->property_trees()
2068 ->scroll_tree.UpdateScrollOffsetBaseForTesting(
2069 scroll_layer->id(), gfx::ScrollOffset(50, 50));
2038 2070
2039 float page_scale_delta = 0.1f; 2071 float page_scale_delta = 0.1f;
2040 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 2072 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
2041 InputHandler::GESTURE); 2073 InputHandler::GESTURE);
2042 host_impl_->PinchGestureBegin(); 2074 host_impl_->PinchGestureBegin();
2043 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); 2075 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point());
2044 host_impl_->PinchGestureEnd(); 2076 host_impl_->PinchGestureEnd();
2045 host_impl_->ScrollEnd(EndState().get()); 2077 host_impl_->ScrollEnd(EndState().get());
2046 2078
2047 scoped_ptr<ScrollAndScaleSet> scroll_info = 2079 scoped_ptr<ScrollAndScaleSet> scroll_info =
2048 host_impl_->ProcessScrollDeltas(); 2080 host_impl_->ProcessScrollDeltas();
2049 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); 2081 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale);
2050 2082
2051 EXPECT_TRUE(scroll_info->scrolls.empty()); 2083 EXPECT_TRUE(scroll_info->scrolls.empty());
2052 } 2084 }
2053 2085
2054 // Two-finger panning should not happen based on pinch events only 2086 // Two-finger panning should not happen based on pinch events only
2055 { 2087 {
2056 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2088 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
2057 max_page_scale); 2089 max_page_scale);
2058 scroll_layer->SetScrollDelta(gfx::Vector2d()); 2090 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d());
2059 scroll_layer->synced_scroll_offset()->PullDeltaForMainThread(); 2091 scroll_layer->synced_scroll_offset()->PullDeltaForMainThread();
2060 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(20, 20)); 2092 scroll_layer->layer_tree_impl()
2093 ->property_trees()
2094 ->scroll_tree.UpdateScrollOffsetBaseForTesting(
2095 scroll_layer->id(), gfx::ScrollOffset(20, 20));
2061 2096
2062 float page_scale_delta = 1.f; 2097 float page_scale_delta = 1.f;
2063 host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(), 2098 host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(),
2064 InputHandler::GESTURE); 2099 InputHandler::GESTURE);
2065 host_impl_->PinchGestureBegin(); 2100 host_impl_->PinchGestureBegin();
2066 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); 2101 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10));
2067 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); 2102 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20));
2068 host_impl_->PinchGestureEnd(); 2103 host_impl_->PinchGestureEnd();
2069 host_impl_->ScrollEnd(EndState().get()); 2104 host_impl_->ScrollEnd(EndState().get());
2070 2105
2071 scoped_ptr<ScrollAndScaleSet> scroll_info = 2106 scoped_ptr<ScrollAndScaleSet> scroll_info =
2072 host_impl_->ProcessScrollDeltas(); 2107 host_impl_->ProcessScrollDeltas();
2073 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); 2108 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta);
2074 EXPECT_TRUE(scroll_info->scrolls.empty()); 2109 EXPECT_TRUE(scroll_info->scrolls.empty());
2075 } 2110 }
2076 2111
2077 // Two-finger panning should work with interleaved scroll events 2112 // Two-finger panning should work with interleaved scroll events
2078 { 2113 {
2079 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2114 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
2080 max_page_scale); 2115 max_page_scale);
2081 scroll_layer->SetScrollDelta(gfx::Vector2d()); 2116 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d());
2082 scroll_layer->synced_scroll_offset()->PullDeltaForMainThread(); 2117 scroll_layer->synced_scroll_offset()->PullDeltaForMainThread();
2083 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(20, 20)); 2118 scroll_layer->layer_tree_impl()
2119 ->property_trees()
2120 ->scroll_tree.UpdateScrollOffsetBaseForTesting(
2121 scroll_layer->id(), gfx::ScrollOffset(20, 20));
2084 2122
2085 float page_scale_delta = 1.f; 2123 float page_scale_delta = 1.f;
2086 host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(), 2124 host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(),
2087 InputHandler::GESTURE); 2125 InputHandler::GESTURE);
2088 host_impl_->PinchGestureBegin(); 2126 host_impl_->PinchGestureBegin();
2089 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); 2127 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10));
2090 host_impl_->ScrollBy( 2128 host_impl_->ScrollBy(
2091 UpdateState(gfx::Point(10, 10), gfx::Vector2d(-10, -10)).get()); 2129 UpdateState(gfx::Point(10, 10), gfx::Vector2d(-10, -10)).get());
2092 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); 2130 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20));
2093 host_impl_->PinchGestureEnd(); 2131 host_impl_->PinchGestureEnd();
2094 host_impl_->ScrollEnd(EndState().get()); 2132 host_impl_->ScrollEnd(EndState().get());
2095 2133
2096 scoped_ptr<ScrollAndScaleSet> scroll_info = 2134 scoped_ptr<ScrollAndScaleSet> scroll_info =
2097 host_impl_->ProcessScrollDeltas(); 2135 host_impl_->ProcessScrollDeltas();
2098 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); 2136 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta);
2099 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), 2137 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(),
2100 gfx::Vector2d(-10, -10))); 2138 gfx::Vector2d(-10, -10)));
2101 } 2139 }
2102 2140
2103 // Two-finger panning should work when starting fully zoomed out. 2141 // Two-finger panning should work when starting fully zoomed out.
2104 { 2142 {
2105 host_impl_->active_tree()->PushPageScaleFromMainThread(0.5f, 0.5f, 4.f); 2143 host_impl_->active_tree()->PushPageScaleFromMainThread(0.5f, 0.5f, 4.f);
2106 scroll_layer->SetScrollDelta(gfx::Vector2d()); 2144 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d());
2107 scroll_layer->synced_scroll_offset()->PullDeltaForMainThread(); 2145 scroll_layer->synced_scroll_offset()->PullDeltaForMainThread();
2108 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 0)); 2146 scroll_layer->layer_tree_impl()
2147 ->property_trees()
2148 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(),
2149 gfx::ScrollOffset(0, 0));
2109 2150
2110 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), 2151 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(),
2111 InputHandler::GESTURE); 2152 InputHandler::GESTURE);
2112 host_impl_->PinchGestureBegin(); 2153 host_impl_->PinchGestureBegin();
2113 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); 2154 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0));
2114 host_impl_->PinchGestureUpdate(1.f, gfx::Point(0, 0)); 2155 host_impl_->PinchGestureUpdate(1.f, gfx::Point(0, 0));
2115 2156
2116 // Needed so layer transform includes page scale. 2157 // Needed so layer transform includes page scale.
2117 DrawFrame(); 2158 DrawFrame();
2118 2159
(...skipping 27 matching lines...) Expand all
2146 base::TimeTicks halfway_through_animation = start_time + duration / 2; 2187 base::TimeTicks halfway_through_animation = start_time + duration / 2;
2147 base::TimeTicks end_time = start_time + duration; 2188 base::TimeTicks end_time = start_time + duration;
2148 2189
2149 BeginFrameArgs begin_frame_args = 2190 BeginFrameArgs begin_frame_args =
2150 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); 2191 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
2151 2192
2152 // Non-anchor zoom-in 2193 // Non-anchor zoom-in
2153 { 2194 {
2154 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2195 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
2155 max_page_scale); 2196 max_page_scale);
2156 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); 2197 scroll_layer->layer_tree_impl()
2198 ->property_trees()
2199 ->scroll_tree.UpdateScrollOffsetBaseForTesting(
2200 scroll_layer->id(), gfx::ScrollOffset(50, 50));
2157 2201
2158 did_request_redraw_ = false; 2202 did_request_redraw_ = false;
2159 did_request_next_frame_ = false; 2203 did_request_next_frame_ = false;
2160 host_impl_->active_tree()->SetPendingPageScaleAnimation( 2204 host_impl_->active_tree()->SetPendingPageScaleAnimation(
2161 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( 2205 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation(
2162 gfx::Vector2d(), 2206 gfx::Vector2d(),
2163 false, 2207 false,
2164 2.f, 2208 2.f,
2165 duration))); 2209 duration)));
2166 host_impl_->ActivateSyncTree(); 2210 host_impl_->ActivateSyncTree();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2203 } 2247 }
2204 2248
2205 start_time += base::TimeDelta::FromSeconds(10); 2249 start_time += base::TimeDelta::FromSeconds(10);
2206 halfway_through_animation += base::TimeDelta::FromSeconds(10); 2250 halfway_through_animation += base::TimeDelta::FromSeconds(10);
2207 end_time += base::TimeDelta::FromSeconds(10); 2251 end_time += base::TimeDelta::FromSeconds(10);
2208 2252
2209 // Anchor zoom-out 2253 // Anchor zoom-out
2210 { 2254 {
2211 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2255 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
2212 max_page_scale); 2256 max_page_scale);
2213 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); 2257 scroll_layer->layer_tree_impl()
2258 ->property_trees()
2259 ->scroll_tree.UpdateScrollOffsetBaseForTesting(
2260 scroll_layer->id(), gfx::ScrollOffset(50, 50));
2214 2261
2215 did_request_redraw_ = false; 2262 did_request_redraw_ = false;
2216 did_request_next_frame_ = false; 2263 did_request_next_frame_ = false;
2217 host_impl_->active_tree()->SetPendingPageScaleAnimation( 2264 host_impl_->active_tree()->SetPendingPageScaleAnimation(
2218 scoped_ptr<PendingPageScaleAnimation> (new PendingPageScaleAnimation( 2265 scoped_ptr<PendingPageScaleAnimation> (new PendingPageScaleAnimation(
2219 gfx::Vector2d(25, 25), 2266 gfx::Vector2d(25, 25),
2220 true, 2267 true,
2221 min_page_scale, 2268 min_page_scale,
2222 duration))); 2269 duration)));
2223 host_impl_->ActivateSyncTree(); 2270 host_impl_->ActivateSyncTree();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2269 base::TimeTicks halfway_through_animation = start_time + duration / 2; 2316 base::TimeTicks halfway_through_animation = start_time + duration / 2;
2270 base::TimeTicks end_time = start_time + duration; 2317 base::TimeTicks end_time = start_time + duration;
2271 2318
2272 BeginFrameArgs begin_frame_args = 2319 BeginFrameArgs begin_frame_args =
2273 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); 2320 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
2274 2321
2275 // Anchor zoom with unchanged page scale should not change scroll or scale. 2322 // Anchor zoom with unchanged page scale should not change scroll or scale.
2276 { 2323 {
2277 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2324 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
2278 max_page_scale); 2325 max_page_scale);
2279 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); 2326 scroll_layer->layer_tree_impl()
2327 ->property_trees()
2328 ->scroll_tree.UpdateScrollOffsetBaseForTesting(
2329 scroll_layer->id(), gfx::ScrollOffset(50, 50));
2280 2330
2281 host_impl_->active_tree()->SetPendingPageScaleAnimation( 2331 host_impl_->active_tree()->SetPendingPageScaleAnimation(
2282 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( 2332 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation(
2283 gfx::Vector2d(), 2333 gfx::Vector2d(),
2284 true, 2334 true,
2285 1.f, 2335 1.f,
2286 duration))); 2336 duration)));
2287 host_impl_->ActivateSyncTree(); 2337 host_impl_->ActivateSyncTree();
2288 begin_frame_args.frame_time = start_time; 2338 begin_frame_args.frame_time = start_time;
2289 host_impl_->WillBeginImplFrame(begin_frame_args); 2339 host_impl_->WillBeginImplFrame(begin_frame_args);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2332 base::TimeDelta::FromSeconds(1); 2382 base::TimeDelta::FromSeconds(1);
2333 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); 2383 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
2334 base::TimeTicks third_through_animation = start_time + duration / 3; 2384 base::TimeTicks third_through_animation = start_time + duration / 3;
2335 base::TimeTicks halfway_through_animation = start_time + duration / 2; 2385 base::TimeTicks halfway_through_animation = start_time + duration / 2;
2336 base::TimeTicks end_time = start_time + duration; 2386 base::TimeTicks end_time = start_time + duration;
2337 float target_scale = 2.f; 2387 float target_scale = 2.f;
2338 2388
2339 BeginFrameArgs begin_frame_args = 2389 BeginFrameArgs begin_frame_args =
2340 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); 2390 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
2341 2391
2342 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); 2392 scroll_layer->layer_tree_impl()
2393 ->property_trees()
2394 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(),
2395 gfx::ScrollOffset(50, 50));
2343 2396
2344 // Make sure TakePageScaleAnimation works properly. 2397 // Make sure TakePageScaleAnimation works properly.
2345 2398
2346 host_impl_->sync_tree()->SetPendingPageScaleAnimation( 2399 host_impl_->sync_tree()->SetPendingPageScaleAnimation(
2347 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( 2400 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation(
2348 gfx::Vector2d(), 2401 gfx::Vector2d(),
2349 false, 2402 false,
2350 target_scale, 2403 target_scale,
2351 duration))); 2404 duration)));
2352 scoped_ptr<PendingPageScaleAnimation> psa = 2405 scoped_ptr<PendingPageScaleAnimation> psa =
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
2444 base::TimeTicks start_time = 2497 base::TimeTicks start_time =
2445 base::TimeTicks() + base::TimeDelta::FromSeconds(1); 2498 base::TimeTicks() + base::TimeDelta::FromSeconds(1);
2446 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); 2499 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
2447 base::TimeTicks halfway_through_animation = start_time + duration / 2; 2500 base::TimeTicks halfway_through_animation = start_time + duration / 2;
2448 base::TimeTicks end_time = start_time + duration; 2501 base::TimeTicks end_time = start_time + duration;
2449 2502
2450 BeginFrameArgs begin_frame_args = 2503 BeginFrameArgs begin_frame_args =
2451 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); 2504 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
2452 2505
2453 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); 2506 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f);
2454 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); 2507 scroll_layer->layer_tree_impl()
2508 ->property_trees()
2509 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(),
2510 gfx::ScrollOffset(50, 50));
2455 2511
2456 did_complete_page_scale_animation_ = false; 2512 did_complete_page_scale_animation_ = false;
2457 host_impl_->active_tree()->SetPendingPageScaleAnimation( 2513 host_impl_->active_tree()->SetPendingPageScaleAnimation(
2458 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( 2514 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation(
2459 gfx::Vector2d(), false, 2.f, duration))); 2515 gfx::Vector2d(), false, 2.f, duration)));
2460 host_impl_->ActivateSyncTree(); 2516 host_impl_->ActivateSyncTree();
2461 begin_frame_args.frame_time = start_time; 2517 begin_frame_args.frame_time = start_time;
2462 host_impl_->WillBeginImplFrame(begin_frame_args); 2518 host_impl_->WillBeginImplFrame(begin_frame_args);
2463 host_impl_->Animate(); 2519 host_impl_->Animate();
2464 EXPECT_FALSE(did_complete_page_scale_animation_); 2520 EXPECT_FALSE(did_complete_page_scale_animation_);
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
2654 EXPECT_TRUE(did_request_next_frame_); 2710 EXPECT_TRUE(did_request_next_frame_);
2655 did_request_next_frame_ = false; 2711 did_request_next_frame_ = false;
2656 EXPECT_TRUE(did_request_redraw_); 2712 EXPECT_TRUE(did_request_redraw_);
2657 did_request_redraw_ = false; 2713 did_request_redraw_ = false;
2658 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); 2714 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2659 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 2715 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2660 host_impl_->DidFinishImplFrame(); 2716 host_impl_->DidFinishImplFrame();
2661 2717
2662 // Setting the scroll offset outside a scroll should also cause the 2718 // Setting the scroll offset outside a scroll should also cause the
2663 // scrollbar to appear and to schedule a scrollbar animation. 2719 // scrollbar to appear and to schedule a scrollbar animation.
2664 host_impl_->InnerViewportScrollLayer()->PushScrollOffsetFromMainThread( 2720 if (host_impl_->active_tree()
2665 gfx::ScrollOffset(5, 5)); 2721 ->property_trees()
2722 ->scroll_tree.UpdateScrollOffsetBaseForTesting(
2723 host_impl_->InnerViewportScrollLayer()->id(),
2724 gfx::ScrollOffset(5, 5)))
2725 host_impl_->InnerViewportScrollLayer()->DidUpdateScrollOffset();
2666 EXPECT_FALSE(did_request_next_frame_); 2726 EXPECT_FALSE(did_request_next_frame_);
2667 EXPECT_FALSE(did_request_redraw_); 2727 EXPECT_FALSE(did_request_redraw_);
2668 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), 2728 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20),
2669 requested_animation_delay_); 2729 requested_animation_delay_);
2670 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 2730 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
2671 requested_animation_delay_ = base::TimeDelta(); 2731 requested_animation_delay_ = base::TimeDelta();
2672 animation_task_ = base::Closure(); 2732 animation_task_ = base::Closure();
2673 2733
2674 // Scrolling should have stopped the animation, so we should not be getting 2734 // Scrolling should have stopped the animation, so we should not be getting
2675 // redraws. 2735 // redraws.
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after
3685 gfx::Size(100, 100)); 3745 gfx::Size(100, 100));
3686 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 3746 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
3687 host_impl_->ActivateSyncTree(); 3747 host_impl_->ActivateSyncTree();
3688 3748
3689 host_impl_->CreatePendingTree(); 3749 host_impl_->CreatePendingTree();
3690 const gfx::ScrollOffset pending_scroll = gfx::ScrollOffset(-100, -100); 3750 const gfx::ScrollOffset pending_scroll = gfx::ScrollOffset(-100, -100);
3691 LayerImpl* active_outer_layer = 3751 LayerImpl* active_outer_layer =
3692 host_impl_->active_tree()->OuterViewportScrollLayer(); 3752 host_impl_->active_tree()->OuterViewportScrollLayer();
3693 LayerImpl* pending_outer_layer = 3753 LayerImpl* pending_outer_layer =
3694 host_impl_->pending_tree()->OuterViewportScrollLayer(); 3754 host_impl_->pending_tree()->OuterViewportScrollLayer();
3695 pending_outer_layer->PushScrollOffsetFromMainThread(pending_scroll); 3755 pending_outer_layer->layer_tree_impl()
3756 ->property_trees()
3757 ->scroll_tree.UpdateScrollOffsetBaseForTesting(pending_outer_layer->id(),
3758 pending_scroll);
3696 3759
3697 host_impl_->ActivateSyncTree(); 3760 host_impl_->ActivateSyncTree();
3698 // Scrolloffsets on the active tree will be clamped after activation. 3761 // Scrolloffsets on the active tree will be clamped after activation.
3699 EXPECT_EQ(active_outer_layer->CurrentScrollOffset(), gfx::ScrollOffset(0, 0)); 3762 EXPECT_EQ(active_outer_layer->CurrentScrollOffset(), gfx::ScrollOffset(0, 0));
3700 } 3763 }
3701 3764
3702 class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest { 3765 class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest {
3703 public: 3766 public:
3704 LayerTreeHostImplTopControlsTest() 3767 LayerTreeHostImplTopControlsTest()
3705 // Make the clip size the same as the layer (content) size so the layer is 3768 // Make the clip size the same as the layer (content) size so the layer is
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
4066 LayerImpl::Create(host_impl_->active_tree(), id + 3); 4129 LayerImpl::Create(host_impl_->active_tree(), id + 3);
4067 4130
4068 child_clip->SetBounds(sub_content_layer_size); 4131 child_clip->SetBounds(sub_content_layer_size);
4069 child->SetScrollClipLayer(child_clip->id()); 4132 child->SetScrollClipLayer(child_clip->id());
4070 child->SetBounds(sub_content_size); 4133 child->SetBounds(sub_content_size);
4071 child->SetPosition(gfx::PointF()); 4134 child->SetPosition(gfx::PointF());
4072 child->SetDrawsContent(true); 4135 child->SetDrawsContent(true);
4073 child->SetIsContainerForFixedPositionLayers(true); 4136 child->SetIsContainerForFixedPositionLayers(true);
4074 4137
4075 // scroll child to limit 4138 // scroll child to limit
4076 child->SetScrollDelta(gfx::Vector2dF(0, 100.f)); 4139 SetScrollOffsetDelta(child.get(), gfx::Vector2dF(0, 100.f));
4077 child_clip->AddChild(std::move(child)); 4140 child_clip->AddChild(std::move(child));
4078 outer_viewport_scroll_layer->AddChild(std::move(child_clip)); 4141 outer_viewport_scroll_layer->AddChild(std::move(child_clip));
4079 4142
4080 // Scroll 25px to hide top controls 4143 // Scroll 25px to hide top controls
4081 gfx::Vector2dF scroll_delta(0.f, 25.f); 4144 gfx::Vector2dF scroll_delta(0.f, 25.f);
4082 host_impl_->active_tree()->property_trees()->needs_rebuild = true; 4145 host_impl_->active_tree()->property_trees()->needs_rebuild = true;
4083 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 4146 host_impl_->active_tree()->BuildPropertyTreesForTesting();
4084 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 4147 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
4085 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 4148 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
4086 InputHandler::GESTURE) 4149 InputHandler::GESTURE)
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
4226 SetupTopControlsAndScrollLayerWithVirtualViewport( 4289 SetupTopControlsAndScrollLayerWithVirtualViewport(
4227 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); 4290 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400));
4228 DrawFrame(); 4291 DrawFrame();
4229 4292
4230 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); 4293 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio());
4231 4294
4232 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); 4295 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer();
4233 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); 4296 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer();
4234 4297
4235 // Scroll the viewports to max scroll offset. 4298 // Scroll the viewports to max scroll offset.
4236 outer_scroll->SetScrollDelta(gfx::Vector2dF(0, 200.f)); 4299 SetScrollOffsetDelta(outer_scroll, gfx::Vector2dF(0, 200.f));
4237 inner_scroll->SetScrollDelta(gfx::Vector2dF(100, 100.f)); 4300 SetScrollOffsetDelta(inner_scroll, gfx::Vector2dF(100, 100.f));
4238 4301
4239 gfx::ScrollOffset viewport_offset = 4302 gfx::ScrollOffset viewport_offset =
4240 host_impl_->active_tree()->TotalScrollOffset(); 4303 host_impl_->active_tree()->TotalScrollOffset();
4241 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), viewport_offset); 4304 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), viewport_offset);
4242 4305
4243 // Hide the top controls by 25px. 4306 // Hide the top controls by 25px.
4244 gfx::Vector2dF scroll_delta(0.f, 25.f); 4307 gfx::Vector2dF scroll_delta(0.f, 25.f);
4245 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 4308 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
4246 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 4309 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
4247 InputHandler::GESTURE) 4310 InputHandler::GESTURE)
(...skipping 27 matching lines...) Expand all
4275 InputHandler::GESTURE) 4338 InputHandler::GESTURE)
4276 .thread); 4339 .thread);
4277 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 4340 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
4278 host_impl_->ScrollEnd(EndState().get()); 4341 host_impl_->ScrollEnd(EndState().get());
4279 4342
4280 // The viewport offset shouldn't have changed. 4343 // The viewport offset shouldn't have changed.
4281 EXPECT_EQ(viewport_offset, 4344 EXPECT_EQ(viewport_offset,
4282 host_impl_->active_tree()->TotalScrollOffset()); 4345 host_impl_->active_tree()->TotalScrollOffset());
4283 4346
4284 // Scroll the viewports to max scroll offset. 4347 // Scroll the viewports to max scroll offset.
4285 outer_scroll->SetScrollDelta(gfx::Vector2dF(0, 200.f)); 4348 SetScrollOffsetDelta(outer_scroll, gfx::Vector2dF(0, 200.f));
4286 inner_scroll->SetScrollDelta(gfx::Vector2dF(100, 100.f)); 4349 SetScrollOffsetDelta(inner_scroll, gfx::Vector2dF(100, 100.f));
4287 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), 4350 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(),
4288 host_impl_->active_tree()->TotalScrollOffset()); 4351 host_impl_->active_tree()->TotalScrollOffset());
4289 } 4352 }
4290 4353
4291 // Test that the top controls coming in and out maintains the same aspect ratio 4354 // Test that the top controls coming in and out maintains the same aspect ratio
4292 // between the inner and outer viewports. 4355 // between the inner and outer viewports.
4293 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsAspectRatio) { 4356 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsAspectRatio) {
4294 SetupTopControlsAndScrollLayerWithVirtualViewport( 4357 SetupTopControlsAndScrollLayerWithVirtualViewport(
4295 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); 4358 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400));
4296 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 2.f); 4359 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 2.f);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
4364 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 4427 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
4365 4428
4366 EXPECT_EQ(0, host_impl_->top_controls_manager()->ContentTopOffset()); 4429 EXPECT_EQ(0, host_impl_->top_controls_manager()->ContentTopOffset());
4367 EXPECT_EQ(host_impl_->InnerViewportScrollLayer(), 4430 EXPECT_EQ(host_impl_->InnerViewportScrollLayer(),
4368 host_impl_->CurrentlyScrollingLayer()); 4431 host_impl_->CurrentlyScrollingLayer());
4369 4432
4370 host_impl_->ScrollEnd(EndState().get()); 4433 host_impl_->ScrollEnd(EndState().get());
4371 4434
4372 // Position the viewports such that the inner viewport will be scrolled. 4435 // Position the viewports such that the inner viewport will be scrolled.
4373 gfx::Vector2dF inner_viewport_offset(0.f, 25.f); 4436 gfx::Vector2dF inner_viewport_offset(0.f, 25.f);
4374 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2dF()); 4437 SetScrollOffsetDelta(host_impl_->OuterViewportScrollLayer(),
4375 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(inner_viewport_offset); 4438 gfx::Vector2dF());
4439 SetScrollOffsetDelta(host_impl_->InnerViewportScrollLayer(),
4440 inner_viewport_offset);
4376 4441
4377 scroll_delta = gfx::Vector2dF(0.f, -65.f); 4442 scroll_delta = gfx::Vector2dF(0.f, -65.f);
4378 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 4443 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
4379 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 4444 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
4380 InputHandler::GESTURE) 4445 InputHandler::GESTURE)
4381 .thread); 4446 .thread);
4382 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 4447 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
4383 4448
4384 EXPECT_EQ(top_controls_height_, 4449 EXPECT_EQ(top_controls_height_,
4385 host_impl_->top_controls_manager()->ContentTopOffset()); 4450 host_impl_->top_controls_manager()->ContentTopOffset());
4386 EXPECT_FLOAT_EQ( 4451 EXPECT_FLOAT_EQ(
4387 inner_viewport_offset.y() + (scroll_delta.y() + top_controls_height_), 4452 inner_viewport_offset.y() + (scroll_delta.y() + top_controls_height_),
4388 host_impl_->InnerViewportScrollLayer()->ScrollDelta().y()); 4453 ScrollDelta(host_impl_->InnerViewportScrollLayer()).y());
4389 4454
4390 host_impl_->ScrollEnd(EndState().get()); 4455 host_impl_->ScrollEnd(EndState().get());
4391 } 4456 }
4392 4457
4393 TEST_F(LayerTreeHostImplTopControlsTest, 4458 TEST_F(LayerTreeHostImplTopControlsTest,
4394 ScrollNonScrollableRootWithTopControls) { 4459 ScrollNonScrollableRootWithTopControls) {
4395 settings_ = DefaultSettings(); 4460 settings_ = DefaultSettings();
4396 CreateHostImpl(settings_, CreateOutputSurface()); 4461 CreateHostImpl(settings_, CreateOutputSurface());
4397 SetupTopControlsAndScrollLayerWithVirtualViewport( 4462 SetupTopControlsAndScrollLayerWithVirtualViewport(
4398 layer_size_, layer_size_, layer_size_); 4463 layer_size_, layer_size_, layer_size_);
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
4803 scoped_ptr<LayerImpl> child = 4868 scoped_ptr<LayerImpl> child =
4804 CreateScrollableLayer(2, content_size, root.get()); 4869 CreateScrollableLayer(2, content_size, root.get());
4805 LayerImpl* grand_child_layer = grand_child.get(); 4870 LayerImpl* grand_child_layer = grand_child.get();
4806 child->AddChild(std::move(grand_child)); 4871 child->AddChild(std::move(grand_child));
4807 4872
4808 LayerImpl* child_layer = child.get(); 4873 LayerImpl* child_layer = child.get();
4809 root->AddChild(std::move(child)); 4874 root->AddChild(std::move(child));
4810 host_impl_->active_tree()->SetRootLayer(std::move(root)); 4875 host_impl_->active_tree()->SetRootLayer(std::move(root));
4811 host_impl_->active_tree()->DidBecomeActive(); 4876 host_impl_->active_tree()->DidBecomeActive();
4812 host_impl_->SetViewportSize(surface_size); 4877 host_impl_->SetViewportSize(surface_size);
4813 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 5)); 4878 grand_child_layer->layer_tree_impl()
4814 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(3, 0)); 4879 ->property_trees()
4880 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(),
4881 gfx::ScrollOffset(0, 5));
4882 child_layer->layer_tree_impl()
4883 ->property_trees()
4884 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(),
4885 gfx::ScrollOffset(3, 0));
4815 4886
4816 SetNeedsRebuildPropertyTrees(); 4887 SetNeedsRebuildPropertyTrees();
4817 DrawFrame(); 4888 DrawFrame();
4818 { 4889 {
4819 gfx::Vector2d scroll_delta(-8, -7); 4890 gfx::Vector2d scroll_delta(-8, -7);
4820 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 4891 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
4821 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 4892 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
4822 InputHandler::WHEEL) 4893 InputHandler::WHEEL)
4823 .thread); 4894 .thread);
4824 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 4895 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
4865 root_scrolling->AddChild(std::move(child)); 4936 root_scrolling->AddChild(std::move(child));
4866 root_clip->AddChild(std::move(root_scrolling)); 4937 root_clip->AddChild(std::move(root_scrolling));
4867 EXPECT_EQ(viewport_size, root_clip->bounds()); 4938 EXPECT_EQ(viewport_size, root_clip->bounds());
4868 root_ptr->AddChild(std::move(root_clip)); 4939 root_ptr->AddChild(std::move(root_clip));
4869 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); 4940 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr));
4870 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, 4941 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3,
4871 Layer::INVALID_ID); 4942 Layer::INVALID_ID);
4872 host_impl_->active_tree()->DidBecomeActive(); 4943 host_impl_->active_tree()->DidBecomeActive();
4873 host_impl_->SetViewportSize(viewport_size); 4944 host_impl_->SetViewportSize(viewport_size);
4874 4945
4875 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); 4946 grand_child_layer->layer_tree_impl()
4876 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 3)); 4947 ->property_trees()
4948 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(),
4949 gfx::ScrollOffset(0, 2));
4950 child_layer->layer_tree_impl()
4951 ->property_trees()
4952 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(),
4953 gfx::ScrollOffset(0, 3));
4877 4954
4878 SetNeedsRebuildPropertyTrees(); 4955 SetNeedsRebuildPropertyTrees();
4879 DrawFrame(); 4956 DrawFrame();
4880 { 4957 {
4881 gfx::Vector2d scroll_delta(0, -10); 4958 gfx::Vector2d scroll_delta(0, -10);
4882 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 4959 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
4883 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 4960 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
4884 InputHandler::NON_BUBBLING_GESTURE) 4961 InputHandler::NON_BUBBLING_GESTURE)
4885 .thread); 4962 .thread);
4886 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 4963 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
5085 .thread); 5162 .thread);
5086 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); 5163 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get());
5087 host_impl_->ScrollEnd(EndState().get()); 5164 host_impl_->ScrollEnd(EndState().get());
5088 5165
5089 // The layer should have scrolled down in its local coordinates. 5166 // The layer should have scrolled down in its local coordinates.
5090 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); 5167 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas();
5091 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), 5168 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(),
5092 gfx::Vector2d(0, gesture_scroll_delta.x()))); 5169 gfx::Vector2d(0, gesture_scroll_delta.x())));
5093 5170
5094 // Reset and scroll down with the wheel. 5171 // Reset and scroll down with the wheel.
5095 scroll_layer->SetScrollDelta(gfx::Vector2dF()); 5172 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF());
5096 gfx::Vector2d wheel_scroll_delta(0, 10); 5173 gfx::Vector2d wheel_scroll_delta(0, 10);
5097 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 5174 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
5098 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 5175 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
5099 InputHandler::WHEEL) 5176 InputHandler::WHEEL)
5100 .thread); 5177 .thread);
5101 host_impl_->ScrollBy(UpdateState(gfx::Point(), wheel_scroll_delta).get()); 5178 host_impl_->ScrollBy(UpdateState(gfx::Point(), wheel_scroll_delta).get());
5102 host_impl_->ScrollEnd(EndState().get()); 5179 host_impl_->ScrollEnd(EndState().get());
5103 5180
5104 // The layer should have scrolled down in its local coordinates. 5181 // The layer should have scrolled down in its local coordinates.
5105 scroll_info = host_impl_->ProcessScrollDeltas(); 5182 scroll_info = host_impl_->ProcessScrollDeltas();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
5159 host_impl_->ProcessScrollDeltas(); 5236 host_impl_->ProcessScrollDeltas();
5160 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id, 5237 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id,
5161 expected_scroll_delta)); 5238 expected_scroll_delta));
5162 5239
5163 // The root scroll layer should not have scrolled, because the input delta 5240 // The root scroll layer should not have scrolled, because the input delta
5164 // was close to the layer's axis of movement. 5241 // was close to the layer's axis of movement.
5165 EXPECT_EQ(scroll_info->scrolls.size(), 1u); 5242 EXPECT_EQ(scroll_info->scrolls.size(), 1u);
5166 } 5243 }
5167 { 5244 {
5168 // Now reset and scroll the same amount horizontally. 5245 // Now reset and scroll the same amount horizontally.
5169 child_ptr->SetScrollDelta(gfx::Vector2dF()); 5246 SetScrollOffsetDelta(child_ptr, gfx::Vector2dF());
5170 gfx::Vector2d gesture_scroll_delta(10, 0); 5247 gfx::Vector2d gesture_scroll_delta(10, 0);
5171 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 5248 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
5172 host_impl_->ScrollBegin(BeginState(gfx::Point(1, 1)).get(), 5249 host_impl_->ScrollBegin(BeginState(gfx::Point(1, 1)).get(),
5173 InputHandler::GESTURE) 5250 InputHandler::GESTURE)
5174 .thread); 5251 .thread);
5175 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); 5252 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get());
5176 host_impl_->ScrollEnd(EndState().get()); 5253 host_impl_->ScrollEnd(EndState().get());
5177 5254
5178 // The child layer shouldn't have scrolled. 5255 // The child layer shouldn't have scrolled.
5179 gfx::Vector2d expected_scroll_delta( 5256 gfx::Vector2d expected_scroll_delta(
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
5240 expected_scroll_deltas[2] = gfx::Vector2d(4, 0); 5317 expected_scroll_deltas[2] = gfx::Vector2d(4, 0);
5241 expected_scroll_deltas[3] = gfx::Vector2d(4, 0); 5318 expected_scroll_deltas[3] = gfx::Vector2d(4, 0);
5242 5319
5243 gfx::Point viewport_point(1, 1); 5320 gfx::Point viewport_point(1, 1);
5244 5321
5245 SetNeedsRebuildPropertyTrees(); 5322 SetNeedsRebuildPropertyTrees();
5246 // Scroll in screen coordinates with a gesture. Each scroll starts 5323 // Scroll in screen coordinates with a gesture. Each scroll starts
5247 // where the previous scroll ended, but the scroll position is reset 5324 // where the previous scroll ended, but the scroll position is reset
5248 // for each scroll. 5325 // for each scroll.
5249 for (int i = 0; i < 4; ++i) { 5326 for (int i = 0; i < 4; ++i) {
5250 child_ptr->SetScrollDelta(gfx::Vector2dF()); 5327 SetScrollOffsetDelta(child_ptr, gfx::Vector2dF());
5251 DrawFrame(); 5328 DrawFrame();
5252 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 5329 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
5253 host_impl_->ScrollBegin(BeginState(viewport_point).get(), 5330 host_impl_->ScrollBegin(BeginState(viewport_point).get(),
5254 InputHandler::GESTURE) 5331 InputHandler::GESTURE)
5255 .thread); 5332 .thread);
5256 host_impl_->ScrollBy( 5333 host_impl_->ScrollBy(
5257 UpdateState(viewport_point, gesture_scroll_deltas[i]).get()); 5334 UpdateState(viewport_point, gesture_scroll_deltas[i]).get());
5258 viewport_point += gesture_scroll_deltas[i]; 5335 viewport_point += gesture_scroll_deltas[i];
5259 host_impl_->ScrollEnd(EndState().get()); 5336 host_impl_->ScrollEnd(EndState().get());
5260 5337
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
5292 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 5369 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
5293 host_impl_->ScrollEnd(EndState().get()); 5370 host_impl_->ScrollEnd(EndState().get());
5294 5371
5295 // The layer should have scrolled down in its local coordinates, but half the 5372 // The layer should have scrolled down in its local coordinates, but half the
5296 // amount. 5373 // amount.
5297 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); 5374 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas();
5298 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), 5375 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(),
5299 gfx::Vector2d(0, scroll_delta.y() / scale))); 5376 gfx::Vector2d(0, scroll_delta.y() / scale)));
5300 5377
5301 // Reset and scroll down with the wheel. 5378 // Reset and scroll down with the wheel.
5302 scroll_layer->SetScrollDelta(gfx::Vector2dF()); 5379 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF());
5303 gfx::Vector2d wheel_scroll_delta(0, 10); 5380 gfx::Vector2d wheel_scroll_delta(0, 10);
5304 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 5381 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
5305 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 5382 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
5306 InputHandler::WHEEL) 5383 InputHandler::WHEEL)
5307 .thread); 5384 .thread);
5308 host_impl_->ScrollBy(UpdateState(gfx::Point(), wheel_scroll_delta).get()); 5385 host_impl_->ScrollBy(UpdateState(gfx::Point(), wheel_scroll_delta).get());
5309 host_impl_->ScrollEnd(EndState().get()); 5386 host_impl_->ScrollEnd(EndState().get());
5310 5387
5311 // It should apply the scale factor to the scroll delta for the wheel event. 5388 // It should apply the scale factor to the scroll delta for the wheel event.
5312 scroll_info = host_impl_->ProcessScrollDeltas(); 5389 scroll_info = host_impl_->ProcessScrollDeltas();
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
5400 host_impl_->SetViewportSize(gfx::Size(10, 20)); 5477 host_impl_->SetViewportSize(gfx::Size(10, 20));
5401 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); 5478 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100));
5402 LayerImpl* clip_layer = scroll_layer->parent()->parent(); 5479 LayerImpl* clip_layer = scroll_layer->parent()->parent();
5403 SetNeedsRebuildPropertyTrees(); 5480 SetNeedsRebuildPropertyTrees();
5404 clip_layer->SetBounds(gfx::Size(10, 20)); 5481 clip_layer->SetBounds(gfx::Size(10, 20));
5405 RebuildPropertyTrees(); 5482 RebuildPropertyTrees();
5406 5483
5407 host_impl_->BindToClient(&scroll_watcher); 5484 host_impl_->BindToClient(&scroll_watcher);
5408 5485
5409 gfx::Vector2dF initial_scroll_delta(10.f, 10.f); 5486 gfx::Vector2dF initial_scroll_delta(10.f, 10.f);
5410 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); 5487 scroll_layer->layer_tree_impl()
5411 scroll_layer->SetScrollDelta(initial_scroll_delta); 5488 ->property_trees()
5489 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(),
5490 gfx::ScrollOffset());
5491 SetScrollOffsetDelta(scroll_layer, initial_scroll_delta);
5412 5492
5413 EXPECT_EQ(gfx::ScrollOffset(), scroll_watcher.last_set_scroll_offset()); 5493 EXPECT_EQ(gfx::ScrollOffset(), scroll_watcher.last_set_scroll_offset());
5414 5494
5415 // Requesting an update results in the current scroll offset being set. 5495 // Requesting an update results in the current scroll offset being set.
5416 host_impl_->RequestUpdateForSynchronousInputHandler(); 5496 host_impl_->RequestUpdateForSynchronousInputHandler();
5417 EXPECT_EQ(gfx::ScrollOffset(initial_scroll_delta), 5497 EXPECT_EQ(gfx::ScrollOffset(initial_scroll_delta),
5418 scroll_watcher.last_set_scroll_offset()); 5498 scroll_watcher.last_set_scroll_offset());
5419 5499
5420 // Setting the delegate results in the scrollable_size, max_scroll_offset, 5500 // Setting the delegate results in the scrollable_size, max_scroll_offset,
5421 // page_scale_factor and {min|max}_page_scale_factor being set. 5501 // page_scale_factor and {min|max}_page_scale_factor being set.
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
5672 CreateScrollableLayer(3, surface_size, root_clip.get()); 5752 CreateScrollableLayer(3, surface_size, root_clip.get());
5673 5753
5674 scoped_ptr<LayerImpl> child = 5754 scoped_ptr<LayerImpl> child =
5675 CreateScrollableLayer(2, surface_size, root_clip.get()); 5755 CreateScrollableLayer(2, surface_size, root_clip.get());
5676 LayerImpl* grand_child_layer = grand_child.get(); 5756 LayerImpl* grand_child_layer = grand_child.get();
5677 child->AddChild(std::move(grand_child)); 5757 child->AddChild(std::move(grand_child));
5678 5758
5679 LayerImpl* child_layer = child.get(); 5759 LayerImpl* child_layer = child.get();
5680 root->AddChild(std::move(child)); 5760 root->AddChild(std::move(child));
5681 root_clip->AddChild(std::move(root)); 5761 root_clip->AddChild(std::move(root));
5682 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 3)); 5762 child_layer->layer_tree_impl()
5683 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); 5763 ->property_trees()
5764 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(),
5765 gfx::ScrollOffset(0, 3));
5766 grand_child_layer->layer_tree_impl()
5767 ->property_trees()
5768 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(),
5769 gfx::ScrollOffset(0, 2));
5684 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); 5770 host_impl_->active_tree()->SetRootLayer(std::move(root_clip));
5685 host_impl_->active_tree()->DidBecomeActive(); 5771 host_impl_->active_tree()->DidBecomeActive();
5686 host_impl_->SetViewportSize(surface_size); 5772 host_impl_->SetViewportSize(surface_size);
5687 SetNeedsRebuildPropertyTrees(); 5773 SetNeedsRebuildPropertyTrees();
5688 DrawFrame(); 5774 DrawFrame();
5689 { 5775 {
5690 gfx::Vector2d scroll_delta(0, -10); 5776 gfx::Vector2d scroll_delta(0, -10);
5691 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 5777 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
5692 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 5778 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
5693 InputHandler::NON_BUBBLING_GESTURE) 5779 InputHandler::NON_BUBBLING_GESTURE)
(...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after
7207 3, raster_source); 7293 3, raster_source);
7208 LayerImpl* content_layer = scoped_content_layer.get(); 7294 LayerImpl* content_layer = scoped_content_layer.get();
7209 scrolling_layer->AddChild(std::move(scoped_content_layer)); 7295 scrolling_layer->AddChild(std::move(scoped_content_layer));
7210 content_layer->SetBounds(content_layer_bounds); 7296 content_layer->SetBounds(content_layer_bounds);
7211 content_layer->SetDrawsContent(true); 7297 content_layer->SetDrawsContent(true);
7212 7298
7213 root->SetBounds(root_size); 7299 root->SetBounds(root_size);
7214 7300
7215 gfx::ScrollOffset scroll_offset(100000, 0); 7301 gfx::ScrollOffset scroll_offset(100000, 0);
7216 scrolling_layer->SetScrollClipLayer(root->id()); 7302 scrolling_layer->SetScrollClipLayer(root->id());
7217 scrolling_layer->PushScrollOffsetFromMainThread(scroll_offset); 7303 scrolling_layer->layer_tree_impl()
7304 ->property_trees()
7305 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scrolling_layer->id(),
7306 scroll_offset);
7218 7307
7219 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 7308 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
7220 host_impl_->ActivateSyncTree(); 7309 host_impl_->ActivateSyncTree();
7221 7310
7222 bool update_lcd_text = false; 7311 bool update_lcd_text = false;
7223 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); 7312 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text);
7224 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); 7313 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size());
7225 7314
7226 LayerTreeHostImpl::FrameData frame; 7315 LayerTreeHostImpl::FrameData frame;
7227 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); 7316 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame));
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
7608 // Scroll a child layer beyond its maximum scroll range and make sure the 7697 // Scroll a child layer beyond its maximum scroll range and make sure the
7609 // the scroll doesn't bubble up to the parent layer. 7698 // the scroll doesn't bubble up to the parent layer.
7610 gfx::Size surface_size(10, 10); 7699 gfx::Size surface_size(10, 10);
7611 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 7700 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
7612 root->SetForceRenderSurface(true); 7701 root->SetForceRenderSurface(true);
7613 scoped_ptr<LayerImpl> root_scrolling = 7702 scoped_ptr<LayerImpl> root_scrolling =
7614 CreateScrollableLayer(2, surface_size, root.get()); 7703 CreateScrollableLayer(2, surface_size, root.get());
7615 7704
7616 scoped_ptr<LayerImpl> grand_child = 7705 scoped_ptr<LayerImpl> grand_child =
7617 CreateScrollableLayer(4, surface_size, root.get()); 7706 CreateScrollableLayer(4, surface_size, root.get());
7618 grand_child->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); 7707 grand_child->layer_tree_impl()
7708 ->property_trees()
7709 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child->id(),
7710 gfx::ScrollOffset(0, 2));
7619 7711
7620 scoped_ptr<LayerImpl> child = 7712 scoped_ptr<LayerImpl> child =
7621 CreateScrollableLayer(3, surface_size, root.get()); 7713 CreateScrollableLayer(3, surface_size, root.get());
7622 child->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 4)); 7714 child->layer_tree_impl()
7715 ->property_trees()
7716 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child->id(),
7717 gfx::ScrollOffset(0, 4));
7623 child->AddChild(std::move(grand_child)); 7718 child->AddChild(std::move(grand_child));
7624 7719
7625 root_scrolling->AddChild(std::move(child)); 7720 root_scrolling->AddChild(std::move(child));
7626 root->AddChild(std::move(root_scrolling)); 7721 root->AddChild(std::move(root_scrolling));
7627 host_impl_->active_tree()->SetRootLayer(std::move(root)); 7722 host_impl_->active_tree()->SetRootLayer(std::move(root));
7628 host_impl_->active_tree()->DidBecomeActive(); 7723 host_impl_->active_tree()->DidBecomeActive();
7629 host_impl_->SetViewportSize(surface_size); 7724 host_impl_->SetViewportSize(surface_size);
7630 SetNeedsRebuildPropertyTrees(); 7725 SetNeedsRebuildPropertyTrees();
7631 DrawFrame(); 7726 DrawFrame();
7632 { 7727 {
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
8166 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); 8261 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f);
8167 } 8262 }
8168 8263
8169 protected: 8264 protected:
8170 static const int top_controls_height_; 8265 static const int top_controls_height_;
8171 }; 8266 };
8172 8267
8173 const int LayerTreeHostImplWithTopControlsTest::top_controls_height_ = 50; 8268 const int LayerTreeHostImplWithTopControlsTest::top_controls_height_ = 50;
8174 8269
8175 TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) { 8270 TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) {
8176 SetupScrollAndContentsLayers(gfx::Size(100, 100)) 8271 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100));
8177 ->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 10)); 8272 scroll_layer->layer_tree_impl()
8273 ->property_trees()
8274 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(),
8275 gfx::ScrollOffset(0, 10));
8178 BeginFrameArgs begin_frame_args = 8276 BeginFrameArgs begin_frame_args =
8179 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); 8277 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
8180 host_impl_->WillBeginImplFrame(begin_frame_args); 8278 host_impl_->WillBeginImplFrame(begin_frame_args);
8181 host_impl_->Animate(); 8279 host_impl_->Animate();
8182 EXPECT_FALSE(did_request_redraw_); 8280 EXPECT_FALSE(did_request_redraw_);
8183 host_impl_->DidFinishImplFrame(); 8281 host_impl_->DidFinishImplFrame();
8184 } 8282 }
8185 8283
8186 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsHeightIsCommitted) { 8284 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsHeightIsCommitted) {
8187 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 8285 SetupScrollAndContentsLayers(gfx::Size(100, 100));
(...skipping 14 matching lines...) Expand all
8202 host_impl_->ActivateSyncTree(); 8300 host_impl_->ActivateSyncTree();
8203 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ControlsTopOffset()); 8301 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ControlsTopOffset());
8204 8302
8205 host_impl_->CreatePendingTree(); 8303 host_impl_->CreatePendingTree();
8206 host_impl_->sync_tree()->set_top_controls_height(50); 8304 host_impl_->sync_tree()->set_top_controls_height(50);
8207 host_impl_->ActivateSyncTree(); 8305 host_impl_->ActivateSyncTree();
8208 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ControlsTopOffset()); 8306 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ControlsTopOffset());
8209 } 8307 }
8210 8308
8211 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationScheduling) { 8309 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationScheduling) {
8212 SetupScrollAndContentsLayers(gfx::Size(100, 100)) 8310 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100));
8213 ->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 10)); 8311 scroll_layer->layer_tree_impl()
8312 ->property_trees()
8313 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(),
8314 gfx::ScrollOffset(0, 10));
8214 host_impl_->DidChangeTopControlsPosition(); 8315 host_impl_->DidChangeTopControlsPosition();
8215 EXPECT_TRUE(did_request_next_frame_); 8316 EXPECT_TRUE(did_request_next_frame_);
8216 EXPECT_TRUE(did_request_redraw_); 8317 EXPECT_TRUE(did_request_redraw_);
8217 } 8318 }
8218 8319
8219 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { 8320 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) {
8220 InputHandlerScrollResult result; 8321 InputHandlerScrollResult result;
8221 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); 8322 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200));
8222 host_impl_->SetViewportSize(gfx::Size(100, 100)); 8323 host_impl_->SetViewportSize(gfx::Size(100, 100));
8223 host_impl_->top_controls_manager()->UpdateTopControlsState( 8324 host_impl_->top_controls_manager()->UpdateTopControlsState(
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
8400 } 8501 }
8401 EXPECT_FALSE(host_impl_->top_controls_manager()->has_animation()); 8502 EXPECT_FALSE(host_impl_->top_controls_manager()->has_animation());
8402 } 8503 }
8403 8504
8404 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) { 8505 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) {
8405 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); 8506 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200));
8406 host_impl_->SetViewportSize(gfx::Size(100, 100)); 8507 host_impl_->SetViewportSize(gfx::Size(100, 100));
8407 host_impl_->top_controls_manager()->UpdateTopControlsState( 8508 host_impl_->top_controls_manager()->UpdateTopControlsState(
8408 BOTH, SHOWN, false); 8509 BOTH, SHOWN, false);
8409 float initial_scroll_offset = 50; 8510 float initial_scroll_offset = 50;
8410 scroll_layer->PushScrollOffsetFromMainThread( 8511 scroll_layer->layer_tree_impl()
8411 gfx::ScrollOffset(0, initial_scroll_offset)); 8512 ->property_trees()
8513 ->scroll_tree.UpdateScrollOffsetBaseForTesting(
8514 scroll_layer->id(), gfx::ScrollOffset(0, initial_scroll_offset));
8412 DrawFrame(); 8515 DrawFrame();
8413 8516
8414 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 8517 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
8415 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 8518 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
8416 InputHandler::GESTURE) 8519 InputHandler::GESTURE)
8417 .thread); 8520 .thread);
8418 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); 8521 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset());
8419 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), 8522 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(),
8420 scroll_layer->CurrentScrollOffset().ToString()); 8523 scroll_layer->CurrentScrollOffset().ToString());
8421 8524
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
8471 host_impl_->top_controls_manager()->ControlsTopOffset()); 8574 host_impl_->top_controls_manager()->ControlsTopOffset());
8472 } 8575 }
8473 8576
8474 TEST_F(LayerTreeHostImplWithTopControlsTest, 8577 TEST_F(LayerTreeHostImplWithTopControlsTest,
8475 TopControlsAnimationAfterMainThreadFlingStopped) { 8578 TopControlsAnimationAfterMainThreadFlingStopped) {
8476 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); 8579 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200));
8477 host_impl_->SetViewportSize(gfx::Size(100, 100)); 8580 host_impl_->SetViewportSize(gfx::Size(100, 100));
8478 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, 8581 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN,
8479 false); 8582 false);
8480 float initial_scroll_offset = 50; 8583 float initial_scroll_offset = 50;
8481 scroll_layer->PushScrollOffsetFromMainThread( 8584 scroll_layer->layer_tree_impl()
8482 gfx::ScrollOffset(0, initial_scroll_offset)); 8585 ->property_trees()
8586 ->scroll_tree.UpdateScrollOffsetBaseForTesting(
8587 scroll_layer->id(), gfx::ScrollOffset(0, initial_scroll_offset));
8483 DrawFrame(); 8588 DrawFrame();
8484 8589
8485 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 8590 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
8486 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 8591 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
8487 InputHandler::GESTURE) 8592 InputHandler::GESTURE)
8488 .thread); 8593 .thread);
8489 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); 8594 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset());
8490 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), 8595 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(),
8491 scroll_layer->CurrentScrollOffset().ToString()); 8596 scroll_layer->CurrentScrollOffset().ToString());
8492 8597
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
8624 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); 8729 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree();
8625 const int kOuterViewportClipLayerId = 6; 8730 const int kOuterViewportClipLayerId = 6;
8626 const int kOuterViewportScrollLayerId = 7; 8731 const int kOuterViewportScrollLayerId = 7;
8627 const int kInnerViewportScrollLayerId = 2; 8732 const int kInnerViewportScrollLayerId = 2;
8628 const int kInnerViewportClipLayerId = 4; 8733 const int kInnerViewportClipLayerId = 4;
8629 const int kPageScaleLayerId = 5; 8734 const int kPageScaleLayerId = 5;
8630 8735
8631 scoped_ptr<LayerImpl> inner_scroll = 8736 scoped_ptr<LayerImpl> inner_scroll =
8632 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); 8737 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId);
8633 inner_scroll->SetIsContainerForFixedPositionLayers(true); 8738 inner_scroll->SetIsContainerForFixedPositionLayers(true);
8634 inner_scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); 8739 inner_scroll->layer_tree_impl()
8740 ->property_trees()
8741 ->scroll_tree.UpdateScrollOffsetBaseForTesting(inner_scroll->id(),
8742 gfx::ScrollOffset());
8635 8743
8636 scoped_ptr<LayerImpl> inner_clip = 8744 scoped_ptr<LayerImpl> inner_clip =
8637 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); 8745 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId);
8638 inner_clip->SetBounds(inner_viewport); 8746 inner_clip->SetBounds(inner_viewport);
8639 8747
8640 scoped_ptr<LayerImpl> page_scale = 8748 scoped_ptr<LayerImpl> page_scale =
8641 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); 8749 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId);
8642 8750
8643 inner_scroll->SetScrollClipLayer(inner_clip->id()); 8751 inner_scroll->SetScrollClipLayer(inner_clip->id());
8644 inner_scroll->SetBounds(outer_viewport); 8752 inner_scroll->SetBounds(outer_viewport);
8645 inner_scroll->SetPosition(gfx::PointF()); 8753 inner_scroll->SetPosition(gfx::PointF());
8646 8754
8647 scoped_ptr<LayerImpl> outer_clip = 8755 scoped_ptr<LayerImpl> outer_clip =
8648 LayerImpl::Create(layer_tree_impl, kOuterViewportClipLayerId); 8756 LayerImpl::Create(layer_tree_impl, kOuterViewportClipLayerId);
8649 outer_clip->SetBounds(outer_viewport); 8757 outer_clip->SetBounds(outer_viewport);
8650 outer_clip->SetIsContainerForFixedPositionLayers(true); 8758 outer_clip->SetIsContainerForFixedPositionLayers(true);
8651 8759
8652 scoped_ptr<LayerImpl> outer_scroll = 8760 scoped_ptr<LayerImpl> outer_scroll =
8653 LayerImpl::Create(layer_tree_impl, kOuterViewportScrollLayerId); 8761 LayerImpl::Create(layer_tree_impl, kOuterViewportScrollLayerId);
8654 outer_scroll->SetScrollClipLayer(outer_clip->id()); 8762 outer_scroll->SetScrollClipLayer(outer_clip->id());
8655 outer_scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); 8763 outer_scroll->layer_tree_impl()
8764 ->property_trees()
8765 ->scroll_tree.UpdateScrollOffsetBaseForTesting(outer_scroll->id(),
8766 gfx::ScrollOffset());
8656 outer_scroll->SetBounds(content_size); 8767 outer_scroll->SetBounds(content_size);
8657 outer_scroll->SetPosition(gfx::PointF()); 8768 outer_scroll->SetPosition(gfx::PointF());
8658 8769
8659 scoped_ptr<LayerImpl> contents = 8770 scoped_ptr<LayerImpl> contents =
8660 LayerImpl::Create(layer_tree_impl, 8); 8771 LayerImpl::Create(layer_tree_impl, 8);
8661 contents->SetDrawsContent(true); 8772 contents->SetDrawsContent(true);
8662 contents->SetBounds(content_size); 8773 contents->SetBounds(content_size);
8663 contents->SetPosition(gfx::PointF()); 8774 contents->SetPosition(gfx::PointF());
8664 8775
8665 outer_scroll->AddChild(std::move(contents)); 8776 outer_scroll->AddChild(std::move(contents));
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after
9745 EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer()); 9856 EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer());
9746 9857
9747 float min_page_scale = 1.f, max_page_scale = 4.f; 9858 float min_page_scale = 1.f, max_page_scale = 4.f;
9748 float page_scale_factor = 1.f; 9859 float page_scale_factor = 1.f;
9749 9860
9750 // The scroll deltas should have the page scale factor applied. 9861 // The scroll deltas should have the page scale factor applied.
9751 { 9862 {
9752 host_impl_->active_tree()->PushPageScaleFromMainThread( 9863 host_impl_->active_tree()->PushPageScaleFromMainThread(
9753 page_scale_factor, min_page_scale, max_page_scale); 9864 page_scale_factor, min_page_scale, max_page_scale);
9754 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); 9865 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
9755 scroll_layer->SetScrollDelta(gfx::Vector2d()); 9866 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d());
9756 9867
9757 float page_scale_delta = 2.f; 9868 float page_scale_delta = 2.f;
9758 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 9869 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
9759 InputHandler::GESTURE); 9870 InputHandler::GESTURE);
9760 host_impl_->PinchGestureBegin(); 9871 host_impl_->PinchGestureBegin();
9761 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); 9872 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point());
9762 host_impl_->PinchGestureEnd(); 9873 host_impl_->PinchGestureEnd();
9763 host_impl_->ScrollEnd(EndState().get()); 9874 host_impl_->ScrollEnd(EndState().get());
9764 9875
9765 gfx::Vector2dF scroll_delta(0, 5); 9876 gfx::Vector2dF scroll_delta(0, 5);
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
10218 // There should not be any jitter measured till we hit the fixed point hits 10329 // There should not be any jitter measured till we hit the fixed point hits
10219 // threshold. 10330 // threshold.
10220 float expected_jitter = 10331 float expected_jitter =
10221 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; 10332 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0;
10222 EXPECT_EQ(jitter, expected_jitter); 10333 EXPECT_EQ(jitter, expected_jitter);
10223 } 10334 }
10224 } 10335 }
10225 10336
10226 } // namespace 10337 } // namespace
10227 } // namespace cc 10338 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698