Index: ui/android/view_android.cc |
diff --git a/ui/android/view_android.cc b/ui/android/view_android.cc |
index 3771c37282d3359e8febec8ebcbb99db1b53a260..32072295dc4996637c82c645afc957af09b522cf 100644 |
--- a/ui/android/view_android.cc |
+++ b/ui/android/view_android.cc |
@@ -15,15 +15,13 @@ using base::android::AttachCurrentThread; |
using base::android::JavaRef; |
using base::android::ScopedJavaLocalRef; |
-ViewAndroid::ViewAndroid(const JavaRef<jobject>& delegate, |
- WindowAndroid* root_window) |
- : parent_(nullptr), window_(root_window), delegate_(delegate) {} |
+ViewAndroid::ViewAndroid(const JavaRef<jobject>& delegate) |
+ : parent_(nullptr), delegate_(delegate) {} |
-ViewAndroid::ViewAndroid() : parent_(nullptr), window_(nullptr) {} |
+ViewAndroid::ViewAndroid() : parent_(nullptr) {} |
ViewAndroid::~ViewAndroid() { |
- if (parent_) |
- parent_->RemoveChild(this); |
+ RemoveFromParent(); |
for (std::list<ViewAndroid*>::iterator it = children_.begin(); |
it != children_.end(); it++) { |
@@ -34,16 +32,20 @@ ViewAndroid::~ViewAndroid() { |
void ViewAndroid::AddChild(ViewAndroid* child) { |
DCHECK(child); |
- DCHECK(child->window_ == nullptr) << "Children shouldn't have a root window"; |
DCHECK(std::find(children_.begin(), children_.end(), child) == |
children_.end()); |
children_.push_back(child); |
if (child->parent_) |
- parent_->RemoveChild(child); |
+ child->RemoveFromParent(); |
child->parent_ = this; |
} |
+void ViewAndroid::RemoveFromParent() { |
+ if (parent_) |
+ parent_->RemoveChild(this); |
+} |
+ |
void ViewAndroid::RemoveChild(ViewAndroid* child) { |
DCHECK(child); |
DCHECK_EQ(child->parent_, this); |
@@ -55,18 +57,10 @@ void ViewAndroid::RemoveChild(ViewAndroid* child) { |
child->parent_ = nullptr; |
} |
-WindowAndroid* ViewAndroid::GetWindowAndroid() const { |
- if (window_) |
- return window_; |
- |
+WindowAndroid* ViewAndroid::GetWindowAndroid() { |
Yusuf
2016/07/13 19:54:36
GetWindowAndroid will always return null if this i
no sievers
2016/07/13 23:32:12
It will return only non-null if the tree actually
|
return parent_ ? parent_->GetWindowAndroid() : nullptr; |
} |
-void ViewAndroid::SetWindowAndroid(WindowAndroid* root_window) { |
- window_ = root_window; |
- DCHECK(parent_ == nullptr) << "Children shouldn't have a root window"; |
-} |
- |
const JavaRef<jobject>& ViewAndroid::GetViewAndroidDelegate() |
const { |
if (!delegate_.is_null()) |