Move away from AsyncHitTest messages to handle tap
authorAntonio Gomes <a1.gomes@samsung.com>
Fri, 28 Aug 2015 18:28:47 +0000 (14:28 -0400)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
We have an existing mechanism to post-handle tap events.
This mechanism lives in render_view_observer_efl.cc
and is used by the renderer to inform the browser to
play sound in response to clicking a link.
In order to have the context information, an extra hit
test is performed on the renderer side, and browser gets
notified by a message.

In order to eliminate the last client of the hit test
ping-pong messaging in the text selection code, patch
extends the mechanism described above to provided the
information needed by text selection (read is_content_editable),
in addition to the current link information.

Original beta/m42 patch:
- http://165.213.202.130/gerrit/#/c/86093/ , reviewed by
Janusz Majnert, Arnaud Renevier.

Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=6663

Reviewed by: Janusz Majnert

Change-Id: I0b5d7f0b0d457bd89e911a2768ce0c480f331f9b
Signed-off-by: Antonio Gomes <a1.gomes@samsung.com>
tizen_src/chromium_impl/content/browser/selection/selection_controller_efl.cc
tizen_src/chromium_impl/content/browser/selection/selection_controller_efl.h
tizen_src/ewk/efl_integration/browser/web_view_browser_message_filter.cc
tizen_src/ewk/efl_integration/common/render_messages_ewk.h
tizen_src/ewk/efl_integration/eweb_view.cc
tizen_src/ewk/efl_integration/eweb_view.h
tizen_src/ewk/efl_integration/renderer/render_view_observer_efl.cc

index e79d383..e5aaced 100644 (file)
@@ -672,11 +672,7 @@ void SelectionControllerEfl::HandlePostponedGesture(int x, int y, ui::EventType
         SetShowOnlyLargeHandle(true);
     }
     case ui::ET_GESTURE_SHOW_PRESS: {
-      RwhvAsyncRequestHitTestDataInternalCallback* cb =
-          new RwhvAsyncRequestHitTestDataInternalCallback(point,
-              &SelectionControllerEfl::HandleTapEvent);
-      // below call takes full ownership of cb.
-      AsyncRequestHitTestDataAtBlinkCords(x, y, cb);
+      // Do not do anything.
       break;
     }
     default:
