| 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" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 env, Java_ViewAndroidDelegate_acquireView(env, delegate), delegate); | 118 env, Java_ViewAndroidDelegate_acquireView(env, delegate), delegate); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void ViewAndroid::SetAnchorRect(const JavaRef<jobject>& anchor, | 121 void ViewAndroid::SetAnchorRect(const JavaRef<jobject>& anchor, |
| 122 const gfx::RectF& bounds) { | 122 const gfx::RectF& bounds) { |
| 123 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); | 123 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); |
| 124 if (delegate.is_null()) | 124 if (delegate.is_null()) |
| 125 return; | 125 return; |
| 126 | 126 |
| 127 float scale = display::Screen::GetScreen() | 127 float scale = display::Screen::GetScreen() |
| 128 ->GetDisplayNearestWindow(this) | 128 ->GetDisplayNearestView(this) |
| 129 .device_scale_factor(); | 129 .device_scale_factor(); |
| 130 int left_margin = std::round(bounds.x() * scale); | 130 int left_margin = std::round(bounds.x() * scale); |
| 131 int top_margin = std::round((content_offset().y() + bounds.y()) * scale); | 131 int top_margin = std::round((content_offset().y() + bounds.y()) * scale); |
| 132 JNIEnv* env = base::android::AttachCurrentThread(); | 132 JNIEnv* env = base::android::AttachCurrentThread(); |
| 133 Java_ViewAndroidDelegate_setViewPosition( | 133 Java_ViewAndroidDelegate_setViewPosition( |
| 134 env, delegate, anchor, bounds.x(), bounds.y(), bounds.width(), | 134 env, delegate, anchor, bounds.x(), bounds.y(), bounds.width(), |
| 135 bounds.height(), scale, left_margin, top_margin); | 135 bounds.height(), scale, left_margin, top_margin); |
| 136 } | 136 } |
| 137 | 137 |
| 138 ScopedJavaLocalRef<jobject> ViewAndroid::GetContainerView() { | 138 ScopedJavaLocalRef<jobject> ViewAndroid::GetContainerView() { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 if (delegate.is_null()) | 221 if (delegate.is_null()) |
| 222 return; | 222 return; |
| 223 JNIEnv* env = base::android::AttachCurrentThread(); | 223 JNIEnv* env = base::android::AttachCurrentThread(); |
| 224 ScopedJavaLocalRef<jstring> jcontent_url = | 224 ScopedJavaLocalRef<jstring> jcontent_url = |
| 225 ConvertUTF8ToJavaString(env, content_url.spec()); | 225 ConvertUTF8ToJavaString(env, content_url.spec()); |
| 226 Java_ViewAndroidDelegate_onStartContentIntent(env, delegate, jcontent_url, | 226 Java_ViewAndroidDelegate_onStartContentIntent(env, delegate, jcontent_url, |
| 227 is_main_frame); | 227 is_main_frame); |
| 228 } | 228 } |
| 229 | 229 |
| 230 } // namespace ui | 230 } // namespace ui |
| OLD | NEW |