script: Move BlobMethods to &mut JSContext#43215
Conversation
Signed-off-by: Uiniel <174327181+uiniel@users.noreply.github.com>
| let in_realm_proof = AlreadyInRealm::assert::<crate::DomTypeHolder>(); | ||
| let p = Promise::new_in_current_realm(InRealm::Already(&in_realm_proof), can_gc); | ||
| let p = | ||
| Promise::new_in_current_realm(InRealm::Already(&in_realm_proof), CanGc::from_cx(cx)); |
There was a problem hiding this comment.
| Promise::new_in_current_realm(InRealm::Already(&in_realm_proof), CanGc::from_cx(cx)); | |
| Promise::new_in_realm(cx); |
| 'canGc': ['Slice', 'Text', 'ArrayBuffer', 'Stream', 'Bytes'], | ||
| 'canGc': ['ArrayBuffer', 'Bytes'], | ||
| 'inRealms': ['Bytes', 'ArrayBuffer'], | ||
| 'cx': ['Stream', 'Slice', 'Text', 'Constructor'] |
There was a problem hiding this comment.
Since Text creates a Promise we need to move it to 'realm': ['Text']
| let task = task!(resolve_promise: move || { | ||
| let task = task!(resolve_promise: move |cx| { | ||
| let promise = trusted_promise.root(); | ||
| let _ac = enter_realm(&*promise.global()); |
There was a problem hiding this comment.
Let's call enter_auto_realm(cx, promise.global()) here.
There was a problem hiding this comment.
This change would result in two mutable borrows of cx, because _ac is dropped after the call to callback. I'm also not familiar enough with the code to understand why enter_realm is needed here or if it is still needed after changing CanGc::note to CanGc::from_cx in the callback.
There was a problem hiding this comment.
I think we still need it, you can fix the borrow issue by doing
let mut realm = enter_auto_realm(cx, promise.global());
let cx = &mut realm;There was a problem hiding this comment.
Ah right thanks! I forgot that realms can also be used as a context.
| self.task_source.queue(task!(reject_promise: move || { | ||
| self.task_source.queue(task!(reject_promise: move |cx| { | ||
| let promise = trusted_promise.root(); | ||
| let _ac = enter_realm(&*promise.global()); |
Signed-off-by: Uiniel <174327181+uiniel@users.noreply.github.com>
Signed-off-by: Uiniel <174327181+uiniel@users.noreply.github.com>
Move from CanGc to &mut js::context:JSContext. `ArrayBuffer` and `Bytes` require many changes in `dom/stream` for which I'm going to create a seperate pull request before porting the two methods. Testing: Just a refactor, `./mach test-unit` still passes. Fixes: Part of servo#42638 --------- Signed-off-by: Uiniel <174327181+uiniel@users.noreply.github.com> (cherry picked from commit 0f5e020)
Move from CanGc to &mut js::context:JSContext.
ArrayBufferandBytesrequire many changes indom/streamfor which I'm going to create a seperate pull request before porting the two methods.Testing: Just a refactor,
./mach test-unitstill passes.Fixes: Part of #42638