Chromium Code Reviews| 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..23d7a3f35483f6f5fc89272b832a2822fe1fb5db 100644 |
| --- a/ui/android/java/src/org/chromium/ui/base/ViewRoot.java |
| +++ b/ui/android/java/src/org/chromium/ui/base/ViewRoot.java |
| @@ -9,24 +9,28 @@ 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(long nativeView) { |
| - mNativeView = nativeView; |
| + private ViewRoot(WindowAndroid window) { |
| + mNativeView = nativeInit(window == null ? 0 : window.getNativePointer()); |
|
boliu
2017/01/05 19:09:29
don't need null check here anymore
Jinsuk Kim
2017/01/05 22:30:15
Done.
|
| + mWindowAndroid = window; |
| + } |
| + |
| + public WindowAndroid getWindowAndroid() { |
| + return mWindowAndroid; |
| } |
| /** |
| @@ -41,10 +45,17 @@ public class ViewRoot { |
| } |
| @CalledByNative |
|
boliu
2017/01/05 19:09:29
Remove ViewRoot::FromJavaObject entirely, and then
Jinsuk Kim
2017/01/05 22:30:15
Now it's used to pass native pointer through CVC n
|
| - private void onDestroyNativeView() { |
| + public long getNativePtr() { |
| + return mNativeView; |
| + } |
| + |
| + public void destroy() { |
|
boliu
2017/01/05 19:09:29
assert mNativeView != 0
Jinsuk Kim
2017/01/05 22:30:15
Done.
|
| + 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); |
| } |