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 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <map> | 11 #include <map> |
12 #include <memory> | 12 #include <memory> |
13 #include <queue> | 13 #include <queue> |
14 | 14 |
15 #include "base/callback.h" | 15 #include "base/callback.h" |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/i18n/rtl.h" | 17 #include "base/i18n/rtl.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
20 #include "base/process/process.h" | 20 #include "base/process/process.h" |
21 #include "cc/input/selection.h" | 21 #include "cc/input/selection.h" |
22 #include "cc/output/begin_frame_args.h" | 22 #include "cc/output/begin_frame_args.h" |
| 23 #include "cc/scheduler/begin_frame_source.h" |
23 #include "content/browser/accessibility/browser_accessibility_manager.h" | 24 #include "content/browser/accessibility/browser_accessibility_manager.h" |
24 #include "content/browser/android/content_view_core_impl_observer.h" | 25 #include "content/browser/android/content_view_core_impl_observer.h" |
25 #include "content/browser/renderer_host/delegated_frame_evictor.h" | 26 #include "content/browser/renderer_host/delegated_frame_evictor.h" |
26 #include "content/browser/renderer_host/ime_adapter_android.h" | 27 #include "content/browser/renderer_host/ime_adapter_android.h" |
27 #include "content/browser/renderer_host/input/stylus_text_selector.h" | 28 #include "content/browser/renderer_host/input/stylus_text_selector.h" |
28 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 29 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
29 #include "content/browser/renderer_host/text_input_manager.h" | 30 #include "content/browser/renderer_host/text_input_manager.h" |
30 #include "content/common/content_export.h" | 31 #include "content/common/content_export.h" |
31 #include "content/public/browser/readback_types.h" | 32 #include "content/public/browser/readback_types.h" |
32 #include "gpu/command_buffer/common/mailbox.h" | 33 #include "gpu/command_buffer/common/mailbox.h" |
33 #include "third_party/skia/include/core/SkColor.h" | 34 #include "third_party/skia/include/core/SkColor.h" |
| 35 #include "ui/android/delegated_frame_host_android.h" |
34 #include "ui/android/view_android.h" | 36 #include "ui/android/view_android.h" |
35 #include "ui/android/window_android_observer.h" | 37 #include "ui/android/window_android_observer.h" |
36 #include "ui/events/android/motion_event_android.h" | 38 #include "ui/events/android/motion_event_android.h" |
37 #include "ui/events/gesture_detection/filtered_gesture_provider.h" | 39 #include "ui/events/gesture_detection/filtered_gesture_provider.h" |
38 #include "ui/gfx/geometry/size.h" | 40 #include "ui/gfx/geometry/size.h" |
39 #include "ui/gfx/geometry/vector2d_f.h" | 41 #include "ui/gfx/geometry/vector2d_f.h" |
40 #include "ui/gfx/selection_bound.h" | 42 #include "ui/gfx/selection_bound.h" |
41 #include "ui/touch_selection/touch_selection_controller.h" | 43 #include "ui/touch_selection/touch_selection_controller.h" |
42 | 44 |
43 class GURL; | 45 class GURL; |
44 | 46 |
45 namespace ui { | 47 namespace ui { |
46 struct DidOverscrollParams; | 48 struct DidOverscrollParams; |
47 } | 49 } |
48 | 50 |
49 namespace ui { | |
50 class DelegatedFrameHostAndroid; | |
51 } | |
52 | |
53 namespace content { | 51 namespace content { |
54 class ContentViewCoreImpl; | 52 class ContentViewCoreImpl; |
55 class OverscrollControllerAndroid; | 53 class OverscrollControllerAndroid; |
56 class RenderWidgetHost; | 54 class RenderWidgetHost; |
57 class RenderWidgetHostImpl; | 55 class RenderWidgetHostImpl; |
58 class SynchronousCompositorHost; | 56 class SynchronousCompositorHost; |
59 class SynchronousCompositorClient; | 57 class SynchronousCompositorClient; |
60 struct NativeWebKeyboardEvent; | 58 struct NativeWebKeyboardEvent; |
61 | 59 |
62 // ----------------------------------------------------------------------------- | 60 // ----------------------------------------------------------------------------- |
63 // See comments in render_widget_host_view.h about this class and its members. | 61 // See comments in render_widget_host_view.h about this class and its members. |
64 // ----------------------------------------------------------------------------- | 62 // ----------------------------------------------------------------------------- |
65 class CONTENT_EXPORT RenderWidgetHostViewAndroid | 63 class CONTENT_EXPORT RenderWidgetHostViewAndroid |
66 : public RenderWidgetHostViewBase, | 64 : public RenderWidgetHostViewBase, |
67 public ui::GestureProviderClient, | 65 public ui::GestureProviderClient, |
68 public ui::WindowAndroidObserver, | 66 public ui::WindowAndroidObserver, |
69 public DelegatedFrameEvictorClient, | 67 public DelegatedFrameEvictorClient, |
70 public StylusTextSelectorClient, | 68 public StylusTextSelectorClient, |
71 public ui::TouchSelectionControllerClient, | 69 public ui::TouchSelectionControllerClient, |
72 public content::ContentViewCoreImplObserver, | 70 public content::ContentViewCoreImplObserver, |
73 public content::TextInputManager::Observer { | 71 public content::TextInputManager::Observer, |
| 72 public ui::DelegatedFrameHostAndroid::Client, |
| 73 public cc::BeginFrameObserver { |
74 public: | 74 public: |
75 RenderWidgetHostViewAndroid(RenderWidgetHostImpl* widget, | 75 RenderWidgetHostViewAndroid(RenderWidgetHostImpl* widget, |
76 ContentViewCoreImpl* content_view_core); | 76 ContentViewCoreImpl* content_view_core); |
77 ~RenderWidgetHostViewAndroid() override; | 77 ~RenderWidgetHostViewAndroid() override; |
78 | 78 |
79 void Blur(); | 79 void Blur(); |
80 | 80 |
81 // RenderWidgetHostView implementation. | 81 // RenderWidgetHostView implementation. |
82 bool OnMessageReceived(const IPC::Message& msg) override; | 82 bool OnMessageReceived(const IPC::Message& msg) override; |
83 void InitAsChild(gfx::NativeView parent_view) override; | 83 void InitAsChild(gfx::NativeView parent_view) override; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 const blink::WebInputEvent& input_event) override; | 136 const blink::WebInputEvent& input_event) override; |
137 void OnSetNeedsFlushInput() override; | 137 void OnSetNeedsFlushInput() override; |
138 void GestureEventAck(const blink::WebGestureEvent& event, | 138 void GestureEventAck(const blink::WebGestureEvent& event, |
139 InputEventAckState ack_result) override; | 139 InputEventAckState ack_result) override; |
140 BrowserAccessibilityManager* CreateBrowserAccessibilityManager( | 140 BrowserAccessibilityManager* CreateBrowserAccessibilityManager( |
141 BrowserAccessibilityDelegate* delegate, bool for_root_frame) override; | 141 BrowserAccessibilityDelegate* delegate, bool for_root_frame) override; |
142 bool LockMouse() override; | 142 bool LockMouse() override; |
143 void UnlockMouse() override; | 143 void UnlockMouse() override; |
144 void OnSwapCompositorFrame(uint32_t compositor_frame_sink_id, | 144 void OnSwapCompositorFrame(uint32_t compositor_frame_sink_id, |
145 cc::CompositorFrame frame) override; | 145 cc::CompositorFrame frame) override; |
| 146 void OnBeginFrameDidNotDraw(cc::BeginFrameAck ack) override; |
146 void ClearCompositorFrame() override; | 147 void ClearCompositorFrame() override; |
147 void DidOverscroll(const ui::DidOverscrollParams& params) override; | 148 void DidOverscroll(const ui::DidOverscrollParams& params) override; |
148 void DidStopFlinging() override; | 149 void DidStopFlinging() override; |
149 cc::FrameSinkId GetFrameSinkId() override; | 150 cc::FrameSinkId GetFrameSinkId() override; |
150 void ShowDisambiguationPopup(const gfx::Rect& rect_pixels, | 151 void ShowDisambiguationPopup(const gfx::Rect& rect_pixels, |
151 const SkBitmap& zoomed_bitmap) override; | 152 const SkBitmap& zoomed_bitmap) override; |
152 std::unique_ptr<SyntheticGestureTarget> CreateSyntheticGestureTarget() | 153 std::unique_ptr<SyntheticGestureTarget> CreateSyntheticGestureTarget() |
153 override; | 154 override; |
154 void LockCompositingSurface() override; | 155 void LockCompositingSurface() override; |
155 void UnlockCompositingSurface() override; | 156 void UnlockCompositingSurface() override; |
156 void OnDidNavigateMainFrameToNewPage() override; | 157 void OnDidNavigateMainFrameToNewPage() override; |
157 void SetNeedsBeginFrames(bool needs_begin_frames) override; | 158 void SetNeedsBeginFrames(bool needs_begin_frames) override; |
158 | 159 |
159 // ui::GestureProviderClient implementation. | 160 // ui::GestureProviderClient implementation. |
160 void OnGestureEvent(const ui::GestureEventData& gesture) override; | 161 void OnGestureEvent(const ui::GestureEventData& gesture) override; |
161 | 162 |
162 // ui::WindowAndroidObserver implementation. | 163 // ui::WindowAndroidObserver implementation. |
163 void OnCompositingDidCommit() override; | 164 void OnCompositingDidCommit() override; |
164 void OnRootWindowVisibilityChanged(bool visible) override; | 165 void OnRootWindowVisibilityChanged(bool visible) override; |
165 void OnAttachCompositor() override; | 166 void OnAttachCompositor() override; |
166 void OnDetachCompositor() override; | 167 void OnDetachCompositor() override; |
167 void OnVSync(base::TimeTicks frame_time, | |
168 base::TimeDelta vsync_period) override; | |
169 void OnAnimate(base::TimeTicks begin_frame_time) override; | 168 void OnAnimate(base::TimeTicks begin_frame_time) override; |
170 void OnActivityStopped() override; | 169 void OnActivityStopped() override; |
171 void OnActivityStarted() override; | 170 void OnActivityStarted() override; |
172 | 171 |
173 // content::ContentViewCoreImplObserver implementation. | 172 // content::ContentViewCoreImplObserver implementation. |
174 void OnContentViewCoreDestroyed() override; | 173 void OnContentViewCoreDestroyed() override; |
175 void OnAttachedToWindow() override; | 174 void OnAttachedToWindow() override; |
176 void OnDetachedFromWindow() override; | 175 void OnDetachedFromWindow() override; |
177 | 176 |
178 // DelegatedFrameEvictor implementation | 177 // DelegatedFrameEvictor implementation |
179 void EvictDelegatedFrame() override; | 178 void EvictDelegatedFrame() override; |
180 | 179 |
181 // StylusTextSelectorClient implementation. | 180 // StylusTextSelectorClient implementation. |
182 void OnStylusSelectBegin(float x0, float y0, float x1, float y1) override; | 181 void OnStylusSelectBegin(float x0, float y0, float x1, float y1) override; |
183 void OnStylusSelectUpdate(float x, float y) override; | 182 void OnStylusSelectUpdate(float x, float y) override; |
184 void OnStylusSelectEnd() override; | 183 void OnStylusSelectEnd() override; |
185 void OnStylusSelectTap(base::TimeTicks time, float x, float y) override; | 184 void OnStylusSelectTap(base::TimeTicks time, float x, float y) override; |
186 | 185 |
187 // ui::TouchSelectionControllerClient implementation. | 186 // ui::TouchSelectionControllerClient implementation. |
188 bool SupportsAnimation() const override; | 187 bool SupportsAnimation() const override; |
189 void SetNeedsAnimate() override; | 188 void SetNeedsAnimate() override; |
190 void MoveCaret(const gfx::PointF& position) override; | 189 void MoveCaret(const gfx::PointF& position) override; |
191 void MoveRangeSelectionExtent(const gfx::PointF& extent) override; | 190 void MoveRangeSelectionExtent(const gfx::PointF& extent) override; |
192 void SelectBetweenCoordinates(const gfx::PointF& base, | 191 void SelectBetweenCoordinates(const gfx::PointF& base, |
193 const gfx::PointF& extent) override; | 192 const gfx::PointF& extent) override; |
194 void OnSelectionEvent(ui::SelectionEventType event) override; | 193 void OnSelectionEvent(ui::SelectionEventType event) override; |
195 std::unique_ptr<ui::TouchHandleDrawable> CreateDrawable() override; | 194 std::unique_ptr<ui::TouchHandleDrawable> CreateDrawable() override; |
196 | 195 |
| 196 // DelegatedFrameHostAndroid::Client implementation. |
| 197 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; |
| 198 void ReturnResources(const cc::ReturnedResourceArray& resources) override; |
| 199 |
| 200 // cc::BeginFrameObserver implementation. |
| 201 void OnBeginFrame(const cc::BeginFrameArgs& args) override; |
| 202 const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override; |
| 203 void OnBeginFrameSourcePausedChanged(bool paused) override; |
| 204 |
197 // Non-virtual methods | 205 // Non-virtual methods |
198 void SetContentViewCore(ContentViewCoreImpl* content_view_core); | 206 void SetContentViewCore(ContentViewCoreImpl* content_view_core); |
199 SkColor GetCachedBackgroundColor() const; | 207 SkColor GetCachedBackgroundColor() const; |
200 void SendKeyEvent(const NativeWebKeyboardEvent& event); | 208 void SendKeyEvent(const NativeWebKeyboardEvent& event); |
201 void SendMouseEvent(const ui::MotionEventAndroid&, int changed_button); | 209 void SendMouseEvent(const ui::MotionEventAndroid&, int changed_button); |
202 void SendMouseWheelEvent(const blink::WebMouseWheelEvent& event); | 210 void SendMouseWheelEvent(const blink::WebMouseWheelEvent& event); |
203 void SendGestureEvent(const blink::WebGestureEvent& event); | 211 void SendGestureEvent(const blink::WebGestureEvent& event); |
204 | 212 |
205 void OnStartContentIntent(const GURL& content_url, bool is_main_frame); | 213 void OnStartContentIntent(const GURL& content_url, bool is_main_frame); |
206 void OnSmartClipDataExtracted(const base::string16& text, | 214 void OnSmartClipDataExtracted(const base::string16& text, |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 // Drop any incoming frames from the renderer when there are locks on the | 284 // Drop any incoming frames from the renderer when there are locks on the |
277 // current frame. | 285 // current frame. |
278 void RetainFrame(uint32_t compositor_frame_sink_id, | 286 void RetainFrame(uint32_t compositor_frame_sink_id, |
279 cc::CompositorFrame frame); | 287 cc::CompositorFrame frame); |
280 | 288 |
281 void InternalSwapCompositorFrame(uint32_t compositor_frame_sink_id, | 289 void InternalSwapCompositorFrame(uint32_t compositor_frame_sink_id, |
282 cc::CompositorFrame frame); | 290 cc::CompositorFrame frame); |
283 void DestroyDelegatedContent(); | 291 void DestroyDelegatedContent(); |
284 void OnLostResources(); | 292 void OnLostResources(); |
285 | 293 |
286 void ReturnResources(const cc::ReturnedResourceArray& resources); | 294 enum BeginFrameRequestType { |
287 | |
288 enum VSyncRequestType { | |
289 FLUSH_INPUT = 1 << 0, | 295 FLUSH_INPUT = 1 << 0, |
290 BEGIN_FRAME = 1 << 1, | 296 BEGIN_FRAME = 1 << 1, |
291 PERSISTENT_BEGIN_FRAME = 1 << 2 | 297 PERSISTENT_BEGIN_FRAME = 1 << 2 |
292 }; | 298 }; |
293 void RequestVSyncUpdate(uint32_t requests); | 299 void AddBeginFrameRequest(BeginFrameRequestType request); |
| 300 void ClearBeginFrameRequest(BeginFrameRequestType request); |
294 void StartObservingRootWindow(); | 301 void StartObservingRootWindow(); |
295 void StopObservingRootWindow(); | 302 void StopObservingRootWindow(); |
296 void SendBeginFrame(base::TimeTicks frame_time, base::TimeDelta vsync_period); | 303 void SendBeginFrame(cc::BeginFrameArgs args); |
297 bool Animate(base::TimeTicks frame_time); | 304 bool Animate(base::TimeTicks frame_time); |
298 void RequestDisallowInterceptTouchEvent(); | 305 void RequestDisallowInterceptTouchEvent(); |
299 | 306 |
300 bool SyncCompositorOnMessageReceived(const IPC::Message& message); | 307 bool SyncCompositorOnMessageReceived(const IPC::Message& message); |
301 | 308 |
302 void ComputeEventLatencyOSTouchHistograms(const ui::MotionEvent& event); | 309 void ComputeEventLatencyOSTouchHistograms(const ui::MotionEvent& event); |
303 | 310 |
304 // The model object. | 311 // The model object. |
305 RenderWidgetHostImpl* host_; | 312 RenderWidgetHostImpl* host_; |
306 | 313 |
307 // Used to control action dispatch at the next |OnVSync()| call. | 314 // The begin frame source being observed. Null if none. |
308 uint32_t outstanding_vsync_requests_; | 315 cc::BeginFrameSource* begin_frame_source_; |
| 316 cc::BeginFrameArgs last_begin_frame_args_; |
| 317 |
| 318 // Indicates whether and for what reason a request for begin frames has been |
| 319 // issued. Used to control action dispatch at the next |OnBeginFrame()| call. |
| 320 uint32_t outstanding_begin_frame_requests_; |
309 | 321 |
310 bool is_showing_; | 322 bool is_showing_; |
311 | 323 |
312 // Window-specific bits that affect widget visibility. | 324 // Window-specific bits that affect widget visibility. |
313 bool is_window_visible_; | 325 bool is_window_visible_; |
314 bool is_window_activity_started_; | 326 bool is_window_activity_started_; |
315 | 327 |
316 // ContentViewCoreImpl is our interface to the view system. | 328 // ContentViewCoreImpl is our interface to the view system. |
317 ContentViewCoreImpl* content_view_core_; | 329 ContentViewCoreImpl* content_view_core_; |
318 | 330 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 gfx::Vector2dF last_scroll_offset_; | 389 gfx::Vector2dF last_scroll_offset_; |
378 | 390 |
379 base::WeakPtrFactory<RenderWidgetHostViewAndroid> weak_ptr_factory_; | 391 base::WeakPtrFactory<RenderWidgetHostViewAndroid> weak_ptr_factory_; |
380 | 392 |
381 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAndroid); | 393 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAndroid); |
382 }; | 394 }; |
383 | 395 |
384 } // namespace content | 396 } // namespace content |
385 | 397 |
386 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_ | 398 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_ |
OLD | NEW |