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