webkit6/auto/hit_test_result.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from webkit-gir-files
4// DO NOT EDIT
5
6use crate::ffi;
7use glib::translate::*;
8
9glib::wrapper! {
10 /// Result of a Hit Test.
11 ///
12 /// A Hit Test is an operation to get context information about a given
13 /// point in a [`WebView`][crate::WebView]. [`HitTestResult`][crate::HitTestResult] represents the
14 /// result of a Hit Test. It provides context information about what is
15 /// at the coordinates of the Hit Test, such as if there's a link,
16 /// an image or a media.
17 ///
18 /// You can get the context of the HitTestResult with
19 /// [`context()`][Self::context()] that returns a bitmask of
20 /// [`HitTestResultContext`][crate::HitTestResultContext] flags. You can also use
21 /// [`context_is_link()`][Self::context_is_link()], [`context_is_image()`][Self::context_is_image()] and
22 /// [`context_is_media()`][Self::context_is_media()] to determine whether there's
23 /// a link, image or a media element at the coordinates of the Hit Test.
24 /// Note that it's possible that several [`HitTestResultContext`][crate::HitTestResultContext] flags
25 /// are active at the same time, for example if there's a link containing an image.
26 ///
27 /// When the mouse is moved over a [`WebView`][crate::WebView] a Hit Test is performed
28 /// for the mouse coordinates and [`mouse-target-changed`][struct@crate::WebView#mouse-target-changed]
29 /// signal is emitted with a [`HitTestResult`][crate::HitTestResult].
30 ///
31 /// ## Properties
32 ///
33 ///
34 /// #### `context`
35 /// Bitmask of [`HitTestResultContext`][crate::HitTestResultContext] flags representing
36 /// the context of the [`HitTestResult`][crate::HitTestResult].
37 ///
38 /// Readable | Writeable | Construct Only
39 ///
40 ///
41 /// #### `image-uri`
42 /// The URI of the image if flag [`HitTestResultContext::IMAGE`][crate::HitTestResultContext::IMAGE]
43 /// is present in [`context`][struct@crate::HitTestResult#context]
44 ///
45 /// Readable | Writeable | Construct Only
46 ///
47 ///
48 /// #### `link-label`
49 /// The label of the link if flag [`HitTestResultContext::LINK`][crate::HitTestResultContext::LINK]
50 /// is present in [`context`][struct@crate::HitTestResult#context]
51 ///
52 /// Readable | Writeable | Construct Only
53 ///
54 ///
55 /// #### `link-title`
56 /// The title of the link if flag [`HitTestResultContext::LINK`][crate::HitTestResultContext::LINK]
57 /// is present in [`context`][struct@crate::HitTestResult#context]
58 ///
59 /// Readable | Writeable | Construct Only
60 ///
61 ///
62 /// #### `link-uri`
63 /// The URI of the link if flag [`HitTestResultContext::LINK`][crate::HitTestResultContext::LINK]
64 /// is present in [`context`][struct@crate::HitTestResult#context]
65 ///
66 /// Readable | Writeable | Construct Only
67 ///
68 ///
69 /// #### `media-uri`
70 /// The URI of the media if flag [`HitTestResultContext::MEDIA`][crate::HitTestResultContext::MEDIA]
71 /// is present in [`context`][struct@crate::HitTestResult#context]
72 ///
73 /// Readable | Writeable | Construct Only
74 #[doc(alias = "WebKitHitTestResult")]
75 pub struct HitTestResult(Object<ffi::WebKitHitTestResult, ffi::WebKitHitTestResultClass>);
76
77 match fn {
78 type_ => || ffi::webkit_hit_test_result_get_type(),
79 }
80}
81
82impl HitTestResult {
83 /// Gets whether [`HitTestResultContext::EDITABLE`][crate::HitTestResultContext::EDITABLE] flag is present in
84 /// [`context`][struct@crate::HitTestResult#context].
85 ///
86 /// # Returns
87 ///
88 /// [`true`] if there's an editable element at the coordinates of the `self`,
89 /// or [`false`] otherwise
90 #[doc(alias = "webkit_hit_test_result_context_is_editable")]
91 pub fn context_is_editable(&self) -> bool {
92 unsafe {
93 from_glib(ffi::webkit_hit_test_result_context_is_editable(
94 self.to_glib_none().0,
95 ))
96 }
97 }
98
99 /// Gets whether [`HitTestResultContext::IMAGE`][crate::HitTestResultContext::IMAGE] flag is present in
100 /// [`context`][struct@crate::HitTestResult#context].
101 ///
102 /// # Returns
103 ///
104 /// [`true`] if there's an image element in the coordinates of the Hit Test,
105 /// or [`false`] otherwise
106 #[doc(alias = "webkit_hit_test_result_context_is_image")]
107 pub fn context_is_image(&self) -> bool {
108 unsafe {
109 from_glib(ffi::webkit_hit_test_result_context_is_image(
110 self.to_glib_none().0,
111 ))
112 }
113 }
114
115 /// Gets whether [`HitTestResultContext::LINK`][crate::HitTestResultContext::LINK] flag is present in
116 /// [`context`][struct@crate::HitTestResult#context].
117 ///
118 /// # Returns
119 ///
120 /// [`true`] if there's a link element in the coordinates of the Hit Test,
121 /// or [`false`] otherwise
122 #[doc(alias = "webkit_hit_test_result_context_is_link")]
123 pub fn context_is_link(&self) -> bool {
124 unsafe {
125 from_glib(ffi::webkit_hit_test_result_context_is_link(
126 self.to_glib_none().0,
127 ))
128 }
129 }
130
131 /// Gets whether [`HitTestResultContext::MEDIA`][crate::HitTestResultContext::MEDIA] flag is present in
132 /// [`context`][struct@crate::HitTestResult#context].
133 ///
134 /// # Returns
135 ///
136 /// [`true`] if there's a media element in the coordinates of the Hit Test,
137 /// or [`false`] otherwise
138 #[doc(alias = "webkit_hit_test_result_context_is_media")]
139 pub fn context_is_media(&self) -> bool {
140 unsafe {
141 from_glib(ffi::webkit_hit_test_result_context_is_media(
142 self.to_glib_none().0,
143 ))
144 }
145 }
146
147 /// Gets whether [`HitTestResultContext::SCROLLBAR`][crate::HitTestResultContext::SCROLLBAR] flag is present in
148 /// [`context`][struct@crate::HitTestResult#context].
149 ///
150 /// # Returns
151 ///
152 /// [`true`] if there's a scrollbar element at the coordinates of the `self`,
153 /// or [`false`] otherwise
154 #[doc(alias = "webkit_hit_test_result_context_is_scrollbar")]
155 pub fn context_is_scrollbar(&self) -> bool {
156 unsafe {
157 from_glib(ffi::webkit_hit_test_result_context_is_scrollbar(
158 self.to_glib_none().0,
159 ))
160 }
161 }
162
163 /// Gets whether [`HitTestResultContext::SELECTION`][crate::HitTestResultContext::SELECTION] flag is present in
164 /// [`context`][struct@crate::HitTestResult#context].
165 ///
166 /// # Returns
167 ///
168 /// [`true`] if there's a selected element at the coordinates of the `self`,
169 /// or [`false`] otherwise
170 #[doc(alias = "webkit_hit_test_result_context_is_selection")]
171 pub fn context_is_selection(&self) -> bool {
172 unsafe {
173 from_glib(ffi::webkit_hit_test_result_context_is_selection(
174 self.to_glib_none().0,
175 ))
176 }
177 }
178
179 /// Gets the value of the [`context`][struct@crate::HitTestResult#context] property.
180 ///
181 /// # Returns
182 ///
183 /// a bitmask of [`HitTestResultContext`][crate::HitTestResultContext] flags
184 #[doc(alias = "webkit_hit_test_result_get_context")]
185 #[doc(alias = "get_context")]
186 pub fn context(&self) -> u32 {
187 unsafe { ffi::webkit_hit_test_result_get_context(self.to_glib_none().0) }
188 }
189
190 /// Gets the value of the [`image-uri`][struct@crate::HitTestResult#image-uri] property.
191 ///
192 /// # Returns
193 ///
194 /// the URI of the image element in the coordinates of the Hit Test,
195 /// or [`None`] if there isn't an image element in `self` context
196 #[doc(alias = "webkit_hit_test_result_get_image_uri")]
197 #[doc(alias = "get_image_uri")]
198 #[doc(alias = "image-uri")]
199 pub fn image_uri(&self) -> Option<glib::GString> {
200 unsafe {
201 from_glib_none(ffi::webkit_hit_test_result_get_image_uri(
202 self.to_glib_none().0,
203 ))
204 }
205 }
206
207 /// Gets the value of the [`link-label`][struct@crate::HitTestResult#link-label] property.
208 ///
209 /// # Returns
210 ///
211 /// the label of the link element in the coordinates of the Hit Test,
212 /// or [`None`] if there isn't a link element in `self` context or the
213 /// link element doesn't have a label
214 #[doc(alias = "webkit_hit_test_result_get_link_label")]
215 #[doc(alias = "get_link_label")]
216 #[doc(alias = "link-label")]
217 pub fn link_label(&self) -> Option<glib::GString> {
218 unsafe {
219 from_glib_none(ffi::webkit_hit_test_result_get_link_label(
220 self.to_glib_none().0,
221 ))
222 }
223 }
224
225 /// Gets the value of the [`link-title`][struct@crate::HitTestResult#link-title] property.
226 ///
227 /// # Returns
228 ///
229 /// the title of the link element in the coordinates of the Hit Test,
230 /// or [`None`] if there isn't a link element in `self` context or the
231 /// link element doesn't have a title
232 #[doc(alias = "webkit_hit_test_result_get_link_title")]
233 #[doc(alias = "get_link_title")]
234 #[doc(alias = "link-title")]
235 pub fn link_title(&self) -> Option<glib::GString> {
236 unsafe {
237 from_glib_none(ffi::webkit_hit_test_result_get_link_title(
238 self.to_glib_none().0,
239 ))
240 }
241 }
242
243 /// Gets the value of the [`link-uri`][struct@crate::HitTestResult#link-uri] property.
244 ///
245 /// # Returns
246 ///
247 /// the URI of the link element in the coordinates of the Hit Test,
248 /// or [`None`] if there isn't a link element in `self` context
249 #[doc(alias = "webkit_hit_test_result_get_link_uri")]
250 #[doc(alias = "get_link_uri")]
251 #[doc(alias = "link-uri")]
252 pub fn link_uri(&self) -> Option<glib::GString> {
253 unsafe {
254 from_glib_none(ffi::webkit_hit_test_result_get_link_uri(
255 self.to_glib_none().0,
256 ))
257 }
258 }
259
260 /// Gets the value of the [`media-uri`][struct@crate::HitTestResult#media-uri] property.
261 ///
262 /// # Returns
263 ///
264 /// the URI of the media element in the coordinates of the Hit Test,
265 /// or [`None`] if there isn't a media element in `self` context
266 #[doc(alias = "webkit_hit_test_result_get_media_uri")]
267 #[doc(alias = "get_media_uri")]
268 #[doc(alias = "media-uri")]
269 pub fn media_uri(&self) -> Option<glib::GString> {
270 unsafe {
271 from_glib_none(ffi::webkit_hit_test_result_get_media_uri(
272 self.to_glib_none().0,
273 ))
274 }
275 }
276}