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

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 783543003: Update from https://crrev.com/306901 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_impl_unittest.cc
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 4e070e2a856cc2be481a7711ae1fedf0b4c01843..934946bca89aa2803c624287f694b64494e4f3a9 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -155,8 +155,8 @@ class LayerTreeHostImplTest : public testing::Test,
reduce_memory_result_ = reduce_memory_result;
}
- bool CreateHostImpl(const LayerTreeSettings& settings,
- scoped_ptr<OutputSurface> output_surface) {
+ virtual bool CreateHostImpl(const LayerTreeSettings& settings,
+ scoped_ptr<OutputSurface> output_surface) {
host_impl_ = LayerTreeHostImpl::Create(settings,
this,
&proxy_,
@@ -919,9 +919,9 @@ TEST_F(LayerTreeHostImplTest, ImplPinchZoom) {
// The impl-based pinch zoom should adjust the max scroll position.
{
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(
+ host_impl_->active_tree()->PushPageScaleFromMainThread(
page_scale_factor, min_page_scale, max_page_scale);
- host_impl_->active_tree()->SetPageScaleDelta(1.f);
+ host_impl_->SetPageScaleOnActiveTree(page_scale_factor);
scroll_layer->SetScrollDelta(gfx::Vector2d());
float page_scale_delta = 2.f;
@@ -947,9 +947,9 @@ TEST_F(LayerTreeHostImplTest, ImplPinchZoom) {
// Scrolling after a pinch gesture should always be in local space. The
// scroll deltas have the page scale factor applied.
{
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(
+ host_impl_->active_tree()->PushPageScaleFromMainThread(
page_scale_factor, min_page_scale, max_page_scale);
- host_impl_->active_tree()->SetPageScaleDelta(1.f);
+ host_impl_->SetPageScaleOnActiveTree(page_scale_factor);
scroll_layer->SetScrollDelta(gfx::Vector2d());
float page_scale_delta = 2.f;
@@ -1004,8 +1004,7 @@ TEST_F(LayerTreeHostImplTest, PinchGesture) {
// Basic pinch zoom in gesture
{
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f,
- min_page_scale,
+ host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
max_page_scale);
scroll_layer->SetScrollDelta(gfx::Vector2d());
@@ -1026,8 +1025,7 @@ TEST_F(LayerTreeHostImplTest, PinchGesture) {
// Zoom-in clamping
{
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f,
- min_page_scale,
+ host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
max_page_scale);
scroll_layer->SetScrollDelta(gfx::Vector2d());
float page_scale_delta = 10.f;
@@ -1045,8 +1043,7 @@ TEST_F(LayerTreeHostImplTest, PinchGesture) {
// Zoom-out clamping
{
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f,
- min_page_scale,
+ host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
max_page_scale);
scroll_layer->SetScrollDelta(gfx::Vector2d());
scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50));
@@ -1067,8 +1064,7 @@ TEST_F(LayerTreeHostImplTest, PinchGesture) {
// Two-finger panning should not happen based on pinch events only
{
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f,
- min_page_scale,
+ host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
max_page_scale);
scroll_layer->SetScrollDelta(gfx::Vector2d());
scroll_layer->SetScrollOffset(gfx::ScrollOffset(20, 20));
@@ -1089,8 +1085,7 @@ TEST_F(LayerTreeHostImplTest, PinchGesture) {
// Two-finger panning should work with interleaved scroll events
{
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f,
- min_page_scale,
+ host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
max_page_scale);
scroll_layer->SetScrollDelta(gfx::Vector2d());
scroll_layer->SetScrollOffset(gfx::ScrollOffset(20, 20));
@@ -1112,9 +1107,7 @@ TEST_F(LayerTreeHostImplTest, PinchGesture) {
// Two-finger panning should work when starting fully zoomed out.
{
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(0.5f,
- 0.5f,
- 4.f);
+ host_impl_->active_tree()->PushPageScaleFromMainThread(0.5f, 0.5f, 4.f);
scroll_layer->SetScrollDelta(gfx::Vector2d());
scroll_layer->SetScrollOffset(gfx::ScrollOffset(0, 0));
@@ -1152,8 +1145,7 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimation) {
// Non-anchor zoom-in
{
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f,
- min_page_scale,
+ host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
max_page_scale);
scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50));
@@ -1196,8 +1188,7 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimation) {
// Anchor zoom-out
{
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f,
- min_page_scale,
+ host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
max_page_scale);
scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50));
@@ -1253,8 +1244,7 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimationNoOp) {
// Anchor zoom with unchanged page scale should not change scroll or scale.
{
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f,
- min_page_scale,
+ host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
max_page_scale);
scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50));
@@ -1291,8 +1281,7 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) {
float min_page_scale = 0.5f;
float max_page_scale = 4.f;
- host_impl_->sync_tree()->SetPageScaleFactorAndLimits(1.f,
- min_page_scale,
+ host_impl_->sync_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
max_page_scale);
host_impl_->ActivateSyncTree();
@@ -1522,7 +1511,7 @@ TEST_F(LayerTreeHostImplTest, ScrollbarFadePinchZoomScrollbars) {
base::TimeTicks fake_now = gfx::FrameTime::Now();
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f);
+ host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f);
EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_);
EXPECT_FALSE(did_request_animate_);
@@ -1549,7 +1538,7 @@ TEST_F(LayerTreeHostImplTest, ScrollbarFadePinchZoomScrollbars) {
EXPECT_FALSE(did_request_animate_);
// Make page scale > min so that subsequent scrolls will trigger fades.
- host_impl_->active_tree()->SetPageScaleDelta(1.1f);
+ host_impl_->SetPageScaleOnActiveTree(1.1f);
// After a scroll, a fade animation should be scheduled about 20ms from now.
host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel);
@@ -1664,7 +1653,7 @@ TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf2) {
TEST_F(LayerTreeHostImplTest, CompositorFrameMetadata) {
SetupScrollAndContentsLayers(gfx::Size(100, 100));
host_impl_->SetViewportSize(gfx::Size(50, 50));
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f);
+ host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f);
DrawFrame();
{
CompositorFrameMetadata metadata =
@@ -1712,8 +1701,8 @@ TEST_F(LayerTreeHostImplTest, CompositorFrameMetadata) {
// Likewise if set from the main thread.
host_impl_->ProcessScrollDeltas();
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(4.f, 0.5f, 4.f);
- host_impl_->active_tree()->SetPageScaleDelta(1.f);
+ host_impl_->active_tree()->PushPageScaleFromMainThread(4.f, 0.5f, 4.f);
+ host_impl_->SetPageScaleOnActiveTree(4.f);
{
CompositorFrameMetadata metadata =
host_impl_->MakeCompositorFrameMetadata();
@@ -2265,14 +2254,27 @@ class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest {
// Make the clip size the same as the layer (content) size so the layer is
// non-scrollable.
: layer_size_(10, 10),
- clip_size_(layer_size_) {
+ clip_size_(layer_size_),
+ top_controls_height_(50) {
settings_.calculate_top_controls_position = true;
- settings_.top_controls_height = 50;
settings_.use_pinch_virtual_viewport = true;
- viewport_size_ =
- gfx::Size(clip_size_.width(),
- clip_size_.height() + settings_.top_controls_height);
+ viewport_size_ = gfx::Size(clip_size_.width(),
+ clip_size_.height() + top_controls_height_);
+ }
+
+ bool CreateHostImpl(const LayerTreeSettings& settings,
+ scoped_ptr<OutputSurface> output_surface) override {
+ bool init =
+ LayerTreeHostImplTest::CreateHostImpl(settings, output_surface.Pass());
+ if (init && settings.calculate_top_controls_position) {
+ host_impl_->active_tree()->set_top_controls_height(top_controls_height_);
+ host_impl_->active_tree()->set_top_controls_delta(top_controls_height_);
+ host_impl_->top_controls_manager()->SetTopControlsHeight(
+ top_controls_height_);
+ host_impl_->DidChangeTopControlsPosition();
+ }
+ return init;
}
void SetupTopControlsAndScrollLayer() {
@@ -2297,8 +2299,9 @@ class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest {
// Set a viewport size that is large enough to contain both the top controls
// and some content.
host_impl_->SetViewportSize(viewport_size_);
- host_impl_->SetTopControlsLayoutHeight(
- settings_.top_controls_height);
+ host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true);
+
+ host_impl_->DidChangeTopControlsPosition();
host_impl_->CreatePendingTree();
root =
@@ -2322,8 +2325,8 @@ class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest {
// Set a viewport size that is large enough to contain both the top controls
// and some content.
host_impl_->SetViewportSize(viewport_size_);
- host_impl_->sync_tree()->set_top_controls_layout_height(
- settings_.top_controls_height);
+ host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true);
+ host_impl_->DidChangeTopControlsPosition();
}
void SetupTopControlsAndScrollLayerWithVirtualViewport(
@@ -2331,8 +2334,8 @@ class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest {
const gfx::Size& outer_viewport_size,
const gfx::Size& scroll_layer_size) {
CreateHostImpl(settings_, CreateOutputSurface());
- host_impl_->SetTopControlsLayoutHeight(
- settings_.top_controls_height);
+ host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true);
+ host_impl_->DidChangeTopControlsPosition();
scoped_ptr<LayerImpl> root =
LayerImpl::Create(host_impl_->active_tree(), 1);
@@ -2385,6 +2388,7 @@ class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest {
gfx::Size layer_size_;
gfx::Size clip_size_;
gfx::Size viewport_size_;
+ float top_controls_height_;
LayerTreeSettings settings_;
}; // class LayerTreeHostImplTopControlsTest
@@ -2433,7 +2437,7 @@ TEST_F(LayerTreeHostImplTopControlsTest,
// Need SetDrawsContent so ScrollBegin's hit test finds an actual layer.
outer_scroll->SetDrawsContent(true);
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(2.f, 1.f, 2.f);
+ host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f);
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
@@ -2496,13 +2500,12 @@ TEST_F(LayerTreeHostImplTopControlsTest, FixedContainerDelta) {
DrawFrame();
float page_scale = 1.5f;
- float top_controls_height = settings_.top_controls_height;
LayerImpl* outer_viewport_scroll_layer =
host_impl_->active_tree()->OuterViewportScrollLayer();
// Zoom in, since the fixed container is the outer viewport, the delta should
// not be scaled.
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(page_scale, 1.f, 2.f);
+ host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 2.f);
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
@@ -2512,7 +2515,7 @@ TEST_F(LayerTreeHostImplTopControlsTest, FixedContainerDelta) {
gfx::Vector2dF top_controls_scroll_delta(0.f, 20.f);
host_impl_->top_controls_manager()->ScrollBegin();
host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta);
- EXPECT_EQ(top_controls_height - top_controls_scroll_delta.y(),
+ EXPECT_EQ(top_controls_height_ - top_controls_scroll_delta.y(),
host_impl_->top_controls_manager()->ContentTopOffset());
EXPECT_VECTOR_EQ(top_controls_scroll_delta,
outer_viewport_scroll_layer->FixedContainerSizeDelta());
@@ -2525,7 +2528,7 @@ TEST_F(LayerTreeHostImplTopControlsTest, FixedContainerDelta) {
host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta);
host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta);
EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset());
- EXPECT_VECTOR_EQ(gfx::Vector2dF(0, top_controls_height),
+ EXPECT_VECTOR_EQ(gfx::Vector2dF(0, top_controls_height_),
outer_viewport_scroll_layer->FixedContainerSizeDelta());
host_impl_->ScrollEnd();
@@ -2535,7 +2538,7 @@ TEST_F(LayerTreeHostImplTopControlsTest, FixedContainerDelta) {
EXPECT_EQ(top_controls_scroll_delta.y(),
host_impl_->top_controls_manager()->ContentTopOffset());
EXPECT_VECTOR_EQ(
- gfx::Vector2dF(0, top_controls_height - top_controls_scroll_delta.y()),
+ gfx::Vector2dF(0, top_controls_height_ - top_controls_scroll_delta.y()),
outer_viewport_scroll_layer->FixedContainerSizeDelta());
host_impl_->top_controls_manager()->ScrollEnd();
}
@@ -2606,12 +2609,11 @@ TEST_F(LayerTreeHostImplTopControlsTest, TopControlsLayoutHeightChanged) {
SetupTopControlsAndScrollLayer();
DrawFrame();
- host_impl_->sync_tree()->set_top_controls_content_offset(15.f);
- host_impl_->sync_tree()->set_top_controls_layout_height(15.f);
+ host_impl_->sync_tree()->set_top_controls_content_offset(50.f);
+ host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true);
- host_impl_->active_tree()->set_top_controls_content_offset(20.f);
- host_impl_->active_tree()->set_top_controls_delta(-20.f);
- host_impl_->active_tree()->set_sent_top_controls_delta(-5.f);
+ host_impl_->active_tree()->set_top_controls_content_offset(50.f);
+ host_impl_->active_tree()->set_top_controls_delta(-50.f);
host_impl_->DidChangeTopControlsPosition();
LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer();
@@ -2620,7 +2622,7 @@ TEST_F(LayerTreeHostImplTopControlsTest, TopControlsLayoutHeightChanged) {
host_impl_->sync_tree()->root_layer()->SetBounds(
gfx::Size(root_clip_ptr->bounds().width(),
- root_clip_ptr->bounds().height() - 15.f));
+ root_clip_ptr->bounds().height() - 50.f));
host_impl_->ActivateSyncTree();
@@ -2631,14 +2633,14 @@ TEST_F(LayerTreeHostImplTopControlsTest, TopControlsLayoutHeightChanged) {
// account for the difference between the layout height and the current
// top controls offset.
EXPECT_EQ(viewport_size_, root_clip_ptr->bounds());
- EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 15.f), root_clip_ptr->bounds_delta());
+ EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 50.f), root_clip_ptr->bounds_delta());
host_impl_->active_tree()->set_top_controls_delta(0.f);
host_impl_->DidChangeTopControlsPosition();
- EXPECT_EQ(15.f, host_impl_->top_controls_manager()->ContentTopOffset());
+ EXPECT_EQ(50.f, host_impl_->top_controls_manager()->ContentTopOffset());
EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 0.f), root_clip_ptr->bounds_delta());
- EXPECT_EQ(gfx::Size(viewport_size_.width(), viewport_size_.height()-15.f),
+ EXPECT_EQ(gfx::Size(viewport_size_.width(), viewport_size_.height() - 50.f),
root_clip_ptr->bounds());
}
@@ -2650,7 +2652,7 @@ TEST_F(LayerTreeHostImplTopControlsTest, TopControlsViewportOffsetClamping) {
gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400));
DrawFrame();
- EXPECT_EQ(settings_.top_controls_height,
+ EXPECT_EQ(top_controls_height_,
host_impl_->active_tree()->total_top_controls_content_offset());
LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer();
@@ -2672,7 +2674,7 @@ TEST_F(LayerTreeHostImplTopControlsTest, TopControlsViewportOffsetClamping) {
// scrolling down at the max extents no longer hides the top controls
EXPECT_EQ(0.f,
- settings_.top_controls_height -
+ top_controls_height_ -
host_impl_->active_tree()->total_top_controls_content_offset());
// forcefully hide the top controls by 25px
@@ -2680,7 +2682,7 @@ TEST_F(LayerTreeHostImplTopControlsTest, TopControlsViewportOffsetClamping) {
host_impl_->ScrollEnd();
EXPECT_EQ(scroll_delta.y(),
- settings_.top_controls_height -
+ top_controls_height_ -
host_impl_->active_tree()->total_top_controls_content_offset());
inner_scroll->ClampScrollToMaxScrollOffset();
@@ -2717,7 +2719,7 @@ TEST_F(LayerTreeHostImplTopControlsTest, TopControlsAspectRatio) {
gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400));
DrawFrame();
- EXPECT_EQ(settings_.top_controls_height,
+ EXPECT_EQ(top_controls_height_,
host_impl_->active_tree()->total_top_controls_content_offset());
gfx::Vector2dF scroll_delta(0.f, 25.f);
@@ -2727,7 +2729,7 @@ TEST_F(LayerTreeHostImplTopControlsTest, TopControlsAspectRatio) {
host_impl_->ScrollEnd();
EXPECT_EQ(scroll_delta.y(),
- settings_.top_controls_height -
+ top_controls_height_ -
host_impl_->active_tree()->total_top_controls_content_offset());
// Top controls were hidden by 25px so the inner viewport should have expanded
@@ -2753,7 +2755,7 @@ TEST_F(LayerTreeHostImplTopControlsTest, TopControlsScrollOuterViewport) {
gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400));
DrawFrame();
- EXPECT_EQ(settings_.top_controls_height,
+ EXPECT_EQ(top_controls_height_,
host_impl_->active_tree()->total_top_controls_content_offset());
// Send a gesture scroll that will scroll the outer viewport, make sure the
@@ -2767,7 +2769,7 @@ TEST_F(LayerTreeHostImplTopControlsTest, TopControlsScrollOuterViewport) {
host_impl_->ScrollEnd();
EXPECT_EQ(scroll_delta.y(),
- settings_.top_controls_height -
+ top_controls_height_ -
host_impl_->active_tree()->total_top_controls_content_offset());
scroll_delta = gfx::Vector2dF(0.f, 50.f);
@@ -2791,11 +2793,11 @@ TEST_F(LayerTreeHostImplTopControlsTest, TopControlsScrollOuterViewport) {
host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
host_impl_->ScrollBy(gfx::Point(), scroll_delta);
- EXPECT_EQ(settings_.top_controls_height,
+ EXPECT_EQ(top_controls_height_,
host_impl_->active_tree()->total_top_controls_content_offset());
- EXPECT_EQ(inner_viewport_offset.y() +
- (scroll_delta.y() + settings_.top_controls_height),
- host_impl_->InnerViewportScrollLayer()->ScrollDelta().y());
+ EXPECT_EQ(
+ inner_viewport_offset.y() + (scroll_delta.y() + top_controls_height_),
+ host_impl_->InnerViewportScrollLayer()->ScrollDelta().y());
host_impl_->ScrollEnd();
}
@@ -3017,8 +3019,7 @@ TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) {
host_impl_->ScrollEnd();
// Set new page scale from main thread.
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(page_scale,
- page_scale,
+ host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, page_scale,
page_scale);
scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas();
@@ -3052,7 +3053,7 @@ TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnImplThread) {
Layer::INVALID_ID);
host_impl_->active_tree()->DidBecomeActive();
host_impl_->SetViewportSize(viewport_size);
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, page_scale);
+ host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, page_scale);
DrawFrame();
LayerImpl* root_scroll =
@@ -3084,7 +3085,7 @@ TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnImplThread) {
EXPECT_EQ(expected_max_scroll, root_scroll->MaxScrollOffset());
// The page scale delta should match the new scale on the impl side.
- EXPECT_EQ(page_scale, host_impl_->active_tree()->total_page_scale_factor());
+ EXPECT_EQ(page_scale, host_impl_->active_tree()->current_page_scale_factor());
}
TEST_F(LayerTreeHostImplTest, PageScaleDeltaAppliedToRootScrollLayerOnly) {
@@ -3180,8 +3181,7 @@ TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) {
host_impl_->ScrollEnd();
float page_scale = 2.f;
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(page_scale,
- 1.f,
+ host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f,
page_scale);
DrawOneFrame();
@@ -3336,8 +3336,8 @@ TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) {
// Scrolling should be adjusted from viewport space.
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(2.f, 2.f, 2.f);
- host_impl_->active_tree()->SetPageScaleDelta(1.f);
+ host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 2.f, 2.f);
+ host_impl_->SetPageScaleOnActiveTree(2.f);
scroll_delta = gfx::Vector2d(0, -2);
EXPECT_EQ(InputHandler::ScrollStarted,
@@ -3611,7 +3611,7 @@ TEST_F(LayerTreeHostImplTest, ScrollViewportRounding) {
host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds(
gfx::Size(width * scale - 1, height * scale));
host_impl_->SetDeviceScaleFactor(scale);
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f);
+ host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f);
LayerImpl* inner_viewport_scroll_layer =
host_impl_->active_tree()->InnerViewportScrollLayer();
@@ -3712,16 +3712,16 @@ TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) {
EXPECT_EQ(0.f, scroll_delegate.max_page_scale_factor());
// Updating page scale immediately updates the delegate.
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(2.f, 0.5f, 4.f);
+ host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 0.5f, 4.f);
EXPECT_EQ(2.f, scroll_delegate.page_scale_factor());
EXPECT_EQ(0.5f, scroll_delegate.min_page_scale_factor());
EXPECT_EQ(4.f, scroll_delegate.max_page_scale_factor());
- host_impl_->active_tree()->SetPageScaleDelta(1.5f);
+ host_impl_->SetPageScaleOnActiveTree(2.f * 1.5f);
EXPECT_EQ(3.f, scroll_delegate.page_scale_factor());
EXPECT_EQ(0.5f, scroll_delegate.min_page_scale_factor());
EXPECT_EQ(4.f, scroll_delegate.max_page_scale_factor());
- host_impl_->active_tree()->SetPageScaleDelta(1.f);
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f);
+ host_impl_->SetPageScaleOnActiveTree(2.f);
+ host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f);
EXPECT_EQ(1.f, scroll_delegate.page_scale_factor());
EXPECT_EQ(0.5f, scroll_delegate.min_page_scale_factor());
EXPECT_EQ(4.f, scroll_delegate.max_page_scale_factor());
@@ -3818,7 +3818,7 @@ TEST_F(LayerTreeHostImplTest, OverscrollRoot) {
InputHandlerScrollResult scroll_result;
SetupScrollAndContentsLayers(gfx::Size(100, 100));
host_impl_->SetViewportSize(gfx::Size(50, 50));
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f);
+ host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f);
DrawFrame();
EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
@@ -4037,7 +4037,7 @@ TEST_F(LayerTreeHostImplTest, OverscrollAlways) {
LayerImpl* clip_layer = scroll_layer->parent()->parent();
clip_layer->SetBounds(gfx::Size(50, 50));
host_impl_->SetViewportSize(gfx::Size(50, 50));
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f);
+ host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f);
DrawFrame();
EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
@@ -4060,9 +4060,9 @@ TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) {
scoped_ptr<LayerImpl> child =
CreateScrollableLayer(2, content_size, root_clip.get());
root->scroll_clip_layer()->SetBounds(gfx::Size(320, 469));
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(
- 0.326531f, 0.326531f, 5.f);
- host_impl_->active_tree()->SetPageScaleDelta(1.f);
+ host_impl_->active_tree()->PushPageScaleFromMainThread(0.326531f, 0.326531f,
+ 5.f);
+ host_impl_->SetPageScaleOnActiveTree(0.326531f);
child->SetScrollClipLayer(Layer::INVALID_ID);
root->AddChild(child.Pass());
root_clip->AddChild(root.Pass());
@@ -6142,8 +6142,8 @@ TEST_F(LayerTreeHostImplTest, FarAwayQuadsDontNeedAA) {
host_impl_->SetViewportSize(device_viewport_size);
host_impl_->CreatePendingTree();
- host_impl_->pending_tree()
- ->SetPageScaleFactorAndLimits(1.f, 1.f / 16.f, 16.f);
+ host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f / 16.f,
+ 16.f);
scoped_ptr<LayerImpl> scoped_root =
LayerImpl::Create(host_impl_->pending_tree(), 1);
@@ -7166,8 +7166,11 @@ class LayerTreeHostImplWithTopControlsTest : public LayerTreeHostImplTest {
void SetUp() override {
LayerTreeSettings settings = DefaultSettings();
settings.calculate_top_controls_position = true;
- settings.top_controls_height = top_controls_height_;
CreateHostImpl(settings, CreateOutputSurface());
+ host_impl_->active_tree()->set_top_controls_height(top_controls_height_);
+ host_impl_->active_tree()->set_top_controls_delta(top_controls_height_);
+ host_impl_->top_controls_manager()->SetTopControlsHeight(
+ top_controls_height_);
}
protected:
@@ -7183,6 +7186,31 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) {
EXPECT_FALSE(did_request_redraw_);
}
+TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsHeightIsCommitted) {
+ SetupScrollAndContentsLayers(gfx::Size(100, 100));
+ EXPECT_FALSE(did_request_redraw_);
+ host_impl_->CreatePendingTree();
+ host_impl_->sync_tree()->set_top_controls_height(100);
+ host_impl_->ActivateSyncTree();
+ EXPECT_EQ(100, host_impl_->top_controls_manager()->top_controls_height());
+}
+
+TEST_F(LayerTreeHostImplWithTopControlsTest,
+ TopControlsStayFullyVisibleOnHeightChange) {
+ SetupScrollAndContentsLayers(gfx::Size(100, 100));
+ EXPECT_EQ(0.f, host_impl_->ControlsTopOffset());
+
+ host_impl_->CreatePendingTree();
+ host_impl_->sync_tree()->set_top_controls_height(0);
+ host_impl_->ActivateSyncTree();
+ EXPECT_EQ(0.f, host_impl_->ControlsTopOffset());
+
+ host_impl_->CreatePendingTree();
+ host_impl_->sync_tree()->set_top_controls_height(50);
+ host_impl_->ActivateSyncTree();
+ EXPECT_EQ(0.f, host_impl_->ControlsTopOffset());
+}
+
TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationScheduling) {
SetupScrollAndContentsLayers(gfx::Size(100, 100))
->SetScrollOffset(gfx::ScrollOffset(0, 10));
@@ -7812,9 +7840,9 @@ TEST_F(LayerTreeHostImplTest, WheelScrollWithPageScaleFactorOnInnerLayer) {
// The scroll deltas should have the page scale factor applied.
{
- host_impl_->active_tree()->SetPageScaleFactorAndLimits(
+ host_impl_->active_tree()->PushPageScaleFromMainThread(
page_scale_factor, min_page_scale, max_page_scale);
- host_impl_->active_tree()->SetPageScaleDelta(1.f);
+ host_impl_->SetPageScaleOnActiveTree(page_scale_factor);
scroll_layer->SetScrollDelta(gfx::Vector2d());
float page_scale_delta = 2.f;
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698