Support scroll in 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 b8d6379..c3b9389
@@ -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.
@@ -25,9 +25,8 @@
 
 namespace Dali
 {
-
 class KeyEvent;
-class TouchData;
+class TouchEvent;
 
 /**
  * @brief WebEnginePlugin is an abstract interface, used by dali-adaptor to access WebEngine plugin.
@@ -36,16 +35,23 @@ class TouchData;
 class WebEnginePlugin
 {
 public:
-
   /**
    * @brief WebEngine signal type related with page loading.
    */
-  typedef Signal< void( const std::string& ) > WebEnginePageLoadSignalType;
+  typedef Signal<void(const std::string&)> WebEnginePageLoadSignalType;
 
   /**
    * @brief WebView signal type related with page loading error.
    */
-  typedef Signal< void( const std::string&, int ) > WebEnginePageLoadErrorSignalType;
+  typedef Signal<void(const std::string&, int)> WebEnginePageLoadErrorSignalType;
+
+  // forward declaration.
+  enum class ScrollEdge;
+
+  /**
+   * @brief WebView signal type related with scroll edge reached.
+   */
+  typedef Signal< void( const ScrollEdge )> WebEngineScrollEdgeReachedSignalType;
 
   /**
    * @brief Enumeration for cache model options.
@@ -90,18 +96,25 @@ public:
   };
 
   /**
-   * @brief Constructor.
+   * @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.
@@ -111,7 +124,7 @@ 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 Destroys WebEngine instance.
@@ -123,7 +136,7 @@ public:
    *
    * @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 Gets image to render.
@@ -142,7 +155,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.
@@ -165,6 +178,31 @@ public:
   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 void GetScrollPosition( int& x, int& y ) const = 0;
+
+  /**
+   * @brief Gets the possible scroll size of the given view.
+   */
+  virtual void GetScrollSize( int& width, int& height ) const = 0;
+
+  /**
+   * @brief Gets the last known content's size.
+   */
+  virtual void GetContentSize( int& width, int& height ) const = 0;
+
+  /**
    * @brief Returns whether forward is possible.
    *
    * @return True if forward is possible, false otherwise
@@ -194,7 +232,7 @@ public:
    * @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, std::function< void( const std::string& ) > resultHandler ) = 0;
+  virtual void EvaluateJavaScript(const std::string& script, std::function<void(const std::string&)> resultHandler) = 0;
 
   /**
    * @brief Add a message handler into JavaScript.
@@ -202,7 +240,7 @@ 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 the history of Web.
@@ -231,7 +269,7 @@ public:
    *
    * @param[in] cacheModel The cache model option
    */
-  virtual void SetCacheModel( CacheModel cacheModel ) = 0;
+  virtual void SetCacheModel(CacheModel cacheModel) = 0;
 
   /**
    * @brief Gets the cookie acceptance policy. The default is NO_THIRD_PARTY.
@@ -245,7 +283,7 @@ public:
    *
    * @param[in] policy The cookie acceptance policy
    */
-  virtual void SetCookieAcceptPolicy( CookieAcceptPolicy policy ) = 0;
+  virtual void SetCookieAcceptPolicy(CookieAcceptPolicy policy) = 0;
 
   /**
    * @brief Get user agent string.
@@ -259,7 +297,7 @@ public:
    *
    * @param[in] userAgent The string value of user agent
    */
-  virtual void SetUserAgent( const std::string& userAgent ) = 0;
+  virtual void SetUserAgent(const std::string& userAgent) = 0;
 
   /**
    * @brief Returns whether JavaScript can be executable. The default is true.
@@ -273,7 +311,7 @@ public:
    *
    * @param[in] enabled True if JavaScript executing is enabled, false otherwise
    */
-  virtual void EnableJavaScript( bool enabled ) = 0;
+  virtual void EnableJavaScript(bool enabled) = 0;
 
   /**
    * @brief Returns whether images can be loaded automatically. The default is true.
@@ -287,7 +325,7 @@ public:
    *
    * @param[in] automatic True if images are loaded automatically, false otherwise
    */
-  virtual void LoadImagesAutomatically( bool automatic ) = 0;
+  virtual void LoadImagesAutomatically(bool automatic) = 0;
 
   /**
    * @brief Gets the default text encoding name (e.g. UTF-8).
@@ -301,7 +339,7 @@ public:
    *
    * @param[in] defaultTextEncodingName The default text encoding name
    */
-  virtual void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ) = 0;
+  virtual void SetDefaultTextEncodingName(const std::string& defaultTextEncodingName) = 0;
 
   /**
    * @brief Returns the default font size in pixel. The default value is 16.
@@ -315,22 +353,27 @@ public:
    *
    * @param[in] defaultFontSize A new default font size to set
    */
-  virtual void SetDefaultFontSize( int defaultFontSize ) = 0;
+  virtual void SetDefaultFontSize(int defaultFontSize) = 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 Connects to this signal to be notified when page loading is started.
@@ -353,8 +396,14 @@ public:
    */
   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