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

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

Issue 2417783005: [Master/Overview CL] Make PageScaleFactor work for oopif subframe.
Patch Set: Rebase to master@{#429656}. Created 4 years, 1 month 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_impl.h » ('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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 if (host_impl_) 196 if (host_impl_)
197 host_impl_->ReleaseCompositorFrameSink(); 197 host_impl_->ReleaseCompositorFrameSink();
198 host_impl_ = LayerTreeHostImpl::Create( 198 host_impl_ = LayerTreeHostImpl::Create(
199 settings, this, task_runner_provider, &stats_instrumentation_, 199 settings, this, task_runner_provider, &stats_instrumentation_,
200 &task_graph_runner_, 200 &task_graph_runner_,
201 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); 201 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0);
202 compositor_frame_sink_ = std::move(compositor_frame_sink); 202 compositor_frame_sink_ = std::move(compositor_frame_sink);
203 host_impl_->SetVisible(true); 203 host_impl_->SetVisible(true);
204 bool init = host_impl_->InitializeRenderer(compositor_frame_sink_.get()); 204 bool init = host_impl_->InitializeRenderer(compositor_frame_sink_.get());
205 host_impl_->SetViewportSize(gfx::Size(10, 10)); 205 host_impl_->SetViewportSize(gfx::Size(10, 10));
206 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 206 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f, 1.f);
207 // Set the BeginFrameArgs so that methods which use it are able to. 207 // Set the BeginFrameArgs so that methods which use it are able to.
208 host_impl_->WillBeginImplFrame(CreateBeginFrameArgsForTesting( 208 host_impl_->WillBeginImplFrame(CreateBeginFrameArgsForTesting(
209 BEGINFRAME_FROM_HERE, 209 BEGINFRAME_FROM_HERE,
210 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1))); 210 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1)));
211 host_impl_->DidFinishImplFrame(); 211 host_impl_->DidFinishImplFrame();
212 212
213 timeline_ = 213 timeline_ =
214 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); 214 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
215 GetImplAnimationHost()->AddAnimationTimeline(timeline_); 215 GetImplAnimationHost()->AddAnimationTimeline(timeline_);
216 216
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer()); 1596 EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer());
1597 LayerImpl* container_layer = scroll_layer->scroll_clip_layer(); 1597 LayerImpl* container_layer = scroll_layer->scroll_clip_layer();
1598 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); 1598 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds());
1599 1599
1600 float min_page_scale = 1.f, max_page_scale = 4.f; 1600 float min_page_scale = 1.f, max_page_scale = 4.f;
1601 float page_scale_factor = 1.f; 1601 float page_scale_factor = 1.f;
1602 1602
1603 // The impl-based pinch zoom should adjust the max scroll position. 1603 // The impl-based pinch zoom should adjust the max scroll position.
1604 { 1604 {
1605 host_impl_->active_tree()->PushPageScaleFromMainThread( 1605 host_impl_->active_tree()->PushPageScaleFromMainThread(
1606 page_scale_factor, min_page_scale, max_page_scale); 1606 page_scale_factor, min_page_scale, min_page_scale, max_page_scale);
1607 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); 1607 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
1608 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d()); 1608 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d());
1609 1609
1610 float page_scale_delta = 2.f; 1610 float page_scale_delta = 2.f;
1611 1611
1612 host_impl_->ScrollBegin(BeginState(gfx::Point(50, 50)).get(), 1612 host_impl_->ScrollBegin(BeginState(gfx::Point(50, 50)).get(),
1613 InputHandler::TOUCHSCREEN); 1613 InputHandler::TOUCHSCREEN);
1614 host_impl_->PinchGestureBegin(); 1614 host_impl_->PinchGestureBegin();
1615 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); 1615 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50));
1616 host_impl_->PinchGestureEnd(); 1616 host_impl_->PinchGestureEnd();
1617 host_impl_->ScrollEnd(EndState().get()); 1617 host_impl_->ScrollEnd(EndState().get());
1618 EXPECT_FALSE(did_request_next_frame_); 1618 EXPECT_FALSE(did_request_next_frame_);
1619 EXPECT_TRUE(did_request_redraw_); 1619 EXPECT_TRUE(did_request_redraw_);
1620 EXPECT_TRUE(did_request_commit_); 1620 EXPECT_TRUE(did_request_commit_);
1621 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); 1621 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds());
1622 1622
1623 std::unique_ptr<ScrollAndScaleSet> scroll_info = 1623 std::unique_ptr<ScrollAndScaleSet> scroll_info =
1624 host_impl_->ProcessScrollDeltas(); 1624 host_impl_->ProcessScrollDeltas();
1625 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); 1625 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta);
1626 1626
1627 EXPECT_EQ(gfx::ScrollOffset(75.0, 75.0).ToString(), 1627 EXPECT_EQ(gfx::ScrollOffset(75.0, 75.0).ToString(),
1628 scroll_layer->MaxScrollOffset().ToString()); 1628 scroll_layer->MaxScrollOffset().ToString());
1629 } 1629 }
1630 1630
1631 // Scrolling after a pinch gesture should always be in local space. The 1631 // Scrolling after a pinch gesture should always be in local space. The
1632 // scroll deltas have the page scale factor applied. 1632 // scroll deltas have the page scale factor applied.
1633 { 1633 {
1634 host_impl_->active_tree()->PushPageScaleFromMainThread( 1634 host_impl_->active_tree()->PushPageScaleFromMainThread(
1635 page_scale_factor, min_page_scale, max_page_scale); 1635 page_scale_factor, min_page_scale, min_page_scale, max_page_scale);
1636 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); 1636 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
1637 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d()); 1637 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d());
1638 1638
1639 float page_scale_delta = 2.f; 1639 float page_scale_delta = 2.f;
1640 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 1640 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
1641 InputHandler::TOUCHSCREEN); 1641 InputHandler::TOUCHSCREEN);
1642 host_impl_->PinchGestureBegin(); 1642 host_impl_->PinchGestureBegin();
1643 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); 1643 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point());
1644 host_impl_->PinchGestureEnd(); 1644 host_impl_->PinchGestureEnd();
1645 host_impl_->ScrollEnd(EndState().get()); 1645 host_impl_->ScrollEnd(EndState().get());
(...skipping 10 matching lines...) Expand all
1656 host_impl_->ProcessScrollDeltas(); 1656 host_impl_->ProcessScrollDeltas();
1657 EXPECT_TRUE(ScrollInfoContains( 1657 EXPECT_TRUE(ScrollInfoContains(
1658 *scroll_info.get(), scroll_layer->id(), 1658 *scroll_info.get(), scroll_layer->id(),
1659 gfx::Vector2d(0, scroll_delta.y() / page_scale_delta))); 1659 gfx::Vector2d(0, scroll_delta.y() / page_scale_delta)));
1660 } 1660 }
1661 } 1661 }
1662 1662
1663 TEST_F(LayerTreeHostImplTest, ViewportScrollOrder) { 1663 TEST_F(LayerTreeHostImplTest, ViewportScrollOrder) {
1664 LayerTreeSettings settings = DefaultSettings(); 1664 LayerTreeSettings settings = DefaultSettings();
1665 CreateHostImpl(settings, CreateCompositorFrameSink()); 1665 CreateHostImpl(settings, CreateCompositorFrameSink());
1666 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.25f, 4.f); 1666 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 0.25f, 4.f);
1667 1667
1668 const gfx::Size content_size(1000, 1000); 1668 const gfx::Size content_size(1000, 1000);
1669 const gfx::Size viewport_size(500, 500); 1669 const gfx::Size viewport_size(500, 500);
1670 CreateBasicVirtualViewportLayers(viewport_size, content_size); 1670 CreateBasicVirtualViewportLayers(viewport_size, content_size);
1671 1671
1672 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); 1672 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer();
1673 outer_scroll_layer->SetDrawsContent(true); 1673 outer_scroll_layer->SetDrawsContent(true);
1674 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); 1674 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer();
1675 inner_scroll_layer->SetDrawsContent(true); 1675 inner_scroll_layer->SetDrawsContent(true);
1676 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 1676 host_impl_->active_tree()->BuildPropertyTreesForTesting();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 EXPECT_VECTOR_EQ( 1722 EXPECT_VECTOR_EQ(
1723 gfx::Vector2dF(300, 300), 1723 gfx::Vector2dF(300, 300),
1724 outer_scroll_layer->CurrentScrollOffset()); 1724 outer_scroll_layer->CurrentScrollOffset());
1725 } 1725 }
1726 1726
1727 // Make sure scrolls smaller than a unit applied to the viewport don't get 1727 // Make sure scrolls smaller than a unit applied to the viewport don't get
1728 // dropped. crbug.com/539334. 1728 // dropped. crbug.com/539334.
1729 TEST_F(LayerTreeHostImplTest, ScrollViewportWithFractionalAmounts) { 1729 TEST_F(LayerTreeHostImplTest, ScrollViewportWithFractionalAmounts) {
1730 LayerTreeSettings settings = DefaultSettings(); 1730 LayerTreeSettings settings = DefaultSettings();
1731 CreateHostImpl(settings, CreateCompositorFrameSink()); 1731 CreateHostImpl(settings, CreateCompositorFrameSink());
1732 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); 1732 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f, 2.f);
1733 1733
1734 const gfx::Size content_size(1000, 1000); 1734 const gfx::Size content_size(1000, 1000);
1735 const gfx::Size viewport_size(500, 500); 1735 const gfx::Size viewport_size(500, 500);
1736 CreateBasicVirtualViewportLayers(viewport_size, content_size); 1736 CreateBasicVirtualViewportLayers(viewport_size, content_size);
1737 1737
1738 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); 1738 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer();
1739 outer_scroll_layer->SetDrawsContent(true); 1739 outer_scroll_layer->SetDrawsContent(true);
1740 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); 1740 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer();
1741 inner_scroll_layer->SetDrawsContent(true); 1741 inner_scroll_layer->SetDrawsContent(true);
1742 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 1742 host_impl_->active_tree()->BuildPropertyTreesForTesting();
(...skipping 11 matching lines...) Expand all
1754 host_impl_->ScrollBy( 1754 host_impl_->ScrollBy(
1755 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(0.125f, 0.125f)).get()); 1755 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(0.125f, 0.125f)).get());
1756 EXPECT_VECTOR2DF_EQ( 1756 EXPECT_VECTOR2DF_EQ(
1757 gfx::Vector2dF(0.125f, 0.125f), 1757 gfx::Vector2dF(0.125f, 0.125f),
1758 outer_scroll_layer->CurrentScrollOffset()); 1758 outer_scroll_layer->CurrentScrollOffset());
1759 EXPECT_VECTOR2DF_EQ( 1759 EXPECT_VECTOR2DF_EQ(
1760 gfx::Vector2dF(0, 0), 1760 gfx::Vector2dF(0, 0),
1761 inner_scroll_layer->CurrentScrollOffset()); 1761 inner_scroll_layer->CurrentScrollOffset());
1762 host_impl_->ScrollEnd(EndState().get()); 1762 host_impl_->ScrollEnd(EndState().get());
1763 1763
1764 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f); 1764 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 1.f, 2.f);
1765 1765
1766 // Now that we zoomed in, the scroll should be applied to the inner viewport. 1766 // Now that we zoomed in, the scroll should be applied to the inner viewport.
1767 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), 1767 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(),
1768 InputHandler::TOUCHSCREEN); 1768 InputHandler::TOUCHSCREEN);
1769 host_impl_->ScrollBy( 1769 host_impl_->ScrollBy(
1770 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(0.5f, 0.5f)).get()); 1770 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(0.5f, 0.5f)).get());
1771 EXPECT_VECTOR2DF_EQ( 1771 EXPECT_VECTOR2DF_EQ(
1772 gfx::Vector2dF(0.125f, 0.125f), 1772 gfx::Vector2dF(0.125f, 0.125f),
1773 outer_scroll_layer->CurrentScrollOffset()); 1773 outer_scroll_layer->CurrentScrollOffset());
1774 EXPECT_VECTOR2DF_EQ( 1774 EXPECT_VECTOR2DF_EQ(
1775 gfx::Vector2dF(0.25f, 0.25f), 1775 gfx::Vector2dF(0.25f, 0.25f),
1776 inner_scroll_layer->CurrentScrollOffset()); 1776 inner_scroll_layer->CurrentScrollOffset());
1777 host_impl_->ScrollEnd(EndState().get()); 1777 host_impl_->ScrollEnd(EndState().get());
1778 } 1778 }
1779 1779
1780 // Tests that scrolls during a pinch gesture (i.e. "two-finger" scrolls) work 1780 // Tests that scrolls during a pinch gesture (i.e. "two-finger" scrolls) work
1781 // as expected. That is, scrolling during a pinch should bubble from the inner 1781 // as expected. That is, scrolling during a pinch should bubble from the inner
1782 // to the outer viewport. 1782 // to the outer viewport.
1783 TEST_F(LayerTreeHostImplTest, ScrollDuringPinchGesture) { 1783 TEST_F(LayerTreeHostImplTest, ScrollDuringPinchGesture) {
1784 LayerTreeSettings settings = DefaultSettings(); 1784 LayerTreeSettings settings = DefaultSettings();
1785 CreateHostImpl(settings, CreateCompositorFrameSink()); 1785 CreateHostImpl(settings, CreateCompositorFrameSink());
1786 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); 1786 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f, 2.f);
1787 1787
1788 const gfx::Size content_size(1000, 1000); 1788 const gfx::Size content_size(1000, 1000);
1789 const gfx::Size viewport_size(500, 500); 1789 const gfx::Size viewport_size(500, 500);
1790 CreateBasicVirtualViewportLayers(viewport_size, content_size); 1790 CreateBasicVirtualViewportLayers(viewport_size, content_size);
1791 1791
1792 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); 1792 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer();
1793 outer_scroll_layer->SetDrawsContent(true); 1793 outer_scroll_layer->SetDrawsContent(true);
1794 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); 1794 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer();
1795 inner_scroll_layer->SetDrawsContent(true); 1795 inner_scroll_layer->SetDrawsContent(true);
1796 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 1796 host_impl_->active_tree()->BuildPropertyTreesForTesting();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1837 host_impl_->PinchGestureEnd(); 1837 host_impl_->PinchGestureEnd();
1838 host_impl_->ScrollEnd(EndState().get()); 1838 host_impl_->ScrollEnd(EndState().get());
1839 } 1839 }
1840 1840
1841 // Tests the "snapping" of pinch-zoom gestures to the screen edge. That is, when 1841 // Tests the "snapping" of pinch-zoom gestures to the screen edge. That is, when
1842 // a pinch zoom is anchored within a certain margin of the screen edge, we 1842 // a pinch zoom is anchored within a certain margin of the screen edge, we
1843 // should assume the user means to scroll into the edge of the screen. 1843 // should assume the user means to scroll into the edge of the screen.
1844 TEST_F(LayerTreeHostImplTest, PinchZoomSnapsToScreenEdge) { 1844 TEST_F(LayerTreeHostImplTest, PinchZoomSnapsToScreenEdge) {
1845 LayerTreeSettings settings = DefaultSettings(); 1845 LayerTreeSettings settings = DefaultSettings();
1846 CreateHostImpl(settings, CreateCompositorFrameSink()); 1846 CreateHostImpl(settings, CreateCompositorFrameSink());
1847 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); 1847 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f, 2.f);
1848 1848
1849 const gfx::Size content_size(1000, 1000); 1849 const gfx::Size content_size(1000, 1000);
1850 const gfx::Size viewport_size(500, 500); 1850 const gfx::Size viewport_size(500, 500);
1851 CreateBasicVirtualViewportLayers(viewport_size, content_size); 1851 CreateBasicVirtualViewportLayers(viewport_size, content_size);
1852 1852
1853 int offsetFromEdge = Viewport::kPinchZoomSnapMarginDips - 5; 1853 int offsetFromEdge = Viewport::kPinchZoomSnapMarginDips - 5;
1854 gfx::Point anchor(viewport_size.width() - offsetFromEdge, 1854 gfx::Point anchor(viewport_size.width() - offsetFromEdge,
1855 viewport_size.height() - offsetFromEdge); 1855 viewport_size.height() - offsetFromEdge);
1856 1856
1857 // Pinch in within the margins. The scroll should stay exactly locked to the 1857 // Pinch in within the margins. The scroll should stay exactly locked to the
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1927 const gfx::Size viewport_size(100, 100); 1927 const gfx::Size viewport_size(100, 100);
1928 CreateBasicVirtualViewportLayers(viewport_size, content_size); 1928 CreateBasicVirtualViewportLayers(viewport_size, content_size);
1929 1929
1930 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); 1930 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer();
1931 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); 1931 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer();
1932 1932
1933 // Zoom into the page by a 2X factor 1933 // Zoom into the page by a 2X factor
1934 float min_page_scale = 1.f, max_page_scale = 4.f; 1934 float min_page_scale = 1.f, max_page_scale = 4.f;
1935 float page_scale_factor = 2.f; 1935 float page_scale_factor = 2.f;
1936 host_impl_->active_tree()->PushPageScaleFromMainThread( 1936 host_impl_->active_tree()->PushPageScaleFromMainThread(
1937 page_scale_factor, min_page_scale, max_page_scale); 1937 page_scale_factor, min_page_scale, min_page_scale, max_page_scale);
1938 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); 1938 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
1939 1939
1940 // Scroll by a small amount, there should be no bubbling to the outer 1940 // Scroll by a small amount, there should be no bubbling to the outer
1941 // viewport. 1941 // viewport.
1942 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), 1942 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(),
1943 InputHandler::WHEEL); 1943 InputHandler::WHEEL);
1944 host_impl_->ScrollBy( 1944 host_impl_->ScrollBy(
1945 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(10.f, 20.f)).get()); 1945 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(10.f, 20.f)).get());
1946 host_impl_->ScrollEnd(EndState().get()); 1946 host_impl_->ScrollEnd(EndState().get());
1947 1947
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
2106 DrawFrame(); 2106 DrawFrame();
2107 2107
2108 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); 2108 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer();
2109 DCHECK(scroll_layer); 2109 DCHECK(scroll_layer);
2110 2110
2111 float min_page_scale = 1.f; 2111 float min_page_scale = 1.f;
2112 float max_page_scale = 4.f; 2112 float max_page_scale = 4.f;
2113 2113
2114 // Basic pinch zoom in gesture 2114 // Basic pinch zoom in gesture
2115 { 2115 {
2116 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2116 host_impl_->active_tree()->PushPageScaleFromMainThread(
2117 max_page_scale); 2117 1.f, min_page_scale, min_page_scale, max_page_scale);
2118 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d()); 2118 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d());
2119 2119
2120 float page_scale_delta = 2.f; 2120 float page_scale_delta = 2.f;
2121 host_impl_->ScrollBegin(BeginState(gfx::Point(50, 50)).get(), 2121 host_impl_->ScrollBegin(BeginState(gfx::Point(50, 50)).get(),
2122 InputHandler::TOUCHSCREEN); 2122 InputHandler::TOUCHSCREEN);
2123 host_impl_->PinchGestureBegin(); 2123 host_impl_->PinchGestureBegin();
2124 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); 2124 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50));
2125 host_impl_->PinchGestureEnd(); 2125 host_impl_->PinchGestureEnd();
2126 host_impl_->ScrollEnd(EndState().get()); 2126 host_impl_->ScrollEnd(EndState().get());
2127 EXPECT_FALSE(did_request_next_frame_); 2127 EXPECT_FALSE(did_request_next_frame_);
2128 EXPECT_TRUE(did_request_redraw_); 2128 EXPECT_TRUE(did_request_redraw_);
2129 EXPECT_TRUE(did_request_commit_); 2129 EXPECT_TRUE(did_request_commit_);
2130 2130
2131 std::unique_ptr<ScrollAndScaleSet> scroll_info = 2131 std::unique_ptr<ScrollAndScaleSet> scroll_info =
2132 host_impl_->ProcessScrollDeltas(); 2132 host_impl_->ProcessScrollDeltas();
2133 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); 2133 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta);
2134 } 2134 }
2135 2135
2136 // Zoom-in clamping 2136 // Zoom-in clamping
2137 { 2137 {
2138 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2138 host_impl_->active_tree()->PushPageScaleFromMainThread(
2139 max_page_scale); 2139 1.f, min_page_scale, min_page_scale, max_page_scale);
2140 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d()); 2140 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d());
2141 float page_scale_delta = 10.f; 2141 float page_scale_delta = 10.f;
2142 2142
2143 host_impl_->ScrollBegin(BeginState(gfx::Point(50, 50)).get(), 2143 host_impl_->ScrollBegin(BeginState(gfx::Point(50, 50)).get(),
2144 InputHandler::TOUCHSCREEN); 2144 InputHandler::TOUCHSCREEN);
2145 host_impl_->PinchGestureBegin(); 2145 host_impl_->PinchGestureBegin();
2146 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); 2146 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50));
2147 host_impl_->PinchGestureEnd(); 2147 host_impl_->PinchGestureEnd();
2148 host_impl_->ScrollEnd(EndState().get()); 2148 host_impl_->ScrollEnd(EndState().get());
2149 2149
2150 std::unique_ptr<ScrollAndScaleSet> scroll_info = 2150 std::unique_ptr<ScrollAndScaleSet> scroll_info =
2151 host_impl_->ProcessScrollDeltas(); 2151 host_impl_->ProcessScrollDeltas();
2152 EXPECT_EQ(scroll_info->page_scale_delta, max_page_scale); 2152 EXPECT_EQ(scroll_info->page_scale_delta, max_page_scale);
2153 } 2153 }
2154 2154
2155 // Zoom-out clamping 2155 // Zoom-out clamping
2156 { 2156 {
2157 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2157 host_impl_->active_tree()->PushPageScaleFromMainThread(
2158 max_page_scale); 2158 1.f, min_page_scale, min_page_scale, max_page_scale);
2159 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d()); 2159 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d());
2160 scroll_layer->layer_tree_impl() 2160 scroll_layer->layer_tree_impl()
2161 ->property_trees() 2161 ->property_trees()
2162 ->scroll_tree.CollectScrollDeltasForTesting(); 2162 ->scroll_tree.CollectScrollDeltasForTesting();
2163 scroll_layer->layer_tree_impl() 2163 scroll_layer->layer_tree_impl()
2164 ->property_trees() 2164 ->property_trees()
2165 ->scroll_tree.UpdateScrollOffsetBaseForTesting( 2165 ->scroll_tree.UpdateScrollOffsetBaseForTesting(
2166 scroll_layer->id(), gfx::ScrollOffset(50, 50)); 2166 scroll_layer->id(), gfx::ScrollOffset(50, 50));
2167 2167
2168 float page_scale_delta = 0.1f; 2168 float page_scale_delta = 0.1f;
2169 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 2169 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
2170 InputHandler::TOUCHSCREEN); 2170 InputHandler::TOUCHSCREEN);
2171 host_impl_->PinchGestureBegin(); 2171 host_impl_->PinchGestureBegin();
2172 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); 2172 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point());
2173 host_impl_->PinchGestureEnd(); 2173 host_impl_->PinchGestureEnd();
2174 host_impl_->ScrollEnd(EndState().get()); 2174 host_impl_->ScrollEnd(EndState().get());
2175 2175
2176 std::unique_ptr<ScrollAndScaleSet> scroll_info = 2176 std::unique_ptr<ScrollAndScaleSet> scroll_info =
2177 host_impl_->ProcessScrollDeltas(); 2177 host_impl_->ProcessScrollDeltas();
2178 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); 2178 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale);
2179 2179
2180 EXPECT_TRUE(scroll_info->scrolls.empty()); 2180 EXPECT_TRUE(scroll_info->scrolls.empty());
2181 } 2181 }
2182 2182
2183 // Two-finger panning should not happen based on pinch events only 2183 // Two-finger panning should not happen based on pinch events only
2184 { 2184 {
2185 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2185 host_impl_->active_tree()->PushPageScaleFromMainThread(
2186 max_page_scale); 2186 1.f, min_page_scale, min_page_scale, max_page_scale);
2187 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d()); 2187 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d());
2188 scroll_layer->layer_tree_impl() 2188 scroll_layer->layer_tree_impl()
2189 ->property_trees() 2189 ->property_trees()
2190 ->scroll_tree.CollectScrollDeltasForTesting(); 2190 ->scroll_tree.CollectScrollDeltasForTesting();
2191 scroll_layer->layer_tree_impl() 2191 scroll_layer->layer_tree_impl()
2192 ->property_trees() 2192 ->property_trees()
2193 ->scroll_tree.UpdateScrollOffsetBaseForTesting( 2193 ->scroll_tree.UpdateScrollOffsetBaseForTesting(
2194 scroll_layer->id(), gfx::ScrollOffset(20, 20)); 2194 scroll_layer->id(), gfx::ScrollOffset(20, 20));
2195 2195
2196 float page_scale_delta = 1.f; 2196 float page_scale_delta = 1.f;
2197 host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(), 2197 host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(),
2198 InputHandler::TOUCHSCREEN); 2198 InputHandler::TOUCHSCREEN);
2199 host_impl_->PinchGestureBegin(); 2199 host_impl_->PinchGestureBegin();
2200 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); 2200 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10));
2201 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); 2201 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20));
2202 host_impl_->PinchGestureEnd(); 2202 host_impl_->PinchGestureEnd();
2203 host_impl_->ScrollEnd(EndState().get()); 2203 host_impl_->ScrollEnd(EndState().get());
2204 2204
2205 std::unique_ptr<ScrollAndScaleSet> scroll_info = 2205 std::unique_ptr<ScrollAndScaleSet> scroll_info =
2206 host_impl_->ProcessScrollDeltas(); 2206 host_impl_->ProcessScrollDeltas();
2207 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); 2207 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta);
2208 EXPECT_TRUE(scroll_info->scrolls.empty()); 2208 EXPECT_TRUE(scroll_info->scrolls.empty());
2209 } 2209 }
2210 2210
2211 // Two-finger panning should work with interleaved scroll events 2211 // Two-finger panning should work with interleaved scroll events
2212 { 2212 {
2213 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2213 host_impl_->active_tree()->PushPageScaleFromMainThread(
2214 max_page_scale); 2214 1.f, min_page_scale, min_page_scale, max_page_scale);
2215 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d()); 2215 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d());
2216 scroll_layer->layer_tree_impl() 2216 scroll_layer->layer_tree_impl()
2217 ->property_trees() 2217 ->property_trees()
2218 ->scroll_tree.CollectScrollDeltasForTesting(); 2218 ->scroll_tree.CollectScrollDeltasForTesting();
2219 scroll_layer->layer_tree_impl() 2219 scroll_layer->layer_tree_impl()
2220 ->property_trees() 2220 ->property_trees()
2221 ->scroll_tree.UpdateScrollOffsetBaseForTesting( 2221 ->scroll_tree.UpdateScrollOffsetBaseForTesting(
2222 scroll_layer->id(), gfx::ScrollOffset(20, 20)); 2222 scroll_layer->id(), gfx::ScrollOffset(20, 20));
2223 2223
2224 float page_scale_delta = 1.f; 2224 float page_scale_delta = 1.f;
2225 host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(), 2225 host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(),
2226 InputHandler::TOUCHSCREEN); 2226 InputHandler::TOUCHSCREEN);
2227 host_impl_->PinchGestureBegin(); 2227 host_impl_->PinchGestureBegin();
2228 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); 2228 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10));
2229 host_impl_->ScrollBy( 2229 host_impl_->ScrollBy(
2230 UpdateState(gfx::Point(10, 10), gfx::Vector2d(-10, -10)).get()); 2230 UpdateState(gfx::Point(10, 10), gfx::Vector2d(-10, -10)).get());
2231 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); 2231 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20));
2232 host_impl_->PinchGestureEnd(); 2232 host_impl_->PinchGestureEnd();
2233 host_impl_->ScrollEnd(EndState().get()); 2233 host_impl_->ScrollEnd(EndState().get());
2234 2234
2235 std::unique_ptr<ScrollAndScaleSet> scroll_info = 2235 std::unique_ptr<ScrollAndScaleSet> scroll_info =
2236 host_impl_->ProcessScrollDeltas(); 2236 host_impl_->ProcessScrollDeltas();
2237 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); 2237 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta);
2238 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), 2238 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(),
2239 gfx::Vector2d(-10, -10))); 2239 gfx::Vector2d(-10, -10)));
2240 } 2240 }
2241 2241
2242 // Two-finger panning should work when starting fully zoomed out. 2242 // Two-finger panning should work when starting fully zoomed out.
2243 { 2243 {
2244 host_impl_->active_tree()->PushPageScaleFromMainThread(0.5f, 0.5f, 4.f); 2244 host_impl_->active_tree()->PushPageScaleFromMainThread(0.5f, 1.f, 0.5f,
2245 4.f);
2245 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d()); 2246 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d());
2246 scroll_layer->layer_tree_impl() 2247 scroll_layer->layer_tree_impl()
2247 ->property_trees() 2248 ->property_trees()
2248 ->scroll_tree.CollectScrollDeltasForTesting(); 2249 ->scroll_tree.CollectScrollDeltasForTesting();
2249 scroll_layer->layer_tree_impl() 2250 scroll_layer->layer_tree_impl()
2250 ->property_trees() 2251 ->property_trees()
2251 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), 2252 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(),
2252 gfx::ScrollOffset(0, 0)); 2253 gfx::ScrollOffset(0, 0));
2253 2254
2254 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), 2255 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2288 base::TimeDelta::FromSeconds(1); 2289 base::TimeDelta::FromSeconds(1);
2289 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); 2290 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
2290 base::TimeTicks halfway_through_animation = start_time + duration / 2; 2291 base::TimeTicks halfway_through_animation = start_time + duration / 2;
2291 base::TimeTicks end_time = start_time + duration; 2292 base::TimeTicks end_time = start_time + duration;
2292 2293
2293 BeginFrameArgs begin_frame_args = 2294 BeginFrameArgs begin_frame_args =
2294 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); 2295 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
2295 2296
2296 // Non-anchor zoom-in 2297 // Non-anchor zoom-in
2297 { 2298 {
2298 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2299 host_impl_->active_tree()->PushPageScaleFromMainThread(
2299 max_page_scale); 2300 1.f, min_page_scale, min_page_scale, max_page_scale);
2300 scroll_layer->layer_tree_impl() 2301 scroll_layer->layer_tree_impl()
2301 ->property_trees() 2302 ->property_trees()
2302 ->scroll_tree.UpdateScrollOffsetBaseForTesting( 2303 ->scroll_tree.UpdateScrollOffsetBaseForTesting(
2303 scroll_layer->id(), gfx::ScrollOffset(50, 50)); 2304 scroll_layer->id(), gfx::ScrollOffset(50, 50));
2304 2305
2305 did_request_redraw_ = false; 2306 did_request_redraw_ = false;
2306 did_request_next_frame_ = false; 2307 did_request_next_frame_ = false;
2307 host_impl_->active_tree()->SetPendingPageScaleAnimation( 2308 host_impl_->active_tree()->SetPendingPageScaleAnimation(
2308 std::unique_ptr<PendingPageScaleAnimation>( 2309 std::unique_ptr<PendingPageScaleAnimation>(
2309 new PendingPageScaleAnimation(gfx::Vector2d(), false, 2.f, 2310 new PendingPageScaleAnimation(gfx::Vector2d(), false, 2.f,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2346 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), 2347 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(),
2347 gfx::Vector2d(-50, -50))); 2348 gfx::Vector2d(-50, -50)));
2348 } 2349 }
2349 2350
2350 start_time += base::TimeDelta::FromSeconds(10); 2351 start_time += base::TimeDelta::FromSeconds(10);
2351 halfway_through_animation += base::TimeDelta::FromSeconds(10); 2352 halfway_through_animation += base::TimeDelta::FromSeconds(10);
2352 end_time += base::TimeDelta::FromSeconds(10); 2353 end_time += base::TimeDelta::FromSeconds(10);
2353 2354
2354 // Anchor zoom-out 2355 // Anchor zoom-out
2355 { 2356 {
2356 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2357 host_impl_->active_tree()->PushPageScaleFromMainThread(
2357 max_page_scale); 2358 1.f, min_page_scale, min_page_scale, max_page_scale);
2358 scroll_layer->layer_tree_impl() 2359 scroll_layer->layer_tree_impl()
2359 ->property_trees() 2360 ->property_trees()
2360 ->scroll_tree.UpdateScrollOffsetBaseForTesting( 2361 ->scroll_tree.UpdateScrollOffsetBaseForTesting(
2361 scroll_layer->id(), gfx::ScrollOffset(50, 50)); 2362 scroll_layer->id(), gfx::ScrollOffset(50, 50));
2362 2363
2363 did_request_redraw_ = false; 2364 did_request_redraw_ = false;
2364 did_request_next_frame_ = false; 2365 did_request_next_frame_ = false;
2365 host_impl_->active_tree()->SetPendingPageScaleAnimation( 2366 host_impl_->active_tree()->SetPendingPageScaleAnimation(
2366 std::unique_ptr<PendingPageScaleAnimation>( 2367 std::unique_ptr<PendingPageScaleAnimation>(
2367 new PendingPageScaleAnimation(gfx::Vector2d(25, 25), true, 2368 new PendingPageScaleAnimation(gfx::Vector2d(25, 25), true,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2413 base::TimeDelta::FromSeconds(1); 2414 base::TimeDelta::FromSeconds(1);
2414 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); 2415 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
2415 base::TimeTicks halfway_through_animation = start_time + duration / 2; 2416 base::TimeTicks halfway_through_animation = start_time + duration / 2;
2416 base::TimeTicks end_time = start_time + duration; 2417 base::TimeTicks end_time = start_time + duration;
2417 2418
2418 BeginFrameArgs begin_frame_args = 2419 BeginFrameArgs begin_frame_args =
2419 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); 2420 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
2420 2421
2421 // Anchor zoom with unchanged page scale should not change scroll or scale. 2422 // Anchor zoom with unchanged page scale should not change scroll or scale.
2422 { 2423 {
2423 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2424 host_impl_->active_tree()->PushPageScaleFromMainThread(
2424 max_page_scale); 2425 1.f, min_page_scale, min_page_scale, max_page_scale);
2425 scroll_layer->layer_tree_impl() 2426 scroll_layer->layer_tree_impl()
2426 ->property_trees() 2427 ->property_trees()
2427 ->scroll_tree.UpdateScrollOffsetBaseForTesting( 2428 ->scroll_tree.UpdateScrollOffsetBaseForTesting(
2428 scroll_layer->id(), gfx::ScrollOffset(50, 50)); 2429 scroll_layer->id(), gfx::ScrollOffset(50, 50));
2429 2430
2430 host_impl_->active_tree()->SetPendingPageScaleAnimation( 2431 host_impl_->active_tree()->SetPendingPageScaleAnimation(
2431 std::unique_ptr<PendingPageScaleAnimation>( 2432 std::unique_ptr<PendingPageScaleAnimation>(
2432 new PendingPageScaleAnimation(gfx::Vector2d(), true, 1.f, 2433 new PendingPageScaleAnimation(gfx::Vector2d(), true, 1.f,
2433 duration))); 2434 duration)));
2434 host_impl_->ActivateSyncTree(); 2435 host_impl_->ActivateSyncTree();
(...skipping 16 matching lines...) Expand all
2451 2452
2452 std::unique_ptr<ScrollAndScaleSet> scroll_info = 2453 std::unique_ptr<ScrollAndScaleSet> scroll_info =
2453 host_impl_->ProcessScrollDeltas(); 2454 host_impl_->ProcessScrollDeltas();
2454 EXPECT_EQ(scroll_info->page_scale_delta, 1); 2455 EXPECT_EQ(scroll_info->page_scale_delta, 1);
2455 ExpectNone(*scroll_info, scroll_layer->id()); 2456 ExpectNone(*scroll_info, scroll_layer->id());
2456 } 2457 }
2457 } 2458 }
2458 2459
2459 TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) { 2460 TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) {
2460 host_impl_->CreatePendingTree(); 2461 host_impl_->CreatePendingTree();
2461 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 2462 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f, 1.f);
2462 CreateScrollAndContentsLayers( 2463 CreateScrollAndContentsLayers(
2463 host_impl_->pending_tree(), 2464 host_impl_->pending_tree(),
2464 gfx::Size(100, 100)); 2465 gfx::Size(100, 100));
2465 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 2466 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
2466 host_impl_->ActivateSyncTree(); 2467 host_impl_->ActivateSyncTree();
2467 DrawFrame(); 2468 DrawFrame();
2468 2469
2469 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); 2470 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer();
2470 DCHECK(scroll_layer); 2471 DCHECK(scroll_layer);
2471 2472
2472 float min_page_scale = 0.5f; 2473 float min_page_scale = 0.5f;
2473 float max_page_scale = 4.f; 2474 float max_page_scale = 4.f;
2474 host_impl_->sync_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2475 host_impl_->sync_tree()->PushPageScaleFromMainThread(
2475 max_page_scale); 2476 1.f, min_page_scale, min_page_scale, max_page_scale);
2476 host_impl_->ActivateSyncTree(); 2477 host_impl_->ActivateSyncTree();
2477 2478
2478 base::TimeTicks start_time = base::TimeTicks() + 2479 base::TimeTicks start_time = base::TimeTicks() +
2479 base::TimeDelta::FromSeconds(1); 2480 base::TimeDelta::FromSeconds(1);
2480 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); 2481 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
2481 base::TimeTicks third_through_animation = start_time + duration / 3; 2482 base::TimeTicks third_through_animation = start_time + duration / 3;
2482 base::TimeTicks halfway_through_animation = start_time + duration / 2; 2483 base::TimeTicks halfway_through_animation = start_time + duration / 2;
2483 base::TimeTicks end_time = start_time + duration; 2484 base::TimeTicks end_time = start_time + duration;
2484 float target_scale = 2.f; 2485 float target_scale = 2.f;
2485 2486
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2587 2588
2588 base::TimeTicks start_time = 2589 base::TimeTicks start_time =
2589 base::TimeTicks() + base::TimeDelta::FromSeconds(1); 2590 base::TimeTicks() + base::TimeDelta::FromSeconds(1);
2590 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); 2591 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
2591 base::TimeTicks halfway_through_animation = start_time + duration / 2; 2592 base::TimeTicks halfway_through_animation = start_time + duration / 2;
2592 base::TimeTicks end_time = start_time + duration; 2593 base::TimeTicks end_time = start_time + duration;
2593 2594
2594 BeginFrameArgs begin_frame_args = 2595 BeginFrameArgs begin_frame_args =
2595 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); 2596 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
2596 2597
2597 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); 2598 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 0.5f, 4.f);
2598 scroll_layer->layer_tree_impl() 2599 scroll_layer->layer_tree_impl()
2599 ->property_trees() 2600 ->property_trees()
2600 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), 2601 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(),
2601 gfx::ScrollOffset(50, 50)); 2602 gfx::ScrollOffset(50, 50));
2602 2603
2603 did_complete_page_scale_animation_ = false; 2604 did_complete_page_scale_animation_ = false;
2604 host_impl_->active_tree()->SetPendingPageScaleAnimation( 2605 host_impl_->active_tree()->SetPendingPageScaleAnimation(
2605 std::unique_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( 2606 std::unique_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation(
2606 gfx::Vector2d(), false, 2.f, duration))); 2607 gfx::Vector2d(), false, 2.f, duration)));
2607 host_impl_->ActivateSyncTree(); 2608 host_impl_->ActivateSyncTree();
(...skipping 12 matching lines...) Expand all
2620 begin_frame_args.frame_time = end_time; 2621 begin_frame_args.frame_time = end_time;
2621 host_impl_->WillBeginImplFrame(begin_frame_args); 2622 host_impl_->WillBeginImplFrame(begin_frame_args);
2622 host_impl_->Animate(); 2623 host_impl_->Animate();
2623 EXPECT_TRUE(did_complete_page_scale_animation_); 2624 EXPECT_TRUE(did_complete_page_scale_animation_);
2624 host_impl_->DidFinishImplFrame(); 2625 host_impl_->DidFinishImplFrame();
2625 } 2626 }
2626 2627
2627 TEST_F(LayerTreeHostImplTest, MaxScrollOffsetAffectedByBoundsDelta) { 2628 TEST_F(LayerTreeHostImplTest, MaxScrollOffsetAffectedByBoundsDelta) {
2628 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 2629 SetupScrollAndContentsLayers(gfx::Size(100, 100));
2629 host_impl_->SetViewportSize(gfx::Size(50, 50)); 2630 host_impl_->SetViewportSize(gfx::Size(50, 50));
2630 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); 2631 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 0.5f, 4.f);
2631 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 2632 host_impl_->active_tree()->BuildPropertyTreesForTesting();
2632 DrawFrame(); 2633 DrawFrame();
2633 2634
2634 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); 2635 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer();
2635 LayerImpl* inner_container = inner_scroll->scroll_clip_layer(); 2636 LayerImpl* inner_container = inner_scroll->scroll_clip_layer();
2636 DCHECK(inner_scroll); 2637 DCHECK(inner_scroll);
2637 DCHECK(inner_container); 2638 DCHECK(inner_container);
2638 EXPECT_EQ(gfx::ScrollOffset(50, 50), inner_scroll->MaxScrollOffset()); 2639 EXPECT_EQ(gfx::ScrollOffset(50, 50), inner_scroll->MaxScrollOffset());
2639 2640
2640 inner_container->SetBoundsDelta(gfx::Vector2dF(15.f, 15.f)); 2641 inner_container->SetBoundsDelta(gfx::Vector2dF(15.f, 15.f));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2691 LayerTreeHostImplOverridePhysicalTime* host_impl_override_time = 2692 LayerTreeHostImplOverridePhysicalTime* host_impl_override_time =
2692 new LayerTreeHostImplOverridePhysicalTime( 2693 new LayerTreeHostImplOverridePhysicalTime(
2693 settings, this, &task_runner_provider_, &task_graph_runner_, 2694 settings, this, &task_runner_provider_, &task_graph_runner_,
2694 &stats_instrumentation_); 2695 &stats_instrumentation_);
2695 host_impl_ = base::WrapUnique(host_impl_override_time); 2696 host_impl_ = base::WrapUnique(host_impl_override_time);
2696 compositor_frame_sink_ = CreateCompositorFrameSink(); 2697 compositor_frame_sink_ = CreateCompositorFrameSink();
2697 host_impl_->SetVisible(true); 2698 host_impl_->SetVisible(true);
2698 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); 2699 host_impl_->InitializeRenderer(compositor_frame_sink_.get());
2699 2700
2700 SetupScrollAndContentsLayers(content_size); 2701 SetupScrollAndContentsLayers(content_size);
2701 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); 2702 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f, 4.f);
2702 host_impl_->SetViewportSize( 2703 host_impl_->SetViewportSize(
2703 gfx::Size(content_size.width() / 2, content_size.height() / 2)); 2704 gfx::Size(content_size.width() / 2, content_size.height() / 2));
2704 2705
2705 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = 2706 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar =
2706 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 400, 2707 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 400,
2707 VERTICAL, 10, 0, false, true); 2708 VERTICAL, 10, 0, false, true);
2708 scrollbar->test_properties()->opacity = 0.f; 2709 scrollbar->test_properties()->opacity = 0.f;
2709 EXPECT_FLOAT_EQ(0.f, scrollbar->test_properties()->opacity); 2710 EXPECT_FLOAT_EQ(0.f, scrollbar->test_properties()->opacity);
2710 2711
2711 LayerImpl* scroll = host_impl_->active_tree()->OuterViewportScrollLayer(); 2712 LayerImpl* scroll = host_impl_->active_tree()->OuterViewportScrollLayer();
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
2870 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); 2871 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2871 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 2872 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2872 2873
2873 host_impl_->ScrollEnd(EndState().get()); 2874 host_impl_->ScrollEnd(EndState().get());
2874 EXPECT_FALSE(did_request_next_frame_); 2875 EXPECT_FALSE(did_request_next_frame_);
2875 EXPECT_FALSE(did_request_redraw_); 2876 EXPECT_FALSE(did_request_redraw_);
2876 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); 2877 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2877 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 2878 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2878 2879
2879 // Changing page scale triggers scrollbar animation. 2880 // Changing page scale triggers scrollbar animation.
2880 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); 2881 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f, 4.f);
2881 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.1f); 2882 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.1f);
2882 EXPECT_FALSE(did_request_next_frame_); 2883 EXPECT_FALSE(did_request_next_frame_);
2883 EXPECT_FALSE(did_request_redraw_); 2884 EXPECT_FALSE(did_request_redraw_);
2884 if (expecting_animations) { 2885 if (expecting_animations) {
2885 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), 2886 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20),
2886 requested_animation_delay_); 2887 requested_animation_delay_);
2887 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 2888 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
2888 requested_animation_delay_ = base::TimeDelta(); 2889 requested_animation_delay_ = base::TimeDelta();
2889 animation_task_ = base::Closure(); 2890 animation_task_ = base::Closure();
2890 } else { 2891 } else {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2923 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size); 2924 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size);
2924 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = 2925 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar =
2925 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, 2926 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400,
2926 VERTICAL, 10, 0, false, true); 2927 VERTICAL, 10, 0, false, true);
2927 scrollbar->test_properties()->opacity = 0.f; 2928 scrollbar->test_properties()->opacity = 0.f;
2928 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); 2929 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer();
2929 LayerImpl* container = 2930 LayerImpl* container =
2930 host_impl_->pending_tree()->InnerViewportContainerLayer(); 2931 host_impl_->pending_tree()->InnerViewportContainerLayer();
2931 scrollbar->SetScrollLayerId(scroll->id()); 2932 scrollbar->SetScrollLayerId(scroll->id());
2932 container->test_properties()->AddChild(std::move(scrollbar)); 2933 container->test_properties()->AddChild(std::move(scrollbar));
2933 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 2934 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f, 1.f);
2934 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 2935 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
2935 host_impl_->ActivateSyncTree(); 2936 host_impl_->ActivateSyncTree();
2936 2937
2937 LayerImpl* active_scrollbar_layer = 2938 LayerImpl* active_scrollbar_layer =
2938 host_impl_->active_tree()->LayerById(400); 2939 host_impl_->active_tree()->LayerById(400);
2939 2940
2940 EffectNode* active_tree_node = 2941 EffectNode* active_tree_node =
2941 host_impl_->active_tree()->property_trees()->effect_tree.Node( 2942 host_impl_->active_tree()->property_trees()->effect_tree.Node(
2942 active_scrollbar_layer->effect_tree_index()); 2943 active_scrollbar_layer->effect_tree_index());
2943 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(), 2944 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(),
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
3231 SetupMouseMoveAtWithDeviceScale(1.f); 3232 SetupMouseMoveAtWithDeviceScale(1.f);
3232 } 3233 }
3233 3234
3234 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf2) { 3235 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf2) {
3235 SetupMouseMoveAtWithDeviceScale(2.f); 3236 SetupMouseMoveAtWithDeviceScale(2.f);
3236 } 3237 }
3237 3238
3238 TEST_F(LayerTreeHostImplTest, CompositorFrameMetadata) { 3239 TEST_F(LayerTreeHostImplTest, CompositorFrameMetadata) {
3239 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 3240 SetupScrollAndContentsLayers(gfx::Size(100, 100));
3240 host_impl_->SetViewportSize(gfx::Size(50, 50)); 3241 host_impl_->SetViewportSize(gfx::Size(50, 50));
3241 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); 3242 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 0.5f, 4.f);
3242 DrawFrame(); 3243 DrawFrame();
3243 { 3244 {
3244 CompositorFrameMetadata metadata = 3245 CompositorFrameMetadata metadata =
3245 host_impl_->MakeCompositorFrameMetadata(); 3246 host_impl_->MakeCompositorFrameMetadata();
3246 EXPECT_EQ(gfx::Vector2dF(), metadata.root_scroll_offset); 3247 EXPECT_EQ(gfx::Vector2dF(), metadata.root_scroll_offset);
3247 EXPECT_EQ(1.f, metadata.page_scale_factor); 3248 EXPECT_EQ(1.f, metadata.page_scale_factor);
3248 EXPECT_EQ(gfx::SizeF(50.f, 50.f), metadata.scrollable_viewport_size); 3249 EXPECT_EQ(gfx::SizeF(50.f, 50.f), metadata.scrollable_viewport_size);
3249 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size); 3250 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size);
3250 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); 3251 EXPECT_EQ(0.5f, metadata.min_page_scale_factor);
3251 EXPECT_EQ(4.f, metadata.max_page_scale_factor); 3252 EXPECT_EQ(4.f, metadata.max_page_scale_factor);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
3336 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); 3337 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset);
3337 EXPECT_EQ(2.f, metadata.page_scale_factor); 3338 EXPECT_EQ(2.f, metadata.page_scale_factor);
3338 EXPECT_EQ(gfx::SizeF(25.f, 25.f), metadata.scrollable_viewport_size); 3339 EXPECT_EQ(gfx::SizeF(25.f, 25.f), metadata.scrollable_viewport_size);
3339 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size); 3340 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size);
3340 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); 3341 EXPECT_EQ(0.5f, metadata.min_page_scale_factor);
3341 EXPECT_EQ(4.f, metadata.max_page_scale_factor); 3342 EXPECT_EQ(4.f, metadata.max_page_scale_factor);
3342 } 3343 }
3343 3344
3344 // Likewise if set from the main thread. 3345 // Likewise if set from the main thread.
3345 host_impl_->ProcessScrollDeltas(); 3346 host_impl_->ProcessScrollDeltas();
3346 host_impl_->active_tree()->PushPageScaleFromMainThread(4.f, 0.5f, 4.f); 3347 host_impl_->active_tree()->PushPageScaleFromMainThread(4.f, 1.f, 0.5f, 4.f);
3347 host_impl_->active_tree()->SetPageScaleOnActiveTree(4.f); 3348 host_impl_->active_tree()->SetPageScaleOnActiveTree(4.f);
3348 { 3349 {
3349 CompositorFrameMetadata metadata = 3350 CompositorFrameMetadata metadata =
3350 host_impl_->MakeCompositorFrameMetadata(); 3351 host_impl_->MakeCompositorFrameMetadata();
3351 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); 3352 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset);
3352 EXPECT_EQ(4.f, metadata.page_scale_factor); 3353 EXPECT_EQ(4.f, metadata.page_scale_factor);
3353 EXPECT_EQ(gfx::SizeF(12.5f, 12.5f), metadata.scrollable_viewport_size); 3354 EXPECT_EQ(gfx::SizeF(12.5f, 12.5f), metadata.scrollable_viewport_size);
3354 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size); 3355 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size);
3355 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); 3356 EXPECT_EQ(0.5f, metadata.min_page_scale_factor);
3356 EXPECT_EQ(4.f, metadata.max_page_scale_factor); 3357 EXPECT_EQ(4.f, metadata.max_page_scale_factor);
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
3862 BeginState(gfx::Point()).get(), InputHandler::WHEEL); 3863 BeginState(gfx::Point()).get(), InputHandler::WHEEL);
3863 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); 3864 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread);
3864 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, 3865 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer,
3865 status.main_thread_scrolling_reasons); 3866 status.main_thread_scrolling_reasons);
3866 EXPECT_FALSE(did_request_redraw_); 3867 EXPECT_FALSE(did_request_redraw_);
3867 EXPECT_FALSE(did_request_commit_); 3868 EXPECT_FALSE(did_request_commit_);
3868 } 3869 }
3869 3870
3870 TEST_F(LayerTreeHostImplTest, ClampingAfterActivation) { 3871 TEST_F(LayerTreeHostImplTest, ClampingAfterActivation) {
3871 host_impl_->CreatePendingTree(); 3872 host_impl_->CreatePendingTree();
3872 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 3873 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f, 1.f);
3873 CreateScrollAndContentsLayers(host_impl_->pending_tree(), 3874 CreateScrollAndContentsLayers(host_impl_->pending_tree(),
3874 gfx::Size(100, 100)); 3875 gfx::Size(100, 100));
3875 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 3876 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
3876 host_impl_->ActivateSyncTree(); 3877 host_impl_->ActivateSyncTree();
3877 3878
3878 host_impl_->CreatePendingTree(); 3879 host_impl_->CreatePendingTree();
3879 const gfx::ScrollOffset pending_scroll = gfx::ScrollOffset(-100, -100); 3880 const gfx::ScrollOffset pending_scroll = gfx::ScrollOffset(-100, -100);
3880 LayerImpl* active_outer_layer = 3881 LayerImpl* active_outer_layer =
3881 host_impl_->active_tree()->OuterViewportScrollLayer(); 3882 host_impl_->active_tree()->OuterViewportScrollLayer();
3882 LayerImpl* pending_outer_layer = 3883 LayerImpl* pending_outer_layer =
(...skipping 21 matching lines...) Expand all
3904 } 3905 }
3905 3906
3906 bool CreateHostImpl( 3907 bool CreateHostImpl(
3907 const LayerTreeSettings& settings, 3908 const LayerTreeSettings& settings,
3908 std::unique_ptr<CompositorFrameSink> compositor_frame_sink) override { 3909 std::unique_ptr<CompositorFrameSink> compositor_frame_sink) override {
3909 bool init = LayerTreeHostImplTest::CreateHostImpl( 3910 bool init = LayerTreeHostImplTest::CreateHostImpl(
3910 settings, std::move(compositor_frame_sink)); 3911 settings, std::move(compositor_frame_sink));
3911 if (init) { 3912 if (init) {
3912 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); 3913 host_impl_->active_tree()->set_top_controls_height(top_controls_height_);
3913 host_impl_->active_tree()->SetCurrentBrowserControlsShownRatio(1.f); 3914 host_impl_->active_tree()->SetCurrentBrowserControlsShownRatio(1.f);
3914 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 3915 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f,
3916 1.f);
3915 } 3917 }
3916 return init; 3918 return init;
3917 } 3919 }
3918 3920
3919 void SetupBrowserControlsAndScrollLayerWithVirtualViewport( 3921 void SetupBrowserControlsAndScrollLayerWithVirtualViewport(
3920 const gfx::Size& inner_viewport_size, 3922 const gfx::Size& inner_viewport_size,
3921 const gfx::Size& outer_viewport_size, 3923 const gfx::Size& outer_viewport_size,
3922 const gfx::Size& scroll_layer_size) { 3924 const gfx::Size& scroll_layer_size) {
3923 settings_ = DefaultSettings(); 3925 settings_ = DefaultSettings();
3924 CreateHostImpl(settings_, CreateCompositorFrameSink()); 3926 CreateHostImpl(settings_, CreateCompositorFrameSink());
3925 SetupBrowserControlsAndScrollLayerWithVirtualViewport( 3927 SetupBrowserControlsAndScrollLayerWithVirtualViewport(
3926 host_impl_->active_tree(), inner_viewport_size, outer_viewport_size, 3928 host_impl_->active_tree(), inner_viewport_size, outer_viewport_size,
3927 scroll_layer_size); 3929 scroll_layer_size);
3928 } 3930 }
3929 3931
3930 void SetupBrowserControlsAndScrollLayerWithVirtualViewport( 3932 void SetupBrowserControlsAndScrollLayerWithVirtualViewport(
3931 LayerTreeImpl* tree_impl, 3933 LayerTreeImpl* tree_impl,
3932 const gfx::Size& inner_viewport_size, 3934 const gfx::Size& inner_viewport_size,
3933 const gfx::Size& outer_viewport_size, 3935 const gfx::Size& outer_viewport_size,
3934 const gfx::Size& scroll_layer_size) { 3936 const gfx::Size& scroll_layer_size) {
3935 tree_impl->set_browser_controls_shrink_blink_size(true); 3937 tree_impl->set_browser_controls_shrink_blink_size(true);
3936 tree_impl->set_top_controls_height(top_controls_height_); 3938 tree_impl->set_top_controls_height(top_controls_height_);
3937 tree_impl->SetCurrentBrowserControlsShownRatio(1.f); 3939 tree_impl->SetCurrentBrowserControlsShownRatio(1.f);
3938 tree_impl->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 3940 tree_impl->PushPageScaleFromMainThread(1.f, 1.f, 1.f, 1.f);
3939 host_impl_->DidChangeBrowserControlsPosition(); 3941 host_impl_->DidChangeBrowserControlsPosition();
3940 3942
3941 std::unique_ptr<LayerImpl> root = LayerImpl::Create(tree_impl, 1); 3943 std::unique_ptr<LayerImpl> root = LayerImpl::Create(tree_impl, 1);
3942 std::unique_ptr<LayerImpl> root_clip = LayerImpl::Create(tree_impl, 2); 3944 std::unique_ptr<LayerImpl> root_clip = LayerImpl::Create(tree_impl, 2);
3943 std::unique_ptr<LayerImpl> page_scale = LayerImpl::Create(tree_impl, 3); 3945 std::unique_ptr<LayerImpl> page_scale = LayerImpl::Create(tree_impl, 3);
3944 3946
3945 std::unique_ptr<LayerImpl> outer_scroll = LayerImpl::Create(tree_impl, 4); 3947 std::unique_ptr<LayerImpl> outer_scroll = LayerImpl::Create(tree_impl, 4);
3946 std::unique_ptr<LayerImpl> outer_clip = LayerImpl::Create(tree_impl, 5); 3948 std::unique_ptr<LayerImpl> outer_clip = LayerImpl::Create(tree_impl, 5);
3947 3949
3948 root_clip->SetBounds(inner_viewport_size); 3950 root_clip->SetBounds(inner_viewport_size);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
4106 LayerImpl* inner_container = 4108 LayerImpl* inner_container =
4107 host_impl_->active_tree()->InnerViewportContainerLayer(); 4109 host_impl_->active_tree()->InnerViewportContainerLayer();
4108 LayerImpl* outer_scroll = 4110 LayerImpl* outer_scroll =
4109 host_impl_->active_tree()->OuterViewportScrollLayer(); 4111 host_impl_->active_tree()->OuterViewportScrollLayer();
4110 outer_scroll->SetDrawsContent(true); 4112 outer_scroll->SetDrawsContent(true);
4111 LayerImpl* outer_container = 4113 LayerImpl* outer_container =
4112 host_impl_->active_tree()->OuterViewportContainerLayer(); 4114 host_impl_->active_tree()->OuterViewportContainerLayer();
4113 4115
4114 // Need SetDrawsContent so ScrollBegin's hit test finds an actual layer. 4116 // Need SetDrawsContent so ScrollBegin's hit test finds an actual layer.
4115 outer_scroll->SetDrawsContent(true); 4117 outer_scroll->SetDrawsContent(true);
4116 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f); 4118 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 1.f, 2.f);
4117 4119
4118 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 4120 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
4119 host_impl_ 4121 host_impl_
4120 ->ScrollBegin(BeginState(gfx::Point()).get(), 4122 ->ScrollBegin(BeginState(gfx::Point()).get(),
4121 InputHandler::TOUCHSCREEN) 4123 InputHandler::TOUCHSCREEN)
4122 .thread); 4124 .thread);
4123 host_impl_->ScrollBy( 4125 host_impl_->ScrollBy(
4124 UpdateState(gfx::Point(), gfx::Vector2dF(0.f, 50.f)).get()); 4126 UpdateState(gfx::Point(), gfx::Vector2dF(0.f, 50.f)).get());
4125 4127
4126 // The entire scroll delta should have been used to hide the browser controls. 4128 // The entire scroll delta should have been used to hide the browser controls.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
4177 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); 4179 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y());
4178 EXPECT_EQ(0.f, inner_scroll->CurrentScrollOffset().y()); 4180 EXPECT_EQ(0.f, inner_scroll->CurrentScrollOffset().y());
4179 } 4181 }
4180 4182
4181 // Test that the fixed position container delta is appropriately adjusted 4183 // Test that the fixed position container delta is appropriately adjusted
4182 // by the browser controls showing/hiding and page scale doesn't affect it. 4184 // by the browser controls showing/hiding and page scale doesn't affect it.
4183 TEST_F(LayerTreeHostImplBrowserControlsTest, FixedContainerDelta) { 4185 TEST_F(LayerTreeHostImplBrowserControlsTest, FixedContainerDelta) {
4184 SetupBrowserControlsAndScrollLayerWithVirtualViewport( 4186 SetupBrowserControlsAndScrollLayerWithVirtualViewport(
4185 gfx::Size(100, 100), gfx::Size(100, 100), gfx::Size(100, 100)); 4187 gfx::Size(100, 100), gfx::Size(100, 100), gfx::Size(100, 100));
4186 DrawFrame(); 4188 DrawFrame();
4187 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); 4189 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f, 2.f);
4188 4190
4189 float page_scale = 1.5f; 4191 float page_scale = 1.5f;
4190 LayerImpl* outer_viewport_scroll_layer = 4192 LayerImpl* outer_viewport_scroll_layer =
4191 host_impl_->active_tree()->OuterViewportScrollLayer(); 4193 host_impl_->active_tree()->OuterViewportScrollLayer();
4192 4194
4193 // Zoom in, since the fixed container is the outer viewport, the delta should 4195 // Zoom in, since the fixed container is the outer viewport, the delta should
4194 // not be scaled. 4196 // not be scaled.
4195 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 2.f); 4197 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 1.f,
4198 2.f);
4196 4199
4197 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 4200 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
4198 host_impl_ 4201 host_impl_
4199 ->ScrollBegin(BeginState(gfx::Point()).get(), 4202 ->ScrollBegin(BeginState(gfx::Point()).get(),
4200 InputHandler::TOUCHSCREEN) 4203 InputHandler::TOUCHSCREEN)
4201 .thread); 4204 .thread);
4202 4205
4203 // Scroll down, the browser controls hiding should expand the viewport size so 4206 // Scroll down, the browser controls hiding should expand the viewport size so
4204 // the delta should be equal to the scroll distance. 4207 // the delta should be equal to the scroll distance.
4205 gfx::Vector2dF top_controls_scroll_delta(0.f, 20.f); 4208 gfx::Vector2dF top_controls_scroll_delta(0.f, 20.f);
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
4547 SetScrollOffsetDelta(inner_scroll, gfx::Vector2dF(100, 100.f)); 4550 SetScrollOffsetDelta(inner_scroll, gfx::Vector2dF(100, 100.f));
4548 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), 4551 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(),
4549 host_impl_->active_tree()->TotalScrollOffset()); 4552 host_impl_->active_tree()->TotalScrollOffset());
4550 } 4553 }
4551 4554
4552 // Test that the browser controls coming in and out maintains the same aspect 4555 // Test that the browser controls coming in and out maintains the same aspect
4553 // ratio between the inner and outer viewports. 4556 // ratio between the inner and outer viewports.
4554 TEST_F(LayerTreeHostImplBrowserControlsTest, BrowserControlsAspectRatio) { 4557 TEST_F(LayerTreeHostImplBrowserControlsTest, BrowserControlsAspectRatio) {
4555 SetupBrowserControlsAndScrollLayerWithVirtualViewport( 4558 SetupBrowserControlsAndScrollLayerWithVirtualViewport(
4556 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); 4559 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400));
4557 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 2.f); 4560 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 0.5f, 2.f);
4558 DrawFrame(); 4561 DrawFrame();
4559 4562
4560 EXPECT_FLOAT_EQ(top_controls_height_, 4563 EXPECT_FLOAT_EQ(top_controls_height_,
4561 host_impl_->browser_controls_manager()->ContentTopOffset()); 4564 host_impl_->browser_controls_manager()->ContentTopOffset());
4562 4565
4563 gfx::Vector2dF scroll_delta(0.f, 25.f); 4566 gfx::Vector2dF scroll_delta(0.f, 25.f);
4564 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 4567 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
4565 host_impl_ 4568 host_impl_
4566 ->ScrollBegin(BeginState(gfx::Point()).get(), 4569 ->ScrollBegin(BeginState(gfx::Point()).get(),
4567 InputHandler::TOUCHSCREEN) 4570 InputHandler::TOUCHSCREEN)
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
4734 TEST_F(LayerTreeHostImplBrowserControlsTest, 4737 TEST_F(LayerTreeHostImplBrowserControlsTest,
4735 ViewportBoundsDeltaOnTreeActivation) { 4738 ViewportBoundsDeltaOnTreeActivation) {
4736 const gfx::Size inner_viewport_size(1000, 1000); 4739 const gfx::Size inner_viewport_size(1000, 1000);
4737 const gfx::Size outer_viewport_size(1000, 1000); 4740 const gfx::Size outer_viewport_size(1000, 1000);
4738 const gfx::Size content_size(2000, 2000); 4741 const gfx::Size content_size(2000, 2000);
4739 4742
4740 // Initialization 4743 // Initialization
4741 { 4744 {
4742 SetupBrowserControlsAndScrollLayerWithVirtualViewport( 4745 SetupBrowserControlsAndScrollLayerWithVirtualViewport(
4743 inner_viewport_size, outer_viewport_size, content_size); 4746 inner_viewport_size, outer_viewport_size, content_size);
4744 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 4747 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f, 1.f);
4745 4748
4746 // Start off with the browser controls hidden on both main and impl. 4749 // Start off with the browser controls hidden on both main and impl.
4747 host_impl_->active_tree()->set_browser_controls_shrink_blink_size(false); 4750 host_impl_->active_tree()->set_browser_controls_shrink_blink_size(false);
4748 host_impl_->active_tree()->PushBrowserControlsFromMainThread(0); 4751 host_impl_->active_tree()->PushBrowserControlsFromMainThread(0);
4749 4752
4750 host_impl_->CreatePendingTree(); 4753 host_impl_->CreatePendingTree();
4751 SetupBrowserControlsAndScrollLayerWithVirtualViewport( 4754 SetupBrowserControlsAndScrollLayerWithVirtualViewport(
4752 host_impl_->pending_tree(), inner_viewport_size, outer_viewport_size, 4755 host_impl_->pending_tree(), inner_viewport_size, outer_viewport_size,
4753 content_size); 4756 content_size);
4754 host_impl_->pending_tree()->set_browser_controls_shrink_blink_size(false); 4757 host_impl_->pending_tree()->set_browser_controls_shrink_blink_size(false);
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
4996 4999
4997 SetupScrollAndContentsLayers(viewport_size); 5000 SetupScrollAndContentsLayers(viewport_size);
4998 5001
4999 // Setup the layers so that the outer viewport is scrollable. 5002 // Setup the layers so that the outer viewport is scrollable.
5000 host_impl_->active_tree() 5003 host_impl_->active_tree()
5001 ->InnerViewportScrollLayer() 5004 ->InnerViewportScrollLayer()
5002 ->test_properties() 5005 ->test_properties()
5003 ->parent->SetBounds(viewport_size); 5006 ->parent->SetBounds(viewport_size);
5004 host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds( 5007 host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds(
5005 gfx::Size(40, 40)); 5008 gfx::Size(40, 40));
5006 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); 5009 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f, 2.f);
5007 DrawFrame(); 5010 DrawFrame();
5008 5011
5009 LayerImpl* root_scroll = 5012 LayerImpl* root_scroll =
5010 host_impl_->active_tree()->OuterViewportScrollLayer(); 5013 host_impl_->active_tree()->OuterViewportScrollLayer();
5011 LayerImpl* inner_scroll = 5014 LayerImpl* inner_scroll =
5012 host_impl_->active_tree()->InnerViewportScrollLayer(); 5015 host_impl_->active_tree()->InnerViewportScrollLayer();
5013 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); 5016 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds());
5014 5017
5015 gfx::Vector2d scroll_delta(0, 10); 5018 gfx::Vector2d scroll_delta(0, 10);
5016 gfx::Vector2d expected_scroll_delta = scroll_delta; 5019 gfx::Vector2d expected_scroll_delta = scroll_delta;
5017 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); 5020 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset();
5018 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 5021 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
5019 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), 5022 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(),
5020 InputHandler::WHEEL) 5023 InputHandler::WHEEL)
5021 .thread); 5024 .thread);
5022 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 5025 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
5023 host_impl_->ScrollEnd(EndState().get()); 5026 host_impl_->ScrollEnd(EndState().get());
5024 5027
5025 // Set new page scale from main thread. 5028 // Set new page scale from main thread.
5026 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 2.f); 5029 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 1.f,
5030 2.f);
5027 5031
5028 std::unique_ptr<ScrollAndScaleSet> scroll_info = 5032 std::unique_ptr<ScrollAndScaleSet> scroll_info =
5029 host_impl_->ProcessScrollDeltas(); 5033 host_impl_->ProcessScrollDeltas();
5030 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(), 5034 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(),
5031 expected_scroll_delta)); 5035 expected_scroll_delta));
5032 5036
5033 // The scroll range should also have been updated. 5037 // The scroll range should also have been updated.
5034 EXPECT_EQ(expected_max_scroll, root_scroll->MaxScrollOffset()); 5038 EXPECT_EQ(expected_max_scroll, root_scroll->MaxScrollOffset());
5035 5039
5036 // The page scale delta remains constant because the impl thread did not 5040 // The page scale delta remains constant because the impl thread did not
5037 // scale. 5041 // scale.
5038 EXPECT_EQ(1.f, host_impl_->active_tree()->page_scale_delta()); 5042 EXPECT_EQ(1.f, host_impl_->active_tree()->page_scale_delta());
5039 } 5043 }
5040 5044
5041 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnImplThread) { 5045 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnImplThread) {
5042 gfx::Size viewport_size(20, 20); 5046 gfx::Size viewport_size(20, 20);
5043 float page_scale = 2.f; 5047 float page_scale = 2.f;
5044 5048
5045 SetupScrollAndContentsLayers(viewport_size); 5049 SetupScrollAndContentsLayers(viewport_size);
5046 5050
5047 // Setup the layers so that the outer viewport is scrollable. 5051 // Setup the layers so that the outer viewport is scrollable.
5048 host_impl_->active_tree() 5052 host_impl_->active_tree()
5049 ->InnerViewportScrollLayer() 5053 ->InnerViewportScrollLayer()
5050 ->test_properties() 5054 ->test_properties()
5051 ->parent->SetBounds(viewport_size); 5055 ->parent->SetBounds(viewport_size);
5052 host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds( 5056 host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds(
5053 gfx::Size(40, 40)); 5057 gfx::Size(40, 40));
5054 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); 5058 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f, 2.f);
5055 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 5059 host_impl_->active_tree()->BuildPropertyTreesForTesting();
5056 5060
5057 DrawFrame(); 5061 DrawFrame();
5058 5062
5059 LayerImpl* root_scroll = 5063 LayerImpl* root_scroll =
5060 host_impl_->active_tree()->OuterViewportScrollLayer(); 5064 host_impl_->active_tree()->OuterViewportScrollLayer();
5061 LayerImpl* inner_scroll = 5065 LayerImpl* inner_scroll =
5062 host_impl_->active_tree()->InnerViewportScrollLayer(); 5066 host_impl_->active_tree()->InnerViewportScrollLayer();
5063 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); 5067 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds());
5064 5068
(...skipping 24 matching lines...) Expand all
5089 expected_scroll_delta)); 5093 expected_scroll_delta));
5090 5094
5091 // The scroll range should also have been updated. 5095 // The scroll range should also have been updated.
5092 EXPECT_EQ(expected_max_scroll, root_scroll->MaxScrollOffset()); 5096 EXPECT_EQ(expected_max_scroll, root_scroll->MaxScrollOffset());
5093 5097
5094 // The page scale delta should match the new scale on the impl side. 5098 // The page scale delta should match the new scale on the impl side.
5095 EXPECT_EQ(page_scale, host_impl_->active_tree()->current_page_scale_factor()); 5099 EXPECT_EQ(page_scale, host_impl_->active_tree()->current_page_scale_factor());
5096 } 5100 }
5097 5101
5098 TEST_F(LayerTreeHostImplTest, PageScaleDeltaAppliedToRootScrollLayerOnly) { 5102 TEST_F(LayerTreeHostImplTest, PageScaleDeltaAppliedToRootScrollLayerOnly) {
5099 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); 5103 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f, 2.f);
5100 gfx::Size surface_size(10, 10); 5104 gfx::Size surface_size(10, 10);
5101 float default_page_scale = 1.f; 5105 float default_page_scale = 1.f;
5102 gfx::Transform default_page_scale_matrix; 5106 gfx::Transform default_page_scale_matrix;
5103 default_page_scale_matrix.Scale(default_page_scale, default_page_scale); 5107 default_page_scale_matrix.Scale(default_page_scale, default_page_scale);
5104 5108
5105 float new_page_scale = 2.f; 5109 float new_page_scale = 2.f;
5106 gfx::Transform new_page_scale_matrix; 5110 gfx::Transform new_page_scale_matrix;
5107 new_page_scale_matrix.Scale(new_page_scale, new_page_scale); 5111 new_page_scale_matrix.Scale(new_page_scale, new_page_scale);
5108 5112
5109 // Create a normal scrollable root layer and another scrollable child layer. 5113 // Create a normal scrollable root layer and another scrollable child layer.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
5168 gfx::Vector2d expected_scroll_delta(scroll_delta); 5172 gfx::Vector2d expected_scroll_delta(scroll_delta);
5169 gfx::ScrollOffset expected_max_scroll(outer_scroll->MaxScrollOffset()); 5173 gfx::ScrollOffset expected_max_scroll(outer_scroll->MaxScrollOffset());
5170 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 5174 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
5171 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), 5175 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(),
5172 InputHandler::WHEEL) 5176 InputHandler::WHEEL)
5173 .thread); 5177 .thread);
5174 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 5178 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
5175 host_impl_->ScrollEnd(EndState().get()); 5179 host_impl_->ScrollEnd(EndState().get());
5176 5180
5177 float page_scale = 2.f; 5181 float page_scale = 2.f;
5178 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 5182 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 1.f,
5179 page_scale); 5183 page_scale);
5180 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 5184 host_impl_->active_tree()->BuildPropertyTreesForTesting();
5181 5185
5182 DrawOneFrame(); 5186 DrawOneFrame();
5183 5187
5184 std::unique_ptr<ScrollAndScaleSet> scroll_info = 5188 std::unique_ptr<ScrollAndScaleSet> scroll_info =
5185 host_impl_->ProcessScrollDeltas(); 5189 host_impl_->ProcessScrollDeltas();
5186 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(), 5190 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(),
5187 expected_scroll_delta)); 5191 expected_scroll_delta));
5188 5192
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
5364 5368
5365 // The grand child should have scrolled. 5369 // The grand child should have scrolled.
5366 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), 5370 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(),
5367 gfx::Vector2d(0, 5))); 5371 gfx::Vector2d(0, 5)));
5368 5372
5369 // The child should not have scrolled. 5373 // The child should not have scrolled.
5370 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(), 5374 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(),
5371 gfx::Vector2d(0, -3))); 5375 gfx::Vector2d(0, -3)));
5372 5376
5373 // Scrolling should be adjusted from viewport space. 5377 // Scrolling should be adjusted from viewport space.
5374 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 2.f, 2.f); 5378 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 2.f, 2.f, 2.f);
5375 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); 5379 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f);
5376 5380
5377 scroll_delta = gfx::Vector2d(0, -2); 5381 scroll_delta = gfx::Vector2d(0, -2);
5378 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 5382 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
5379 host_impl_->ScrollBegin(BeginState(gfx::Point(1, 1)).get(), 5383 host_impl_->ScrollBegin(BeginState(gfx::Point(1, 1)).get(),
5380 InputHandler::NON_BUBBLING_GESTURE) 5384 InputHandler::NON_BUBBLING_GESTURE)
5381 .thread); 5385 .thread);
5382 EXPECT_EQ(grand_child, host_impl_->CurrentlyScrollingLayer()); 5386 EXPECT_EQ(grand_child, host_impl_->CurrentlyScrollingLayer());
5383 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 5387 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
5384 host_impl_->ScrollEnd(EndState().get()); 5388 host_impl_->ScrollEnd(EndState().get());
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
5772 TEST_F(LayerTreeHostImplTest, ScrollViewportRounding) { 5776 TEST_F(LayerTreeHostImplTest, ScrollViewportRounding) {
5773 int width = 332; 5777 int width = 332;
5774 int height = 20; 5778 int height = 20;
5775 int scale = 3; 5779 int scale = 3;
5776 SetupScrollAndContentsLayers(gfx::Size(width, height)); 5780 SetupScrollAndContentsLayers(gfx::Size(width, height));
5777 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( 5781 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds(
5778 gfx::Size(width * scale - 1, height * scale)); 5782 gfx::Size(width * scale - 1, height * scale));
5779 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 5783 host_impl_->active_tree()->BuildPropertyTreesForTesting();
5780 5784
5781 host_impl_->active_tree()->SetDeviceScaleFactor(scale); 5785 host_impl_->active_tree()->SetDeviceScaleFactor(scale);
5782 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); 5786 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 0.5f, 4.f);
5783 5787
5784 LayerImpl* inner_viewport_scroll_layer = 5788 LayerImpl* inner_viewport_scroll_layer =
5785 host_impl_->active_tree()->InnerViewportScrollLayer(); 5789 host_impl_->active_tree()->InnerViewportScrollLayer();
5786 EXPECT_EQ(gfx::ScrollOffset(0, 0), 5790 EXPECT_EQ(gfx::ScrollOffset(0, 0),
5787 inner_viewport_scroll_layer->MaxScrollOffset()); 5791 inner_viewport_scroll_layer->MaxScrollOffset());
5788 } 5792 }
5789 5793
5790 class TestInputHandlerClient : public InputHandlerClient { 5794 class TestInputHandlerClient : public InputHandlerClient {
5791 public: 5795 public:
5792 TestInputHandlerClient() 5796 TestInputHandlerClient()
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
5877 5881
5878 // Setting the delegate results in the scrollable_size, max_scroll_offset, 5882 // Setting the delegate results in the scrollable_size, max_scroll_offset,
5879 // page_scale_factor and {min|max}_page_scale_factor being set. 5883 // page_scale_factor and {min|max}_page_scale_factor being set.
5880 EXPECT_EQ(gfx::SizeF(100, 100), scroll_watcher.scrollable_size()); 5884 EXPECT_EQ(gfx::SizeF(100, 100), scroll_watcher.scrollable_size());
5881 EXPECT_EQ(gfx::ScrollOffset(90, 80), scroll_watcher.max_scroll_offset()); 5885 EXPECT_EQ(gfx::ScrollOffset(90, 80), scroll_watcher.max_scroll_offset());
5882 EXPECT_EQ(1.f, scroll_watcher.page_scale_factor()); 5886 EXPECT_EQ(1.f, scroll_watcher.page_scale_factor());
5883 EXPECT_EQ(1.f, scroll_watcher.min_page_scale_factor()); 5887 EXPECT_EQ(1.f, scroll_watcher.min_page_scale_factor());
5884 EXPECT_EQ(1.f, scroll_watcher.max_page_scale_factor()); 5888 EXPECT_EQ(1.f, scroll_watcher.max_page_scale_factor());
5885 5889
5886 // Put a page scale on the tree. 5890 // Put a page scale on the tree.
5887 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 0.5f, 4.f); 5891 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 0.5f, 4.f);
5888 EXPECT_EQ(1.f, scroll_watcher.page_scale_factor()); 5892 EXPECT_EQ(1.f, scroll_watcher.page_scale_factor());
5889 EXPECT_EQ(1.f, scroll_watcher.min_page_scale_factor()); 5893 EXPECT_EQ(1.f, scroll_watcher.min_page_scale_factor());
5890 EXPECT_EQ(1.f, scroll_watcher.max_page_scale_factor()); 5894 EXPECT_EQ(1.f, scroll_watcher.max_page_scale_factor());
5891 // Activation will update the delegate. 5895 // Activation will update the delegate.
5892 host_impl_->ActivateSyncTree(); 5896 host_impl_->ActivateSyncTree();
5893 EXPECT_EQ(2.f, scroll_watcher.page_scale_factor()); 5897 EXPECT_EQ(2.f, scroll_watcher.page_scale_factor());
5894 EXPECT_EQ(.5f, scroll_watcher.min_page_scale_factor()); 5898 EXPECT_EQ(.5f, scroll_watcher.min_page_scale_factor());
5895 EXPECT_EQ(4.f, scroll_watcher.max_page_scale_factor()); 5899 EXPECT_EQ(4.f, scroll_watcher.max_page_scale_factor());
5896 5900
5897 // Animating page scale can change the root offset, so it should update the 5901 // Animating page scale can change the root offset, so it should update the
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
5934 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 5938 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
5935 EXPECT_EQ(current_offset + gfx::ScrollOffset(scroll_delta), 5939 EXPECT_EQ(current_offset + gfx::ScrollOffset(scroll_delta),
5936 scroll_watcher.last_set_scroll_offset()); 5940 scroll_watcher.last_set_scroll_offset());
5937 host_impl_->ScrollEnd(EndState().get()); 5941 host_impl_->ScrollEnd(EndState().get());
5938 host_impl_->SetSynchronousInputHandlerRootScrollOffset(gfx::ScrollOffset()); 5942 host_impl_->SetSynchronousInputHandlerRootScrollOffset(gfx::ScrollOffset());
5939 5943
5940 // Forces a full tree synchronization and ensures that the scroll delegate 5944 // Forces a full tree synchronization and ensures that the scroll delegate
5941 // sees the correct size of the new tree. 5945 // sees the correct size of the new tree.
5942 gfx::Size new_size(42, 24); 5946 gfx::Size new_size(42, 24);
5943 host_impl_->CreatePendingTree(); 5947 host_impl_->CreatePendingTree();
5944 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 5948 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f, 1.f);
5945 CreateScrollAndContentsLayers(host_impl_->pending_tree(), new_size); 5949 CreateScrollAndContentsLayers(host_impl_->pending_tree(), new_size);
5946 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 5950 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
5947 host_impl_->ActivateSyncTree(); 5951 host_impl_->ActivateSyncTree();
5948 EXPECT_EQ(gfx::SizeF(new_size), scroll_watcher.scrollable_size()); 5952 EXPECT_EQ(gfx::SizeF(new_size), scroll_watcher.scrollable_size());
5949 5953
5950 // Tear down the LayerTreeHostImpl before the InputHandlerClient. 5954 // Tear down the LayerTreeHostImpl before the InputHandlerClient.
5951 host_impl_->ReleaseCompositorFrameSink(); 5955 host_impl_->ReleaseCompositorFrameSink();
5952 host_impl_ = nullptr; 5956 host_impl_ = nullptr;
5953 } 5957 }
5954 5958
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
5989 EXPECT_FALSE(frame.has_no_damage); 5993 EXPECT_FALSE(frame.has_no_damage);
5990 CheckLayerScrollDelta(scroll_layer, ScrollOffsetToVector2dF(scroll_offset)); 5994 CheckLayerScrollDelta(scroll_layer, ScrollOffsetToVector2dF(scroll_offset));
5991 } 5995 }
5992 5996
5993 TEST_F(LayerTreeHostImplTest, OverscrollRoot) { 5997 TEST_F(LayerTreeHostImplTest, OverscrollRoot) {
5994 InputHandlerScrollResult scroll_result; 5998 InputHandlerScrollResult scroll_result;
5995 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 5999 SetupScrollAndContentsLayers(gfx::Size(100, 100));
5996 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6000 host_impl_->active_tree()->BuildPropertyTreesForTesting();
5997 6001
5998 host_impl_->SetViewportSize(gfx::Size(50, 50)); 6002 host_impl_->SetViewportSize(gfx::Size(50, 50));
5999 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); 6003 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 0.5f, 4.f);
6000 DrawFrame(); 6004 DrawFrame();
6001 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); 6005 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
6002 6006
6003 // In-bounds scrolling does not affect overscroll. 6007 // In-bounds scrolling does not affect overscroll.
6004 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 6008 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
6005 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 6009 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
6006 InputHandler::WHEEL) 6010 InputHandler::WHEEL)
6007 .thread); 6011 .thread);
6008 scroll_result = host_impl_->ScrollBy( 6012 scroll_result = host_impl_->ScrollBy(
6009 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); 6013 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get());
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
6246 CreateHostImpl(settings, CreateCompositorFrameSink()); 6250 CreateHostImpl(settings, CreateCompositorFrameSink());
6247 6251
6248 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(50, 50)); 6252 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(50, 50));
6249 LayerImpl* clip_layer = 6253 LayerImpl* clip_layer =
6250 scroll_layer->test_properties()->parent->test_properties()->parent; 6254 scroll_layer->test_properties()->parent->test_properties()->parent;
6251 6255
6252 clip_layer->SetBounds(gfx::Size(50, 50)); 6256 clip_layer->SetBounds(gfx::Size(50, 50));
6253 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6257 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6254 6258
6255 host_impl_->SetViewportSize(gfx::Size(50, 50)); 6259 host_impl_->SetViewportSize(gfx::Size(50, 50));
6256 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); 6260 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 0.5f, 4.f);
6257 DrawFrame(); 6261 DrawFrame();
6258 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); 6262 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
6259 6263
6260 // Even though the layer can't scroll the overscroll still happens. 6264 // Even though the layer can't scroll the overscroll still happens.
6261 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 6265 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
6262 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 6266 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
6263 InputHandler::WHEEL) 6267 InputHandler::WHEEL)
6264 .thread); 6268 .thread);
6265 scroll_result = host_impl_->ScrollBy( 6269 scroll_result = host_impl_->ScrollBy(
6266 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); 6270 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get());
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
6467 6471
6468 EXPECT_VECTOR_EQ(gfx::Vector2dF(), 6472 EXPECT_VECTOR_EQ(gfx::Vector2dF(),
6469 outer_scroll_layer->CurrentScrollOffset()); 6473 outer_scroll_layer->CurrentScrollOffset());
6470 } 6474 }
6471 6475
6472 // Zoom into the page by a 2X factor so that the inner viewport becomes 6476 // Zoom into the page by a 2X factor so that the inner viewport becomes
6473 // scrollable. 6477 // scrollable.
6474 float min_page_scale = 1.f, max_page_scale = 4.f; 6478 float min_page_scale = 1.f, max_page_scale = 4.f;
6475 float page_scale_factor = 2.f; 6479 float page_scale_factor = 2.f;
6476 host_impl_->active_tree()->PushPageScaleFromMainThread( 6480 host_impl_->active_tree()->PushPageScaleFromMainThread(
6477 page_scale_factor, min_page_scale, max_page_scale); 6481 page_scale_factor, min_page_scale, min_page_scale, max_page_scale);
6478 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); 6482 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
6479 6483
6480 // Reset the parent scrolling layer (i.e. the current outer viewport) so that 6484 // Reset the parent scrolling layer (i.e. the current outer viewport) so that
6481 // we can ensure viewport scrolling works correctly. 6485 // we can ensure viewport scrolling works correctly.
6482 scroll_layer->SetCurrentScrollOffset(gfx::ScrollOffset(0, 0)); 6486 scroll_layer->SetCurrentScrollOffset(gfx::ScrollOffset(0, 0));
6483 6487
6484 // Scrolling the content layer should now scroll the inner viewport first, 6488 // Scrolling the content layer should now scroll the inner viewport first,
6485 // and then chain up to the current outer viewport (i.e. the parent scroll 6489 // and then chain up to the current outer viewport (i.e. the parent scroll
6486 // layer). 6490 // layer).
6487 { 6491 {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
6589 6593
6590 EXPECT_VECTOR_EQ(gfx::Vector2dF(600.f, 600.f), 6594 EXPECT_VECTOR_EQ(gfx::Vector2dF(600.f, 600.f),
6591 sibling_scroll_layer->CurrentScrollOffset()); 6595 sibling_scroll_layer->CurrentScrollOffset());
6592 EXPECT_VECTOR_EQ(gfx::Vector2dF(), 6596 EXPECT_VECTOR_EQ(gfx::Vector2dF(),
6593 outer_scroll_layer->CurrentScrollOffset()); 6597 outer_scroll_layer->CurrentScrollOffset());
6594 } 6598 }
6595 6599
6596 float min_page_scale = 1.f, max_page_scale = 4.f; 6600 float min_page_scale = 1.f, max_page_scale = 4.f;
6597 float page_scale_factor = 1.f; 6601 float page_scale_factor = 1.f;
6598 host_impl_->active_tree()->PushPageScaleFromMainThread( 6602 host_impl_->active_tree()->PushPageScaleFromMainThread(
6599 page_scale_factor, min_page_scale, max_page_scale); 6603 page_scale_factor, min_page_scale, min_page_scale, max_page_scale);
6600 6604
6601 gfx::Vector2dF viewport_size_vec(viewport_size.width(), 6605 gfx::Vector2dF viewport_size_vec(viewport_size.width(),
6602 viewport_size.height()); 6606 viewport_size.height());
6603 6607
6604 // Reset the scroll offset. 6608 // Reset the scroll offset.
6605 sibling_scroll_layer->SetCurrentScrollOffset(gfx::ScrollOffset()); 6609 sibling_scroll_layer->SetCurrentScrollOffset(gfx::ScrollOffset());
6606 6610
6607 // Now pinch-zoom in. Anchoring should cause scrolling only on the inner 6611 // Now pinch-zoom in. Anchoring should cause scrolling only on the inner
6608 // viewport layer. 6612 // viewport layer.
6609 { 6613 {
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after
7847 // Due to precision issues (especially on Android), sometimes far 7851 // Due to precision issues (especially on Android), sometimes far
7848 // away quads can end up thinking they need AA. 7852 // away quads can end up thinking they need AA.
7849 float device_scale_factor = 4.f / 3.f; 7853 float device_scale_factor = 4.f / 3.f;
7850 gfx::Size root_size(2000, 1000); 7854 gfx::Size root_size(2000, 1000);
7851 gfx::Size device_viewport_size = 7855 gfx::Size device_viewport_size =
7852 gfx::ScaleToCeiledSize(root_size, device_scale_factor); 7856 gfx::ScaleToCeiledSize(root_size, device_scale_factor);
7853 host_impl_->SetViewportSize(device_viewport_size); 7857 host_impl_->SetViewportSize(device_viewport_size);
7854 7858
7855 host_impl_->CreatePendingTree(); 7859 host_impl_->CreatePendingTree();
7856 host_impl_->pending_tree()->SetDeviceScaleFactor(device_scale_factor); 7860 host_impl_->pending_tree()->SetDeviceScaleFactor(device_scale_factor);
7857 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f / 16.f, 7861 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f / 16.f,
7858 16.f); 7862 16.f);
7859 7863
7860 std::unique_ptr<LayerImpl> scoped_root = 7864 std::unique_ptr<LayerImpl> scoped_root =
7861 LayerImpl::Create(host_impl_->pending_tree(), 1); 7865 LayerImpl::Create(host_impl_->pending_tree(), 1);
7862 LayerImpl* root = scoped_root.get(); 7866 LayerImpl* root = scoped_root.get();
7863 root->test_properties()->force_render_surface = true; 7867 root->test_properties()->force_render_surface = true;
7864 7868
7865 host_impl_->pending_tree()->SetRootLayerForTesting(std::move(scoped_root)); 7869 host_impl_->pending_tree()->SetRootLayerForTesting(std::move(scoped_root));
7866 7870
7867 std::unique_ptr<LayerImpl> scoped_scrolling_layer = 7871 std::unique_ptr<LayerImpl> scoped_scrolling_layer =
(...skipping 2683 matching lines...) Expand 10 before | Expand all | Expand 10 after
10551 CreateBasicVirtualViewportLayers(viewport_size, content_size); 10555 CreateBasicVirtualViewportLayers(viewport_size, content_size);
10552 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 10556 host_impl_->active_tree()->BuildPropertyTreesForTesting();
10553 10557
10554 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); 10558 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer();
10555 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); 10559 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer();
10556 10560
10557 // Zoom into the page by a 2X factor 10561 // Zoom into the page by a 2X factor
10558 float min_page_scale = 1.f, max_page_scale = 4.f; 10562 float min_page_scale = 1.f, max_page_scale = 4.f;
10559 float page_scale_factor = 2.f; 10563 float page_scale_factor = 2.f;
10560 host_impl_->active_tree()->PushPageScaleFromMainThread( 10564 host_impl_->active_tree()->PushPageScaleFromMainThread(
10561 page_scale_factor, min_page_scale, max_page_scale); 10565 page_scale_factor, min_page_scale, min_page_scale, max_page_scale);
10562 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); 10566 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
10563 10567
10564 // Scroll by a small amount, there should be no bubbling to the outer 10568 // Scroll by a small amount, there should be no bubbling to the outer
10565 // viewport. 10569 // viewport.
10566 base::TimeTicks start_time = 10570 base::TimeTicks start_time =
10567 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250); 10571 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250);
10568 BeginFrameArgs begin_frame_args = 10572 BeginFrameArgs begin_frame_args =
10569 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); 10573 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
10570 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 10574 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
10571 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(10.f, 20.f)) 10575 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(10.f, 20.f))
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
10640 const gfx::Size viewport_size(100, 100); 10644 const gfx::Size viewport_size(100, 100);
10641 CreateBasicVirtualViewportLayers(viewport_size, content_size); 10645 CreateBasicVirtualViewportLayers(viewport_size, content_size);
10642 10646
10643 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); 10647 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer();
10644 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); 10648 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer();
10645 10649
10646 // Zoom into the page by a 2X factor 10650 // Zoom into the page by a 2X factor
10647 float min_page_scale = 1.f, max_page_scale = 4.f; 10651 float min_page_scale = 1.f, max_page_scale = 4.f;
10648 float page_scale_factor = 2.f; 10652 float page_scale_factor = 2.f;
10649 host_impl_->active_tree()->PushPageScaleFromMainThread( 10653 host_impl_->active_tree()->PushPageScaleFromMainThread(
10650 page_scale_factor, min_page_scale, max_page_scale); 10654 page_scale_factor, min_page_scale, min_page_scale, max_page_scale);
10651 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); 10655 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
10652 10656
10653 // Scroll the inner viewport. 10657 // Scroll the inner viewport.
10654 base::TimeTicks start_time = 10658 base::TimeTicks start_time =
10655 base::TimeTicks() + base::TimeDelta::FromMilliseconds(50); 10659 base::TimeTicks() + base::TimeDelta::FromMilliseconds(50);
10656 BeginFrameArgs begin_frame_args = 10660 BeginFrameArgs begin_frame_args =
10657 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); 10661 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
10658 EXPECT_EQ( 10662 EXPECT_EQ(
10659 InputHandler::SCROLL_ON_IMPL_THREAD, 10663 InputHandler::SCROLL_ON_IMPL_THREAD,
10660 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(90, 90)).thread); 10664 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(90, 90)).thread);
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
10886 DrawFrame(); 10890 DrawFrame();
10887 10891
10888 EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer()); 10892 EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer());
10889 10893
10890 float min_page_scale = 1.f, max_page_scale = 4.f; 10894 float min_page_scale = 1.f, max_page_scale = 4.f;
10891 float page_scale_factor = 1.f; 10895 float page_scale_factor = 1.f;
10892 10896
10893 // The scroll deltas should have the page scale factor applied. 10897 // The scroll deltas should have the page scale factor applied.
10894 { 10898 {
10895 host_impl_->active_tree()->PushPageScaleFromMainThread( 10899 host_impl_->active_tree()->PushPageScaleFromMainThread(
10896 page_scale_factor, min_page_scale, max_page_scale); 10900 page_scale_factor, min_page_scale, min_page_scale, max_page_scale);
10897 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); 10901 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
10898 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d()); 10902 SetScrollOffsetDelta(scroll_layer, gfx::Vector2d());
10899 10903
10900 float page_scale_delta = 2.f; 10904 float page_scale_delta = 2.f;
10901 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 10905 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
10902 InputHandler::TOUCHSCREEN); 10906 InputHandler::TOUCHSCREEN);
10903 host_impl_->PinchGestureBegin(); 10907 host_impl_->PinchGestureBegin();
10904 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); 10908 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point());
10905 host_impl_->PinchGestureEnd(); 10909 host_impl_->PinchGestureEnd();
10906 host_impl_->ScrollEnd(EndState().get()); 10910 host_impl_->ScrollEnd(EndState().get());
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
11335 11339
11336 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); 11340 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink));
11337 EXPECT_CALL(*mock_compositor_frame_sink, ForceReclaimResources()).Times(1); 11341 EXPECT_CALL(*mock_compositor_frame_sink, ForceReclaimResources()).Times(1);
11338 host_impl_->BeginCommit(); 11342 host_impl_->BeginCommit();
11339 } 11343 }
11340 11344
11341 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) { 11345 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) {
11342 // Check page scale factor update in property trees when an update is made 11346 // Check page scale factor update in property trees when an update is made
11343 // on the active tree. 11347 // on the active tree.
11344 host_impl_->CreatePendingTree(); 11348 host_impl_->CreatePendingTree();
11345 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); 11349 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f, 3.f);
11346 CreateScrollAndContentsLayers(host_impl_->pending_tree(), 11350 CreateScrollAndContentsLayers(host_impl_->pending_tree(),
11347 gfx::Size(100, 100)); 11351 gfx::Size(100, 100));
11348 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 11352 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
11349 host_impl_->ActivateSyncTree(); 11353 host_impl_->ActivateSyncTree();
11350 DrawFrame(); 11354 DrawFrame();
11351 11355
11352 host_impl_->CreatePendingTree(); 11356 host_impl_->CreatePendingTree();
11353 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); 11357 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f);
11354 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer(); 11358 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer();
11355 11359
(...skipping 20 matching lines...) Expand all
11376 host_impl_->active_tree()->UpdateDrawProperties(false); 11380 host_impl_->active_tree()->UpdateDrawProperties(false);
11377 active_tree_node = 11381 active_tree_node =
11378 host_impl_->active_tree()->property_trees()->transform_tree.Node( 11382 host_impl_->active_tree()->property_trees()->transform_tree.Node(
11379 page_scale_layer->transform_tree_index()); 11383 page_scale_layer->transform_tree_index());
11380 EXPECT_EQ(active_tree_node->post_local_scale_factor, 2.f); 11384 EXPECT_EQ(active_tree_node->post_local_scale_factor, 2.f);
11381 } 11385 }
11382 11386
11383 TEST_F(LayerTreeHostImplTest, SubLayerScaleForNodeInSubtreeOfPageScaleLayer) { 11387 TEST_F(LayerTreeHostImplTest, SubLayerScaleForNodeInSubtreeOfPageScaleLayer) {
11384 // Checks that the sublayer scale of a transform node in the subtree of the 11388 // Checks that the sublayer scale of a transform node in the subtree of the
11385 // page scale layer is updated without a property tree rebuild. 11389 // page scale layer is updated without a property tree rebuild.
11386 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); 11390 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f, 3.f);
11387 CreateScrollAndContentsLayers(host_impl_->active_tree(), gfx::Size(100, 100)); 11391 CreateScrollAndContentsLayers(host_impl_->active_tree(), gfx::Size(100, 100));
11388 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer(); 11392 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer();
11389 page_scale_layer->test_properties()->AddChild( 11393 page_scale_layer->test_properties()->AddChild(
11390 LayerImpl::Create(host_impl_->active_tree(), 100)); 11394 LayerImpl::Create(host_impl_->active_tree(), 100));
11391 11395
11392 LayerImpl* in_subtree_of_page_scale_layer = 11396 LayerImpl* in_subtree_of_page_scale_layer =
11393 host_impl_->active_tree()->LayerById(100); 11397 host_impl_->active_tree()->LayerById(100);
11394 in_subtree_of_page_scale_layer->test_properties()->force_render_surface = 11398 in_subtree_of_page_scale_layer->test_properties()->force_render_surface =
11395 true; 11399 true;
11396 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 11400 host_impl_->active_tree()->BuildPropertyTreesForTesting();
(...skipping 16 matching lines...) Expand all
11413 } 11417 }
11414 11418
11415 TEST_F(LayerTreeHostImplTest, JitterTest) { 11419 TEST_F(LayerTreeHostImplTest, JitterTest) {
11416 host_impl_->SetViewportSize(gfx::Size(100, 100)); 11420 host_impl_->SetViewportSize(gfx::Size(100, 100));
11417 11421
11418 host_impl_->CreatePendingTree(); 11422 host_impl_->CreatePendingTree();
11419 CreateScrollAndContentsLayers(host_impl_->pending_tree(), 11423 CreateScrollAndContentsLayers(host_impl_->pending_tree(),
11420 gfx::Size(100, 100)); 11424 gfx::Size(100, 100));
11421 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 11425 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
11422 11426
11423 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 11427 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f, 1.f);
11424 const int scroll = 5; 11428 const int scroll = 5;
11425 int accumulated_scroll = 0; 11429 int accumulated_scroll = 0;
11426 for (int i = 0; i < host_impl_->pending_tree()->kFixedPointHitsThreshold + 1; 11430 for (int i = 0; i < host_impl_->pending_tree()->kFixedPointHitsThreshold + 1;
11427 ++i) { 11431 ++i) {
11428 host_impl_->ActivateSyncTree(); 11432 host_impl_->ActivateSyncTree();
11429 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), 11433 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(),
11430 InputHandler::TOUCHSCREEN); 11434 InputHandler::TOUCHSCREEN);
11431 host_impl_->ScrollBy( 11435 host_impl_->ScrollBy(
11432 UpdateState(gfx::Point(), gfx::Vector2dF(0, scroll)).get()); 11436 UpdateState(gfx::Point(), gfx::Vector2dF(0, scroll)).get());
11433 accumulated_scroll += scroll; 11437 accumulated_scroll += scroll;
11434 host_impl_->ScrollEnd(EndState().get()); 11438 host_impl_->ScrollEnd(EndState().get());
11435 host_impl_->active_tree()->UpdateDrawProperties(false); 11439 host_impl_->active_tree()->UpdateDrawProperties(false);
11436 11440
11437 host_impl_->CreatePendingTree(); 11441 host_impl_->CreatePendingTree();
11438 host_impl_->pending_tree()->set_source_frame_number(i + 1); 11442 host_impl_->pending_tree()->set_source_frame_number(i + 1);
11439 LayerImpl* content_layer = host_impl_->pending_tree() 11443 LayerImpl* content_layer = host_impl_->pending_tree()
11440 ->OuterViewportScrollLayer() 11444 ->OuterViewportScrollLayer()
11441 ->test_properties() 11445 ->test_properties()
11442 ->children[0]; 11446 ->children[0];
11443 // The scroll done on the active tree is undone on the pending tree. 11447 // The scroll done on the active tree is undone on the pending tree.
11444 gfx::Transform translate; 11448 gfx::Transform translate;
11445 translate.Translate(0, accumulated_scroll); 11449 translate.Translate(0, accumulated_scroll);
11446 content_layer->test_properties()->transform = translate; 11450 content_layer->test_properties()->transform = translate;
11447 11451
11448 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); 11452 LayerTreeImpl* pending_tree = host_impl_->pending_tree();
11449 pending_tree->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 11453 pending_tree->PushPageScaleFromMainThread(1.f, 1.f, 1.f, 1.f);
11450 LayerImpl* last_scrolled_layer = pending_tree->LayerById( 11454 LayerImpl* last_scrolled_layer = pending_tree->LayerById(
11451 host_impl_->active_tree()->InnerViewportScrollLayer()->id()); 11455 host_impl_->active_tree()->InnerViewportScrollLayer()->id());
11452 11456
11453 // When building property trees from impl side, the builder uses the scroll 11457 // When building property trees from impl side, the builder uses the scroll
11454 // offset of layer_impl to initialize the scroll offset in scroll tree: 11458 // offset of layer_impl to initialize the scroll offset in scroll tree:
11455 // scroll_tree.synced_scroll_offset.PushFromMainThread( 11459 // scroll_tree.synced_scroll_offset.PushFromMainThread(
11456 // layer->CurrentScrollOffset()). 11460 // layer->CurrentScrollOffset()).
11457 // However, layer_impl does not store scroll_offset, so it is using scroll 11461 // However, layer_impl does not store scroll_offset, so it is using scroll
11458 // tree's scroll offset to initialize itself. Usually this approach works 11462 // tree's scroll offset to initialize itself. Usually this approach works
11459 // because this is a simple assignment. However if scroll_offset's pending 11463 // because this is a simple assignment. However if scroll_offset's pending
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
11630 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); 11634 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar());
11631 host_impl_->MouseMoveAt(gfx::Point(10, 150)); 11635 host_impl_->MouseMoveAt(gfx::Point(10, 150));
11632 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); 11636 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar());
11633 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); 11637 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar());
11634 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); 11638 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar());
11635 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); 11639 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar());
11636 } 11640 }
11637 11641
11638 } // namespace 11642 } // namespace
11639 } // namespace cc 11643 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698