(WebView) Update and sync all the latest patches related to WebView that have been... 37/322137/3
authordongsug.song <dongsug.song@samsung.com>
Fri, 4 Apr 2025 01:43:05 +0000 (10:43 +0900)
committerdongsug.song <dongsug.song@samsung.com>
Tue, 8 Apr 2025 09:05:32 +0000 (18:05 +0900)
- Add SetVideoHole() for EFL window
- Add WebView DeviceListGet,SetDefaultAudio
- Add WebView FeedMouseWheel as hidden api
- Add APIs for setting IME position, cursor theme name.

Change-Id: I02ffba7b09246f162e61866d9a4929e2f5444808

automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp
automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp
dali-toolkit/devel-api/controls/web-view/web-settings.cpp
dali-toolkit/devel-api/controls/web-view/web-settings.h
dali-toolkit/devel-api/controls/web-view/web-view.cpp
dali-toolkit/devel-api/controls/web-view/web-view.h
dali-toolkit/internal/controls/web-view/web-view-impl.cpp
dali-toolkit/internal/controls/web-view/web-view-impl.h

index 61e9d3ebd1bd48209bac072d3f8eb1f36d57ac9c..759e6e872dece163ec57663440496c53797575d7 100644 (file)
@@ -44,6 +44,7 @@
 #include <toolkit-application.h>
 #include <memory>
 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-user-media-permission-request.h>
+#include <dali/devel-api/adaptor-framework/web-engine/web-engine-plugin.h>
 
 namespace Dali
 {
@@ -905,7 +906,8 @@ public:
     mockClipboardEnabled(true),
     mockImePanelEnabled(true),
     mockImageLoadedAutomatically(true),
-    mockDefaultTextEncodingName()
+    mockDefaultTextEncodingName(),
+    mockImeStyle(9)
   {
   }
 
@@ -1135,6 +1137,20 @@ public:
     return true;
   }
 
+  void SetImeStyle(int style) override
+  {
+    mockImeStyle = style;
+  }
+
+  int GetImeStyle() const override
+  {
+    return mockImeStyle;
+  }
+
+  void SetDefaultAudioInputDevice(const std::string& deviceId) const override
+  {
+  }
+
 private:
   int         mockDefaultFontSize;
   bool        mockJavaScriptEnabled;
@@ -1152,6 +1168,7 @@ private:
   bool        mockImePanelEnabled;
   bool        mockImageLoadedAutomatically;
   std::string mockDefaultTextEncodingName;
+  int         mockImeStyle;
 };
 
 class MockWebEnginePlugin : public Dali::WebEnginePlugin
@@ -1522,6 +1539,31 @@ public:
   {
   }
 
+  bool SetImePositionAndAlignment(Dali::Vector2 position, int alignment) override
+  {
+    return true;
+  }
+
+  void SetCursorThemeName(const std::string themeName) override
+  {
+  }
+
+  void RegisterDeviceConnectionChangedCallback(Dali::WebEnginePlugin::WebEngineDeviceConnectionChangedCallback callback) override
+  {
+  }
+
+  void RegisterDeviceListGetCallback(Dali::WebEnginePlugin::WebEngineDeviceListGetCallback callback) override
+  {
+  }
+
+  void FeedMouseWheel(bool yDirection, int step, int x, int y) override
+  {
+  }
+
+  void SetVideoHole(bool enabled, bool isWaylandWindow) override
+  {
+  }
+
 private:
   MockWebEngineSettings        settings;
   MockWebEngineBackForwardList backForwardList;
@@ -2030,6 +2072,31 @@ public:
     mUserMediaPermissionRequestCallback = callback;
   }
 
+  bool SetImePositionAndAlignment(Dali::Vector2 position, int alignment)
+  {
+    return true;
+  }
+
+  void SetCursorThemeName(const std::string themeName)
+  {
+  }
+
+  void RegisterDeviceConnectionChangedCallback(Dali::WebEnginePlugin::WebEngineDeviceConnectionChangedCallback callback)
+  {
+  }
+
+  void RegisterDeviceListGetCallback(Dali::WebEnginePlugin::WebEngineDeviceListGetCallback callback)
+  {
+  }
+
+  void FeedMouseWheel(bool yDirection, int step, int x, int y)
+  {
+  }
+
+  void SetVideoHole(bool enabled, bool isWaylandWindow)
+  {
+  }
+
   std::string              mUrl;
   std::vector<std::string> mHistory;
   size_t                   mCurrentPlusOnePos;
