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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 #include "ui/gfx/geometry/size_f.h" | 61 #include "ui/gfx/geometry/size_f.h" |
| 62 | 62 |
| 63 using base::android::AttachCurrentThread; | 63 using base::android::AttachCurrentThread; |
| 64 using base::android::ConvertJavaStringToUTF16; | 64 using base::android::ConvertJavaStringToUTF16; |
| 65 using base::android::ConvertJavaStringToUTF8; | 65 using base::android::ConvertJavaStringToUTF8; |
| 66 using base::android::ConvertUTF16ToJavaString; | 66 using base::android::ConvertUTF16ToJavaString; |
| 67 using base::android::ConvertUTF8ToJavaString; | 67 using base::android::ConvertUTF8ToJavaString; |
| 68 using base::android::ScopedJavaLocalRef; | 68 using base::android::ScopedJavaLocalRef; |
| 69 using blink::WebGestureEvent; | 69 using blink::WebGestureEvent; |
| 70 using blink::WebInputEvent; | 70 using blink::WebInputEvent; |
| 71 using blink::WebPointerProperties; | |
| 71 | 72 |
| 72 namespace content { | 73 namespace content { |
| 73 | 74 |
| 74 namespace { | 75 namespace { |
| 75 | 76 |
| 76 // Describes the type and enabled state of a select popup item. | 77 // Describes the type and enabled state of a select popup item. |
| 77 // | 78 // |
| 78 // A Java counterpart will be generated for this enum. | 79 // A Java counterpart will be generated for this enum. |
| 79 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.content.browser.input | 80 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.content.browser.input |
| 80 enum PopupItemType { | 81 enum PopupItemType { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 case WebInputEvent::GesturePinchUpdate: | 146 case WebInputEvent::GesturePinchUpdate: |
| 146 return GESTURE_EVENT_TYPE_PINCH_BY; | 147 return GESTURE_EVENT_TYPE_PINCH_BY; |
| 147 case WebInputEvent::GestureTwoFingerTap: | 148 case WebInputEvent::GestureTwoFingerTap: |
| 148 default: | 149 default: |
| 149 NOTREACHED() << "Invalid source gesture type: " | 150 NOTREACHED() << "Invalid source gesture type: " |
| 150 << WebInputEventTraits::GetName(type); | 151 << WebInputEventTraits::GetName(type); |
| 151 return -1; | 152 return -1; |
| 152 } | 153 } |
| 153 } | 154 } |
| 154 | 155 |
| 156 WebPointerProperties::PointerType ToWebPointerType(int tool_type) { | |
|
Rick Byers
2016/03/07 17:52:20
I think there's an existing process for sharing en
mustaq
2016/03/07 21:50:42
Reused the method in blink_event_util here.
Rick Byers
2016/03/08 15:43:37
Ah, even better - thanks!
| |
| 157 switch (tool_type) { | |
| 158 case 0: | |
| 159 return WebPointerProperties::PointerType::Unknown; | |
| 160 case 1: | |
| 161 return WebPointerProperties::PointerType::Touch; | |
| 162 case 2: | |
| 163 case 4: | |
| 164 return WebPointerProperties::PointerType::Pen; | |
| 165 case 3: | |
| 166 return WebPointerProperties::PointerType::Mouse; | |
| 167 default: | |
| 168 NOTREACHED() << "Invalid tool type: " << tool_type; | |
| 169 return WebPointerProperties::PointerType::Unknown; | |
| 170 } | |
| 171 } | |
| 172 | |
| 155 } // namespace | 173 } // namespace |
| 156 | 174 |
| 157 // Enables a callback when the underlying WebContents is destroyed, to enable | 175 // Enables a callback when the underlying WebContents is destroyed, to enable |
| 158 // nulling the back-pointer. | 176 // nulling the back-pointer. |
| 159 class ContentViewCoreImpl::ContentViewUserData | 177 class ContentViewCoreImpl::ContentViewUserData |
| 160 : public base::SupportsUserData::Data { | 178 : public base::SupportsUserData::Data { |
| 161 public: | 179 public: |
| 162 explicit ContentViewUserData(ContentViewCoreImpl* content_view_core) | 180 explicit ContentViewUserData(ContentViewCoreImpl* content_view_core) |
| 163 : content_view_core_(content_view_core) { | 181 : content_view_core_(content_view_core) { |
| 164 } | 182 } |
| (...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 974 | 992 |
| 975 float ContentViewCoreImpl::GetDpiScale() const { | 993 float ContentViewCoreImpl::GetDpiScale() const { |
| 976 return dpi_scale_; | 994 return dpi_scale_; |
| 977 } | 995 } |
| 978 | 996 |
| 979 jboolean ContentViewCoreImpl::SendMouseMoveEvent( | 997 jboolean ContentViewCoreImpl::SendMouseMoveEvent( |
| 980 JNIEnv* env, | 998 JNIEnv* env, |
| 981 const JavaParamRef<jobject>& obj, | 999 const JavaParamRef<jobject>& obj, |
| 982 jlong time_ms, | 1000 jlong time_ms, |
| 983 jfloat x, | 1001 jfloat x, |
| 984 jfloat y) { | 1002 jfloat y, |
| 1003 jint tool_type) { | |
| 985 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); | 1004 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); |
| 986 if (!rwhv) | 1005 if (!rwhv) |
| 987 return false; | 1006 return false; |
| 988 | 1007 |
| 989 blink::WebMouseEvent event = WebMouseEventBuilder::Build( | 1008 blink::WebMouseEvent event = WebMouseEventBuilder::Build( |
| 990 WebInputEvent::MouseMove, | 1009 WebInputEvent::MouseMove, |
| 991 blink::WebMouseEvent::ButtonNone, | 1010 blink::WebMouseEvent::ButtonNone, |
| 992 time_ms / 1000.0, x / dpi_scale(), y / dpi_scale(), 0, 1); | 1011 time_ms / 1000.0, x / dpi_scale(), y / dpi_scale(), 0, 1, |
| 1012 ToWebPointerType(tool_type)); | |
| 993 | 1013 |
| 994 rwhv->SendMouseEvent(event); | 1014 rwhv->SendMouseEvent(event); |
| 995 return true; | 1015 return true; |
| 996 } | 1016 } |
| 997 | 1017 |
| 998 jboolean ContentViewCoreImpl::SendMouseWheelEvent( | 1018 jboolean ContentViewCoreImpl::SendMouseWheelEvent( |
| 999 JNIEnv* env, | 1019 JNIEnv* env, |
| 1000 const JavaParamRef<jobject>& obj, | 1020 const JavaParamRef<jobject>& obj, |
| 1001 jlong time_ms, | 1021 jlong time_ms, |
| 1002 jfloat x, | 1022 jfloat x, |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1537 return ScopedJavaLocalRef<jobject>(); | 1557 return ScopedJavaLocalRef<jobject>(); |
| 1538 | 1558 |
| 1539 return view->GetJavaObject(); | 1559 return view->GetJavaObject(); |
| 1540 } | 1560 } |
| 1541 | 1561 |
| 1542 bool RegisterContentViewCore(JNIEnv* env) { | 1562 bool RegisterContentViewCore(JNIEnv* env) { |
| 1543 return RegisterNativesImpl(env); | 1563 return RegisterNativesImpl(env); |
| 1544 } | 1564 } |
| 1545 | 1565 |
| 1546 } // namespace content | 1566 } // namespace content |
| OLD | NEW |