Update position & size of web engine.
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / web-engine-plugin.h
old mode 100644 (file)
new mode 100755 (executable)
index 68cdd90..f74c41a
@@ -2,7 +2,7 @@
 #define DALI_WEB_ENGINE_PLUGIN_H
 
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/images/native-image-interface.h>
+#include <dali/public-api/math/rect.h>
 #include <dali/public-api/signals/dali-signal.h>
 #include <functional>
 
 namespace Dali
 {
-
 class KeyEvent;
-class TouchData;
+class PixelData;
+class TouchEvent;
+class WebEngineBackForwardList;
+class WebEngineContext;
+class WebEngineCookieManager;
+class WebEngineSettings;
 
 /**
  * @brief WebEnginePlugin is an abstract interface, used by dali-adaptor to access WebEngine plugin.
@@ -36,22 +41,44 @@ class TouchData;
 class WebEnginePlugin
 {
 public:
+  /**
+   * @brief WebEngine signal type related with page loading.
+   */
+  using WebEnginePageLoadSignalType = Signal< void( const std::string& ) >;
+
+  /**
+   * @brief WebView signal type related with page loading error.
+   */
+  using WebEnginePageLoadErrorSignalType = Signal< void( const std::string&, int ) >;
 
-  typedef Signal< void( const std::string& ) > WebEngineSignalType;
+  // forward declaration.
+  enum class ScrollEdge;
 
   /**
-   * @brief Constructor.
+   * @brief WebView signal type related with scroll edge reached.
+   */
+  using WebEngineScrollEdgeReachedSignalType = Signal< void( const ScrollEdge ) >;
+
+  /**
+   * @brief Enumeration for the scroll edge.
    */
-  WebEnginePlugin()
+  enum class ScrollEdge
   {
-  }
+    LEFT,   ///< Left edge reached.
+    RIGHT,  ///< Right edge reached.
+    TOP,    ///< Top edge reached.
+    BOTTOM, ///< Bottom edge reached.
+  };
+
+  /**
+   * @brief Constructor.
+   */
+  WebEnginePlugin() = default;
 
   /**
    * @brief Destructor.
    */
-  virtual ~WebEnginePlugin()
-  {
-  }
+  virtual ~WebEnginePlugin() = default;
 
   /**
    * @brief Creates WebEngine instance.
@@ -61,7 +88,17 @@ public:
    * @param [in] locale The locale of Web
    * @param [in] timezoneId The timezoneID of Web
    */
-  virtual void Create( int width, int height, const std::string& locale, const std::string& timezoneId ) = 0;
+  virtual void Create(int width, int height, const std::string& locale, const std::string& timezoneId) = 0;
+
+  /**
+   * @brief Creates WebEngine instance.
+   *
+   * @param [in] width The width of Web
+   * @param [in] height The height of Web
+   * @param [in] argc The count of application arguments
+   * @param [in] argv The string array of application arguments
+   */
+  virtual void Create( int width, int height, int argc, char** argv ) = 0;
 
   /**
    * @brief Destroys WebEngine instance.
@@ -69,11 +106,45 @@ public:
   virtual void Destroy() = 0;
 
   /**
+   * @brief Get settings of WebEngine.
+   */
+  virtual WebEngineSettings& GetSettings() const = 0;
+
+  /**
+   * @brief Get context of WebEngine.
+   */
+  virtual WebEngineContext& GetContext() const = 0;
+
+  /**
+   * @brief Get cookie manager of WebEngine.
+   */
+  virtual WebEngineCookieManager& GetCookieManager() const = 0;
+
+  /**
+   * @brief Get back-forward list of WebEngine.
+   */
+  virtual WebEngineBackForwardList& GetBackForwardList() const = 0;
+
+  /**
    * @brief Loads a web page based on a given URL.
    *
    * @param [in] url The URL of the resource to load
    */
-  virtual void LoadUrl( const std::string& url ) = 0;
+  virtual void LoadUrl(const std::string& url) = 0;
+
+  /**
+   * @brief Returns the title of the Web.
+   *
+   * @return The title of web page
+   */
+  virtual std::string GetTitle() const = 0;
+
+  /**
+   * @brief Returns the Favicon of the Web.
+   *
+   * @return Favicon of Dali::PixelData& type
+   */
+  virtual Dali::PixelData GetFavicon() const = 0;
 
   /**
    * @brief Gets image to render.
@@ -92,7 +163,7 @@ public:
    *
    * @param [in] htmlString The string to use as the contents of the web page
    */
