Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_android.h

Issue 335943002: [Android] Composited selection handle rendering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@input_native_handles_final
Patch Set: Tweaks to dragging and visibility Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 void SendMouseWheelEvent(const blink::WebMouseWheelEvent& event); 205 void SendMouseWheelEvent(const blink::WebMouseWheelEvent& event);
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& result, 211 void OnSmartClipDataExtracted(const base::string16& result,
210 const gfx::Rect rect); 212 const gfx::Rect rect);
211 213
212 bool OnTouchEvent(const ui::MotionEvent& event); 214 bool OnTouchEvent(const ui::MotionEvent& event);
215 bool OnTouchHandleEvent(const ui::MotionEvent& event);
213 void ResetGestureDetection(); 216 void ResetGestureDetection();
214 void SetDoubleTapSupportEnabled(bool enabled); 217 void SetDoubleTapSupportEnabled(bool enabled);
215 void SetMultiTouchZoomSupportEnabled(bool enabled); 218 void SetMultiTouchZoomSupportEnabled(bool enabled);
216 219
217 long GetNativeImeAdapter(); 220 long GetNativeImeAdapter();
218 221
219 void WasResized(); 222 void WasResized();
220 223
221 void GetScaledContentBitmap( 224 void GetScaledContentBitmap(
222 float scale, 225 float scale,
223 SkColorType color_type, 226 SkColorType color_type,
224 gfx::Rect src_subrect, 227 gfx::Rect src_subrect,
225 const base::Callback<void(bool, const SkBitmap&)>& result_callback); 228 const base::Callback<void(bool, const SkBitmap&)>& result_callback);
226 229
227 bool HasValidFrame() const; 230 bool HasValidFrame() const;
228 231
229 void MoveCaret(const gfx::Point& point); 232 void MoveCaret(const gfx::Point& point);
233 void HideTextHandles();
230 234
231 void SynchronousFrameMetadata( 235 void SynchronousFrameMetadata(
232 const cc::CompositorFrameMetadata& frame_metadata); 236 const cc::CompositorFrameMetadata& frame_metadata);
233 237
234 void SetOverlayVideoMode(bool enabled); 238 void SetOverlayVideoMode(bool enabled);
235 239
236 typedef base::Callback< 240 typedef base::Callback<
237 void(const base::string16& content, int start_offset, int end_offset)> 241 void(const base::string16& content, int start_offset, int end_offset)>
238 TextSurroundingSelectionCallback; 242 TextSurroundingSelectionCallback;
239 void SetTextSurroundingSelectionCallback( 243 void SetTextSurroundingSelectionCallback(
240 const TextSurroundingSelectionCallback& callback); 244 const TextSurroundingSelectionCallback& callback);
241 245
242 private: 246 private:
247 // TouchSelectionControllerClient implementation.
248 virtual bool SupportsAnimation() const OVERRIDE;
249 virtual void SetNeedsAnimate() OVERRIDE;
250 virtual void MoveCaret(const gfx::PointF& position) OVERRIDE;
251 virtual void SelectBetweenCoordinates(const gfx::PointF& start,
252 const gfx::PointF& end) OVERRIDE;
253 virtual void OnSelectionEvent(SelectionEventType event,
254 const gfx::PointF& anchor_position) OVERRIDE;
255 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() OVERRIDE;
256
243 void RunAckCallbacks(); 257 void RunAckCallbacks();
244 258
245 void DestroyDelegatedContent(); 259 void DestroyDelegatedContent();
246 void SwapDelegatedFrame(uint32 output_surface_id, 260 void SwapDelegatedFrame(uint32 output_surface_id,
247 scoped_ptr<cc::DelegatedFrameData> frame_data); 261 scoped_ptr<cc::DelegatedFrameData> frame_data);
248 void SendDelegatedFrameAck(uint32 output_surface_id); 262 void SendDelegatedFrameAck(uint32 output_surface_id);
249 void SendReturnedDelegatedResources(uint32 output_surface_id); 263 void SendReturnedDelegatedResources(uint32 output_surface_id);
250 264
251 void OnFrameMetadataUpdated( 265 void OnFrameMetadataUpdated(
252 const cc::CompositorFrameMetadata& frame_metadata); 266 const cc::CompositorFrameMetadata& frame_metadata);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 void ReleaseLocksOnSurface(); 301 void ReleaseLocksOnSurface();
288 302
289 // Drop any incoming frames from the renderer when there are locks on the 303 // Drop any incoming frames from the renderer when there are locks on the
290 // current frame. 304 // current frame.
291 void RetainFrame(uint32 output_surface_id, 305 void RetainFrame(uint32 output_surface_id,
292 scoped_ptr<cc::CompositorFrame> frame); 306 scoped_ptr<cc::CompositorFrame> frame);
293 307
294 void InternalSwapCompositorFrame(uint32 output_surface_id, 308 void InternalSwapCompositorFrame(uint32 output_surface_id,
295 scoped_ptr<cc::CompositorFrame> frame); 309 scoped_ptr<cc::CompositorFrame> frame);
296 310
297 void SetNeedsAnimate();
298 bool Animate(base::TimeTicks frame_time); 311 bool Animate(base::TimeTicks frame_time);
299 312
313 float GetDpiScale() const;
314
300 // The model object. 315 // The model object.
301 RenderWidgetHostImpl* host_; 316 RenderWidgetHostImpl* host_;
302 317
303 // Used to track whether this render widget needs a BeginFrame. 318 // Used to track whether this render widget needs a BeginFrame.
304 bool needs_begin_frame_; 319 bool needs_begin_frame_;
305 320
306 bool is_showing_; 321 bool is_showing_;
307 322
308 // ContentViewCoreImpl is our interface to the view system. 323 // ContentViewCoreImpl is our interface to the view system.
309 ContentViewCoreImpl* content_view_core_; 324 ContentViewCoreImpl* content_view_core_;
(...skipping 28 matching lines...) Expand all
338 // Note: |overscroll_effect_| will never be NULL, even if it's never enabled. 353 // Note: |overscroll_effect_| will never be NULL, even if it's never enabled.
339 scoped_ptr<OverscrollGlow> overscroll_effect_; 354 scoped_ptr<OverscrollGlow> overscroll_effect_;
340 355
341 // Provides gesture synthesis given a stream of touch events (derived from 356 // Provides gesture synthesis given a stream of touch events (derived from
342 // Android MotionEvent's) and touch event acks. 357 // Android MotionEvent's) and touch event acks.
343 ui::FilteredGestureProvider gesture_provider_; 358 ui::FilteredGestureProvider gesture_provider_;
344 359
345 // Handles gesture based text selection 360 // Handles gesture based text selection
346 GestureTextSelector gesture_text_selector_; 361 GestureTextSelector gesture_text_selector_;
347 362
363 // Manages selection handle rendering and manipulation.
364 // This will always be NULL if |content_view_core_| is NULL.
365 scoped_ptr<TouchSelectionController> selection_controller_;
366
348 bool flush_input_requested_; 367 bool flush_input_requested_;
349 368
350 int accelerated_surface_route_id_; 369 int accelerated_surface_route_id_;
351 370
352 // Size to use if we have no backing ContentViewCore 371 // Size to use if we have no backing ContentViewCore
353 gfx::Size default_size_; 372 gfx::Size default_size_;
354 373
355 // Cached selection bounds to avoid redundant selection handle updates.
356 cc::ViewportSelectionBound cached_selection_start_;
357 cc::ViewportSelectionBound cached_selection_end_;
358
359 const bool using_synchronous_compositor_; 374 const bool using_synchronous_compositor_;
360 375
361 scoped_ptr<DelegatedFrameEvictor> frame_evictor_; 376 scoped_ptr<DelegatedFrameEvictor> frame_evictor_;
362 377
363 size_t locks_on_frame_count_; 378 size_t locks_on_frame_count_;
364 bool observing_root_window_; 379 bool observing_root_window_;
365 380
366 struct LastFrameInfo { 381 struct LastFrameInfo {
367 LastFrameInfo(uint32 output_id, 382 LastFrameInfo(uint32 output_id,
368 scoped_ptr<cc::CompositorFrame> output_frame); 383 scoped_ptr<cc::CompositorFrame> output_frame);
369 ~LastFrameInfo(); 384 ~LastFrameInfo();
370 uint32 output_surface_id; 385 uint32 output_surface_id;
371 scoped_ptr<cc::CompositorFrame> frame; 386 scoped_ptr<cc::CompositorFrame> frame;
372 }; 387 };
373 388
374 scoped_ptr<LastFrameInfo> last_frame_info_; 389 scoped_ptr<LastFrameInfo> last_frame_info_;
375 390
376 TextSurroundingSelectionCallback text_surrounding_selection_callback_; 391 TextSurroundingSelectionCallback text_surrounding_selection_callback_;
377 392
378 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAndroid); 393 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAndroid);
379 }; 394 };
380 395
381 } // namespace content 396 } // namespace content
382 397
383 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_ 398 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698