Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / content / renderer / render_view_impl_android.cc
blob6863c5775b45fc19933dbf2da85180b3f73493ca
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/common/view_messages.h"
11 #include "content/renderer/gpu/render_widget_compositor.h"
12 #include "third_party/WebKit/public/platform/WebRect.h"
13 #include "third_party/WebKit/public/web/WebView.h"
15 namespace content {
17 // Check content::TopControlsState and cc::TopControlsState are kept in sync.
18 COMPILE_ASSERT(int(SHOWN) == int(cc::SHOWN), mismatching_enums);
19 COMPILE_ASSERT(int(HIDDEN) == int(cc::HIDDEN), mismatching_enums);
20 COMPILE_ASSERT(int(BOTH) == int(cc::BOTH), mismatching_enums);
22 cc::TopControlsState ContentToCcTopControlsState(
23 TopControlsState state) {
24 return static_cast<cc::TopControlsState>(state);
27 // TODO(mvanouwerkerk): Stop calling this code path and delete it.
28 void RenderViewImpl::OnUpdateTopControlsState(bool enable_hiding,
29 bool enable_showing,
30 bool animate) {
31 // TODO(tedchoc): Investigate why messages are getting here before the
32 // compositor has been initialized.
33 LOG_IF(WARNING, !compositor_) << "OnUpdateTopControlsState was unhandled.";
34 if (compositor_) {
35 cc::TopControlsState constraints = cc::BOTH;
36 if (!enable_showing)
37 constraints = cc::HIDDEN;
38 if (!enable_hiding)
39 constraints = cc::SHOWN;
40 cc::TopControlsState current = cc::BOTH;
41 compositor_->UpdateTopControlsState(constraints, current, animate);
42 top_controls_constraints_ = constraints;
46 void RenderViewImpl::UpdateTopControlsState(TopControlsState constraints,
47 TopControlsState current,
48 bool animate) {
49 cc::TopControlsState constraints_cc =
50 ContentToCcTopControlsState(constraints);
51 cc::TopControlsState current_cc = ContentToCcTopControlsState(current);
52 if (compositor_)
53 compositor_->UpdateTopControlsState(constraints_cc, current_cc, animate);
54 top_controls_constraints_ = constraints_cc;
57 void RenderViewImpl::didScrollWithKeyboard(const blink::WebSize& delta) {
58 if (delta.height == 0)
59 return;
60 if (compositor_) {
61 cc::TopControlsState current = delta.height < 0 ? cc::SHOWN : cc::HIDDEN;
62 compositor_->UpdateTopControlsState(top_controls_constraints_,
63 current,
64 true);
68 void RenderViewImpl::OnExtractSmartClipData(const gfx::Rect& rect) {
69 Send(new ViewHostMsg_SmartClipDataExtracted(
70 routing_id_, webview()->getSmartClipData(rect)));
73 void RenderViewImpl::GetSelectionRootBounds(gfx::Rect* bounds) const {
74 blink::WebRect bounds_webrect;
75 webview()->getSelectionRootBounds(bounds_webrect);
76 *bounds = bounds_webrect;
79 void RenderViewImpl::UpdateSelectionRootBounds() {
80 if (!webview() || handling_ime_event_)
81 return;
83 gfx::Rect bounds;
84 GetSelectionRootBounds(&bounds);
85 if (selection_root_rect_ != bounds) {
86 selection_root_rect_ = bounds;
87 Send(new ViewHostMsg_SelectionRootBoundsChanged(routing_id_, bounds));
91 } // namespace content