mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
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:
parent
53a2e61fec
commit
5a76906d64
16 changed files with 143 additions and 51 deletions
|
@ -43,13 +43,11 @@ impl TryFrom<&Value> for PrefValue {
|
|||
.unwrap_or(Err("Could not parse number from JSON".into())),
|
||||
Value::String(value) => Ok(value.clone().into()),
|
||||
Value::Array(array) => {
|
||||
let array = array.iter().map(TryInto::try_into);
|
||||
if !array.clone().all(|v| v.is_ok()) {
|
||||
return Err(format!(
|
||||
"Cannot turn all array avlues into preference: {array:?}"
|
||||
));
|
||||
}
|
||||
Ok(PrefValue::Array(array.map(Result::unwrap).collect()))
|
||||
let array = array
|
||||
.iter()
|
||||
.map(TryInto::<PrefValue>::try_into)
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
Ok(PrefValue::Array(array))
|
||||
},
|
||||
Value::Object(_) => Err("Cannot turn object into preference".into()),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue