[M108 Migration] Migrate changes related to touch events 74/288374/2
authorayush.k123 <ayush.k123@samsung.com>
Wed, 15 Feb 2023 03:51:00 +0000 (09:21 +0530)
committerAyush Kumar <ayush.k123@samsung.com>
Thu, 16 Feb 2023 06:50:41 +0000 (12:20 +0530)
This patch migrates following changes related to touch events:
1. Add helper function for making ui::TouchEvent
2. Set touch events enable/disable preference from ewk api to
   EflEventHandler

Reference:
1. https://review.tizen.org/gerrit/281666
2. https://review.tizen.org/gerrit/282749

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

index 1b07939..7005822 100644 (file)
@@ -1163,4 +1163,16 @@ void RWHVAuraOffscreenHelperEfl::BackgroundColorReceived(int callback_id,
   web_contents_->GetDelegate()->BackgroundColorReceived(callback_id, bg_color);
 }
 
+void RWHVAuraOffscreenHelperEfl::SetTouchEventsEnabled(bool enabled) {
+  if (auto* event_handler = GetEventHandler())
+    event_handler->SetTouchEventsEnabled(enabled);
+}
+
+bool RWHVAuraOffscreenHelperEfl::TouchEventsEnabled() {
+  if (auto* event_handler = GetEventHandler())
+    return event_handler->TouchEventsEnabled();
+
+  return false;
+}
+
 }  // namespace content
