Decouple context menu from selection controller class.
authorAntonio Gomes <a1.gomes@samsung.com>
Tue, 15 Dec 2015 18:59:25 +0000 (14:59 -0400)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 07:55:23 +0000 (07:55 +0000)
Chromium-efl enters selection mode by a long press gesture.
Such event is only triggered when touch events are enabled.
The upstream counterpart of our SelectionControllerEfl
class is TouchSelectionController (see
ui/touch_selection/touch_selection_controller.cc).
As the name implies, its logic is also tied to touch events.

Patch decouples our context menu logic from the
SelectionControllerEfl class, tying it up to touch
event status. This allows context menus to be shown on
TV and desktop builds.

Original beta/m47 patches:
- http://165.213.202.130/gerrit/#/c/99552/
- http://165.213.202.130/gerrit/#/c/100348/
- http://165.213.202.130/gerrit/#/c/100324/

Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=15220
Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=15393
Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=15414

Reviewed by: g.czajkowski

Change-Id: I949afb612d3fb0806d95c865d34d51101014734b
Signed-off-by: Antonio Gomes <a1.gomes@samsung.com>
tizen_src/chromium_impl/content/browser/renderer_host/render_widget_host_view_efl.cc
tizen_src/chromium_impl/content/browser/selection/selection_controller_efl.cc
tizen_src/ewk/efl_integration/context_menu_controller_efl.cc
tizen_src/ewk/efl_integration/eweb_view.cc

index 2c22eec..378dc0a 100755 (executable)
@@ -292,9 +292,6 @@ void RenderWidgetHostViewEfl::InitAsChild(gfx::NativeView parent_view) {
   // initialized after evas_ is valid
   im_context_ = IMContextEfl::Create(this);
 
-  selection_controller_.reset(new SelectionControllerEfl(
-    smart_parent_, web_contents_));
-
   Init_EvasGL(width, height);
 }
 
@@ -1621,8 +1618,18 @@ void RenderWidgetHostViewEfl::SetDoubleTapSupportEnabled(bool enabled) {
 }
 
 void RenderWidgetHostViewEfl::SetTouchEventsEnabled(bool enabled) {
+  if (enabled == touch_events_enabled_)
+    return;
+
   touch_events_enabled_ = enabled;
   SetDoubleTapSupportEnabled(enabled);
+
+  if (enabled) {
+    selection_controller_.reset(new SelectionControllerEfl(
+        smart_parent_, web_contents_));
+  } else {
+    selection_controller_.reset();
+  }
 }
 
 void RenderWidgetHostViewEfl::set_magnifier(bool status) {
index 60453da..89ad722 100644 (file)
@@ -66,6 +66,10 @@ SelectionControllerEfl::SelectionControllerEfl(Evas_Object* parent_view, WebCont
 }
 
 SelectionControllerEfl::~SelectionControllerEfl() {
+  if (GetSelectionStatus())
+    ClearSelectionViaEWebView();
+  HideHandleAndContextMenu();
+
   evas_object_event_callback_del(parent_view_, EVAS_CALLBACK_MOVE, &EvasParentViewMoveCallback);
 }
 
index 3db8cb0..20db459 100644 (file)
@@ -422,14 +422,9 @@ bool ContextMenuControllerEfl::ShowContextMenu() {
       return false;
     }
 
-    SelectionControllerEfl* controller = webview_->GetSelectionController();
-    if (!controller) {
-      DeletePopup();
-      return false;
-    }
-
-    int draw_direction;
-    controller->ChangeContextMenuPosition(popup_position, draw_direction);
+    int draw_direction = 0;
+    if (SelectionControllerEfl* controller = webview_->GetSelectionController())
+      controller->ChangeContextMenuPosition(popup_position, draw_direction);
 
     if ((popup_position.y() > webview_height + webview_y) ||
        (popup_position.x() > webview_width + webview_x))
index 9e44551..c529e46 100644 (file)
@@ -1123,7 +1123,8 @@ void EWebView::ShowContextMenuInternal(const content::ContextMenuParams& params)
   context_menu_.reset(new content::ContextMenuControllerEfl(this, *web_contents_.get()));
   if (!context_menu_->PopulateAndShowContextMenu(params)) {
     context_menu_.reset();
-    GetSelectionController()->HideHandles();
+    if (GetSelectionController())
+      GetSelectionController()->HideHandles();
   }
 }
 
@@ -1278,7 +1279,11 @@ Eina_Bool EWebView::ClearSelection() {
 
   ResetContextMenuController();
   rwhv()->SelectionChanged(base::string16(), 0, gfx::Range());
-  return GetSelectionController()->ClearSelectionViaEWebView() ? EINA_TRUE : EINA_FALSE;
+
+  if (GetSelectionController())
+    return GetSelectionController()->ClearSelectionViaEWebView();
+
+  return EINA_FALSE;
 }
 
 _Ewk_Hit_Test* EWebView::RequestHitTestDataAt(int x, int y,