mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Remove global argument from Promise::new_in_current_realm.
This commit is contained in:
parent
f79e1e327d
commit
fca5833e21
30 changed files with 54 additions and 56 deletions
|
@ -721,7 +721,7 @@ pub fn consume_body<T: BodyMixin + DomObject>(object: &T, body_type: BodyType) -
|
||||||
let global = object.global();
|
let global = object.global();
|
||||||
let in_realm_proof = AlreadyInRealm::assert(&global);
|
let in_realm_proof = AlreadyInRealm::assert(&global);
|
||||||
let promise =
|
let promise =
|
||||||
Promise::new_in_current_realm(&object.global(), InRealm::Already(&in_realm_proof));
|
Promise::new_in_current_realm(InRealm::Already(&in_realm_proof));
|
||||||
|
|
||||||
// Step 1
|
// Step 1
|
||||||
if object.is_disturbed() || object.is_locked() {
|
if object.is_disturbed() || object.is_locked() {
|
||||||
|
|
|
@ -132,7 +132,7 @@ impl AudioContextMethods for AudioContext {
|
||||||
// https://webaudio.github.io/web-audio-api/#dom-audiocontext-suspend
|
// https://webaudio.github.io/web-audio-api/#dom-audiocontext-suspend
|
||||||
fn Suspend(&self, comp: InRealm) -> Rc<Promise> {
|
fn Suspend(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let promise = Promise::new_in_current_realm(&self.global(), comp);
|
let promise = Promise::new_in_current_realm(comp);
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
if self.context.control_thread_state() == ProcessingState::Closed {
|
if self.context.control_thread_state() == ProcessingState::Closed {
|
||||||
|
@ -193,7 +193,7 @@ impl AudioContextMethods for AudioContext {
|
||||||
// https://webaudio.github.io/web-audio-api/#dom-audiocontext-close
|
// https://webaudio.github.io/web-audio-api/#dom-audiocontext-close
|
||||||
fn Close(&self, comp: InRealm) -> Rc<Promise> {
|
fn Close(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let promise = Promise::new_in_current_realm(&self.global(), comp);
|
let promise = Promise::new_in_current_realm(comp);
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
if self.context.control_thread_state() == ProcessingState::Closed {
|
if self.context.control_thread_state() == ProcessingState::Closed {
|
||||||
|
|
|
@ -284,7 +284,7 @@ impl BaseAudioContextMethods for BaseAudioContext {
|
||||||
/// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-resume
|
/// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-resume
|
||||||
fn Resume(&self, comp: InRealm) -> Rc<Promise> {
|
fn Resume(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let promise = Promise::new_in_current_realm(&self.global(), comp);
|
let promise = Promise::new_in_current_realm(comp);
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
if self.audio_context_impl.lock().unwrap().state() == ProcessingState::Closed {
|
if self.audio_context_impl.lock().unwrap().state() == ProcessingState::Closed {
|
||||||
|
@ -440,7 +440,7 @@ impl BaseAudioContextMethods for BaseAudioContext {
|
||||||
comp: InRealm,
|
comp: InRealm,
|
||||||
) -> Rc<Promise> {
|
) -> Rc<Promise> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let promise = Promise::new_in_current_realm(&self.global(), comp);
|
let promise = Promise::new_in_current_realm(comp);
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
let window = global.as_window();
|
let window = global.as_window();
|
||||||
|
|
||||||
|
|
|
@ -239,7 +239,7 @@ impl BlobMethods for Blob {
|
||||||
fn Text(&self) -> Rc<Promise> {
|
fn Text(&self) -> Rc<Promise> {
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
let in_realm_proof = AlreadyInRealm::assert(&global);
|
let in_realm_proof = AlreadyInRealm::assert(&global);
|
||||||
let p = Promise::new_in_current_realm(&global, InRealm::Already(&in_realm_proof));
|
let p = Promise::new_in_current_realm(InRealm::Already(&in_realm_proof));
|
||||||
let id = self.get_blob_url_id();
|
let id = self.get_blob_url_id();
|
||||||
global.read_file_async(
|
global.read_file_async(
|
||||||
id,
|
id,
|
||||||
|
@ -262,7 +262,7 @@ impl BlobMethods for Blob {
|
||||||
fn ArrayBuffer(&self) -> Rc<Promise> {
|
fn ArrayBuffer(&self) -> Rc<Promise> {
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
let in_realm_proof = AlreadyInRealm::assert(&global);
|
let in_realm_proof = AlreadyInRealm::assert(&global);
|
||||||
let p = Promise::new_in_current_realm(&global, InRealm::Already(&in_realm_proof));
|
let p = Promise::new_in_current_realm(InRealm::Already(&in_realm_proof));
|
||||||
|
|
||||||
let id = self.get_blob_url_id();
|
let id = self.get_blob_url_id();
|
||||||
|
|
||||||
|
|
|
@ -288,7 +288,7 @@ where
|
||||||
F: FnOnce(StringOrUnsignedLong) -> Fallible<UUID>,
|
F: FnOnce(StringOrUnsignedLong) -> Fallible<UUID>,
|
||||||
{
|
{
|
||||||
let in_realm_proof = AlreadyInRealm::assert(&attribute.global());
|
let in_realm_proof = AlreadyInRealm::assert(&attribute.global());
|
||||||
let p = Promise::new_in_current_realm(&attribute.global(), InRealm::Already(&in_realm_proof));
|
let p = Promise::new_in_current_realm(InRealm::Already(&in_realm_proof));
|
||||||
|
|
||||||
let result_uuid = if let Some(u) = uuid {
|
let result_uuid = if let Some(u) = uuid {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
|
@ -528,7 +528,7 @@ impl From<BluetoothError> for Error {
|
||||||
impl BluetoothMethods for Bluetooth {
|
impl BluetoothMethods for Bluetooth {
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice
|
||||||
fn RequestDevice(&self, option: &RequestDeviceOptions, comp: InRealm) -> Rc<Promise> {
|
fn RequestDevice(&self, option: &RequestDeviceOptions, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_realm(&self.global(), comp);
|
let p = Promise::new_in_current_realm(comp);
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if (option.filters.is_some() && option.acceptAllDevices) ||
|
if (option.filters.is_some() && option.acceptAllDevices) ||
|
||||||
(option.filters.is_none() && !option.acceptAllDevices)
|
(option.filters.is_none() && !option.acceptAllDevices)
|
||||||
|
@ -546,7 +546,7 @@ impl BluetoothMethods for Bluetooth {
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-getavailability
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-getavailability
|
||||||
fn GetAvailability(&self, comp: InRealm) -> Rc<Promise> {
|
fn GetAvailability(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_realm(&self.global(), comp);
|
let p = Promise::new_in_current_realm(comp);
|
||||||
// Step 1. We did not override the method
|
// Step 1. We did not override the method
|
||||||
// Step 2 - 3. in handle_response
|
// Step 2 - 3. in handle_response
|
||||||
let sender = response_async(&p, self);
|
let sender = response_async(&p, self);
|
||||||
|
|
|
@ -277,7 +277,7 @@ impl BluetoothDeviceMethods for BluetoothDevice {
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-watchadvertisements
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-watchadvertisements
|
||||||
fn WatchAdvertisements(&self, comp: InRealm) -> Rc<Promise> {
|
fn WatchAdvertisements(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_realm(&self.global(), comp);
|
let p = Promise::new_in_current_realm(comp);
|
||||||
let sender = response_async(&p, self);
|
let sender = response_async(&p, self);
|
||||||
// TODO: Step 1.
|
// TODO: Step 1.
|
||||||
// Note: Steps 2 - 3 are implemented in components/bluetooth/lib.rs in watch_advertisements function
|
// Note: Steps 2 - 3 are implemented in components/bluetooth/lib.rs in watch_advertisements function
|
||||||
|
|
|
@ -137,7 +137,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-readvalue
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-readvalue
|
||||||
fn ReadValue(&self, comp: InRealm) -> Rc<Promise> {
|
fn ReadValue(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_realm(&self.global(), comp);
|
let p = Promise::new_in_current_realm(comp);
|
||||||
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Reads) {
|
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Reads) {
|
||||||
|
@ -170,7 +170,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-writevalue
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-writevalue
|
||||||
fn WriteValue(&self, value: ArrayBufferViewOrArrayBuffer, comp: InRealm) -> Rc<Promise> {
|
fn WriteValue(&self, value: ArrayBufferViewOrArrayBuffer, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_realm(&self.global(), comp);
|
let p = Promise::new_in_current_realm(comp);
|
||||||
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Writes) {
|
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Writes) {
|
||||||
|
@ -221,7 +221,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-startnotifications
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-startnotifications
|
||||||
fn StartNotifications(&self, comp: InRealm) -> Rc<Promise> {
|
fn StartNotifications(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_realm(&self.global(), comp);
|
let p = Promise::new_in_current_realm(comp);
|
||||||
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Reads) {
|
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Reads) {
|
||||||
|
@ -258,7 +258,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-stopnotifications
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-stopnotifications
|
||||||
fn StopNotifications(&self, comp: InRealm) -> Rc<Promise> {
|
fn StopNotifications(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_realm(&self.global(), comp);
|
let p = Promise::new_in_current_realm(comp);
|
||||||
let sender = response_async(&p, self);
|
let sender = response_async(&p, self);
|
||||||
|
|
||||||
// TODO: Step 3 - 4: Implement `active notification context set` for BluetoothRemoteGATTCharacteristic,
|
// TODO: Step 3 - 4: Implement `active notification context set` for BluetoothRemoteGATTCharacteristic,
|
||||||
|
|
|
@ -93,7 +93,7 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-readvalue
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-readvalue
|
||||||
fn ReadValue(&self, comp: InRealm) -> Rc<Promise> {
|
fn ReadValue(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_realm(&self.global(), comp);
|
let p = Promise::new_in_current_realm(comp);
|
||||||
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Reads) {
|
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Reads) {
|
||||||
|
@ -125,7 +125,7 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-writevalue
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-writevalue
|
||||||
fn WriteValue(&self, value: ArrayBufferViewOrArrayBuffer, comp: InRealm) -> Rc<Promise> {
|
fn WriteValue(&self, value: ArrayBufferViewOrArrayBuffer, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_realm(&self.global(), comp);
|
let p = Promise::new_in_current_realm(comp);
|
||||||
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Writes) {
|
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Writes) {
|
||||||
|
|
|
@ -71,7 +71,7 @@ impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer {
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn Connect(&self, comp: InRealm) -> Rc<Promise> {
|
fn Connect(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let p = Promise::new_in_current_realm(&self.global(), comp);
|
let p = Promise::new_in_current_realm(comp);
|
||||||
let sender = response_async(&p, self);
|
let sender = response_async(&p, self);
|
||||||
|
|
||||||
// TODO: Step 3: Check if the UA is currently using the Bluetooth system.
|
// TODO: Step 3: Check if the UA is currently using the Bluetooth system.
|
||||||
|
|
|
@ -428,7 +428,7 @@ impl CustomElementRegistryMethods for CustomElementRegistry {
|
||||||
|
|
||||||
// Step 1
|
// Step 1
|
||||||
if !is_valid_custom_element_name(&name) {
|
if !is_valid_custom_element_name(&name) {
|
||||||
let promise = Promise::new_in_current_realm(&global_scope, comp);
|
let promise = Promise::new_in_current_realm(comp);
|
||||||
promise.reject_native(&DOMException::new(&global_scope, DOMErrorName::SyntaxError));
|
promise.reject_native(&DOMException::new(&global_scope, DOMErrorName::SyntaxError));
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
@ -441,7 +441,7 @@ impl CustomElementRegistryMethods for CustomElementRegistry {
|
||||||
definition
|
definition
|
||||||
.constructor
|
.constructor
|
||||||
.to_jsval(*cx, constructor.handle_mut());
|
.to_jsval(*cx, constructor.handle_mut());
|
||||||
let promise = Promise::new_in_current_realm(&global_scope, comp);
|
let promise = Promise::new_in_current_realm(comp);
|
||||||
promise.resolve_native(&constructor.get());
|
promise.resolve_native(&constructor.get());
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
@ -452,7 +452,7 @@ impl CustomElementRegistryMethods for CustomElementRegistry {
|
||||||
|
|
||||||
// Steps 4, 5
|
// Steps 4, 5
|
||||||
let promise = map.get(&name).cloned().unwrap_or_else(|| {
|
let promise = map.get(&name).cloned().unwrap_or_else(|| {
|
||||||
let promise = Promise::new_in_current_realm(&global_scope, comp);
|
let promise = Promise::new_in_current_realm(comp);
|
||||||
map.insert(name, promise.clone());
|
map.insert(name, promise.clone());
|
||||||
promise
|
promise
|
||||||
});
|
});
|
||||||
|
|
|
@ -3575,7 +3575,7 @@ impl Document {
|
||||||
// Step 1
|
// Step 1
|
||||||
let in_realm_proof = AlreadyInRealm::assert(&self.global());
|
let in_realm_proof = AlreadyInRealm::assert(&self.global());
|
||||||
let promise =
|
let promise =
|
||||||
Promise::new_in_current_realm(&self.global(), InRealm::Already(&in_realm_proof));
|
Promise::new_in_current_realm(InRealm::Already(&in_realm_proof));
|
||||||
let mut error = false;
|
let mut error = false;
|
||||||
|
|
||||||
// Step 4
|
// Step 4
|
||||||
|
@ -3643,7 +3643,7 @@ impl Document {
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
// Step 1
|
// Step 1
|
||||||
let in_realm_proof = AlreadyInRealm::assert(&global);
|
let in_realm_proof = AlreadyInRealm::assert(&global);
|
||||||
let promise = Promise::new_in_current_realm(&global, InRealm::Already(&in_realm_proof));
|
let promise = Promise::new_in_current_realm(InRealm::Already(&in_realm_proof));
|
||||||
// Step 2
|
// Step 2
|
||||||
if self.fullscreen_element.get().is_none() {
|
if self.fullscreen_element.get().is_none() {
|
||||||
promise.reject_error(Error::Type(String::from("fullscreen is null")));
|
promise.reject_error(Error::Type(String::from("fullscreen is null")));
|
||||||
|
|
|
@ -2734,7 +2734,7 @@ impl GlobalScope {
|
||||||
options: &ImageBitmapOptions,
|
options: &ImageBitmapOptions,
|
||||||
) -> Rc<Promise> {
|
) -> Rc<Promise> {
|
||||||
let in_realm_proof = AlreadyInRealm::assert(&self);
|
let in_realm_proof = AlreadyInRealm::assert(&self);
|
||||||
let p = Promise::new_in_current_realm(&self, InRealm::Already(&in_realm_proof));
|
let p = Promise::new_in_current_realm(InRealm::Already(&in_realm_proof));
|
||||||
if options.resizeWidth.map_or(false, |w| w == 0) {
|
if options.resizeWidth.map_or(false, |w| w == 0) {
|
||||||
p.reject_error(Error::InvalidState);
|
p.reject_error(Error::InvalidState);
|
||||||
return p;
|
return p;
|
||||||
|
|
|
@ -100,7 +100,7 @@ impl GPUMethods for GPU {
|
||||||
// https://gpuweb.github.io/gpuweb/#dom-gpu-requestadapter
|
// https://gpuweb.github.io/gpuweb/#dom-gpu-requestadapter
|
||||||
fn RequestAdapter(&self, options: &GPURequestAdapterOptions, comp: InRealm) -> Rc<Promise> {
|
fn RequestAdapter(&self, options: &GPURequestAdapterOptions, comp: InRealm) -> Rc<Promise> {
|
||||||
let global = &self.global();
|
let global = &self.global();
|
||||||
let promise = Promise::new_in_current_realm(global, comp);
|
let promise = Promise::new_in_current_realm(comp);
|
||||||
let sender = response_async(&promise, self);
|
let sender = response_async(&promise, self);
|
||||||
let power_preference = match options.powerPreference {
|
let power_preference = match options.powerPreference {
|
||||||
Some(GPUPowerPreference::Low_power) => PowerPreference::LowPower,
|
Some(GPUPowerPreference::Low_power) => PowerPreference::LowPower,
|
||||||
|
|
|
@ -78,7 +78,7 @@ impl GPUAdapterMethods for GPUAdapter {
|
||||||
|
|
||||||
/// https://gpuweb.github.io/gpuweb/#dom-gpuadapter-requestdevice
|
/// https://gpuweb.github.io/gpuweb/#dom-gpuadapter-requestdevice
|
||||||
fn RequestDevice(&self, descriptor: &GPUDeviceDescriptor, comp: InRealm) -> Rc<Promise> {
|
fn RequestDevice(&self, descriptor: &GPUDeviceDescriptor, comp: InRealm) -> Rc<Promise> {
|
||||||
let promise = Promise::new_in_current_realm(&self.global(), comp);
|
let promise = Promise::new_in_current_realm(comp);
|
||||||
let sender = response_async(&promise, self);
|
let sender = response_async(&promise, self);
|
||||||
let mut features = wgt::Features::empty();
|
let mut features = wgt::Features::empty();
|
||||||
for &ext in descriptor.extensions.iter() {
|
for &ext in descriptor.extensions.iter() {
|
||||||
|
|
|
@ -6,7 +6,6 @@ use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::GPUBufferBinding::{GPUBufferMethods, GPUSize64};
|
use crate::dom::bindings::codegen::Bindings::GPUBufferBinding::{GPUBufferMethods, GPUSize64};
|
||||||
use crate::dom::bindings::codegen::Bindings::GPUMapModeBinding::GPUMapModeConstants;
|
use crate::dom::bindings::codegen::Bindings::GPUMapModeBinding::GPUMapModeConstants;
|
||||||
use crate::dom::bindings::error::{Error, Fallible};
|
use crate::dom::bindings::error::{Error, Fallible};
|
||||||
use crate::dom::bindings::reflector::DomObject;
|
|
||||||
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||||
use crate::dom::bindings::str::USVString;
|
use crate::dom::bindings::str::USVString;
|
||||||
|
@ -209,7 +208,7 @@ impl GPUBufferMethods for GPUBuffer {
|
||||||
size: Option<GPUSize64>,
|
size: Option<GPUSize64>,
|
||||||
comp: InRealm,
|
comp: InRealm,
|
||||||
) -> Rc<Promise> {
|
) -> Rc<Promise> {
|
||||||
let promise = Promise::new_in_current_realm(&self.global(), comp);
|
let promise = Promise::new_in_current_realm(comp);
|
||||||
let range_size = if let Some(s) = size {
|
let range_size = if let Some(s) = size {
|
||||||
s
|
s
|
||||||
} else if offset >= self.size {
|
} else if offset >= self.size {
|
||||||
|
|
|
@ -357,7 +357,7 @@ impl GPUDeviceMethods for GPUDevice {
|
||||||
|
|
||||||
/// https://gpuweb.github.io/gpuweb/#dom-gpudevice-lost
|
/// https://gpuweb.github.io/gpuweb/#dom-gpudevice-lost
|
||||||
fn Lost(&self, comp: InRealm) -> Rc<Promise> {
|
fn Lost(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let promise = Promise::new_in_current_realm(&self.global(), comp);
|
let promise = Promise::new_in_current_realm(comp);
|
||||||
*self.lost_promise.borrow_mut() = Some(promise.clone());
|
*self.lost_promise.borrow_mut() = Some(promise.clone());
|
||||||
promise
|
promise
|
||||||
}
|
}
|
||||||
|
@ -1117,7 +1117,7 @@ impl GPUDeviceMethods for GPUDevice {
|
||||||
/// https://gpuweb.github.io/gpuweb/#dom-gpudevice-poperrorscope
|
/// https://gpuweb.github.io/gpuweb/#dom-gpudevice-poperrorscope
|
||||||
fn PopErrorScope(&self, comp: InRealm) -> Rc<Promise> {
|
fn PopErrorScope(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let mut context = self.scope_context.borrow_mut();
|
let mut context = self.scope_context.borrow_mut();
|
||||||
let promise = Promise::new_in_current_realm(&self.global(), comp);
|
let promise = Promise::new_in_current_realm(comp);
|
||||||
let scope_id =
|
let scope_id =
|
||||||
if let Some(meta) = context.scope_stack.iter().rev().find(|m| !m.popped.get()) {
|
if let Some(meta) = context.scope_stack.iter().rev().find(|m| !m.popped.get()) {
|
||||||
meta.popped.set(true);
|
meta.popped.set(true);
|
||||||
|
|
|
@ -2112,7 +2112,7 @@ impl HTMLMediaElementMethods for HTMLMediaElement {
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-media-play
|
// https://html.spec.whatwg.org/multipage/#dom-media-play
|
||||||
fn Play(&self, comp: InRealm) -> Rc<Promise> {
|
fn Play(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let promise = Promise::new_in_current_realm(&self.global(), comp);
|
let promise = Promise::new_in_current_realm(comp);
|
||||||
// Step 1.
|
// Step 1.
|
||||||
// FIXME(nox): Reject promise if not allowed to play.
|
// FIXME(nox): Reject promise if not allowed to play.
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ impl MediaDevicesMethods for MediaDevices {
|
||||||
/// https://w3c.github.io/mediacapture-main/#dom-mediadevices-getusermedia
|
/// https://w3c.github.io/mediacapture-main/#dom-mediadevices-getusermedia
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn GetUserMedia(&self, constraints: &MediaStreamConstraints, comp: InRealm) -> Rc<Promise> {
|
fn GetUserMedia(&self, constraints: &MediaStreamConstraints, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_realm(&self.global(), comp);
|
let p = Promise::new_in_current_realm(comp);
|
||||||
let media = ServoMedia::get().unwrap();
|
let media = ServoMedia::get().unwrap();
|
||||||
let stream = MediaStream::new(&self.global());
|
let stream = MediaStream::new(&self.global());
|
||||||
if let Some(constraints) = convert_constraints(&constraints.audio) {
|
if let Some(constraints) = convert_constraints(&constraints.audio) {
|
||||||
|
@ -69,7 +69,7 @@ impl MediaDevicesMethods for MediaDevices {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
let in_realm_proof = AlreadyInRealm::assert(&global);
|
let in_realm_proof = AlreadyInRealm::assert(&global);
|
||||||
let p = Promise::new_in_current_realm(&global, InRealm::Already(&in_realm_proof));
|
let p = Promise::new_in_current_realm(InRealm::Already(&in_realm_proof));
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
// XXX These steps should be run in parallel.
|
// XXX These steps should be run in parallel.
|
||||||
|
|
|
@ -43,7 +43,7 @@ impl NavigationPreloadManager {
|
||||||
impl NavigationPreloadManagerMethods for NavigationPreloadManager {
|
impl NavigationPreloadManagerMethods for NavigationPreloadManager {
|
||||||
// https://w3c.github.io/ServiceWorker/#navigation-preload-manager-enable
|
// https://w3c.github.io/ServiceWorker/#navigation-preload-manager-enable
|
||||||
fn Enable(&self, comp: InRealm) -> Rc<Promise> {
|
fn Enable(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let promise = Promise::new_in_current_realm(&*self.global(), comp);
|
let promise = Promise::new_in_current_realm(comp);
|
||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
if self.serviceworker_registration.is_active() {
|
if self.serviceworker_registration.is_active() {
|
||||||
|
@ -65,7 +65,7 @@ impl NavigationPreloadManagerMethods for NavigationPreloadManager {
|
||||||
|
|
||||||
// https://w3c.github.io/ServiceWorker/#navigation-preload-manager-disable
|
// https://w3c.github.io/ServiceWorker/#navigation-preload-manager-disable
|
||||||
fn Disable(&self, comp: InRealm) -> Rc<Promise> {
|
fn Disable(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let promise = Promise::new_in_current_realm(&*self.global(), comp);
|
let promise = Promise::new_in_current_realm(comp);
|
||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
if self.serviceworker_registration.is_active() {
|
if self.serviceworker_registration.is_active() {
|
||||||
|
@ -87,7 +87,7 @@ impl NavigationPreloadManagerMethods for NavigationPreloadManager {
|
||||||
|
|
||||||
// https://w3c.github.io/ServiceWorker/#navigation-preload-manager-setheadervalue
|
// https://w3c.github.io/ServiceWorker/#navigation-preload-manager-setheadervalue
|
||||||
fn SetHeaderValue(&self, value: ByteString, comp: InRealm) -> Rc<Promise> {
|
fn SetHeaderValue(&self, value: ByteString, comp: InRealm) -> Rc<Promise> {
|
||||||
let promise = Promise::new_in_current_realm(&*self.global(), comp);
|
let promise = Promise::new_in_current_realm(comp);
|
||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
if self.serviceworker_registration.is_active() {
|
if self.serviceworker_registration.is_active() {
|
||||||
|
@ -109,7 +109,7 @@ impl NavigationPreloadManagerMethods for NavigationPreloadManager {
|
||||||
|
|
||||||
// https://w3c.github.io/ServiceWorker/#navigation-preload-manager-getstate
|
// https://w3c.github.io/ServiceWorker/#navigation-preload-manager-getstate
|
||||||
fn GetState(&self, comp: InRealm) -> Rc<Promise> {
|
fn GetState(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let promise = Promise::new_in_current_realm(&*self.global(), comp);
|
let promise = Promise::new_in_current_realm(comp);
|
||||||
// 2.
|
// 2.
|
||||||
let mut state = NavigationPreloadState::empty();
|
let mut state = NavigationPreloadState::empty();
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ impl OfflineAudioContextMethods for OfflineAudioContext {
|
||||||
|
|
||||||
// https://webaudio.github.io/web-audio-api/#dom-offlineaudiocontext-startrendering
|
// https://webaudio.github.io/web-audio-api/#dom-offlineaudiocontext-startrendering
|
||||||
fn StartRendering(&self, comp: InRealm) -> Rc<Promise> {
|
fn StartRendering(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let promise = Promise::new_in_current_realm(&self.global(), comp);
|
let promise = Promise::new_in_current_realm(comp);
|
||||||
if self.rendering_started.get() {
|
if self.rendering_started.get() {
|
||||||
promise.reject_error(Error::InvalidState);
|
promise.reject_error(Error::InvalidState);
|
||||||
return promise;
|
return promise;
|
||||||
|
|
|
@ -88,7 +88,7 @@ impl Permissions {
|
||||||
Some(promise) => promise,
|
Some(promise) => promise,
|
||||||
None => {
|
None => {
|
||||||
let in_realm_proof = AlreadyInRealm::assert(&self.global());
|
let in_realm_proof = AlreadyInRealm::assert(&self.global());
|
||||||
Promise::new_in_current_realm(&self.global(), InRealm::Already(&in_realm_proof))
|
Promise::new_in_current_realm(InRealm::Already(&in_realm_proof))
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -88,10 +88,10 @@ impl Promise {
|
||||||
pub fn new(global: &GlobalScope) -> Rc<Promise> {
|
pub fn new(global: &GlobalScope) -> Rc<Promise> {
|
||||||
let realm = enter_realm(&*global);
|
let realm = enter_realm(&*global);
|
||||||
let comp = InRealm::Entered(&realm);
|
let comp = InRealm::Entered(&realm);
|
||||||
Promise::new_in_current_realm(global, comp)
|
Promise::new_in_current_realm(comp)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_in_current_realm(_global: &GlobalScope, _comp: InRealm) -> Rc<Promise> {
|
pub fn new_in_current_realm(_comp: InRealm) -> Rc<Promise> {
|
||||||
let cx = GlobalScope::get_cx();
|
let cx = GlobalScope::get_cx();
|
||||||
rooted!(in(*cx) let mut obj = ptr::null_mut::<JSObject>());
|
rooted!(in(*cx) let mut obj = ptr::null_mut::<JSObject>());
|
||||||
Promise::create_js_promise(cx, obj.handle_mut());
|
Promise::create_js_promise(cx, obj.handle_mut());
|
||||||
|
|
|
@ -548,7 +548,7 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
|
||||||
|
|
||||||
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addicecandidate
|
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addicecandidate
|
||||||
fn AddIceCandidate(&self, candidate: &RTCIceCandidateInit, comp: InRealm) -> Rc<Promise> {
|
fn AddIceCandidate(&self, candidate: &RTCIceCandidateInit, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_realm(&self.global(), comp);
|
let p = Promise::new_in_current_realm(comp);
|
||||||
if candidate.sdpMid.is_none() && candidate.sdpMLineIndex.is_none() {
|
if candidate.sdpMid.is_none() && candidate.sdpMLineIndex.is_none() {
|
||||||
p.reject_error(Error::Type(format!(
|
p.reject_error(Error::Type(format!(
|
||||||
"one of sdpMid and sdpMLineIndex must be set"
|
"one of sdpMid and sdpMLineIndex must be set"
|
||||||
|
@ -583,7 +583,7 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
|
||||||
|
|
||||||
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-createoffer
|
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-createoffer
|
||||||
fn CreateOffer(&self, _options: &RTCOfferOptions, comp: InRealm) -> Rc<Promise> {
|
fn CreateOffer(&self, _options: &RTCOfferOptions, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_realm(&self.global(), comp);
|
let p = Promise::new_in_current_realm(comp);
|
||||||
if self.closed.get() {
|
if self.closed.get() {
|
||||||
p.reject_error(Error::InvalidState);
|
p.reject_error(Error::InvalidState);
|
||||||
return p;
|
return p;
|
||||||
|
@ -595,7 +595,7 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
|
||||||
|
|
||||||
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-createoffer
|
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-createoffer
|
||||||
fn CreateAnswer(&self, _options: &RTCAnswerOptions, comp: InRealm) -> Rc<Promise> {
|
fn CreateAnswer(&self, _options: &RTCAnswerOptions, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_realm(&self.global(), comp);
|
let p = Promise::new_in_current_realm(comp);
|
||||||
if self.closed.get() {
|
if self.closed.get() {
|
||||||
p.reject_error(Error::InvalidState);
|
p.reject_error(Error::InvalidState);
|
||||||
return p;
|
return p;
|
||||||
|
@ -618,7 +618,7 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
|
||||||
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-setlocaldescription
|
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-setlocaldescription
|
||||||
fn SetLocalDescription(&self, desc: &RTCSessionDescriptionInit, comp: InRealm) -> Rc<Promise> {
|
fn SetLocalDescription(&self, desc: &RTCSessionDescriptionInit, comp: InRealm) -> Rc<Promise> {
|
||||||
// XXXManishearth validate the current state
|
// XXXManishearth validate the current state
|
||||||
let p = Promise::new_in_current_realm(&self.global(), comp);
|
let p = Promise::new_in_current_realm(comp);
|
||||||
let this = Trusted::new(self);
|
let this = Trusted::new(self);
|
||||||
let desc: SessionDescription = desc.into();
|
let desc: SessionDescription = desc.into();
|
||||||
let trusted_promise = TrustedPromise::new(p.clone());
|
let trusted_promise = TrustedPromise::new(p.clone());
|
||||||
|
@ -651,7 +651,7 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
|
||||||
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-setremotedescription
|
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-setremotedescription
|
||||||
fn SetRemoteDescription(&self, desc: &RTCSessionDescriptionInit, comp: InRealm) -> Rc<Promise> {
|
fn SetRemoteDescription(&self, desc: &RTCSessionDescriptionInit, comp: InRealm) -> Rc<Promise> {
|
||||||
// XXXManishearth validate the current state
|
// XXXManishearth validate the current state
|
||||||
let p = Promise::new_in_current_realm(&self.global(), comp);
|
let p = Promise::new_in_current_realm(comp);
|
||||||
let this = Trusted::new(self);
|
let this = Trusted::new(self);
|
||||||
let desc: SessionDescription = desc.into();
|
let desc: SessionDescription = desc.into();
|
||||||
let trusted_promise = TrustedPromise::new(p.clone());
|
let trusted_promise = TrustedPromise::new(p.clone());
|
||||||
|
|
|
@ -70,7 +70,7 @@ impl ServiceWorkerContainerMethods for ServiceWorkerContainer {
|
||||||
let global = self.client.global();
|
let global = self.client.global();
|
||||||
|
|
||||||
// A: Step 1
|
// A: Step 1
|
||||||
let promise = Promise::new_in_current_realm(&*global, comp);
|
let promise = Promise::new_in_current_realm(comp);
|
||||||
let USVString(ref script_url) = script_url;
|
let USVString(ref script_url) = script_url;
|
||||||
|
|
||||||
// A: Step 3
|
// A: Step 3
|
||||||
|
|
|
@ -1005,7 +1005,7 @@ impl TestBindingMethods for TestBinding {
|
||||||
resolve.map(SimpleHandler::new),
|
resolve.map(SimpleHandler::new),
|
||||||
reject.map(SimpleHandler::new),
|
reject.map(SimpleHandler::new),
|
||||||
);
|
);
|
||||||
let p = Promise::new_in_current_realm(&global, comp.clone());
|
let p = Promise::new_in_current_realm(comp.clone());
|
||||||
p.append_native_handler(&handler, comp);
|
p.append_native_handler(&handler, comp);
|
||||||
return p;
|
return p;
|
||||||
|
|
||||||
|
@ -1028,7 +1028,7 @@ impl TestBindingMethods for TestBinding {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn PromiseAttribute(&self, comp: InRealm) -> Rc<Promise> {
|
fn PromiseAttribute(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
Promise::new_in_current_realm(&self.global(), comp)
|
Promise::new_in_current_realm(comp)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn AcceptPromise(&self, _promise: &Promise) {}
|
fn AcceptPromise(&self, _promise: &Promise) {}
|
||||||
|
|
|
@ -130,8 +130,7 @@ impl WorkletMethods for Worklet {
|
||||||
comp: InRealm,
|
comp: InRealm,
|
||||||
) -> Rc<Promise> {
|
) -> Rc<Promise> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let global = self.window.upcast();
|
let promise = Promise::new_in_current_realm(comp);
|
||||||
let promise = Promise::new_in_current_realm(&global, comp);
|
|
||||||
|
|
||||||
// Step 3.
|
// Step 3.
|
||||||
let module_url_record = match self.window.Document().base_url().join(&module_url.0) {
|
let module_url_record = match self.window.Document().base_url().join(&module_url.0) {
|
||||||
|
|
|
@ -757,7 +757,7 @@ impl XRSessionMethods for XRSession {
|
||||||
|
|
||||||
/// https://immersive-web.github.io/webxr/#dom-xrsession-requestreferencespace
|
/// https://immersive-web.github.io/webxr/#dom-xrsession-requestreferencespace
|
||||||
fn RequestReferenceSpace(&self, ty: XRReferenceSpaceType, comp: InRealm) -> Rc<Promise> {
|
fn RequestReferenceSpace(&self, ty: XRReferenceSpaceType, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_realm(&self.global(), comp);
|
let p = Promise::new_in_current_realm(comp);
|
||||||
|
|
||||||
// https://immersive-web.github.io/webxr/#create-a-reference-space
|
// https://immersive-web.github.io/webxr/#create-a-reference-space
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,7 @@ impl XRSystemMethods for XRSystem {
|
||||||
) -> Rc<Promise> {
|
) -> Rc<Promise> {
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
let window = global.as_window();
|
let window = global.as_window();
|
||||||
let promise = Promise::new_in_current_realm(&global, comp);
|
let promise = Promise::new_in_current_realm(comp);
|
||||||
|
|
||||||
if mode != XRSessionMode::Inline {
|
if mode != XRSessionMode::Inline {
|
||||||
if !ScriptThread::is_user_interacting() {
|
if !ScriptThread::is_user_interacting() {
|
||||||
|
|
|
@ -142,7 +142,7 @@ pub fn Fetch(
|
||||||
let core_resource_thread = global.core_resource_thread();
|
let core_resource_thread = global.core_resource_thread();
|
||||||
|
|
||||||
// Step 1
|
// Step 1
|
||||||
let promise = Promise::new_in_current_realm(global, comp);
|
let promise = Promise::new_in_current_realm(comp);
|
||||||
let response = Response::new(global);
|
let response = Response::new(global);
|
||||||
|
|
||||||
// Step 2
|
// Step 2
|
||||||
|
|
|
@ -357,7 +357,7 @@ impl ModuleTree {
|
||||||
match promise.as_ref() {
|
match promise.as_ref() {
|
||||||
Some(promise) => promise.append_native_handler(&handler, comp),
|
Some(promise) => promise.append_native_handler(&handler, comp),
|
||||||
None => {
|
None => {
|
||||||
let new_promise = Promise::new_in_current_realm(&owner.global(), comp);
|
let new_promise = Promise::new_in_current_realm(comp);
|
||||||
new_promise.append_native_handler(&handler, comp);
|
new_promise.append_native_handler(&handler, comp);
|
||||||
*promise = Some(new_promise);
|
*promise = Some(new_promise);
|
||||||
},
|
},
|
||||||
|
@ -393,7 +393,7 @@ impl ModuleTree {
|
||||||
match promise.as_ref() {
|
match promise.as_ref() {
|
||||||
Some(promise) => promise.append_native_handler(&handler, comp),
|
Some(promise) => promise.append_native_handler(&handler, comp),
|
||||||
None => {
|
None => {
|
||||||
let new_promise = Promise::new_in_current_realm(&owner.global(), comp);
|
let new_promise = Promise::new_in_current_realm(comp);
|
||||||
new_promise.append_native_handler(&handler, comp);
|
new_promise.append_native_handler(&handler, comp);
|
||||||
*promise = Some(new_promise);
|
*promise = Some(new_promise);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue