@@ -203,8 +203,13 @@ pub struct WebviewAttributes {
203203 ///
204204 /// ## Platform-specific
205205 ///
206- /// - **Android on Wry:** The Android WebView does not provide an API for initialization scripts,
207- /// so we prepend them to each HTML head. They are only implemented on custom protocol URLs.
206+ /// - **Windows:** scripts are always added to subframes.
207+ /// - **Android:** When [addDocumentStartJavaScript] is not supported,
208+ /// we prepend initialization scripts to each HTML head (implementation only supported on custom protocol URLs).
209+ /// For remote URLs, we use [onPageStarted] which is not guaranteed to run before other scripts.
210+ ///
211+ /// [addDocumentStartJavaScript]: https://developer.android.com/reference/androidx/webkit/WebViewCompat#addDocumentStartJavaScript(android.webkit.WebView,java.lang.String,java.util.Set%3Cjava.lang.String%3E)
212+ /// [onPageStarted]: https://developer.android.com/reference/android/webkit/WebViewClient#onPageStarted(android.webkit.WebView,%20java.lang.String,%20android.graphics.Bitmap)
208213 pub initialization_scripts : Vec < InitializationScript > ,
209214 pub data_directory : Option < PathBuf > ,
210215 pub drag_drop_handler_enabled : bool ,
@@ -559,12 +564,3 @@ pub struct InitializationScript {
559564 /// Whether the script should be injected to main frame only
560565 pub for_main_frame_only : bool ,
561566}
562-
563- impl InitializationScript {
564- pub fn new ( script : & str , for_main_frame_only : bool ) -> Self {
565- Self {
566- script : script. to_owned ( ) ,
567- for_main_frame_only,
568- }
569- }
570- }
0 commit comments