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

Unified Diff: ui/android/java/src/org/chromium/ui/base/ViewRoot.java

Issue 2595263002: Introduce ViewRoot forwarding input/view events to native (Closed)
Patch Set: view_root.java_obj_... Created 3 years, 11 months 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
« no previous file with comments | « ui/android/display_android_manager.cc ('k') | ui/android/java/src/org/chromium/ui/base/WindowAndroid.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/android/java/src/org/chromium/ui/base/ViewRoot.java
diff --git a/ui/android/java/src/org/chromium/ui/base/ViewRoot.java b/ui/android/java/src/org/chromium/ui/base/ViewRoot.java
index c224e8e3ed8c9cdfd31b3ed2e783e090ea42a4e7..4141c15a88356ee682812edd8c4bc00ca04e9ab8 100644
--- a/ui/android/java/src/org/chromium/ui/base/ViewRoot.java
+++ b/ui/android/java/src/org/chromium/ui/base/ViewRoot.java
@@ -4,29 +4,32 @@
package org.chromium.ui.base;
-import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
/**
* Class used to forward view, input events down to native.
- *
- * TODO(jinsukkim): Add its native counterpart inheriting from ViewAndroid
- * so that it will act as a root of ViewAndroid tree. It effectively
- * replaces WindowAndroid in terms of the role.
*/
@JNINamespace("ui")
public class ViewRoot {
- // The corresponding native ViewAndroid. This object can only be used while
+
+ private final WindowAndroid mWindowAndroid;
+
+ // The corresponding native instance. This class can only be used while
// the native instance is alive.
private long mNativeView;
- @CalledByNative
- private static ViewRoot create(long nativeView) {
- return new ViewRoot(nativeView);
+ public static ViewRoot create(WindowAndroid window) {
+ if (window == null) throw new IllegalArgumentException("WindowAndroid should not be null");
+ return new ViewRoot(window);
+ }
+
+ private ViewRoot(WindowAndroid window) {
+ mNativeView = nativeInit(window.getNativePointer());
+ mWindowAndroid = window;
}
- private ViewRoot(long nativeView) {
- mNativeView = nativeView;
+ public WindowAndroid getWindowAndroid() {
+ return mWindowAndroid;
}
/**
@@ -40,11 +43,18 @@ public class ViewRoot {
nativeOnPhysicalBackingSizeChanged(mNativeView, width, height);
}
- @CalledByNative
- private void onDestroyNativeView() {
+ public long getNativePtr() {
+ return mNativeView;
+ }
+
+ public void destroy() {
+ assert mNativeView != 0;
+ nativeDestroy(mNativeView);
mNativeView = 0;
}
- private static native void nativeOnPhysicalBackingSizeChanged(long viewAndroid,
+ private native long nativeInit(long windowNativePointer);
+ private native void nativeDestroy(long nativeViewRoot);
+ private native void nativeOnPhysicalBackingSizeChanged(long nativeViewRoot,
int width, int height);
}
« no previous file with comments | « ui/android/display_android_manager.cc ('k') | ui/android/java/src/org/chromium/ui/base/WindowAndroid.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698