OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "cc/trees/layer_tree_host.h" | 9 #include "cc/trees/layer_tree_host.h" |
10 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
11 #include "content/renderer/gpu/render_widget_compositor.h" | 11 #include "content/renderer/gpu/render_widget_compositor.h" |
12 #include "third_party/WebKit/public/web/WebView.h" | 12 #include "third_party/WebKit/public/web/WebView.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 // Check content::TopControlsState and cc::TopControlsState are kept in sync. | 16 // Check content::TopControlsState , cc::TopControlsState, and |
17 // blink::WebWidget::TopControlsState are kept in sync. | |
17 static_assert(int(TOP_CONTROLS_STATE_SHOWN) == int(cc::SHOWN), | 18 static_assert(int(TOP_CONTROLS_STATE_SHOWN) == int(cc::SHOWN), |
18 "mismatching enums: SHOWN"); | 19 "mismatching enums: SHOWN"); |
20 static_assert(int(TOP_CONTROLS_STATE_SHOWN) == int(blink::WebWidget::Shown), | |
21 "mismatching enums: SHOWN"); | |
19 static_assert(int(TOP_CONTROLS_STATE_HIDDEN) == int(cc::HIDDEN), | 22 static_assert(int(TOP_CONTROLS_STATE_HIDDEN) == int(cc::HIDDEN), |
20 "mismatching enums: HIDDEN"); | 23 "mismatching enums: HIDDEN"); |
24 static_assert(int(TOP_CONTROLS_STATE_HIDDEN) == int(blink::WebWidget::Hidden), | |
25 "mismatching enums: HIDDEN"); | |
21 static_assert(int(TOP_CONTROLS_STATE_BOTH) == int(cc::BOTH), | 26 static_assert(int(TOP_CONTROLS_STATE_BOTH) == int(cc::BOTH), |
22 "mismatching enums: BOTH"); | 27 "mismatching enums: BOTH"); |
28 static_assert(int(TOP_CONTROLS_STATE_BOTH) == int(blink::WebWidget::Both), | |
29 "mismatching enums: BOTH"); | |
23 | 30 |
24 cc::TopControlsState ContentToCcTopControlsState( | 31 cc::TopControlsState ContentToCc( |
25 TopControlsState state) { | 32 TopControlsState state) { |
26 return static_cast<cc::TopControlsState>(state); | 33 return static_cast<cc::TopControlsState>(state); |
27 } | 34 } |
28 | 35 |
36 // TODO(majidvp) Use a single enum for both cc and blink | |
37 blink::WebWidget::TopControlsState ContentToBlink( | |
38 TopControlsState state) { | |
39 return static_cast<blink::WebWidget::TopControlsState>(state); | |
40 } | |
41 | |
42 | |
29 // TODO(mvanouwerkerk): Stop calling this code path and delete it. | 43 // TODO(mvanouwerkerk): Stop calling this code path and delete it. |
30 void RenderViewImpl::OnUpdateTopControlsState(bool enable_hiding, | 44 void RenderViewImpl::OnUpdateTopControlsState(bool enable_hiding, |
31 bool enable_showing, | 45 bool enable_showing, |
32 bool animate) { | 46 bool animate) { |
33 // TODO(tedchoc): Investigate why messages are getting here before the | 47 // TODO(tedchoc): Investigate why messages are getting here before the |
34 // compositor has been initialized. | 48 // compositor has been initialized. |
35 LOG_IF(WARNING, !compositor_) << "OnUpdateTopControlsState was unhandled."; | 49 LOG_IF(WARNING, !compositor_) << "OnUpdateTopControlsState was unhandled."; |
36 if (compositor_) { | 50 TopControlsState constraints = TOP_CONTROLS_STATE_BOTH; |
37 cc::TopControlsState constraints = cc::BOTH; | 51 if (!enable_showing) |
38 if (!enable_showing) | 52 constraints = TOP_CONTROLS_STATE_HIDDEN; |
39 constraints = cc::HIDDEN; | 53 if (!enable_hiding) |
40 if (!enable_hiding) | 54 constraints = TOP_CONTROLS_STATE_SHOWN; |
41 constraints = cc::SHOWN; | 55 TopControlsState current = TOP_CONTROLS_STATE_BOTH; |
42 cc::TopControlsState current = cc::BOTH; | 56 |
43 compositor_->UpdateTopControlsState(constraints, current, animate); | 57 UpdateTopControlsState(constraints, current, animate); |
44 top_controls_constraints_ = constraints; | |
45 } | |
46 } | 58 } |
47 | 59 |
48 void RenderViewImpl::UpdateTopControlsState(TopControlsState constraints, | 60 void RenderViewImpl::UpdateTopControlsState(TopControlsState constraints, |
49 TopControlsState current, | 61 TopControlsState current, |
50 bool animate) { | 62 bool animate) { |
51 cc::TopControlsState constraints_cc = | 63 if (compositor_) { |
52 ContentToCcTopControlsState(constraints); | 64 compositor_->UpdateTopControlsState(ContentToCc(constraints), |
aelias_OOO_until_Jul13
2015/02/12 00:45:29
Instead of having the plumbing fork here, let's pl
majidvp
2015/02/12 13:51:48
That sounds good. In which case to be consistent I
aelias_OOO_until_Jul13
2015/02/12 19:24:54
Sounds good, go ahead.
| |
53 cc::TopControlsState current_cc = ContentToCcTopControlsState(current); | 65 ContentToCc(current), |
54 if (compositor_) | 66 animate); |
55 compositor_->UpdateTopControlsState(constraints_cc, current_cc, animate); | 67 } |
56 top_controls_constraints_ = constraints_cc; | 68 if (webwidget()) { |
69 webwidget()->updateTopControlsState(ContentToBlink(constraints), | |
70 ContentToBlink(current), | |
71 animate); | |
72 } | |
73 | |
74 top_controls_constraints_ = constraints; | |
57 } | 75 } |
58 | 76 |
59 void RenderViewImpl::didScrollWithKeyboard(const blink::WebSize& delta) { | 77 void RenderViewImpl::didScrollWithKeyboard(const blink::WebSize& delta) { |
60 if (delta.height == 0) | 78 if (delta.height == 0) |
61 return; | 79 return; |
62 if (compositor_) { | 80 |
63 cc::TopControlsState current = delta.height < 0 ? cc::SHOWN : cc::HIDDEN; | 81 TopControlsState current = delta.height < 0 ? TOP_CONTROLS_STATE_SHOWN |
64 compositor_->UpdateTopControlsState(top_controls_constraints_, | 82 : TOP_CONTROLS_STATE_HIDDEN; |
65 current, | 83 |
66 true); | 84 UpdateTopControlsState(top_controls_constraints_, current, true); |
67 } | |
68 } | 85 } |
69 | 86 |
70 void RenderViewImpl::OnExtractSmartClipData(const gfx::Rect& rect) { | 87 void RenderViewImpl::OnExtractSmartClipData(const gfx::Rect& rect) { |
71 blink::WebString clip_text; | 88 blink::WebString clip_text; |
72 blink::WebString clip_html; | 89 blink::WebString clip_html; |
73 blink::WebRect clip_rect; | 90 blink::WebRect clip_rect; |
74 webview()->extractSmartClipData(rect, clip_text, clip_html, clip_rect); | 91 webview()->extractSmartClipData(rect, clip_text, clip_html, clip_rect); |
75 Send(new ViewHostMsg_SmartClipDataExtracted( | 92 Send(new ViewHostMsg_SmartClipDataExtracted( |
76 routing_id_, clip_text, clip_html, clip_rect)); | 93 routing_id_, clip_text, clip_html, clip_rect)); |
77 } | 94 } |
78 | 95 |
79 } // namespace content | 96 } // namespace content |
OLD | NEW |