1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from webkit-gir-files
// DO NOT EDIT

use crate::{ffi, ScriptWorld};
use glib::translate::*;

glib::wrapper! {
    /// Result of a Hit Test (Web Process Extensions).
    ///
    /// WebKitWebHitTestResult extends #WebKitHitTestResult to provide information
    /// about the #WebKitDOMNode in the coordinates of the Hit Test.
    #[doc(alias = "WebKitWebHitTestResult")]
    pub struct WebHitTestResult(Object<ffi::WebKitWebHitTestResult, ffi::WebKitWebHitTestResultClass>);

    match fn {
        type_ => || ffi::webkit_web_hit_test_result_get_type(),
    }
}

impl WebHitTestResult {
    /// Check whether there is an editable element at the hit test position.
    ///
    /// Checks whether [`HitTestResultContext::EDITABLE`][crate::HitTestResultContext::EDITABLE] flag is present in
    /// the context flags.
    ///
    /// # Returns
    ///
    /// [`true`] if the hit test covers an editable element or [`false`] otherwise.
    #[doc(alias = "webkit_web_hit_test_result_context_is_editable")]
    pub fn context_is_editable(&self) -> bool {
        unsafe {
            from_glib(ffi::webkit_web_hit_test_result_context_is_editable(
                self.to_glib_none().0,
            ))
        }
    }

    /// Check whether there is an image element at the hit test position.
    ///
    /// Checks whether [`HitTestResultContext::IMAGE`][crate::HitTestResultContext::IMAGE] flag is present in
    /// the context flags.
    ///
    /// # Returns
    ///
    /// [`true`] if the hit test covers an image element or [`false`] otherwise.
    #[doc(alias = "webkit_web_hit_test_result_context_is_image")]
    pub fn context_is_image(&self) -> bool {
        unsafe {
            from_glib(ffi::webkit_web_hit_test_result_context_is_image(
                self.to_glib_none().0,
            ))
        }
    }

    /// Check whether there is a link element at the hit test position.
    ///
    /// Checks whether [`HitTestResultContext::LINK`][crate::HitTestResultContext::LINK] flag is present in
    /// the context flags.
    ///
    /// # Returns
    ///
    /// [`true`] if the hit test covers a link element or [`false`] otherwise.
    #[doc(alias = "webkit_web_hit_test_result_context_is_link")]
    pub fn context_is_link(&self) -> bool {
        unsafe {
            from_glib(ffi::webkit_web_hit_test_result_context_is_link(
                self.to_glib_none().0,
            ))
        }
    }

    /// Check whether there is a media element at the hit test position.
    ///
    /// Checks whether [`HitTestResultContext::MEDIA`][crate::HitTestResultContext::MEDIA] flag is present in
    /// the context flags.
    ///
    /// # Returns
    ///
    /// [`true`] if the hit test covers a media element or [`false`] otherwise.
    #[doc(alias = "webkit_web_hit_test_result_context_is_media")]
    pub fn context_is_media(&self) -> bool {
        unsafe {
            from_glib(ffi::webkit_web_hit_test_result_context_is_media(
                self.to_glib_none().0,
            ))
        }
    }

    /// Check whether there is a scrollbar at the hit test position.
    ///
    /// Checks whether [`HitTestResultContext::SCROLLBAR`][crate::HitTestResultContext::SCROLLBAR] flag is present in
    /// the context flags.
    ///
    /// # Returns
    ///
    /// [`true`] if the hit test covers a scrollbar or [`false`] otherwise.
    #[doc(alias = "webkit_web_hit_test_result_context_is_scrollbar")]
    pub fn context_is_scrollbar(&self) -> bool {
        unsafe {
            from_glib(ffi::webkit_web_hit_test_result_context_is_scrollbar(
                self.to_glib_none().0,
            ))
        }
    }

