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

Unified Diff: ui/android/view_android.cc

Issue 2502763003: Introduce ViewRoot to forward input/view events to native (Closed)
Patch Set: lazy creation Created 4 years 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 side-by-side diff with in-line comments
Download patch
« ui/android/view_android.h ('K') | « ui/android/view_android.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/android/view_android.cc
diff --git a/ui/android/view_android.cc b/ui/android/view_android.cc
index 664758cd5304088709f1cd99bdb655bae764aadf..773a0242b31f757e2091c7680acff2c7da6b0291 100644
--- a/ui/android/view_android.cc
+++ b/ui/android/view_android.cc
@@ -9,12 +9,14 @@
#include "base/android/jni_android.h"
#include "cc/layers/layer.h"
#include "jni/ViewAndroidDelegate_jni.h"
+#include "ui/android/event_handler.h"
#include "ui/android/window_android.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
namespace ui {
+using base::android::JavaParamRef;
using base::android::JavaRef;
using base::android::ScopedJavaLocalRef;
@@ -68,12 +70,9 @@ ViewAndroid::ScopedAnchorView::view() const {
return view_.get(env);
}
-ViewAndroid::ViewAndroid(const JavaRef<jobject>& delegate)
- : parent_(nullptr)
- , delegate_(base::android::AttachCurrentThread(),
- delegate.obj()) {}
-
-ViewAndroid::ViewAndroid() : parent_(nullptr) {}
+ViewAndroid::ViewAndroid() : parent_(nullptr),
+ client_(nullptr),
+ handler_(nullptr) {}
ViewAndroid::~ViewAndroid() {
RemoveFromParent();
@@ -86,10 +85,21 @@ ViewAndroid::~ViewAndroid() {
}
void ViewAndroid::SetDelegate(const JavaRef<jobject>& delegate) {
+ // A ViewAndroid may have its own delegate or otherwise will
+ // use the next available parent's delegate.
JNIEnv* env = base::android::AttachCurrentThread();
delegate_ = JavaObjectWeakGlobalRef(env, delegate);
}
+EventHandler* ViewAndroid::GetEventHandler() {
+ if (!parent_ || parent_ == GetWindowAndroid()) {
boliu 2016/12/02 23:53:22 what is the second half of this condition checking
Jinsuk Kim 2016/12/05 11:07:44 In the tree WindowAndroid - ViewAndroid(1) - ViewA
boliu 2016/12/06 00:10:17 Ahh I see.. But for chrome (and other non-webview
Jinsuk Kim 2016/12/06 07:35:07 Addressed in the new patch.
+ if (!handler_)
+ handler_ = new EventHandler(this);
+ return handler_;
+ }
+ return parent_->GetEventHandler();
+}
+
void ViewAndroid::AddChild(ViewAndroid* child) {
DCHECK(child);
DCHECK(std::find(children_.begin(), children_.end(), child) ==
@@ -179,4 +189,22 @@ bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext,
jimage);
}
+gfx::Size ViewAndroid::GetPhysicalBackingSize() {
+ EventHandler* handler = GetEventHandler();
+ if (!handler)
+ return gfx::Size();
+ return gfx::Size(handler->GetPhysicalBackingSizeWidthPix(),
+ handler->GetPhysicalBackingSizeHeightPix());
+}
+
+bool ViewAndroid::OnPhysicalBackingSizeChanged(int width, int height) {
+ if (client_ && client_->OnPhysicalBackingSizeChanged(width, height))
+ return true;
+ for (auto it = children_.begin(); it != children_.end(); ++it) {
+ if ((*it)->OnPhysicalBackingSizeChanged(width, height))
+ return true;
+ }
+ return false;
+}
+
} // namespace ui
« ui/android/view_android.h ('K') | « ui/android/view_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698