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 08051f5dfb6acc9fca324492f6ea911aef8f6b6f..6876ccb24fb67a2b26a5c7abd6006684a234979e 100644 |
--- a/content/browser/android/content_view_core_impl.cc |
+++ b/content/browser/android/content_view_core_impl.cc |
@@ -22,6 +22,7 @@ |
#include "content/browser/android/interstitial_page_delegate_android.h" |
#include "content/browser/android/java/gin_java_bridge_dispatcher_host.h" |
#include "content/browser/android/load_url_params.h" |
+#include "content/browser/android/popup_touch_handle_drawable.h" |
#include "content/browser/frame_host/interstitial_page_impl.h" |
#include "content/browser/frame_host/navigation_controller_impl.h" |
#include "content/browser/frame_host/navigation_entry_impl.h" |
@@ -541,9 +542,6 @@ void ContentViewCoreImpl::OnGestureEventAck(const blink::WebGestureEvent& event, |
event.x * dpi_scale(), |
event.y * dpi_scale()); |
break; |
- case WebInputEvent::GestureDoubleTap: |
- Java_ContentViewCore_onDoubleTapEventAck(env, j_obj.obj()); |
- break; |
default: |
break; |
} |
@@ -590,22 +588,27 @@ void ContentViewCoreImpl::OnSelectionChanged(const std::string& text) { |
Java_ContentViewCore_onSelectionChanged(env, obj.obj(), jtext.obj()); |
} |
-void ContentViewCoreImpl::OnSelectionBoundsChanged( |
- const ViewHostMsg_SelectionBounds_Params& params) { |
+void ContentViewCoreImpl::OnSelectionEvent(SelectionEventType event, |
+ const gfx::PointF& position) { |
JNIEnv* env = AttachCurrentThread(); |
- ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
- if (obj.is_null()) |
+ ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
+ if (j_obj.is_null()) |
return; |
- ScopedJavaLocalRef<jobject> anchor_rect_dip( |
- CreateJavaRect(env, params.anchor_rect)); |
- ScopedJavaLocalRef<jobject> focus_rect_dip( |
- CreateJavaRect(env, params.focus_rect)); |
- Java_ContentViewCore_onSelectionBoundsChanged(env, obj.obj(), |
- anchor_rect_dip.obj(), |
- params.anchor_dir, |
- focus_rect_dip.obj(), |
- params.focus_dir, |
- params.is_anchor_first); |
+ Java_ContentViewCore_onSelectionEvent( |
+ env, j_obj.obj(), event, position.x(), position.y()); |
+} |
+ |
+scoped_ptr<TouchHandleDrawable> |
+ContentViewCoreImpl::CreatePopupTouchHandleDrawable() { |
+ JNIEnv* env = AttachCurrentThread(); |
+ ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
+ if (obj.is_null()) { |
+ NOTREACHED(); |
+ return scoped_ptr<TouchHandleDrawable>(); |
+ } |
+ return scoped_ptr<TouchHandleDrawable>(new PopupTouchHandleDrawable( |
+ Java_ContentViewCore_createPopupTouchHandleDrawable(env, obj.obj()), |
+ dpi_scale_)); |
} |
void ContentViewCoreImpl::ShowPastePopup(int x_dip, int y_dip) { |
@@ -771,7 +774,7 @@ float ContentViewCoreImpl::GetOverdrawBottomHeightDip() const { |
} |
void ContentViewCoreImpl::AttachLayer(scoped_refptr<cc::Layer> layer) { |
- root_layer_->AddChild(layer); |
+ root_layer_->InsertChild(layer, 0); |
root_layer_->SetIsDrawable(false); |
} |
@@ -782,6 +785,19 @@ void ContentViewCoreImpl::RemoveLayer(scoped_refptr<cc::Layer> layer) { |
root_layer_->SetIsDrawable(true); |
} |
+void ContentViewCoreImpl::SelectBetweenCoordinates(const gfx::PointF& start, |
+ const gfx::PointF& end) { |
+ if (!web_contents_) |
+ return; |
+ |
+ gfx::Point start_point = gfx::Point(start.x(), start.y()); |
+ gfx::Point end_point = gfx::Point(end.x(), end.y()); |
+ if (start_point == end_point) |
+ return; |
+ |
+ web_contents_->SelectRange(start_point, end_point); |
+} |
+ |
void ContentViewCoreImpl::LoadUrl( |
NavigationController::LoadURLParams& params) { |
GetWebContents()->GetController().LoadURLWithParams(params); |
@@ -935,7 +951,8 @@ jboolean ContentViewCoreImpl::OnTouchEvent(JNIEnv* env, |
jfloat raw_pos_y, |
jint android_tool_type_0, |
jint android_tool_type_1, |
- jint android_button_state) { |
+ jint android_button_state, |
+ jboolean is_touch_handle_event) { |
RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); |
// Avoid synthesizing a touch event if it cannot be forwarded. |
if (!rwhv) |
@@ -963,7 +980,8 @@ jboolean ContentViewCoreImpl::OnTouchEvent(JNIEnv* env, |
android_tool_type_1, |
android_button_state); |
- return rwhv->OnTouchEvent(event); |
+ return is_touch_handle_event ? rwhv->OnTouchHandleEvent(event) |
+ : rwhv->OnTouchEvent(event); |
} |
float ContentViewCoreImpl::GetDpiScale() const { |
@@ -1127,22 +1145,23 @@ void ContentViewCoreImpl::PinchBy(JNIEnv* env, jobject obj, jlong time_ms, |
void ContentViewCoreImpl::SelectBetweenCoordinates(JNIEnv* env, jobject obj, |
jfloat x1, jfloat y1, |
jfloat x2, jfloat y2) { |
- if (!web_contents_) |
- return; |
- |
- web_contents_->SelectRange( |
- gfx::Point(x1 / dpi_scale(), y1 / dpi_scale()), |
- gfx::Point(x2 / dpi_scale(), y2 / dpi_scale())); |
+ SelectBetweenCoordinates(gfx::PointF(x1 / dpi_scale(), y1 / dpi_scale()), |
+ gfx::PointF(x2 / dpi_scale(), y2 / dpi_scale())); |
} |
void ContentViewCoreImpl::MoveCaret(JNIEnv* env, jobject obj, |
jfloat x, jfloat y) { |
if (GetRenderWidgetHostViewAndroid()) { |
GetRenderWidgetHostViewAndroid()->MoveCaret( |
- gfx::Point(x / dpi_scale(), y / dpi_scale())); |
+ gfx::Point(x / dpi_scale_, y / dpi_scale_)); |
} |
} |
+void ContentViewCoreImpl::HideTextHandles(JNIEnv* env, jobject obj) { |
+ if (GetRenderWidgetHostViewAndroid()) |
+ GetRenderWidgetHostViewAndroid()->HideTextHandles(); |
+} |
+ |
void ContentViewCoreImpl::ResetGestureDetection(JNIEnv* env, jobject obj) { |
RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); |
if (rwhv) |
@@ -1425,14 +1444,6 @@ void ContentViewCoreImpl::SetAccessibilityEnabled(JNIEnv* env, jobject obj, |
SetAccessibilityEnabledInternal(enabled); |
} |
-void ContentViewCoreImpl::ShowSelectionHandlesAutomatically() const { |
- JNIEnv* env = AttachCurrentThread(); |
- ScopedJavaLocalRef<jobject> obj(java_ref_.get(env)); |
- if (obj.is_null()) |
- return; |
- Java_ContentViewCore_showSelectionHandlesAutomatically(env, obj.obj()); |
-} |
- |
bool ContentViewCoreImpl::IsFullscreenRequiredForOrientationLock() const { |
JNIEnv* env = AttachCurrentThread(); |
ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |