objc2_web_kit/generated/
WKContentWorld.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9extern_class!(
10    /// A WKContentWorld object allows you to separate your application's interaction with content displayed in a WKWebView into different roles that cannot interfere with one another.
11    ///
12    /// WKContentWorld objects should be treated as namespaces. This is useful for keeping your application's web content environment separate from the environment of the web page content itself,
13    /// as well as managing multiple different environments within your own application.
14    /// For example:
15    /// - If you have complex scripting logic to bridge your web content to your application but your web content also has complex scripting libraries of its own,
16    /// you avoid possible conflicts by using a client WKContentWorld.
17    /// - If you are writing a general purpose web browser that supports JavaScript extensions, you would use a different client WKContentWorld for each extension.
18    ///
19    /// Since a WKContentWorld object is a namespace it does not contain any data itself.
20    /// For example:
21    /// - If you store a variable in JavaScript in the scope of a particular WKContentWorld while viewing a particular web page document, after navigating to a new document that variable will be gone.
22    /// - If you store a variable in JavaScript in the scope of a particular WKContentWorld in one WKWebView, that variable will not exist in the same world in another WKWebView.
23    ///
24    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkcontentworld?language=objc)
25    #[unsafe(super(NSObject))]
26    #[thread_kind = MainThreadOnly]
27    #[derive(Debug, PartialEq, Eq, Hash)]
28    pub struct WKContentWorld;
29);
30
31extern_conformance!(
32    unsafe impl NSObjectProtocol for WKContentWorld {}
33);
34
35impl WKContentWorld {
36    extern_methods!(
37        #[unsafe(method(new))]
38        #[unsafe(method_family = new)]
39        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
40
41        #[unsafe(method(init))]
42        #[unsafe(method_family = init)]
43        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
44
45        /// Retrieve the main world that page content itself uses.
46        ///
47        /// When interacting with page content in a WKWebView using the page content world you can disrupt the operation of page content (e.g. by conflicting with variable names in JavaScript set by the web page content itself).
48        #[unsafe(method(pageWorld))]
49        #[unsafe(method_family = none)]
50        pub unsafe fn pageWorld(mtm: MainThreadMarker) -> Retained<WKContentWorld>;
51
52        /// Retrieve the default world for API client use.
53        ///
54        /// When using a content world different from the page content world you can still manipulate the DOM and built-in DOM APIs but without conflicting with other aspects of the page content (e.g. JavaScript from the web page content itself)
55        /// Repeated calls will retrieve the same WKContentWorld instance.
56        #[unsafe(method(defaultClientWorld))]
57        #[unsafe(method_family = none)]
58        pub unsafe fn defaultClientWorld(mtm: MainThreadMarker) -> Retained<WKContentWorld>;
59
60        /// Retrieves a named content world for API client use.
61        ///
62        /// Parameter `name`: The name of the WKContentWorld to retrieve.
63        ///
64        /// When using a content world different from the page content world you can still manipulate the DOM and built-in DOM APIs but without conflicting with other aspects of the page content (e.g. JavaScript from the web page content itself)
65        /// As long as a particular named WKContentWorld instance has not been deallocated, repeated calls with the same name will retrieve that same WKContentWorld instance.
66        /// Each named content world is distinct from all other named content worlds, the defaultClientWorld, and the pageWorld.
67        /// The name can be used to keep distinct worlds identifiable anywhere a world might be surfaced in a user interface. For example, the different worlds used in your application will be surfaced by name in the WebKit Web Inspector.
68        #[unsafe(method(worldWithName:))]
69        #[unsafe(method_family = none)]
70        pub unsafe fn worldWithName(
71            name: &NSString,
72            mtm: MainThreadMarker,
73        ) -> Retained<WKContentWorld>;
74
75        /// The name of the WKContentWorld
76        ///
77        /// The pageWorld and defaultClientWorld instances will have a nil name.
78        /// All other instances will have the non-nil name they were accessed by.
79        #[unsafe(method(name))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn name(&self) -> Option<Retained<NSString>>;
82    );
83}