Move away from AsyncHitTest messages to handle long press.
authorAntonio Gomes <a1.gomes@samsung.com>
Wed, 26 Aug 2015 23:11:05 +0000 (19:11 -0400)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
As another step to move our text selection implementation
away from hit test messages, patch makes use of the existing
FrameHostMsg_ContextMenu message in order to update the
context menu data. Flow:

0- (..)
1- RenderFrameImpl::showContextMenu
2-       <<IPC>>
3- RenderFrameHostImpl::OnContextMenu
4- WebContentsViewDelegateEwk::ShowContextMenu
5- EWebView::ShowContextMenu
6- SelectionControllerEfl::HandleLongPressEvent
7- (..)

Note that EWebView::ShowContextMenu *needs* to get called twiced
when long press is being handled: First, when long press event
processing itself happens. This is called as part of the chain
that handles message FrameHostMsg_ContextMenu (see stable above).
The second call to EWebView::ShowContextMenu used to happen
when user lifts its finger, and context menu should actually
get shown.

Additionally, patch moves in advance the moment when
long_mouse_press_ is set to true: instead of setting it
in SelectionControllerEfl::HandleLongEventPrivate, it is
now set in ::HandleGesture. That allows EWebView::ShowContextMenu
to check for it reliably instead of checking for ::IsShowingMagnifier
Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=6663

Original beta/m42 patches:
- http://165.213.202.130/gerrit/#/c/85895/ , reviewed by
DONGJUN KiM, Janusz Majnert, Arnaud Renevier.
- http://165.213.202.130/gerrit/#/c/86028/ , reviewed by
Janusz Majnert, Arnaud Renevier.

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

Reviewed by: Janusz Majnert

Change-Id: I3eabb73f56d1003cff738c817e42ba8eae4e14c6
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/eweb_view.cc

index 2d55669..e79d383 100644 (file)
@@ -342,7 +342,6 @@ bool SelectionControllerEfl::IsAnyHandleOnScreen() const {
 
 void SelectionControllerEfl::ShowContextMenu() {
   WebContentsImpl* wci = static_cast<WebContentsImpl*>(&web_contents_);
-  WebContentsViewEfl* wcve = static_cast<WebContentsViewEfl*>(wci->GetView());
   RenderWidgetHostViewEfl* rwhv =
       static_cast<RenderWidgetHostViewEfl*>(web_contents_.GetRenderWidgetHostView());
   RenderViewHost* rvh = static_cast<RenderViewHost*>(wci->GetRenderViewHost());
@@ -359,6 +358,11 @@ void SelectionControllerEfl::ShowContextMenu() {
     rwhv->EvasToBlinkCords(convertedParams.x, convertedParams.y, &blinkX, &blinkY);
   convertedParams.x = blinkX;
   convertedParams.y = blinkY;
+
+  // TODO(a1.gomes): In case of EWK apps, the call below end up calling
+  // EWebView::ShowContextMenu. We have to make sure parameters
+  // are correct.
+  WebContentsViewEfl* wcve = static_cast<WebContentsViewEfl*>(wci->GetView());
   wcve->ShowContextMenu(rvh->GetMainFrame(), convertedParams);
 }
 
@@ -582,6 +586,7 @@ void SelectionControllerEfl::HandleGesture(blink::WebGestureEvent& event) {
     restore_showing_large_handle_on_gesture_end_.reset();
     HandlePostponedGesture(
         event.x, event.y, ui::ET_GESTURE_LONG_PRESS);
+    long_mouse_press_ = true;
   } else if (event.type == blink::WebInputEvent::GestureTapDown) {
     single_tap_performed_ = true;
   } else if (event.type == blink::WebInputEvent::GestureTapCancel ||
@@ -656,11 +661,8 @@ void SelectionControllerEfl::HandlePostponedGesture(int x, int y, ui::EventType
     case ui::ET_GESTURE_LONG_PRESS: {
       ClearSelectionViaEWebView();
       HideHandleAndContextMenu();
-      RwhvAsyncRequestHitTestDataInternalCallback* cb =
-          new RwhvAsyncRequestHitTestDataInternalCallback(point,
-              &SelectionControllerEfl::HandleLongPressEvent);
-      // below call takes full ownership of cb.
-      AsyncRequestHitTestDataAtBlinkCords(x, y, cb);
+      // Long press data will call to WebContentsViewDelegateEwk.
+      // It is called by the chain that handles FrameHostMsg_ContextMenu.
       break;
     }
     case ui::ET_GESTURE_TAP: {
@@ -685,31 +687,28 @@ void SelectionControllerEfl::HandlePostponedGesture(int x, int y, ui::EventType
 
 void SelectionControllerEfl::HandleLongPressEvent(
     const gfx::Point& touch_point,
-    const ViewHostMsg_HitTestAsyncReply_Params& params) {
+    const content::ContextMenuParams& params) {
 
-  if (params.isEditable) {
+  if (params.is_editable) {
     SetSelectionStatus(true);
     SetSelectionEditable(true);
     HandleLongPressEventPrivate(touch_point);
-  } else if (params.linkURI.empty()
-      && params.imageURI.empty()
-      && params.mediaURI.empty()
-      && params.isTextNode) {
+  } else if (params.link_url.is_empty()
+      && params.src_url.is_empty()
+      && params.is_text_node) {
     SetSelectionStatus(true);
     HandleLongPressEventPrivate(touch_point);
     DVLOG(1) << __PRETTY_FUNCTION__ << ":: link, !image, !media, text";
-  } else if (!params.imageURI.empty()) {
+  } else if (!params.src_url.is_empty() && params.has_image_contents) {
     DVLOG(1) << __PRETTY_FUNCTION__ << ":: IMAGE";
-  } else if (!params.linkURI.empty()) {
+  } else if (!params.link_url.is_empty()) {
     ClearSelectionViaEWebView();
     DVLOG(1) << __PRETTY_FUNCTION__ << ":: LINK";
   }
-
 }
 
 void SelectionControllerEfl::HandleLongPressEventPrivate(const gfx::Point& touch_point) {
   show_only_large_handle_ = false;
-  long_mouse_press_ = true;
   Clear();
   if (selection_data_->IsInEditField())
     SetCaretSelectionStatus(true);
index 821deb7..86137f1 100644 (file)
@@ -55,7 +55,7 @@ class CONTENT_EXPORT SelectionControllerEfl {
 
   // Functions that handle long press, long press move and release
   void HandleLongPressEvent(const gfx::Point& touch_point,
-      const ViewHostMsg_HitTestAsyncReply_Params& params);
+      const content::ContextMenuParams& params);
   void HandleLongPressMoveEvent(const gfx::Point& touch_point);
   void HandleLongPressEndEvent();
 
index 0f89e96..a9587c9 100644 (file)
@@ -1125,7 +1125,9 @@ void EWebView::ShowContextMenu(const content::ContextMenuParams& params) {
   context_menu_position_ = gfx::Point(convertedParams.x, convertedParams.y);
 
   if (GetSelectionController()) {
-    if (!GetSelectionController()->IsShowingMagnifier()) {
+    if (GetSelectionController()->GetLongPressed()) {
+      GetSelectionController()->HandleLongPressEvent(convertedPoint, convertedParams);
+    } else {
       if(!context_menu_->PopulateAndShowContextMenu(convertedParams)) {
         context_menu_.reset();
         GetSelectionController()->HideHandles();