[dali_2.3.22] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / web-view / web-view-impl.h
old mode 100755 (executable)
new mode 100644 (file)
index cfbb31e..6415a8b
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_INTERNAL_WEB_VIEW_H
 
 /*
- * 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.
@@ -25,7 +25,6 @@
 #include <dali/public-api/images/image-operations.h>
 #include <dali/public-api/object/property-notification.h>
 #include <memory>
-#include <unordered_map>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/devel-api/controls/control-accessible.h>
@@ -99,6 +98,11 @@ public:
   Dali::Toolkit::WebBackForwardList* GetBackForwardList() const;
 
   /**
+   * @copydoc Dali::Toolkit::WebView::GetPlugin()
+   */
+  Dali::WebEnginePlugin* GetPlugin() const;
+
+  /**
    * @copydoc Dali::Toolkit::WebView::GetFavicon()
    */
   Dali::Toolkit::ImageView GetFavicon() const;
@@ -121,7 +125,7 @@ public:
   /**
    * @copydoc Dali::WebEngine::LoadContents()
    */
-  bool LoadContents(const std::string& contents, uint32_t contentSize, const std::string& mimeType, const std::string& encoding, const std::string& baseUri);
+  bool LoadContents(const int8_t* contents, uint32_t contentSize, const std::string& mimeType, const std::string& encoding, const std::string& baseUri);
 
   /**
    * @copydoc Dali::Toolkit::WebView::Reload()
@@ -374,6 +378,11 @@ public:
   void RegisterNavigationPolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineNavigationPolicyDecidedCallback callback);
 
   /**
+   * @copydoc Dali::Toolkit::WebView::RegisterNewWindowCreatedCallback()
+   */
+  void RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback);
+
+  /**
    * @copydoc Dali::Toolkit::WebView::RegisterCertificateConfirmedCallback()
    */
   void RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback);
@@ -434,6 +443,11 @@ private: // From Control
   DevelControl::ControlAccessible* CreateAccessibleObject() override;
 
   /**
+   * @copydoc Toolkit::Internal::Control::OnRelayout()
+   */
+  void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
+
+  /**
    * @copydoc Toolkit::Control::GetNaturalSize
    */
   Vector3 GetNaturalSize() override;
@@ -458,6 +472,11 @@ private: // From Control
    */
   void OnSceneConnection(int depth) override;
 
+  /**
+   * @copydoc Toolkit::Control::OnSceneDisconnection()
+   */
+  void OnSceneDisconnection() override;
+
 private:
   // Undefined
   WebView(const WebView& webView);
@@ -465,11 +484,6 @@ private:
   WebView& operator=(const WebView& webView);
 
   /**
-   * @brief Gets web engine plugin.
-   */
-  Dali::WebEnginePlugin* GetPlugin() const;
-
-  /**
    * @brief Set an absolute scroll of the given view.
    * @param[in] x The coordinate x of scroll
    * @param[in] y The coordinate y of scroll
@@ -593,12 +607,6 @@ private:
   bool SetVisibility(bool visible);
 
   /**
-   * @brief Update display area of web view.
-   * @param[in] source The soource triggers Notification.
-   */
-  void UpdateDisplayArea(Dali::PropertyNotification& source);
-
-  /**
    * @brief Enable/Disable video hole for video playing.
    * @param[in] enabled True if video hole is enabled, false otherwise.
    */
@@ -661,9 +669,10 @@ private:
   void OnFrameRendered();
 
   /**
-   * @brief Callback function to be called when frame is rendered. This is to check initial buffer is ready.
+   * @brief Callback for updating display area of web view.
+   * @param[in] source The soource triggers Notification.
    */
-  void OnInitialFrameRendered();
+  void OnDisplayAreaUpdated(Dali::PropertyNotification& source);
 
   /**
    * @brief Callback function to be called when visibility is changed.
@@ -674,11 +683,31 @@ private:
   void OnVisibilityChanged(Actor actor, bool isVisible, Dali::DevelActor::VisibilityChange::Type type);
 
   /**
+   * @brief Callback when the visibility of the window is changed.
+   * @param[in] window The window whose visibility has changed
+   * @param[in] visible Whether the window is now visible or not
+   */
+  void OnWindowVisibilityChanged(Window window, bool visible);
+
+  /**
    * @brief callback for screen shot captured.
    * @param[in] pixel Pixel data of screen shot.
    */
   void OnScreenshotCaptured(Dali::PixelData pixel);
 
+  /**
+   * @brief Set DisplayArea by input value.
+   * It will send changes area infomations to webengine internally.
+   *
+   * @param[in] displayArea The display area for current webview want to show.
+   */
+  void SetDisplayArea(const Dali::Rect<int32_t>& displayArea);
+
+  /**
+   * @brief Apply self visibility state and send visibility chagend to web engine.
+   */
+  void ApplyVisibilityCheck();
+
 protected:
   class WebViewAccessible : public DevelControl::ControlAccessible
   {
@@ -712,6 +741,22 @@ private:
   Dali::Size                  mWebViewSize;
   Dali::WebEngine             mWebEngine;
 
+  uint32_t mLastRenderedNativeImageWidth;
+  uint32_t mLastRenderedNativeImageHeight;
+
+  enum WebViewVisibleStateFlag
+  {
+    NONE        = 0,
+    SCENE_ON    = 1 << 0,
+    WINDOW_SHOW = 1 << 1,
+    SELF_SHOW   = 1 << 2,
+    PARENT_SHOW = 1 << 3,
+
+    VISIBLE = SCENE_ON | WINDOW_SHOW | SELF_SHOW | PARENT_SHOW,
+  };
+  uint32_t           mWebViewVisibleState{WebViewVisibleStateFlag::NONE}; /// Flag of web view visible.
+  WeakHandle<Window> mPlacementWindow;
+
   std::unique_ptr<Dali::Toolkit::WebSettings>        mWebSettings;
   std::unique_ptr<Dali::Toolkit::WebBackForwardList> mWebBackForwardList;
 
@@ -723,10 +768,10 @@ private:
   bool                       mMouseEventsEnabled;
   bool                       mKeyEventsEnabled;
 
+  bool mVisualChangeRequired;
+
   Dali::Toolkit::WebView::WebViewScreenshotCapturedCallback mScreenshotCapturedCallback;
   Dali::WebEnginePlugin::WebEngineFrameRenderedCallback     mFrameRenderedCallback;
-
-  static std::unordered_map<Dali::WebEnginePlugin*, Dali::WeakHandle<Toolkit::WebView>> mPluginWebViewMap;
 };
 
 } // namespace Internal