[WebView] [TCSACR-219] Add view APIs (#675)
authorBasavarajPS <45586075+BasavarajPS@users.noreply.github.com>
Mon, 15 Apr 2019 23:50:21 +0000 (05:20 +0530)
committeryounghajung <35090305+younghajung@users.noreply.github.com>
Mon, 15 Apr 2019 23:50:21 +0000 (08:50 +0900)
* [WebView][TCSACR-219] Add view APIs

Signed-off-by: basavarajps <basavaraj.ps@samsung.com>
src/Tizen.WebView/Interop/Interop.ChromiumEwk.View.cs
src/Tizen.WebView/Interop/Interop.Eina.cs
src/Tizen.WebView/Tizen.WebView/WebView.cs

index 8ff9607..ac64477 100644 (file)
@@ -16,6 +16,7 @@
 
 using System;
 using System.Runtime.InteropServices;
+using Tizen.WebView;
 
 internal static partial class Interop
 {
@@ -113,6 +114,56 @@ internal static partial class Interop
         [return: MarshalAs(UnmanagedType.U1)]
         internal static extern bool ewk_view_focus_get(IntPtr obj);
 
+        [DllImport(Libraries.ChromiumEwk)]
+        [return: MarshalAs(UnmanagedType.U1)]
+        internal static extern bool ewk_view_contents_size_get(IntPtr obj, out int width, out int height);
+
+        [DllImport(Libraries.ChromiumEwk)]
+        [return: MarshalAs(UnmanagedType.U1)]
+        internal static extern bool ewk_view_fullscreen_exit(IntPtr obj);
+
+        [DllImport(Libraries.ChromiumEwk)]
+        internal static extern double ewk_view_load_progress_get(IntPtr obj);
+
+        [DllImport(Libraries.ChromiumEwk)]
+        internal static extern void ewk_view_orientation_send(IntPtr obj, Orientation orientation);
+
+        [DllImport(Libraries.ChromiumEwk)]
+        internal static extern void ewk_view_suspend(IntPtr obj);
+
+        [DllImport(Libraries.ChromiumEwk)]
+        internal static extern void ewk_view_resume(IntPtr obj);
+
+        [DllImport(Libraries.ChromiumEwk)]
+        internal static extern double ewk_view_scale_get(IntPtr obj);
+
+        [DllImport(Libraries.ChromiumEwk)]
+        [return: MarshalAs(UnmanagedType.U1)]
+        internal static extern bool ewk_view_scale_set(IntPtr obj, double scaleFactor, int cX, int cY);
+
+        [DllImport(Libraries.ChromiumEwk)]
+        [return: MarshalAs(UnmanagedType.U1)]
+        internal static extern bool ewk_view_visibility_set(IntPtr obj, bool enable);
+
+        [DllImport(Libraries.ChromiumEwk)]
+        [return: MarshalAs(UnmanagedType.U1)]
+        internal static extern bool ewk_view_scroll_pos_get(IntPtr obj, out int X, out int Y);
+
+        [DllImport(Libraries.ChromiumEwk)]
+        [return: MarshalAs(UnmanagedType.U1)]
+        internal static extern bool ewk_view_scroll_set(IntPtr obj, int X, int Y);
+
+        [DllImport(Libraries.ChromiumEwk)]
+        internal static extern void ewk_view_scroll_by(IntPtr obj, int X, int Y);
+
+        [DllImport(Libraries.ChromiumEwk)]
+        [return: MarshalAs(UnmanagedType.U1)]
+        internal static extern bool ewk_view_text_find(IntPtr obj, string text, FindOption option, int maxMatchCount);
+
+        [DllImport(Libraries.ChromiumEwk)]
+        [return: MarshalAs(UnmanagedType.U1)]
+        internal static extern bool ewk_view_url_request_set(IntPtr obj, string url, HttpMethod method, IntPtr headers, string body);
+
         [StructLayout(LayoutKind.Sequential, CharSet =CharSet.Ansi)]
         internal struct ScriptMessage
         {
index 4c49d47..a80d61b 100644 (file)
@@ -22,6 +22,13 @@ internal static partial class Interop
     internal static partial class Eina
     {
         [DllImport(Libraries.Eina)]
+        internal static extern IntPtr eina_hash_string_small_new();
+
+        [DllImport(Libraries.Eina)]
+        [return: MarshalAs(UnmanagedType.U1)]
+        internal static extern bool eina_hash_add(IntPtr hash, string Key, string Value);
+
+        [DllImport(Libraries.Eina)]
         internal static extern uint eina_list_count(IntPtr list);
 
         [DllImport(Libraries.Eina)]
index fd322d4..ee9b58b 100644 (file)
@@ -18,10 +18,108 @@ using ElmSharp;
 using System;
 using System.Collections.Generic;
 using System.Runtime.InteropServices;
+using System.ComponentModel;
 
 namespace Tizen.WebView
 {
     /// <summary>
+    /// Enumeration values used to specify search options.
+    /// </summary>
+    /// <since_tizen> 6 </since_tizen>
+    [Flags]
+    public enum FindOption
+    {
+        /// <summary>
+        /// No search flags, this means a case sensitive, no wrap, forward only search.
+        /// </summary>
+        None = 0,
+        /// <summary>
+        /// Case insensitive search.
+        /// </summary>
+        CaseInsensitive = 1 << 0,
+        /// <summary>
+        /// Search text only at the beginning of the words.
+        /// </summary>
+        AtWordStart = 1 << 1,
+        /// <summary>
+        /// Treat capital letters in the middle of words as word start.
+        /// </summary>
+        TreatMedialCapitalAsWordStart = 1 << 2,
+        /// <summary>
+        /// Search backwards.
+        /// </summary>
+        Backwards = 1 << 3,
+        /// <summary>
+        /// If not present the search stops at the end of the document.
+        /// </summary>
+        WrapAround = 1 << 4,
+        /// <summary>
+        /// Show overlay.
+        /// </summary>
+        ShowOverlay = 1 << 5,
+        /// <summary>
+        /// Show Indicator.
+        /// </summary>
+        ShowIndicator = 1 << 6,
+        /// <summary>
+        /// Show Highlight.
+        /// </summary>
+        ShowHighlight = 1 << 7,
+    }
+
+    /// <summary>
+    /// Enumeration for Http Method.
+    /// </summary>
+    /// <since_tizen> 6 </since_tizen>
+    public enum HttpMethod
+    {
+        /// <summary>
+        /// Get.
+        /// </summary>
+        Get,
+        /// <summary>
+        /// Head.
+        /// </summary>
+        Head,
+        /// <summary>
+        /// Post.
+        /// </summary>
+        Post,
+        /// <summary>
+        /// Put.
+        /// </summary>
+        Put,
+        /// <summary>
+        /// Delete.
+        /// </summary>
+        Delete, 
+    }
+
+    /// <summary>
+    /// Enumeration for Orientation of the device.
+    /// </summary>
+    /// <since_tizen> 6 </since_tizen>
+    public enum Orientation
+    {
+        /// <summary>
+        /// 0 degrees when the device is oriented to natural position.
+        /// </summary>
+        Natural = 0,
+        /// <summary>
+        /// -90 degrees when it's left side is at the top.
+        /// </summary>
+        LeftAtTop = -90,
+        /// <summary>
+        /// 90 degrees when it's right side is at the top.
+        /// </summary>
+        RightAtTop = 90,
+        /// <summary>
+        /// 180 degrees when it is upside down.
+        /// </summary>
+        UpsideDown = 180,
+    }
+
+    /// <summary>
     /// A view used to render the web contents.
     /// </summary>
     /// <since_tizen> 4 </since_tizen>
@@ -391,6 +489,163 @@ namespace Tizen.WebView
         }
 
         /// <summary>
+        /// Gets size of the content.
+        /// </summary>
+        /// <returns> size of the coordinate.</returns>
+        /// <since_tizen> 6 </since_tizen>
+        public Size ContentsSize
+        {
+            get
+            {
+                int width, height;
+                Interop.ChromiumEwk.ewk_view_contents_size_get(_realHandle, out width, out height);
+                return new Size(width, height);
+            }
+        }
+
+        /// <summary>
+        /// Exit full screen.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        public void ExitFullscreen ()
+        {
+            Interop.ChromiumEwk.ewk_view_fullscreen_exit(_realHandle);
+        }
+
+        /// <summary>
+        /// Gets the current load progress of the page.
+        /// </summary>
+        /// <returns>'value 0.0 to 1.0' on success, otherwise '-1.0'.</returns>
+        /// <since_tizen> 6 </since_tizen>
+        public double LoadProgress
+        {
+            get
+            {
+                return Interop.ChromiumEwk.ewk_view_load_progress_get(_realHandle);
+            }
+        }
+
+        /// <summary>
+        /// Sends the orientation of the device.
+        /// </summary>
+        /// <param name="orientation">The new orientation of the device in degree.</param>
+        /// <since_tizen> 6 </since_tizen>
+        public void SendOrientation (Orientation orientation)
+        {
+            Interop.ChromiumEwk.ewk_view_orientation_send(_realHandle, orientation);
+        }
+
+        /// <summary>
+        /// Suspends the operation associated with the view.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        public void Suspend ()
+        {
+            Interop.ChromiumEwk.ewk_view_suspend(_realHandle);
+        }
+
+        /// <summary>
+        /// Resumes the operation associated with the view.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        public void Resume ()
+        {
+            Interop.ChromiumEwk.ewk_view_resume(_realHandle);
+        }
+
+        /// <summary>
+        /// Gets the current scale factor of the page.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        public double Scale
+        {
+            get
+            {
+                return Interop.ChromiumEwk.ewk_view_scale_get(_realHandle);
+            }
+        }
+
+        /// <summary>
+        /// Sets the current scale factor of the page.
+        /// </summary>
+        /// <param name="scaleFactor">A new level to set.</param>
+        /// <param name="scrollTo">The class Point object with X, Y coordinates.</param>
+        /// <since_tizen> 6 </since_tizen>
+        public void SetScale (double scaleFactor, Point scrollTo)
+        {
+            Interop.ChromiumEwk.ewk_view_scale_set(_realHandle, scaleFactor, scrollTo.X, scrollTo.Y);
+        }
+
+        /// <summary>
+        /// Sets the current page's visibility.
+        /// </summary>
+        /// <param name="enable">'true' to set on the visibility of the page, 'false' otherwise.</param>
+        /// <since_tizen> 6 </since_tizen>
+        public void SetViewVisibility (bool enable)
+        {
+            Interop.ChromiumEwk.ewk_view_visibility_set(_realHandle, enable);
+        }
+
+        /// <summary>
+        /// Get and Sets the scroll position of the page.
+        /// </summary>
+        /// <returns>The class Point object with X, Y coordinates.</returns>
+        /// <since_tizen> 6 </since_tizen>
+        public Point ScrollPosition
+        {
+            get
+            {
+                Point p;
+                Interop.ChromiumEwk.ewk_view_scroll_pos_get(_realHandle, out p.X, out p.Y);
+                return p;
+            }
+            set
+            {
+                Interop.ChromiumEwk.ewk_view_scroll_set(_realHandle, value.X, value.Y);
+            }
+        }
+
+        /// <summary>
+        /// Scrolls the webpage by the given amount.
+        /// </summary>
+        /// <param name="delta">The class Point object with X, Y coordinates.</param>
+        /// <since_tizen> 6 </since_tizen>
+        public void ScrollBy (Point delta)
+        {
+            Interop.ChromiumEwk.ewk_view_scroll_by(_realHandle, delta.X, delta.Y);
+        }
+
+        /// <summary>
+        /// Searches and highlights the given text string in the document.
+        /// </summary>
+        /// <param name="text">The text to find.</param>
+        /// <param name="option">The options to find.</param>
+        /// <param name="maxMatchCount">The maximum match count to find, unlimited if 0.</param>
+        /// <since_tizen> 6 </since_tizen>
+        public void FindText (string text, FindOption option, int maxMatchCount)
+        {
+            Interop.ChromiumEwk.ewk_view_text_find(_realHandle, text, option, maxMatchCount);
+        }
+
+        /// <summary>
+        /// Requests loading of the given request data.
+        /// </summary>
+        /// <param name="url">The uniform resource identifier to load.</param>
+        /// <param name="httpMethod">The http method.</param>
+        /// <param name="httpHeaders">The http headers.</param>
+        /// <param name="httpBody">The http body data.</param>
+        /// <since_tizen> 6 </since_tizen>
+        public void SetUrlRequest (string url, HttpMethod httpMethod, IDictionary<string, string> httpHeaders, string httpBody)
+        {
+            IntPtr hashHttpHeaders = Interop.Eina.eina_hash_string_small_new();
+            foreach (KeyValuePair<string, string> entry in httpHeaders)
+            {
+                Interop.Eina.eina_hash_add(hashHttpHeaders, entry.Key, entry.Value);
+            }
+            Interop.ChromiumEwk.ewk_view_url_request_set(_realHandle, url, httpMethod, hashHttpHeaders, httpBody);
+        }
+
+        /// <summary>
         /// Creates a widget handle.
         /// </summary>
         /// <param name="parent">Parent EvasObject.</param>