Chromium Code Reviews| 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" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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(!SubtreeHasEventForwarder(child) || !ViewTreeHasEventForwarder(this)) |
| 119 << "Only one event handler is allowed."; | 119 << "Only one event handler is allowed."; |
| 120 | 120 |
| 121 // The new child goes to the top, which is the end of the list. | 121 // The new child goes to the top, which is the end of the list. |
| 122 children_.push_back(child); | 122 children_.push_back(child); |
| 123 if (child->parent_) | 123 if (child->parent_) |
| 124 child->RemoveFromParent(); | 124 child->RemoveFromParent(); |
| 125 child->parent_ = this; | 125 child->parent_ = this; |
| 126 child->OnPhysicalBackingSizeChanged(physical_size_); | |
| 126 } | 127 } |
| 127 | 128 |
| 128 // static | 129 // static |
| 129 bool ViewAndroid::ViewTreeHasEventForwarder(ViewAndroid* view) { | 130 bool ViewAndroid::ViewTreeHasEventForwarder(ViewAndroid* view) { |
| 130 ViewAndroid* v = view; | 131 ViewAndroid* v = view; |
| 131 do { | 132 do { |
| 132 if (v->has_event_forwarder()) | 133 if (v->has_event_forwarder()) |
| 133 return true; | 134 return true; |
| 134 v = v->parent_; | 135 v = v->parent_; |
| 135 } while (v); | 136 } while (v); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 | 221 |
| 221 return parent_ ? parent_->GetViewAndroidDelegate() : delegate; | 222 return parent_ ? parent_->GetViewAndroidDelegate() : delegate; |
| 222 } | 223 } |
| 223 | 224 |
| 224 cc::Layer* ViewAndroid::GetLayer() const { | 225 cc::Layer* ViewAndroid::GetLayer() const { |
| 225 return layer_.get(); | 226 return layer_.get(); |
| 226 } | 227 } |
| 227 | 228 |
| 228 void ViewAndroid::SetLayer(scoped_refptr<cc::Layer> layer) { | 229 void ViewAndroid::SetLayer(scoped_refptr<cc::Layer> layer) { |
| 229 layer_ = layer; | 230 layer_ = layer; |
| 231 UpdateLayerBounds(); | |
| 232 } | |
| 233 | |
| 234 void ViewAndroid::UpdateLayerBounds() { | |
|
Khushal
2017/05/04 00:01:22
I think the caller should update the size *if* the
Jinsuk Kim
2017/05/08 07:40:44
Sorry I don't get the suggestion made here. Would
Khushal
2017/05/08 17:55:37
Sorry, my point was that VA shouldn't need to do t
Jinsuk Kim
2017/05/10 06:05:27
Removed |UpdateLayerBounds()|
| |
| 235 if (layer_) | |
| 236 layer_->SetBounds(physical_size_); | |
| 230 } | 237 } |
| 231 | 238 |
| 232 void ViewAndroid::SetLayout(ViewAndroid::LayoutParams params) { | 239 void ViewAndroid::SetLayout(ViewAndroid::LayoutParams params) { |
| 233 layout_params_ = params; | 240 layout_params_ = params; |
| 234 } | 241 } |
| 235 | 242 |
| 236 bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext, | 243 bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext, |
| 237 const JavaRef<jobject>& jimage) { | 244 const JavaRef<jobject>& jimage) { |
| 238 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); | 245 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); |
| 239 if (delegate.is_null()) | 246 if (delegate.is_null()) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 } | 279 } |
| 273 | 280 |
| 274 int ViewAndroid::GetSystemWindowInsetBottom() { | 281 int ViewAndroid::GetSystemWindowInsetBottom() { |
| 275 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); | 282 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); |
| 276 if (delegate.is_null()) | 283 if (delegate.is_null()) |
| 277 return 0; | 284 return 0; |
| 278 JNIEnv* env = base::android::AttachCurrentThread(); | 285 JNIEnv* env = base::android::AttachCurrentThread(); |
| 279 return Java_ViewAndroidDelegate_getSystemWindowInsetBottom(env, delegate); | 286 return Java_ViewAndroidDelegate_getSystemWindowInsetBottom(env, delegate); |
| 280 } | 287 } |
| 281 | 288 |
| 289 void ViewAndroid::OnPhysicalBackingSizeChanged(const gfx::Size& size) { | |
|
Khushal
2017/05/04 00:01:22
Something still needs to poke RWHVA to send the up
Jinsuk Kim
2017/05/08 07:40:44
It was present in the earlier patches but removed
| |
| 290 if (physical_size_ == size) | |
| 291 return; | |
| 292 physical_size_ = size; | |
| 293 UpdateLayerBounds(); | |
| 294 | |
| 295 for (auto* child : children_) | |
| 296 child->OnPhysicalBackingSizeChanged(size); | |
| 297 } | |
| 298 | |
| 299 gfx::Size ViewAndroid::GetPhysicalBackingSize() { | |
| 300 return physical_size_; | |
| 301 } | |
| 302 | |
| 282 bool ViewAndroid::OnTouchEvent(const MotionEventAndroid& event, | 303 bool ViewAndroid::OnTouchEvent(const MotionEventAndroid& event, |
| 283 bool for_touch_handle) { | 304 bool for_touch_handle) { |
| 284 return HitTest( | 305 return HitTest( |
| 285 base::Bind(&ViewAndroid::SendTouchEventToClient, for_touch_handle), | 306 base::Bind(&ViewAndroid::SendTouchEventToClient, for_touch_handle), |
| 286 event); | 307 event); |
| 287 } | 308 } |
| 288 | 309 |
| 289 bool ViewAndroid::SendTouchEventToClient(bool for_touch_handle, | 310 bool ViewAndroid::SendTouchEventToClient(bool for_touch_handle, |
| 290 ViewClient* client, | 311 ViewClient* client, |
| 291 const MotionEventAndroid& event) { | 312 const MotionEventAndroid& event) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 matched = bound.Contains(e->GetX(0), e->GetY(0)); | 353 matched = bound.Contains(e->GetX(0), e->GetY(0)); |
| 333 } | 354 } |
| 334 if (matched && child->HitTest(send_to_client, *e)) | 355 if (matched && child->HitTest(send_to_client, *e)) |
| 335 return true; | 356 return true; |
| 336 } | 357 } |
| 337 } | 358 } |
| 338 return false; | 359 return false; |
| 339 } | 360 } |
| 340 | 361 |
| 341 } // namespace ui | 362 } // namespace ui |
| OLD | NEW |