[M120 Migration][VD] Provide ewk_settings_drag_drop_enabled_set api 24/310524/3
authorfang fengrong <fr.fang@samsung.com>
Tue, 30 Apr 2024 08:25:12 +0000 (16:25 +0800)
committerBot Blink <blinkbot@samsung.com>
Mon, 6 May 2024 06:47:22 +0000 (06:47 +0000)
The patch is for the requirement:
Provide ewk setting api for text/image selection and using
mouse drag and drop.

1.Provide ewk_settings_drag_drop_enabled_set api for app,
to set enable drag and drop true or false;
2.Check the dragDropEnabled value before handle mouse drag,
When app set enable drag and drop, mouse drag can handle.

Default is enable drag and drop.

References:
https://review.tizen.org/gerrit/#/c/296642

Change-Id: I2d6effdc2893a5f64c538d6c6eeaeb3cdf94020a
Signed-off-by: fang fengrong <fr.fang@samsung.com>
12 files changed:
content/browser/web_contents/web_contents_impl.cc
third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc
third_party/blink/public/common/web_preferences/web_preferences.h
third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h
third_party/blink/public/mojom/webpreferences/web_preferences.mojom
third_party/blink/public/web/web_settings.h
third_party/blink/renderer/core/exported/web_settings_impl.cc
third_party/blink/renderer/core/exported/web_settings_impl.h
third_party/blink/renderer/core/exported/web_view_impl.cc
third_party/blink/renderer/core/frame/settings.json5
third_party/blink/renderer/core/input/mouse_event_manager.cc
tizen_src/ewk/efl_integration/public/ewk_settings.cc

