2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.ComponentModel;
20 using Tizen.NUI.BaseComponents;
25 /// It is a class for hit test result of web view.
27 [EditorBrowsable(EditorBrowsableState.Never)]
28 public class WebHitTestResult : Disposable
30 internal WebHitTestResult(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
34 /// This will not be public opened.
35 /// <param name="swigCPtr"></param>
36 [EditorBrowsable(EditorBrowsableState.Never)]
37 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
39 Interop.WebHitTest.DeleteWebHitTest(swigCPtr);
43 /// Enumeration for context of hit test result.
45 [EditorBrowsable(EditorBrowsableState.Never)]
46 public enum ResultContext
49 /// Anywhere in the document.
51 [EditorBrowsable(EditorBrowsableState.Never)]
55 /// A hyperlink element.
57 [EditorBrowsable(EditorBrowsableState.Never)]
63 [EditorBrowsable(EditorBrowsableState.Never)]
67 /// a video or audio element.
69 [EditorBrowsable(EditorBrowsableState.Never)]
73 /// The area which is selected.
75 [EditorBrowsable(EditorBrowsableState.Never)]
79 /// The area which is editable
81 [EditorBrowsable(EditorBrowsableState.Never)]
85 /// the area which is text
87 [EditorBrowsable(EditorBrowsableState.Never)]
92 /// Gets the context of the hit test.
94 [EditorBrowsable(EditorBrowsableState.Never)]
95 public ResultContext TestResultContext
99 return (ResultContext)Interop.WebHitTest.GetResultContext(SwigCPtr);
104 /// Gets the link url of the hit test.
106 [EditorBrowsable(EditorBrowsableState.Never)]
107 public string LinkUrl
111 return Interop.WebHitTest.GetLinkUri(SwigCPtr);
116 /// Gets the link title of the hit test.
118 [EditorBrowsable(EditorBrowsableState.Never)]
119 public string LinkTitle
123 return Interop.WebHitTest.GetLinkTitle(SwigCPtr);
128 /// Gets the link label of the hit test.
130 [EditorBrowsable(EditorBrowsableState.Never)]
131 public string LinkLabel
135 return Interop.WebHitTest.GetLinkLabel(SwigCPtr);
140 /// Gets the image url of the hit test.
142 [EditorBrowsable(EditorBrowsableState.Never)]
143 public string ImageUrl
147 return Interop.WebHitTest.GetImageUri(SwigCPtr);
152 /// Gets the media url of the hit test.
154 [EditorBrowsable(EditorBrowsableState.Never)]
155 public string MediaUrl
159 return Interop.WebHitTest.GetMediaUri(SwigCPtr);
164 /// Gets the tag name of hit element of the hit test.
166 [EditorBrowsable(EditorBrowsableState.Never)]
167 public string TagName
171 return Interop.WebHitTest.GetTagName(SwigCPtr);
176 /// Gets the node value of hit element of the hit test.
178 [EditorBrowsable(EditorBrowsableState.Never)]
179 public string NodeValue
183 return Interop.WebHitTest.GetNodeValue(SwigCPtr);
188 /// Gets the attributes of hit element of the hit test.
189 /// The attributes include the standard W3C HTML attributes.
190 /// For example, if <img src="img_girl.jpg" /> is hit,
191 /// key 'src', value 'img_girl.jpg' would be stored in the map.
193 [EditorBrowsable(EditorBrowsableState.Never)]
194 public PropertyMap Attributes
198 IntPtr arributesIntPtr = Interop.WebHitTest.GetAttributes(SwigCPtr);
199 return new PropertyMap(arributesIntPtr, true);
204 /// Gets the image file name extension of hit element of the hit test.
206 [EditorBrowsable(EditorBrowsableState.Never)]
207 public string ImageFileNameExtension
211 return Interop.WebHitTest.GetImageFileNameExtension(SwigCPtr);
216 /// Gets the image of hit element of the hit test.
218 [EditorBrowsable(EditorBrowsableState.Never)]
219 public ImageView Image
223 IntPtr bufferIntPtr = Interop.WebHitTest.GetImageBuffer(SwigCPtr);
224 PixelData pixelData = new PixelData(bufferIntPtr, true);
225 ImageUrl url = pixelData.GenerateUrl();
226 ImageView image = new ImageView(url.ToString());
227 image.Size = new Size(pixelData.GetWidth(), pixelData.GetHeight());