From c0e8a21aaaca44157437967e1107c53535aa723b Mon Sep 17 00:00:00 2001 From: Antonio Gomes Date: Wed, 16 Dec 2015 15:35:02 -0400 Subject: [PATCH] Disambiguation popup should send tap gestures not mouse events When disambiguation popup is shown, and user clicks on its content, RWHVEfl synthesizes and sends mouse down/up events to the renderer. Mouse events are different from a regular touch input, and various touch-oriented features are not triggered: - zoom to focused editable node; - insert large handle on tap. Patch switches from the disambiguation popup handling logic from synthesized mouse events to tap gestures. Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=15359 Reviewed by: a1.gomes, g.czajkowski Change-Id: I291e107634c4cc56c8512705bcf05ecbcfd81f19 Signed-off-by: Antonio Gomes --- .../renderer_host/disambiguation_popup_efl.cc | 7 +++-- .../renderer_host/render_widget_host_view_efl.cc | 31 ++++++++++++++++------ .../renderer_host/render_widget_host_view_efl.h | 2 ++ .../browser/renderer_host/web_event_factory_efl.cc | 22 +++++++++++++++ .../browser/renderer_host/web_event_factory_efl.h | 4 +++ 5 files changed, 54 insertions(+), 12 deletions(-) diff --git a/tizen_src/chromium_impl/content/browser/renderer_host/disambiguation_popup_efl.cc b/tizen_src/chromium_impl/content/browser/renderer_host/disambiguation_popup_efl.cc index e977478..3e8e3f6 100644 --- a/tizen_src/chromium_impl/content/browser/renderer_host/disambiguation_popup_efl.cc +++ b/tizen_src/chromium_impl/content/browser/renderer_host/disambiguation_popup_efl.cc @@ -89,8 +89,7 @@ DisambiguationPopupEfl::~DisambiguationPopupEfl() { void DisambiguationPopupEfl::Show(const gfx::Rect& target, const SkBitmap& display_image) { - Dismiss(); - + DCHECK(!IsVisible()); target_rect_ = target; if (content_image_) @@ -130,8 +129,8 @@ void DisambiguationPopupEfl::Show(const gfx::Rect& target, } void DisambiguationPopupEfl::Dismiss() { - if (!IsVisible()) - return; + DCHECK(IsVisible()); + rwhv_->DisambiguationPopupDismissed(); target_rect_ = gfx::Rect(); elm_ctxpopup_dismiss(popup_); diff --git a/tizen_src/chromium_impl/content/browser/renderer_host/render_widget_host_view_efl.cc b/tizen_src/chromium_impl/content/browser/renderer_host/render_widget_host_view_efl.cc index 378dc0a..c65a42f 100755 --- a/tizen_src/chromium_impl/content/browser/renderer_host/render_widget_host_view_efl.cc +++ b/tizen_src/chromium_impl/content/browser/renderer_host/render_widget_host_view_efl.cc @@ -194,6 +194,7 @@ RenderWidgetHostViewEfl::RenderWidgetHostViewEfl(RenderWidgetHost* widget, surface_id_(0), is_modifier_key_(false), touch_events_enabled_(false), + handling_disambiguation_popup_gesture_(false), web_contents_(web_contents), compositor_(NULL), root_layer_(new ui::Layer(ui::LAYER_SOLID_COLOR)), @@ -982,24 +983,37 @@ void RenderWidgetHostViewEfl::SelectClosestWord(const gfx::Point& touch_point) { } void RenderWidgetHostViewEfl::ShowDisambiguationPopup(const gfx::Rect& rect_pixels, const SkBitmap& zoomed_bitmap) { + handling_disambiguation_popup_gesture_ = true; if (!disambiguation_popup_) disambiguation_popup_.reset(new DisambiguationPopupEfl(content_image_, this)); disambiguation_popup_->Show(rect_pixels, zoomed_bitmap); } +void RenderWidgetHostViewEfl::DisambiguationPopupDismissed() { + handling_disambiguation_popup_gesture_ = false; +} + void RenderWidgetHostViewEfl::HandleDisambiguationPopupMouseDownEvent( Evas_Event_Mouse_Down* evas_event) { - blink::WebMouseEvent event = MakeWebMouseEvent( - blink::WebInputEvent::MouseDown, content_image_, evas_event); - host_->ForwardMouseEvent(event); + blink::WebGestureEvent tap_down_event = MakeGestureEvent( + blink::WebInputEvent::GestureTapDown, + content_image_, + evas_event); + tap_down_event.data.tap.width = 0; + tap_down_event.data.tap.tapCount = 1; + SendGestureEvent(tap_down_event); } void RenderWidgetHostViewEfl::HandleDisambiguationPopupMouseUpEvent( Evas_Event_Mouse_Up* evas_event) { - blink::WebMouseEvent event = MakeWebMouseEvent( - blink::WebInputEvent::MouseUp, content_image_, evas_event); - host_->ForwardMouseEvent(event); + blink::WebGestureEvent tap_event = MakeGestureEvent( + blink::WebInputEvent::GestureTap, + content_image_, + evas_event); + tap_event.data.tap.width = 0; + tap_event.data.tap.tapCount = 1; + SendGestureEvent(tap_event); } void RenderWidgetHostViewEfl::LockCompositingSurface() { @@ -1685,8 +1699,9 @@ void RenderWidgetHostViewEfl::HandleGesture( wcve->HandleZoomGesture(event); } - if (event.type == blink::WebInputEvent::GestureTap || - event.type == blink::WebInputEvent::GestureTapCancel) { + if ((event.type == blink::WebInputEvent::GestureTap || + event.type == blink::WebInputEvent::GestureTapCancel) && + !handling_disambiguation_popup_gesture_) { float size = 32.0f; // Default value #if defined(OS_TIZEN_MOBILE) size = elm_config_finger_size_get() / device_scale_factor_; diff --git a/tizen_src/chromium_impl/content/browser/renderer_host/render_widget_host_view_efl.h b/tizen_src/chromium_impl/content/browser/renderer_host/render_widget_host_view_efl.h index b136690..0fcfdbb 100755 --- a/tizen_src/chromium_impl/content/browser/renderer_host/render_widget_host_view_efl.h +++ b/tizen_src/chromium_impl/content/browser/renderer_host/render_widget_host_view_efl.h @@ -170,6 +170,7 @@ class CONTENT_EXPORT RenderWidgetHostViewEfl void ShowDisambiguationPopup(const gfx::Rect& rect_pixels, const SkBitmap& zoomed_bitmap) override; + void DisambiguationPopupDismissed(); void HandleDisambiguationPopupMouseDownEvent(Evas_Event_Mouse_Down*); void HandleDisambiguationPopupMouseUpEvent(Evas_Event_Mouse_Up*); void LockCompositingSurface() override; @@ -409,6 +410,7 @@ class CONTENT_EXPORT RenderWidgetHostViewEfl GLuint index_buffer_obj_; bool touch_events_enabled_; + bool handling_disambiguation_popup_gesture_; // The last scroll offset of the view. gfx::Vector2dF last_scroll_offset_; diff --git a/tizen_src/chromium_impl/content/browser/renderer_host/web_event_factory_efl.cc b/tizen_src/chromium_impl/content/browser/renderer_host/web_event_factory_efl.cc index 4e62ecd..180abce 100644 --- a/tizen_src/chromium_impl/content/browser/renderer_host/web_event_factory_efl.cc +++ b/tizen_src/chromium_impl/content/browser/renderer_host/web_event_factory_efl.cc @@ -540,4 +540,26 @@ ui::TouchEvent MakeTouchEvent(Evas_Coord_Point pt, gfx::Point(pt.x / scale, pt.y / scale), id, event_timestamp); } +template WebGestureEvent MakeGestureEvent( + WebInputEvent::Type type, Evas_Object*, const Evas_Event_Mouse_Down* ev); +template WebGestureEvent MakeGestureEvent( + WebInputEvent::Type type, Evas_Object*, const Evas_Event_Mouse_Up* ev); + +template +WebGestureEvent MakeGestureEvent(WebInputEvent::Type type, + Evas_Object* view, const EVT* ev) { + + WebGestureEvent event; + event.timeStampSeconds = ev->timestamp / 1000; + event.type = type; + event.sourceDevice = WebGestureDeviceTouchscreen; + + const float sf = GetDeviceScaleFactor(); + event.x = ev->canvas.x / sf; + event.y = ev->canvas.y / sf; + + TranslateEvasCoordToWebKitCoord(view, event.x, event.y); + return event; +} + } diff --git a/tizen_src/chromium_impl/content/browser/renderer_host/web_event_factory_efl.h b/tizen_src/chromium_impl/content/browser/renderer_host/web_event_factory_efl.h index 5f3a2f8..16965e9 100644 --- a/tizen_src/chromium_impl/content/browser/renderer_host/web_event_factory_efl.h +++ b/tizen_src/chromium_impl/content/browser/renderer_host/web_event_factory_efl.h @@ -36,6 +36,10 @@ CONTENT_EXPORT ui::TouchEvent MakeTouchEvent(Evas_Coord_Point pt, int id, Evas_Object* view, unsigned int timestamp = 0); +template +blink::WebGestureEvent MakeGestureEvent(blink::WebInputEvent::Type type, + Evas_Object* view, const EVT* event); + } // namespace content #endif -- 2.7.4