OLD | NEW |
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" |
11 #include "base/containers/adapters.h" | 11 #include "base/containers/adapters.h" |
| 12 #include "base/stl_util.h" |
12 #include "cc/layers/layer.h" | 13 #include "cc/layers/layer.h" |
13 #include "jni/ViewAndroidDelegate_jni.h" | 14 #include "jni/ViewAndroidDelegate_jni.h" |
14 #include "ui/android/event_forwarder.h" | 15 #include "ui/android/event_forwarder.h" |
15 #include "ui/android/view_client.h" | 16 #include "ui/android/view_client.h" |
16 #include "ui/android/window_android.h" | 17 #include "ui/android/window_android.h" |
17 #include "ui/base/layout.h" | 18 #include "ui/base/layout.h" |
18 #include "ui/events/android/drag_event_android.h" | 19 #include "ui/events/android/drag_event_android.h" |
19 #include "ui/events/android/motion_event_android.h" | 20 #include "ui/events/android/motion_event_android.h" |
20 #include "url/gurl.h" | 21 #include "url/gurl.h" |
21 | 22 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 << "The view tree path already has an event forwarder."; | 110 << "The view tree path already has an event forwarder."; |
110 DCHECK(!SubtreeHasEventForwarder(this)) | 111 DCHECK(!SubtreeHasEventForwarder(this)) |
111 << "The view tree path already has an event forwarder."; | 112 << "The view tree path already has an event forwarder."; |
112 event_forwarder_.reset(new EventForwarder(this)); | 113 event_forwarder_.reset(new EventForwarder(this)); |
113 } | 114 } |
114 return event_forwarder_->GetJavaObject(); | 115 return event_forwarder_->GetJavaObject(); |
115 } | 116 } |
116 | 117 |
117 void ViewAndroid::AddChild(ViewAndroid* child) { | 118 void ViewAndroid::AddChild(ViewAndroid* child) { |
118 DCHECK(child); | 119 DCHECK(child); |
119 DCHECK(std::find(children_.begin(), children_.end(), child) == | 120 DCHECK(!base::ContainsValue(children_, child)); |
120 children_.end()); | |
121 DCHECK(!RootPathHasEventForwarder(this) || !SubtreeHasEventForwarder(child)) | 121 DCHECK(!RootPathHasEventForwarder(this) || !SubtreeHasEventForwarder(child)) |
122 << "Some view tree path will have more than one event forwarder " | 122 << "Some view tree path will have more than one event forwarder " |
123 "if the child is added."; | 123 "if the child is added."; |
124 | 124 |
125 // The new child goes to the top, which is the end of the list. | 125 // The new child goes to the top, which is the end of the list. |
126 children_.push_back(child); | 126 children_.push_back(child); |
127 if (child->parent_) | 127 if (child->parent_) |
128 child->RemoveFromParent(); | 128 child->RemoveFromParent(); |
129 child->parent_ = this; | 129 child->parent_ = this; |
130 | 130 |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 matched = bound.Contains(int_point); | 380 matched = bound.Contains(int_point); |
381 } | 381 } |
382 if (matched && child->HitTest(send_to_client, event, offset_point)) | 382 if (matched && child->HitTest(send_to_client, event, offset_point)) |
383 return true; | 383 return true; |
384 } | 384 } |
385 } | 385 } |
386 return false; | 386 return false; |
387 } | 387 } |
388 | 388 |
389 } // namespace ui | 389 } // namespace ui |
OLD | NEW |