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

Unified Diff: ui/android/view_android.cc

Issue 2502763003: Introduce ViewRoot to forward input/view events to native (Closed)
Patch Set: Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: ui/android/view_android.cc
diff --git a/ui/android/view_android.cc b/ui/android/view_android.cc
index 664758cd5304088709f1cd99bdb655bae764aadf..0ab53036f2f8657783c7e05f476c4182717b8e4d 100644
--- a/ui/android/view_android.cc
+++ b/ui/android/view_android.cc
@@ -15,6 +15,7 @@
namespace ui {
+using base::android::JavaParamRef;
using base::android::JavaRef;
using base::android::ScopedJavaLocalRef;
@@ -68,11 +69,6 @@ ViewAndroid::ScopedAnchorView::view() const {
return view_.get(env);
}
-ViewAndroid::ViewAndroid(const JavaRef<jobject>& delegate)
- : parent_(nullptr)
- , delegate_(base::android::AttachCurrentThread(),
- delegate.obj()) {}
-
ViewAndroid::ViewAndroid() : parent_(nullptr) {}
ViewAndroid::~ViewAndroid() {
@@ -86,8 +82,13 @@ ViewAndroid::~ViewAndroid() {
}
void ViewAndroid::SetDelegate(const JavaRef<jobject>& delegate) {
+ // A ViewAndroid may have its own delegate or otherwise will
+ // use the next available parent's delegate.
JNIEnv* env = base::android::AttachCurrentThread();
delegate_ = JavaObjectWeakGlobalRef(env, delegate);
+ Java_ViewAndroidDelegate_setNativePointer(env,
boliu 2016/11/15 04:51:03 delegate has a many-to-one relationship with view,
Jinsuk Kim 2016/11/15 16:47:44 My intention was to maintain only one handler per
+ delegate,
+ reinterpret_cast<jlong>(this));
}
void ViewAndroid::AddChild(ViewAndroid* child) {
@@ -179,4 +180,19 @@ bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext,
jimage);
}
+void ViewAndroid::OnPhysicalBackingSizeChanged(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jint width, jint height) {
+ if (!physical_backing_size_changed_handler_.is_null()) {
+ physical_backing_size_changed_handler_.Run(width, height);
+ return;
+ }
+}
+
+// static
+bool ViewAndroid::RegisterViewAndroid(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698