blob: 75690e7310e84218489d11723c44d86ba9753559 [file] [log] [blame]
[email protected]198f64122012-11-05 13:09:311// 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.
4
5#include "content/renderer/render_view_impl.h"
6
[email protected]bf189f62012-12-18 03:42:117#include "base/command_line.h"
[email protected]aaf68892013-07-18 00:11:308#include "base/message_loop/message_loop.h"
[email protected]556fd292013-03-18 08:03:049#include "cc/trees/layer_tree_host.h"
[email protected]c4790dcb2013-12-27 22:08:0210#include "content/common/view_messages.h"
[email protected]da82a1f2013-02-26 03:17:5911#include "content/renderer/gpu/render_widget_compositor.h"
[email protected]c4790dcb2013-12-27 22:08:0212#include "third_party/WebKit/public/web/WebView.h"
[email protected]198f64122012-11-05 13:09:3113
14namespace content {
15
mdjones2ee41afd2016-10-27 16:50:2016// Check content::BrowserControlsState, and
17// blink::WebWidget::BrowserControlsState
majidvpfb80e432015-02-23 14:15:5018// are kept in sync.
mdjones2ee41afd2016-10-27 16:50:2019static_assert(int(BROWSER_CONTROLS_STATE_SHOWN) ==
Blink Reformat1c4d759e2017-04-09 16:34:5420 int(blink::kWebBrowserControlsShown),
mdjones2ee41afd2016-10-27 16:50:2021 "mismatching enums: SHOWN");
22static_assert(int(BROWSER_CONTROLS_STATE_HIDDEN) ==
Blink Reformat1c4d759e2017-04-09 16:34:5423 int(blink::kWebBrowserControlsHidden),
mdjones2ee41afd2016-10-27 16:50:2024 "mismatching enums: HIDDEN");
25static_assert(int(BROWSER_CONTROLS_STATE_BOTH) ==
Blink Reformat1c4d759e2017-04-09 16:34:5426 int(blink::kWebBrowserControlsBoth),
mdjones2ee41afd2016-10-27 16:50:2027 "mismatching enums: BOTH");
[email protected]9b003482013-05-21 14:00:1728
mdjones2ee41afd2016-10-27 16:50:2029blink::WebBrowserControlsState ContentToBlink(BrowserControlsState state) {
30 return static_cast<blink::WebBrowserControlsState>(state);
[email protected]9b003482013-05-21 14:00:1731}
32
majidvpfb80e432015-02-23 14:15:5033
[email protected]9b003482013-05-21 14:00:1734// TODO(mvanouwerkerk): Stop calling this code path and delete it.
mdjones2ee41afd2016-10-27 16:50:2035void RenderViewImpl::OnUpdateBrowserControlsState(bool enable_hiding,
36 bool enable_showing,
37 bool animate) {
[email protected]1e62dfcf2013-03-29 08:43:4138 // TODO(tedchoc): Investigate why messages are getting here before the
39 // compositor has been initialized.
mdjones2ee41afd2016-10-27 16:50:2040 LOG_IF(WARNING, !compositor_)
41 << "OnUpdateBrowserControlsState was unhandled.";
42 BrowserControlsState constraints = BROWSER_CONTROLS_STATE_BOTH;
majidvpfb80e432015-02-23 14:15:5043 if (!enable_showing)
mdjones2ee41afd2016-10-27 16:50:2044 constraints = BROWSER_CONTROLS_STATE_HIDDEN;
majidvpfb80e432015-02-23 14:15:5045 if (!enable_hiding)
mdjones2ee41afd2016-10-27 16:50:2046 constraints = BROWSER_CONTROLS_STATE_SHOWN;
47 BrowserControlsState current = BROWSER_CONTROLS_STATE_BOTH;
majidvpfb80e432015-02-23 14:15:5048
mdjones2ee41afd2016-10-27 16:50:2049 UpdateBrowserControlsState(constraints, current, animate);
[email protected]9b003482013-05-21 14:00:1750}
51
mdjones2ee41afd2016-10-27 16:50:2052void RenderViewImpl::UpdateBrowserControlsState(
53 BrowserControlsState constraints,
54 BrowserControlsState current,
55 bool animate) {
lfg8ff33912016-09-13 20:59:2156 if (GetWebWidget())
Blink Reformat1c4d759e2017-04-09 16:34:5457 GetWebWidget()->UpdateBrowserControlsState(
mdjones2ee41afd2016-10-27 16:50:2058 ContentToBlink(constraints), ContentToBlink(current), animate);
majidvpfb80e432015-02-23 14:15:5059
60 top_controls_constraints_ = constraints;
[email protected]bbc8856d2013-06-14 10:37:0461}
62
[email protected]180ef242013-11-07 06:50:4663void RenderViewImpl::didScrollWithKeyboard(const blink::WebSize& delta) {
[email protected]bbc8856d2013-06-14 10:37:0464 if (delta.height == 0)
65 return;
majidvpfb80e432015-02-23 14:15:5066
mdjones2ee41afd2016-10-27 16:50:2067 BrowserControlsState current = delta.height < 0
68 ? BROWSER_CONTROLS_STATE_SHOWN
69 : BROWSER_CONTROLS_STATE_HIDDEN;
majidvpfb80e432015-02-23 14:15:5070
mdjones2ee41afd2016-10-27 16:50:2071 UpdateBrowserControlsState(top_controls_constraints_, current, true);
[email protected]da82a1f2013-02-26 03:17:5972}
73
[email protected]198f64122012-11-05 13:09:3174} // namespace content