index c024976..216e234 100644 (file)
@@ -72,6 +72,9 @@ class CONTENT_EXPORT RWHVAuraOffscreenHelperEfl {
   gfx::Size GetPhysicalBackingSize() const;
   void OnGetFocusedNodeBounds(const gfx::RectF& rect);
 
+  void SetTouchEventsEnabled(bool enabled);
+  bool TouchEventsEnabled();
+
   bool GetHorizontalPanningHold() const { return horizontal_panning_hold_; }
   void SetHorizontalPanningHold(bool hold) { horizontal_panning_hold_ = hold; }
   bool GetVerticalPanningHold() const { return vertical_panning_hold_; }
index 3788a5d..9ec559c 100644 (file)
@@ -80,6 +80,7 @@
 #include "ui/events/event_switches.h"
 #include "ui/gfx/geometry/dip_util.h"
 #include "ui/gfx/geometry/vector2d_f.h"
+#include "ui/ozone/platform/efl/efl_event_handler.h"
 #include "ui/platform_window/platform_window_init_properties.h"
 #include "web_contents_delegate_efl.h"
 #include "web_contents_efl_delegate_ewk.h"
@@ -234,13 +235,6 @@ EWebView* EWebView::FromEvasObject(Evas_Object* eo) {
   return WebViewDelegateEwk::GetInstance().GetWebViewFromEvasObject(eo);
 }
 
-#if !defined(USE_AURA)
-RenderWidgetHostViewEfl* EWebView::rwhv() const {
-  return static_cast<RenderWidgetHostViewEfl*>(
-      web_contents_->GetRenderWidgetHostView());
-}
-#endif
-
 void EWebView::OnViewFocusIn(void* data, Evas*, Evas_Object*, void*) {
   auto view = static_cast<EWebView*>(data);
   view->SetFocus(EINA_TRUE);
@@ -255,7 +249,6 @@ EWebView::EWebView(Ewk_Context* context, Evas_Object* object)
     : context_(context),
       evas_object_(object),
       native_view_(object),
-      touch_events_enabled_(false),
       mouse_events_enabled_(false),
       text_zoom_factor_(1.0),
       formIsNavigating_(false),
@@ -787,7 +780,6 @@ void EWebView::InvokePolicyNavigationCallback(
 void EWebView::HandleTouchEvents(Ewk_Touch_Event_Type type,
                                  const Eina_List* points,
                                  const Evas_Modifier* modifiers) {
-#if !defined(USE_AURA)
   const Eina_List* l;
   void* data;
   EINA_LIST_FOREACH(points, l, data) {
@@ -796,41 +788,45 @@ void EWebView::HandleTouchEvents(Ewk_Touch_Event_Type type,
       // Chromium doesn't expect (and doesn't like) these events.
       continue;
     }
-    if (rwhv()) {
+    if (rwhva()) {
       Evas_Coord_Point pt;
       pt.x = point->x;
       pt.y = point->y;
+
+      int delta_y = 0;
+      evas_object_geometry_get(evas_object(), nullptr, &delta_y, nullptr,
+                               nullptr);
       ui::TouchEvent touch_event =
-          MakeTouchEvent(pt, point->state, point->id, evas_object());
-      rwhv()->HandleTouchEvent(&touch_event);
+          ui::MakeTouchEvent(pt, point->state, point->id, 0, delta_y);
+      rwhva()->OnTouchEvent(&touch_event);
     }
   }
-#endif
 }
 
 bool EWebView::TouchEventsEnabled() const {
-  return touch_events_enabled_;
+  return rwhva()->offscreen_helper()->TouchEventsEnabled();
 }
 
 // TODO: Touch events use the same mouse events in EFL API.
 // Figure out how to distinguish touch and mouse events on touch&mice devices.
 // Currently mouse and touch support is mutually exclusive.
 void EWebView::SetTouchEventsEnabled(bool enabled) {
-  if (touch_events_enabled_ == enabled)
+  if (!rwhva() || !rwhva()->offscreen_helper()) {
+    LOG(WARNING) << "RWHV is not created yet!";
     return;
+  }
 
-  touch_events_enabled_ = enabled;
-#if !defined(USE_AURA)
-  GetWebContentsViewEfl()->SetTouchEventsEnabled(enabled);
-#endif
-#if !defined(EWK_BRINGUP)  // FIXME: m94 bringup
-  // there is no flag touch_enabled in web preferences
-  GetSettings()->getPreferences().touch_enabled = enabled;
+  if (rwhva()->offscreen_helper()->TouchEventsEnabled() == enabled)
+    return;
+
+  rwhva()->offscreen_helper()->SetTouchEventsEnabled(enabled);
+
+  GetSettings()->getPreferences().touch_event_feature_detection_enabled =
+      enabled;
   GetSettings()->getPreferences().double_tap_to_zoom_enabled = enabled;
   GetSettings()->getPreferences().editing_behavior =
-      enabled ? content::EDITING_BEHAVIOR_ANDROID
-              : content::EDITING_BEHAVIOR_UNIX;
-#endif
+      enabled ? blink::mojom::EditingBehavior::kEditingAndroidBehavior
+              : blink::mojom::EditingBehavior::kEditingUnixBehavior,
   UpdateWebKitPreferences();
 }
 
@@ -839,13 +835,16 @@ bool EWebView::MouseEventsEnabled() const {
 }
 
 void EWebView::SetMouseEventsEnabled(bool enabled) {
+  if (!rwhva() || !rwhva()->offscreen_helper()) {
+    LOG(WARNING) << "RWHV is not created yet!";
+    return;
+  }
+
   if (mouse_events_enabled_ == enabled)
     return;
 
   mouse_events_enabled_ = enabled;
-#if !defined(USE_AURA)
-  GetWebContentsViewEfl()->SetTouchEventsEnabled(!enabled);
-#endif
+  rwhva()->offscreen_helper()->SetTouchEventsEnabled(!enabled);
 }
 
 namespace {
@@ -953,12 +952,6 @@ bool EWebView::SetUserAgentAppName(const char* application_name) {
   return true;
 }
 
-void EWebView::set_magnifier(bool status) {
-#if !defined(USE_AURA)
-  rwhv()->set_magnifier(status);
-#endif
-}
-
 #if BUILDFLAG(IS_TIZEN)
 bool EWebView::SetPrivateBrowsing(bool incognito) {
   if (context_->GetImpl()->browser_context()->IsOffTheRecord() == incognito)
@@ -1252,13 +1245,13 @@ void EWebView::PopupMenuClose() {
 
 void EWebView::HandleLongPressGesture(
     const content::ContextMenuParams& params) {
-#if !defined(USE_AURA)
   // This menu is created in renderer process and it does not now anything about
   // view scaling factor and it has another calling sequence, so coordinates is
   // not updated.
   content::ContextMenuParams convertedParams = params;
   gfx::Point convertedPoint =
-      rwhv()->ConvertPointInViewPix(gfx::Point(params.x, params.y));
+      rwhva()->offscreen_helper()->ConvertPointInViewPix(
+          gfx::Point(params.x, params.y));
   convertedParams.x = convertedPoint.x();
   convertedParams.y = convertedPoint.y();
 
@@ -1274,7 +1267,6 @@ void EWebView::HandleLongPressGesture(
     if (show_context_menu_now)
       ShowContextMenuInternal(convertedParams);
   }
-#endif
 }
 
 void EWebView::ShowContextMenu(const content::ContextMenuParams& params) {
index bcf8a89..eda7a4a 100644 (file)
@@ -311,8 +311,6 @@ class EWebView {
     return EWebViewCallbacks::CallBack<callbackType>(evas_object_);
   }
 
-  void set_magnifier(bool status);
-
   // ewk_view api
   void SetURL(const GURL& url, bool from_api = false);
   const GURL& GetURL() const;
@@ -699,9 +697,6 @@ class EWebView {
 #if BUILDFLAG(IS_TIZEN) && !defined(EWK_BRINGUP)
   bool LaunchCamera(std::u16string mimetype);
 #endif
-#if !defined(USE_AURA)
-  content::RenderWidgetHostViewEfl* rwhv() const;
-#endif
   JavaScriptDialogManagerEfl* GetJavaScriptDialogManagerEfl();
 
   void ReleasePopupMenuList();
@@ -738,7 +733,6 @@ class EWebView {
   std::unique_ptr<_Ewk_Policy_Decision> window_policy_;
   Evas_Object* evas_object_;
   Evas_Object* native_view_;
-  bool touch_events_enabled_;
   bool mouse_events_enabled_;
   double text_zoom_factor_;
   mutable std::string user_agent_;