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

Side by Side Diff: ui/android/view_android.cc

Issue 2147853002: ui: Correctly add children for the ViewAndroid tree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/android/view_android.h" 5 #include "ui/android/view_android.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "cc/layers/layer.h" 10 #include "cc/layers/layer.h"
(...skipping 22 matching lines...) Expand all
33 } 33 }
34 34
35 void ViewAndroid::AddChild(ViewAndroid* child) { 35 void ViewAndroid::AddChild(ViewAndroid* child) {
36 DCHECK(child); 36 DCHECK(child);
37 DCHECK(child->window_ == nullptr) << "Children shouldn't have a root window"; 37 DCHECK(child->window_ == nullptr) << "Children shouldn't have a root window";
38 DCHECK(std::find(children_.begin(), children_.end(), child) == 38 DCHECK(std::find(children_.begin(), children_.end(), child) ==
39 children_.end()); 39 children_.end());
40 40
41 children_.push_back(child); 41 children_.push_back(child);
42 if (child->parent_) 42 if (child->parent_)
43 parent_->RemoveChild(child); 43 child->parent_->RemoveChild(child);
44 child->parent_ = this; 44 child->parent_ = this;
45 } 45 }
46 46
47 void ViewAndroid::RemoveChild(ViewAndroid* child) { 47 void ViewAndroid::RemoveChild(ViewAndroid* child) {
48 DCHECK(child); 48 DCHECK(child);
49 DCHECK_EQ(child->parent_, this); 49 DCHECK_EQ(child->parent_, this);
50 50
51 std::list<ViewAndroid*>::iterator it = 51 std::list<ViewAndroid*>::iterator it =
52 std::find(children_.begin(), children_.end(), child); 52 std::find(children_.begin(), children_.end(), child);
53 DCHECK(it != children_.end()); 53 DCHECK(it != children_.end());
(...skipping 23 matching lines...) Expand all
77 77
78 cc::Layer* ViewAndroid::GetLayer() const { 78 cc::Layer* ViewAndroid::GetLayer() const {
79 return layer_.get(); 79 return layer_.get();
80 } 80 }
81 81
82 void ViewAndroid::SetLayer(scoped_refptr<cc::Layer> layer) { 82 void ViewAndroid::SetLayer(scoped_refptr<cc::Layer> layer) {
83 layer_ = layer; 83 layer_ = layer;
84 } 84 }
85 85
86 } // namespace ui 86 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698