1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/renderer/render_view_impl.h"
7 #include "base/command_line.h"
8 #include "base/message_loop/message_loop.h"
9 #include "cc/trees/layer_tree_host.h"
10 #include "content/renderer/gpu/render_widget_compositor.h"
14 // Check content::TopControlsState and cc::TopControlsState are kept in sync.
15 COMPILE_ASSERT(int(SHOWN) == int(cc::SHOWN), mismatching_enums);
16 COMPILE_ASSERT(int(HIDDEN) == int(cc::HIDDEN), mismatching_enums);
17 COMPILE_ASSERT(int(BOTH) == int(cc::BOTH), mismatching_enums);
19 cc::TopControlsState ContentToCcTopControlsState(
20 TopControlsState state) {
21 return static_cast<cc::TopControlsState>(state);
24 // TODO(mvanouwerkerk): Stop calling this code path and delete it.
25 void RenderViewImpl::OnUpdateTopControlsState(bool enable_hiding,
28 // TODO(tedchoc): Investigate why messages are getting here before the
29 // compositor has been initialized.
30 LOG_IF(WARNING, !compositor_) << "OnUpdateTopControlsState was unhandled.";
32 cc::TopControlsState constraints = cc::BOTH;
34 constraints = cc::HIDDEN;
36 constraints = cc::SHOWN;
37 cc::TopControlsState current = cc::BOTH;
38 compositor_->UpdateTopControlsState(constraints, current, animate);
39 top_controls_constraints_ = constraints;
43 void RenderViewImpl::UpdateTopControlsState(TopControlsState constraints,
44 TopControlsState current,
46 cc::TopControlsState constraints_cc =
47 ContentToCcTopControlsState(constraints);
48 cc::TopControlsState current_cc = ContentToCcTopControlsState(current);
50 compositor_->UpdateTopControlsState(constraints_cc, current_cc, animate);
51 top_controls_constraints_ = constraints_cc;
54 void RenderViewImpl::didScrollWithKeyboard(const WebKit::WebSize& delta) {
55 if (delta.height == 0)
58 cc::TopControlsState current = delta.height < 0 ? cc::SHOWN : cc::HIDDEN;
59 compositor_->UpdateTopControlsState(top_controls_constraints_,
65 } // namespace content