Let long press selection bits be handled by SelectionController
authorAntonio Gomes <a1.gomes@samsung.com>
Thu, 19 Feb 2015 20:54:11 +0000 (16:54 -0400)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
Lots of code in EWebView::HandleLongPressGesture did not
belong there, and should be defered to SelectionControllerEfl.

Patch pulls the trigger.

Bug: http://web.sec.samsung.net/bugzilla/show_bug.cgi?id=8773
Reviewed by: Piotr Grad, arno renevier

Change-Id: I157619d78cb590ae67b93564050837391fcc3a43
Signed-off-by: Antonio Gomes <a1.gomes@samsung.com>
tizen_src/impl/eweb_view.cc
tizen_src/impl/selection_controller_efl.cc
tizen_src/impl/selection_controller_efl.h

index 8dd9e2c..edd02da 100644 (file)
@@ -848,35 +848,18 @@ void EWebView::DispatchPostponedGestureEvent(ui::GestureEvent* event) {
 */
 
 void EWebView::HandleLongPressGesture(int x, int y,
-                                      tizen_webview::Hit_Test_Mode mode,
+                                      tizen_webview::Hit_Test_Mode,
                                       tizen_webview::Hit_Test* hit_test) {
   _Ewk_Hit_Test* hit_test_data = hit_test->impl;
-  if (hit_test_data && hit_test_data->context & TW_HIT_TEST_RESULT_CONTEXT_EDITABLE) {
-    selection_controller_->SetSelectionStatus(true);
-    selection_controller_->SetSelectionEditable(true);
-    selection_controller_->HandleLongPressEvent(rwhv()->ConvertPointInViewPix(gfx::Point(x, y)));
-  } else if (hit_test_data
-      && !(hit_test_data->context & TW_HIT_TEST_RESULT_CONTEXT_LINK)
-      && !(hit_test_data->context & TW_HIT_TEST_RESULT_CONTEXT_IMAGE)
-      && !(hit_test_data->context & TW_HIT_TEST_RESULT_CONTEXT_MEDIA)
-      && hit_test_data->context & TW_HIT_TEST_RESULT_CONTEXT_TEXT) {
-    selection_controller_->SetSelectionStatus(true);
-    selection_controller_->HandleLongPressEvent(rwhv()->ConvertPointInViewPix(gfx::Point(x, y)));
-    LOG(INFO) << __PRETTY_FUNCTION__ << ":: link, !image, !media, text";
-  } else if (hit_test_data && hit_test_data->context & TW_HIT_TEST_RESULT_CONTEXT_DOCUMENT) {
-    LOG(INFO) << __PRETTY_FUNCTION__ << ":: TW_HIT_TEST_RESULT_CONTEXT_DOCUMENT";
-  } else if (hit_test_data && hit_test_data->context & TW_HIT_TEST_RESULT_CONTEXT_IMAGE) {
-    LOG(INFO) << __PRETTY_FUNCTION__ << ":: TW_HIT_TEST_RESULT_CONTEXT_IMAGE";
-  } else if (hit_test_data && hit_test_data->context & TW_HIT_TEST_RESULT_CONTEXT_LINK) {
-    selection_controller_->ClearSelectionViaEWebView();
-    LOG(INFO) << __PRETTY_FUNCTION__ << ":: TW_HIT_TEST_RESULT_CONTEXT_LINK";
-  } else {
-    LOG(INFO) << __PRETTY_FUNCTION__ << ":: hit_test = " << hit_test_data->context;
-  }
+  if (!hit_test_data)
+    return;
+
+  selection_controller_->HandleLongPressEvent(
+      rwhv()->ConvertPointInViewPix(gfx::Point(x, y)), hit_test_data->context);
 }
 
 void EWebView::HandleTapGesture(int x, int y,
-                                tizen_webview::Hit_Test_Mode mode,
+                                tizen_webview::Hit_Test_Mode,
                                 tizen_webview::Hit_Test* hit_test) {
   _Ewk_Hit_Test* hit_test_data = hit_test->impl;
   LOG(INFO) << __PRETTY_FUNCTION__ << " hit_test = " << hit_test_data;
index 3876235..70d3dbe 100644 (file)
@@ -7,9 +7,12 @@
 #include "selection_box_efl.h"
 #include "selection_magnifier_efl.h"
 #include "ui/gfx/screen.h"
+#include "tizen_webview/public/tw_hit_test.h"
 
 #include <Edje.h>
 
+using namespace tizen_webview;
+
 namespace content {
 
 static const int menuHeight = 140;// The Height fo the context menu.
@@ -431,7 +434,32 @@ void SelectionControllerEfl::GetSelectionBounds(gfx::Rect* left,
     *right = selection_data_->GetRightRect();
 }
 
-void SelectionControllerEfl::HandleLongPressEvent(const gfx::Point& touch_point) {
+void SelectionControllerEfl::HandleLongPressEvent(
+    const gfx::Point& touch_point, tizen_webview::Hit_Test_Result_Context context) {
+  if (context & TW_HIT_TEST_RESULT_CONTEXT_EDITABLE) {
+    SetSelectionStatus(true);
+    SetSelectionEditable(true);
+  } else if (!(context & TW_HIT_TEST_RESULT_CONTEXT_LINK)
+      && !(context & TW_HIT_TEST_RESULT_CONTEXT_IMAGE)
+      && !(context & TW_HIT_TEST_RESULT_CONTEXT_MEDIA)
+      && context & TW_HIT_TEST_RESULT_CONTEXT_TEXT) {
+    SetSelectionStatus(true);
+    LOG(INFO) << __PRETTY_FUNCTION__ << ":: link, !image, !media, text";
+  } else if (context & TW_HIT_TEST_RESULT_CONTEXT_DOCUMENT) {
+    LOG(INFO) << __PRETTY_FUNCTION__ << ":: TW_HIT_TEST_RESULT_CONTEXT_DOCUMENT";
+  } else if (context & TW_HIT_TEST_RESULT_CONTEXT_IMAGE) {
+    LOG(INFO) << __PRETTY_FUNCTION__ << ":: TW_HIT_TEST_RESULT_CONTEXT_IMAGE";
+  } else if (context & TW_HIT_TEST_RESULT_CONTEXT_LINK) {
+    ClearSelectionViaEWebView();
+    LOG(INFO) << __PRETTY_FUNCTION__ << ":: TW_HIT_TEST_RESULT_CONTEXT_LINK";
+  } else {
+    LOG(INFO) << __PRETTY_FUNCTION__ << ":: hit_test = " << context;
+  }
+
+  HandleLongPressEventPrivate(touch_point);
+}
+
+void SelectionControllerEfl::HandleLongPressEventPrivate(const gfx::Point& touch_point) {
   show_only_large_handler_ = false;
   long_mouse_press_ = true;
   Clear();
@@ -673,7 +701,7 @@ bool SelectionControllerEfl::TextSelectionDown(int x, int y) {
    * Source/WebKit2/UIProcess/API/efl/ewk_view.cpp line 614
    */
   if (!long_mouse_press_) {
-    HandleLongPressEvent(gfx::Point(x, y));
+    HandleLongPressEventPrivate(gfx::Point(x, y));
     return true;
   }
 
index f80f751..8b204ee 100644 (file)
@@ -47,7 +47,7 @@ class SelectionControllerEfl : public tizen_webview::SelectionController {
   explicit SelectionControllerEfl(EWebView* parent_view);
 
   // Functions that handle long press, long press move and release
-  void HandleLongPressEvent(const gfx::Point& touch_point);
+  void HandleLongPressEvent(const gfx::Point& touch_point, tizen_webview::Hit_Test_Result_Context);
   void HandleLongPressMoveEvent(const gfx::Point& touch_point);
   void HandleLongPressEndEvent();
   // Set if selection is valid
@@ -106,6 +106,8 @@ class SelectionControllerEfl : public tizen_webview::SelectionController {
   bool GetShowOnlyLargeHandler() const { return show_only_large_handler_; }
 
  private:
+  void HandleLongPressEventPrivate(const gfx::Point& touch_point);
+
   // TODO: This method should be renamed to ScheduleShowHandleAndContextMenuIfNeeded
   // as it now performs an asyncrhonous hit test passing the method that actually
   // updates the selection handles and context menu as a registered callback.