Skip to content

Commit

Permalink
rename compartment to realm
Browse files Browse the repository at this point in the history
  • Loading branch information
kunalmohan committed Jan 24, 2020
1 parent be40923 commit 5a3e1b8
Show file tree
Hide file tree
Showing 54 changed files with 226 additions and 259 deletions.
3 changes: 0 additions & 3 deletions components/config/prefs.rs
Expand Up @@ -377,9 +377,6 @@ mod gen {
slice_ms: i64,
},
low_frequency_heap_growth: i64,
per_compartment: {
enabled: bool,
},
per_zone: {
enabled: bool,
},
Expand Down
10 changes: 4 additions & 6 deletions components/script/body.rs
Expand Up @@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use crate::compartments::{AlreadyInCompartment, InCompartment};
use crate::dom::bindings::cell::Ref;
use crate::dom::bindings::codegen::Bindings::FormDataBinding::FormDataMethods;
use crate::dom::bindings::error::{Error, Fallible};
Expand All @@ -14,6 +13,7 @@ use crate::dom::blob::{normalize_type_string, Blob};
use crate::dom::formdata::FormData;
use crate::dom::globalscope::GlobalScope;
use crate::dom::promise::Promise;
use crate::realms::{AlreadyInRealm, InRealm};
use crate::script_runtime::JSContext;
use js::jsapi::Heap;
use js::jsapi::JSObject;
Expand Down Expand Up @@ -52,11 +52,9 @@ pub enum FetchedData {
// https://fetch.spec.whatwg.org/#concept-body-consume-body
#[allow(unrooted_must_root)]
pub fn consume_body<T: BodyOperations + DomObject>(object: &T, body_type: BodyType) -> Rc<Promise> {
let in_compartment_proof = AlreadyInCompartment::assert(&object.global());
let promise = Promise::new_in_current_compartment(
&object.global(),
InCompartment::Already(&in_compartment_proof),
);
let in_realm_proof = AlreadyInRealm::assert(&object.global());
let promise =
Promise::new_in_current_realm(&object.global(), InRealm::Already(&in_realm_proof));

// Step 1
if object.get_body_used() || object.is_locked() {
Expand Down
2 changes: 1 addition & 1 deletion components/script/devtools.rs
Expand Up @@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use crate::compartments::enter_realm;
use crate::dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods;
use crate::dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods;
use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
Expand All @@ -17,6 +16,7 @@ use crate::dom::element::Element;
use crate::dom::globalscope::GlobalScope;
use crate::dom::node::{window_from_node, Node, ShadowIncluding};
use crate::dom::window::Window;
use crate::realms::enter_realm;
use crate::script_thread::Documents;
use devtools_traits::{AutoMargins, ComputedNodeLayout, TimelineMarkerType};
use devtools_traits::{EvaluateJSReply, Modification, NodeInfo, TimelineMarker};
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/audiobuffer.rs
Expand Up @@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use crate::compartments::enter_realm;
use crate::dom::audionode::MAX_CHANNEL_COUNT;
use crate::dom::bindings::cell::{DomRefCell, Ref};
use crate::dom::bindings::codegen::Bindings::AudioBufferBinding::{
Expand All @@ -13,6 +12,7 @@ use crate::dom::bindings::num::Finite;
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
use crate::dom::bindings::root::DomRoot;
use crate::dom::window::Window;
use crate::realms::enter_realm;
use crate::script_runtime::JSContext;
use dom_struct::dom_struct;
use js::jsapi::JS_GetArrayBufferViewBuffer;
Expand Down
10 changes: 5 additions & 5 deletions components/script/dom/audiocontext.rs
Expand Up @@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use crate::compartments::InCompartment;
use crate::dom::baseaudiocontext::{BaseAudioContext, BaseAudioContextOptions};
use crate::dom::bindings::codegen::Bindings::AudioContextBinding;
use crate::dom::bindings::codegen::Bindings::AudioContextBinding::{
Expand All @@ -24,6 +23,7 @@ use crate::dom::htmlmediaelement::HTMLMediaElement;
use crate::dom::mediaelementaudiosourcenode::MediaElementAudioSourceNode;
use crate::dom::promise::Promise;
use crate::dom::window::Window;
use crate::realms::InRealm;
use crate::task_source::TaskSource;
use dom_struct::dom_struct;
use msg::constellation_msg::PipelineId;
Expand Down Expand Up @@ -127,9 +127,9 @@ impl AudioContextMethods for AudioContext {
}

// https://webaudio.github.io/web-audio-api/#dom-audiocontext-suspend
fn Suspend(&self, comp: InCompartment) -> Rc<Promise> {
fn Suspend(&self, comp: InRealm) -> Rc<Promise> {
// Step 1.
let promise = Promise::new_in_current_compartment(&self.global(), comp);
let promise = Promise::new_in_current_realm(&self.global(), comp);

// Step 2.
if self.context.control_thread_state() == ProcessingState::Closed {
Expand Down Expand Up @@ -188,9 +188,9 @@ impl AudioContextMethods for AudioContext {
}

// https://webaudio.github.io/web-audio-api/#dom-audiocontext-close
fn Close(&self, comp: InCompartment) -> Rc<Promise> {
fn Close(&self, comp: InRealm) -> Rc<Promise> {
// Step 1.
let promise = Promise::new_in_current_compartment(&self.global(), comp);
let promise = Promise::new_in_current_realm(&self.global(), comp);

// Step 2.
if self.context.control_thread_state() == ProcessingState::Closed {
Expand Down
10 changes: 5 additions & 5 deletions components/script/dom/baseaudiocontext.rs
Expand Up @@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use crate::compartments::InCompartment;
use crate::dom::analysernode::AnalyserNode;
use crate::dom::audiobuffer::AudioBuffer;
use crate::dom::audiobuffersourcenode::AudioBufferSourceNode;
Expand Down Expand Up @@ -47,6 +46,7 @@ use crate::dom::pannernode::PannerNode;
use crate::dom::promise::Promise;
use crate::dom::stereopannernode::StereoPannerNode;
use crate::dom::window::Window;
use crate::realms::InRealm;
use crate::task_source::TaskSource;
use dom_struct::dom_struct;
use js::rust::CustomAutoRooterGuard;
Expand Down Expand Up @@ -282,9 +282,9 @@ impl BaseAudioContextMethods for BaseAudioContext {
}

/// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-resume
fn Resume(&self, comp: InCompartment) -> Rc<Promise> {
fn Resume(&self, comp: InRealm) -> Rc<Promise> {
// Step 1.
let promise = Promise::new_in_current_compartment(&self.global(), comp);
let promise = Promise::new_in_current_realm(&self.global(), comp);

// Step 2.
if self.audio_context_impl.lock().unwrap().state() == ProcessingState::Closed {
Expand Down Expand Up @@ -437,10 +437,10 @@ impl BaseAudioContextMethods for BaseAudioContext {
audio_data: CustomAutoRooterGuard<ArrayBuffer>,
decode_success_callback: Option<Rc<DecodeSuccessCallback>>,
decode_error_callback: Option<Rc<DecodeErrorCallback>>,
comp: InCompartment,
comp: InRealm,
) -> Rc<Promise> {
// Step 1.
let promise = Promise::new_in_current_compartment(&self.global(), comp);
let promise = Promise::new_in_current_realm(&self.global(), comp);
let global = self.global();
let window = global.as_window();

Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/bindings/callback.rs
Expand Up @@ -205,7 +205,7 @@ impl CallbackInterface {
}
}

/// Wraps the reflector for `p` into the compartment of `cx`.
/// Wraps the reflector for `p` into the realm of `cx`.
pub fn wrap_call_this_object<T: DomObject>(cx: JSContext, p: &T, mut rval: MutableHandleObject) {
rval.set(p.reflector().get_jsobject().get());
assert!(!rval.get().is_null());
Expand All @@ -225,7 +225,7 @@ pub struct CallSetup {
exception_global: DomRoot<GlobalScope>,
/// The `JSContext` used for the call.
cx: JSContext,
/// The compartment we were in before the call.
/// The realm we were in before the call.
old_realm: *mut Realm,
/// The exception handling used for the call.
handling: ExceptionHandling,
Expand Down
50 changes: 25 additions & 25 deletions components/script/dom/bindings/codegen/Bindings.conf
Expand Up @@ -44,7 +44,7 @@ DOMInterfaces = {

#FIXME(jdm): This should be 'register': False, but then we don't generate enum types
'TestBinding': {
'inCompartments': ['PromiseAttribute', 'PromiseNativeHandler'],
'inRealms': ['PromiseAttribute', 'PromiseNativeHandler'],
},

'URL': {
Expand All @@ -57,99 +57,99 @@ DOMInterfaces = {
},

'Window': {
'inCompartments': ['Fetch'],
'inRealms': ['Fetch'],
},

'WorkerGlobalScope': {
'inCompartments': ['Fetch'],
'inRealms': ['Fetch'],
},

'CustomElementRegistry': {
'inCompartments': ['WhenDefined'],
'inRealms': ['WhenDefined'],
},

'AudioContext': {
'inCompartments': ['Suspend', 'Close'],
'inRealms': ['Suspend', 'Close'],
},

'NavigationPreloadManager': {
'inCompartments': ['Enable', 'Disable', 'SetHeaderValue', 'GetState'],
'inRealms': ['Enable', 'Disable', 'SetHeaderValue', 'GetState'],
},

'HTMLMediaElement': {
'inCompartments': ['Play'],
'inRealms': ['Play'],
},

'BluetoothRemoteGATTDescriptor': {
'inCompartments': ['ReadValue', 'WriteValue'],
'inRealms': ['ReadValue', 'WriteValue'],
},

'OfflineAudioContext': {
'inCompartments': ['StartRendering'],
'inRealms': ['StartRendering'],
},

'BluetoothRemoteGATTServer': {
'inCompartments': ['Connect'],
'inRealms': ['Connect'],
},

'ServiceWorkerContainer': {
'inCompartments': ['Register'],
'inRealms': ['Register'],
},

'Navigator': {
'inCompartments': ['GetVRDisplays'],
'inRealms': ['GetVRDisplays'],
},

'MediaDevices': {
'inCompartments': ['GetUserMedia'],
'inRealms': ['GetUserMedia'],
},

'XRSession': {
'inCompartments': ['UpdateRenderState', 'RequestReferenceSpace'],
'inRealms': ['UpdateRenderState', 'RequestReferenceSpace'],
},

'Bluetooth': {
'inCompartments': ['RequestDevice', 'GetAvailability'],
'inRealms': ['RequestDevice', 'GetAvailability'],
},

'BaseAudioContext': {
'inCompartments': ['Resume', 'DecodeAudioData'],
'inRealms': ['Resume', 'DecodeAudioData'],
},

'RTCPeerConnection': {
'inCompartments': ['AddIceCandidate', 'CreateOffer', 'CreateAnswer', 'SetLocalDescription', 'SetRemoteDescription'],
'inRealms': ['AddIceCandidate', 'CreateOffer', 'CreateAnswer', 'SetLocalDescription', 'SetRemoteDescription'],
},

'BluetoothRemoteGATTCharacteristic': {
'inCompartments': ['ReadValue', 'WriteValue', 'StartNotifications', 'StopNotifications'],
'inRealms': ['ReadValue', 'WriteValue', 'StartNotifications', 'StopNotifications'],
},

'VRDisplay': {
'inCompartments': ['RequestPresent', 'ExitPresent'],
'inRealms': ['RequestPresent', 'ExitPresent'],
},

'Worklet': {
'inCompartments': ['AddModule'],
'inRealms': ['AddModule'],
},

'TestWorklet': {
'inCompartments': ['AddModule'],
'inRealms': ['AddModule'],
},

'BluetoothDevice': {
'inCompartments': ['WatchAdvertisements'],
'inRealms': ['WatchAdvertisements'],
},

'XR': {
'inCompartments': ['SupportsSessionMode', 'RequestSession'],
'inRealms': ['SupportsSessionMode', 'RequestSession'],
},

'GPU': {
'inCompartments': ['RequestAdapter'],
'inRealms': ['RequestAdapter'],
},

'GPUAdapter': {
'inCompartments': ['RequestDevice'],
'inRealms': ['RequestDevice'],
}

}

0 comments on commit 5a3e1b8

Please sign in to comment.