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

@ -35,11 +35,6 @@ pub struct Opts {
/// True to turn off incremental layout.
pub nonincremental_layout: bool,
/// Where to load userscripts from, if any. An empty string will load from
/// the resources/user-agent-js directory, and if the option isn't passed userscripts
/// won't be loaded
pub userscripts: Option<String>,
pub user_stylesheets: Vec<(Vec<u8>, ServoUrl)>,
/// True to exit on thread failure instead of displaying about:failure.
@ -191,7 +186,6 @@ impl Default for Opts {
time_profiling: None,
time_profiler_trace_path: None,
nonincremental_layout: false,
userscripts: None,
user_stylesheets: Vec::new(),
hard_fail: true,
webdriver_port: None,