Chromium Code Reviews| Index: ui/android/view_android.cc |
| diff --git a/ui/android/view_android.cc b/ui/android/view_android.cc |
| index 96e56495886dd26d8807a5847a0d6f0e12894295..eb4d1d9898bb46e1425c5b0251b623c172dadfe2 100644 |
| --- a/ui/android/view_android.cc |
| +++ b/ui/android/view_android.cc |
| @@ -9,7 +9,6 @@ |
| #include "base/android/jni_android.h" |
| #include "cc/layers/layer.h" |
| #include "jni/ViewAndroidDelegate_jni.h" |
| -#include "jni/ViewRoot_jni.h" |
| #include "ui/android/view_client.h" |
| #include "ui/android/window_android.h" |
| #include "ui/display/display.h" |
| @@ -84,11 +83,6 @@ ViewAndroid::~ViewAndroid() { |
| DCHECK_EQ(child->parent_, this); |
| child->parent_ = nullptr; |
| } |
| - |
| - JNIEnv* env = base::android::AttachCurrentThread(); |
| - const ScopedJavaLocalRef<jobject> view_root = view_root_.get(env); |
| - if (!view_root.is_null()) |
| - Java_ViewRoot_onDestroyNativeView(env, view_root); |
| } |
| void ViewAndroid::SetDelegate(const JavaRef<jobject>& delegate) { |
| @@ -100,18 +94,17 @@ void ViewAndroid::SetDelegate(const JavaRef<jobject>& delegate) { |
| void ViewAndroid::AddChild(ViewAndroid* child) { |
| DCHECK(child); |
| + DCHECK(child->GetViewRoot() != child); // ViewRoot cannot be a child. |
|
boliu
2017/01/04 18:58:06
just have a "bool IsViewRoot" method instead
Jinsuk Kim
2017/01/05 11:03:12
Done.
|
| DCHECK(std::find(children_.begin(), children_.end(), child) == |
| children_.end()); |
| - DCHECK(!HasViewRootInTreeHierarchy() || |
| - !child->HasViewRootInSubtree()); |
| children_.push_back(child); |
| if (child->parent_) |
| child->RemoveFromParent(); |
| child->parent_ = this; |
| if (physical_width_pix_ || physical_height_pix_) { |
| - child->OnPhysicalBackingSizeChanged(physical_width_pix_, |
| - physical_height_pix_); |
| + child->OnPhysicalBackingSizeChangedInternal(physical_width_pix_, |
| + physical_height_pix_); |
| } |
| } |
| @@ -165,15 +158,6 @@ WindowAndroid* ViewAndroid::GetWindowAndroid() const { |
| return parent_ ? parent_->GetWindowAndroid() : nullptr; |
| } |
| -ScopedJavaLocalRef<jobject> ViewAndroid::CreateViewRoot() { |
| - JNIEnv* env = base::android::AttachCurrentThread(); |
| - return Java_ViewRoot_create(env, reinterpret_cast<intptr_t>(this)); |
| -} |
| - |
| -bool ViewAndroid::HasViewRoot() { |
| - return !view_root_.is_uninitialized(); |
| -} |
| - |
| const ScopedJavaLocalRef<jobject> ViewAndroid::GetViewAndroidDelegate() |
| const { |
| JNIEnv* env = base::android::AttachCurrentThread(); |
| @@ -193,35 +177,8 @@ void ViewAndroid::SetLayer(scoped_refptr<cc::Layer> layer) { |
| UpdateLayerBounds(); |
| } |
| -ScopedJavaLocalRef<jobject> ViewAndroid::GetViewRoot() { |
| - JNIEnv* env = base::android::AttachCurrentThread(); |
| - const ScopedJavaLocalRef<jobject> view_root = view_root_.get(env); |
| - if (!view_root.is_null()) |
| - return view_root; |
| - |
| - DCHECK(!HasViewRootInTreeHierarchy()); |
| - view_root_ = JavaObjectWeakGlobalRef(env, CreateViewRoot()); |
| - return view_root_.get(env); |
| -} |
| - |
| -bool ViewAndroid::HasViewRootInTreeHierarchy() { |
| - ViewAndroid* view = parent_; |
| - while (view) { |
| - if (view->HasViewRoot()) |
| - return true; |
| - view = view->parent_; |
| - } |
| - return HasViewRootInSubtree(); |
| -} |
| - |
| -bool ViewAndroid::HasViewRootInSubtree() { |
| - if (HasViewRoot()) |
| - return true; |
| - for (auto& child : children_) { |
| - if (child->HasViewRootInSubtree()) |
| - return true; |
| - } |
| - return false; |
| +ViewAndroid* ViewAndroid::GetViewRoot() { |
| + return parent_ ? parent_->GetViewRoot() : nullptr; |
| } |
| bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext, |
| @@ -243,7 +200,7 @@ void ViewAndroid::UpdateLayerBounds() { |
| layer_->SetBounds(GetPhysicalBackingSize()); |
| } |
| -void ViewAndroid::OnPhysicalBackingSizeChanged(int width, int height) { |
| +void ViewAndroid::OnPhysicalBackingSizeChangedInternal(int width, int height) { |
| if (width == physical_width_pix_ && height == physical_height_pix_) |
| return; |
| @@ -255,21 +212,6 @@ void ViewAndroid::OnPhysicalBackingSizeChanged(int width, int height) { |
| client_->OnPhysicalBackingSizeChanged(width, height); |
| for (auto& child : children_) |
| - child->OnPhysicalBackingSizeChanged(width, height); |
| + child->OnPhysicalBackingSizeChangedInternal(width, height); |
| } |
| - |
| -// static |
| -void OnPhysicalBackingSizeChanged(JNIEnv* env, |
| - const JavaParamRef<jclass>& jcaller, |
| - jlong native_view, |
| - int width, |
| - int height) { |
| - ViewAndroid* view_android = reinterpret_cast<ViewAndroid*>(native_view); |
| - view_android->OnPhysicalBackingSizeChanged(width, height); |
| -} |
| - |
| -bool RegisterViewRoot(JNIEnv* env) { |
| - return RegisterNativesImpl(env); |
| -} |
| - |
| } // namespace ui |