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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 void SetNeedsBeginFrames(bool needs_begin_frames) override; | 158 void SetNeedsBeginFrames(bool needs_begin_frames) override; |
159 | 159 |
160 // ui::GestureProviderClient implementation. | 160 // ui::GestureProviderClient implementation. |
161 void OnGestureEvent(const ui::GestureEventData& gesture) override; | 161 void OnGestureEvent(const ui::GestureEventData& gesture) override; |
162 | 162 |
163 // ui::WindowAndroidObserver implementation. | 163 // ui::WindowAndroidObserver implementation. |
164 void OnCompositingDidCommit() override; | 164 void OnCompositingDidCommit() override; |
165 void OnRootWindowVisibilityChanged(bool visible) override; | 165 void OnRootWindowVisibilityChanged(bool visible) override; |
166 void OnAttachCompositor() override; | 166 void OnAttachCompositor() override; |
167 void OnDetachCompositor() override; | 167 void OnDetachCompositor() override; |
168 void OnVSync(base::TimeTicks frame_time, | |
169 base::TimeDelta vsync_period) override; | |
170 void OnAnimate(base::TimeTicks begin_frame_time) override; | 168 void OnAnimate(base::TimeTicks begin_frame_time) override; |
171 void OnActivityStopped() override; | 169 void OnActivityStopped() override; |
172 void OnActivityStarted() override; | 170 void OnActivityStarted() override; |
173 | 171 |
174 // content::ContentViewCoreImplObserver implementation. | 172 // content::ContentViewCoreImplObserver implementation. |
175 void OnContentViewCoreDestroyed() override; | 173 void OnContentViewCoreDestroyed() override; |
176 void OnAttachedToWindow() override; | 174 void OnAttachedToWindow() override; |
177 void OnDetachedFromWindow() override; | 175 void OnDetachedFromWindow() override; |
178 | 176 |
179 // DelegatedFrameEvictor implementation | 177 // DelegatedFrameEvictor implementation |
180 void EvictDelegatedFrame() override; | 178 void EvictDelegatedFrame() override; |
181 | 179 |
182 // StylusTextSelectorClient implementation. | 180 // StylusTextSelectorClient implementation. |
183 void OnStylusSelectBegin(float x0, float y0, float x1, float y1) override; | 181 void OnStylusSelectBegin(float x0, float y0, float x1, float y1) override; |
184 void OnStylusSelectUpdate(float x, float y) override; | 182 void OnStylusSelectUpdate(float x, float y) override; |
185 void OnStylusSelectEnd() override; | 183 void OnStylusSelectEnd() override; |
186 void OnStylusSelectTap(base::TimeTicks time, float x, float y) override; | 184 void OnStylusSelectTap(base::TimeTicks time, float x, float y) override; |
187 | 185 |
188 // ui::TouchSelectionControllerClient implementation. | 186 // ui::TouchSelectionControllerClient implementation. |
189 bool SupportsAnimation() const override; | 187 bool SupportsAnimation() const override; |
190 void SetNeedsAnimate() override; | 188 void SetNeedsAnimate() override; |
191 void MoveCaret(const gfx::PointF& position) override; | 189 void MoveCaret(const gfx::PointF& position) override; |
192 void MoveRangeSelectionExtent(const gfx::PointF& extent) override; | 190 void MoveRangeSelectionExtent(const gfx::PointF& extent) override; |
193 void SelectBetweenCoordinates(const gfx::PointF& base, | 191 void SelectBetweenCoordinates(const gfx::PointF& base, |
194 const gfx::PointF& extent) override; | 192 const gfx::PointF& extent) override; |
195 void OnSelectionEvent(ui::SelectionEventType event) override; | 193 void OnSelectionEvent(ui::SelectionEventType event) override; |
196 std::unique_ptr<ui::TouchHandleDrawable> CreateDrawable() override; | 194 std::unique_ptr<ui::TouchHandleDrawable> CreateDrawable() override; |
197 | 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 |
198 // Non-virtual methods | 205 // Non-virtual methods |
199 void SetContentViewCore(ContentViewCoreImpl* content_view_core); | 206 void SetContentViewCore(ContentViewCoreImpl* content_view_core); |
200 SkColor GetCachedBackgroundColor() const; | 207 SkColor GetCachedBackgroundColor() const; |
201 void SendKeyEvent(const NativeWebKeyboardEvent& event); | 208 void SendKeyEvent(const NativeWebKeyboardEvent& event); |
202 void SendMouseEvent(const ui::MotionEventAndroid&, int changed_button); | 209 void SendMouseEvent(const ui::MotionEventAndroid&, int changed_button); |
203 void SendMouseWheelEvent(const blink::WebMouseWheelEvent& event); | 210 void SendMouseWheelEvent(const blink::WebMouseWheelEvent& event); |
204 void SendGestureEvent(const blink::WebGestureEvent& event); | 211 void SendGestureEvent(const blink::WebGestureEvent& event); |
205 | 212 |
206 void OnStartContentIntent(const GURL& content_url, bool is_main_frame); | 213 void OnStartContentIntent(const GURL& content_url, bool is_main_frame); |
207 void OnSmartClipDataExtracted(const base::string16& text, | 214 void OnSmartClipDataExtracted(const base::string16& text, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 // Drop any incoming frames from the renderer when there are locks on the | 286 // Drop any incoming frames from the renderer when there are locks on the |
280 // current frame. | 287 // current frame. |
281 void RetainFrame(uint32_t compositor_frame_sink_id, | 288 void RetainFrame(uint32_t compositor_frame_sink_id, |
282 cc::CompositorFrame frame); | 289 cc::CompositorFrame frame); |
283 | 290 |
284 void InternalSwapCompositorFrame(uint32_t compositor_frame_sink_id, | 291 void InternalSwapCompositorFrame(uint32_t compositor_frame_sink_id, |
285 cc::CompositorFrame frame); | 292 cc::CompositorFrame frame); |
286 void DestroyDelegatedContent(); | 293 void DestroyDelegatedContent(); |
287 void OnLostResources(); | 294 void OnLostResources(); |
288 | 295 |
289 void ReturnResources(const cc::ReturnedResourceArray& resources); | 296 enum BeginFrameRequestType { |
290 | |
291 enum VSyncRequestType { | |
292 FLUSH_INPUT = 1 << 0, | 297 FLUSH_INPUT = 1 << 0, |
293 BEGIN_FRAME = 1 << 1, | 298 BEGIN_FRAME = 1 << 1, |
294 PERSISTENT_BEGIN_FRAME = 1 << 2 | 299 PERSISTENT_BEGIN_FRAME = 1 << 2 |
295 }; | 300 }; |
296 void RequestVSyncUpdate(uint32_t requests); | 301 void AddBeginFrameRequest(BeginFrameRequestType request); |
| 302 void ClearBeginFrameRequest(BeginFrameRequestType request); |
297 void StartObservingRootWindow(); | 303 void StartObservingRootWindow(); |
298 void StopObservingRootWindow(); | 304 void StopObservingRootWindow(); |
299 void SendBeginFrame(base::TimeTicks frame_time, base::TimeDelta vsync_period); | 305 void SendBeginFrame(cc::BeginFrameArgs args); |
300 bool Animate(base::TimeTicks frame_time); | 306 bool Animate(base::TimeTicks frame_time); |
301 void RequestDisallowInterceptTouchEvent(); | 307 void RequestDisallowInterceptTouchEvent(); |
302 | 308 |
303 bool SyncCompositorOnMessageReceived(const IPC::Message& message); | 309 bool SyncCompositorOnMessageReceived(const IPC::Message& message); |
304 | 310 |
305 void ComputeEventLatencyOSTouchHistograms(const ui::MotionEvent& event); | 311 void ComputeEventLatencyOSTouchHistograms(const ui::MotionEvent& event); |
306 | 312 |
307 void CreateOverscrollControllerIfPossible(); | 313 void CreateOverscrollControllerIfPossible(); |
308 | 314 |
309 // The model object. | 315 // The model object. |
310 RenderWidgetHostImpl* host_; | 316 RenderWidgetHostImpl* host_; |
311 | 317 |
312 // Used to control action dispatch at the next |OnVSync()| call. | 318 // The begin frame source being observed. Null if none. |
313 uint32_t outstanding_vsync_requests_; | 319 cc::BeginFrameSource* begin_frame_source_; |
| 320 cc::BeginFrameArgs last_begin_frame_args_; |
| 321 |
| 322 // Indicates whether and for what reason a request for begin frames has been |
| 323 // issued. Used to control action dispatch at the next |OnBeginFrame()| call. |
| 324 uint32_t outstanding_begin_frame_requests_; |
314 | 325 |
315 bool is_showing_; | 326 bool is_showing_; |
316 | 327 |
317 // Window-specific bits that affect widget visibility. | 328 // Window-specific bits that affect widget visibility. |
318 bool is_window_visible_; | 329 bool is_window_visible_; |
319 bool is_window_activity_started_; | 330 bool is_window_activity_started_; |
320 | 331 |
321 // Used to control the appearance of overscroll glow. | 332 // Used to control the appearance of overscroll glow. |
322 bool is_showing_overscroll_glow_; | 333 bool is_showing_overscroll_glow_; |
323 | 334 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 gfx::Vector2dF last_scroll_offset_; | 396 gfx::Vector2dF last_scroll_offset_; |
386 | 397 |
387 base::WeakPtrFactory<RenderWidgetHostViewAndroid> weak_ptr_factory_; | 398 base::WeakPtrFactory<RenderWidgetHostViewAndroid> weak_ptr_factory_; |
388 | 399 |
389 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAndroid); | 400 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAndroid); |
390 }; | 401 }; |
391 | 402 |
392 } // namespace content | 403 } // namespace content |
393 | 404 |
394 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_ | 405 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_ |
OLD | NEW |