| Index: content/browser/android/content_view_core_impl.cc
|
| diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
|
| index 6dc7a5500de8cb81a23bf0e76374ee9bccc0528c..fd90312be6d7797732c12b24ac65fa5711157801 100644
|
| --- a/content/browser/android/content_view_core_impl.cc
|
| +++ b/content/browser/android/content_view_core_impl.cc
|
| @@ -55,6 +55,7 @@
|
| #include "jni/DragEvent_jni.h"
|
| #include "third_party/WebKit/public/platform/WebInputEvent.h"
|
| #include "ui/android/view_android.h"
|
| +#include "ui/android/view_root.h"
|
| #include "ui/android/window_android.h"
|
| #include "ui/base/clipboard/clipboard.h"
|
| #include "ui/base/ui_base_switches_util.h"
|
| @@ -230,12 +231,6 @@ ContentViewCoreImpl::ContentViewCoreImpl(
|
| dpi_scale_(dpi_scale),
|
| device_orientation_(0),
|
| accessibility_enabled_(false) {
|
| - GetViewAndroid()->SetLayer(cc::Layer::Create());
|
| - gfx::Size physical_size(
|
| - Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj),
|
| - Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj));
|
| - GetViewAndroid()->GetLayer()->SetBounds(physical_size);
|
| -
|
| // Currently, the only use case we have for overriding a user agent involves
|
| // spoofing a desktop Linux user agent for "Request desktop site".
|
| // Automatically set it for all WebContents so that it is available when a
|
| @@ -277,22 +272,23 @@ ContentViewCoreImpl::~ContentViewCoreImpl() {
|
| }
|
| }
|
|
|
| -void ContentViewCoreImpl::UpdateWindowAndroid(
|
| +void ContentViewCoreImpl::UpdateViewRoot(
|
| JNIEnv* env,
|
| const base::android::JavaParamRef<jobject>& obj,
|
| - jlong window_android) {
|
| + jlong view_root_ptr) {
|
| + ui::ViewRoot* view_root = reinterpret_cast<ui::ViewRoot*>(view_root_ptr);
|
| ui::ViewAndroid* view = GetViewAndroid();
|
| - ui::WindowAndroid* window =
|
| - reinterpret_cast<ui::WindowAndroid*>(window_android);
|
| - if (window == GetWindowAndroid())
|
| + if (view_root == view->GetViewRoot())
|
| return;
|
| - if (GetWindowAndroid()) {
|
| +
|
| + if (view->GetViewRoot()) {
|
| for (auto& observer : observer_list_)
|
| observer.OnDetachedFromWindow();
|
| view->RemoveFromParent();
|
| }
|
| - if (window) {
|
| - window->AddChild(view);
|
| +
|
| + if (view_root) {
|
| + view_root->AddChild(view);
|
| for (auto& observer : observer_list_)
|
| observer.OnAttachedToWindow();
|
| }
|
| @@ -892,78 +888,6 @@ void ContentViewCoreImpl::SendOrientationChangeEvent(
|
| }
|
| }
|
|
|
| -jboolean ContentViewCoreImpl::OnTouchEvent(
|
| - JNIEnv* env,
|
| - const JavaParamRef<jobject>& obj,
|
| - const JavaParamRef<jobject>& motion_event,
|
| - jlong time_ms,
|
| - jint android_action,
|
| - jint pointer_count,
|
| - jint history_size,
|
| - jint action_index,
|
| - jfloat pos_x_0,
|
| - jfloat pos_y_0,
|
| - jfloat pos_x_1,
|
| - jfloat pos_y_1,
|
| - jint pointer_id_0,
|
| - jint pointer_id_1,
|
| - jfloat touch_major_0,
|
| - jfloat touch_major_1,
|
| - jfloat touch_minor_0,
|
| - jfloat touch_minor_1,
|
| - jfloat orientation_0,
|
| - jfloat orientation_1,
|
| - jfloat tilt_0,
|
| - jfloat tilt_1,
|
| - jfloat raw_pos_x,
|
| - jfloat raw_pos_y,
|
| - jint android_tool_type_0,
|
| - jint android_tool_type_1,
|
| - jint android_button_state,
|
| - jint android_meta_state,
|
| - jboolean is_touch_handle_event) {
|
| - RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
|
| - // Avoid synthesizing a touch event if it cannot be forwarded.
|
| - if (!rwhv)
|
| - return false;
|
| -
|
| - MotionEventAndroid::Pointer pointer0(pointer_id_0,
|
| - pos_x_0,
|
| - pos_y_0,
|
| - touch_major_0,
|
| - touch_minor_0,
|
| - orientation_0,
|
| - tilt_0,
|
| - android_tool_type_0);
|
| - MotionEventAndroid::Pointer pointer1(pointer_id_1,
|
| - pos_x_1,
|
| - pos_y_1,
|
| - touch_major_1,
|
| - touch_minor_1,
|
| - orientation_1,
|
| - tilt_1,
|
| - android_tool_type_1);
|
| - MotionEventAndroid event(1.f / dpi_scale(),
|
| - env,
|
| - motion_event,
|
| - time_ms,
|
| - android_action,
|
| - pointer_count,
|
| - history_size,
|
| - action_index,
|
| - android_button_state,
|
| - android_meta_state,
|
| - raw_pos_x - pos_x_0,
|
| - raw_pos_y - pos_y_0,
|
| - &pointer0,
|
| - &pointer1);
|
| -
|
| - RecordToolTypeForActionDown(event);
|
| -
|
| - return is_touch_handle_event ? rwhv->OnTouchHandleEvent(event)
|
| - : rwhv->OnTouchEvent(event);
|
| -}
|
| -
|
| jboolean ContentViewCoreImpl::SendMouseEvent(
|
| JNIEnv* env,
|
| const JavaParamRef<jobject>& obj,
|
| @@ -1270,6 +1194,12 @@ void ContentViewCoreImpl::WasResized(JNIEnv* env,
|
| Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj));
|
| GetViewAndroid()->GetLayer()->SetBounds(physical_size);
|
|
|
| + gfx::Size view_size(GetViewSize());
|
| + // TODO(jinsukkim): Take top offset into account for adjusting y
|
| + // when refactoring content view.
|
| + GetViewAndroid()->SetBounds(gfx::Point(),
|
| + view_size.width(),
|
| + view_size.height());
|
| SendScreenRectsAndResizeWidget();
|
| }
|
|
|
| @@ -1442,6 +1372,26 @@ bool ContentViewCoreImpl::IsTouchDragDropEnabled(
|
| return switches::IsTouchDragDropEnabled();
|
| }
|
|
|
| +void ContentViewCoreImpl::MoveToFrontInViewHierarchy(
|
| + JNIEnv* env,
|
| + const base::android::JavaParamRef<jobject>& jobj) {
|
| + ui::ViewAndroid* view_android = GetViewAndroid();
|
| + ui::ViewRoot* view_root =
|
| + static_cast<ui::ViewRoot*>(view_android->GetViewRoot());
|
| + view_root->MoveToFront(view_android);
|
| +}
|
| +
|
| +void ContentViewCoreImpl::UpdateViewBounds(
|
| + JNIEnv* env,
|
| + const base::android::JavaParamRef<jobject>& jobj,
|
| + int x,
|
| + int y,
|
| + int width,
|
| + int height) {
|
| + ui::ViewAndroid* view_android = GetViewAndroid();
|
| + view_android->SetBounds(gfx::Point(x, y), width, height);
|
| +}
|
| +
|
| void ContentViewCoreImpl::OnDragEvent(
|
| JNIEnv* env,
|
| const base::android::JavaParamRef<jobject>& jobj,
|
| @@ -1550,7 +1500,7 @@ jlong Init(JNIEnv* env,
|
| const JavaParamRef<jobject>& obj,
|
| const JavaParamRef<jobject>& jweb_contents,
|
| const JavaParamRef<jobject>& jview_android_delegate,
|
| - jlong jwindow_android,
|
| + jlong view_root_ptr,
|
| jfloat dipScale,
|
| const JavaParamRef<jobject>& retained_objects_set) {
|
| WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(
|
| @@ -1559,11 +1509,14 @@ jlong Init(JNIEnv* env,
|
| "A ContentViewCoreImpl should be created with a valid WebContents.";
|
| ui::ViewAndroid* view_android = web_contents->GetView()->GetNativeView();
|
| view_android->SetDelegate(jview_android_delegate);
|
| + view_android->SetLayer(cc::Layer::Create());
|
| + gfx::Size physical_size(
|
| + Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj),
|
| + Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj));
|
| + view_android->GetLayer()->SetBounds(physical_size);
|
|
|
| - ui::WindowAndroid* window_android =
|
| - reinterpret_cast<ui::WindowAndroid*>(jwindow_android);
|
| - DCHECK(window_android);
|
| - window_android->AddChild(view_android);
|
| + ui::ViewRoot* view_root = reinterpret_cast<ui::ViewRoot*>(view_root_ptr);
|
| + view_root->AddChild(view_android);
|
|
|
| // TODO: pass dipScale.
|
| ContentViewCoreImpl* view = new ContentViewCoreImpl(
|
|
|