Do not show selection ctx when selection range is offscreen
authorGrzegorz Czajkowski <g.czajkowski@samsung.com>
Mon, 14 Dec 2015 15:29:57 +0000 (16:29 +0100)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 07:55:23 +0000 (07:55 +0000)
Currently, regardless of selection visibilty (start, end) we show selection ctx.
This patch changes ShowHandleAndContextMenuIfRequired() method in a way that
at least one handler visibilty (selection start or end) is required to show
ctx menu.

This fixes WCS TC 10.
Inspired by http://165.213.202.130/gerrit/#/c/98864/.

Additionally, remove ::IsAnyHandleOnScreen because with composited updates the
text selection contains such information.

Original beta/m47 patch:
- http://165.213.202.130/gerrit/#/c/99275/

Bug: http://web.sec.samsung.net/bugzilla/show_bug.cgi?id=12055

Reviewed by: a1.gomes, djmix.kim, g.czajkowski

Change-Id: I56d2ce545aeecec8f4e4bf9a5be22180eb98596c
Signed-off-by: Grzegorz Czajkowski <g.czajkowski@samsung.com>
tizen_src/chromium_impl/content/browser/selection/selection_controller_efl.cc
tizen_src/chromium_impl/content/browser/selection/selection_controller_efl.h

index 6793119..f5ee170 100644 (file)
@@ -259,6 +259,9 @@ void SelectionControllerEfl::ShowHandleAndContextMenuIfRequired(
     return;
   }
 
+  bool is_any_handle_visible = start_selection_.visible() ||
+      end_selection_.visible();
+
   // Is in edit field and no text is selected. show only single handle
   if (selection_data_->IsInEditField() && left == right) {
     if (!GetSelectionEditable())
@@ -266,7 +269,7 @@ void SelectionControllerEfl::ShowHandleAndContextMenuIfRequired(
 
     CHECK(start_selection_ == end_selection_);
 
-    if (GetCaretSelectionStatus() && start_selection_.visible()) {
+    if (GetCaretSelectionStatus() && is_any_handle_visible) {
       gfx::Rect left = selection_data_->GetLeftRect();
       input_handle_->SetBasePosition(gfx::Point(left.x(), left.y()));
       input_handle_->Move(left.bottom_right());
@@ -277,7 +280,8 @@ void SelectionControllerEfl::ShowHandleAndContextMenuIfRequired(
 
     QuerySelectionStyle();
 
-    bool show_context_menu = effective_reason != Reason::ScrollOrZoomGestureEnded &&
+    bool show_context_menu = is_any_handle_visible &&
+                             effective_reason != Reason::ScrollOrZoomGestureEnded &&
                              effective_reason != Reason::Tap &&
                              effective_reason != Reason::Irrelevant;
     if (!handle_being_dragged_ && show_context_menu)
@@ -314,8 +318,10 @@ void SelectionControllerEfl::ShowHandleAndContextMenuIfRequired(
   else
     end_handle->Hide();
 
-  // Do not show the context menu during selection extend
-  if (!handle_being_dragged_ && effective_reason != Reason::Irrelevant)
+  // Do not show the context menu during selection extend and
+  // offscreen selection.
+  if (!handle_being_dragged_ && effective_reason != Reason::Irrelevant &&
+      is_any_handle_visible)
     ShowContextMenu();
 
   QuerySelectionStyle();
@@ -327,29 +333,7 @@ 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() {
-  // If there is no handles on screen, do not show context
-  // menu, but also do not leave selection mode.
-  if (!IsAnyHandleOnScreen())
-    return;
-
   content::ContextMenuParams convertedParams = *(selection_data_->GetContextMenuParams());
 
   RenderWidgetHostViewEfl* rwhv =
index 570b048..a739441 100644 (file)
@@ -91,7 +91,6 @@ class CONTENT_EXPORT SelectionControllerEfl {
   void HideHandles();
   void HideHandleAndContextMenu();
   bool IsAnyHandleVisible() const;
-  bool IsAnyHandleOnScreen() const;
 
   void SetControlsTemporarilyHidden(bool hidden);