@@ -2239,7 +2306,7 @@ bool OnLoadUrl()
     if(gInstance->mUserMediaPermissionRequestCallback)
     {
       std::unique_ptr<Dali::WebEngineUserMediaPermissionRequest> request(new MockUserMediaPermissionRequest());
-      gInstance->mUserMediaPermissionRequestCallback(std::move(request), "message");
+      gInstance->mUserMediaPermissionRequestCallback(request.get(), "message");
     }
   }
   return false;
@@ -3043,5 +3110,34 @@ void WebEngine::RegisterUserMediaPermissionRequestCallback(Dali::WebEnginePlugin
   Internal::Adaptor::GetImplementation(*this).RegisterUserMediaPermissionRequestCallback(callback);
 }
 
+bool WebEngine::SetImePositionAndAlignment(Dali::Vector2 position, int alignment)
+{
+  return Internal::Adaptor::GetImplementation(*this).SetImePositionAndAlignment(position, alignment);
+}
+
+void WebEngine::SetCursorThemeName(const std::string themeName)
+{
+  Internal::Adaptor::GetImplementation(*this).SetCursorThemeName(themeName);
+}
+
+void WebEngine::RegisterDeviceConnectionChangedCallback(Dali::WebEnginePlugin::WebEngineDeviceConnectionChangedCallback callback)
+{
+  Internal::Adaptor::GetImplementation(*this).RegisterDeviceConnectionChangedCallback(callback);
+}
+
+void WebEngine::RegisterDeviceListGetCallback(Dali::WebEnginePlugin::WebEngineDeviceListGetCallback callback)
+{
+  Internal::Adaptor::GetImplementation(*this).RegisterDeviceListGetCallback(callback);
+}
+
+void WebEngine::FeedMouseWheel(bool yDirection, int step, int x, int y)
+{
+  Internal::Adaptor::GetImplementation(*this).FeedMouseWheel(yDirection, step, x, y);
+}
+
+void WebEngine::SetVideoHole(bool enabled, bool isWaylandWindow)
+{
+  Internal::Adaptor::GetImplementation(*this).SetVideoHole(enabled, isWaylandWindow);
+}
 
 } // namespace Dali
index a35a4eabc0117f7b1555a09a29c098f305d087f8..a5639b1ae7455226e6d84474c86ae6eb7e64a8ca 100644 (file)
@@ -363,11 +363,22 @@ static void OnWebAuthResponse()
   gWebAuthDisplayResponseCalled++;
 }
 
-static void OnUserMediaPermissionRequest(std::unique_ptr<Dali::WebEngineUserMediaPermissionRequest> request, const std::string& msg)
+static void OnUserMediaPermissionRequest(Dali::WebEngineUserMediaPermissionRequest*, const std::string&)
 {
   gUserMediaPermissionRequestCalled++;
 }
 
+//using WebEngineDeviceConnectionChangedCallback = std::function<void(int32_t)>;
+static void OnDeviceConnectionChanged(int32_t)
+{
+}
+
+//using WebEngineDeviceListGetCallback = std::function<void(Dali::WebEngineDeviceListGet*, int32_t)>;
+static void OnDeviceListGetCallback(Dali::WebEngineDeviceListGet*, int32_t)
+{
+}
+
+
 } // namespace
 
 void web_view_startup(void)
@@ -2406,6 +2417,43 @@ int UtcDaliWebSettingsSetExtraFeature(void)
   END_TEST;
 }
 
+int UtcDaliWebSettingsSetImeStyle(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK(view);
+
+  Dali::Toolkit::WebSettings* settings = view.GetSettings();
+  DALI_TEST_CHECK(settings != 0)
+
+  // Check the value is true or not
+  int value = settings->GetImeStyle();
+  DALI_TEST_CHECK(value);
+
+  settings->SetImeStyle(99);
+
+  value = settings->GetImeStyle();
+  DALI_TEST_EQUALS(value, 99, TEST_LOCATION);
+
+  END_TEST;
+}
+
+int UtcDaliWebSettingsSetDefaultAudioInputDevice(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK(view);
+
+  Dali::Toolkit::WebSettings* settings = view.GetSettings();
+  DALI_TEST_CHECK(settings != 0)
+
+  settings->SetDefaultAudioInputDevice("test");
+
+  END_TEST;
+}
+
 int UtcDaliWebViewGetPlainText(void)
 {
   ToolkitTestApplication application;
@@ -2612,6 +2660,79 @@ int UtcDaliWebViewRegisterUserMediaPermissionRequestCallback(void)
   END_TEST;
 }
 
