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

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

Issue 2842693005: Store physical backing size in ViewAndroid (Closed)
Patch Set: no UpdateLayerBounds 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
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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 } 273 }
273 274
274 int ViewAndroid::GetSystemWindowInsetBottom() { 275 int ViewAndroid::GetSystemWindowInsetBottom() {
275 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); 276 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
276 if (delegate.is_null()) 277 if (delegate.is_null())
277 return 0; 278 return 0;
278 JNIEnv* env = base::android::AttachCurrentThread(); 279 JNIEnv* env = base::android::AttachCurrentThread();
279 return Java_ViewAndroidDelegate_getSystemWindowInsetBottom(env, delegate); 280 return Java_ViewAndroidDelegate_getSystemWindowInsetBottom(env, delegate);
280 } 281 }
281 282
283 void ViewAndroid::OnPhysicalBackingSizeChanged(const gfx::Size& size) {
284 if (physical_size_ == size)
285 return;
286 physical_size_ = size;
287 client_->OnPhysicalBackingSizeChanged();
288
289 for (auto* child : children_)
290 child->OnPhysicalBackingSizeChanged(size);
291 }
292
293 gfx::Size ViewAndroid::GetPhysicalBackingSize() {
294 return physical_size_;
295 }
296
282 bool ViewAndroid::OnTouchEvent(const MotionEventAndroid& event, 297 bool ViewAndroid::OnTouchEvent(const MotionEventAndroid& event,
283 bool for_touch_handle) { 298 bool for_touch_handle) {
284 return HitTest( 299 return HitTest(
285 base::Bind(&ViewAndroid::SendTouchEventToClient, for_touch_handle), 300 base::Bind(&ViewAndroid::SendTouchEventToClient, for_touch_handle),
286 event); 301 event);
287 } 302 }
288 303
289 bool ViewAndroid::SendTouchEventToClient(bool for_touch_handle, 304 bool ViewAndroid::SendTouchEventToClient(bool for_touch_handle,
290 ViewClient* client, 305 ViewClient* client,
291 const MotionEventAndroid& event) { 306 const MotionEventAndroid& event) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 matched = bound.Contains(e->GetX(0), e->GetY(0)); 347 matched = bound.Contains(e->GetX(0), e->GetY(0));
333 } 348 }
334 if (matched && child->HitTest(send_to_client, *e)) 349 if (matched && child->HitTest(send_to_client, *e))
335 return true; 350 return true;
336 } 351 }
337 } 352 }
338 return false; 353 return false;
339 } 354 }
340 355
341 } // namespace ui 356 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698