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

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

Issue 2861413002: Refined DCHECK preventing multiple event forwarders in VA tree path (Closed)
Patch Set: fix tests Created 3 years, 7 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 | ui/android/view_android_unittests.cc » ('j') | 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 "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 << "Root of the ViewAndroid can have at most one handler."; 108 << "Root of the ViewAndroid can have at most one handler.";
109 event_forwarder_.reset(new EventForwarder(this)); 109 event_forwarder_.reset(new EventForwarder(this));
110 } 110 }
111 return event_forwarder_->GetJavaObject(); 111 return event_forwarder_->GetJavaObject();
112 } 112 }
113 113
114 void ViewAndroid::AddChild(ViewAndroid* child) { 114 void ViewAndroid::AddChild(ViewAndroid* child) {
115 DCHECK(child); 115 DCHECK(child);
116 DCHECK(std::find(children_.begin(), children_.end(), child) == 116 DCHECK(std::find(children_.begin(), children_.end(), child) ==
117 children_.end()); 117 children_.end());
118 DCHECK(!SubtreeHasEventForwarder(child) || !ViewTreeHasEventForwarder(this)) 118 DCHECK(GetWindowAndroid() == this || !SubtreeHasEventForwarder(child) ||
119 !ViewTreeHasEventForwarder(this))
boliu 2017/05/08 16:54:55 the previous check is too strict. check should be
Jinsuk Kim 2017/05/10 01:42:10 Updated the DCHECK to do what's actually intended.
119 << "Only one event handler is allowed."; 120 << "Only one event handler is allowed.";
120 121
121 // The new child goes to the top, which is the end of the list. 122 // The new child goes to the top, which is the end of the list.
122 children_.push_back(child); 123 children_.push_back(child);
123 if (child->parent_) 124 if (child->parent_)
124 child->RemoveFromParent(); 125 child->RemoveFromParent();
125 child->parent_ = this; 126 child->parent_ = this;
126 } 127 }
127 128
128 // static 129 // static
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 matched = bound.Contains(e->GetX(0), e->GetY(0)); 333 matched = bound.Contains(e->GetX(0), e->GetY(0));
333 } 334 }
334 if (matched && child->HitTest(send_to_client, *e)) 335 if (matched && child->HitTest(send_to_client, *e))
335 return true; 336 return true;
336 } 337 }
337 } 338 }
338 return false; 339 return false;
339 } 340 }
340 341
341 } // namespace ui 342 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/android/view_android_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698