[dev/m42][uBrowser] No selection handler on long text
authorAntonio Gomes <a1.gomes@samsung.com>
Thu, 6 Aug 2015 22:05:21 +0000 (18:05 -0400)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
Our text selection and context menu code has some logic
to _not_ show the context menu when it calculates handles
are not positioned properly. See for example, some of cases
returning 'false' in ContextMenuControllerEfl::ShowContextMenu.

This has two problems:
1) It only takes into account the "start" handle, and no
matter if the "end" handle were onscreen, it was ignored.
2) It was not only not showing the context menu.
By returning "false" in ContextMenuControllerEfl::ShowContextMenu,
selection was actually canceled, leaving SelectionController
and the renderer process selection code out of sync.

In s-browser (verified on S6) context menu is not shown
if both handles are offscreen and the selected content itself
is also offscreen.

Patch makes us behavior similarly to s-browser by.
implementing the first patch of the behavior described:
if no handles are on screen (i.e. both are scrolled away from
viewport), do not show the context menu.

Another big different from the previous behavior is that
we do not leave selection mode when handles are offscreen.
Instead, we do not show context menu only. Once handles
are onscreen again, context menu is shown just fine.

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

Reviewed by: SeungSeop Park

Change-Id: Ic39d9497f2fa4400096bd8c8356183b0cab760d6
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/context_menu_controller_efl.cc

index 6cd7cdc..8541b07 100644 (file)
@@ -300,6 +300,23 @@ void SelectionControllerEfl::QuerySelectionStyle() {
   wcve->QuerySelectionStyle();
 }
 
+bool SelectionControllerEfl::IsAnyHandleOnScreen() const {
+  int webview_x, webview_y, webview_width, webview_height;
+  evas_object_geometry_get(GetParentView(),
+      &webview_x, &webview_y, &webview_width, &webview_height);
+
+  gfx::Rect left_handle_rect = selection_data_->GetLeftRect();
+  left_handle_rect.Offset(webview_x, webview_y);
+
+  gfx::Rect viewport_rect = gfx::Rect(webview_x, webview_y, webview_width, webview_height);
+  if (viewport_rect.Contains(left_handle_rect.x(), left_handle_rect.y()))
+    return true;
+
+  gfx::Rect right_handle_rect = selection_data_->GetRightRect();
+  right_handle_rect.Offset(webview_x, webview_y);
+  return viewport_rect.Contains(right_handle_rect.x(), right_handle_rect.y());
+}
+
 void SelectionControllerEfl::ShowContextMenu() {
   WebContentsImpl* wci = static_cast<WebContentsImpl*>(&web_contents_);
   WebContentsViewEfl* wcve = static_cast<WebContentsViewEfl*>(wci->GetView());
@@ -309,6 +326,11 @@ void SelectionControllerEfl::ShowContextMenu() {
 
   content::ContextMenuParams convertedParams = *(selection_data_->GetContextMenuParams());
 
+  // If there is no handles on screen, do not show context
+  // menu, but also do not leave selection mode.
+  if (!IsAnyHandleOnScreen())
+    return;
+
   int blinkX, blinkY;
   if (rwhv)
     rwhv->EvasToBlinkCords(convertedParams.x, convertedParams.y, &blinkX, &blinkY);
index 7129a4c..2180729 100644 (file)
@@ -87,10 +87,11 @@ class CONTENT_EXPORT SelectionControllerEfl {
   // Clears the selection and hides context menu and handles
   void ClearSelection();
   bool ClearSelectionViaEWebView();
-  Evas_Object* GetParentView() { return parent_view_; }
+  Evas_Object* GetParentView() const { return parent_view_; }
   void HideHandles();
   void HideHandleAndContextMenu();
   bool IsAnyHandleVisible() const;
+  bool IsAnyHandleOnScreen() const;
 
   void SetScrollStatus(const bool enable);
   bool GetScrollStatus();
index 3e95bbb..b9ed490 100644 (file)
@@ -408,8 +408,6 @@ bool ContextMenuControllerEfl::ShowContextMenu() {
       return false;
     }
 
-    if ((popup_position.y() - webview_y < webview_y) || (popup_position.x() - webview_x < webview_x))
-        return false;
     int draw_direction;
     controller->ChangeContextMenuPosition(popup_position, draw_direction);