| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 void SendGestureEvent(const blink::WebGestureEvent& event); | 207 void SendGestureEvent(const blink::WebGestureEvent& event); |
| 206 | 208 |
| 207 void OnDidChangeBodyBackgroundColor(SkColor color); | 209 void OnDidChangeBodyBackgroundColor(SkColor color); |
| 208 void OnStartContentIntent(const GURL& content_url); | 210 void OnStartContentIntent(const GURL& content_url); |
| 209 void OnSetNeedsBeginFrame(bool enabled); | 211 void OnSetNeedsBeginFrame(bool enabled); |
| 210 void OnSmartClipDataExtracted(const base::string16& text, | 212 void OnSmartClipDataExtracted(const base::string16& text, |
| 211 const base::string16& html, | 213 const base::string16& html, |
| 212 const gfx::Rect rect); | 214 const gfx::Rect rect); |
| 213 | 215 |
| 214 bool OnTouchEvent(const ui::MotionEvent& event); | 216 bool OnTouchEvent(const ui::MotionEvent& event); |
| 217 bool OnTouchHandleEvent(const ui::MotionEvent& event); |
| 215 void ResetGestureDetection(); | 218 void ResetGestureDetection(); |
| 216 void SetDoubleTapSupportEnabled(bool enabled); | 219 void SetDoubleTapSupportEnabled(bool enabled); |
| 217 void SetMultiTouchZoomSupportEnabled(bool enabled); | 220 void SetMultiTouchZoomSupportEnabled(bool enabled); |
| 218 | 221 |
| 219 long GetNativeImeAdapter(); | 222 long GetNativeImeAdapter(); |
| 220 | 223 |
| 221 void WasResized(); | 224 void WasResized(); |
| 222 | 225 |
| 223 void GetScaledContentBitmap( | 226 void GetScaledContentBitmap( |
| 224 float scale, | 227 float scale, |
| 225 SkColorType color_type, | 228 SkColorType color_type, |
| 226 gfx::Rect src_subrect, | 229 gfx::Rect src_subrect, |
| 227 const base::Callback<void(bool, const SkBitmap&)>& result_callback); | 230 const base::Callback<void(bool, const SkBitmap&)>& result_callback); |
| 228 | 231 |
| 229 bool HasValidFrame() const; | 232 bool HasValidFrame() const; |
| 230 | 233 |
| 231 void MoveCaret(const gfx::Point& point); | 234 void MoveCaret(const gfx::Point& point); |
| 235 void HideTextHandles(); |
| 232 | 236 |
| 233 void SynchronousFrameMetadata( | 237 void SynchronousFrameMetadata( |
| 234 const cc::CompositorFrameMetadata& frame_metadata); | 238 const cc::CompositorFrameMetadata& frame_metadata); |
| 235 | 239 |
| 236 void SetOverlayVideoMode(bool enabled); | 240 void SetOverlayVideoMode(bool enabled); |
| 237 | 241 |
| 238 typedef base::Callback< | 242 typedef base::Callback< |
| 239 void(const base::string16& content, int start_offset, int end_offset)> | 243 void(const base::string16& content, int start_offset, int end_offset)> |
| 240 TextSurroundingSelectionCallback; | 244 TextSurroundingSelectionCallback; |
| 241 void SetTextSurroundingSelectionCallback( | 245 void SetTextSurroundingSelectionCallback( |
| 242 const TextSurroundingSelectionCallback& callback); | 246 const TextSurroundingSelectionCallback& callback); |
| 243 | 247 |
| 244 private: | 248 private: |
| 249 // TouchSelectionControllerClient implementation. |
| 250 virtual bool SupportsAnimation() const OVERRIDE; |
| 251 virtual void SetNeedsAnimate() OVERRIDE; |
| 252 virtual void MoveCaret(const gfx::PointF& position) OVERRIDE; |
| 253 virtual void SelectBetweenCoordinates(const gfx::PointF& start, |
| 254 const gfx::PointF& end) OVERRIDE; |
| 255 virtual void OnSelectionEvent(SelectionEventType event, |
| 256 const gfx::PointF& anchor_position) OVERRIDE; |
| 257 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() OVERRIDE; |
| 258 |
| 245 void RunAckCallbacks(); | 259 void RunAckCallbacks(); |
| 246 | 260 |
| 247 void DestroyDelegatedContent(); | 261 void DestroyDelegatedContent(); |
| 248 void SwapDelegatedFrame(uint32 output_surface_id, | 262 void SwapDelegatedFrame(uint32 output_surface_id, |
| 249 scoped_ptr<cc::DelegatedFrameData> frame_data); | 263 scoped_ptr<cc::DelegatedFrameData> frame_data); |
| 250 void SendDelegatedFrameAck(uint32 output_surface_id); | 264 void SendDelegatedFrameAck(uint32 output_surface_id); |
| 251 void SendReturnedDelegatedResources(uint32 output_surface_id); | 265 void SendReturnedDelegatedResources(uint32 output_surface_id); |
| 252 | 266 |
| 253 void OnFrameMetadataUpdated( | 267 void OnFrameMetadataUpdated( |
| 254 const cc::CompositorFrameMetadata& frame_metadata); | 268 const cc::CompositorFrameMetadata& frame_metadata); |
| 255 void ComputeContentsSize(const cc::CompositorFrameMetadata& frame_metadata); | 269 void ComputeContentsSize(const cc::CompositorFrameMetadata& frame_metadata); |
| 256 void ResetClipping(); | |
| 257 void ClipContents(const gfx::Rect& clipping, const gfx::Size& content_size); | |
| 258 | 270 |
| 259 void AttachLayers(); | 271 void AttachLayers(); |
| 260 void RemoveLayers(); | 272 void RemoveLayers(); |
| 261 | 273 |
| 262 // Called after async screenshot task completes. Scales and crops the result | 274 // Called after async screenshot task completes. Scales and crops the result |
| 263 // of the copy. | 275 // of the copy. |
| 264 static void PrepareTextureCopyOutputResult( | 276 static void PrepareTextureCopyOutputResult( |
| 265 const gfx::Size& dst_size_in_pixel, | 277 const gfx::Size& dst_size_in_pixel, |
| 266 const SkColorType color_type, | 278 const SkColorType color_type, |
| 267 const base::TimeTicks& start_time, | 279 const base::TimeTicks& start_time, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 290 void ReleaseLocksOnSurface(); | 302 void ReleaseLocksOnSurface(); |
| 291 | 303 |
| 292 // 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 |
| 293 // current frame. | 305 // current frame. |
| 294 void RetainFrame(uint32 output_surface_id, | 306 void RetainFrame(uint32 output_surface_id, |
| 295 scoped_ptr<cc::CompositorFrame> frame); | 307 scoped_ptr<cc::CompositorFrame> frame); |
| 296 | 308 |
| 297 void InternalSwapCompositorFrame(uint32 output_surface_id, | 309 void InternalSwapCompositorFrame(uint32 output_surface_id, |
| 298 scoped_ptr<cc::CompositorFrame> frame); | 310 scoped_ptr<cc::CompositorFrame> frame); |
| 299 | 311 |
| 300 void SetNeedsAnimate(); | |
| 301 bool Animate(base::TimeTicks frame_time); | 312 bool Animate(base::TimeTicks frame_time); |
| 302 | 313 |
| 314 void OnContentScrollingChange(); |
| 315 bool IsContentScrolling() const; |
| 316 |
| 317 float GetDpiScale() const; |
| 318 |
| 303 // The model object. | 319 // The model object. |
| 304 RenderWidgetHostImpl* host_; | 320 RenderWidgetHostImpl* host_; |
| 305 | 321 |
| 306 // Used to track whether this render widget needs a BeginFrame. | 322 // Used to track whether this render widget needs a BeginFrame. |
| 307 bool needs_begin_frame_; | 323 bool needs_begin_frame_; |
| 308 | 324 |
| 309 bool is_showing_; | 325 bool is_showing_; |
| 310 | 326 |
| 311 // ContentViewCoreImpl is our interface to the view system. | 327 // ContentViewCoreImpl is our interface to the view system. |
| 312 ContentViewCoreImpl* content_view_core_; | 328 ContentViewCoreImpl* content_view_core_; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 341 // Note: |overscroll_effect_| will never be NULL, even if it's never enabled. | 357 // Note: |overscroll_effect_| will never be NULL, even if it's never enabled. |
| 342 scoped_ptr<OverscrollGlow> overscroll_effect_; | 358 scoped_ptr<OverscrollGlow> overscroll_effect_; |
| 343 | 359 |
| 344 // Provides gesture synthesis given a stream of touch events (derived from | 360 // Provides gesture synthesis given a stream of touch events (derived from |
| 345 // Android MotionEvent's) and touch event acks. | 361 // Android MotionEvent's) and touch event acks. |
| 346 ui::FilteredGestureProvider gesture_provider_; | 362 ui::FilteredGestureProvider gesture_provider_; |
| 347 | 363 |
| 348 // Handles gesture based text selection | 364 // Handles gesture based text selection |
| 349 GestureTextSelector gesture_text_selector_; | 365 GestureTextSelector gesture_text_selector_; |
| 350 | 366 |
| 367 // Manages selection handle rendering and manipulation. |
| 368 // This will always be NULL if |content_view_core_| is NULL. |
| 369 scoped_ptr<TouchSelectionController> selection_controller_; |
| 370 bool touch_scrolling_; |
| 371 size_t potentially_active_fling_count_; |
| 372 |
| 351 bool flush_input_requested_; | 373 bool flush_input_requested_; |
| 352 | 374 |
| 353 int accelerated_surface_route_id_; | 375 int accelerated_surface_route_id_; |
| 354 | 376 |
| 355 // Size to use if we have no backing ContentViewCore | 377 // Size to use if we have no backing ContentViewCore |
| 356 gfx::Size default_size_; | 378 gfx::Size default_size_; |
| 357 | 379 |
| 358 const bool using_synchronous_compositor_; | 380 const bool using_synchronous_compositor_; |
| 359 | 381 |
| 360 scoped_ptr<DelegatedFrameEvictor> frame_evictor_; | 382 scoped_ptr<DelegatedFrameEvictor> frame_evictor_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 373 scoped_ptr<LastFrameInfo> last_frame_info_; | 395 scoped_ptr<LastFrameInfo> last_frame_info_; |
| 374 | 396 |
| 375 TextSurroundingSelectionCallback text_surrounding_selection_callback_; | 397 TextSurroundingSelectionCallback text_surrounding_selection_callback_; |
| 376 | 398 |
| 377 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAndroid); | 399 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAndroid); |
| 378 }; | 400 }; |
| 379 | 401 |
| 380 } // namespace content | 402 } // namespace content |
| 381 | 403 |
| 382 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_ | 404 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_ |
| OLD | NEW |