diff options
author | Aron Zwaan <aronzwaan@gmail.com> | 2019-04-24 22:33:16 +0200 |
---|---|---|
committer | Aron Zwaan <aronzwaan@gmail.com> | 2019-04-25 11:37:35 +0200 |
commit | e2e6e2ac9428b9448edb06f7f11b201ce68e7191 (patch) | |
tree | 1ad0b3a8647d2946bf9a0b5ff427f1d8c1e6cf29 /components/script/dom | |
parent | 1b6949d4cf951600efa6db6747b65e2db42a96cd (diff) | |
download | servo-e2e6e2ac9428b9448edb06f7f11b201ce68e7191.tar.gz servo-e2e6e2ac9428b9448edb06f7f11b201ce68e7191.zip |
Pass InCompartment by value
Diffstat (limited to 'components/script/dom')
23 files changed, 49 insertions, 48 deletions
diff --git a/components/script/dom/audiocontext.rs b/components/script/dom/audiocontext.rs index 7e3bed85e06..3147f9bfb0a 100644 --- a/components/script/dom/audiocontext.rs +++ b/components/script/dom/audiocontext.rs @@ -113,7 +113,7 @@ impl AudioContextMethods for AudioContext { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let promise = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); // Step 2. @@ -178,7 +178,7 @@ impl AudioContextMethods for AudioContext { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let promise = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); // Step 2. diff --git a/components/script/dom/baseaudiocontext.rs b/components/script/dom/baseaudiocontext.rs index e18a2f8ede8..1d69532c8b1 100644 --- a/components/script/dom/baseaudiocontext.rs +++ b/components/script/dom/baseaudiocontext.rs @@ -277,7 +277,7 @@ impl BaseAudioContextMethods for BaseAudioContext { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let promise = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); // Step 2. @@ -418,7 +418,7 @@ impl BaseAudioContextMethods for BaseAudioContext { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let promise = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); let global = self.global(); let window = global.as_window(); diff --git a/components/script/dom/bluetooth.rs b/components/script/dom/bluetooth.rs index dc57af6b1cb..4b31a4b765e 100644 --- a/components/script/dom/bluetooth.rs +++ b/components/script/dom/bluetooth.rs @@ -295,7 +295,7 @@ where let in_compartment_proof = AlreadyInCompartment::assert(&attribute.global()); let p = Promise::new_in_current_compartment( &attribute.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); let result_uuid = if let Some(u) = uuid { @@ -539,7 +539,7 @@ impl BluetoothMethods for Bluetooth { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let p = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); // Step 1. if (option.filters.is_some() && option.acceptAllDevices) || @@ -561,7 +561,7 @@ impl BluetoothMethods for Bluetooth { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let p = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); // Step 1. We did not override the method // Step 2 - 3. in handle_response diff --git a/components/script/dom/bluetoothdevice.rs b/components/script/dom/bluetoothdevice.rs index a1ec00f4b3a..8ca7643737c 100644 --- a/components/script/dom/bluetoothdevice.rs +++ b/components/script/dom/bluetoothdevice.rs @@ -282,7 +282,7 @@ impl BluetoothDeviceMethods for BluetoothDevice { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let p = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); let sender = response_async(&p, self); // TODO: Step 1. diff --git a/components/script/dom/bluetoothremotegattcharacteristic.rs b/components/script/dom/bluetoothremotegattcharacteristic.rs index aa6d95ddb59..440e0523492 100644 --- a/components/script/dom/bluetoothremotegattcharacteristic.rs +++ b/components/script/dom/bluetoothremotegattcharacteristic.rs @@ -139,7 +139,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let p = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); // Step 1. @@ -176,7 +176,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let p = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); // Step 1. @@ -231,7 +231,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let p = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); // Step 1. @@ -272,7 +272,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let p = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); let sender = response_async(&p, self); diff --git a/components/script/dom/bluetoothremotegattdescriptor.rs b/components/script/dom/bluetoothremotegattdescriptor.rs index aaeb1145422..b4483db0410 100644 --- a/components/script/dom/bluetoothremotegattdescriptor.rs +++ b/components/script/dom/bluetoothremotegattdescriptor.rs @@ -98,7 +98,7 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let p = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); // Step 1. @@ -134,7 +134,7 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let p = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); // Step 1. diff --git a/components/script/dom/bluetoothremotegattserver.rs b/components/script/dom/bluetoothremotegattserver.rs index 0693599e742..19f1ba154ca 100644 --- a/components/script/dom/bluetoothremotegattserver.rs +++ b/components/script/dom/bluetoothremotegattserver.rs @@ -76,7 +76,7 @@ impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let p = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); let sender = response_async(&p, self); diff --git a/components/script/dom/customelementregistry.rs b/components/script/dom/customelementregistry.rs index e75d9b03da2..ee62c827637 100644 --- a/components/script/dom/customelementregistry.rs +++ b/components/script/dom/customelementregistry.rs @@ -409,7 +409,7 @@ impl CustomElementRegistryMethods for CustomElementRegistry { let in_compartment_proof = AlreadyInCompartment::assert(&global_scope); let promise = Promise::new_in_current_compartment( &global_scope, - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); promise.reject_native(&DOMException::new(&global_scope, DOMErrorName::SyntaxError)); return promise; @@ -420,7 +420,7 @@ impl CustomElementRegistryMethods for CustomElementRegistry { let in_compartment_proof = AlreadyInCompartment::assert(&global_scope); let promise = Promise::new_in_current_compartment( &global_scope, - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); promise.resolve_native(&UndefinedValue()); return promise; @@ -434,7 +434,7 @@ impl CustomElementRegistryMethods for CustomElementRegistry { let in_compartment_proof = AlreadyInCompartment::assert(&global_scope); let promise = Promise::new_in_current_compartment( &global_scope, - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); map.insert(name, promise.clone()); promise diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 7d4950caa66..4fec01bd38c 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -3135,7 +3135,7 @@ impl Document { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let promise = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); let mut error = false; @@ -3206,7 +3206,7 @@ impl Document { let in_compartment_proof = AlreadyInCompartment::assert(&global); let promise = Promise::new_in_current_compartment( &global, - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); // Step 2 if self.fullscreen_element.get().is_none() { diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index 252755cb64e..aeba3794310 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -1688,7 +1688,7 @@ impl HTMLMediaElementMethods for HTMLMediaElement { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let promise = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); // Step 1. // FIXME(nox): Reject promise if not allowed to play. diff --git a/components/script/dom/mediadevices.rs b/components/script/dom/mediadevices.rs index eca54b1fd57..0a4f00e2472 100644 --- a/components/script/dom/mediadevices.rs +++ b/components/script/dom/mediadevices.rs @@ -48,7 +48,7 @@ impl MediaDevicesMethods for MediaDevices { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let p = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); let media = ServoMedia::get().unwrap(); let mut tracks = vec![]; diff --git a/components/script/dom/navigationpreloadmanager.rs b/components/script/dom/navigationpreloadmanager.rs index a170acda4bc..a1e3c9de923 100644 --- a/components/script/dom/navigationpreloadmanager.rs +++ b/components/script/dom/navigationpreloadmanager.rs @@ -48,7 +48,7 @@ impl NavigationPreloadManagerMethods for NavigationPreloadManager { let in_compartment_proof = AlreadyInCompartment::assert(&*self.global()); let promise = Promise::new_in_current_compartment( &*self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); // 2. @@ -74,7 +74,7 @@ impl NavigationPreloadManagerMethods for NavigationPreloadManager { let in_compartment_proof = AlreadyInCompartment::assert(&*self.global()); let promise = Promise::new_in_current_compartment( &*self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); // 2. @@ -100,7 +100,7 @@ impl NavigationPreloadManagerMethods for NavigationPreloadManager { let in_compartment_proof = AlreadyInCompartment::assert(&*self.global()); let promise = Promise::new_in_current_compartment( &*self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); // 2. @@ -126,7 +126,7 @@ impl NavigationPreloadManagerMethods for NavigationPreloadManager { let in_compartment_proof = AlreadyInCompartment::assert(&*self.global()); let promise = Promise::new_in_current_compartment( &*self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); // 2. let mut state = NavigationPreloadState::empty(); diff --git a/components/script/dom/navigator.rs b/components/script/dom/navigator.rs index e7e93415b85..9d1a0de8e2e 100644 --- a/components/script/dom/navigator.rs +++ b/components/script/dom/navigator.rs @@ -155,7 +155,7 @@ impl NavigatorMethods for Navigator { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let promise = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); let displays = self.Xr().get_displays(); match displays { diff --git a/components/script/dom/offlineaudiocontext.rs b/components/script/dom/offlineaudiocontext.rs index c526ae9a890..a4d6c54c9ca 100644 --- a/components/script/dom/offlineaudiocontext.rs +++ b/components/script/dom/offlineaudiocontext.rs @@ -118,7 +118,7 @@ impl OfflineAudioContextMethods for OfflineAudioContext { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let promise = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); if self.rendering_started.get() { promise.reject_error(Error::InvalidState); diff --git a/components/script/dom/permissions.rs b/components/script/dom/permissions.rs index e6eba6a5082..e7d3b600814 100644 --- a/components/script/dom/permissions.rs +++ b/components/script/dom/permissions.rs @@ -102,7 +102,7 @@ impl Permissions { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ) }, }; diff --git a/components/script/dom/promise.rs b/components/script/dom/promise.rs index 52e6dfab56a..b4e3109e789 100644 --- a/components/script/dom/promise.rs +++ b/components/script/dom/promise.rs @@ -11,7 +11,7 @@ //! native Promise values that refer to the same JS value yet are distinct native objects //! (ie. address equality for the native objects is meaningless). -use crate::compartments::InCompartment; +use crate::compartments::{AlreadyInCompartment, InCompartment}; use crate::dom::bindings::conversions::root_from_object; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::{DomObject, MutDomObject, Reflector}; @@ -80,12 +80,13 @@ impl Drop for Promise { } impl Promise { - pub fn new(global: &GlobalScope, comp: &InCompartment) -> Rc<Promise> { - Promise::new_in_current_compartment(global, comp) + pub fn new(global: &GlobalScope) -> Rc<Promise> { + let comp = AlreadyInCompartment::assert(&global); + Promise::new_in_current_compartment(global, InCompartment::Already(&comp)) } #[allow(unsafe_code)] - pub fn new_in_current_compartment(global: &GlobalScope, _comp: &InCompartment) -> Rc<Promise> { + pub fn new_in_current_compartment(global: &GlobalScope, _comp: InCompartment) -> Rc<Promise> { let cx = global.get_cx(); rooted!(in(cx) let mut obj = ptr::null_mut::<JSObject>()); unsafe { diff --git a/components/script/dom/rtcpeerconnection.rs b/components/script/dom/rtcpeerconnection.rs index 163f84a89da..962eb0fb02c 100644 --- a/components/script/dom/rtcpeerconnection.rs +++ b/components/script/dom/rtcpeerconnection.rs @@ -432,7 +432,7 @@ impl RTCPeerConnectionMethods for RTCPeerConnection { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let p = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); if candidate.sdpMid.is_none() && candidate.sdpMLineIndex.is_none() { p.reject_error(Error::Type(format!( @@ -471,7 +471,7 @@ impl RTCPeerConnectionMethods for RTCPeerConnection { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let p = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); if self.closed.get() { p.reject_error(Error::InvalidState); @@ -487,7 +487,7 @@ impl RTCPeerConnectionMethods for RTCPeerConnection { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let p = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); if self.closed.get() { p.reject_error(Error::InvalidState); @@ -514,7 +514,7 @@ impl RTCPeerConnectionMethods for RTCPeerConnection { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let p = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); let this = Trusted::new(self); let desc: SessionDescription = desc.into(); @@ -551,7 +551,7 @@ impl RTCPeerConnectionMethods for RTCPeerConnection { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let p = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); let this = Trusted::new(self); let desc: SessionDescription = desc.into(); diff --git a/components/script/dom/serviceworkercontainer.rs b/components/script/dom/serviceworkercontainer.rs index 202a973f851..a8eada04678 100644 --- a/components/script/dom/serviceworkercontainer.rs +++ b/components/script/dom/serviceworkercontainer.rs @@ -60,7 +60,7 @@ impl ServiceWorkerContainerMethods for ServiceWorkerContainer { let in_compartment_proof = AlreadyInCompartment::assert(&*self.global()); let promise = Promise::new_in_current_compartment( &*self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); let USVString(ref script_url) = script_url; let api_base_url = self.global().api_base_url(); diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index a1515340199..99e294e75e9 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -1024,7 +1024,7 @@ impl TestBindingMethods for TestBinding { let in_compartment_proof = AlreadyInCompartment::assert(&global); let p = Promise::new_in_current_compartment( &global, - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); p.append_native_handler(&handler); return p; @@ -1052,7 +1052,7 @@ impl TestBindingMethods for TestBinding { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ) } diff --git a/components/script/dom/vrdisplay.rs b/components/script/dom/vrdisplay.rs index e98ca1ad1ec..a8cb594a2b1 100644 --- a/components/script/dom/vrdisplay.rs +++ b/components/script/dom/vrdisplay.rs @@ -346,7 +346,7 @@ impl VRDisplayMethods for VRDisplay { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let promise = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); // TODO: WebVR spec: this method must be called in response to a user gesture @@ -414,7 +414,7 @@ impl VRDisplayMethods for VRDisplay { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let promise = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); // WebVR spec: If the VRDisplay is not presenting the promise MUST be rejected. diff --git a/components/script/dom/worklet.rs b/components/script/dom/worklet.rs index caccf0609d4..90421efac61 100644 --- a/components/script/dom/worklet.rs +++ b/components/script/dom/worklet.rs @@ -117,7 +117,7 @@ impl WorkletMethods for Worklet { let in_compartment_proof = AlreadyInCompartment::assert(&global); let promise = Promise::new_in_current_compartment( &global, - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); // Step 3. diff --git a/components/script/dom/xr.rs b/components/script/dom/xr.rs index cd963c4cf03..3ff67b0042c 100644 --- a/components/script/dom/xr.rs +++ b/components/script/dom/xr.rs @@ -89,7 +89,7 @@ impl XRMethods for XR { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let promise = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); if mode == XRSessionMode::Immersive_vr { promise.resolve_native(&()); @@ -106,7 +106,7 @@ impl XRMethods for XR { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let promise = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); if options.mode != XRSessionMode::Immersive_vr { promise.reject_error(Error::NotSupported); diff --git a/components/script/dom/xrsession.rs b/components/script/dom/xrsession.rs index 7633775ebc6..4b855cba4c8 100644 --- a/components/script/dom/xrsession.rs +++ b/components/script/dom/xrsession.rs @@ -94,7 +94,7 @@ impl XRSessionMethods for XRSession { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let p = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); self.display.queue_renderstate(init, p.clone()); p @@ -120,7 +120,7 @@ impl XRSessionMethods for XRSession { let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); let p = Promise::new_in_current_compartment( &self.global(), - &InCompartment::Already(&in_compartment_proof), + InCompartment::Already(&in_compartment_proof), ); // https://immersive-web.github.io/webxr/#create-a-reference-space |