Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: content/browser/android/content_view_core_impl.cc

Issue 2352143002: Keep ContentViewCore selection rectangle in DIP (Closed)
Patch Set: Dropped Dip suffix to names and added Pix suffix where dimension is pixels Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 } 639 }
640 640
641 void ContentViewCoreImpl::OnSelectionEvent(ui::SelectionEventType event, 641 void ContentViewCoreImpl::OnSelectionEvent(ui::SelectionEventType event,
642 const gfx::PointF& selection_anchor, 642 const gfx::PointF& selection_anchor,
643 const gfx::RectF& selection_rect) { 643 const gfx::RectF& selection_rect) {
644 JNIEnv* env = AttachCurrentThread(); 644 JNIEnv* env = AttachCurrentThread();
645 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 645 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
646 if (j_obj.is_null()) 646 if (j_obj.is_null())
647 return; 647 return;
648 648
649 gfx::PointF selection_anchor_pix =
650 gfx::ScalePoint(selection_anchor, dpi_scale());
651 gfx::RectF selection_rect_pix = gfx::ScaleRect(selection_rect, dpi_scale());
652 Java_ContentViewCore_onSelectionEvent( 649 Java_ContentViewCore_onSelectionEvent(
653 env, j_obj, event, selection_anchor_pix.x(), selection_anchor_pix.y(), 650 env, j_obj, event, selection_anchor.x(), selection_anchor.y(),
654 selection_rect_pix.x(), selection_rect_pix.y(), 651 selection_rect.x(), selection_rect.y(), selection_rect.right(),
655 selection_rect_pix.right(), selection_rect_pix.bottom()); 652 selection_rect.bottom());
656 } 653 }
657 654
658 bool ContentViewCoreImpl::ShowPastePopup(int x_dip, int y_dip) { 655 bool ContentViewCoreImpl::ShowPastePopup(int x_dip, int y_dip) {
659 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); 656 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid();
660 if (!view) 657 if (!view)
661 return false; 658 return false;
662 659
663 view->OnShowingPastePopup(gfx::PointF(x_dip, y_dip)); 660 view->OnShowingPastePopup(gfx::PointF(x_dip, y_dip));
664 661
665 JNIEnv* env = AttachCurrentThread(); 662 JNIEnv* env = AttachCurrentThread();
666 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 663 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
667 if (obj.is_null()) 664 if (obj.is_null())
668 return false; 665 return false;
669 return Java_ContentViewCore_showPastePopupWithFeedback( 666 return Java_ContentViewCore_showPastePopupWithFeedback(env, obj, x_dip,
670 env, obj, static_cast<jint>(x_dip * dpi_scale()), 667 y_dip);
671 static_cast<jint>(y_dip * dpi_scale()));
672 } 668 }
673 669
674 void ContentViewCoreImpl::StartContentIntent(const GURL& content_url, 670 void ContentViewCoreImpl::StartContentIntent(const GURL& content_url,
675 bool is_main_frame) { 671 bool is_main_frame) {
676 JNIEnv* env = AttachCurrentThread(); 672 JNIEnv* env = AttachCurrentThread();
677 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 673 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
678 if (j_obj.is_null()) 674 if (j_obj.is_null())
679 return; 675 return;
680 ScopedJavaLocalRef<jstring> jcontent_url = 676 ScopedJavaLocalRef<jstring> jcontent_url =
681 ConvertUTF8ToJavaString(env, content_url.spec()); 677 ConvertUTF8ToJavaString(env, content_url.spec());
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 return ScopedJavaLocalRef<jobject>(); 1597 return ScopedJavaLocalRef<jobject>();
1602 1598
1603 return view->GetJavaObject(); 1599 return view->GetJavaObject();
1604 } 1600 }
1605 1601
1606 bool RegisterContentViewCore(JNIEnv* env) { 1602 bool RegisterContentViewCore(JNIEnv* env) {
1607 return RegisterNativesImpl(env); 1603 return RegisterNativesImpl(env);
1608 } 1604 }
1609 1605
1610 } // namespace content 1606 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698