Chromium Code Reviews| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 ->GetDisplayNearestWindow(this) | 126 ->GetDisplayNearestWindow(this) |
| 127 .device_scale_factor(); | 127 .device_scale_factor(); |
| 128 int left_margin = std::round(bounds.x() * scale); | 128 int left_margin = std::round(bounds.x() * scale); |
| 129 int top_margin = std::round((content_offset().y() + bounds.y()) * scale); | 129 int top_margin = std::round((content_offset().y() + bounds.y()) * scale); |
| 130 JNIEnv* env = base::android::AttachCurrentThread(); | 130 JNIEnv* env = base::android::AttachCurrentThread(); |
| 131 Java_ViewAndroidDelegate_setViewPosition( | 131 Java_ViewAndroidDelegate_setViewPosition( |
| 132 env, delegate, anchor, bounds.x(), bounds.y(), bounds.width(), | 132 env, delegate, anchor, bounds.x(), bounds.y(), bounds.width(), |
| 133 bounds.height(), scale, left_margin, top_margin); | 133 bounds.height(), scale, left_margin, top_margin); |
| 134 } | 134 } |
| 135 | 135 |
| 136 ScopedJavaLocalRef<jobject> ViewAndroid::GetContainerView() { | |
| 137 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); | |
| 138 if (delegate.is_null()) | |
| 139 return ScopedJavaLocalRef<jobject>(); | |
|
boliu
2017/01/18 18:21:16
nullptr should work I think
Jinsuk Kim
2017/01/19 23:48:08
Done.
| |
| 140 | |
| 141 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 142 return Java_ViewAndroidDelegate_getContainerView(env, delegate); | |
| 143 } | |
| 144 | |
| 136 void ViewAndroid::RemoveChild(ViewAndroid* child) { | 145 void ViewAndroid::RemoveChild(ViewAndroid* child) { |
| 137 DCHECK(child); | 146 DCHECK(child); |
| 138 DCHECK_EQ(child->parent_, this); | 147 DCHECK_EQ(child->parent_, this); |
| 139 | 148 |
| 140 std::list<ViewAndroid*>::iterator it = | 149 std::list<ViewAndroid*>::iterator it = |
| 141 std::find(children_.begin(), children_.end(), child); | 150 std::find(children_.begin(), children_.end(), child); |
| 142 DCHECK(it != children_.end()); | 151 DCHECK(it != children_.end()); |
| 143 children_.erase(it); | 152 children_.erase(it); |
| 144 child->parent_ = nullptr; | 153 child->parent_ = nullptr; |
| 145 } | 154 } |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 170 const JavaRef<jobject>& jimage) { | 179 const JavaRef<jobject>& jimage) { |
| 171 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); | 180 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); |
| 172 if (delegate.is_null()) | 181 if (delegate.is_null()) |
| 173 return false; | 182 return false; |
| 174 JNIEnv* env = base::android::AttachCurrentThread(); | 183 JNIEnv* env = base::android::AttachCurrentThread(); |
| 175 return Java_ViewAndroidDelegate_startDragAndDrop(env, delegate, jtext, | 184 return Java_ViewAndroidDelegate_startDragAndDrop(env, delegate, jtext, |
| 176 jimage); | 185 jimage); |
| 177 } | 186 } |
| 178 | 187 |
| 179 } // namespace ui | 188 } // namespace ui |
| OLD | NEW |