Skip to content
Permalink
Browse files

Add SimulateVisibilityChange()

  • Loading branch information
Manishearth committed Jan 8, 2020
1 parent 6a21983 commit 9ecb13d83f2c83c27f2e50f98dcda0a5ef0a886d
Showing with 14 additions and 9 deletions.
  1. +13 −2 components/script/dom/fakexrdevice.rs
  2. +1 −7 components/script/dom/webidls/FakeXRDevice.webidl
@@ -5,6 +5,7 @@
use crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::{
self, FakeXRDeviceMethods, FakeXRRigidTransformInit, FakeXRViewInit,
};
use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XRVisibilityState;
use crate::dom::bindings::codegen::Bindings::XRViewBinding::XREye;
use crate::dom::bindings::error::{Error, Fallible};
use crate::dom::bindings::refcounted::TrustedPromise;
@@ -20,7 +21,7 @@ use ipc_channel::ipc::IpcSender;
use ipc_channel::router::ROUTER;
use profile_traits::ipc;
use std::rc::Rc;
use webxr_api::{MockDeviceMsg, MockViewInit, MockViewsInit};
use webxr_api::{MockDeviceMsg, MockViewInit, MockViewsInit, Visibility};

#[dom_struct]
pub struct FakeXRDevice {
@@ -163,7 +164,17 @@ impl FakeXRDeviceMethods for FakeXRDevice {
Ok(())
}

/// https://github.com/immersive-web/webxr-test-api/blob/master/explainer.md
/// https://immersive-web.github.io/webxr-test-api/#dom-fakexrdevice-simulatevisibilitychange
fn SimulateVisibilityChange(&self, v: XRVisibilityState) {
let v = match v {
XRVisibilityState::Visible => Visibility::Visible,
XRVisibilityState::Visible_blurred => Visibility::VisibleBlurred,
XRVisibilityState::Hidden => Visibility::Hidden,
};
let _ = self.sender.send(MockDeviceMsg::VisibilityChange(v));
}

/// https://immersive-web.github.io/webxr-test-api/#dom-fakexrdevice-disconnect
fn Disconnect(&self) -> Rc<Promise> {
let global = self.global();
let p = Promise::new(&global);
@@ -10,22 +10,16 @@ interface FakeXRDevice {
// requestAnimationFrame() callbacks.
[Throws] void setViews(sequence<FakeXRViewInit> views);

// // behaves as if device was disconnected
// Promise<void> disconnect();

[Throws] void setViewerOrigin(FakeXRRigidTransformInit origin, optional boolean emulatedPosition = false);
void clearViewerOrigin();

[Throws] void setFloorOrigin(FakeXRRigidTransformInit origin);
void clearFloorOrigin();

// // Simulates devices focusing and blurring sessions.
// void simulateVisibilityChange(XRVisibilityState);
void simulateVisibilityChange(XRVisibilityState state);

// void setBoundsGeometry(sequence<FakeXRBoundsPoint> boundsCoodinates);
// // Sets eye level used for calculating floor-level spaces
// void setEyeLevel(float eyeLevel);


// Promise<FakeXRInputController>
// simulateInputSourceConnection(FakeXRInputSourceInit);

0 comments on commit 9ecb13d

Please sign in to comment.
You can’t perform that action at this time.