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
31unsafe impl NSObjectProtocol for WKContentWorld {}
32
33impl WKContentWorld {
34    extern_methods!(
35        #[unsafe(method(new))]
36        #[unsafe(method_family = new)]
37        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
38
39        #[unsafe(method(init))]
40        #[unsafe(method_family = init)]
41        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
42
43        /// Retrieve the main world that page content itself uses.
44        ///
45        /// 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).
46        #[unsafe(method(pageWorld))]
47        #[unsafe(method_family = none)]
48        pub unsafe fn pageWorld(mtm: MainThreadMarker) -> Retained<WKContentWorld>;
49
50        /// Retrieve the default world for API client use.
51        ///
52        /// 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)
53        /// Repeated calls will retrieve the same WKContentWorld instance.
54        #[unsafe(method(defaultClientWorld))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn defaultClientWorld(mtm: MainThreadMarker) -> Retained<WKContentWorld>;
57
58        /// Retrieves a named content world for API client use.
59        ///
60        /// Parameter `name`: The name of the WKContentWorld to retrieve.
61        ///
62        /// 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)
63        /// As long as a particular named WKContentWorld instance has not been deallocated, repeated calls with the same name will retrieve that same WKContentWorld instance.
64        /// Each named content world is distinct from all other named content worlds, the defaultClientWorld, and the pageWorld.
65        /// 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.
66        #[unsafe(method(worldWithName:))]
67        #[unsafe(method_family = none)]
68        pub unsafe fn worldWithName(
69            name: &NSString,
70            mtm: MainThreadMarker,
71        ) -> Retained<WKContentWorld>;
72
73        /// The name of the WKContentWorld
74        ///
75        /// The pageWorld and defaultClientWorld instances will have a nil name.
76        /// All other instances will have the non-nil name they were accessed by.
77        #[unsafe(method(name))]
78        #[unsafe(method_family = none)]
79        pub unsafe fn name(&self) -> Option<Retained<NSString>>;
80    );
81}