index 0c464a401143fbb7489fbc86e6085ef5af764620..38320619946c3aa087a0a1955b5122a2e3bacd41 100644 (file)
@@ -3290,6 +3290,7 @@ const blink::web_pref::WebPreferences WebContentsImpl::ComputeWebPreferences() {
   prefs.use_arrow_scroll = false;
   // Disallow file access from external urls by default.
   prefs.allow_file_access_from_external_urls = false;
+  prefs.drag_drop_enabled = true;
   prefs.use_scrollbar_thumb_focus_notifications = false;
 #endif
   if (command_line.HasSwitch(switches::kHideScrollbars)) {
index 14530faa78a0c87e401c84667247e3a48f7164f4..1c430f9fa8daddece097665b77f042ce7b014ef1 100644 (file)
@@ -264,6 +264,7 @@ bool StructTraits<blink::mojom::WebPreferencesDataView,
   out->use_arrow_scroll = data.use_arrow_scroll();
   out->allow_file_access_from_external_urls =
       data.allow_file_access_from_external_urls();
+  out->drag_drop_enabled = data.drag_drop_enabled();
   out->media_playback_notification_enabled =
       data.media_playback_notification_enabled();
   out->media_subtitle_notification_enabled =
index dab002ee3a9f82de29ffe574d9f8d718f0ef2620..4167ffa7e9d303ff3a8c1c63596b3d279bf0d536 100644 (file)
@@ -321,6 +321,7 @@ struct BLINK_COMMON_EXPORT WebPreferences {
 #endif
 
 #if BUILDFLAG(IS_TIZEN_TV)
+  bool drag_drop_enabled = true;
   bool media_playback_notification_enabled = false;
   bool media_subtitle_notification_enabled = false;
 #endif
index 03a12e1f996efd7d8dcf6a44de3aea19023d8b28..01499f4981fe3011a2b3367393d83aceafc26ff6 100644 (file)
@@ -185,6 +185,10 @@ struct BLINK_COMMON_EXPORT StructTraits<blink::mojom::WebPreferencesDataView,
     return r.additional_shared_array_buffer_schemes;
   }
 
+  static bool drag_drop_enabled(const blink::web_pref::WebPreferences& r) {
+    return r.drag_drop_enabled;
+  }
+
   static bool media_playback_notification_enabled(
       const blink::web_pref::WebPreferences& r) {
     return r.media_playback_notification_enabled;
index e95b14225c36d499daca4b9bc43657b903b711cf..08689421a877ab8dfc6ad23ae3a94bf22ad75d14 100644 (file)
@@ -546,4 +546,7 @@ struct WebPreferences {
 
   [EnableIf=is_tizen_tv]
   bool use_scrollbar_thumb_focus_notifications;
+
+  [EnableIf=is_tizen_tv]
+  bool drag_drop_enabled;
 };
index db68f21f7a06658dc619dfc9f96b5cc7770f270d..9eb9f00a00ca9203ac96c285bd2f08c0f04ad344 100644 (file)
@@ -296,6 +296,7 @@ class WebSettings {
 #if BUILDFLAG(IS_TIZEN_TV)
   virtual bool AllowFileAccessFromExternalURLs() = 0;
   virtual void SetAllowFileAccessFromExternalURLs(bool) = 0;
+  virtual void SetDragDropEnabled(bool) = 0;
   virtual void SetMediaSubtitleNotificationEnabled(bool) = 0;
   virtual bool MediaSubtitleNotificationEnabled() = 0;
   virtual void SetUseArrowScroll(bool) = 0;
index 5eb136e8519c18deabf786b281cbece1b05b674a..ccf19247bc1681c76b42f4967bf62178e719d9e8 100644 (file)
@@ -867,6 +867,10 @@ bool WebSettingsImpl::GetAccessibilityEnabled() {
 #endif
 
 #if BUILDFLAG(IS_TIZEN_TV)
+void WebSettingsImpl::SetDragDropEnabled(bool enabled) {
+  settings_->SetDragDropEnabled(enabled);
+}
+
 void WebSettingsImpl::SetMediaPlaybackNotificationEnabled(bool enabled) {
   settings_->SetMediaPlaybackNotificationEnabled(enabled);
 }
index b4187803b0fbe7edc6cf7c2c9c4dfb70ca7358cd..a03175e1472ab60f02425ed56410120bfc2f3e2f 100644 (file)
@@ -243,6 +243,7 @@ class CORE_EXPORT WebSettingsImpl final : public WebSettings {
 #if BUILDFLAG(IS_TIZEN_TV)
   void SetAllowFileAccessFromExternalURLs(bool) override;
   bool AllowFileAccessFromExternalURLs() override;
+  void SetDragDropEnabled(bool) override;
   void SetMediaPlaybackNotificationEnabled(bool) override;
   bool MediaPlaybackNotificationEnabled() override;
   void SetMediaSubtitleNotificationEnabled(bool) override;
index b0e55f47ae44f63b26584b2c4fe4cedf654b5b0e..5602c68686d4e78f67ab8eef1bf3f25bac070afd 100644 (file)
@@ -1793,6 +1793,7 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs,
   settings->SetUseArrowScroll(prefs.use_arrow_scroll);
   settings->SetUseScrollbarThumbFocusNotifications(
       prefs.use_scrollbar_thumb_focus_notifications);
+  settings->SetDragDropEnabled(prefs.drag_drop_enabled);
 #endif
 
 #if BUILDFLAG(IS_EFL)
index b8f00820fb5a8ebf256d4803b0ef8a0708464c54..58ee411a7a812fd506e97310973a6fdd25612272 100644 (file)
       initial: "false",
       type: "bool",
     },
+    // Whether drag and drop is enabled
+    {
+      name: "dragDropEnabled",
+      initial: true,
+      type: "bool",
+    },
   ],
 }
index 2119054d86cea7ca5302f815b8ca1385384648c3..6572f0046287de919d83675f59d7b464829de31d 100644 (file)
@@ -806,6 +806,13 @@ WebInputEventResult MouseEventManager::HandleMouseDraggedEvent(
   should_handle_drag = !is_pen;
 #endif
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  // Enable/Disable the DND(drop & drag) feature as app set.
+  if (frame_->GetSettings() && !frame_->GetSettings()->GetDragDropEnabled()) {
+    should_handle_drag = false;
+  }
+#endif
+
   if (should_handle_drag && HandleDrag(event, DragInitiator::kMouse))
     return WebInputEventResult::kHandledSystem;
 
index e2c41f6cde8f5dd944bae18e7153f9b9b68ca624..546ae319e42a81b4d6b084871e8d2beb14b10042 100644 (file)
@@ -973,13 +973,26 @@ Eina_Bool ewk_settings_swipe_to_refresh_enabled_get(const Ewk_Settings *settings
 
 void ewk_settings_drag_drop_enabled_set(Ewk_Settings* settings, Eina_Bool enabled)
 {
-  LOG_EWK_API_MOCKUP();
+#if BUILDFLAG(IS_TIZEN_TV)
+  EINA_SAFETY_ON_NULL_RETURN(settings);
+  LOG(INFO) << "ewk_settings_drag_drop_enabled_set, enabled: " << !!enabled;
+  settings->getPreferences().drag_drop_enabled = !!enabled;
+  ewkUpdateWebkitPreferences(settings->ewk_view());
+#else
+  LOG_EWK_API_MOCKUP("Only for Tizen TV");
+#endif
+
 }
 
 Eina_Bool ewk_settings_drag_drop_enabled_get(const Ewk_Settings* settings)
 {
-  LOG_EWK_API_MOCKUP();
+#if BUILDFLAG(IS_TIZEN_TV)
+  EINA_SAFETY_ON_NULL_RETURN_VAL(settings, EINA_FALSE);
+  return settings->getPreferences().drag_drop_enabled;
+#else
+  LOG_EWK_API_MOCKUP("Only for Tizen TV");
   return EINA_FALSE;
+#endif
 }
 
 void ewk_settings_clipboard_enabled_set(Ewk_Settings* settings, Eina_Bool enabled)