Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename compartment to realm #25597

Merged
merged 1 commit into from Jan 24, 2020
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -377,9 +377,6 @@ mod gen {
slice_ms: i64,
},
low_frequency_heap_growth: i64,
per_compartment: {
enabled: bool,
},
per_zone: {
enabled: bool,
},
@@ -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};
@@ -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;
@@ -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() {
@@ -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;
@@ -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};
@@ -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::{
@@ -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;
@@ -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::{
@@ -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;
@@ -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 {
@@ -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 {
@@ -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;
@@ -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;
@@ -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 {
@@ -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();

@@ -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());
@@ -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,
@@ -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': {
@@ -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'],
}

}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.