| Index: cc/trees/layer_tree_host_impl.cc
|
| diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
|
| index 9259b34743b8906fbee1a0ac5a63a78b38d5e5c0..a5cdc02734071d9c01977779467ff40b8184c4c4 100644
|
| --- a/cc/trees/layer_tree_host_impl.cc
|
| +++ b/cc/trees/layer_tree_host_impl.cc
|
| @@ -241,12 +241,10 @@ LayerTreeHostImpl::LayerTreeHostImpl(
|
| TRACE_EVENT_OBJECT_CREATED_WITH_ID(
|
| TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_);
|
|
|
| - if (settings.calculate_top_controls_position) {
|
| - top_controls_manager_ =
|
| - TopControlsManager::Create(this,
|
| - settings.top_controls_show_threshold,
|
| - settings.top_controls_hide_threshold);
|
| - }
|
| + top_controls_manager_ =
|
| + TopControlsManager::Create(this,
|
| + settings.top_controls_show_threshold,
|
| + settings.top_controls_hide_threshold);
|
| }
|
|
|
| LayerTreeHostImpl::~LayerTreeHostImpl() {
|
| @@ -916,8 +914,7 @@ DrawResult LayerTreeHostImpl::CalculateRenderPasses(
|
| }
|
|
|
| void LayerTreeHostImpl::MainThreadHasStoppedFlinging() {
|
| - if (top_controls_manager_)
|
| - top_controls_manager_->MainThreadHasStoppedFlinging();
|
| + top_controls_manager_->MainThreadHasStoppedFlinging();
|
| if (input_handler_client_)
|
| input_handler_client_->MainThreadHasStoppedFlinging();
|
| }
|
| @@ -1423,12 +1420,10 @@ CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() const {
|
| metadata.root_layer_size = active_tree_->ScrollableSize();
|
| metadata.min_page_scale_factor = active_tree_->min_page_scale_factor();
|
| metadata.max_page_scale_factor = active_tree_->max_page_scale_factor();
|
| - if (top_controls_manager_) {
|
| - metadata.location_bar_offset =
|
| - gfx::Vector2dF(0.f, top_controls_manager_->ControlsTopOffset());
|
| - metadata.location_bar_content_translation =
|
| - gfx::Vector2dF(0.f, top_controls_manager_->ContentTopOffset());
|
| - }
|
| + metadata.location_bar_offset =
|
| + gfx::Vector2dF(0.f, top_controls_manager_->ControlsTopOffset());
|
| + metadata.location_bar_content_translation =
|
| + gfx::Vector2dF(0.f, top_controls_manager_->ContentTopOffset());
|
|
|
| active_tree_->GetViewportSelection(&metadata.selection_start,
|
| &metadata.selection_end);
|
| @@ -1658,9 +1653,21 @@ void LayerTreeHostImpl::UpdateViewportContainerSizes() {
|
| LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer();
|
| LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer();
|
|
|
| - if (!inner_container || !top_controls_manager_)
|
| + if (!inner_container)
|
| return;
|
|
|
| + // TODO(bokan): This code is currently specific to top controls. It should be
|
| + // made general. crbug.com/464814.
|
| + if (!TopControlsHeight()) {
|
| + if (outer_container)
|
| + outer_container->SetBoundsDelta(gfx::Vector2dF());
|
| +
|
| + inner_container->SetBoundsDelta(gfx::Vector2dF());
|
| + active_tree_->InnerViewportScrollLayer()->SetBoundsDelta(gfx::Vector2dF());
|
| +
|
| + return;
|
| + }
|
| +
|
| ViewportAnchor anchor(InnerViewportScrollLayer(),
|
| OuterViewportScrollLayer());
|
|
|
| @@ -2361,8 +2368,7 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin(
|
| InputHandler::ScrollInputType type) {
|
| TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin");
|
|
|
| - if (top_controls_manager_)
|
| - top_controls_manager_->ScrollBegin();
|
| + top_controls_manager_->ScrollBegin();
|
|
|
| DCHECK(!CurrentlyScrollingLayer());
|
| ClearCurrentlyScrollingLayer();
|
| @@ -2573,9 +2579,6 @@ bool LayerTreeHostImpl::ShouldTopControlsConsumeScroll(
|
| const gfx::Vector2dF& scroll_delta) const {
|
| DCHECK(CurrentlyScrollingLayer());
|
|
|
| - if (!top_controls_manager_)
|
| - return false;
|
| -
|
| // Always consume if it's in the direction to show the top controls.
|
| if (scroll_delta.y() < 0)
|
| return true;
|
| @@ -2816,8 +2819,7 @@ void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() {
|
| }
|
|
|
| void LayerTreeHostImpl::ScrollEnd() {
|
| - if (top_controls_manager_)
|
| - top_controls_manager_->ScrollEnd();
|
| + top_controls_manager_->ScrollEnd();
|
| ClearCurrentlyScrollingLayer();
|
| }
|
|
|
| @@ -2938,8 +2940,7 @@ void LayerTreeHostImpl::PinchGestureBegin() {
|
| active_tree_->SetCurrentlyScrollingLayer(
|
| active_tree_->InnerViewportScrollLayer());
|
| }
|
| - if (top_controls_manager_)
|
| - top_controls_manager_->PinchBegin();
|
| + top_controls_manager_->PinchBegin();
|
| }
|
|
|
| void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta,
|
| @@ -2998,8 +2999,7 @@ void LayerTreeHostImpl::PinchGestureEnd() {
|
| pinch_gesture_end_should_clear_scrolling_layer_ = false;
|
| ClearCurrentlyScrollingLayer();
|
| }
|
| - if (top_controls_manager_)
|
| - top_controls_manager_->PinchEnd();
|
| + top_controls_manager_->PinchEnd();
|
| client_->SetNeedsCommitOnImplThread();
|
| // When a pinch ends, we may be displaying content cached at incorrect scales,
|
| // so updating draw properties and drawing will ensure we are using the right
|
| @@ -3094,7 +3094,7 @@ void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) {
|
| }
|
|
|
| void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) {
|
| - if (!top_controls_manager_ || !top_controls_manager_->animation())
|
| + if (!top_controls_manager_->animation())
|
| return;
|
|
|
| gfx::Vector2dF scroll = top_controls_manager_->Animate(time);
|
|
|