| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 void ViewAndroid::SetAnchorRect(const JavaRef<jobject>& anchor, | 133 void ViewAndroid::SetAnchorRect(const JavaRef<jobject>& anchor, |
| 134 const gfx::RectF& bounds) { | 134 const gfx::RectF& bounds) { |
| 135 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); | 135 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); |
| 136 if (delegate.is_null()) | 136 if (delegate.is_null()) |
| 137 return; | 137 return; |
| 138 | 138 |
| 139 float scale = display::Screen::GetScreen() | 139 float scale = display::Screen::GetScreen() |
| 140 ->GetDisplayNearestWindow(this) | 140 ->GetDisplayNearestWindow(this) |
| 141 .device_scale_factor(); | 141 .device_scale_factor(); |
| 142 int left_margin = std::round(bounds.x() * scale); | 142 int left_margin = std::round(bounds.x() * scale); |
| 143 // TODO(jinsukkim): Move content_offset() to ViewAndroid, since it's | 143 int top_margin = std::round((content_offset().y() + bounds.y()) * scale); |
| 144 // specific to a given web contents/render widget. | |
| 145 int top_margin = std::round( | |
| 146 (GetWindowAndroid()->content_offset().y() + bounds.y()) * scale); | |
| 147 JNIEnv* env = base::android::AttachCurrentThread(); | 144 JNIEnv* env = base::android::AttachCurrentThread(); |
| 148 Java_ViewAndroidDelegate_setViewPosition( | 145 Java_ViewAndroidDelegate_setViewPosition( |
| 149 env, delegate, anchor, bounds.x(), bounds.y(), bounds.width(), | 146 env, delegate, anchor, bounds.x(), bounds.y(), bounds.width(), |
| 150 bounds.height(), scale, left_margin, top_margin); | 147 bounds.height(), scale, left_margin, top_margin); |
| 151 } | 148 } |
| 152 | 149 |
| 153 void ViewAndroid::RemoveChild(ViewAndroid* child) { | 150 void ViewAndroid::RemoveChild(ViewAndroid* child) { |
| 154 DCHECK(child); | 151 DCHECK(child); |
| 155 DCHECK_EQ(child->parent_, this); | 152 DCHECK_EQ(child->parent_, this); |
| 156 | 153 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 int height) { | 263 int height) { |
| 267 ViewAndroid* view_android = reinterpret_cast<ViewAndroid*>(native_view); | 264 ViewAndroid* view_android = reinterpret_cast<ViewAndroid*>(native_view); |
| 268 view_android->OnPhysicalBackingSizeChanged(width, height); | 265 view_android->OnPhysicalBackingSizeChanged(width, height); |
| 269 } | 266 } |
| 270 | 267 |
| 271 bool RegisterViewRoot(JNIEnv* env) { | 268 bool RegisterViewRoot(JNIEnv* env) { |
| 272 return RegisterNativesImpl(env); | 269 return RegisterNativesImpl(env); |
| 273 } | 270 } |
| 274 | 271 |
| 275 } // namespace ui | 272 } // namespace ui |
| OLD | NEW |