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 <map> | 8 #include <map> |
9 #include <queue> | 9 #include <queue> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/process/process.h" | 16 #include "base/process/process.h" |
17 #include "cc/layers/delegated_frame_resource_collection.h" | 17 #include "cc/layers/delegated_frame_resource_collection.h" |
18 #include "cc/output/begin_frame_args.h" | 18 #include "cc/output/begin_frame_args.h" |
19 #include "content/browser/accessibility/browser_accessibility_manager.h" | 19 #include "content/browser/accessibility/browser_accessibility_manager.h" |
20 #include "content/browser/renderer_host/delegated_frame_evictor.h" | 20 #include "content/browser/renderer_host/delegated_frame_evictor.h" |
21 #include "content/browser/renderer_host/image_transport_factory_android.h" | 21 #include "content/browser/renderer_host/image_transport_factory_android.h" |
22 #include "content/browser/renderer_host/ime_adapter_android.h" | 22 #include "content/browser/renderer_host/ime_adapter_android.h" |
23 #include "content/browser/renderer_host/input/gesture_text_selector.h" | 23 #include "content/browser/renderer_host/input/gesture_text_selector.h" |
| 24 #include "content/browser/renderer_host/input/touch_selection_controller.h" |
24 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 25 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
25 #include "content/common/content_export.h" | 26 #include "content/common/content_export.h" |
26 #include "gpu/command_buffer/common/mailbox.h" | 27 #include "gpu/command_buffer/common/mailbox.h" |
27 #include "third_party/skia/include/core/SkColor.h" | 28 #include "third_party/skia/include/core/SkColor.h" |
28 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 29 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
29 #include "ui/base/android/window_android_observer.h" | 30 #include "ui/base/android/window_android_observer.h" |
30 #include "ui/events/gesture_detection/filtered_gesture_provider.h" | 31 #include "ui/events/gesture_detection/filtered_gesture_provider.h" |
31 #include "ui/gfx/size.h" | 32 #include "ui/gfx/size.h" |
32 #include "ui/gfx/vector2d_f.h" | 33 #include "ui/gfx/vector2d_f.h" |
33 | 34 |
(...skipping 26 matching lines...) Expand all Loading... |
60 // ----------------------------------------------------------------------------- | 61 // ----------------------------------------------------------------------------- |
61 // See comments in render_widget_host_view.h about this class and its members. | 62 // See comments in render_widget_host_view.h about this class and its members. |
62 // ----------------------------------------------------------------------------- | 63 // ----------------------------------------------------------------------------- |
63 class CONTENT_EXPORT RenderWidgetHostViewAndroid | 64 class CONTENT_EXPORT RenderWidgetHostViewAndroid |
64 : public RenderWidgetHostViewBase, | 65 : public RenderWidgetHostViewBase, |
65 public cc::DelegatedFrameResourceCollectionClient, | 66 public cc::DelegatedFrameResourceCollectionClient, |
66 public ImageTransportFactoryAndroidObserver, | 67 public ImageTransportFactoryAndroidObserver, |
67 public ui::GestureProviderClient, | 68 public ui::GestureProviderClient, |
68 public ui::WindowAndroidObserver, | 69 public ui::WindowAndroidObserver, |
69 public DelegatedFrameEvictorClient, | 70 public DelegatedFrameEvictorClient, |
70 public GestureTextSelectorClient { | 71 public GestureTextSelectorClient, |
| 72 public TouchSelectionControllerClient { |
71 public: | 73 public: |
72 RenderWidgetHostViewAndroid(RenderWidgetHostImpl* widget, | 74 RenderWidgetHostViewAndroid(RenderWidgetHostImpl* widget, |
73 ContentViewCoreImpl* content_view_core); | 75 ContentViewCoreImpl* content_view_core); |
74 virtual ~RenderWidgetHostViewAndroid(); | 76 virtual ~RenderWidgetHostViewAndroid(); |
75 | 77 |
76 // RenderWidgetHostView implementation. | 78 // RenderWidgetHostView implementation. |
77 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 79 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
78 virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE; | 80 virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE; |
79 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, | 81 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, |
80 const gfx::Rect& pos) OVERRIDE; | 82 const gfx::Rect& pos) OVERRIDE; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 void SendGestureEvent(const blink::WebGestureEvent& event); | 206 void SendGestureEvent(const blink::WebGestureEvent& event); |
205 | 207 |
206 void OnDidChangeBodyBackgroundColor(SkColor color); | 208 void OnDidChangeBodyBackgroundColor(SkColor color); |
207 void OnStartContentIntent(const GURL& content_url); | 209 void OnStartContentIntent(const GURL& content_url); |
208 void OnSetNeedsBeginFrame(bool enabled); | 210 void OnSetNeedsBeginFrame(bool enabled); |
209 void OnSmartClipDataExtracted(const base::string16& text, | 211 void OnSmartClipDataExtracted(const base::string16& text, |
210 const base::string16& html, | 212 const base::string16& html, |
211 const gfx::Rect rect); | 213 const gfx::Rect rect); |
212 | 214 |
213 bool OnTouchEvent(const ui::MotionEvent& event); | 215 bool OnTouchEvent(const ui::MotionEvent& event); |
| 216 bool OnTouchHandleEvent(const ui::MotionEvent& event); |
214 void ResetGestureDetection(); | 217 void ResetGestureDetection(); |
215 void SetDoubleTapSupportEnabled(bool enabled); | 218 void SetDoubleTapSupportEnabled(bool enabled); |
216 void SetMultiTouchZoomSupportEnabled(bool enabled); | 219 void SetMultiTouchZoomSupportEnabled(bool enabled); |
217 | 220 |
218 long GetNativeImeAdapter(); | 221 long GetNativeImeAdapter(); |
219 | 222 |
220 void WasResized(); | 223 void WasResized(); |
221 | 224 |
222 void GetScaledContentBitmap( | 225 void GetScaledContentBitmap( |
223 float scale, | 226 float scale, |
224 SkColorType color_type, | 227 SkColorType color_type, |
225 gfx::Rect src_subrect, | 228 gfx::Rect src_subrect, |
226 const base::Callback<void(bool, const SkBitmap&)>& result_callback); | 229 const base::Callback<void(bool, const SkBitmap&)>& result_callback); |
227 | 230 |
228 bool HasValidFrame() const; | 231 bool HasValidFrame() const; |
229 | 232 |
230 void MoveCaret(const gfx::Point& point); | 233 void MoveCaret(const gfx::Point& point); |
| 234 void HideTextHandles(); |
231 | 235 |
232 void SynchronousFrameMetadata( | 236 void SynchronousFrameMetadata( |
233 const cc::CompositorFrameMetadata& frame_metadata); | 237 const cc::CompositorFrameMetadata& frame_metadata); |
234 | 238 |
235 void SetOverlayVideoMode(bool enabled); | 239 void SetOverlayVideoMode(bool enabled); |
236 | 240 |
237 typedef base::Callback< | 241 typedef base::Callback< |
238 void(const base::string16& content, int start_offset, int end_offset)> | 242 void(const base::string16& content, int start_offset, int end_offset)> |
239 TextSurroundingSelectionCallback; | 243 TextSurroundingSelectionCallback; |
240 void SetTextSurroundingSelectionCallback( | 244 void SetTextSurroundingSelectionCallback( |
241 const TextSurroundingSelectionCallback& callback); | 245 const TextSurroundingSelectionCallback& callback); |
242 | 246 |
243 private: | 247 private: |
| 248 // TouchSelectionControllerClient implementation. |
| 249 virtual bool SupportsAnimation() const OVERRIDE; |
| 250 virtual void SetNeedsAnimate() OVERRIDE; |
| 251 virtual void MoveCaret(const gfx::PointF& position) OVERRIDE; |
| 252 virtual void SelectBetweenCoordinates(const gfx::PointF& start, |
| 253 const gfx::PointF& end) OVERRIDE; |
| 254 virtual void OnSelectionEvent(SelectionEventType event, |
| 255 const gfx::PointF& anchor_position) OVERRIDE; |
| 256 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() OVERRIDE; |
| 257 |
244 void RunAckCallbacks(); | 258 void RunAckCallbacks(); |
245 | 259 |
246 void DestroyDelegatedContent(); | 260 void DestroyDelegatedContent(); |
247 void SwapDelegatedFrame(uint32 output_surface_id, | 261 void SwapDelegatedFrame(uint32 output_surface_id, |
248 scoped_ptr<cc::DelegatedFrameData> frame_data); | 262 scoped_ptr<cc::DelegatedFrameData> frame_data); |
249 void SendDelegatedFrameAck(uint32 output_surface_id); | 263 void SendDelegatedFrameAck(uint32 output_surface_id); |
250 void SendReturnedDelegatedResources(uint32 output_surface_id); | 264 void SendReturnedDelegatedResources(uint32 output_surface_id); |
251 | 265 |
252 void OnFrameMetadataUpdated( | 266 void OnFrameMetadataUpdated( |
253 const cc::CompositorFrameMetadata& frame_metadata); | 267 const cc::CompositorFrameMetadata& frame_metadata); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 void ReleaseLocksOnSurface(); | 302 void ReleaseLocksOnSurface(); |
289 | 303 |
290 // Drop any incoming frames from the renderer when there are locks on the | 304 // Drop any incoming frames from the renderer when there are locks on the |
291 // current frame. | 305 // current frame. |
292 void RetainFrame(uint32 output_surface_id, | 306 void RetainFrame(uint32 output_surface_id, |
293 scoped_ptr<cc::CompositorFrame> frame); | 307 scoped_ptr<cc::CompositorFrame> frame); |
294 | 308 |
295 void InternalSwapCompositorFrame(uint32 output_surface_id, | 309 void InternalSwapCompositorFrame(uint32 output_surface_id, |
296 scoped_ptr<cc::CompositorFrame> frame); | 310 scoped_ptr<cc::CompositorFrame> frame); |
297 | 311 |
298 void SetNeedsAnimate(); | |
299 bool Animate(base::TimeTicks frame_time); | 312 bool Animate(base::TimeTicks frame_time); |
300 | 313 |
| 314 float GetDpiScale() const; |
| 315 |
301 // The model object. | 316 // The model object. |
302 RenderWidgetHostImpl* host_; | 317 RenderWidgetHostImpl* host_; |
303 | 318 |
304 // Used to track whether this render widget needs a BeginFrame. | 319 // Used to track whether this render widget needs a BeginFrame. |
305 bool needs_begin_frame_; | 320 bool needs_begin_frame_; |
306 | 321 |
307 bool is_showing_; | 322 bool is_showing_; |
308 | 323 |
309 // ContentViewCoreImpl is our interface to the view system. | 324 // ContentViewCoreImpl is our interface to the view system. |
310 ContentViewCoreImpl* content_view_core_; | 325 ContentViewCoreImpl* content_view_core_; |
(...skipping 28 matching lines...) Expand all Loading... |
339 // Note: |overscroll_effect_| will never be NULL, even if it's never enabled. | 354 // Note: |overscroll_effect_| will never be NULL, even if it's never enabled. |
340 scoped_ptr<OverscrollGlow> overscroll_effect_; | 355 scoped_ptr<OverscrollGlow> overscroll_effect_; |
341 | 356 |
342 // Provides gesture synthesis given a stream of touch events (derived from | 357 // Provides gesture synthesis given a stream of touch events (derived from |
343 // Android MotionEvent's) and touch event acks. | 358 // Android MotionEvent's) and touch event acks. |
344 ui::FilteredGestureProvider gesture_provider_; | 359 ui::FilteredGestureProvider gesture_provider_; |
345 | 360 |
346 // Handles gesture based text selection | 361 // Handles gesture based text selection |
347 GestureTextSelector gesture_text_selector_; | 362 GestureTextSelector gesture_text_selector_; |
348 | 363 |
| 364 // Manages selection handle rendering and manipulation. |
| 365 // This will always be NULL if |content_view_core_| is NULL. |
| 366 scoped_ptr<TouchSelectionController> selection_controller_; |
| 367 |
349 bool flush_input_requested_; | 368 bool flush_input_requested_; |
350 | 369 |
351 int accelerated_surface_route_id_; | 370 int accelerated_surface_route_id_; |
352 | 371 |
353 // Size to use if we have no backing ContentViewCore | 372 // Size to use if we have no backing ContentViewCore |
354 gfx::Size default_size_; | 373 gfx::Size default_size_; |
355 | 374 |
356 // Cached selection bounds to avoid redundant selection handle updates. | |
357 cc::ViewportSelectionBound cached_selection_start_; | |
358 cc::ViewportSelectionBound cached_selection_end_; | |
359 | |
360 const bool using_synchronous_compositor_; | 375 const bool using_synchronous_compositor_; |
361 | 376 |
362 scoped_ptr<DelegatedFrameEvictor> frame_evictor_; | 377 scoped_ptr<DelegatedFrameEvictor> frame_evictor_; |
363 | 378 |
364 size_t locks_on_frame_count_; | 379 size_t locks_on_frame_count_; |
365 bool observing_root_window_; | 380 bool observing_root_window_; |
366 | 381 |
367 struct LastFrameInfo { | 382 struct LastFrameInfo { |
368 LastFrameInfo(uint32 output_id, | 383 LastFrameInfo(uint32 output_id, |
369 scoped_ptr<cc::CompositorFrame> output_frame); | 384 scoped_ptr<cc::CompositorFrame> output_frame); |
370 ~LastFrameInfo(); | 385 ~LastFrameInfo(); |
371 uint32 output_surface_id; | 386 uint32 output_surface_id; |
372 scoped_ptr<cc::CompositorFrame> frame; | 387 scoped_ptr<cc::CompositorFrame> frame; |
373 }; | 388 }; |
374 | 389 |
375 scoped_ptr<LastFrameInfo> last_frame_info_; | 390 scoped_ptr<LastFrameInfo> last_frame_info_; |
376 | 391 |
377 TextSurroundingSelectionCallback text_surrounding_selection_callback_; | 392 TextSurroundingSelectionCallback text_surrounding_selection_callback_; |
378 | 393 |
379 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAndroid); | 394 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAndroid); |
380 }; | 395 }; |
381 | 396 |
382 } // namespace content | 397 } // namespace content |
383 | 398 |
384 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_ | 399 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_ |
OLD | NEW |