@@ -697,6 +693,7 @@ void SelectionControllerEfl::HandleLongPressEvent(
       && params.src_url.is_empty()
       && params.is_text_node) {
     SetSelectionStatus(true);
+    SetSelectionEditable(false);
     HandleLongPressEventPrivate(touch_point);
     DVLOG(1) << __PRETTY_FUNCTION__ << ":: link, !image, !media, text";
   } else if (!params.src_url.is_empty() && params.has_image_contents) {
@@ -748,10 +745,8 @@ void SelectionControllerEfl::HandleLongPressEndEvent() {
   ShowHandleAndContextMenuIfRequired();
 }
 
-void SelectionControllerEfl::HandleTapEvent(
-    const gfx::Point& touch_point,
-    const ViewHostMsg_HitTestAsyncReply_Params& params) {
-  if (params.isEditable) {
+void SelectionControllerEfl::PostHandleTapGesture(bool is_content_editable) {
+  if (is_content_editable) {
     DVLOG(1) << "DispatchPostponedGestureEvent :: Editable";
     SetSelectionStatus(true);
     if (GetSelectionEditable()){
index 86137f1..08900ce 100644 (file)
@@ -59,8 +59,7 @@ class CONTENT_EXPORT SelectionControllerEfl {
   void HandleLongPressMoveEvent(const gfx::Point& touch_point);
   void HandleLongPressEndEvent();
 
-  void HandleTapEvent(const gfx::Point& touch_point,
-      const ViewHostMsg_HitTestAsyncReply_Params& params);
+  void PostHandleTapGesture(bool is_content_editable);
 
   // Set if selection is valid
   void SetSelectionStatus(bool enable);
index de331a6..0a7abfb 100644 (file)
@@ -85,9 +85,14 @@ class WebViewBrowserMessageFilterPrivate
       web_view_->InvokePlainTextGetCallback(content_text, plain_text_get_callback_id);
   }
 
-  void OnPlayLinkEffect() {
+  void OnHandleTapGestureWithContext(bool is_link, bool is_content_editable) {
     DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-    sound_effect::playLinkEffect();
+    if (!web_view_)
+      return;
+
+    if (is_link && web_view_->GetSettings()->getWebViewSettings().link_effect_enabled)
+      sound_effect::playLinkEffect();
+    web_view_->HandleTapGestureForSelection(is_content_editable);
   }
 
   void OnWebAppIconUrlGet(const std::string &icon_url, int callback_id) {
@@ -192,7 +197,7 @@ void WebViewBrowserMessageFilter::OverrideThreadForMessage(
     case EwkViewMsg_DidFailLoadWithError::ID:
     case EwkViewHostMsg_HitTestAsyncReply::ID:
     case EwkHostMsg_PlainTextGetContents::ID:
-    case EwkHostMsg_PlayLinkEffect::ID:
+    case EwkHostMsg_HandleTapGestureWithContext::ID:
     case EwkHostMsg_WebAppIconUrlGet::ID:
     case EwkHostMsg_WebAppIconUrlsGet::ID:
     case EwkHostMsg_WebAppCapableGet::ID:
@@ -214,8 +219,8 @@ bool WebViewBrowserMessageFilter::OnMessageReceived(
         WebViewBrowserMessageFilterPrivate::OnReceivedDidFailLoadWithError)
     IPC_MESSAGE_FORWARD(EwkHostMsg_PlainTextGetContents, private_,
         WebViewBrowserMessageFilterPrivate::OnPlainTextGetContents)
-    IPC_MESSAGE_FORWARD(EwkHostMsg_PlayLinkEffect, private_,
-        WebViewBrowserMessageFilterPrivate::OnPlayLinkEffect)
+    IPC_MESSAGE_FORWARD(EwkHostMsg_HandleTapGestureWithContext, private_,
+        WebViewBrowserMessageFilterPrivate::OnHandleTapGestureWithContext)
     IPC_MESSAGE_FORWARD(EwkHostMsg_WebAppIconUrlGet, private_,
         WebViewBrowserMessageFilterPrivate::OnWebAppIconUrlGet)
     IPC_MESSAGE_FORWARD(EwkHostMsg_WebAppIconUrlsGet, private_,
index 8af59ad..6f2c997 100644 (file)
@@ -225,7 +225,9 @@ IPC_MESSAGE_ROUTED1(EwkViewMsg_SelectionTextStyleState,
 
 IPC_MESSAGE_ROUTED1(EflViewMsg_UpdateSettings, WebViewSettings)
 
-IPC_MESSAGE_ROUTED0(EwkHostMsg_PlayLinkEffect)
+IPC_MESSAGE_ROUTED2(EwkHostMsg_HandleTapGestureWithContext,
+                    bool /* is_link */,
+                    bool /* is_editable_content */)
 
 IPC_MESSAGE_ROUTED2(EwkHostMsg_PlainTextGetContents,
                     std::string, /* contentText */
index a9587c9..5582900 100644 (file)
@@ -2191,6 +2191,13 @@ bool EWebView::HandleTextSelectionUp(int x, int y) {
   return GetSelectionController()->TextSelectionUp(x, y);
 }
 
+void EWebView::HandleTapGestureForSelection(bool is_content_editable) {
+  if (!GetSelectionController())
+    return;
+
+  GetSelectionController()->PostHandleTapGesture(is_content_editable);
+}
+
 void EWebView::HandleZoomGesture(blink::WebGestureEvent& event) {
   if (event.type == blink::WebInputEvent::GestureDoubleTap ||
       event.type == blink::WebInputEvent::GesturePinchBegin) {
index cfa52f3..e84f6ad 100644 (file)
@@ -451,6 +451,7 @@ class EWebView {
   void HandleRendererProcessCrash();
   void InvokeWebProcessCrashedCallback();
 
+  void HandleTapGestureForSelection(bool is_content_editable);
   void HandleZoomGesture(blink::WebGestureEvent& event);
 
  private:
index 8930b78..b7f1ccd 100644 (file)
@@ -610,19 +610,17 @@ void RenderViewObserverEfl::OnUpdateSettings(const WebViewSettings& settings)
 
 void RenderViewObserverEfl::HandleTap(const blink::WebGestureEvent& event)
 {
-  if (link_effect_enabled_) {
-    // In order to closely match our touch adjustment logic, we
-    // perform a hit test "for tap" using the same "padding" as the
-    // original tap event. That way, touch adjustment picks up a link
-    // for clicking, we will emit a click sound.
-    blink::WebSize size(event.data.tap.width, event.data.tap.height);
-    const blink::WebHitTestResult web_hit_test_result =
-        render_view()->GetWebView()->hitTestResultForTap(
-            blink::WebPoint(event.x, event.y), size);
-
-    if (!web_hit_test_result.absoluteLinkURL().isEmpty()) {
-      // we are on a link
-      Send(new EwkHostMsg_PlayLinkEffect(render_view()->GetRoutingID()));
-    }
-  }
+  // In order to closely match our touch adjustment logic, we
+  // perform a hit test "for tap" using the same "padding" as the
+  // original tap event. That way, touch adjustment picks up a link
+  // for clicking, we will emit a click sound.
+  blink::WebSize size(event.data.tap.width, event.data.tap.height);
+  const blink::WebHitTestResult web_hit_test_result =
+      render_view()->GetWebView()->hitTestResultForTap(
+          blink::WebPoint(event.x, event.y), size);
+
+  bool hit_link = !web_hit_test_result.absoluteLinkURL().isEmpty();
+  bool hit_content_editable = web_hit_test_result.isContentEditable();
+  Send(new EwkHostMsg_HandleTapGestureWithContext(render_view()->GetRoutingID(),
+      hit_link, hit_content_editable));
 }