Use Window in new methods instead of GlobalScope for interfaces with … (#36133)

…Window-only constructors

<!-- Please describe your changes on the following line: -->


---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by
`[X]` when the step is complete, and replace `___` with appropriate
data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #36118 (GitHub issue number if applicable)

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox
is checked, so that we can help you if you get stuck somewhere along the
way.-->

<!-- Pull requests that do not address these steps are welcome, but they
will require additional verification as part of the review process. -->

---------

Signed-off-by: richarddushime <mudaherarich@gmail.com>
Signed-off-by: Richard Dushime <45734838+richarddushime@users.noreply.github.com>
This commit is contained in:
Richard Dushime 2025-04-02 16:50:56 +02:00 committed by GitHub
parent 2ce306f450
commit 60baa8ce11
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
40 changed files with 226 additions and 240 deletions

View file

@ -289,8 +289,14 @@ impl XRSession {
promise.resolve_native(&(), can_gc);
}
// Step 7
let event =
XRSessionEvent::new(&self.global(), atom!("end"), false, false, self, can_gc);
let event = XRSessionEvent::new(
self.global().as_window(),
atom!("end"),
false,
false,
self,
can_gc,
);
event.upcast::<Event>().fire(self.upcast(), can_gc);
},
XREvent::Select(input, kind, ty, frame) => {
@ -303,11 +309,11 @@ impl XRSession {
let source = self.input_sources.find(input);
let atom_index = if kind == SelectKind::Squeeze { 1 } else { 0 };
if let Some(source) = source {
let frame = XRFrame::new(&self.global(), self, frame, can_gc);
let frame = XRFrame::new(self.global().as_window(), self, frame, can_gc);
frame.set_active(true);
if ty == SelectEvent::Start {
let event = XRInputSourceEvent::new(
&self.global(),
self.global().as_window(),
START_ATOMS[atom_index].clone(),
false,
false,
@ -319,7 +325,7 @@ impl XRSession {
} else {
if ty == SelectEvent::Select {
let event = XRInputSourceEvent::new(
&self.global(),
self.global().as_window(),
EVENT_ATOMS[atom_index].clone(),
false,
false,
@ -330,7 +336,7 @@ impl XRSession {
event.upcast::<Event>().fire(self.upcast(), can_gc);
}
let event = XRInputSourceEvent::new(
&self.global(),
self.global().as_window(),
END_ATOMS[atom_index].clone(),
false,
false,
@ -351,7 +357,7 @@ impl XRSession {
};
self.visibility_state.set(v);
let event = XRSessionEvent::new(
&self.global(),
self.global().as_window(),
atom!("visibilitychange"),
false,
false,
@ -393,9 +399,10 @@ impl XRSession {
base == base_space
})
.for_each(|space| {
let offset = XRRigidTransform::new(&self.global(), transform, can_gc);
let offset =
XRRigidTransform::new(self.global().as_window(), transform, can_gc);
let event = XRReferenceSpaceEvent::new(
&self.global(),
self.global().as_window(),
atom!("reset"),
false,
false,
@ -462,7 +469,7 @@ impl XRSession {
}
let time = self.global().performance().to_dom_high_res_time_stamp(time);
let frame = XRFrame::new(&self.global(), self, frame, CanGc::note());
let frame = XRFrame::new(self.global().as_window(), self, frame, CanGc::note());
// Step 8-9
frame.set_active(true);
@ -603,7 +610,7 @@ impl XRSession {
self.framerate.set(rate);
let event = XRSessionEvent::new(
&self.global(),
self.global().as_window(),
Atom::from("frameratechange"),
false,
false,
@ -862,13 +869,14 @@ impl XRSessionMethods<crate::DomTypeHolder> for XRSession {
}
}
if ty == XRReferenceSpaceType::Bounded_floor {
let space = XRBoundedReferenceSpace::new(&self.global(), self, can_gc);
let space =
XRBoundedReferenceSpace::new(self.global().as_window(), self, can_gc);
self.reference_spaces
.borrow_mut()
.push(Dom::from_ref(space.reference_space()));
p.resolve_native(&space, can_gc);
} else {
let space = XRReferenceSpace::new(&self.global(), self, ty, can_gc);
let space = XRReferenceSpace::new(self.global().as_window(), self, ty, can_gc);
self.reference_spaces
.borrow_mut()
.push(Dom::from_ref(&*space));