    /// Check whether there is a selected element at the hit test position.
    ///
    /// Checks whether [`HitTestResultContext::SELECTION`][crate::HitTestResultContext::SELECTION] flag is present in
    /// the context flags.
    ///
    /// # Returns
    ///
    /// [`true`] if the hit test covers a selected element or [`false`] otherwise.
    #[doc(alias = "webkit_web_hit_test_result_context_is_selection")]
    pub fn context_is_selection(&self) -> bool {
        unsafe {
            from_glib(ffi::webkit_web_hit_test_result_context_is_selection(
                self.to_glib_none().0,
            ))
        }
    }

    /// Gets the the context flags for the hit test result.
    ///
    /// # Returns
    ///
    /// a bitmask of #WebKitHitTestResultContext flags
    #[doc(alias = "webkit_web_hit_test_result_get_context")]
    #[doc(alias = "get_context")]
    pub fn context(&self) -> u32 {
        unsafe { ffi::webkit_web_hit_test_result_get_context(self.to_glib_none().0) }
    }

    /// Obtains the URI associated with the image element at the hit test position.
    ///
    /// # Returns
    ///
    /// the URI of the image element, or [`None`] if the hit test does not cover an image element.
    #[doc(alias = "webkit_web_hit_test_result_get_image_uri")]
    #[doc(alias = "get_image_uri")]
    pub fn image_uri(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::webkit_web_hit_test_result_get_image_uri(
                self.to_glib_none().0,
            ))
        }
    }

    /// Get the #JSCValue for the DOM node in @world at the coordinates of the Hit Test.
    /// ## `world`
    /// a #WebKitScriptWorld, or [`None`] to use the default
    ///
    /// # Returns
    ///
    /// a #JSCValue for the DOM node, or [`None`]
    #[doc(alias = "webkit_web_hit_test_result_get_js_node")]
    #[doc(alias = "get_js_node")]
    pub fn js_node(&self, world: Option<&ScriptWorld>) -> Option<javascriptcore::Value> {
        unsafe {
            from_glib_full(ffi::webkit_web_hit_test_result_get_js_node(
                self.to_glib_none().0,
                world.to_glib_none().0,
            ))
        }
    }

    /// Obtains the label associated with the link element at the hit test position.
    ///
    /// # Returns
    ///
    /// the label of the link element, or [`None`] if the hit test does not cover a link element
    ///    or the link element does not have a label.
    #[doc(alias = "webkit_web_hit_test_result_get_link_label")]
    #[doc(alias = "get_link_label")]
    pub fn link_label(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::webkit_web_hit_test_result_get_link_label(
                self.to_glib_none().0,
            ))
        }
    }

    /// Obtains the title associated with the link element at the hit test position.
    ///
    /// # Returns
    ///
    /// the title of the link element, or [`None`] if the hit test does not cover a link element
    ///    or the link element does not have a title.
    #[doc(alias = "webkit_web_hit_test_result_get_link_title")]
    #[doc(alias = "get_link_title")]
    pub fn link_title(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::webkit_web_hit_test_result_get_link_title(
                self.to_glib_none().0,
            ))
        }
    }

    /// Obtains the URI associated with the link element at the hit test position.
    ///
    /// # Returns
    ///
    /// the URI of the link element, or [`None`] if the hit test does not cover a link element.
    #[doc(alias = "webkit_web_hit_test_result_get_link_uri")]
    #[doc(alias = "get_link_uri")]
    pub fn link_uri(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::webkit_web_hit_test_result_get_link_uri(
                self.to_glib_none().0,
            ))
        }
    }

    /// Obtains the URI associated with the media element at the hit test position.
    ///
    /// # Returns
    ///
    /// the URI of the media element, or [`None`] if the hit test does not cover a media element.
    #[doc(alias = "webkit_web_hit_test_result_get_media_uri")]
    #[doc(alias = "get_media_uri")]
    pub fn media_uri(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::webkit_web_hit_test_result_get_media_uri(
                self.to_glib_none().0,
            ))
        }
    }
}