Mark promise creation methods with CanGc (#33928)

* Add CanGc annotations to promise constructor.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Propagate CanGc arguments for Promise::new_in_current_realm.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Fix out-of-order entries.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Propagate CanGc from Promise::new.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Suppress clippy warning.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Formatting.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2024-10-22 05:35:20 -04:00 committed by GitHub
parent edc304854f
commit 575e885529
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
50 changed files with 422 additions and 221 deletions

View file

@ -831,7 +831,7 @@ impl XRSessionMethods for XRSession {
comp: InRealm,
can_gc: CanGc,
) -> Rc<Promise> {
let p = Promise::new_in_current_realm(comp);
let p = Promise::new_in_current_realm(comp, can_gc);
// https://immersive-web.github.io/webxr/#create-a-reference-space
@ -892,7 +892,7 @@ impl XRSessionMethods for XRSession {
/// <https://immersive-web.github.io/webxr/#dom-xrsession-end>
fn End(&self, can_gc: CanGc) -> Rc<Promise> {
let global = self.global();
let p = Promise::new(&global);
let p = Promise::new(&global, can_gc);
if self.ended.get() && self.end_promises.borrow().is_empty() {
// If the session has completely ended and all end promises have been resolved,
// don't queue up more end promises
@ -922,8 +922,8 @@ impl XRSessionMethods for XRSession {
}
// https://immersive-web.github.io/hit-test/#dom-xrsession-requesthittestsource
fn RequestHitTestSource(&self, options: &XRHitTestOptionsInit) -> Rc<Promise> {
let p = Promise::new(&self.global());
fn RequestHitTestSource(&self, options: &XRHitTestOptionsInit, can_gc: CanGc) -> Rc<Promise> {
let p = Promise::new(&self.global(), can_gc);
if !self
.session
@ -1025,10 +1025,15 @@ impl XRSessionMethods for XRSession {
}
/// <https://www.w3.org/TR/webxr/#dom-xrsession-updatetargetframerate>
fn UpdateTargetFrameRate(&self, rate: Finite<f32>, comp: InRealm) -> Rc<Promise> {
fn UpdateTargetFrameRate(
&self,
rate: Finite<f32>,
comp: InRealm,
can_gc: CanGc,
) -> Rc<Promise> {
let mut session = self.session.borrow_mut();
let supported_frame_rates = session.supported_frame_rates();
let promise = Promise::new_in_current_realm(comp);
let promise = Promise::new_in_current_realm(comp, can_gc);
if self.mode == XRSessionMode::Inline ||
supported_frame_rates.is_empty() ||