objc2-web-kit 0.3.1

Bindings to the WebKit framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/webkit/wkinactiveschedulingpolicy?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct WKInactiveSchedulingPolicy(pub NSInteger);
impl WKInactiveSchedulingPolicy {
    #[doc(alias = "WKInactiveSchedulingPolicySuspend")]
    pub const Suspend: Self = Self(0);
    #[doc(alias = "WKInactiveSchedulingPolicyThrottle")]
    pub const Throttle: Self = Self(1);
    #[doc(alias = "WKInactiveSchedulingPolicyNone")]
    pub const None: Self = Self(2);
}

unsafe impl Encode for WKInactiveSchedulingPolicy {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for WKInactiveSchedulingPolicy {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// A WKPreferences object encapsulates the preference settings for a web
    /// view. The preferences object associated with a web view is specified by
    /// its web view configuration.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkpreferences?language=objc)
    #[unsafe(super(NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct WKPreferences;
);

extern_conformance!(
    unsafe impl NSCoding for WKPreferences {}
);

extern_conformance!(
    unsafe impl NSObjectProtocol for WKPreferences {}
);

extern_conformance!(
    unsafe impl NSSecureCoding for WKPreferences {}
);

impl WKPreferences {
    extern_methods!(
        #[cfg(feature = "objc2-core-foundation")]
        /// The minimum font size in points.
        ///
        /// The default value is 0.
        #[unsafe(method(minimumFontSize))]
        #[unsafe(method_family = none)]
        pub unsafe fn minimumFontSize(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`minimumFontSize`][Self::minimumFontSize].
        #[unsafe(method(setMinimumFontSize:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMinimumFontSize(&self, minimum_font_size: CGFloat);

        /// A Boolean value indicating whether JavaScript can open
        /// windows without user interaction.
        ///
        /// The default value is NO in iOS and YES in OS X.
        #[unsafe(method(javaScriptCanOpenWindowsAutomatically))]
        #[unsafe(method_family = none)]
        pub unsafe fn javaScriptCanOpenWindowsAutomatically(&self) -> bool;

        /// Setter for [`javaScriptCanOpenWindowsAutomatically`][Self::javaScriptCanOpenWindowsAutomatically].
        #[unsafe(method(setJavaScriptCanOpenWindowsAutomatically:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setJavaScriptCanOpenWindowsAutomatically(
            &self,
            java_script_can_open_windows_automatically: bool,
        );

        /// A Boolean value indicating whether warnings should be
        /// shown for suspected fraudulent content such as phishing or malware.
        ///
        /// The default value is YES.
        #[unsafe(method(isFraudulentWebsiteWarningEnabled))]
        #[unsafe(method_family = none)]
        pub unsafe fn isFraudulentWebsiteWarningEnabled(&self) -> bool;

        /// Setter for [`isFraudulentWebsiteWarningEnabled`][Self::isFraudulentWebsiteWarningEnabled].
        #[unsafe(method(setFraudulentWebsiteWarningEnabled:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFraudulentWebsiteWarningEnabled(
            &self,
            fraudulent_website_warning_enabled: bool,
        );

        /// A Boolean value indicating whether the web view should include backgrounds when printing.
        ///
        /// The default value is `NO`.
        #[unsafe(method(shouldPrintBackgrounds))]
        #[unsafe(method_family = none)]
        pub unsafe fn shouldPrintBackgrounds(&self) -> bool;

        /// Setter for [`shouldPrintBackgrounds`][Self::shouldPrintBackgrounds].
        #[unsafe(method(setShouldPrintBackgrounds:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setShouldPrintBackgrounds(&self, should_print_backgrounds: bool);

        /// If tabFocusesLinks is YES, the tab key will focus links and form controls.
        /// The Option key temporarily reverses this preference.
        #[unsafe(method(tabFocusesLinks))]
        #[unsafe(method_family = none)]
        pub unsafe fn tabFocusesLinks(&self) -> bool;

        /// Setter for [`tabFocusesLinks`][Self::tabFocusesLinks].
        #[unsafe(method(setTabFocusesLinks:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTabFocusesLinks(&self, tab_focuses_links: bool);

        /// A Boolean value indicating whether text interaction is disabled.
        #[unsafe(method(isTextInteractionEnabled))]
        #[unsafe(method_family = none)]
        pub unsafe fn isTextInteractionEnabled(&self) -> bool;

        /// Setter for [`isTextInteractionEnabled`][Self::isTextInteractionEnabled].
        #[unsafe(method(setTextInteractionEnabled:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTextInteractionEnabled(&self, text_interaction_enabled: bool);

        /// A Boolean value indicating whether WebKit will apply built-in workarounds (quirks)
        /// to improve compatibility with certain known websites. You can disable site-specific quirks
        /// to help test your website without these workarounds. Enabled by default.
        #[unsafe(method(isSiteSpecificQuirksModeEnabled))]
        #[unsafe(method_family = none)]
        pub unsafe fn isSiteSpecificQuirksModeEnabled(&self) -> bool;

        /// Setter for [`isSiteSpecificQuirksModeEnabled`][Self::isSiteSpecificQuirksModeEnabled].
        #[unsafe(method(setSiteSpecificQuirksModeEnabled:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSiteSpecificQuirksModeEnabled(
            &self,
            site_specific_quirks_mode_enabled: bool,
        );

        /// A Boolean value indicating whether Fullscreen API is enabled.
        ///
        /// The default value is NO. We can set it to YES to enable support for the fullscreen API.
        #[unsafe(method(isElementFullscreenEnabled))]
        #[unsafe(method_family = none)]
        pub unsafe fn isElementFullscreenEnabled(&self) -> bool;

        /// Setter for [`isElementFullscreenEnabled`][Self::isElementFullscreenEnabled].
        #[unsafe(method(setElementFullscreenEnabled:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setElementFullscreenEnabled(&self, element_fullscreen_enabled: bool);

        /// Specify the scheduling policy for the web view when it is inactive
        /// and detached from the view hierarchy. Web views are not considered idle when playing media or loading web pages.
        /// A suspended web view will pause JavaScript execution and page layout.
        #[unsafe(method(inactiveSchedulingPolicy))]
        #[unsafe(method_family = none)]
        pub unsafe fn inactiveSchedulingPolicy(&self) -> WKInactiveSchedulingPolicy;

        /// Setter for [`inactiveSchedulingPolicy`][Self::inactiveSchedulingPolicy].
        #[unsafe(method(setInactiveSchedulingPolicy:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setInactiveSchedulingPolicy(
            &self,
            inactive_scheduling_policy: WKInactiveSchedulingPolicy,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl WKPreferences {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}

/// WKDeprecated.
impl WKPreferences {
    extern_methods!(
        #[deprecated = "Java is no longer supported"]
        #[unsafe(method(javaEnabled))]
        #[unsafe(method_family = none)]
        pub unsafe fn javaEnabled(&self) -> bool;

        /// Setter for [`javaEnabled`][Self::javaEnabled].
        #[deprecated = "Java is no longer supported"]
        #[unsafe(method(setJavaEnabled:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setJavaEnabled(&self, java_enabled: bool);

        #[deprecated = "Plug-ins are no longer supported"]
        #[unsafe(method(plugInsEnabled))]
        #[unsafe(method_family = none)]
        pub unsafe fn plugInsEnabled(&self) -> bool;

        /// Setter for [`plugInsEnabled`][Self::plugInsEnabled].
        #[deprecated = "Plug-ins are no longer supported"]
        #[unsafe(method(setPlugInsEnabled:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPlugInsEnabled(&self, plug_ins_enabled: bool);

        #[deprecated = "Use WKWebpagePreferences.allowsContentJavaScript to disable content JavaScript on a per-navigation basis"]
        #[unsafe(method(javaScriptEnabled))]
        #[unsafe(method_family = none)]
        pub unsafe fn javaScriptEnabled(&self) -> bool;

        /// Setter for [`javaScriptEnabled`][Self::javaScriptEnabled].
        #[deprecated = "Use WKWebpagePreferences.allowsContentJavaScript to disable content JavaScript on a per-navigation basis"]
        #[unsafe(method(setJavaScriptEnabled:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setJavaScriptEnabled(&self, java_script_enabled: bool);
    );
}