Allow setting userscripts directly without the need of files (#35388)

* Allow settings userscripts through preferences

Signed-off-by: Tony <legendmastertony@gmail.com>

* mach fmt instead of cargo fmt

Signed-off-by: Tony <legendmastertony@gmail.com>

* Fix pref loading not working for array values

Signed-off-by: Tony <legendmastertony@gmail.com>

* Use pref! in userscripts instead

Signed-off-by: Tony <legendmastertony@gmail.com>

* Implement the model jdm suggested
- Remove userscripts from all places and move it to servoshell
- Add in `UserContentManager` struct and passing it through `Servo::new`
all the way down to script thread

Signed-off-by: Tony <legendmastertony@gmail.com>

* Apply suggestions from code review and format

Signed-off-by: Tony <legendmastertony@gmail.com>

* Revert unrelated change

Signed-off-by: Tony <legendmastertony@gmail.com>

---------

Signed-off-by: Tony <legendmastertony@gmail.com>
Signed-off-by: Tony <68118705+Legend-Master@users.noreply.github.com>
This commit is contained in:
Tony 2025-03-27 11:00:08 +08:00 committed by GitHub
parent 53a2e61fec
commit 5a76906d64
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 143 additions and 51 deletions

View file

@ -33,6 +33,7 @@ use constellation_traits::{
use crossbeam_channel::{RecvTimeoutError, Sender};
use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, WorkerId};
use embedder_traits::input_events::InputEvent;
use embedder_traits::user_content_manager::UserContentManager;
use embedder_traits::{MediaSessionActionType, Theme, WebDriverScriptCommand};
use euclid::{Rect, Scale, Size2D, UnknownUnit};
use http::{HeaderMap, Method};
@ -463,6 +464,8 @@ pub struct InitialScriptState {
pub compositor_api: CrossProcessCompositorApi,
/// Application window's GL Context for Media player
pub player_context: WindowGLContext,
/// User content manager
pub user_content_manager: UserContentManager,
}
/// This trait allows creating a `ServiceWorkerManager` without depending on the `script`