webkit_web_process_extension6/auto/
web_form_manager.rs1use crate::{Frame, ffi};
7use glib::{
8 object::ObjectType as _,
9 prelude::*,
10 signal::{SignalHandlerId, connect_raw},
11 translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16 #[doc(alias = "WebKitWebFormManager")]
17 pub struct WebFormManager(Object<ffi::WebKitWebFormManager, ffi::WebKitWebFormManagerClass>);
18
19 match fn {
20 type_ => || ffi::webkit_web_form_manager_get_type(),
21 }
22}
23
24impl WebFormManager {
25 pub const NONE: Option<&'static WebFormManager> = None;
26
27 #[doc(alias = "webkit_web_form_manager_input_element_auto_fill")]
28 pub fn input_element_auto_fill(element: &javascriptcore::Value, value: &str) {
29 assert_initialized_main_thread!();
30 unsafe {
31 ffi::webkit_web_form_manager_input_element_auto_fill(
32 element.to_glib_none().0,
33 value.to_glib_none().0,
34 );
35 }
36 }
37
38 #[doc(alias = "webkit_web_form_manager_input_element_is_auto_filled")]
39 pub fn input_element_is_auto_filled(element: &javascriptcore::Value) -> bool {
40 assert_initialized_main_thread!();
41 unsafe {
42 from_glib(ffi::webkit_web_form_manager_input_element_is_auto_filled(
43 element.to_glib_none().0,
44 ))
45 }
46 }
47
48 #[doc(alias = "webkit_web_form_manager_input_element_is_user_edited")]
49 pub fn input_element_is_user_edited(element: &javascriptcore::Value) -> bool {
50 assert_initialized_main_thread!();
51 unsafe {
52 from_glib(ffi::webkit_web_form_manager_input_element_is_user_edited(
53 element.to_glib_none().0,
54 ))
55 }
56 }
57}
58
59pub trait WebFormManagerExt: IsA<WebFormManager> + 'static {
60 #[doc(alias = "will-send-submit-event")]
66 fn connect_will_send_submit_event<
67 F: Fn(&Self, &javascriptcore::Value, &Frame, &Frame) + 'static,
68 >(
69 &self,
70 f: F,
71 ) -> SignalHandlerId {
72 unsafe extern "C" fn will_send_submit_event_trampoline<
73 P: IsA<WebFormManager>,
74 F: Fn(&P, &javascriptcore::Value, &Frame, &Frame) + 'static,
75 >(
76 this: *mut ffi::WebKitWebFormManager,
77 form: *mut javascriptcore::ffi::JSCValue,
78 source_frame: *mut ffi::WebKitFrame,
79 target_frame: *mut ffi::WebKitFrame,
80 f: glib::ffi::gpointer,
81 ) {
82 unsafe {
83 let f: &F = &*(f as *const F);
84 f(
85 WebFormManager::from_glib_borrow(this).unsafe_cast_ref(),
86 &from_glib_borrow(form),
87 &from_glib_borrow(source_frame),
88 &from_glib_borrow(target_frame),
89 )
90 }
91 }
92 unsafe {
93 let f: Box_<F> = Box_::new(f);
94 connect_raw(
95 self.as_ptr() as *mut _,
96 c"will-send-submit-event".as_ptr(),
97 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
98 will_send_submit_event_trampoline::<Self, F> as *const (),
99 )),
100 Box_::into_raw(f),
101 )
102 }
103 }
104
105 #[doc(alias = "will-submit-form")]
106 fn connect_will_submit_form<F: Fn(&Self, &javascriptcore::Value, &Frame, &Frame) + 'static>(
107 &self,
108 f: F,
109 ) -> SignalHandlerId {
110 unsafe extern "C" fn will_submit_form_trampoline<
111 P: IsA<WebFormManager>,
112 F: Fn(&P, &javascriptcore::Value, &Frame, &Frame) + 'static,
113 >(
114 this: *mut ffi::WebKitWebFormManager,
115 form: *mut javascriptcore::ffi::JSCValue,
116 source_frame: *mut ffi::WebKitFrame,
117 target_frame: *mut ffi::WebKitFrame,
118 f: glib::ffi::gpointer,
119 ) {
120 unsafe {
121 let f: &F = &*(f as *const F);
122 f(
123 WebFormManager::from_glib_borrow(this).unsafe_cast_ref(),
124 &from_glib_borrow(form),
125 &from_glib_borrow(source_frame),
126 &from_glib_borrow(target_frame),
127 )
128 }
129 }
130 unsafe {
131 let f: Box_<F> = Box_::new(f);
132 connect_raw(
133 self.as_ptr() as *mut _,
134 c"will-submit-form".as_ptr(),
135 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
136 will_submit_form_trampoline::<Self, F> as *const (),
137 )),
138 Box_::into_raw(f),
139 )
140 }
141 }
142}
143
144impl<O: IsA<WebFormManager>> WebFormManagerExt for O {}