| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/android/view_android.h" | 5 #include "ui/android/view_android.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| 11 #include "base/containers/adapters.h" | 11 #include "base/containers/adapters.h" |
| 12 #include "cc/layers/layer.h" | 12 #include "cc/layers/layer.h" |
| 13 #include "jni/ViewAndroidDelegate_jni.h" | 13 #include "jni/ViewAndroidDelegate_jni.h" |
| 14 #include "third_party/WebKit/public/platform/WebCursorInfo.h" |
| 14 #include "ui/android/event_forwarder.h" | 15 #include "ui/android/event_forwarder.h" |
| 15 #include "ui/android/view_client.h" | 16 #include "ui/android/view_client.h" |
| 16 #include "ui/android/window_android.h" | 17 #include "ui/android/window_android.h" |
| 18 #include "ui/base/cursor/cursors_android.h" |
| 17 #include "ui/base/layout.h" | 19 #include "ui/base/layout.h" |
| 18 #include "ui/events/android/motion_event_android.h" | 20 #include "ui/events/android/motion_event_android.h" |
| 21 #include "ui/gfx/android/java_bitmap.h" |
| 19 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 20 | 23 |
| 21 namespace ui { | 24 namespace ui { |
| 22 | 25 |
| 23 using base::android::ConvertUTF8ToJavaString; | 26 using base::android::ConvertUTF8ToJavaString; |
| 24 using base::android::JavaRef; | 27 using base::android::JavaRef; |
| 25 using base::android::ScopedJavaLocalRef; | 28 using base::android::ScopedJavaLocalRef; |
| 29 using blink::WebCursorInfo; |
| 26 | 30 |
| 27 ViewAndroid::ScopedAnchorView::ScopedAnchorView( | 31 ViewAndroid::ScopedAnchorView::ScopedAnchorView( |
| 28 JNIEnv* env, | 32 JNIEnv* env, |
| 29 const JavaRef<jobject>& jview, | 33 const JavaRef<jobject>& jview, |
| 30 const JavaRef<jobject>& jdelegate) | 34 const JavaRef<jobject>& jdelegate) |
| 31 : view_(env, jview.obj()), delegate_(env, jdelegate.obj()) { | 35 : view_(env, jview.obj()), delegate_(env, jdelegate.obj()) { |
| 32 // If there's a view, then we need a delegate to remove it. | 36 // If there's a view, then we need a delegate to remove it. |
| 33 DCHECK(!jdelegate.is_null() || jview.is_null()); | 37 DCHECK(!jdelegate.is_null() || jview.is_null()); |
| 34 } | 38 } |
| 35 | 39 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext, | 249 bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext, |
| 246 const JavaRef<jobject>& jimage) { | 250 const JavaRef<jobject>& jimage) { |
| 247 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); | 251 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); |
| 248 if (delegate.is_null()) | 252 if (delegate.is_null()) |
| 249 return false; | 253 return false; |
| 250 JNIEnv* env = base::android::AttachCurrentThread(); | 254 JNIEnv* env = base::android::AttachCurrentThread(); |
| 251 return Java_ViewAndroidDelegate_startDragAndDrop(env, delegate, jtext, | 255 return Java_ViewAndroidDelegate_startDragAndDrop(env, delegate, jtext, |
| 252 jimage); | 256 jimage); |
| 253 } | 257 } |
| 254 | 258 |
| 259 void ViewAndroid::OnCursorChanged(int type, |
| 260 const SkBitmap& custom_image, |
| 261 const gfx::Point& hotspot) { |
| 262 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); |
| 263 if (delegate.is_null()) |
| 264 return; |
| 265 JNIEnv* env = base::android::AttachCurrentThread(); |
| 266 SkBitmap drawn_cursor_image; |
| 267 if (type == WebCursorInfo::kTypeCustom) { |
| 268 ScopedJavaLocalRef<jobject> java_bitmap = |
| 269 gfx::ConvertToJavaBitmap(&custom_image); |
| 270 Java_ViewAndroidDelegate_onCursorChangedToCustom(env, delegate, java_bitmap, |
| 271 hotspot.x(), hotspot.y()); |
| 272 } else if (GetCursorBitmap(type, &drawn_cursor_image)) { |
| 273 ScopedJavaLocalRef<jobject> java_bitmap = |
| 274 gfx::ConvertToJavaBitmap(&drawn_cursor_image); |
| 275 Java_ViewAndroidDelegate_onCursorChangedToCustom(env, delegate, java_bitmap, |
| 276 hotspot.x(), hotspot.y()); |
| 277 } else { |
| 278 Java_ViewAndroidDelegate_onCursorChanged(env, delegate, type); |
| 279 } |
| 280 } |
| 281 |
| 255 void ViewAndroid::OnBackgroundColorChanged(unsigned int color) { | 282 void ViewAndroid::OnBackgroundColorChanged(unsigned int color) { |
| 256 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); | 283 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); |
| 257 if (delegate.is_null()) | 284 if (delegate.is_null()) |
| 258 return; | 285 return; |
| 259 JNIEnv* env = base::android::AttachCurrentThread(); | 286 JNIEnv* env = base::android::AttachCurrentThread(); |
| 260 Java_ViewAndroidDelegate_onBackgroundColorChanged(env, delegate, color); | 287 Java_ViewAndroidDelegate_onBackgroundColorChanged(env, delegate, color); |
| 261 } | 288 } |
| 262 | 289 |
| 263 void ViewAndroid::OnTopControlsChanged(float top_controls_offset, | 290 void ViewAndroid::OnTopControlsChanged(float top_controls_offset, |
| 264 float top_content_offset) { | 291 float top_content_offset) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 matched = bound.Contains(e->GetX(0), e->GetY(0)); | 382 matched = bound.Contains(e->GetX(0), e->GetY(0)); |
| 356 } | 383 } |
| 357 if (matched && child->HitTest(send_to_client, *e)) | 384 if (matched && child->HitTest(send_to_client, *e)) |
| 358 return true; | 385 return true; |
| 359 } | 386 } |
| 360 } | 387 } |
| 361 return false; | 388 return false; |
| 362 } | 389 } |
| 363 | 390 |
| 364 } // namespace ui | 391 } // namespace ui |
| OLD | NEW |