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

Side by Side Diff: content/browser/android/content_view_core_impl.h

Issue 120513005: [Android] Perform eager gesture recognition on MotionEvents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More testing Created 6 years, 10 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
« no previous file with comments | « build/android/lint/suppressions.xml ('k') | content/browser/android/content_view_core_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ 5 #ifndef CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_
6 #define CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ 6 #define CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
11 #include "base/android/jni_helper.h" 11 #include "base/android/jni_helper.h"
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/i18n/rtl.h" 14 #include "base/i18n/rtl.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/process/process.h" 16 #include "base/process/process.h"
17 #include "content/browser/renderer_host/input/gesture_event_queue.h"
17 #include "content/browser/renderer_host/render_widget_host_view_android.h" 18 #include "content/browser/renderer_host/render_widget_host_view_android.h"
18 #include "content/browser/web_contents/web_contents_impl.h" 19 #include "content/browser/web_contents/web_contents_impl.h"
19 #include "content/public/browser/android/content_view_core.h" 20 #include "content/public/browser/android/content_view_core.h"
20 #include "content/public/browser/notification_observer.h" 21 #include "content/public/browser/notification_observer.h"
21 #include "content/public/browser/notification_registrar.h" 22 #include "content/public/browser/notification_registrar.h"
22 #include "content/public/browser/web_contents_observer.h" 23 #include "content/public/browser/web_contents_observer.h"
23 #include "third_party/WebKit/public/web/WebInputEvent.h" 24 #include "third_party/WebKit/public/web/WebInputEvent.h"
24 #include "ui/gfx/rect.h" 25 #include "ui/gfx/rect.h"
25 #include "ui/gfx/rect_f.h" 26 #include "ui/gfx/rect_f.h"
26 #include "url/gurl.h" 27 #include "url/gurl.h"
27 28
28 namespace ui { 29 namespace ui {
29 class ViewAndroid; 30 class ViewAndroid;
30 class WindowAndroid; 31 class WindowAndroid;
31 } 32 }
32 33
33 namespace content { 34 namespace content {
34 class RenderWidgetHostViewAndroid; 35 class RenderWidgetHostViewAndroid;
35 struct MenuItem; 36 struct MenuItem;
36 37
37 // TODO(jrg): this is a shell. Upstream the rest. 38 // TODO(jrg): this is a shell. Upstream the rest.
38 class ContentViewCoreImpl : public ContentViewCore, 39 class ContentViewCoreImpl : public ContentViewCore,
39 public NotificationObserver, 40 public NotificationObserver,
40 public WebContentsObserver { 41 public WebContentsObserver,
42 public GestureEventQueueClient {
41 public: 43 public:
42 static ContentViewCoreImpl* FromWebContents(WebContents* web_contents); 44 static ContentViewCoreImpl* FromWebContents(WebContents* web_contents);
43 ContentViewCoreImpl(JNIEnv* env, 45 ContentViewCoreImpl(JNIEnv* env,
44 jobject obj, 46 jobject obj,
45 WebContents* web_contents, 47 WebContents* web_contents,
46 ui::ViewAndroid* view_android, 48 ui::ViewAndroid* view_android,
47 ui::WindowAndroid* window_android); 49 ui::WindowAndroid* window_android);
48 50
49 // ContentViewCore implementation. 51 // ContentViewCore implementation.
50 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaObject() OVERRIDE; 52 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaObject() OVERRIDE;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 jstring extra_headers, 89 jstring extra_headers,
88 jbyteArray post_data, 90 jbyteArray post_data,
89 jstring base_url_for_data_url, 91 jstring base_url_for_data_url,
90 jstring virtual_url_for_data_url, 92 jstring virtual_url_for_data_url,
91 jboolean can_load_local_resources); 93 jboolean can_load_local_resources);
92 base::android::ScopedJavaLocalRef<jstring> GetURL(JNIEnv* env, jobject) const; 94 base::android::ScopedJavaLocalRef<jstring> GetURL(JNIEnv* env, jobject) const;
93 base::android::ScopedJavaLocalRef<jstring> GetTitle( 95 base::android::ScopedJavaLocalRef<jstring> GetTitle(
94 JNIEnv* env, jobject obj) const; 96 JNIEnv* env, jobject obj) const;
95 jboolean IsIncognito(JNIEnv* env, jobject obj); 97 jboolean IsIncognito(JNIEnv* env, jobject obj);
96 void SendOrientationChangeEvent(JNIEnv* env, jobject obj, jint orientation); 98 void SendOrientationChangeEvent(JNIEnv* env, jobject obj, jint orientation);
97 jboolean SendTouchEvent(JNIEnv* env, 99 void OnTouchEventHandlingBegin(JNIEnv* env,
98 jobject obj, 100 jobject obj,
99 jlong time_ms, 101 jlong time_ms,
100 jint type, 102 jint type,
101 jobjectArray pts); 103 jobjectArray pts);
104 void OnTouchEventHandlingEnd(JNIEnv* env, jobject obj);
102 jboolean SendMouseMoveEvent(JNIEnv* env, 105 jboolean SendMouseMoveEvent(JNIEnv* env,
103 jobject obj, 106 jobject obj,
104 jlong time_ms, 107 jlong time_ms,
105 jfloat x, 108 jfloat x,
106 jfloat y); 109 jfloat y);
107 jboolean SendMouseWheelEvent(JNIEnv* env, 110 jboolean SendMouseWheelEvent(JNIEnv* env,
108 jobject obj, 111 jobject obj,
109 jlong time_ms, 112 jlong time_ms,
110 jfloat x, 113 jfloat x,
111 jfloat y, 114 jfloat y,
112 jfloat vertical_axis); 115 jfloat vertical_axis);
113 void ScrollBegin(JNIEnv* env, jobject obj, jlong time_ms, 116 void ScrollBegin(JNIEnv* env, jobject obj, jlong time_ms,
114 jfloat x, jfloat y, jfloat hintx, jfloat hinty); 117 jfloat x, jfloat y, jfloat hintx, jfloat hinty);
115 void ScrollEnd(JNIEnv* env, jobject obj, jlong time_ms); 118 void ScrollEnd(JNIEnv* env, jobject obj, jlong time_ms);
116 void ScrollBy(JNIEnv* env, jobject obj, jlong time_ms, 119 void ScrollBy(JNIEnv* env, jobject obj, jlong time_ms,
117 jfloat x, jfloat y, jfloat dx, jfloat dy); 120 jfloat x, jfloat y, jfloat dx, jfloat dy);
118 void FlingStart(JNIEnv* env, jobject obj, jlong time_ms, 121 void FlingStart(JNIEnv* env, jobject obj, jlong time_ms,
119 jfloat x, jfloat y, jfloat vx, jfloat vy); 122 jfloat x, jfloat y, jfloat vx, jfloat vy);
120 void FlingCancel(JNIEnv* env, jobject obj, jlong time_ms); 123 void FlingCancel(JNIEnv* env, jobject obj, jlong time_ms);
121 void SingleTap(JNIEnv* env, jobject obj, jlong time_ms, 124 void SingleTap(JNIEnv* env, jobject obj, jlong time_ms,
122 jfloat x, jfloat y, 125 jfloat x, jfloat y,
123 jboolean disambiguation_popup_tap); 126 jboolean disambiguation_popup_tap);
124 void SingleTapUnconfirmed(JNIEnv* env, jobject obj, jlong time_ms, 127 void SingleTapUnconfirmed(JNIEnv* env, jobject obj, jlong time_ms,
125 jfloat x, jfloat y); 128 jfloat x, jfloat y);
126 void ShowPressState(JNIEnv* env, jobject obj, jlong time_ms, 129 void ShowPress(JNIEnv* env, jobject obj, jlong time_ms,
127 jfloat x, jfloat y); 130 jfloat x, jfloat y);
128 void TapCancel(JNIEnv* env, jobject obj, jlong time_ms, 131 void TapCancel(JNIEnv* env, jobject obj, jlong time_ms,
129 jfloat x, jfloat y); 132 jfloat x, jfloat y);
130 void TapDown(JNIEnv* env, jobject obj, jlong time_ms, 133 void TapDown(JNIEnv* env, jobject obj, jlong time_ms,
131 jfloat x, jfloat y); 134 jfloat x, jfloat y);
132 void DoubleTap(JNIEnv* env, jobject obj, jlong time_ms, 135 void DoubleTap(JNIEnv* env, jobject obj, jlong time_ms,
133 jfloat x, jfloat y) ; 136 jfloat x, jfloat y) ;
134 void LongPress(JNIEnv* env, jobject obj, jlong time_ms, 137 void LongPress(JNIEnv* env, jobject obj, jlong time_ms,
135 jfloat x, jfloat y, 138 jfloat x, jfloat y,
136 jboolean disambiguation_popup_tap); 139 jboolean disambiguation_popup_tap);
137 void LongTap(JNIEnv* env, jobject obj, jlong time_ms, 140 void LongTap(JNIEnv* env, jobject obj, jlong time_ms,
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 void UpdateImeAdapter(int native_ime_adapter, int text_input_type, 265 void UpdateImeAdapter(int native_ime_adapter, int text_input_type,
263 const std::string& text, 266 const std::string& text,
264 int selection_start, int selection_end, 267 int selection_start, int selection_end,
265 int composition_start, int composition_end, 268 int composition_start, int composition_end,
266 bool show_ime_if_needed, bool require_ack); 269 bool show_ime_if_needed, bool require_ack);
267 void SetTitle(const base::string16& title); 270 void SetTitle(const base::string16& title);
268 void OnBackgroundColorChanged(SkColor color); 271 void OnBackgroundColorChanged(SkColor color);
269 272
270 bool HasFocus(); 273 bool HasFocus();
271 void ConfirmTouchEvent(InputEventAckState ack_result); 274 void ConfirmTouchEvent(InputEventAckState ack_result);
272 void OnFlingStartEventAck(InputEventAckState ack_result); 275 void OnGestureEventAck(const blink::WebGestureEvent& event,
273 void OnScrollBeginEventAck(); 276 InputEventAckState ack_result);
274 void OnScrollUpdateGestureConsumed(); 277 bool FilterInputEvent(const blink::WebInputEvent& event);
275 void OnScrollEndEventAck();
276 void HasTouchEventHandlers(bool need_touch_events);
277 void OnSelectionChanged(const std::string& text); 278 void OnSelectionChanged(const std::string& text);
278 void OnSelectionBoundsChanged( 279 void OnSelectionBoundsChanged(
279 const ViewHostMsg_SelectionBounds_Params& params); 280 const ViewHostMsg_SelectionBounds_Params& params);
280 281
281 void StartContentIntent(const GURL& content_url); 282 void StartContentIntent(const GURL& content_url);
282 283
283 // Shows the disambiguation popup 284 // Shows the disambiguation popup
284 // |target_rect| --> window coordinates which |zoomed_bitmap| represents 285 // |target_rect| --> window coordinates which |zoomed_bitmap| represents
285 // |zoomed_bitmap| --> magnified image of potential touch targets 286 // |zoomed_bitmap| --> magnified image of potential touch targets
286 void ShowDisambiguationPopup( 287 void ShowDisambiguationPopup(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 330
330 // NotificationObserver implementation. 331 // NotificationObserver implementation.
331 virtual void Observe(int type, 332 virtual void Observe(int type,
332 const NotificationSource& source, 333 const NotificationSource& source,
333 const NotificationDetails& details) OVERRIDE; 334 const NotificationDetails& details) OVERRIDE;
334 335
335 // WebContentsObserver implementation. 336 // WebContentsObserver implementation.
336 virtual void RenderViewReady() OVERRIDE; 337 virtual void RenderViewReady() OVERRIDE;
337 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE; 338 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE;
338 339
340 // GestureEventQueueClient implementation.
341 virtual void ForwardGestureEvent(
342 const blink::WebGestureEvent& event) OVERRIDE;
343
339 // -------------------------------------------------------------------------- 344 // --------------------------------------------------------------------------
340 // Other private methods and data 345 // Other private methods and data
341 // -------------------------------------------------------------------------- 346 // --------------------------------------------------------------------------
342 347
343 void InitWebContents(); 348 void InitWebContents();
344 349
345 RenderWidgetHostViewAndroid* GetRenderWidgetHostViewAndroid(); 350 RenderWidgetHostViewAndroid* GetRenderWidgetHostViewAndroid();
346 351
347 float GetTouchPaddingDip(); 352 float GetTouchPaddingDip();
348 353
349 blink::WebGestureEvent MakeGestureEvent( 354 blink::WebGestureEvent MakeGestureEvent(
350 blink::WebInputEvent::Type type, int64 time_ms, float x, float y) const; 355 blink::WebInputEvent::Type type, int64 time_ms, float x, float y) const;
351 356
352 void SendBeginFrame(base::TimeTicks frame_time); 357 void SendBeginFrame(base::TimeTicks frame_time);
353 358
354 gfx::Size GetViewportSizePix() const; 359 gfx::Size GetViewportSizePix() const;
355 gfx::Size GetViewportSizeOffsetPix() const; 360 gfx::Size GetViewportSizeOffsetPix() const;
356 361
357 void DeleteScaledSnapshotTexture(); 362 void DeleteScaledSnapshotTexture();
358 363
359 void SendGestureEvent(const blink::WebGestureEvent& event); 364 void SendGestureEvent(const blink::WebGestureEvent& event);
365 void SendSyntheticGestureEvent(const blink::WebGestureEvent& event);
360 366
361 // Update focus state of the RenderWidgetHostView. 367 // Update focus state of the RenderWidgetHostView.
362 void SetFocusInternal(bool focused); 368 void SetFocusInternal(bool focused);
363 369
364 // Send device_orientation_ to renderer. 370 // Send device_orientation_ to renderer.
365 void SendOrientationChangeEventInternal(); 371 void SendOrientationChangeEventInternal();
366 372
367 // A weak reference to the Java ContentViewCore object. 373 // A weak reference to the Java ContentViewCore object.
368 JavaObjectWeakGlobalRef java_ref_; 374 JavaObjectWeakGlobalRef java_ref_;
369 375
(...skipping 19 matching lines...) Expand all
389 395
390 // The owning window that has a hold of main application activity. 396 // The owning window that has a hold of main application activity.
391 ui::WindowAndroid* window_android_; 397 ui::WindowAndroid* window_android_;
392 398
393 // The cache of device's current orientation set from Java side, this value 399 // The cache of device's current orientation set from Java side, this value
394 // will be sent to Renderer once it is ready. 400 // will be sent to Renderer once it is ready.
395 int device_orientation_; 401 int device_orientation_;
396 402
397 bool geolocation_needs_pause_; 403 bool geolocation_needs_pause_;
398 404
405 GestureEventQueue gesture_event_queue_;
406 bool handling_touch_event_;
407 blink::WebTouchEvent pending_touch_event_;
408 GestureEventPacket pending_gesture_packet_;
409
399 DISALLOW_COPY_AND_ASSIGN(ContentViewCoreImpl); 410 DISALLOW_COPY_AND_ASSIGN(ContentViewCoreImpl);
400 }; 411 };
401 412
402 bool RegisterContentViewCore(JNIEnv* env); 413 bool RegisterContentViewCore(JNIEnv* env);
403 414
404 } // namespace content 415 } // namespace content
405 416
406 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ 417 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_
OLDNEW
« no previous file with comments | « build/android/lint/suppressions.xml ('k') | content/browser/android/content_view_core_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698