mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Propagate CanGc
arguments through callers in constructors (#35541)
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
This commit is contained in:
parent
5465bfc2af
commit
863d2ce871
260 changed files with 986 additions and 603 deletions
|
@ -59,11 +59,12 @@ impl FakeXRDevice {
|
|||
pub(crate) fn new(
|
||||
global: &GlobalScope,
|
||||
sender: IpcSender<MockDeviceMsg>,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<FakeXRDevice> {
|
||||
reflect_dom_object(
|
||||
Box::new(FakeXRDevice::new_inherited(sender)),
|
||||
global,
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -299,7 +300,8 @@ impl FakeXRDeviceMethods<crate::DomTypeHolder> for FakeXRDevice {
|
|||
let global = self.global();
|
||||
let _ = self.sender.send(MockDeviceMsg::AddInputSource(init));
|
||||
|
||||
let controller = FakeXRInputController::new(&global, self.sender.clone(), id);
|
||||
let controller =
|
||||
FakeXRInputController::new(&global, self.sender.clone(), id, CanGc::note());
|
||||
|
||||
Ok(controller)
|
||||
}
|
||||
|
|
|
@ -52,11 +52,12 @@ impl FakeXRInputController {
|
|||
global: &GlobalScope,
|
||||
sender: IpcSender<MockDeviceMsg>,
|
||||
id: InputId,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<FakeXRInputController> {
|
||||
reflect_dom_object(
|
||||
Box::new(FakeXRInputController::new_inherited(sender, id)),
|
||||
global,
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ impl XRBoundedReferenceSpace {
|
|||
can_gc: CanGc,
|
||||
) -> DomRoot<XRBoundedReferenceSpace> {
|
||||
let offset = XRRigidTransform::identity(global, can_gc);
|
||||
Self::new_offset(global, session, &offset)
|
||||
Self::new_offset(global, session, &offset, can_gc)
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
|
@ -53,11 +53,12 @@ impl XRBoundedReferenceSpace {
|
|||
global: &GlobalScope,
|
||||
session: &XRSession,
|
||||
offset: &XRRigidTransform,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<XRBoundedReferenceSpace> {
|
||||
reflect_dom_object(
|
||||
Box::new(XRBoundedReferenceSpace::new_inherited(session, offset)),
|
||||
global,
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -49,11 +49,16 @@ impl XRFrame {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn new(global: &GlobalScope, session: &XRSession, data: Frame) -> DomRoot<XRFrame> {
|
||||
pub(crate) fn new(
|
||||
global: &GlobalScope,
|
||||
session: &XRSession,
|
||||
data: Frame,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<XRFrame> {
|
||||
reflect_dom_object(
|
||||
Box::new(XRFrame::new_inherited(session, data)),
|
||||
global,
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -193,7 +198,7 @@ impl XRFrameMethods<crate::DomTypeHolder> for XRFrame {
|
|||
.hit_test_results
|
||||
.iter()
|
||||
.filter(|r| r.id == source.id())
|
||||
.map(|r| XRHitTestResult::new(&self.global(), *r, self))
|
||||
.map(|r| XRHitTestResult::new(&self.global(), *r, self, CanGc::note()))
|
||||
.collect()
|
||||
}
|
||||
|
||||
|
|
|
@ -127,6 +127,7 @@ impl XRHand {
|
|||
global: &GlobalScope,
|
||||
source: &XRInputSource,
|
||||
support: Hand<()>,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<XRHand> {
|
||||
let id = source.id();
|
||||
let session = source.session();
|
||||
|
@ -136,12 +137,12 @@ impl XRHand {
|
|||
.find(|&&(_, value)| value == joint)
|
||||
.map(|&(hand_joint, _)| hand_joint)
|
||||
.expect("Invalid joint name");
|
||||
field.map(|_| XRJointSpace::new(global, session, id, joint, hand_joint))
|
||||
field.map(|_| XRJointSpace::new(global, session, id, joint, hand_joint, CanGc::note()))
|
||||
});
|
||||
reflect_dom_object(
|
||||
Box::new(XRHand::new_inherited(source, &spaces)),
|
||||
global,
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,11 +36,12 @@ impl XRHitTestResult {
|
|||
global: &GlobalScope,
|
||||
result: HitTestResult,
|
||||
frame: &XRFrame,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<XRHitTestResult> {
|
||||
reflect_dom_object(
|
||||
Box::new(XRHitTestResult::new_inherited(result, frame)),
|
||||
global,
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,11 +34,12 @@ impl XRHitTestSource {
|
|||
global: &GlobalScope,
|
||||
id: HitTestId,
|
||||
session: &XRSession,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<XRHitTestSource> {
|
||||
reflect_dom_object(
|
||||
Box::new(XRHitTestSource::new_inherited(id, session)),
|
||||
global,
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ impl XRInputSourceMethods<crate::DomTypeHolder> for XRInputSource {
|
|||
fn TargetRaySpace(&self) -> DomRoot<XRSpace> {
|
||||
self.target_ray_space.or_init(|| {
|
||||
let global = self.global();
|
||||
XRSpace::new_inputspace(&global, &self.session, self, false)
|
||||
XRSpace::new_inputspace(&global, &self.session, self, false, CanGc::note())
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ impl XRInputSourceMethods<crate::DomTypeHolder> for XRInputSource {
|
|||
if self.info.supports_grip {
|
||||
Some(self.grip_space.or_init(|| {
|
||||
let global = self.global();
|
||||
XRSpace::new_inputspace(&global, &self.session, self, true)
|
||||
XRSpace::new_inputspace(&global, &self.session, self, true, CanGc::note())
|
||||
}))
|
||||
} else {
|
||||
None
|
||||
|
@ -181,7 +181,7 @@ impl XRInputSourceMethods<crate::DomTypeHolder> for XRInputSource {
|
|||
fn GetHand(&self) -> Option<DomRoot<XRHand>> {
|
||||
self.info.hand_support.as_ref().map(|hand| {
|
||||
self.hand
|
||||
.or_init(|| XRHand::new(&self.global(), self, hand.clone()))
|
||||
.or_init(|| XRHand::new(&self.global(), self, hand.clone(), CanGc::note()))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,11 +31,11 @@ impl XRInputSourceArray {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn new(global: &GlobalScope) -> DomRoot<XRInputSourceArray> {
|
||||
pub(crate) fn new(global: &GlobalScope, can_gc: CanGc) -> DomRoot<XRInputSourceArray> {
|
||||
reflect_dom_object(
|
||||
Box::new(XRInputSourceArray::new_inherited()),
|
||||
global,
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -49,11 +49,12 @@ impl XRJointSpace {
|
|||
input: InputId,
|
||||
joint: Joint,
|
||||
hand_joint: XRHandJoint,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<XRJointSpace> {
|
||||
reflect_dom_object(
|
||||
Box::new(Self::new_inherited(session, input, joint, hand_joint)),
|
||||
global,
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -34,11 +34,7 @@ impl XRPose {
|
|||
can_gc: CanGc,
|
||||
) -> DomRoot<XRPose> {
|
||||
let transform = XRRigidTransform::new(global, transform, can_gc);
|
||||
reflect_dom_object(
|
||||
Box::new(XRPose::new_inherited(&transform)),
|
||||
global,
|
||||
CanGc::note(),
|
||||
)
|
||||
reflect_dom_object(Box::new(XRPose::new_inherited(&transform)), global, can_gc)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ impl XRReferenceSpace {
|
|||
can_gc: CanGc,
|
||||
) -> DomRoot<XRReferenceSpace> {
|
||||
let offset = XRRigidTransform::identity(global, can_gc);
|
||||
Self::new_offset(global, session, ty, &offset)
|
||||
Self::new_offset(global, session, ty, &offset, can_gc)
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
|
@ -55,11 +55,12 @@ impl XRReferenceSpace {
|
|||
session: &XRSession,
|
||||
ty: XRReferenceSpaceType,
|
||||
offset: &XRRigidTransform,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<XRReferenceSpace> {
|
||||
reflect_dom_object(
|
||||
Box::new(XRReferenceSpace::new_inherited(session, offset, ty)),
|
||||
global,
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -90,6 +91,7 @@ impl XRReferenceSpaceMethods<crate::DomTypeHolder> for XRReferenceSpace {
|
|||
self.upcast::<XRSpace>().session(),
|
||||
self.ty,
|
||||
&offset,
|
||||
CanGc::note(),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ impl XRRenderState {
|
|||
inline_vertical_fov: Option<f64>,
|
||||
layer: Option<&XRWebGLLayer>,
|
||||
layers: Vec<&XRLayer>,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<XRRenderState> {
|
||||
reflect_dom_object(
|
||||
Box::new(XRRenderState::new_inherited(
|
||||
|
@ -65,7 +66,7 @@ impl XRRenderState {
|
|||
layers,
|
||||
)),
|
||||
global,
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -77,6 +78,7 @@ impl XRRenderState {
|
|||
self.inline_vertical_fov.get(),
|
||||
self.base_layer.get().as_deref(),
|
||||
self.layers.borrow().iter().map(|x| &**x).collect(),
|
||||
CanGc::note(),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -155,14 +155,15 @@ impl XRSession {
|
|||
session: Session,
|
||||
mode: XRSessionMode,
|
||||
frame_receiver: IpcReceiver<Frame>,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<XRSession> {
|
||||
let ivfov = if mode == XRSessionMode::Inline {
|
||||
Some(FRAC_PI_2)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let render_state = XRRenderState::new(global, 0.1, 1000.0, ivfov, None, Vec::new());
|
||||
let input_sources = XRInputSourceArray::new(global);
|
||||
let render_state = XRRenderState::new(global, 0.1, 1000.0, ivfov, None, Vec::new(), can_gc);
|
||||
let input_sources = XRInputSourceArray::new(global, can_gc);
|
||||
let ret = reflect_dom_object(
|
||||
Box::new(XRSession::new_inherited(
|
||||
session,
|
||||
|
@ -171,7 +172,7 @@ impl XRSession {
|
|||
mode,
|
||||
)),
|
||||
global,
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
);
|
||||
ret.attach_event_handler();
|
||||
ret.setup_raf_loop(frame_receiver);
|
||||
|
@ -301,7 +302,7 @@ 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);
|
||||
let frame = XRFrame::new(&self.global(), self, frame, can_gc);
|
||||
frame.set_active(true);
|
||||
if ty == SelectEvent::Start {
|
||||
let event = XRInputSourceEvent::new(
|
||||
|
@ -460,7 +461,7 @@ impl XRSession {
|
|||
}
|
||||
|
||||
let time = self.global().performance().to_dom_high_res_time_stamp(time);
|
||||
let frame = XRFrame::new(&self.global(), self, frame);
|
||||
let frame = XRFrame::new(&self.global(), self, frame, CanGc::note());
|
||||
|
||||
// Step 8-9
|
||||
frame.set_active(true);
|
||||
|
@ -577,7 +578,12 @@ impl XRSession {
|
|||
match event {
|
||||
FrameUpdateEvent::HitTestSourceAdded(id) => {
|
||||
if let Some(promise) = self.pending_hit_test_promises.borrow_mut().remove(&id) {
|
||||
promise.resolve_native(&XRHitTestSource::new(&self.global(), id, self));
|
||||
promise.resolve_native(&XRHitTestSource::new(
|
||||
&self.global(),
|
||||
id,
|
||||
self,
|
||||
CanGc::note(),
|
||||
));
|
||||
} else {
|
||||
warn!(
|
||||
"received hit test add request for unknown hit test {:?}",
|
||||
|
|
|
@ -54,11 +54,12 @@ impl XRSpace {
|
|||
session: &XRSession,
|
||||
input: &XRInputSource,
|
||||
is_grip_space: bool,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<XRSpace> {
|
||||
reflect_dom_object(
|
||||
Box::new(XRSpace::new_inputspace_inner(session, input, is_grip_space)),
|
||||
global,
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -61,11 +61,11 @@ impl XRSystem {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn new(window: &Window) -> DomRoot<XRSystem> {
|
||||
pub(crate) fn new(window: &Window, can_gc: CanGc) -> DomRoot<XRSystem> {
|
||||
reflect_dom_object(
|
||||
Box::new(XRSystem::new_inherited(window.pipeline_id())),
|
||||
window,
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -270,7 +270,8 @@ impl XRSystemMethods<crate::DomTypeHolder> for XRSystem {
|
|||
|
||||
// https://github.com/immersive-web/webxr-test-api/blob/master/explainer.md
|
||||
fn Test(&self) -> DomRoot<XRTest> {
|
||||
self.test.or_init(|| XRTest::new(&self.global()))
|
||||
self.test
|
||||
.or_init(|| XRTest::new(&self.global(), CanGc::note()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -293,7 +294,7 @@ impl XRSystem {
|
|||
return;
|
||||
},
|
||||
};
|
||||
let session = XRSession::new(&self.global(), session, mode, frame_receiver);
|
||||
let session = XRSession::new(&self.global(), session, mode, frame_receiver, CanGc::note());
|
||||
if mode == XRSessionMode::Inline {
|
||||
self.active_inline_sessions
|
||||
.borrow_mut()
|
||||
|
|
|
@ -43,8 +43,8 @@ impl XRTest {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn new(global: &GlobalScope) -> DomRoot<XRTest> {
|
||||
reflect_dom_object(Box::new(XRTest::new_inherited()), global, CanGc::note())
|
||||
pub(crate) fn new(global: &GlobalScope, can_gc: CanGc) -> DomRoot<XRTest> {
|
||||
reflect_dom_object(Box::new(XRTest::new_inherited()), global, can_gc)
|
||||
}
|
||||
|
||||
fn device_obtained(
|
||||
|
@ -54,7 +54,7 @@ impl XRTest {
|
|||
) {
|
||||
let promise = trusted.root();
|
||||
if let Ok(sender) = response {
|
||||
let device = FakeXRDevice::new(&self.global(), sender);
|
||||
let device = FakeXRDevice::new(&self.global(), sender, CanGc::note());
|
||||
self.devices_connected
|
||||
.borrow_mut()
|
||||
.push(Dom::from_ref(&device));
|
||||
|
|
|
@ -75,7 +75,7 @@ impl XRView {
|
|||
view.cast_unit(),
|
||||
)),
|
||||
global,
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -27,11 +27,15 @@ impl XRViewport {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn new(global: &GlobalScope, viewport: Rect<i32, Viewport>) -> DomRoot<XRViewport> {
|
||||
pub(crate) fn new(
|
||||
global: &GlobalScope,
|
||||
viewport: Rect<i32, Viewport>,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<XRViewport> {
|
||||
reflect_dom_object(
|
||||
Box::new(XRViewport::new_inherited(viewport)),
|
||||
global,
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,7 +153,8 @@ impl XRWebGLLayer {
|
|||
let session = self.session();
|
||||
// TODO: Cache this texture
|
||||
let color_texture_id = WebGLTextureId::new(sub_images.sub_image.as_ref()?.color_texture?);
|
||||
let color_texture = WebGLTexture::new_webxr(context, color_texture_id, session);
|
||||
let color_texture =
|
||||
WebGLTexture::new_webxr(context, color_texture_id, session, CanGc::note());
|
||||
let target = self.texture_target();
|
||||
|
||||
// Save the current bindings
|
||||
|
@ -188,7 +189,7 @@ impl XRWebGLLayer {
|
|||
// TODO: Cache this texture
|
||||
let depth_stencil_texture_id = WebGLTextureId::new(id);
|
||||
let depth_stencil_texture =
|
||||
WebGLTexture::new_webxr(context, depth_stencil_texture_id, session);
|
||||
WebGLTexture::new_webxr(context, depth_stencil_texture_id, session, CanGc::note());
|
||||
framebuffer
|
||||
.texture2d_even_if_opaque(
|
||||
constants::DEPTH_STENCIL_ATTACHMENT,
|
||||
|
@ -361,6 +362,6 @@ impl XRWebGLLayerMethods<crate::DomTypeHolder> for XRWebGLLayer {
|
|||
// don't seem to do this for stereoscopic immersive sessions.
|
||||
// Revisit if Servo gets support for handheld AR/VR via ARCore/ARKit
|
||||
|
||||
Some(XRViewport::new(&self.global(), viewport))
|
||||
Some(XRViewport::new(&self.global(), viewport, CanGc::note()))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue