[M108 Migration] Enable proper functionality for ewk_view_text_selection_clear API 82/287182/3
authorayush.k123 <ayush.k123@samsung.com>
Mon, 23 Jan 2023 05:39:52 +0000 (11:09 +0530)
committerAyush Kumar <ayush.k123@samsung.com>
Mon, 23 Jan 2023 07:46:09 +0000 (07:46 +0000)
This patch enables proper functionality of ewk_view_text_selection_clear
api.

Reference: https://review.tizen.org/gerrit/c/274274/

Change-Id: Idbcdc8e50fbde018aefb3ca576597508a3978a97
Signed-off-by: Ayush Kumar <ayush.k123@samsung.com>
tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.cc
tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.h
tizen_src/ewk/efl_integration/eweb_view.cc

index 30492b0..edf0ed4 100644 (file)
@@ -602,6 +602,14 @@ void RWHVAuraOffscreenHelperEfl::SelectionChanged(const std::u16string& text,
                                                   const gfx::Range& range) {
   if (range.start() == range.end() && GetIMContextEfl())
     GetIMContextEfl()->SetCaretPosition(range.start());
+
+  if (!GetSelectionController())
+    return;
+
+  std::u16string selectedText;
+  if (!text.empty() && !range.is_empty())
+    selectedText = rwhv_aura_->GetSelectedText();
+  GetSelectionController()->UpdateSelectionData(selectedText);
 }
 
 void RWHVAuraOffscreenHelperEfl::EvasToBlinkCords(int x,
index a4264d1..1f24974 100644 (file)
@@ -19,6 +19,7 @@
 #include "base/callback.h"
 #include "base/containers/id_map.h"
 #include "base/timer/timer.h"
+#include "content/browser/selection/selection_controller_efl.h"
 #include "content/common/cursors/webcursor.h"
 #include "third_party/blink/public/common/input/web_input_event.h"
 #include "ui/base/ime/mojom/text_input_state.mojom-forward.h"
@@ -103,6 +104,9 @@ class CONTENT_EXPORT RWHVAuraOffscreenHelperEfl {
   void SelectionChanged(const std::u16string& text,
                         size_t offset,
                         const gfx::Range& range);
+  SelectionControllerEfl* GetSelectionController() const {
+    return selection_controller_.get();
+  }
   void EvasToBlinkCords(int x, int y, int* view_x, int* view_y);
 
   Evas_Object* ewk_view() const;
@@ -180,6 +184,7 @@ class CONTENT_EXPORT RWHVAuraOffscreenHelperEfl {
   ui::IMContextEfl* im_context_efl_ = nullptr;
   RenderWidgetHostViewAura* rwhv_aura_ = nullptr;
   WebContents* web_contents_ = nullptr;
+  std::unique_ptr<SelectionControllerEfl> selection_controller_;
 
   std::unique_ptr<RenderWidgetHostHelper> rwh_helper_;
 
index fcad346..015f775 100644 (file)
@@ -1366,14 +1366,10 @@ void EWebView::OnQuerySelectionStyleReply(const SelectionStylePrams& params) {
 }
 
 SelectionControllerEfl* EWebView::GetSelectionController() const {
-#if !defined(USE_AURA)
   RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
-  RenderWidgetHostViewEfl* view = static_cast<RenderWidgetHostViewEfl*>(
+  RenderWidgetHostViewAura* view = static_cast<RenderWidgetHostViewAura*>(
       render_view_host->GetWidget()->GetView());
-  return view ? view->GetSelectionController() : 0;
-#else
-  return nullptr;
-#endif
+  return view ? view->offscreen_helper()->GetSelectionController() : 0;
 }
 
 void EWebView::SelectLinkText(const gfx::Point& touch_point) {
@@ -1407,7 +1403,8 @@ Eina_Bool EWebView::ClearSelection() {
     return EINA_FALSE;
 
   ResetContextMenuController();
-  rwhva()->SelectionChanged(std::u16string(), 0, gfx::Range());
+  rwhva()->offscreen_helper()->SelectionChanged(std::u16string(), 0,
+                                                gfx::Range());
 
   if (GetSelectionController())
     return GetSelectionController()->ClearSelectionViaEWebView();