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

Unified Diff: ui/android/view_android.cc

Issue 2136373002: Make WindowAndroid a ViewAndroid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@view3
Patch Set: Make WindowAndroid a ViewAndroid Created 4 years, 5 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/view_android.h ('k') | ui/android/window_android.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/android/view_android.cc
diff --git a/ui/android/view_android.cc b/ui/android/view_android.cc
index 41a8c346bf21e9328e54d9af032f614280e6b214..b1ea3608998b81ce71032739ac0ee9da3c88367f 100644
--- a/ui/android/view_android.cc
+++ b/ui/android/view_android.cc
@@ -15,15 +15,13 @@ namespace ui {
using base::android::JavaRef;
-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_)
- child->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);
@@ -56,17 +58,9 @@ void ViewAndroid::RemoveChild(ViewAndroid* child) {
}
WindowAndroid* ViewAndroid::GetWindowAndroid() const {
- if (window_)
- return window_;
-
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())
« no previous file with comments | « ui/android/view_android.h ('k') | ui/android/window_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698