+int UtcDaliWebViewSetImePositionAndAlignment(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK(view);
+
+  bool ret = view.SetImePositionAndAlignment(Vector2(0, 0), 9);
+  DALI_TEST_EQUALS(ret, true, TEST_LOCATION);
+
+  END_TEST;
+}
+
+int UtcDaliWebViewSetCursorThemeName(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK(view);
+
+  view.SetCursorThemeName("test");
+
+  END_TEST;
+}
+
+int UtcDaliWebViewRegisterDeviceConnectionChangedCallback(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK(view);
+
+  view.RegisterDeviceConnectionChangedCallback(&OnDeviceConnectionChanged);
+
+  END_TEST;
+}
+
+int UtcDaliWebViewRegisterDeviceListGetCallback(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK(view);
+
+  view.RegisterDeviceListGetCallback(&OnDeviceListGetCallback);
+
+  END_TEST;
+}
+
+int UtcDaliWebViewFeedMouseWheel(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK(view);
+
+  view.FeedMouseWheel(false, 1, 1, 1);
+
+  END_TEST;
+}
+
+int UtcDaliWebViewSetVideoHole(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK(view);
+
+  view.SetVideoHole(true, false);
+
+  END_TEST;
+}
+
 int UtcDaliWebViewWebAuthenticationCancel(void)
 {
   ToolkitTestApplication application;
index 385ecc6210d7f2464553edc3d6792f05554f9618..e0ab251f8dc3522d69ca4b4e25be3867063a65cb 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -269,6 +269,21 @@ bool WebSettings::IsExtraFeatureEnabled(const std::string& feature) const
   return mWebEngineSettings.IsExtraFeatureEnabled(feature);
 }
 
+void WebSettings::SetImeStyle(int style)
+{
+  mWebEngineSettings.SetImeStyle(style);
+}
+
+int WebSettings::GetImeStyle() const
+{
+  return mWebEngineSettings.GetImeStyle();
+}
+
+void WebSettings::SetDefaultAudioInputDevice(const std::string& deviceId) const
+{
+  mWebEngineSettings.SetDefaultAudioInputDevice(deviceId);
+}
+
 
 } // namespace Toolkit
 
index de428338c6f7212148aab45bd7f06226e1e07665..607c4ec0b5aad896f99071e09fe7c9f603c0034e 100755 (executable)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_WEB_SETTINGS_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -407,6 +407,33 @@ public:
    */
   bool IsExtraFeatureEnabled(const std::string& feature) const;
 
+  /**
+   * @brief Sets the style of IME.
+   *
+   * @param[in] style @c IME_STYLE_FULL       full IME style
+   *                  @c IME_STYLE_FLOATING   floating IME style
+   *                  @c IME_STYLE_DYNAMIC    dynamic IME style
+   *
+   */
+  void SetImeStyle(int style);
+
+  /**
+   * @brief Gets the style of IME.
+   *
+   * @return @c IME_STYLE_FULL       full IME style
+   *         @c IME_STYLE_FLOATING   floating IME style
+   *         @c IME_STYLE_DYNAMIC    dynamic IME style
+   */
+  int GetImeStyle() const;
+
+  /**
+   * @brief Sets default audio input device
+   *
+   * @param[in] deviceId default device ID
+   */
+  void SetDefaultAudioInputDevice(const std::string& deviceId) const;
+
+
 private:
   Dali::WebEngineSettings& mWebEngineSettings;
 };
index 05d5a7be7e3f511bb3881456ab6fb347ff37df33..27fe02612b49fe5595f4418c1fc6f487c095093c 100755 (executable)
@@ -189,6 +189,16 @@ bool WebView::StopInspectorServer()
   return Dali::Toolkit::GetImpl(*this).StopInspectorServer();
 }
 
