mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Introduce Reflectable::global_scope
This commit is contained in:
parent
27f100b1d4
commit
ae6af5172b
30 changed files with 116 additions and 120 deletions
|
@ -98,13 +98,14 @@ fn run_package_data_algorithm<T: BodyOperations + Reflectable>(object: &T,
|
||||||
body_type: BodyType,
|
body_type: BodyType,
|
||||||
mime_type: Ref<Vec<u8>>)
|
mime_type: Ref<Vec<u8>>)
|
||||||
-> Fallible<FetchedData> {
|
-> Fallible<FetchedData> {
|
||||||
let cx = object.global().r().get_cx();
|
let global = object.global_scope();
|
||||||
|
let cx = global.get_cx();
|
||||||
let mime = &*mime_type;
|
let mime = &*mime_type;
|
||||||
match body_type {
|
match body_type {
|
||||||
BodyType::Text => run_text_data_algorithm(bytes),
|
BodyType::Text => run_text_data_algorithm(bytes),
|
||||||
BodyType::Json => run_json_data_algorithm(cx, bytes),
|
BodyType::Json => run_json_data_algorithm(cx, bytes),
|
||||||
BodyType::Blob => run_blob_data_algorithm(object.global().r().as_global_scope(), bytes, mime),
|
BodyType::Blob => run_blob_data_algorithm(&global, bytes, mime),
|
||||||
BodyType::FormData => run_form_data_algorithm(object.global().r().as_global_scope(), bytes, mime),
|
BodyType::FormData => run_form_data_algorithm(&global, bytes, mime),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -280,30 +280,44 @@ impl GlobalRoot {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the global scope of the realm that the given DOM object's reflector was created in.
|
||||||
|
pub fn global_scope_from_reflector<T: Reflectable>(reflector: &T) -> Root<GlobalScope> {
|
||||||
|
unsafe { global_scope_from_object(*reflector.reflector().get_jsobject()) }
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the global object of the realm that the given DOM object's reflector was created in.
|
/// Returns the global object of the realm that the given DOM object's reflector was created in.
|
||||||
pub fn global_root_from_reflector<T: Reflectable>(reflector: &T) -> GlobalRoot {
|
pub fn global_root_from_reflector<T: Reflectable>(reflector: &T) -> GlobalRoot {
|
||||||
unsafe { global_root_from_object(*reflector.reflector().get_jsobject()) }
|
unsafe { global_root_from_object(*reflector.reflector().get_jsobject()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the Rust global object from a JS global object.
|
/// Returns the Rust global scope from a JS global object.
|
||||||
#[allow(unrooted_must_root)]
|
unsafe fn global_scope_from_global(global: *mut JSObject) -> Root<GlobalScope> {
|
||||||
unsafe fn global_root_from_global(global: *mut JSObject) -> GlobalRoot {
|
|
||||||
assert!(!global.is_null());
|
assert!(!global.is_null());
|
||||||
let clasp = JS_GetClass(global);
|
let clasp = JS_GetClass(global);
|
||||||
assert!(((*clasp).flags & (JSCLASS_IS_DOMJSCLASS | JSCLASS_IS_GLOBAL)) != 0);
|
assert!(((*clasp).flags & (JSCLASS_IS_DOMJSCLASS | JSCLASS_IS_GLOBAL)) != 0);
|
||||||
match root_from_object(global) {
|
root_from_object(global).unwrap()
|
||||||
Ok(window) => return GlobalRoot::Window(window),
|
}
|
||||||
Err(_) => (),
|
|
||||||
}
|
|
||||||
|
|
||||||
match root_from_object(global) {
|
/// Returns the Rust global object from a JS global object.
|
||||||
Ok(worker) => return GlobalRoot::Worker(worker),
|
#[allow(unrooted_must_root)]
|
||||||
Err(_) => (),
|
unsafe fn global_root_from_global(global: *mut JSObject) -> GlobalRoot {
|
||||||
|
let global_scope = global_scope_from_global(global);
|
||||||
|
if let Some(window) = global_scope.downcast::<window::Window>() {
|
||||||
|
return GlobalRoot::Window(Root::from_ref(window));
|
||||||
|
}
|
||||||
|
if let Some(worker) = Root::downcast(global_scope) {
|
||||||
|
return GlobalRoot::Worker(worker);
|
||||||
}
|
}
|
||||||
|
|
||||||
panic!("found DOM global that doesn't unwrap to Window or WorkerGlobalScope")
|
panic!("found DOM global that doesn't unwrap to Window or WorkerGlobalScope")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the global scope of the realm that the given JS object was created in.
|
||||||
|
pub unsafe fn global_scope_from_object(obj: *mut JSObject) -> Root<GlobalScope> {
|
||||||
|
assert!(!obj.is_null());
|
||||||
|
let global = GetGlobalForObjectCrossCompartment(obj);
|
||||||
|
global_scope_from_global(global)
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the global object of the realm that the given JS object was created in.
|
/// Returns the global object of the realm that the given JS object was created in.
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub unsafe fn global_root_from_object(obj: *mut JSObject) -> GlobalRoot {
|
pub unsafe fn global_root_from_object(obj: *mut JSObject) -> GlobalRoot {
|
||||||
|
|
|
@ -93,8 +93,7 @@ impl<T: Reflectable + JSTraceable + Iterable> IterableIterator<T> {
|
||||||
iterable: JS::from_ref(iterable),
|
iterable: JS::from_ref(iterable),
|
||||||
index: Cell::new(0),
|
index: Cell::new(0),
|
||||||
};
|
};
|
||||||
let global = iterable.global();
|
reflect_dom_object(iterator, &*iterable.global_scope(), wrap)
|
||||||
reflect_dom_object(iterator, global.r().as_global_scope(), wrap)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the next value from the iterable object.
|
/// Return the next value from the iterable object.
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
//! The `Reflector` struct.
|
//! The `Reflector` struct.
|
||||||
|
|
||||||
use dom::bindings::conversions::DerivedFrom;
|
use dom::bindings::conversions::DerivedFrom;
|
||||||
use dom::bindings::global::{GlobalRoot, global_root_from_reflector};
|
use dom::bindings::global::{GlobalRoot, global_root_from_reflector, global_scope_from_reflector};
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use js::jsapi::{HandleObject, JSContext, JSObject};
|
use js::jsapi::{HandleObject, JSContext, JSObject};
|
||||||
|
@ -80,6 +80,11 @@ pub trait Reflectable {
|
||||||
/// Returns the receiver's reflector.
|
/// Returns the receiver's reflector.
|
||||||
fn reflector(&self) -> &Reflector;
|
fn reflector(&self) -> &Reflector;
|
||||||
|
|
||||||
|
/// Returns the global scope of the realm that the Reflectable was created in.
|
||||||
|
fn global_scope(&self) -> Root<GlobalScope> where Self: Sized {
|
||||||
|
global_scope_from_reflector(self)
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the global object of the realm that the Reflectable was created in.
|
/// Returns the global object of the realm that the Reflectable was created in.
|
||||||
fn global(&self) -> GlobalRoot where Self: Sized {
|
fn global(&self) -> GlobalRoot where Self: Sized {
|
||||||
global_root_from_reflector(self)
|
global_root_from_reflector(self)
|
||||||
|
|
|
@ -117,7 +117,7 @@ impl Blob {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Blob::new(parent.global().r().as_global_scope(), blob_impl, relative_content_type.into())
|
Blob::new(&parent.global_scope(), blob_impl, relative_content_type.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/FileAPI/#constructorBlob
|
// https://w3c.github.io/FileAPI/#constructorBlob
|
||||||
|
|
|
@ -106,14 +106,12 @@ impl Bluetooth {
|
||||||
// Step 12-13.
|
// Step 12-13.
|
||||||
match device {
|
match device {
|
||||||
Ok(device) => {
|
Ok(device) => {
|
||||||
let global = self.global();
|
let global = self.global_scope();
|
||||||
let global = global.r();
|
let ad_data = BluetoothAdvertisingData::new(&global,
|
||||||
let global = global.as_global_scope();
|
|
||||||
let ad_data = BluetoothAdvertisingData::new(global,
|
|
||||||
device.appearance,
|
device.appearance,
|
||||||
device.tx_power,
|
device.tx_power,
|
||||||
device.rssi);
|
device.rssi);
|
||||||
Ok(BluetoothDevice::new(global,
|
Ok(BluetoothDevice::new(&global,
|
||||||
DOMString::from(device.id),
|
DOMString::from(device.id),
|
||||||
device.name.map(DOMString::from),
|
device.name.map(DOMString::from),
|
||||||
&ad_data))
|
&ad_data))
|
||||||
|
|
|
@ -67,7 +67,7 @@ impl BluetoothDeviceMethods for BluetoothDevice {
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-gatt
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-gatt
|
||||||
fn Gatt(&self) -> Root<BluetoothRemoteGATTServer> {
|
fn Gatt(&self) -> Root<BluetoothRemoteGATTServer> {
|
||||||
self.gatt.or_init(|| {
|
self.gatt.or_init(|| {
|
||||||
BluetoothRemoteGATTServer::new(self.global().r().as_global_scope(), self)
|
BluetoothRemoteGATTServer::new(&self.global_scope(), self)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ impl BluetoothRemoteGATTCharacteristic {
|
||||||
let descriptor = receiver.recv().unwrap();
|
let descriptor = receiver.recv().unwrap();
|
||||||
match descriptor {
|
match descriptor {
|
||||||
Ok(descriptor) => {
|
Ok(descriptor) => {
|
||||||
Ok(BluetoothRemoteGATTDescriptor::new(self.global().r().as_global_scope(),
|
Ok(BluetoothRemoteGATTDescriptor::new(&self.global_scope(),
|
||||||
self,
|
self,
|
||||||
DOMString::from(descriptor.uuid),
|
DOMString::from(descriptor.uuid),
|
||||||
descriptor.instance_id))
|
descriptor.instance_id))
|
||||||
|
@ -126,7 +126,7 @@ impl BluetoothRemoteGATTCharacteristic {
|
||||||
match descriptors_vec {
|
match descriptors_vec {
|
||||||
Ok(descriptor_vec) => {
|
Ok(descriptor_vec) => {
|
||||||
Ok(descriptor_vec.into_iter()
|
Ok(descriptor_vec.into_iter()
|
||||||
.map(|desc| BluetoothRemoteGATTDescriptor::new(self.global().r().as_global_scope(),
|
.map(|desc| BluetoothRemoteGATTDescriptor::new(&self.global_scope(),
|
||||||
self,
|
self,
|
||||||
DOMString::from(desc.uuid),
|
DOMString::from(desc.uuid),
|
||||||
desc.instance_id))
|
desc.instance_id))
|
||||||
|
|
|
@ -80,7 +80,7 @@ impl BluetoothRemoteGATTServer {
|
||||||
let service = receiver.recv().unwrap();
|
let service = receiver.recv().unwrap();
|
||||||
match service {
|
match service {
|
||||||
Ok(service) => {
|
Ok(service) => {
|
||||||
Ok(BluetoothRemoteGATTService::new(self.global().r().as_global_scope(),
|
Ok(BluetoothRemoteGATTService::new(&self.global_scope(),
|
||||||
&self.device.get(),
|
&self.device.get(),
|
||||||
DOMString::from(service.uuid),
|
DOMString::from(service.uuid),
|
||||||
service.is_primary,
|
service.is_primary,
|
||||||
|
@ -112,7 +112,7 @@ impl BluetoothRemoteGATTServer {
|
||||||
match services_vec {
|
match services_vec {
|
||||||
Ok(service_vec) => {
|
Ok(service_vec) => {
|
||||||
Ok(service_vec.into_iter()
|
Ok(service_vec.into_iter()
|
||||||
.map(|service| BluetoothRemoteGATTService::new(self.global().r().as_global_scope(),
|
.map(|service| BluetoothRemoteGATTService::new(&self.global_scope(),
|
||||||
&self.device.get(),
|
&self.device.get(),
|
||||||
DOMString::from(service.uuid),
|
DOMString::from(service.uuid),
|
||||||
service.is_primary,
|
service.is_primary,
|
||||||
|
|
|
@ -84,10 +84,8 @@ impl BluetoothRemoteGATTService {
|
||||||
let characteristic = receiver.recv().unwrap();
|
let characteristic = receiver.recv().unwrap();
|
||||||
match characteristic {
|
match characteristic {
|
||||||
Ok(characteristic) => {
|
Ok(characteristic) => {
|
||||||
let global = self.global();
|
let global = self.global_scope();
|
||||||
let global = global.r();
|
let properties = BluetoothCharacteristicProperties::new(&global,
|
||||||
let global = global.as_global_scope();
|
|
||||||
let properties = BluetoothCharacteristicProperties::new(global,
|
|
||||||
characteristic.broadcast,
|
characteristic.broadcast,
|
||||||
characteristic.read,
|
characteristic.read,
|
||||||
characteristic.write_without_response,
|
characteristic.write_without_response,
|
||||||
|
@ -97,7 +95,7 @@ impl BluetoothRemoteGATTService {
|
||||||
characteristic.authenticated_signed_writes,
|
characteristic.authenticated_signed_writes,
|
||||||
characteristic.reliable_write,
|
characteristic.reliable_write,
|
||||||
characteristic.writable_auxiliaries);
|
characteristic.writable_auxiliaries);
|
||||||
Ok(BluetoothRemoteGATTCharacteristic::new(global,
|
Ok(BluetoothRemoteGATTCharacteristic::new(&global,
|
||||||
self,
|
self,
|
||||||
DOMString::from(characteristic.uuid),
|
DOMString::from(characteristic.uuid),
|
||||||
&properties,
|
&properties,
|
||||||
|
@ -130,10 +128,8 @@ impl BluetoothRemoteGATTService {
|
||||||
match characteristics_vec {
|
match characteristics_vec {
|
||||||
Ok(characteristic_vec) => {
|
Ok(characteristic_vec) => {
|
||||||
for characteristic in characteristic_vec {
|
for characteristic in characteristic_vec {
|
||||||
let global = self.global();
|
let global = self.global_scope();
|
||||||
let global = global.r();
|
let properties = BluetoothCharacteristicProperties::new(&global,
|
||||||
let global = global.as_global_scope();
|
|
||||||
let properties = BluetoothCharacteristicProperties::new(global,
|
|
||||||
characteristic.broadcast,
|
characteristic.broadcast,
|
||||||
characteristic.read,
|
characteristic.read,
|
||||||
characteristic.write_without_response,
|
characteristic.write_without_response,
|
||||||
|
@ -143,7 +139,7 @@ impl BluetoothRemoteGATTService {
|
||||||
characteristic.authenticated_signed_writes,
|
characteristic.authenticated_signed_writes,
|
||||||
characteristic.reliable_write,
|
characteristic.reliable_write,
|
||||||
characteristic.writable_auxiliaries);
|
characteristic.writable_auxiliaries);
|
||||||
characteristics.push(BluetoothRemoteGATTCharacteristic::new(global,
|
characteristics.push(BluetoothRemoteGATTCharacteristic::new(&global,
|
||||||
self,
|
self,
|
||||||
DOMString::from(characteristic.uuid),
|
DOMString::from(characteristic.uuid),
|
||||||
&properties,
|
&properties,
|
||||||
|
@ -173,7 +169,7 @@ impl BluetoothRemoteGATTService {
|
||||||
let service = receiver.recv().unwrap();
|
let service = receiver.recv().unwrap();
|
||||||
match service {
|
match service {
|
||||||
Ok(service) => {
|
Ok(service) => {
|
||||||
Ok(BluetoothRemoteGATTService::new(self.global().r().as_global_scope(),
|
Ok(BluetoothRemoteGATTService::new(&self.global_scope(),
|
||||||
&self.device.get(),
|
&self.device.get(),
|
||||||
DOMString::from(service.uuid),
|
DOMString::from(service.uuid),
|
||||||
service.is_primary,
|
service.is_primary,
|
||||||
|
@ -207,7 +203,7 @@ impl BluetoothRemoteGATTService {
|
||||||
match services_vec {
|
match services_vec {
|
||||||
Ok(service_vec) => {
|
Ok(service_vec) => {
|
||||||
Ok(service_vec.into_iter()
|
Ok(service_vec.into_iter()
|
||||||
.map(|service| BluetoothRemoteGATTService::new(self.global().r().as_global_scope(),
|
.map(|service| BluetoothRemoteGATTService::new(&self.global_scope(),
|
||||||
&self.device.get(),
|
&self.device.get(),
|
||||||
DOMString::from(service.uuid),
|
DOMString::from(service.uuid),
|
||||||
service.is_primary,
|
service.is_primary,
|
||||||
|
|
|
@ -1016,12 +1016,12 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
|
|
||||||
let sw = cmp::max(1, sw.abs().to_u32().unwrap());
|
let sw = cmp::max(1, sw.abs().to_u32().unwrap());
|
||||||
let sh = cmp::max(1, sh.abs().to_u32().unwrap());
|
let sh = cmp::max(1, sh.abs().to_u32().unwrap());
|
||||||
Ok(ImageData::new(self.global().r().as_global_scope(), sw, sh, None))
|
Ok(ImageData::new(&self.global_scope(), sw, sh, None))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createimagedata
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createimagedata
|
||||||
fn CreateImageData_(&self, imagedata: &ImageData) -> Fallible<Root<ImageData>> {
|
fn CreateImageData_(&self, imagedata: &ImageData) -> Fallible<Root<ImageData>> {
|
||||||
Ok(ImageData::new(self.global().r().as_global_scope(),
|
Ok(ImageData::new(&self.global_scope(),
|
||||||
imagedata.Width(),
|
imagedata.Width(),
|
||||||
imagedata.Height(),
|
imagedata.Height(),
|
||||||
None))
|
None))
|
||||||
|
@ -1077,7 +1077,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
chunk[2] = UNPREMULTIPLY_TABLE[256 * alpha + chunk[2] as usize];
|
chunk[2] = UNPREMULTIPLY_TABLE[256 * alpha + chunk[2] as usize];
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(ImageData::new(self.global().r().as_global_scope(), sw, sh, Some(data)))
|
Ok(ImageData::new(&self.global_scope(), sw, sh, Some(data)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-putimagedata
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-putimagedata
|
||||||
|
@ -1121,7 +1121,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
x1: Finite<f64>,
|
x1: Finite<f64>,
|
||||||
y1: Finite<f64>)
|
y1: Finite<f64>)
|
||||||
-> Root<CanvasGradient> {
|
-> Root<CanvasGradient> {
|
||||||
CanvasGradient::new(self.global().r().as_global_scope(),
|
CanvasGradient::new(&self.global_scope(),
|
||||||
CanvasGradientStyle::Linear(LinearGradientStyle::new(*x0,
|
CanvasGradientStyle::Linear(LinearGradientStyle::new(*x0,
|
||||||
*y0,
|
*y0,
|
||||||
*x1,
|
*x1,
|
||||||
|
@ -1142,7 +1142,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
return Err(Error::IndexSize);
|
return Err(Error::IndexSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(CanvasGradient::new(self.global().r().as_global_scope(),
|
Ok(CanvasGradient::new(&self.global_scope(),
|
||||||
CanvasGradientStyle::Radial(RadialGradientStyle::new(*x0,
|
CanvasGradientStyle::Radial(RadialGradientStyle::new(*x0,
|
||||||
*y0,
|
*y0,
|
||||||
*r0,
|
*r0,
|
||||||
|
@ -1182,7 +1182,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(rep) = RepetitionStyle::from_str(&repetition) {
|
if let Ok(rep) = RepetitionStyle::from_str(&repetition) {
|
||||||
Ok(CanvasPattern::new(self.global().r().as_global_scope(),
|
Ok(CanvasPattern::new(&self.global_scope(),
|
||||||
image_data,
|
image_data,
|
||||||
image_size,
|
image_size,
|
||||||
rep,
|
rep,
|
||||||
|
|
|
@ -464,50 +464,50 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-translate
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-translate
|
||||||
fn Translate(&self, tx: f64, ty: f64, tz: f64) -> Root<DOMMatrix> {
|
fn Translate(&self, tx: f64, ty: f64, tz: f64) -> Root<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(self.global().r().as_global_scope(), self).TranslateSelf(tx, ty, tz)
|
DOMMatrix::from_readonly(&self.global_scope(), self).TranslateSelf(tx, ty, tz)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-scale
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-scale
|
||||||
fn Scale(&self, scaleX: f64, scaleY: Option<f64>, scaleZ: f64,
|
fn Scale(&self, scaleX: f64, scaleY: Option<f64>, scaleZ: f64,
|
||||||
originX: f64, originY: f64, originZ: f64) -> Root<DOMMatrix> {
|
originX: f64, originY: f64, originZ: f64) -> Root<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(self.global().r().as_global_scope(), self)
|
DOMMatrix::from_readonly(&self.global_scope(), self)
|
||||||
.ScaleSelf(scaleX, scaleY, scaleZ, originX, originY, originZ)
|
.ScaleSelf(scaleX, scaleY, scaleZ, originX, originY, originZ)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-scale3d
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-scale3d
|
||||||
fn Scale3d(&self, scale: f64, originX: f64, originY: f64, originZ: f64) -> Root<DOMMatrix> {
|
fn Scale3d(&self, scale: f64, originX: f64, originY: f64, originZ: f64) -> Root<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(self.global().r().as_global_scope(), self)
|
DOMMatrix::from_readonly(&self.global_scope(), self)
|
||||||
.Scale3dSelf(scale, originX, originY, originZ)
|
.Scale3dSelf(scale, originX, originY, originZ)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotate
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotate
|
||||||
fn Rotate(&self, rotX: f64, rotY: Option<f64>, rotZ: Option<f64>) -> Root<DOMMatrix> {
|
fn Rotate(&self, rotX: f64, rotY: Option<f64>, rotZ: Option<f64>) -> Root<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(self.global().r().as_global_scope(), self).RotateSelf(rotX, rotY, rotZ)
|
DOMMatrix::from_readonly(&self.global_scope(), self).RotateSelf(rotX, rotY, rotZ)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotatefromvector
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotatefromvector
|
||||||
fn RotateFromVector(&self, x: f64, y: f64) -> Root<DOMMatrix> {
|
fn RotateFromVector(&self, x: f64, y: f64) -> Root<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(self.global().r().as_global_scope(), self).RotateFromVectorSelf(x, y)
|
DOMMatrix::from_readonly(&self.global_scope(), self).RotateFromVectorSelf(x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotateaxisangle
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotateaxisangle
|
||||||
fn RotateAxisAngle(&self, x: f64, y: f64, z: f64, angle: f64) -> Root<DOMMatrix> {
|
fn RotateAxisAngle(&self, x: f64, y: f64, z: f64, angle: f64) -> Root<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(self.global().r().as_global_scope(), self).RotateAxisAngleSelf(x, y, z, angle)
|
DOMMatrix::from_readonly(&self.global_scope(), self).RotateAxisAngleSelf(x, y, z, angle)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-skewx
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-skewx
|
||||||
fn SkewX(&self, sx: f64) -> Root<DOMMatrix> {
|
fn SkewX(&self, sx: f64) -> Root<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(self.global().r().as_global_scope(), self).SkewXSelf(sx)
|
DOMMatrix::from_readonly(&self.global_scope(), self).SkewXSelf(sx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-skewy
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-skewy
|
||||||
fn SkewY(&self, sy: f64) -> Root<DOMMatrix> {
|
fn SkewY(&self, sy: f64) -> Root<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(self.global().r().as_global_scope(), self).SkewYSelf(sy)
|
DOMMatrix::from_readonly(&self.global_scope(), self).SkewYSelf(sy)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-multiply
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-multiply
|
||||||
fn Multiply(&self, other: &DOMMatrixInit) -> Fallible<Root<DOMMatrix>> {
|
fn Multiply(&self, other: &DOMMatrixInit) -> Fallible<Root<DOMMatrix>> {
|
||||||
DOMMatrix::from_readonly(self.global().r().as_global_scope(), self).MultiplySelf(&other)
|
DOMMatrix::from_readonly(&self.global_scope(), self).MultiplySelf(&other)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipx
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipx
|
||||||
|
@ -518,7 +518,7 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
|
||||||
0.0, 0.0, 1.0, 0.0,
|
0.0, 0.0, 1.0, 0.0,
|
||||||
0.0, 0.0, 0.0, 1.0);
|
0.0, 0.0, 0.0, 1.0);
|
||||||
let matrix = flip.post_mul(&self.matrix.borrow());
|
let matrix = flip.post_mul(&self.matrix.borrow());
|
||||||
DOMMatrix::new(self.global().r().as_global_scope(), is2D, matrix)
|
DOMMatrix::new(&self.global_scope(), is2D, matrix)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipy
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipy
|
||||||
|
@ -529,12 +529,12 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
|
||||||
0.0, 0.0, 1.0, 0.0,
|
0.0, 0.0, 1.0, 0.0,
|
||||||
0.0, 0.0, 0.0, 1.0);
|
0.0, 0.0, 0.0, 1.0);
|
||||||
let matrix = flip.post_mul(&self.matrix.borrow());
|
let matrix = flip.post_mul(&self.matrix.borrow());
|
||||||
DOMMatrix::new(self.global().r().as_global_scope(), is2D, matrix)
|
DOMMatrix::new(&self.global_scope(), is2D, matrix)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-inverse
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-inverse
|
||||||
fn Inverse(&self) -> Root<DOMMatrix> {
|
fn Inverse(&self) -> Root<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(self.global().r().as_global_scope(), self).InvertSelf()
|
DOMMatrix::from_readonly(&self.global_scope(), self).InvertSelf()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-transformpoint
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-transformpoint
|
||||||
|
@ -542,7 +542,7 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
|
||||||
let matrix = self.matrix.borrow();
|
let matrix = self.matrix.borrow();
|
||||||
let result = matrix.transform_point4d(&Point4D::new(point.x, point.y, point.z, point.w));
|
let result = matrix.transform_point4d(&Point4D::new(point.x, point.y, point.z, point.w));
|
||||||
DOMPoint::new(
|
DOMPoint::new(
|
||||||
self.global().r().as_global_scope(),
|
&self.global_scope(),
|
||||||
result.x as f64,
|
result.x as f64,
|
||||||
result.y as f64,
|
result.y as f64,
|
||||||
result.z as f64,
|
result.z as f64,
|
||||||
|
|
|
@ -111,7 +111,7 @@ impl DOMQuadMethods for DOMQuad {
|
||||||
let right = self.p1.X().max(self.p2.X()).max(self.p3.X()).max(self.p4.X());
|
let right = self.p1.X().max(self.p2.X()).max(self.p3.X()).max(self.p4.X());
|
||||||
let bottom = self.p1.Y().max(self.p2.Y()).max(self.p3.Y()).max(self.p4.Y());
|
let bottom = self.p1.Y().max(self.p2.Y()).max(self.p3.Y()).max(self.p4.Y());
|
||||||
|
|
||||||
DOMRect::new(self.global().r().as_global_scope(),
|
DOMRect::new(&self.global_scope(),
|
||||||
left,
|
left,
|
||||||
top,
|
top,
|
||||||
right - left,
|
right - left,
|
||||||
|
|
|
@ -500,8 +500,7 @@ impl EventTarget {
|
||||||
bubbles: EventBubbles,
|
bubbles: EventBubbles,
|
||||||
cancelable: EventCancelable)
|
cancelable: EventCancelable)
|
||||||
-> Root<Event> {
|
-> Root<Event> {
|
||||||
let event = Event::new(
|
let event = Event::new(&self.global_scope(), Atom::from(name), bubbles, cancelable);
|
||||||
self.global().r().as_global_scope(), Atom::from(name), bubbles, cancelable);
|
|
||||||
|
|
||||||
event.fire(self);
|
event.fire(self);
|
||||||
|
|
||||||
|
|
|
@ -115,8 +115,7 @@ impl FileReader {
|
||||||
fr.change_ready_state(FileReaderReadyState::Done);
|
fr.change_ready_state(FileReaderReadyState::Done);
|
||||||
*fr.result.borrow_mut() = None;
|
*fr.result.borrow_mut() = None;
|
||||||
|
|
||||||
let global = fr.r().global();
|
let exception = DOMException::new(&fr.global_scope(), error);
|
||||||
let exception = DOMException::new(global.r().as_global_scope(), error);
|
|
||||||
fr.error.set(Some(&exception));
|
fr.error.set(Some(&exception));
|
||||||
|
|
||||||
fr.dispatch_progress_event(atom!("error"), 0, None);
|
fr.dispatch_progress_event(atom!("error"), 0, None);
|
||||||
|
@ -290,8 +289,7 @@ impl FileReaderMethods for FileReader {
|
||||||
// Steps 1 & 3
|
// Steps 1 & 3
|
||||||
*self.result.borrow_mut() = None;
|
*self.result.borrow_mut() = None;
|
||||||
|
|
||||||
let global = self.global();
|
let exception = DOMException::new(&self.global_scope(), DOMErrorName::AbortError);
|
||||||
let exception = DOMException::new(global.r().as_global_scope(), DOMErrorName::AbortError);
|
|
||||||
self.error.set(Some(&exception));
|
self.error.set(Some(&exception));
|
||||||
|
|
||||||
self.terminate_ongoing_reading();
|
self.terminate_ongoing_reading();
|
||||||
|
@ -319,8 +317,7 @@ impl FileReaderMethods for FileReader {
|
||||||
|
|
||||||
impl FileReader {
|
impl FileReader {
|
||||||
fn dispatch_progress_event(&self, type_: Atom, loaded: u64, total: Option<u64>) {
|
fn dispatch_progress_event(&self, type_: Atom, loaded: u64, total: Option<u64>) {
|
||||||
let global = self.global();
|
let progressevent = ProgressEvent::new(&self.global_scope(),
|
||||||
let progressevent = ProgressEvent::new(global.r().as_global_scope(),
|
|
||||||
type_, EventBubbles::DoesNotBubble, EventCancelable::NotCancelable,
|
type_, EventBubbles::DoesNotBubble, EventCancelable::NotCancelable,
|
||||||
total.is_some(), loaded, total.unwrap_or(0));
|
total.is_some(), loaded, total.unwrap_or(0));
|
||||||
progressevent.upcast::<Event>().fire(self.upcast());
|
progressevent.upcast::<Event>().fire(self.upcast());
|
||||||
|
@ -338,8 +335,7 @@ impl FileReader {
|
||||||
}
|
}
|
||||||
// Step 2
|
// Step 2
|
||||||
if blob.IsClosed() {
|
if blob.IsClosed() {
|
||||||
let global = self.global();
|
let exception = DOMException::new(&self.global_scope(), DOMErrorName::InvalidStateError);
|
||||||
let exception = DOMException::new(global.r().as_global_scope(), DOMErrorName::InvalidStateError);
|
|
||||||
self.error.set(Some(&exception));
|
self.error.set(Some(&exception));
|
||||||
|
|
||||||
self.dispatch_progress_event(atom!("error"), 0, None);
|
self.dispatch_progress_event(atom!("error"), 0, None);
|
||||||
|
|
|
@ -146,8 +146,6 @@ impl FormDataMethods for FormData {
|
||||||
|
|
||||||
impl FormData {
|
impl FormData {
|
||||||
fn get_file(&self, blob: &Blob, opt_filename: Option<USVString>) -> Root<File> {
|
fn get_file(&self, blob: &Blob, opt_filename: Option<USVString>) -> Root<File> {
|
||||||
let global = self.global();
|
|
||||||
|
|
||||||
let name = match opt_filename {
|
let name = match opt_filename {
|
||||||
Some(filename) => DOMString::from(filename.0),
|
Some(filename) => DOMString::from(filename.0),
|
||||||
None => DOMString::from(""),
|
None => DOMString::from(""),
|
||||||
|
@ -155,7 +153,7 @@ impl FormData {
|
||||||
|
|
||||||
let bytes = blob.get_bytes().unwrap_or(vec![]);
|
let bytes = blob.get_bytes().unwrap_or(vec![]);
|
||||||
|
|
||||||
File::new(global.r().as_global_scope(), BlobImpl::new_from_bytes(bytes), name, None, "")
|
File::new(&self.global_scope(), BlobImpl::new_from_bytes(bytes), name, None, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn datums(&self) -> Vec<FormDatum> {
|
pub fn datums(&self) -> Vec<FormDatum> {
|
||||||
|
|
|
@ -267,7 +267,7 @@ impl HTMLLinkElement {
|
||||||
credentials_mode: CredentialsMode::Include,
|
credentials_mode: CredentialsMode::Include,
|
||||||
use_url_credentials: true,
|
use_url_credentials: true,
|
||||||
origin: document.url().clone(),
|
origin: document.url().clone(),
|
||||||
pipeline_id: Some(self.global().r().as_global_scope().pipeline_id()),
|
pipeline_id: Some(self.global_scope().pipeline_id()),
|
||||||
referrer_url: Some(document.url().clone()),
|
referrer_url: Some(document.url().clone()),
|
||||||
referrer_policy: referrer_policy,
|
referrer_policy: referrer_policy,
|
||||||
.. RequestInit::default()
|
.. RequestInit::default()
|
||||||
|
|
|
@ -242,7 +242,7 @@ fn fetch_a_classic_script(script: &HTMLScriptElement,
|
||||||
_ => CredentialsMode::Include,
|
_ => CredentialsMode::Include,
|
||||||
},
|
},
|
||||||
origin: doc.url().clone(),
|
origin: doc.url().clone(),
|
||||||
pipeline_id: Some(script.global().r().as_global_scope().pipeline_id()),
|
pipeline_id: Some(script.global_scope().pipeline_id()),
|
||||||
referrer_url: Some(doc.url().clone()),
|
referrer_url: Some(doc.url().clone()),
|
||||||
referrer_policy: doc.get_referrer_policy(),
|
referrer_policy: doc.get_referrer_policy(),
|
||||||
.. RequestInit::default()
|
.. RequestInit::default()
|
||||||
|
|
|
@ -79,7 +79,7 @@ impl NavigatorMethods for Navigator {
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-navigator-bluetooth
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-navigator-bluetooth
|
||||||
fn Bluetooth(&self) -> Root<Bluetooth> {
|
fn Bluetooth(&self) -> Root<Bluetooth> {
|
||||||
self.bluetooth.or_init(|| Bluetooth::new(self.global().r().as_global_scope()))
|
self.bluetooth.or_init(|| Bluetooth::new(&self.global_scope()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#navigatorlanguage
|
// https://html.spec.whatwg.org/multipage/#navigatorlanguage
|
||||||
|
@ -89,12 +89,12 @@ impl NavigatorMethods for Navigator {
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-plugins
|
// https://html.spec.whatwg.org/multipage/#dom-navigator-plugins
|
||||||
fn Plugins(&self) -> Root<PluginArray> {
|
fn Plugins(&self) -> Root<PluginArray> {
|
||||||
self.plugins.or_init(|| PluginArray::new(self.global().r().as_global_scope()))
|
self.plugins.or_init(|| PluginArray::new(&self.global_scope()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-mimetypes
|
// https://html.spec.whatwg.org/multipage/#dom-navigator-mimetypes
|
||||||
fn MimeTypes(&self) -> Root<MimeTypeArray> {
|
fn MimeTypes(&self) -> Root<MimeTypeArray> {
|
||||||
self.mime_types.or_init(|| MimeTypeArray::new(self.global().r().as_global_scope()))
|
self.mime_types.or_init(|| MimeTypeArray::new(&self.global_scope()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-javaenabled
|
// https://html.spec.whatwg.org/multipage/#dom-navigator-javaenabled
|
||||||
|
@ -105,7 +105,7 @@ impl NavigatorMethods for Navigator {
|
||||||
// https://w3c.github.io/ServiceWorker/#navigator-service-worker-attribute
|
// https://w3c.github.io/ServiceWorker/#navigator-service-worker-attribute
|
||||||
fn ServiceWorker(&self) -> Root<ServiceWorkerContainer> {
|
fn ServiceWorker(&self) -> Root<ServiceWorkerContainer> {
|
||||||
self.service_worker.or_init(|| {
|
self.service_worker.or_init(|| {
|
||||||
ServiceWorkerContainer::new(self.global().r().as_global_scope())
|
ServiceWorkerContainer::new(&self.global_scope())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -305,7 +305,7 @@ impl Request {
|
||||||
let r = Request::from_net_request(global,
|
let r = Request::from_net_request(global,
|
||||||
false,
|
false,
|
||||||
request);
|
request);
|
||||||
r.headers.or_init(|| Headers::for_request(r.global().r().as_global_scope()));
|
r.headers.or_init(|| Headers::for_request(&r.global_scope()));
|
||||||
|
|
||||||
// Step 27
|
// Step 27
|
||||||
let mut headers_copy = r.Headers();
|
let mut headers_copy = r.Headers();
|
||||||
|
@ -549,7 +549,7 @@ impl RequestMethods for Request {
|
||||||
|
|
||||||
// https://fetch.spec.whatwg.org/#dom-request-headers
|
// https://fetch.spec.whatwg.org/#dom-request-headers
|
||||||
fn Headers(&self) -> Root<Headers> {
|
fn Headers(&self) -> Root<Headers> {
|
||||||
self.headers.or_init(|| Headers::new(self.global().r().as_global_scope()))
|
self.headers.or_init(|| Headers::new(&self.global_scope()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://fetch.spec.whatwg.org/#dom-request-type
|
// https://fetch.spec.whatwg.org/#dom-request-type
|
||||||
|
|
|
@ -293,7 +293,7 @@ impl ResponseMethods for Response {
|
||||||
|
|
||||||
// https://fetch.spec.whatwg.org/#dom-response-headers
|
// https://fetch.spec.whatwg.org/#dom-response-headers
|
||||||
fn Headers(&self) -> Root<Headers> {
|
fn Headers(&self) -> Root<Headers> {
|
||||||
self.headers_reflector.or_init(|| Headers::for_response(self.global().r().as_global_scope()))
|
self.headers_reflector.or_init(|| Headers::for_response(&self.global_scope()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://fetch.spec.whatwg.org/#dom-response-clone
|
// https://fetch.spec.whatwg.org/#dom-response-clone
|
||||||
|
@ -302,7 +302,7 @@ impl ResponseMethods for Response {
|
||||||
// TODO: This step relies on body and stream, which are still unimplemented.
|
// TODO: This step relies on body and stream, which are still unimplemented.
|
||||||
|
|
||||||
// Step 2
|
// Step 2
|
||||||
let new_response = Response::new(self.global().r().as_global_scope());
|
let new_response = Response::new(&self.global_scope());
|
||||||
new_response.Headers().set_guard(self.Headers().get_guard());
|
new_response.Headers().set_guard(self.Headers().get_guard());
|
||||||
|
|
||||||
// https://fetch.spec.whatwg.org/#concept-response-clone
|
// https://fetch.spec.whatwg.org/#concept-response-clone
|
||||||
|
|
|
@ -90,8 +90,7 @@ impl ServiceWorkerMethods for ServiceWorker {
|
||||||
let data = try!(StructuredCloneData::write(cx, message));
|
let data = try!(StructuredCloneData::write(cx, message));
|
||||||
let msg_vec = DOMMessage(data.move_to_arraybuffer());
|
let msg_vec = DOMMessage(data.move_to_arraybuffer());
|
||||||
let _ =
|
let _ =
|
||||||
self.global().r()
|
self.global_scope()
|
||||||
.as_global_scope()
|
|
||||||
.constellation_chan()
|
.constellation_chan()
|
||||||
.send(ScriptMsg::ForwardDOMMessage(msg_vec, self.scope_url.clone()));
|
.send(ScriptMsg::ForwardDOMMessage(msg_vec, self.scope_url.clone()));
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -95,14 +95,12 @@ impl ServiceWorkerContainerMethods for ServiceWorkerContainer {
|
||||||
return Err(Error::Type("Scope URL contains forbidden characters".to_owned()));
|
return Err(Error::Type("Scope URL contains forbidden characters".to_owned()));
|
||||||
}
|
}
|
||||||
|
|
||||||
let global = self.global();
|
let global = self.global_scope();
|
||||||
let global = global.r();
|
let worker_registration = ServiceWorkerRegistration::new(&global,
|
||||||
let global_scope = global.as_global_scope();
|
|
||||||
let worker_registration = ServiceWorkerRegistration::new(global_scope,
|
|
||||||
script_url,
|
script_url,
|
||||||
scope.clone(),
|
scope.clone(),
|
||||||
self);
|
self);
|
||||||
ScriptThread::set_registration(scope, &*worker_registration, global_scope.pipeline_id());
|
ScriptThread::set_registration(scope, &*worker_registration, global.pipeline_id());
|
||||||
Ok(worker_registration)
|
Ok(worker_registration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,13 +185,11 @@ impl Runnable for StorageEventRunnable {
|
||||||
let this = *self;
|
let this = *self;
|
||||||
let storage_root = this.element.root();
|
let storage_root = this.element.root();
|
||||||
let storage = storage_root.r();
|
let storage = storage_root.r();
|
||||||
let global_root = storage.global();
|
let global = storage.global_scope();
|
||||||
let global_ref = global_root.r();
|
|
||||||
let ev_window = global_ref.as_window();
|
|
||||||
let ev_url = storage.get_url();
|
let ev_url = storage.get_url();
|
||||||
|
|
||||||
let storage_event = StorageEvent::new(
|
let storage_event = StorageEvent::new(
|
||||||
global_ref.as_global_scope(),
|
&global,
|
||||||
atom!("storage"),
|
atom!("storage"),
|
||||||
EventBubbles::DoesNotBubble, EventCancelable::NotCancelable,
|
EventBubbles::DoesNotBubble, EventCancelable::NotCancelable,
|
||||||
this.key.map(DOMString::from), this.old_value.map(DOMString::from), this.new_value.map(DOMString::from),
|
this.key.map(DOMString::from), this.old_value.map(DOMString::from), this.new_value.map(DOMString::from),
|
||||||
|
@ -206,7 +204,7 @@ impl Runnable for StorageEventRunnable {
|
||||||
assert!(UrlHelper::SameOrigin(&ev_url, &it_window.get_url()));
|
assert!(UrlHelper::SameOrigin(&ev_url, &it_window.get_url()));
|
||||||
// TODO: Such a Document object is not necessarily fully active, but events fired on such
|
// TODO: Such a Document object is not necessarily fully active, but events fired on such
|
||||||
// objects are ignored by the event loop until the Document becomes fully active again.
|
// objects are ignored by the event loop until the Document becomes fully active again.
|
||||||
if ev_window.upcast::<GlobalScope>().pipeline_id() != it_window.upcast::<GlobalScope>().pipeline_id() {
|
if global.pipeline_id() != it_window.upcast::<GlobalScope>().pipeline_id() {
|
||||||
storage_event.upcast::<Event>().fire(it_window.upcast());
|
storage_event.upcast::<Event>().fire(it_window.upcast());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ impl TestBindingMethods for TestBinding {
|
||||||
fn EnumAttribute(&self) -> TestEnum { TestEnum::_empty }
|
fn EnumAttribute(&self) -> TestEnum { TestEnum::_empty }
|
||||||
fn SetEnumAttribute(&self, _: TestEnum) {}
|
fn SetEnumAttribute(&self, _: TestEnum) {}
|
||||||
fn InterfaceAttribute(&self) -> Root<Blob> {
|
fn InterfaceAttribute(&self) -> Root<Blob> {
|
||||||
Blob::new(self.global().r().as_global_scope(), BlobImpl::new_from_bytes(vec![]), "".to_owned())
|
Blob::new(&self.global_scope(), BlobImpl::new_from_bytes(vec![]), "".to_owned())
|
||||||
}
|
}
|
||||||
fn SetInterfaceAttribute(&self, _: &Blob) {}
|
fn SetInterfaceAttribute(&self, _: &Blob) {}
|
||||||
fn UnionAttribute(&self) -> HTMLElementOrLong { HTMLElementOrLong::Long(0) }
|
fn UnionAttribute(&self) -> HTMLElementOrLong { HTMLElementOrLong::Long(0) }
|
||||||
|
@ -210,7 +210,7 @@ impl TestBindingMethods for TestBinding {
|
||||||
fn SetAttr_to_automatically_rename(&self, _: DOMString) {}
|
fn SetAttr_to_automatically_rename(&self, _: DOMString) {}
|
||||||
fn GetEnumAttributeNullable(&self) -> Option<TestEnum> { Some(TestEnum::_empty) }
|
fn GetEnumAttributeNullable(&self) -> Option<TestEnum> { Some(TestEnum::_empty) }
|
||||||
fn GetInterfaceAttributeNullable(&self) -> Option<Root<Blob>> {
|
fn GetInterfaceAttributeNullable(&self) -> Option<Root<Blob>> {
|
||||||
Some(Blob::new(self.global().r().as_global_scope(), BlobImpl::new_from_bytes(vec![]), "".to_owned()))
|
Some(Blob::new(&self.global_scope(), BlobImpl::new_from_bytes(vec![]), "".to_owned()))
|
||||||
}
|
}
|
||||||
fn SetInterfaceAttributeNullable(&self, _: Option<&Blob>) {}
|
fn SetInterfaceAttributeNullable(&self, _: Option<&Blob>) {}
|
||||||
fn GetInterfaceAttributeWeak(&self) -> Option<Root<URL>> {
|
fn GetInterfaceAttributeWeak(&self) -> Option<Root<URL>> {
|
||||||
|
@ -265,7 +265,7 @@ impl TestBindingMethods for TestBinding {
|
||||||
fn ReceiveByteString(&self) -> ByteString { ByteString::new(vec!()) }
|
fn ReceiveByteString(&self) -> ByteString { ByteString::new(vec!()) }
|
||||||
fn ReceiveEnum(&self) -> TestEnum { TestEnum::_empty }
|
fn ReceiveEnum(&self) -> TestEnum { TestEnum::_empty }
|
||||||
fn ReceiveInterface(&self) -> Root<Blob> {
|
fn ReceiveInterface(&self) -> Root<Blob> {
|
||||||
Blob::new(self.global().r().as_global_scope(), BlobImpl::new_from_bytes(vec![]), "".to_owned())
|
Blob::new(&self.global_scope(), BlobImpl::new_from_bytes(vec![]), "".to_owned())
|
||||||
}
|
}
|
||||||
fn ReceiveAny(&self, _: *mut JSContext) -> JSVal { NullValue() }
|
fn ReceiveAny(&self, _: *mut JSContext) -> JSVal { NullValue() }
|
||||||
fn ReceiveObject(&self, cx: *mut JSContext) -> NonZero<*mut JSObject> {
|
fn ReceiveObject(&self, cx: *mut JSContext) -> NonZero<*mut JSObject> {
|
||||||
|
@ -288,7 +288,7 @@ impl TestBindingMethods for TestBinding {
|
||||||
}
|
}
|
||||||
fn ReceiveSequence(&self) -> Vec<i32> { vec![1] }
|
fn ReceiveSequence(&self) -> Vec<i32> { vec![1] }
|
||||||
fn ReceiveInterfaceSequence(&self) -> Vec<Root<Blob>> {
|
fn ReceiveInterfaceSequence(&self) -> Vec<Root<Blob>> {
|
||||||
vec![Blob::new(self.global().r().as_global_scope(), BlobImpl::new_from_bytes(vec![]), "".to_owned())]
|
vec![Blob::new(&self.global_scope(), BlobImpl::new_from_bytes(vec![]), "".to_owned())]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ReceiveNullableBoolean(&self) -> Option<bool> { Some(false) }
|
fn ReceiveNullableBoolean(&self) -> Option<bool> { Some(false) }
|
||||||
|
@ -309,7 +309,7 @@ impl TestBindingMethods for TestBinding {
|
||||||
fn ReceiveNullableByteString(&self) -> Option<ByteString> { Some(ByteString::new(vec!())) }
|
fn ReceiveNullableByteString(&self) -> Option<ByteString> { Some(ByteString::new(vec!())) }
|
||||||
fn ReceiveNullableEnum(&self) -> Option<TestEnum> { Some(TestEnum::_empty) }
|
fn ReceiveNullableEnum(&self) -> Option<TestEnum> { Some(TestEnum::_empty) }
|
||||||
fn ReceiveNullableInterface(&self) -> Option<Root<Blob>> {
|
fn ReceiveNullableInterface(&self) -> Option<Root<Blob>> {
|
||||||
Some(Blob::new(self.global().r().as_global_scope(), BlobImpl::new_from_bytes(vec![]), "".to_owned()))
|
Some(Blob::new(&self.global_scope(), BlobImpl::new_from_bytes(vec![]), "".to_owned()))
|
||||||
}
|
}
|
||||||
fn ReceiveNullableObject(&self, cx: *mut JSContext) -> Option<NonZero<*mut JSObject>> {
|
fn ReceiveNullableObject(&self, cx: *mut JSContext) -> Option<NonZero<*mut JSObject>> {
|
||||||
self.GetObjectAttributeNullable(cx)
|
self.GetObjectAttributeNullable(cx)
|
||||||
|
|
|
@ -285,7 +285,7 @@ impl URLMethods for URL {
|
||||||
// https://url.spec.whatwg.org/#dom-url-searchparams
|
// https://url.spec.whatwg.org/#dom-url-searchparams
|
||||||
fn SearchParams(&self) -> Root<URLSearchParams> {
|
fn SearchParams(&self) -> Root<URLSearchParams> {
|
||||||
self.search_params.or_init(|| {
|
self.search_params.or_init(|| {
|
||||||
URLSearchParams::new(self.global().r().as_global_scope(), Some(self))
|
URLSearchParams::new(&self.global_scope(), Some(self))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -230,7 +230,7 @@ impl WebGLProgram {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
receiver.recv().unwrap().map(|(size, ty, name)|
|
receiver.recv().unwrap().map(|(size, ty, name)|
|
||||||
WebGLActiveInfo::new(self.global().r().as_global_scope(), size, ty, DOMString::from(name)))
|
WebGLActiveInfo::new(&self.global_scope(), size, ty, DOMString::from(name)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// glGetActiveAttrib
|
/// glGetActiveAttrib
|
||||||
|
@ -244,7 +244,7 @@ impl WebGLProgram {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
receiver.recv().unwrap().map(|(size, ty, name)|
|
receiver.recv().unwrap().map(|(size, ty, name)|
|
||||||
WebGLActiveInfo::new(self.global().r().as_global_scope(), size, ty, DOMString::from(name)))
|
WebGLActiveInfo::new(&self.global_scope(), size, ty, DOMString::from(name)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// glGetAttribLocation
|
/// glGetAttribLocation
|
||||||
|
|
|
@ -1154,27 +1154,27 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
||||||
// generated objects, either here or in the webgl thread
|
// generated objects, either here or in the webgl thread
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
|
||||||
fn CreateBuffer(&self) -> Option<Root<WebGLBuffer>> {
|
fn CreateBuffer(&self) -> Option<Root<WebGLBuffer>> {
|
||||||
WebGLBuffer::maybe_new(self.global().r().as_global_scope(), self.ipc_renderer.clone())
|
WebGLBuffer::maybe_new(&self.global_scope(), self.ipc_renderer.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6
|
||||||
fn CreateFramebuffer(&self) -> Option<Root<WebGLFramebuffer>> {
|
fn CreateFramebuffer(&self) -> Option<Root<WebGLFramebuffer>> {
|
||||||
WebGLFramebuffer::maybe_new(self.global().r().as_global_scope(), self.ipc_renderer.clone())
|
WebGLFramebuffer::maybe_new(&self.global_scope(), self.ipc_renderer.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.7
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.7
|
||||||
fn CreateRenderbuffer(&self) -> Option<Root<WebGLRenderbuffer>> {
|
fn CreateRenderbuffer(&self) -> Option<Root<WebGLRenderbuffer>> {
|
||||||
WebGLRenderbuffer::maybe_new(self.global().r().as_global_scope(), self.ipc_renderer.clone())
|
WebGLRenderbuffer::maybe_new(&self.global_scope(), self.ipc_renderer.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
|
||||||
fn CreateTexture(&self) -> Option<Root<WebGLTexture>> {
|
fn CreateTexture(&self) -> Option<Root<WebGLTexture>> {
|
||||||
WebGLTexture::maybe_new(self.global().r().as_global_scope(), self.ipc_renderer.clone())
|
WebGLTexture::maybe_new(&self.global_scope(), self.ipc_renderer.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||||
fn CreateProgram(&self) -> Option<Root<WebGLProgram>> {
|
fn CreateProgram(&self) -> Option<Root<WebGLProgram>> {
|
||||||
WebGLProgram::maybe_new(self.global().r().as_global_scope(), self.ipc_renderer.clone())
|
WebGLProgram::maybe_new(&self.global_scope(), self.ipc_renderer.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||||
|
@ -1186,7 +1186,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WebGLShader::maybe_new(self.global().r().as_global_scope(), self.ipc_renderer.clone(), shader_type)
|
WebGLShader::maybe_new(&self.global_scope(), self.ipc_renderer.clone(), shader_type)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
|
||||||
|
@ -1480,7 +1480,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
||||||
name: DOMString) -> Option<Root<WebGLUniformLocation>> {
|
name: DOMString) -> Option<Root<WebGLUniformLocation>> {
|
||||||
program.and_then(|p| {
|
program.and_then(|p| {
|
||||||
handle_potential_webgl_error!(self, p.get_uniform_location(name), None)
|
handle_potential_webgl_error!(self, p.get_uniform_location(name), None)
|
||||||
.map(|location| WebGLUniformLocation::new(self.global().r().as_global_scope(), location, p.id()))
|
.map(|location| WebGLUniformLocation::new(&self.global_scope(), location, p.id()))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -535,8 +535,6 @@ impl Runnable for CloseTask {
|
||||||
|
|
||||||
fn handler(self: Box<Self>) {
|
fn handler(self: Box<Self>) {
|
||||||
let ws = self.address.root();
|
let ws = self.address.root();
|
||||||
let ws = ws.r();
|
|
||||||
let global = ws.global();
|
|
||||||
|
|
||||||
if ws.ready_state.get() == WebSocketRequestState::Closed {
|
if ws.ready_state.get() == WebSocketRequestState::Closed {
|
||||||
// Do nothing if already closed.
|
// Do nothing if already closed.
|
||||||
|
@ -558,7 +556,7 @@ impl Runnable for CloseTask {
|
||||||
let clean_close = !self.failed;
|
let clean_close = !self.failed;
|
||||||
let code = self.code.unwrap_or(close_code::NO_STATUS);
|
let code = self.code.unwrap_or(close_code::NO_STATUS);
|
||||||
let reason = DOMString::from(self.reason.unwrap_or("".to_owned()));
|
let reason = DOMString::from(self.reason.unwrap_or("".to_owned()));
|
||||||
let close_event = CloseEvent::new(global.r().as_global_scope(),
|
let close_event = CloseEvent::new(&ws.global_scope(),
|
||||||
atom!("close"),
|
atom!("close"),
|
||||||
EventBubbles::DoesNotBubble,
|
EventBubbles::DoesNotBubble,
|
||||||
EventCancelable::NotCancelable,
|
EventCancelable::NotCancelable,
|
||||||
|
|
|
@ -283,8 +283,7 @@ impl LoadOrigin for XMLHttpRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pipeline_id(&self) -> Option<PipelineId> {
|
fn pipeline_id(&self) -> Option<PipelineId> {
|
||||||
let global = self.global();
|
Some(self.global_scope().pipeline_id())
|
||||||
Some(global.r().as_global_scope().pipeline_id())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -859,8 +858,7 @@ impl XMLHttpRequest {
|
||||||
fn change_ready_state(&self, rs: XMLHttpRequestState) {
|
fn change_ready_state(&self, rs: XMLHttpRequestState) {
|
||||||
assert!(self.ready_state.get() != rs);
|
assert!(self.ready_state.get() != rs);
|
||||||
self.ready_state.set(rs);
|
self.ready_state.set(rs);
|
||||||
let global = self.global();
|
let event = Event::new(&self.global_scope(),
|
||||||
let event = Event::new(global.r().as_global_scope(),
|
|
||||||
atom!("readystatechange"),
|
atom!("readystatechange"),
|
||||||
EventBubbles::DoesNotBubble,
|
EventBubbles::DoesNotBubble,
|
||||||
EventCancelable::Cancelable);
|
EventCancelable::Cancelable);
|
||||||
|
@ -1049,8 +1047,7 @@ impl XMLHttpRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dispatch_progress_event(&self, upload: bool, type_: Atom, loaded: u64, total: Option<u64>) {
|
fn dispatch_progress_event(&self, upload: bool, type_: Atom, loaded: u64, total: Option<u64>) {
|
||||||
let global = self.global();
|
let progressevent = ProgressEvent::new(&self.global_scope(),
|
||||||
let progressevent = ProgressEvent::new(global.r().as_global_scope(),
|
|
||||||
type_,
|
type_,
|
||||||
EventBubbles::DoesNotBubble,
|
EventBubbles::DoesNotBubble,
|
||||||
EventCancelable::NotCancelable,
|
EventCancelable::NotCancelable,
|
||||||
|
@ -1118,7 +1115,7 @@ impl XMLHttpRequest {
|
||||||
|
|
||||||
// Step 3, 4
|
// Step 3, 4
|
||||||
let bytes = self.response.borrow().to_vec();
|
let bytes = self.response.borrow().to_vec();
|
||||||
let blob = Blob::new(self.global().r().as_global_scope(), BlobImpl::new_from_bytes(bytes), mime);
|
let blob = Blob::new(&self.global_scope(), BlobImpl::new_from_bytes(bytes), mime);
|
||||||
self.response_blob.set(Some(blob.r()));
|
self.response_blob.set(Some(blob.r()));
|
||||||
blob
|
blob
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue