diff --git a/.changes/macos-fullscreen.md b/.changes/macos-fullscreen.md index 0c4c7aa42..6627db78b 100644 --- a/.changes/macos-fullscreen.md +++ b/.changes/macos-fullscreen.md @@ -2,4 +2,4 @@ wry: patch --- -Enable WebView element fullscreen support on macOS 12.3+ and iOS 15.4+ without using private APIs. Support for older OS versions is still behind the `fullscreen` feature flag. +Enable WebView element fullscreen support on macOS 12.3+ and iOS 15.4+ without using private APIs. diff --git a/.changes/remove-macos-private-api-feature-flags.md b/.changes/remove-macos-private-api-feature-flags.md new file mode 100644 index 000000000..56124e40f --- /dev/null +++ b/.changes/remove-macos-private-api-feature-flags.md @@ -0,0 +1,5 @@ +--- +wry: minor +--- + +**Breaking Change:** Removed the macOS/iOS specific `transparent` and `fullscreen` feature flags. The functionalities are now always enabled. Please reach out immediatly if you see issues in the App Store submission process. diff --git a/Cargo.toml b/Cargo.toml index 305a6e499..23a951609 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,8 +28,6 @@ default = ["protocol", "os-webview", "x11"] serde = ["dpi/serde"] protocol = [] devtools = [] -transparent = [] -fullscreen = [] linux-body = ["webkit2gtk/v2_40", "os-webview"] mac-proxy = [] os-webview = [ diff --git a/README.md b/README.md index 81b6db3c0..fc9440f48 100644 --- a/README.md +++ b/README.md @@ -283,10 +283,6 @@ Wry uses a set of feature flags to toggle several advanced features. interacting with the window. - `devtools`: Enables devtools on release builds. Devtools are always enabled in debug builds. On **macOS**, enabling devtools, requires calling private functions, so avoid this in release builds if you publish your app on the App Store. -- `transparent`: Transparent background on **macOS** requires calling private functions. - Avoid this in release builds if you publish your app on the App Store. -- `fullscreen`: Fullscreen video and other media elements on **macOS** < 12.3 and **iOS** < 15.4 requires calling private functions. - Avoid this in release builds if you publish your app on the App Store. - `linux-body`: Enables body support of custom protocol request on Linux. Requires WebKit2GTK v2.40 or above. - `tracing`: enables [`tracing`] for `evaluate_script`, `ipc_handler`, and `custom_protocols`. diff --git a/examples/transparent.rs b/examples/transparent.rs index 0802012dc..6f78282ec 100644 --- a/examples/transparent.rs +++ b/examples/transparent.rs @@ -32,7 +32,6 @@ fn main() -> wry::Result<()> { let builder = WebViewBuilder::new() // The second is on webview... - // Feature `transparent` is required for transparency to work. .with_transparent(true) // And the last is in html. .with_html( diff --git a/src/lib.rs b/src/lib.rs index 15d29c3f7..516fe716f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -304,10 +304,6 @@ //! - `devtools`: Enables devtools on release builds. Devtools are always enabled in debug builds. //! On **macOS**, enabling devtools, requires calling private APIs so you should not enable this flag in release //! build if your app needs to publish to App Store. -//! - `transparent`: Transparent background on **macOS** requires calling private functions. -//! Avoid this in release build if your app needs to publish to App Store. -//! - `fullscreen`: Fullscreen video and other media on **macOS** requires calling private functions. -//! Avoid this in release build if your app needs to publish to App Store. //! - `linux-body`: Enables body support of custom protocol request on Linux. Requires //! WebKit2GTK v2.40 or above. //! - `tracing`: enables [`tracing`] for `evaluate_script`, `ipc_handler`, and `custom_protocols`. diff --git a/src/wkwebview/mod.rs b/src/wkwebview/mod.rs index 267a69f44..9379c645b 100644 --- a/src/wkwebview/mod.rs +++ b/src/wkwebview/mod.rs @@ -341,7 +341,8 @@ impl InnerWebView { data_store.setValue_forKey(Some(&proxies), ns_string!("proxyConfigurations")); } - // NOTE: Private API — `allowsPictureInPictureMediaPlayback` is a private KVC key on WKPreferences. + // NOTE: Private API on macOS — `allowsPictureInPictureMediaPlayback` is a private KVC key on WKPreferences. + // On iOS it's public _preference.setValue_forKey( Some(&_yes), ns_string!("allowsPictureInPictureMediaPlayback"), @@ -367,16 +368,10 @@ impl InnerWebView { let version = util::operating_system_version(); - #[cfg(feature = "transparent")] if attributes.transparent || attributes.background_color.is_some() { let no = NSNumber::numberWithBool(false); - { - if cfg!(target_os = "ios") || version.0 > 10 || (version.0 == 10 && version.1 >= 14) { - // NOTE: Private API — `drawsBackground`. - // Available: macOS 10.14+ (no public doc). - config.setValue_forKey(Some(&no), ns_string!("drawsBackground")); - } - } + // TODO: Check if this property exists or is used on iOS + config.setValue_forKey(Some(&no), ns_string!("drawsBackground")); } if (cfg!(target_os = "macos") && (version.0 > 12 || (version.0 == 12 && version.1 >= 3))) @@ -385,13 +380,13 @@ impl InnerWebView { // NOTE: Public API alternative for private config fullScreenEnabled (see below) // Only available on macOS 12.3+ and iOS 15.4+ _preference.setElementFullscreenEnabled(true); + } else { + // NOTE: Private API — `fullScreenEnabled` is a private KVC key on WKPreferences. + // This is the private API alternative to setElementFullscreenEnabled above that also works on older macOS/iOS versions. + // TODO: Remove this for Tauri v3? + _preference.setValue_forKey(Some(&_yes), ns_string!("fullScreenEnabled")); } - #[cfg(feature = "fullscreen")] - // NOTE: Private API — `fullScreenEnabled` is a private KVC key on WKPreferences. - // This is the private API alternative to setElementFullscreenEnabled above that also works on older macOS/iOS versions. - _preference.setValue_forKey(Some(&_yes), ns_string!("fullScreenEnabled")); - #[cfg(target_os = "macos")] let webview = { let window = ns_view.window().unwrap(); @@ -543,15 +538,15 @@ impl InnerWebView { if attributes.devtools { // // Available: macOS 13.3+, iOS 16.4+ + // Enables debugging via Safari's Web Inspector, NOT via in-webview devtools. let has_inspectable_property: bool = NSObject::respondsToSelector(&webview, objc2::sel!(setInspectable:)); if has_inspectable_property { webview.setInspectable(true); } // NOTE: Private API — `developerExtrasEnabled` is a private KVC key on WKPreferences. - // this cannot be on an `else` statement, it does not work on macOS :( - let dev = ns_string!("developerExtrasEnabled"); - _preference.setValue_forKey(Some(&_yes), dev); + // This enables the in-webview devtools + _preference.setValue_forKey(Some(&_yes), ns_string!("developerExtrasEnabled")); } // Message handler @@ -986,7 +981,7 @@ r#"Object.defineProperty(window, 'ipc', { self.webview.setBackgroundColor(Some(&color)); } - #[cfg(all(target_os = "macos", feature = "transparent"))] + #[cfg(target_os = "macos")] unsafe { let (red, green, blue, alpha) = _background_color;