-  virtual void LoadHTMLString( const std::string& htmlString ) = 0;
+  virtual void LoadHtmlString(const std::string& htmlString) = 0;
 
   /**
    * @brief Reloads the Web.
@@ -105,6 +176,41 @@ public:
   virtual void StopLoading() = 0;
 
   /**
+   * @brief Suspends the operation associated with the view.
+   */
+  virtual void Suspend() = 0;
+
+  /**
+   * @brief Resumes the operation associated with the view object after calling Suspend().
+   */
+  virtual void Resume() = 0;
+
+  /**
+   * @brief Scrolls the webpage of view by deltaX and deltaY.
+   */
+  virtual void ScrollBy( int deltaX, int deltaY ) = 0;
+
+  /**
+   * @brief Scroll to the specified position of the given view.
+   */
+  virtual void SetScrollPosition( int x, int y ) = 0;
+
+  /**
+   * @brief Gets the current scroll position of the given view.
+   */
+  virtual Dali::Vector2 GetScrollPosition() const = 0;
+
+  /**
+   * @brief Gets the possible scroll size of the given view.
+   */
+  virtual Dali::Vector2 GetScrollSize() const = 0;
+
+  /**
+   * @brief Gets the last known content's size.
+   */
+  virtual Dali::Vector2 GetContentSize() const = 0;
+
+  /**
    * @brief Returns whether forward is possible.
    *
    * @return True if forward is possible, false otherwise
@@ -132,8 +238,9 @@ public:
    * @brief Evaluates JavaScript code represented as a string.
    *
    * @param[in] script The JavaScript code
+   * @param[in] resultHandler The callback function to be called by the JavaScript runtime. This carries evaluation result.
    */
-  virtual void EvaluateJavaScript( const std::string& script ) = 0;
+  virtual void EvaluateJavaScript(const std::string& script, std::function<void(const std::string&)> resultHandler) = 0;
 
   /**
    * @brief Add a message handler into JavaScript.
@@ -141,7 +248,12 @@ public:
    * @param[in] exposedObjectName The name of exposed object
    * @param[in] handler The callback function
    */
-  virtual void AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void( const std::string& ) > handler ) = 0;
+  virtual void AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler) = 0;
+
+  /**
+   * @brief Clears all tiles resources of Web.
+   */
+  virtual void ClearAllTilesResources() = 0;
 
   /**
    * @brief Clears the history of Web.
@@ -149,41 +261,80 @@ public:
   virtual void ClearHistory() = 0;
 
   /**
-   * @brief Clears the cache of Web.
+   * @brief Get user agent string.
+   *
+   * @return The string value of user agent
+   */
+  virtual const std::string& GetUserAgent() const = 0;
+
+  /**
+   * @brief Set user agent string.
+   *
+   * @param[in] userAgent The string value of user agent
    */
-  virtual void ClearCache() = 0;
+  virtual void SetUserAgent(const std::string& userAgent) = 0;
 
   /**
    * @brief Sets size of Web Page.
    */
-  virtual void SetSize( int width, int height ) = 0;
+  virtual void SetSize(int width, int height) = 0;
 
   /**
    * @brief Sends Touch Events.
    */
-  virtual bool SendTouchEvent( const TouchData& touch ) = 0;
+  virtual bool SendTouchEvent(const TouchEvent& touch) = 0;
 
   /**
    * @brief Sends Key Events.
    */
-  virtual bool SendKeyEvent( const KeyEvent& event ) = 0;
+  virtual bool SendKeyEvent(const KeyEvent& event) = 0;
+
+  /**
+   * @brief Sets focus.
+   */
+  virtual void SetFocus( bool focused ) = 0;
+
+  /**
+   * @brief Update display area.
+   * @param[in] displayArea The display area need be updated.
+   */
+  virtual void UpdateDisplayArea( Dali::Rect< int > displayArea ) = 0;
+
+  /**
+   * @brief Enable video hole.
+   * @param[in] enabled True if enabled, false othewise.
+   */
+  virtual void EnableVideoHole( bool enabled ) = 0;
 
   /**
    * @brief Connects to this signal to be notified when page loading is started.
    *
    * @return A signal object to connect with.
    */
-  virtual WebEngineSignalType& PageLoadStartedSignal() = 0;
+  virtual WebEnginePageLoadSignalType& PageLoadStartedSignal() = 0;
 
   /**
    * @brief Connects to this signal to be notified when page loading is finished.
    *
    * @return A signal object to connect with.
    */
-  virtual WebEngineSignalType& PageLoadFinishedSignal() = 0;
+  virtual WebEnginePageLoadSignalType& PageLoadFinishedSignal() = 0;
 
+  /**
+   * @brief Connects to this signal to be notified when an error occurs in page loading.
+   *
+   * @return A signal object to connect with.
+   */
+  virtual WebEnginePageLoadErrorSignalType& PageLoadErrorSignal() = 0;
+
+  /**
+   * @brief Connects to this signal to be notified when scroll edge is reached.
+   *
+   * @return A signal object to connect with.
+   */
+  virtual WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal() = 0;
 };
 
-} // namespace Dali;
+} // namespace Dali
 
 #endif