+bool WebView::SetImePositionAndAlignment(Dali::Vector2 position, int alignment)
+{
+  return Dali::Toolkit::GetImpl(*this).SetImePositionAndAlignment(position, alignment);
+}
+
+void WebView::SetCursorThemeName(const std::string themeName)
+{
+  Dali::Toolkit::GetImpl(*this).SetCursorThemeName(themeName);
+}
+
 void WebView::ScrollBy(int32_t deltaX, int32_t deltaY)
 {
   Dali::Toolkit::GetImpl(*this).ScrollBy(deltaX, deltaY);
@@ -474,6 +484,25 @@ void WebView::RegisterUserMediaPermissionRequestCallback(Dali::WebEnginePlugin::
   Dali::Toolkit::GetImpl(*this).RegisterUserMediaPermissionRequestCallback(callback);
 }
 
+void WebView::RegisterDeviceConnectionChangedCallback(Dali::WebEnginePlugin::WebEngineDeviceConnectionChangedCallback callback)
+{
+  Dali::Toolkit::GetImpl(*this).RegisterDeviceConnectionChangedCallback(callback);
+}
+
+void WebView::RegisterDeviceListGetCallback(Dali::WebEnginePlugin::WebEngineDeviceListGetCallback callback)
+{
+  Dali::Toolkit::GetImpl(*this).RegisterDeviceListGetCallback(callback);
+}
+
+void WebView::FeedMouseWheel(bool yDirection, int step, int x, int y)
+{
+  Dali::Toolkit::GetImpl(*this).FeedMouseWheel(yDirection, step, x, y);
+}
+
+void WebView::SetVideoHole(bool enabled, bool isWaylandWindow)
+{
+  Dali::Toolkit::GetImpl(*this).SetVideoHole(enabled, isWaylandWindow);
+}
 
 WebView::WebView(Internal::WebView& implementation)
 : Control(implementation)
index cacec2467177a10ff001e7c19050d59076c0a740..3719c79d9beaeb2bb5dcf3747cb95aa8c6e0be99 100755 (executable)
@@ -413,6 +413,21 @@ public:
    */
   bool StopInspectorServer();
 
+  /**
+   * @brief Set the style of IME.
+   * @param[in] position Position of IME.
+   * @param[in] alignment Alignment of IME.
+   *
+   * @return true if succeeded, false otherwise
+   */
+  bool SetImePositionAndAlignment(Dali::Vector2 position, int alignment);
+
+  /**
+   * @brief Set the theme name of cursor.
+   * @param[in] themeName The name of theme of cursor.
+   */
+  void SetCursorThemeName(const std::string themeName);
+
   /**
    * @brief Scroll web page of view by deltaX and deltaY.
    * @param[in] deltaX The delta x of scroll
@@ -839,6 +854,37 @@ public:
    */
   void RegisterUserMediaPermissionRequestCallback(Dali::WebEnginePlugin::WebEngineUserMediaPermissionRequestCallback callback);
 
+  /**
+   * @brief Feed mouse wheel event forcefully.
+   *
+   * @param[in] yDirection wheel event's y direction.
+   * @param[in] step step of wheel event.
+   * @param[in] x x value of wheel event.
+   * @param[in] y y value of wheel event.
+   */
+  void FeedMouseWheel(bool yDirection, int step, int x, int y);
+
+  /**
+   * @brief Enable video hole for a specific window type.
+   * @param[in] enabled True if enabled, false othewise.
+   * @param[in] isWaylandWindow True if wayland window, false if EFL window.
+   */
+  void SetVideoHole(bool enabled, bool isWaylandWindow);
+
+  /**
+   * @brief Register DeviceConnectionChanged callback.
+   *
+   * @param[in] callback The callback to be called for handling device connection changed event.
+   */
+  void RegisterDeviceConnectionChangedCallback(Dali::WebEnginePlugin::WebEngineDeviceConnectionChangedCallback callback);
+
+  /**
+   * @brief Register DeviceListGet callback.
+   *
+   * @param[in] callback The callback to be called for getting device list.
+   */
+  void RegisterDeviceListGetCallback(Dali::WebEnginePlugin::WebEngineDeviceListGetCallback callback);
+
 public: // Not intended for application developers
   /// @cond internal
   /**
index 85a5d4db21c135ee0ae3427bb85f102ad80eb65c..445c2a45230ce06fd5fd2c3a9295d39a5aa44c22 100644 (file)
@@ -508,6 +508,19 @@ bool WebView::StopInspectorServer()
   return mWebEngine ? mWebEngine.StopInspectorServer() : false;
 }
 
+bool WebView::SetImePositionAndAlignment(Dali::Vector2 position, int alignment)
+{
+  return mWebEngine ? mWebEngine.SetImePositionAndAlignment(position, alignment) : false;
+}
+
+void WebView::SetCursorThemeName(const std::string themeName)
+{
+  if(mWebEngine)
+  {
+    mWebEngine.SetCursorThemeName(themeName);
+  }
+}
+
 void WebView::ScrollBy(int32_t deltaX, int32_t deltaY)
 {
   if(mWebEngine)
@@ -982,6 +995,43 @@ void WebView::RegisterUserMediaPermissionRequestCallback(Dali::WebEnginePlugin::
   }
 }
 
+void WebView::RegisterDeviceConnectionChangedCallback(Dali::WebEnginePlugin::WebEngineDeviceConnectionChangedCallback callback)
+{
+  if(mWebEngine)
+  {
+    mWebEngine.RegisterDeviceConnectionChangedCallback(std::move(callback));
+  }
+}
+
+void WebView::RegisterDeviceListGetCallback(Dali::WebEnginePlugin::WebEngineDeviceListGetCallback callback)
+{
+  if(mWebEngine)
+  {
+    mWebEngine.RegisterDeviceListGetCallback(std::move(callback));
+  }
+}
+
+void WebView::FeedMouseWheel(bool yDirection, int step, int x, int y)
+{
+  if(mWebEngine)
+  {
+    mWebEngine.FeedMouseWheel(yDirection, step, x, y);
+  }
+}
+
+void WebView::SetVideoHole(bool enabled, bool isWaylandWindow)
+{
+  mVideoHoleEnabled = enabled;
+
+  EnableBlendMode(!mVideoHoleEnabled);
+
+  if(mWebEngine)
+  {
+    DALI_LOG_DEBUG_INFO("WebView[%p] SetVideoHole(%d) isWaylandWindow(%d)\n", this, mVideoHoleEnabled, isWaylandWindow);
+    mWebEngine.SetVideoHole(mVideoHoleEnabled, isWaylandWindow);
+  }
+}
+
 void WebView::OnFrameRendered()
 {
   if(mFrameRenderedCallback)
index 21a4c766605ef02467430f2d7849b5fe68dcda9a..ba517780f67eefccc72f55e9b84899c434992e56 100644 (file)
@@ -187,6 +187,21 @@ public:
    */
   bool StopInspectorServer();
 
+  /**
+   * @brief Set the style of IME.
+   * @param[in] position Position of IME.
+   * @param[in] alignment Alignment of IME.
+   *
+   * @return true if succeeded, false otherwise
+   */
+  bool SetImePositionAndAlignment(Dali::Vector2 position, int alignment);
+
+  /**
+   * @brief Set the theme name of cursor.
+   * @param[in] themeName The name of theme of cursor.
+   */
+  void SetCursorThemeName(const std::string themeName);
+
   /**
    * @copydoc Dali::Toolkit::WebView::ScrollBy()
    */
@@ -467,6 +482,26 @@ public:
    */
   void RegisterUserMediaPermissionRequestCallback(Dali::WebEnginePlugin::WebEngineUserMediaPermissionRequestCallback callback);
 
+  /**
+   * @copydoc Dali::Toolkit::WebView::RegisterDeviceConnectionChangedCallback()
+   */
+  void RegisterDeviceConnectionChangedCallback(Dali::WebEnginePlugin::WebEngineDeviceConnectionChangedCallback callback);
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::RegisterDeviceListGetCallback()
+   */
+  void RegisterDeviceListGetCallback(Dali::WebEnginePlugin::WebEngineDeviceListGetCallback callback);
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::FeedMouseWheel()
+   */
+  void FeedMouseWheel(bool yDirection, int step, int x, int y);
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::SetVideoHole()
+   */
+  void SetVideoHole(bool enabled, bool isWaylandWindow);
+
 public: // Properties
   /**
    * @brief Called when a property of an object of this type is set.