Chromium Code Reviews| 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 #include "content/browser/android/content_view_core_impl.h" | 5 #include "content/browser/android/content_view_core_impl.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj, | 144 ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj, |
| 145 bool hardware_accelerated, | 145 bool hardware_accelerated, |
| 146 bool input_events_delivered_at_vsync, | 146 bool input_events_delivered_at_vsync, |
| 147 WebContents* web_contents, | 147 WebContents* web_contents, |
| 148 ui::WindowAndroid* window_android) | 148 ui::WindowAndroid* window_android) |
| 149 : java_ref_(env, obj), | 149 : java_ref_(env, obj), |
| 150 web_contents_(static_cast<WebContentsImpl*>(web_contents)), | 150 web_contents_(static_cast<WebContentsImpl*>(web_contents)), |
| 151 root_layer_(cc::Layer::create()), | 151 root_layer_(cc::Layer::create()), |
| 152 tab_crashed_(false), | 152 tab_crashed_(false), |
| 153 input_events_delivered_at_vsync_(input_events_delivered_at_vsync), | 153 input_events_delivered_at_vsync_(input_events_delivered_at_vsync), |
| 154 has_touch_event_handlers_(false), | |
| 154 renderer_frame_pending_(false), | 155 renderer_frame_pending_(false), |
| 155 window_android_(window_android) { | 156 window_android_(window_android) { |
| 156 CHECK(web_contents) << | 157 CHECK(web_contents) << |
| 157 "A ContentViewCoreImpl should be created with a valid WebContents."; | 158 "A ContentViewCoreImpl should be created with a valid WebContents."; |
| 158 | 159 |
| 159 // When a tab is restored (from a saved state), it does not have a renderer | 160 // When a tab is restored (from a saved state), it does not have a renderer |
| 160 // process. We treat it like the tab is crashed. If the content is loaded | 161 // process. We treat it like the tab is crashed. If the content is loaded |
| 161 // when the tab is shown, tab_crashed_ will be reset. Since | 162 // when the tab is shown, tab_crashed_ will be reset. Since |
| 162 // RenderWidgetHostView is associated with the lifetime of the renderer | 163 // RenderWidgetHostView is associated with the lifetime of the renderer |
| 163 // process, we use it to test whether there is a renderer process. | 164 // process, we use it to test whether there is a renderer process. |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 491 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 492 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
| 492 if (j_obj.is_null()) | 493 if (j_obj.is_null()) |
| 493 return; | 494 return; |
| 494 Java_ContentViewCore_confirmTouchEvent(env, j_obj.obj(), | 495 Java_ContentViewCore_confirmTouchEvent(env, j_obj.obj(), |
| 495 static_cast<jint>(ack_result)); | 496 static_cast<jint>(ack_result)); |
| 496 } | 497 } |
| 497 | 498 |
| 498 void ContentViewCoreImpl::HasTouchEventHandlers(bool need_touch_events) { | 499 void ContentViewCoreImpl::HasTouchEventHandlers(bool need_touch_events) { |
| 499 JNIEnv* env = AttachCurrentThread(); | 500 JNIEnv* env = AttachCurrentThread(); |
| 500 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 501 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
| 502 has_touch_event_handlers_ = need_touch_events; | |
| 501 if (j_obj.is_null()) | 503 if (j_obj.is_null()) |
| 502 return; | 504 return; |
| 503 Java_ContentViewCore_hasTouchEventHandlers(env, | 505 Java_ContentViewCore_hasTouchEventHandlers(env, |
| 504 j_obj.obj(), | 506 j_obj.obj(), |
| 505 need_touch_events); | 507 need_touch_events); |
| 506 } | 508 } |
| 507 | 509 |
| 508 bool ContentViewCoreImpl::HasFocus() { | 510 bool ContentViewCoreImpl::HasFocus() { |
| 509 JNIEnv* env = AttachCurrentThread(); | 511 JNIEnv* env = AttachCurrentThread(); |
| 510 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 512 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 859 event.x = x / DpiScale(); | 861 event.x = x / DpiScale(); |
| 860 event.y = y / DpiScale(); | 862 event.y = y / DpiScale(); |
| 861 event.timeStampSeconds = time_ms / 1000.0; | 863 event.timeStampSeconds = time_ms / 1000.0; |
| 862 event.sourceDevice = WebGestureEvent::Touchscreen; | 864 event.sourceDevice = WebGestureEvent::Touchscreen; |
| 863 UpdateVSyncFlagOnInputEvent(&event); | 865 UpdateVSyncFlagOnInputEvent(&event); |
| 864 return event; | 866 return event; |
| 865 } | 867 } |
| 866 | 868 |
| 867 void ContentViewCoreImpl::UpdateVSyncFlagOnInputEvent( | 869 void ContentViewCoreImpl::UpdateVSyncFlagOnInputEvent( |
| 868 WebKit::WebInputEvent* event) const { | 870 WebKit::WebInputEvent* event) const { |
| 869 if (!input_events_delivered_at_vsync_) | 871 if (!input_events_delivered_at_vsync_ || has_touch_event_handlers_) |
| 870 return; | 872 return; |
| 871 if (event->type == WebInputEvent::GestureScrollUpdate || | 873 if (event->type == WebInputEvent::GestureScrollUpdate || |
| 872 event->type == WebInputEvent::GesturePinchUpdate || | 874 event->type == WebInputEvent::GesturePinchUpdate) |
| 873 event->type == WebInputEvent::TouchMove) | |
|
jamesr
2013/01/16 04:13:26
whaaaa? why was this here?
actually, this whole f
Sami
2013/01/16 10:49:15
From Android's point of view input events are alwa
| |
| 874 event->modifiers |= WebInputEvent::IsLastInputEventForCurrentVSync; | 875 event->modifiers |= WebInputEvent::IsLastInputEventForCurrentVSync; |
| 875 } | 876 } |
| 876 | 877 |
| 877 void ContentViewCoreImpl::ScrollBegin(JNIEnv* env, jobject obj, jlong time_ms, | 878 void ContentViewCoreImpl::ScrollBegin(JNIEnv* env, jobject obj, jlong time_ms, |
| 878 jint x, jint y) { | 879 jint x, jint y) { |
| 879 WebGestureEvent event = MakeGestureEvent( | 880 WebGestureEvent event = MakeGestureEvent( |
| 880 WebInputEvent::GestureScrollBegin, time_ms, x, y); | 881 WebInputEvent::GestureScrollBegin, time_ms, x, y); |
| 881 if (GetRenderWidgetHostViewAndroid()) | 882 if (GetRenderWidgetHostViewAndroid()) |
| 882 GetRenderWidgetHostViewAndroid()->SendGestureEvent(event); | 883 GetRenderWidgetHostViewAndroid()->SendGestureEvent(event); |
| 883 } | 884 } |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1372 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { | 1373 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { |
| 1373 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; | 1374 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; |
| 1374 return false; | 1375 return false; |
| 1375 } | 1376 } |
| 1376 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); | 1377 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); |
| 1377 | 1378 |
| 1378 return RegisterNativesImpl(env) >= 0; | 1379 return RegisterNativesImpl(env) >= 0; |
| 1379 } | 1380 } |
| 1380 | 1381 |
| 1381 } // namespace content | 1382 } // namespace content |
| OLD | NEW |