| 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 "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); | 119 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); |
| 120 if (delegate.is_null()) | 120 if (delegate.is_null()) |
| 121 return; | 121 return; |
| 122 | 122 |
| 123 float scale = display::Screen::GetScreen() | 123 float scale = display::Screen::GetScreen() |
| 124 ->GetDisplayNearestWindow(this) | 124 ->GetDisplayNearestWindow(this) |
| 125 .device_scale_factor(); | 125 .device_scale_factor(); |
| 126 int left_margin = std::round(bounds.x() * scale); | 126 int left_margin = std::round(bounds.x() * scale); |
| 127 // TODO(jinsukkim): Move content_offset() to ViewAndroid, since it's | 127 // TODO(jinsukkim): Move content_offset() to ViewAndroid, since it's |
| 128 // specific to a given web contents/render widget. | 128 // specific to a given web contents/render widget. |
| 129 float content_offset_y_pix = GetWindowAndroid()->content_offset().y(); | 129 int top_margin = std::round( |
| 130 int top_margin = std::round(content_offset_y_pix + bounds.y() * scale); | 130 (GetWindowAndroid()->content_offset().y() + bounds.y()) * scale); |
| 131 JNIEnv* env = base::android::AttachCurrentThread(); | 131 JNIEnv* env = base::android::AttachCurrentThread(); |
| 132 Java_ViewAndroidDelegate_setViewPosition( | 132 Java_ViewAndroidDelegate_setViewPosition( |
| 133 env, delegate, anchor, bounds.x(), bounds.y(), bounds.width(), | 133 env, delegate, anchor, bounds.x(), bounds.y(), bounds.width(), |
| 134 bounds.height(), scale, left_margin, top_margin); | 134 bounds.height(), scale, left_margin, top_margin); |
| 135 } | 135 } |
| 136 | 136 |
| 137 void ViewAndroid::RemoveChild(ViewAndroid* child) { | 137 void ViewAndroid::RemoveChild(ViewAndroid* child) { |
| 138 DCHECK(child); | 138 DCHECK(child); |
| 139 DCHECK_EQ(child->parent_, this); | 139 DCHECK_EQ(child->parent_, this); |
| 140 | 140 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 170 void ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext, | 170 void ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext, |
| 171 const JavaRef<jobject>& jimage) { | 171 const JavaRef<jobject>& jimage) { |
| 172 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); | 172 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); |
| 173 if (delegate.is_null()) | 173 if (delegate.is_null()) |
| 174 return; | 174 return; |
| 175 JNIEnv* env = base::android::AttachCurrentThread(); | 175 JNIEnv* env = base::android::AttachCurrentThread(); |
| 176 Java_ViewAndroidDelegate_startDragAndDrop(env, delegate, jtext, jimage); | 176 Java_ViewAndroidDelegate_startDragAndDrop(env, delegate, jtext, jimage); |
| 177 } | 177 } |
| 178 | 178 |
| 179 } // namespace ui | 179 } // namespace ui |
| OLD | NEW |