| 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 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 void ContentViewCoreImpl::OnSelectionChanged(const std::string& text) { | 602 void ContentViewCoreImpl::OnSelectionChanged(const std::string& text) { |
| 603 JNIEnv* env = AttachCurrentThread(); | 603 JNIEnv* env = AttachCurrentThread(); |
| 604 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 604 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 605 if (obj.is_null()) | 605 if (obj.is_null()) |
| 606 return; | 606 return; |
| 607 ScopedJavaLocalRef<jstring> jtext = ConvertUTF8ToJavaString(env, text); | 607 ScopedJavaLocalRef<jstring> jtext = ConvertUTF8ToJavaString(env, text); |
| 608 Java_ContentViewCore_onSelectionChanged(env, obj.obj(), jtext.obj()); | 608 Java_ContentViewCore_onSelectionChanged(env, obj.obj(), jtext.obj()); |
| 609 } | 609 } |
| 610 | 610 |
| 611 void ContentViewCoreImpl::OnSelectionEvent(ui::SelectionEventType event, | 611 void ContentViewCoreImpl::OnSelectionEvent(ui::SelectionEventType event, |
| 612 const gfx::PointF& position) { | 612 const gfx::PointF& selection_anchor, |
| 613 const gfx::RectF& selection_rect) { |
| 613 JNIEnv* env = AttachCurrentThread(); | 614 JNIEnv* env = AttachCurrentThread(); |
| 614 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 615 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
| 615 if (j_obj.is_null()) | 616 if (j_obj.is_null()) |
| 616 return; | 617 return; |
| 617 Java_ContentViewCore_onSelectionEvent(env, j_obj.obj(), event, | 618 |
| 618 position.x() * dpi_scale(), | 619 gfx::PointF selection_anchor_pix = |
| 619 position.y() * dpi_scale()); | 620 gfx::ScalePoint(selection_anchor, dpi_scale()); |
| 621 gfx::RectF selection_rect_pix = gfx::ScaleRect(selection_rect, dpi_scale()); |
| 622 Java_ContentViewCore_onSelectionEvent( |
| 623 env, j_obj.obj(), event, selection_anchor_pix.x(), |
| 624 selection_anchor_pix.y(), selection_rect_pix.x(), selection_rect_pix.y(), |
| 625 selection_rect_pix.right(), selection_rect_pix.bottom()); |
| 620 } | 626 } |
| 621 | 627 |
| 622 scoped_ptr<ui::TouchHandleDrawable> | 628 scoped_ptr<ui::TouchHandleDrawable> |
| 623 ContentViewCoreImpl::CreatePopupTouchHandleDrawable() { | 629 ContentViewCoreImpl::CreatePopupTouchHandleDrawable() { |
| 624 JNIEnv* env = AttachCurrentThread(); | 630 JNIEnv* env = AttachCurrentThread(); |
| 625 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 631 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 626 if (obj.is_null()) { | 632 if (obj.is_null()) { |
| 627 NOTREACHED(); | 633 NOTREACHED(); |
| 628 return scoped_ptr<ui::TouchHandleDrawable>(); | 634 return scoped_ptr<ui::TouchHandleDrawable>(); |
| 629 } | 635 } |
| (...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1432 return NULL; | 1438 return NULL; |
| 1433 | 1439 |
| 1434 return view->GetJavaObject().Release(); | 1440 return view->GetJavaObject().Release(); |
| 1435 } | 1441 } |
| 1436 | 1442 |
| 1437 bool RegisterContentViewCore(JNIEnv* env) { | 1443 bool RegisterContentViewCore(JNIEnv* env) { |
| 1438 return RegisterNativesImpl(env); | 1444 return RegisterNativesImpl(env); |
| 1439 } | 1445 } |
| 1440 | 1446 |
| 1441 } // namespace content | 1447 } // namespace content |
| OLD | NEW |