Chromium Code Reviews| 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 d3eb700e397e68fa76a023d070bb60527eff508e..0d21e3c6a882204b597610779747ebe103c2ce56 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/java/java_bound_object.h" |
| #include "content/browser/android/java/java_bridge_dispatcher_host_manager.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" |
| @@ -551,9 +552,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; |
| } |
| @@ -600,26 +598,27 @@ void ContentViewCoreImpl::OnSelectionChanged(const std::string& text) { |
| Java_ContentViewCore_onSelectionChanged(env, obj.obj(), jtext.obj()); |
| } |
| -void ContentViewCoreImpl::OnSelectionBoundsChanged(const gfx::PointF& anchor, |
| - const gfx::PointF& focus, |
| - int anchor_dir, |
| - int focus_dir, |
| - bool is_anchor_visible, |
| - bool is_focus_visible) { |
| +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; |
| - Java_ContentViewCore_onSelectionBoundsChanged(env, |
| - obj.obj(), |
| - anchor.x(), |
| - anchor.y(), |
| - focus.x(), |
| - focus.y(), |
| - anchor_dir, |
| - focus_dir, |
| - is_anchor_visible, |
| - is_focus_visible); |
| + 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) { |
| @@ -785,7 +784,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); |
| } |
| @@ -796,6 +795,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 anchor = gfx::Point(start.x(), start.y()); |
| + gfx::Point focus = gfx::Point(end.x(), end.y()); |
| + if (anchor.x() == focus.x() && anchor.y() == focus.y()) |
|
cjhopman
2014/07/09 22:29:12
nit: if (anchor == focus) {
jdduke (slow)
2014/07/10 02:08:39
Done.
|
| + return; |
| + |
| + web_contents_->SelectRange(anchor, focus); |
| +} |
| + |
| void ContentViewCoreImpl::LoadUrl( |
| NavigationController::LoadURLParams& params) { |
| GetWebContents()->GetController().LoadURLWithParams(params); |
| @@ -984,6 +996,20 @@ jboolean ContentViewCoreImpl::OnTouchEvent(JNIEnv* env, |
| return rwhv->OnTouchEvent(event); |
| } |
| +jboolean ContentViewCoreImpl::OnTouchHandleEvent(JNIEnv* env, |
| + jobject obj, |
| + jobject motion_event) { |
| + RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); |
| + // Avoid synthesizing a touch event if it cannot be forwarded. |
| + if (!rwhv) |
| + return false; |
| + |
| + const bool recycle = false; |
| + MotionEventAndroid event(1.f / dpi_scale(), env, motion_event, recycle); |
| + |
| + return rwhv->OnTouchHandleEvent(event); |
| +} |
| + |
| float ContentViewCoreImpl::GetDpiScale() const { |
| return dpi_scale_; |
| } |
| @@ -1145,22 +1171,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) |
| @@ -1535,14 +1562,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); |