[M108 Migration][Text Selection] Selection handles & Caret Selection
[platform/framework/web/chromium-efl.git] / tizen_src / chromium_impl / content / browser / renderer_host / rwhv_aura_offscreen_helper_efl.cc
index aea5901..1e436c2 100644 (file)
@@ -549,6 +549,10 @@ void RWHVAuraOffscreenHelperEfl::OnFocusIn(void* data,
       static_cast<RWHVAuraOffscreenHelperEfl*>(data);
   thiz->FocusRWHVA();
 
+  if (IsMobileProfile() && thiz->GetSelectionController()) {
+    thiz->GetSelectionController()->ShowHandleAndContextMenuIfRequired();
+  }
+
   if (!thiz->on_focus_in_callback_.is_null())
     thiz->on_focus_in_callback_.Run();
 }
@@ -568,6 +572,10 @@ void RWHVAuraOffscreenHelperEfl::OnFocusOut(void* data,
   if (focused_window)
     focused_window->LostFocus();
 
+  if (IsMobileProfile() && thiz->GetSelectionController()) {
+    thiz->GetSelectionController()->HideHandleAndContextMenu();
+  }
+
   if (!thiz->on_focus_out_callback_.is_null())
     thiz->on_focus_out_callback_.Run();
 }
@@ -1053,6 +1061,42 @@ void RWHVAuraOffscreenHelperEfl::TextInputStateChanged(
   }
 }
 
+void RWHVAuraOffscreenHelperEfl::MoveCaret(const gfx::Point& point) {
+  if (auto* delegate = rwhv_aura_->host()->delegate()) {
+    delegate->MoveCaret(gfx::Point(point.x() / device_scale_factor_,
+                                   point.y() / device_scale_factor_));
+  }
+}
+
+void RWHVAuraOffscreenHelperEfl::SelectClosestWord(
+    const gfx::Point& touch_point) {
+  int view_x, view_y;
+  EvasToBlinkCords(touch_point.x(), touch_point.y(), &view_x, &view_y);
+
+#if !defined(EWK_BRINGUP)  // FIXME: m67 bringup
+  // FIXME: The SelectClosestWord function was removed by
+  // commit 9720a4494c8bcd24d1f496feec5cfac7582103d2 in s-chromium
+  // It will be fixed by webview team.
+  // FIXME: http://suprem.sec.samsung.net/jira/browse/TWF-2122
+  Send(new ViewMsg_SelectClosestWord(host_->GetRoutingID(), view_x, view_y));
+#endif  // EWK_BRINGUP
+}
+
+bool RWHVAuraOffscreenHelperEfl::HasSelectableText() {
+  // If the last character of textarea is '\n', We can assume an extra '\n'.
+  // Actually when you insert line break by ENTER key, '\n\n' is stored in
+  // textarea. And If you press delete key, only a '\n' character will be stored
+  // although there is no visible and selectable character in textarea. That's
+  // why we should check whether selection_text contains only one line break.
+  // Bug: http://suprem.sec.samsung.net/jira/browse/TSAM-2230
+  //
+  // Please see below commit for more information.
+  // https://codereview.chromium.org/1785603002
+  std::u16string selection_text = rwhv_aura_->GetSelectedText();
+  return !selection_text.empty() &&
+         base::UTF16ToUTF8(selection_text).compare("\n") != 0;
+}
+
 void RWHVAuraOffscreenHelperEfl::FocusedNodeChanged(
     bool editable
 #if BUILDFLAG(IS_TIZEN_TV)