Fix 'select' context menu option.
authorAntonio Gomes <a1.gomes@samsung.com>
Wed, 16 Sep 2015 18:32:04 +0000 (14:32 -0400)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
After [1] is fixed, whenever ones does a long press
gesture on a link content, a context menu shows up, whereas
one of the menu options is "select".
Naturally, once picked up, the link text should be selected,
and selection handles and context menu should appear.

Problem is that text gets selected (on the renderer side),
but there is synchronization problem on the browser side
which causes handles and context menu not being shown.
Problem is the flow:
1) user selects menu item
2) this calls ContextMenuController:ShowSelectionHandleAndContextMenu
3) This sends a IPC message to the renderer to select the content..
4) .. and tries to show the context menu and handles right after.

Calling (4) right way (3) is wrong because (3) is async.

Patch fixes this by changing (4): it now only flags
SelectionControllerEfl that a renderer text selection
change is expected.
Once the selection notification change gets to the browser
(RWHVEfl::OnSwapCompositorFrame), context menu and handles
are shown as expected.

[1] http://165.213.202.130/gerrit/#/c/86943/

Original beta/m42 patch:
- http://165.213.202.130/gerrit/#/c/87568/ , reviewed by
Janusz Majnert, arno renevier.

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

Reviewed by: hh4813.kim

Change-Id: I057bc74c3edaa141e7ed6fc4edab7c72638d93d2
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
tizen_src/ewk/efl_integration/context_menu_controller_efl.h

index 0a8ef0b..1b70f65 100644 (file)
@@ -143,8 +143,9 @@ void SelectionControllerEfl::OnSelectionChanged(
   truncated_start = ConvertRectToPixel(device_scale_factor, truncated_start);
   truncated_end = ConvertRectToPixel(device_scale_factor, truncated_end);
 
+  bool show = expecting_update_;
   UpdateSelectionDataAndShow(
-      truncated_start, truncated_end, false /*show*/);
+      truncated_start, truncated_end, show);
 }
 
 void SelectionControllerEfl::UpdateSelectionData(const base::string16& text) {
@@ -172,6 +173,7 @@ bool SelectionControllerEfl::UpdateSelectionDataAndShow(
     selection_data_->UpdateRectData(left_rect, right_rect);
     return false;
   }
+
   RenderWidgetHostViewEfl* rwhv =
       static_cast<RenderWidgetHostViewEfl*>(web_contents_.GetRenderWidgetHostView());
   if (show_only_large_handle_ && GetCaretSelectionStatus() &&
index 3428a71..34d765a 100644 (file)
@@ -111,6 +111,9 @@ class CONTENT_EXPORT SelectionControllerEfl {
   { show_only_large_handle_ = show_only_large_handle; }
   bool GetShowOnlyLargeHandle() const { return show_only_large_handle_; }
 
+  void SetWaitsForRendererSelectionChanges(
+      bool value) { expecting_update_ = value; }
+
   // Gesture handlers.
   void HandlePostponedGesture(int x, int y, ui::EventType type);
   void HandleGesture(blink::WebGestureEvent& event);
@@ -166,8 +169,9 @@ class CONTENT_EXPORT SelectionControllerEfl {
   // behind other layer.
   bool postponed_;
 
-  // True when new caret/selection position was sent to chromium,
-  // but no reply was received, yet
+  // Enters a state where browser has requested a text selection
+  // change to the renderer. At the next composited selection update
+  // state is handled and reset.
   bool expecting_update_;
 
   // Saves state so that handlers and context menu is not shown when seletion change event occurs.
index 25a6c41..a994f5a 100644 (file)
@@ -464,14 +464,11 @@ void ContextMenuControllerEfl::HideSelectionHandle() {
     controller->HideHandles();
 }
 
-void ContextMenuControllerEfl::ShowSelectionHandleAndContextMenu() {
+void ContextMenuControllerEfl::RequestShowSelectionHandleAndContextMenu() {
   SelectionControllerEfl* controller = webview_->GetSelectionController();
   if (controller) {
     controller->SetSelectionStatus(true);
-    controller->UpdateSelectionDataAndShow(
-        controller->GetLeftRect(),
-        controller->GetRightRect(),
-        true);
+    controller->SetWaitsForRendererSelectionChanges(true);
   }
 }
 
@@ -740,7 +737,7 @@ void ContextMenuControllerEfl::MenuItemSelected(ContextMenuItemEfl* menu_item)
       Evas_Coord x, y;
       evas_object_geometry_get(webview_->evas_object(), &x, &y, 0, 0);
       webview_->SelectLinkText(gfx::Point(params_.x - x, params_.y - y));
-      ShowSelectionHandleAndContextMenu();
+      RequestShowSelectionHandleAndContextMenu();
       break;
     }
     case MENU_ITEM_COPY_IMAGE_TO_CLIPBOARD: {
@@ -793,12 +790,12 @@ void ContextMenuControllerEfl::MenuItemSelected(ContextMenuItemEfl* menu_item)
     }
     case MENU_ITEM_SELECT_WORD: {
       webview_->ExecuteEditCommand("SelectWord", NULL);
-      ShowSelectionHandleAndContextMenu();
+      RequestShowSelectionHandleAndContextMenu();
       break;
     }
     case MENU_ITEM_SELECT_ALL: {
       webview_->ExecuteEditCommand("SelectAll", NULL);
-      ShowSelectionHandleAndContextMenu();
+      RequestShowSelectionHandleAndContextMenu();
       break;
     }
     case MENU_ITEM_PASTE: {
index 9daaa92..7ee3eda 100644 (file)
@@ -204,7 +204,7 @@ class ContextMenuControllerEfl
                              const std::string& link_url = std::string(),
                              const std::string& icon_path = std::string());
   void HideSelectionHandle();
-  void ShowSelectionHandleAndContextMenu();
+  void RequestShowSelectionHandleAndContextMenu();
   virtual void OnDownloadUpdated(content::DownloadItem* download) override;
   void OnClipboardDownload(content::DownloadItem* item,
                            content::DownloadInterruptReason interrupt_reason);