Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 #include "content/public/common/content_client.h" | 51 #include "content/public/common/content_client.h" |
| 52 #include "content/public/common/content_switches.h" | 52 #include "content/public/common/content_switches.h" |
| 53 #include "content/public/common/menu_item.h" | 53 #include "content/public/common/menu_item.h" |
| 54 #include "content/public/common/page_transition_types.h" | 54 #include "content/public/common/page_transition_types.h" |
| 55 #include "content/public/common/user_agent.h" | 55 #include "content/public/common/user_agent.h" |
| 56 #include "jni/ContentViewCore_jni.h" | 56 #include "jni/ContentViewCore_jni.h" |
| 57 #include "third_party/WebKit/public/web/WebBindings.h" | 57 #include "third_party/WebKit/public/web/WebBindings.h" |
| 58 #include "third_party/WebKit/public/web/WebInputEvent.h" | 58 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 59 #include "ui/base/android/view_android.h" | 59 #include "ui/base/android/view_android.h" |
| 60 #include "ui/base/android/window_android.h" | 60 #include "ui/base/android/window_android.h" |
| 61 #include "ui/events/gesture_detection/motion_event.h" | |
| 61 #include "ui/gfx/android/java_bitmap.h" | 62 #include "ui/gfx/android/java_bitmap.h" |
| 62 #include "ui/gfx/screen.h" | 63 #include "ui/gfx/screen.h" |
| 63 #include "ui/gfx/size_conversions.h" | 64 #include "ui/gfx/size_conversions.h" |
| 64 #include "ui/gfx/size_f.h" | 65 #include "ui/gfx/size_f.h" |
| 65 | 66 |
| 66 using base::android::AttachCurrentThread; | 67 using base::android::AttachCurrentThread; |
| 67 using base::android::ConvertJavaStringToUTF16; | 68 using base::android::ConvertJavaStringToUTF16; |
| 68 using base::android::ConvertJavaStringToUTF8; | 69 using base::android::ConvertJavaStringToUTF8; |
| 69 using base::android::ConvertUTF16ToJavaString; | 70 using base::android::ConvertUTF16ToJavaString; |
| 70 using base::android::ConvertUTF8ToJavaString; | 71 using base::android::ConvertUTF8ToJavaString; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 ui::WindowAndroid* window_android, | 219 ui::WindowAndroid* window_android, |
| 219 jobject java_bridge_retained_object_set) | 220 jobject java_bridge_retained_object_set) |
| 220 : WebContentsObserver(web_contents), | 221 : WebContentsObserver(web_contents), |
| 221 java_ref_(env, obj), | 222 java_ref_(env, obj), |
| 222 web_contents_(static_cast<WebContentsImpl*>(web_contents)), | 223 web_contents_(static_cast<WebContentsImpl*>(web_contents)), |
| 223 root_layer_(cc::SolidColorLayer::Create()), | 224 root_layer_(cc::SolidColorLayer::Create()), |
| 224 dpi_scale_(GetPrimaryDisplayDeviceScaleFactor()), | 225 dpi_scale_(GetPrimaryDisplayDeviceScaleFactor()), |
| 225 view_android_(view_android), | 226 view_android_(view_android), |
| 226 window_android_(window_android), | 227 window_android_(window_android), |
| 227 device_orientation_(0), | 228 device_orientation_(0), |
| 228 accessibility_enabled_(false) { | 229 accessibility_enabled_(false), |
| 230 mouse_drag_start_x_(0), | |
| 231 mouse_drag_start_y_(0) { | |
| 229 CHECK(web_contents) << | 232 CHECK(web_contents) << |
| 230 "A ContentViewCoreImpl should be created with a valid WebContents."; | 233 "A ContentViewCoreImpl should be created with a valid WebContents."; |
| 231 | 234 |
| 232 root_layer_->SetBackgroundColor(GetBackgroundColor(env, obj)); | 235 root_layer_->SetBackgroundColor(GetBackgroundColor(env, obj)); |
| 233 gfx::Size physical_size( | 236 gfx::Size physical_size( |
| 234 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), | 237 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), |
| 235 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj)); | 238 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj)); |
| 236 root_layer_->SetBounds(physical_size); | 239 root_layer_->SetBounds(physical_size); |
| 237 root_layer_->SetIsDrawable(true); | 240 root_layer_->SetIsDrawable(true); |
| 238 | 241 |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 970 pointer_id_0, | 973 pointer_id_0, |
| 971 pointer_id_1, | 974 pointer_id_1, |
| 972 touch_major_0, | 975 touch_major_0, |
| 973 touch_major_1, | 976 touch_major_1, |
| 974 raw_pos_x, | 977 raw_pos_x, |
| 975 raw_pos_y, | 978 raw_pos_y, |
| 976 android_tool_type_0, | 979 android_tool_type_0, |
| 977 android_tool_type_1, | 980 android_tool_type_1, |
| 978 android_button_state); | 981 android_button_state); |
| 979 | 982 |
| 983 // Select text and show handles if necessary. | |
| 984 if (rwhv->ShouldTriggerOrUntriggerTextSelection(event)) { | |
| 985 Java_ContentViewCore_showSelectionHandlesAutomatically(env, obj); | |
| 986 switch (event.GetAction()) { | |
| 987 case ui::MotionEvent::ACTION_DOWN: | |
| 988 web_contents_->Unselect(); | |
| 989 mouse_drag_start_x_ = pos_x_0; | |
|
jdduke (slow)
2014/06/23 15:09:59
All of this logic should live close to where we de
jdduke (slow)
2014/06/23 15:24:50
Hmm, it appears |GetWebContents()| is a proper pub
Changwan Ryu
2014/06/24 09:29:48
Done
| |
| 990 mouse_drag_start_y_ = pos_y_0; | |
| 991 break; | |
| 992 case ui::MotionEvent::ACTION_MOVE: | |
| 993 case ui::MotionEvent::ACTION_UP: | |
| 994 if (rwhv->IsGestureTextSelectionTriggered()) { | |
| 995 SelectBetweenCoordinates(env, obj, mouse_drag_start_x_, | |
| 996 mouse_drag_start_y_, pos_x_0, pos_y_0); | |
| 997 } | |
| 998 break; | |
| 999 case ui::MotionEvent::ACTION_CANCEL: | |
| 1000 web_contents_->Unselect(); | |
| 1001 break; | |
| 1002 default: | |
| 1003 break; | |
| 1004 } | |
| 1005 } | |
| 980 return rwhv->OnTouchEvent(event); | 1006 return rwhv->OnTouchEvent(event); |
| 981 } | 1007 } |
| 982 | 1008 |
| 983 float ContentViewCoreImpl::GetDpiScale() const { | 1009 float ContentViewCoreImpl::GetDpiScale() const { |
| 984 return dpi_scale_; | 1010 return dpi_scale_; |
| 985 } | 1011 } |
| 986 | 1012 |
| 987 jboolean ContentViewCoreImpl::SendMouseMoveEvent(JNIEnv* env, | 1013 jboolean ContentViewCoreImpl::SendMouseMoveEvent(JNIEnv* env, |
| 988 jobject obj, | 1014 jobject obj, |
| 989 jlong time_ms, | 1015 jlong time_ms, |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1677 reinterpret_cast<ui::WindowAndroid*>(window_android), | 1703 reinterpret_cast<ui::WindowAndroid*>(window_android), |
| 1678 retained_objects_set); | 1704 retained_objects_set); |
| 1679 return reinterpret_cast<intptr_t>(view); | 1705 return reinterpret_cast<intptr_t>(view); |
| 1680 } | 1706 } |
| 1681 | 1707 |
| 1682 bool RegisterContentViewCore(JNIEnv* env) { | 1708 bool RegisterContentViewCore(JNIEnv* env) { |
| 1683 return RegisterNativesImpl(env); | 1709 return RegisterNativesImpl(env); |
| 1684 } | 1710 } |
| 1685 | 1711 |
| 1686 } // namespace content | 1712 } // namespace content |
| OLD | NEW |