1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9#[cfg(feature = "objc2-quartz-core")]
10#[cfg(not(target_os = "watchos"))]
11use objc2_quartz_core::*;
12
13use crate::*;
14
15#[repr(transparent)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
19pub struct UIWebViewNavigationType(pub NSInteger);
20impl UIWebViewNavigationType {
21 #[doc(alias = "UIWebViewNavigationTypeLinkClicked")]
22 pub const LinkClicked: Self = Self(0);
23 #[doc(alias = "UIWebViewNavigationTypeFormSubmitted")]
24 pub const FormSubmitted: Self = Self(1);
25 #[doc(alias = "UIWebViewNavigationTypeBackForward")]
26 pub const BackForward: Self = Self(2);
27 #[doc(alias = "UIWebViewNavigationTypeReload")]
28 pub const Reload: Self = Self(3);
29 #[doc(alias = "UIWebViewNavigationTypeFormResubmitted")]
30 pub const FormResubmitted: Self = Self(4);
31 #[doc(alias = "UIWebViewNavigationTypeOther")]
32 pub const Other: Self = Self(5);
33}
34
35unsafe impl Encode for UIWebViewNavigationType {
36 const ENCODING: Encoding = NSInteger::ENCODING;
37}
38
39unsafe impl RefEncode for UIWebViewNavigationType {
40 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
41}
42
43#[repr(transparent)]
46#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
47pub struct UIWebPaginationMode(pub NSInteger);
48impl UIWebPaginationMode {
49 #[doc(alias = "UIWebPaginationModeUnpaginated")]
50 pub const Unpaginated: Self = Self(0);
51 #[doc(alias = "UIWebPaginationModeLeftToRight")]
52 pub const LeftToRight: Self = Self(1);
53 #[doc(alias = "UIWebPaginationModeTopToBottom")]
54 pub const TopToBottom: Self = Self(2);
55 #[doc(alias = "UIWebPaginationModeBottomToTop")]
56 pub const BottomToTop: Self = Self(3);
57 #[doc(alias = "UIWebPaginationModeRightToLeft")]
58 pub const RightToLeft: Self = Self(4);
59}
60
61unsafe impl Encode for UIWebPaginationMode {
62 const ENCODING: Encoding = NSInteger::ENCODING;
63}
64
65unsafe impl RefEncode for UIWebPaginationMode {
66 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
67}
68
69#[repr(transparent)]
72#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
73pub struct UIWebPaginationBreakingMode(pub NSInteger);
74impl UIWebPaginationBreakingMode {
75 #[doc(alias = "UIWebPaginationBreakingModePage")]
76 pub const Page: Self = Self(0);
77 #[doc(alias = "UIWebPaginationBreakingModeColumn")]
78 pub const Column: Self = Self(1);
79}
80
81unsafe impl Encode for UIWebPaginationBreakingMode {
82 const ENCODING: Encoding = NSInteger::ENCODING;
83}
84
85unsafe impl RefEncode for UIWebPaginationBreakingMode {
86 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
87}
88
89extern_class!(
90 #[unsafe(super(UIView, UIResponder, NSObject))]
92 #[thread_kind = MainThreadOnly]
93 #[derive(Debug, PartialEq, Eq, Hash)]
94 #[cfg(all(feature = "UIResponder", feature = "UIView"))]
95 #[deprecated = "No longer supported; please adopt WKWebView."]
96 pub struct UIWebView;
97);
98
99#[cfg(all(
100 feature = "UIResponder",
101 feature = "UIView",
102 feature = "objc2-quartz-core"
103))]
104#[cfg(not(target_os = "watchos"))]
105extern_conformance!(
106 unsafe impl CALayerDelegate for UIWebView {}
107);
108
109#[cfg(all(feature = "UIResponder", feature = "UIView"))]
110extern_conformance!(
111 unsafe impl NSCoding for UIWebView {}
112);
113
114#[cfg(all(feature = "UIResponder", feature = "UIView"))]
115extern_conformance!(
116 unsafe impl NSObjectProtocol for UIWebView {}
117);
118
119#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
120extern_conformance!(
121 unsafe impl UIAppearance for UIWebView {}
122);
123
124#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
125extern_conformance!(
126 unsafe impl UIAppearanceContainer for UIWebView {}
127);
128
129#[cfg(all(feature = "UIResponder", feature = "UIView"))]
130extern_conformance!(
131 unsafe impl UICoordinateSpace for UIWebView {}
132);
133
134#[cfg(all(
135 feature = "UIDynamicBehavior",
136 feature = "UIResponder",
137 feature = "UIView"
138))]
139extern_conformance!(
140 unsafe impl UIDynamicItem for UIWebView {}
141);
142
143#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
144extern_conformance!(
145 unsafe impl UIFocusEnvironment for UIWebView {}
146);
147
148#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
149extern_conformance!(
150 unsafe impl UIFocusItem for UIWebView {}
151);
152
153#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
154extern_conformance!(
155 unsafe impl UIFocusItemContainer for UIWebView {}
156);
157
158#[cfg(all(feature = "UIResponder", feature = "UIView"))]
159extern_conformance!(
160 unsafe impl UIResponderStandardEditActions for UIWebView {}
161);
162
163#[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
164extern_conformance!(
165 unsafe impl UIScrollViewDelegate for UIWebView {}
166);
167
168#[cfg(all(
169 feature = "UIResponder",
170 feature = "UITraitCollection",
171 feature = "UIView"
172))]
173extern_conformance!(
174 unsafe impl UITraitEnvironment for UIWebView {}
175);
176
177#[cfg(all(feature = "UIResponder", feature = "UIView"))]
178impl UIWebView {
179 extern_methods!(
180 #[deprecated = "No longer supported; please adopt WKWebView."]
181 #[unsafe(method(delegate))]
182 #[unsafe(method_family = none)]
183 pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn UIWebViewDelegate>>>;
184
185 #[deprecated = "No longer supported; please adopt WKWebView."]
187 #[unsafe(method(setDelegate:))]
188 #[unsafe(method_family = none)]
189 pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn UIWebViewDelegate>>);
190
191 #[cfg(feature = "UIScrollView")]
192 #[unsafe(method(scrollView))]
193 #[unsafe(method_family = none)]
194 pub unsafe fn scrollView(&self) -> Retained<UIScrollView>;
195
196 #[deprecated = "No longer supported; please adopt WKWebView."]
197 #[unsafe(method(loadRequest:))]
198 #[unsafe(method_family = none)]
199 pub unsafe fn loadRequest(&self, request: &NSURLRequest);
200
201 #[deprecated = "No longer supported; please adopt WKWebView."]
202 #[unsafe(method(loadHTMLString:baseURL:))]
203 #[unsafe(method_family = none)]
204 pub unsafe fn loadHTMLString_baseURL(&self, string: &NSString, base_url: Option<&NSURL>);
205
206 #[deprecated = "No longer supported; please adopt WKWebView."]
207 #[unsafe(method(loadData:MIMEType:textEncodingName:baseURL:))]
208 #[unsafe(method_family = none)]
209 pub unsafe fn loadData_MIMEType_textEncodingName_baseURL(
210 &self,
211 data: &NSData,
212 mime_type: &NSString,
213 text_encoding_name: &NSString,
214 base_url: &NSURL,
215 );
216
217 #[deprecated = "No longer supported; please adopt WKWebView."]
218 #[unsafe(method(request))]
219 #[unsafe(method_family = none)]
220 pub unsafe fn request(&self) -> Option<Retained<NSURLRequest>>;
221
222 #[deprecated = "No longer supported; please adopt WKWebView."]
223 #[unsafe(method(reload))]
224 #[unsafe(method_family = none)]
225 pub unsafe fn reload(&self);
226
227 #[deprecated = "No longer supported; please adopt WKWebView."]
228 #[unsafe(method(stopLoading))]
229 #[unsafe(method_family = none)]
230 pub unsafe fn stopLoading(&self);
231
232 #[deprecated = "No longer supported; please adopt WKWebView."]
233 #[unsafe(method(goBack))]
234 #[unsafe(method_family = none)]
235 pub unsafe fn goBack(&self);
236
237 #[deprecated = "No longer supported; please adopt WKWebView."]
238 #[unsafe(method(goForward))]
239 #[unsafe(method_family = none)]
240 pub unsafe fn goForward(&self);
241
242 #[deprecated = "No longer supported; please adopt WKWebView."]
243 #[unsafe(method(canGoBack))]
244 #[unsafe(method_family = none)]
245 pub unsafe fn canGoBack(&self) -> bool;
246
247 #[deprecated = "No longer supported; please adopt WKWebView."]
248 #[unsafe(method(canGoForward))]
249 #[unsafe(method_family = none)]
250 pub unsafe fn canGoForward(&self) -> bool;
251
252 #[deprecated = "No longer supported; please adopt WKWebView."]
253 #[unsafe(method(isLoading))]
254 #[unsafe(method_family = none)]
255 pub unsafe fn isLoading(&self) -> bool;
256
257 #[deprecated = "No longer supported; please adopt WKWebView."]
258 #[unsafe(method(stringByEvaluatingJavaScriptFromString:))]
259 #[unsafe(method_family = none)]
260 pub unsafe fn stringByEvaluatingJavaScriptFromString(
261 &self,
262 script: &NSString,
263 ) -> Option<Retained<NSString>>;
264
265 #[deprecated = "No longer supported; please adopt WKWebView."]
266 #[unsafe(method(scalesPageToFit))]
267 #[unsafe(method_family = none)]
268 pub unsafe fn scalesPageToFit(&self) -> bool;
269
270 #[deprecated = "No longer supported; please adopt WKWebView."]
272 #[unsafe(method(setScalesPageToFit:))]
273 #[unsafe(method_family = none)]
274 pub unsafe fn setScalesPageToFit(&self, scales_page_to_fit: bool);
275
276 #[deprecated]
277 #[unsafe(method(detectsPhoneNumbers))]
278 #[unsafe(method_family = none)]
279 pub unsafe fn detectsPhoneNumbers(&self) -> bool;
280
281 #[deprecated]
283 #[unsafe(method(setDetectsPhoneNumbers:))]
284 #[unsafe(method_family = none)]
285 pub unsafe fn setDetectsPhoneNumbers(&self, detects_phone_numbers: bool);
286
287 #[cfg(feature = "UIDataDetectors")]
288 #[unsafe(method(dataDetectorTypes))]
289 #[unsafe(method_family = none)]
290 pub unsafe fn dataDetectorTypes(&self) -> UIDataDetectorTypes;
291
292 #[cfg(feature = "UIDataDetectors")]
293 #[unsafe(method(setDataDetectorTypes:))]
295 #[unsafe(method_family = none)]
296 pub unsafe fn setDataDetectorTypes(&self, data_detector_types: UIDataDetectorTypes);
297
298 #[unsafe(method(allowsInlineMediaPlayback))]
299 #[unsafe(method_family = none)]
300 pub unsafe fn allowsInlineMediaPlayback(&self) -> bool;
301
302 #[unsafe(method(setAllowsInlineMediaPlayback:))]
304 #[unsafe(method_family = none)]
305 pub unsafe fn setAllowsInlineMediaPlayback(&self, allows_inline_media_playback: bool);
306
307 #[unsafe(method(mediaPlaybackRequiresUserAction))]
308 #[unsafe(method_family = none)]
309 pub unsafe fn mediaPlaybackRequiresUserAction(&self) -> bool;
310
311 #[unsafe(method(setMediaPlaybackRequiresUserAction:))]
313 #[unsafe(method_family = none)]
314 pub unsafe fn setMediaPlaybackRequiresUserAction(
315 &self,
316 media_playback_requires_user_action: bool,
317 );
318
319 #[unsafe(method(mediaPlaybackAllowsAirPlay))]
320 #[unsafe(method_family = none)]
321 pub unsafe fn mediaPlaybackAllowsAirPlay(&self) -> bool;
322
323 #[unsafe(method(setMediaPlaybackAllowsAirPlay:))]
325 #[unsafe(method_family = none)]
326 pub unsafe fn setMediaPlaybackAllowsAirPlay(&self, media_playback_allows_air_play: bool);
327
328 #[unsafe(method(suppressesIncrementalRendering))]
329 #[unsafe(method_family = none)]
330 pub unsafe fn suppressesIncrementalRendering(&self) -> bool;
331
332 #[unsafe(method(setSuppressesIncrementalRendering:))]
334 #[unsafe(method_family = none)]
335 pub unsafe fn setSuppressesIncrementalRendering(
336 &self,
337 suppresses_incremental_rendering: bool,
338 );
339
340 #[unsafe(method(keyboardDisplayRequiresUserAction))]
341 #[unsafe(method_family = none)]
342 pub unsafe fn keyboardDisplayRequiresUserAction(&self) -> bool;
343
344 #[unsafe(method(setKeyboardDisplayRequiresUserAction:))]
346 #[unsafe(method_family = none)]
347 pub unsafe fn setKeyboardDisplayRequiresUserAction(
348 &self,
349 keyboard_display_requires_user_action: bool,
350 );
351
352 #[unsafe(method(paginationMode))]
353 #[unsafe(method_family = none)]
354 pub unsafe fn paginationMode(&self) -> UIWebPaginationMode;
355
356 #[unsafe(method(setPaginationMode:))]
358 #[unsafe(method_family = none)]
359 pub unsafe fn setPaginationMode(&self, pagination_mode: UIWebPaginationMode);
360
361 #[unsafe(method(paginationBreakingMode))]
362 #[unsafe(method_family = none)]
363 pub unsafe fn paginationBreakingMode(&self) -> UIWebPaginationBreakingMode;
364
365 #[unsafe(method(setPaginationBreakingMode:))]
367 #[unsafe(method_family = none)]
368 pub unsafe fn setPaginationBreakingMode(
369 &self,
370 pagination_breaking_mode: UIWebPaginationBreakingMode,
371 );
372
373 #[cfg(feature = "objc2-core-foundation")]
374 #[unsafe(method(pageLength))]
375 #[unsafe(method_family = none)]
376 pub unsafe fn pageLength(&self) -> CGFloat;
377
378 #[cfg(feature = "objc2-core-foundation")]
379 #[unsafe(method(setPageLength:))]
381 #[unsafe(method_family = none)]
382 pub unsafe fn setPageLength(&self, page_length: CGFloat);
383
384 #[cfg(feature = "objc2-core-foundation")]
385 #[unsafe(method(gapBetweenPages))]
386 #[unsafe(method_family = none)]
387 pub unsafe fn gapBetweenPages(&self) -> CGFloat;
388
389 #[cfg(feature = "objc2-core-foundation")]
390 #[unsafe(method(setGapBetweenPages:))]
392 #[unsafe(method_family = none)]
393 pub unsafe fn setGapBetweenPages(&self, gap_between_pages: CGFloat);
394
395 #[unsafe(method(pageCount))]
396 #[unsafe(method_family = none)]
397 pub unsafe fn pageCount(&self) -> NSUInteger;
398
399 #[unsafe(method(allowsPictureInPictureMediaPlayback))]
400 #[unsafe(method_family = none)]
401 pub unsafe fn allowsPictureInPictureMediaPlayback(&self) -> bool;
402
403 #[unsafe(method(setAllowsPictureInPictureMediaPlayback:))]
405 #[unsafe(method_family = none)]
406 pub unsafe fn setAllowsPictureInPictureMediaPlayback(
407 &self,
408 allows_picture_in_picture_media_playback: bool,
409 );
410
411 #[unsafe(method(allowsLinkPreview))]
412 #[unsafe(method_family = none)]
413 pub unsafe fn allowsLinkPreview(&self) -> bool;
414
415 #[unsafe(method(setAllowsLinkPreview:))]
417 #[unsafe(method_family = none)]
418 pub unsafe fn setAllowsLinkPreview(&self, allows_link_preview: bool);
419 );
420}
421
422#[cfg(all(feature = "UIResponder", feature = "UIView"))]
424impl UIWebView {
425 extern_methods!(
426 #[cfg(feature = "objc2-core-foundation")]
427 #[unsafe(method(initWithFrame:))]
428 #[unsafe(method_family = init)]
429 pub unsafe fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
430
431 #[unsafe(method(initWithCoder:))]
432 #[unsafe(method_family = init)]
433 pub unsafe fn initWithCoder(
434 this: Allocated<Self>,
435 coder: &NSCoder,
436 ) -> Option<Retained<Self>>;
437 );
438}
439
440#[cfg(all(feature = "UIResponder", feature = "UIView"))]
442impl UIWebView {
443 extern_methods!(
444 #[unsafe(method(init))]
445 #[unsafe(method_family = init)]
446 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
447
448 #[unsafe(method(new))]
449 #[unsafe(method_family = new)]
450 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
451 );
452}
453
454extern_protocol!(
455 pub unsafe trait UIWebViewDelegate: NSObjectProtocol + MainThreadOnly {
457 #[cfg(all(feature = "UIResponder", feature = "UIView"))]
458 #[deprecated = "No longer supported."]
459 #[optional]
460 #[unsafe(method(webView:shouldStartLoadWithRequest:navigationType:))]
461 #[unsafe(method_family = none)]
462 unsafe fn webView_shouldStartLoadWithRequest_navigationType(
463 &self,
464 web_view: &UIWebView,
465 request: &NSURLRequest,
466 navigation_type: UIWebViewNavigationType,
467 ) -> bool;
468
469 #[cfg(all(feature = "UIResponder", feature = "UIView"))]
470 #[deprecated = "No longer supported."]
471 #[optional]
472 #[unsafe(method(webViewDidStartLoad:))]
473 #[unsafe(method_family = none)]
474 unsafe fn webViewDidStartLoad(&self, web_view: &UIWebView);
475
476 #[cfg(all(feature = "UIResponder", feature = "UIView"))]
477 #[deprecated = "No longer supported."]
478 #[optional]
479 #[unsafe(method(webViewDidFinishLoad:))]
480 #[unsafe(method_family = none)]
481 unsafe fn webViewDidFinishLoad(&self, web_view: &UIWebView);
482
483 #[cfg(all(feature = "UIResponder", feature = "UIView"))]
484 #[deprecated = "No longer supported."]
485 #[optional]
486 #[unsafe(method(webView:didFailLoadWithError:))]
487 #[unsafe(method_family = none)]
488 unsafe fn webView_didFailLoadWithError(&self, web_view: &UIWebView, error: &NSError);
489 }
490);