mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Make reflect_dom_object take a &GlobalScope
This commit is contained in:
parent
093b189b48
commit
fcb59d3057
132 changed files with 488 additions and 407 deletions
|
@ -4,12 +4,12 @@
|
|||
|
||||
use dom::bindings::codegen::Bindings::FormDataBinding::FormDataMethods;
|
||||
use dom::bindings::error::{Error, Fallible};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::Reflectable;
|
||||
use dom::bindings::str::USVString;
|
||||
use dom::blob::{Blob, BlobImpl};
|
||||
use dom::formdata::FormData;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::promise::Promise;
|
||||
use encoding::all::UTF_8;
|
||||
use encoding::types::{DecoderTrap, Encoding};
|
||||
|
@ -103,8 +103,8 @@ fn run_package_data_algorithm<T: BodyOperations + Reflectable>(object: &T,
|
|||
match body_type {
|
||||
BodyType::Text => run_text_data_algorithm(bytes),
|
||||
BodyType::Json => run_json_data_algorithm(cx, bytes),
|
||||
BodyType::Blob => run_blob_data_algorithm(object.global().r(), bytes, mime),
|
||||
BodyType::FormData => run_form_data_algorithm(object.global().r(), bytes, mime),
|
||||
BodyType::Blob => run_blob_data_algorithm(object.global().r().as_global_scope(), bytes, mime),
|
||||
BodyType::FormData => run_form_data_algorithm(object.global().r().as_global_scope(), bytes, mime),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ fn run_json_data_algorithm(cx: *mut JSContext,
|
|||
}
|
||||
}
|
||||
|
||||
fn run_blob_data_algorithm(root: GlobalRef,
|
||||
fn run_blob_data_algorithm(root: &GlobalScope,
|
||||
bytes: Vec<u8>,
|
||||
mime: &[u8]) -> Fallible<FetchedData> {
|
||||
let mime_string = if let Ok(s) = String::from_utf8(mime.to_vec()) {
|
||||
|
@ -144,7 +144,7 @@ fn run_blob_data_algorithm(root: GlobalRef,
|
|||
Ok(FetchedData::BlobData(blob))
|
||||
}
|
||||
|
||||
fn run_form_data_algorithm(root: GlobalRef, bytes: Vec<u8>, mime: &[u8]) -> Fallible<FetchedData> {
|
||||
fn run_form_data_algorithm(root: &GlobalScope, bytes: Vec<u8>, mime: &[u8]) -> Fallible<FetchedData> {
|
||||
let mime_str = if let Ok(s) = str::from_utf8(mime) {
|
||||
s
|
||||
} else {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
use devtools_traits::AttrInfo;
|
||||
use dom::bindings::cell::DOMRefCell;
|
||||
use dom::bindings::codegen::Bindings::AttrBinding::{self, AttrMethods};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::{JS, MutNullableHeap};
|
||||
use dom::bindings::js::{LayoutJS, Root, RootedReference};
|
||||
|
@ -66,7 +65,7 @@ impl Attr {
|
|||
namespace,
|
||||
prefix,
|
||||
owner),
|
||||
GlobalRef::Window(window),
|
||||
window,
|
||||
AttrBinding::Wrap)
|
||||
}
|
||||
|
||||
|
|
|
@ -6,12 +6,12 @@ use dom::bindings::cell::DOMRefCell;
|
|||
use dom::bindings::codegen::Bindings::BeforeUnloadEventBinding;
|
||||
use dom::bindings::codegen::Bindings::BeforeUnloadEventBinding::BeforeUnloadEventMethods;
|
||||
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use string_cache::Atom;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#beforeunloadevent
|
||||
|
@ -29,13 +29,13 @@ impl BeforeUnloadEvent {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new_uninitialized(global: GlobalRef) -> Root<BeforeUnloadEvent> {
|
||||
pub fn new_uninitialized(global: &GlobalScope) -> Root<BeforeUnloadEvent> {
|
||||
reflect_dom_object(box BeforeUnloadEvent::new_inherited(),
|
||||
global,
|
||||
BeforeUnloadEventBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef,
|
||||
pub fn new(global: &GlobalScope,
|
||||
type_: Atom,
|
||||
bubbles: EventBubbles,
|
||||
cancelable: EventCancelable) -> Root<BeforeUnloadEvent> {
|
||||
|
|
|
@ -1927,8 +1927,10 @@ class CGImports(CGWrapper):
|
|||
if t in dictionaries or t in enums:
|
||||
continue
|
||||
if t.isInterface() or t.isNamespace():
|
||||
descriptor = descriptorProvider.getDescriptor(getIdentifier(t).name)
|
||||
extras += [descriptor.path]
|
||||
name = getIdentifier(t).name
|
||||
descriptor = descriptorProvider.getDescriptor(name)
|
||||
if name != 'GlobalScope':
|
||||
extras += [descriptor.path]
|
||||
parentName = descriptor.getParentName()
|
||||
if parentName:
|
||||
descriptor = descriptorProvider.getDescriptor(parentName)
|
||||
|
@ -2523,7 +2525,8 @@ class CGWrapMethod(CGAbstractMethod):
|
|||
def __init__(self, descriptor):
|
||||
assert not descriptor.interface.isCallback()
|
||||
assert not descriptor.isGlobal()
|
||||
args = [Argument('*mut JSContext', 'cx'), Argument('GlobalRef', 'scope'),
|
||||
args = [Argument('*mut JSContext', 'cx'),
|
||||
Argument('&GlobalScope', 'scope'),
|
||||
Argument("Box<%s>" % descriptor.concreteType, 'object')]
|
||||
retval = 'Root<%s>' % descriptor.concreteType
|
||||
CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args,
|
||||
|
@ -5594,6 +5597,7 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
|||
'dom::bindings::weakref::WeakBox',
|
||||
'dom::bindings::weakref::WeakReferenceable',
|
||||
'dom::browsingcontext::BrowsingContext',
|
||||
'dom::globalscope::GlobalScope',
|
||||
'mem::heap_size_of_raw_self_and_children',
|
||||
'libc',
|
||||
'util::prefs::PREFS',
|
||||
|
|
|
@ -127,7 +127,7 @@ pub unsafe fn throw_dom_exception(cx: *mut JSContext, global: GlobalRef, result:
|
|||
};
|
||||
|
||||
assert!(!JS_IsExceptionPending(cx));
|
||||
let exception = DOMException::new(global, code);
|
||||
let exception = DOMException::new(global.as_global_scope(), code);
|
||||
rooted!(in(cx) let mut thrown = UndefinedValue());
|
||||
exception.to_jsval(cx, thrown.handle_mut());
|
||||
JS_SetPendingException(cx, thrown.handle());
|
||||
|
|
|
@ -11,9 +11,11 @@ use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId};
|
|||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||
use dom::bindings::conversions::root_from_object;
|
||||
use dom::bindings::error::{ErrorInfo, report_pending_exception};
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflectable, Reflector};
|
||||
use dom::console::TimerSet;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::window;
|
||||
use dom::workerglobalscope::WorkerGlobalScope;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
|
@ -55,6 +57,14 @@ pub enum GlobalRoot {
|
|||
}
|
||||
|
||||
impl<'a> GlobalRef<'a> {
|
||||
/// Returns that `GlobalRef` as a `GlobalScope` referengce.
|
||||
pub fn as_global_scope(&self) -> &GlobalScope {
|
||||
match *self {
|
||||
GlobalRef::Window(window) => window.upcast(),
|
||||
GlobalRef::Worker(worker) => worker.upcast(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the `JSContext` for the `JSRuntime` associated with the thread
|
||||
/// this global object is on.
|
||||
pub fn get_cx(&self) -> *mut JSContext {
|
||||
|
|
|
@ -10,10 +10,10 @@ use core::nonzero::NonZero;
|
|||
use dom::bindings::codegen::Bindings::IterableIteratorBinding::IterableKeyAndValueResult;
|
||||
use dom::bindings::codegen::Bindings::IterableIteratorBinding::IterableKeyOrValueResult;
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::reflector::{Reflector, Reflectable, MutReflectable, reflect_dom_object};
|
||||
use dom::bindings::trace::JSTraceable;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use js::conversions::ToJSValConvertible;
|
||||
use js::jsapi::{JSContext, JSObject, MutableHandleValue, MutableHandleObject, HandleValue};
|
||||
use js::jsval::UndefinedValue;
|
||||
|
@ -85,7 +85,7 @@ impl<T: Reflectable + JSTraceable + Iterable> IterableIterator<T> {
|
|||
/// Create a new iterator instance for the provided iterable DOM interface.
|
||||
pub fn new(iterable: &T,
|
||||
type_: IteratorType,
|
||||
wrap: fn(*mut JSContext, GlobalRef, Box<IterableIterator<T>>)
|
||||
wrap: fn(*mut JSContext, &GlobalScope, Box<IterableIterator<T>>)
|
||||
-> Root<Self>) -> Root<Self> {
|
||||
let iterator = box IterableIterator {
|
||||
reflector: Reflector::new(),
|
||||
|
@ -94,7 +94,7 @@ impl<T: Reflectable + JSTraceable + Iterable> IterableIterator<T> {
|
|||
index: Cell::new(0),
|
||||
};
|
||||
let global = iterable.global();
|
||||
reflect_dom_object(iterator, global.r(), wrap)
|
||||
reflect_dom_object(iterator, global.r().as_global_scope(), wrap)
|
||||
}
|
||||
|
||||
/// Return the next value from the iterable object.
|
||||
|
|
|
@ -4,19 +4,25 @@
|
|||
|
||||
//! The `Reflector` struct.
|
||||
|
||||
use dom::bindings::global::{GlobalRef, GlobalRoot, global_root_from_reflector};
|
||||
use dom::bindings::conversions::DerivedFrom;
|
||||
use dom::bindings::global::{GlobalRoot, global_root_from_reflector};
|
||||
use dom::bindings::js::Root;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use js::jsapi::{HandleObject, JSContext, JSObject};
|
||||
use std::cell::UnsafeCell;
|
||||
use std::ptr;
|
||||
|
||||
/// Create the reflector for a new DOM object and yield ownership to the
|
||||
/// reflector.
|
||||
pub fn reflect_dom_object<T: Reflectable>(obj: Box<T>,
|
||||
global: GlobalRef,
|
||||
wrap_fn: fn(*mut JSContext, GlobalRef, Box<T>) -> Root<T>)
|
||||
-> Root<T> {
|
||||
wrap_fn(global.get_cx(), global, obj)
|
||||
pub fn reflect_dom_object<T, U>(
|
||||
obj: Box<T>,
|
||||
global: &U,
|
||||
wrap_fn: fn(*mut JSContext, &GlobalScope, Box<T>) -> Root<T>)
|
||||
-> Root<T>
|
||||
where T: Reflectable, U: DerivedFrom<GlobalScope>
|
||||
{
|
||||
let global_scope = global.upcast();
|
||||
wrap_fn(global_scope.get_cx(), global_scope, obj)
|
||||
}
|
||||
|
||||
/// A struct to store a reference to the reflector of a DOM object.
|
||||
|
|
|
@ -11,6 +11,7 @@ use dom::bindings::global::GlobalRef;
|
|||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use encoding::all::UTF_8;
|
||||
use encoding::types::{EncoderTrap, Encoding};
|
||||
use ipc_channel::ipc;
|
||||
|
@ -79,7 +80,9 @@ pub struct Blob {
|
|||
|
||||
impl Blob {
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn new(global: GlobalRef, blob_impl: BlobImpl, typeString: String) -> Root<Blob> {
|
||||
pub fn new(
|
||||
global: &GlobalScope, blob_impl: BlobImpl, typeString: String)
|
||||
-> Root<Blob> {
|
||||
let boxed_blob = box Blob::new_inherited(blob_impl, typeString);
|
||||
reflect_dom_object(boxed_blob, global, BlobBinding::Wrap)
|
||||
}
|
||||
|
@ -99,7 +102,6 @@ impl Blob {
|
|||
#[allow(unrooted_must_root)]
|
||||
fn new_sliced(parent: &Blob, rel_pos: RelativePos,
|
||||
relative_content_type: DOMString) -> Root<Blob> {
|
||||
let global = parent.global();
|
||||
let blob_impl = match *parent.blob_impl.borrow() {
|
||||
BlobImpl::File(_) => {
|
||||
// Create new parent node
|
||||
|
@ -115,7 +117,7 @@ impl Blob {
|
|||
}
|
||||
};
|
||||
|
||||
Blob::new(global.r(), blob_impl, relative_content_type.into())
|
||||
Blob::new(parent.global().r().as_global_scope(), blob_impl, relative_content_type.into())
|
||||
}
|
||||
|
||||
// https://w3c.github.io/FileAPI/#constructorBlob
|
||||
|
@ -132,7 +134,7 @@ impl Blob {
|
|||
}
|
||||
};
|
||||
|
||||
Ok(Blob::new(global, BlobImpl::new_from_bytes(bytes), blobPropertyBag.type_.to_string()))
|
||||
Ok(Blob::new(global.as_global_scope(), BlobImpl::new_from_bytes(bytes), blobPropertyBag.type_.to_string()))
|
||||
}
|
||||
|
||||
/// Get a slice to inner data, this might incur synchronous read and caching
|
||||
|
|
|
@ -15,6 +15,7 @@ use dom::bindings::str::DOMString;
|
|||
use dom::bluetoothadvertisingdata::BluetoothAdvertisingData;
|
||||
use dom::bluetoothdevice::BluetoothDevice;
|
||||
use dom::bluetoothuuid::{BluetoothServiceUUID, BluetoothUUID};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::promise::Promise;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use js::conversions::ToJSValConvertible;
|
||||
|
@ -52,7 +53,7 @@ impl Bluetooth {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef) -> Root<Bluetooth> {
|
||||
pub fn new(global: &GlobalScope) -> Root<Bluetooth> {
|
||||
reflect_dom_object(box Bluetooth::new_inherited(),
|
||||
global,
|
||||
BluetoothBinding::Wrap)
|
||||
|
@ -105,11 +106,14 @@ impl Bluetooth {
|
|||
// Step 12-13.
|
||||
match device {
|
||||
Ok(device) => {
|
||||
let ad_data = BluetoothAdvertisingData::new(self.global().r(),
|
||||
let global = self.global();
|
||||
let global = global.r();
|
||||
let global = global.as_global_scope();
|
||||
let ad_data = BluetoothAdvertisingData::new(global,
|
||||
device.appearance,
|
||||
device.tx_power,
|
||||
device.rssi);
|
||||
Ok(BluetoothDevice::new(self.global().r(),
|
||||
Ok(BluetoothDevice::new(global,
|
||||
DOMString::from(device.id),
|
||||
device.name.map(DOMString::from),
|
||||
&ad_data))
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
use dom::bindings::codegen::Bindings::BluetoothAdvertisingDataBinding;
|
||||
use dom::bindings::codegen::Bindings::BluetoothAdvertisingDataBinding::BluetoothAdvertisingDataMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::globalscope::GlobalScope;
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothadvertisingdata
|
||||
#[dom_struct]
|
||||
|
@ -30,7 +30,7 @@ impl BluetoothAdvertisingData {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef,
|
||||
pub fn new(global: &GlobalScope,
|
||||
appearance: Option<u16>,
|
||||
txPower: Option<i8>,
|
||||
rssi: Option<i8>)
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
use dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding;
|
||||
use dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding::
|
||||
BluetoothCharacteristicPropertiesMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::globalscope::GlobalScope;
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#characteristicproperties
|
||||
#[dom_struct]
|
||||
|
@ -49,7 +49,7 @@ impl BluetoothCharacteristicProperties {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef,
|
||||
pub fn new(global: &GlobalScope,
|
||||
broadcast: bool,
|
||||
read: bool,
|
||||
writeWithoutResponse: bool,
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
|
||||
use dom::bindings::codegen::Bindings::BluetoothDeviceBinding;
|
||||
use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, Root, MutHeap, MutNullableHeap};
|
||||
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::bluetoothadvertisingdata::BluetoothAdvertisingData;
|
||||
use dom::bluetoothremotegattserver::BluetoothRemoteGATTServer;
|
||||
use dom::globalscope::GlobalScope;
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothdevice
|
||||
#[dom_struct]
|
||||
|
@ -35,7 +35,7 @@ impl BluetoothDevice {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef,
|
||||
pub fn new(global: &GlobalScope,
|
||||
id: DOMString,
|
||||
name: Option<DOMString>,
|
||||
adData: &BluetoothAdvertisingData)
|
||||
|
@ -66,6 +66,8 @@ impl BluetoothDeviceMethods for BluetoothDevice {
|
|||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-gatt
|
||||
fn Gatt(&self) -> Root<BluetoothRemoteGATTServer> {
|
||||
self.gatt.or_init(|| BluetoothRemoteGATTServer::new(self.global().r(), self))
|
||||
self.gatt.or_init(|| {
|
||||
BluetoothRemoteGATTServer::new(self.global().r().as_global_scope(), self)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::Bluetoot
|
|||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
|
||||
use dom::bindings::error::{ErrorResult, Fallible};
|
||||
use dom::bindings::error::Error::{self, InvalidModification, Network, NotSupported, Security};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, MutHeap, Root};
|
||||
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::{ByteString, DOMString};
|
||||
|
@ -23,6 +22,7 @@ use dom::bluetoothcharacteristicproperties::BluetoothCharacteristicProperties;
|
|||
use dom::bluetoothremotegattdescriptor::BluetoothRemoteGATTDescriptor;
|
||||
use dom::bluetoothremotegattservice::BluetoothRemoteGATTService;
|
||||
use dom::bluetoothuuid::{BluetoothDescriptorUUID, BluetoothUUID};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::promise::Promise;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use net_traits::bluetooth_thread::BluetoothMethodMsg;
|
||||
|
@ -59,7 +59,7 @@ impl BluetoothRemoteGATTCharacteristic {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef,
|
||||
pub fn new(global: &GlobalScope,
|
||||
service: &BluetoothRemoteGATTService,
|
||||
uuid: DOMString,
|
||||
properties: &BluetoothCharacteristicProperties,
|
||||
|
@ -95,7 +95,7 @@ impl BluetoothRemoteGATTCharacteristic {
|
|||
let descriptor = receiver.recv().unwrap();
|
||||
match descriptor {
|
||||
Ok(descriptor) => {
|
||||
Ok(BluetoothRemoteGATTDescriptor::new(self.global().r(),
|
||||
Ok(BluetoothRemoteGATTDescriptor::new(self.global().r().as_global_scope(),
|
||||
self,
|
||||
DOMString::from(descriptor.uuid),
|
||||
descriptor.instance_id))
|
||||
|
@ -126,7 +126,7 @@ impl BluetoothRemoteGATTCharacteristic {
|
|||
match descriptors_vec {
|
||||
Ok(descriptor_vec) => {
|
||||
Ok(descriptor_vec.into_iter()
|
||||
.map(|desc| BluetoothRemoteGATTDescriptor::new(self.global().r(),
|
||||
.map(|desc| BluetoothRemoteGATTDescriptor::new(self.global().r().as_global_scope(),
|
||||
self,
|
||||
DOMString::from(desc.uuid),
|
||||
desc.instance_id))
|
||||
|
|
|
@ -13,12 +13,12 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::Bluetoot
|
|||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
|
||||
use dom::bindings::error::{ErrorResult, Fallible};
|
||||
use dom::bindings::error::Error::{self, InvalidModification, Network, Security};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, MutHeap, Root};
|
||||
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::{ByteString, DOMString};
|
||||
use dom::bluetooth::result_to_promise;
|
||||
use dom::bluetoothremotegattcharacteristic::{BluetoothRemoteGATTCharacteristic, MAXIMUM_ATTRIBUTE_LENGTH};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::promise::Promise;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use net_traits::bluetooth_thread::BluetoothMethodMsg;
|
||||
|
@ -48,7 +48,7 @@ impl BluetoothRemoteGATTDescriptor {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef,
|
||||
pub fn new(global: &GlobalScope,
|
||||
characteristic: &BluetoothRemoteGATTCharacteristic,
|
||||
uuid: DOMString,
|
||||
instanceID: String)
|
||||
|
|
|
@ -8,7 +8,6 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding;
|
|||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods;
|
||||
use dom::bindings::error::{ErrorResult, Fallible};
|
||||
use dom::bindings::error::Error::{self, Security};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, MutHeap, Root};
|
||||
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::DOMString;
|
||||
|
@ -16,6 +15,7 @@ use dom::bluetooth::result_to_promise;
|
|||
use dom::bluetoothdevice::BluetoothDevice;
|
||||
use dom::bluetoothremotegattservice::BluetoothRemoteGATTService;
|
||||
use dom::bluetoothuuid::{BluetoothServiceUUID, BluetoothUUID};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::promise::Promise;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use net_traits::bluetooth_thread::BluetoothMethodMsg;
|
||||
|
@ -39,10 +39,10 @@ impl BluetoothRemoteGATTServer {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef, device: &BluetoothDevice) -> Root<BluetoothRemoteGATTServer> {
|
||||
pub fn new(global: &GlobalScope, device: &BluetoothDevice) -> Root<BluetoothRemoteGATTServer> {
|
||||
reflect_dom_object(box BluetoothRemoteGATTServer::new_inherited(device),
|
||||
global,
|
||||
BluetoothRemoteGATTServerBinding::Wrap)
|
||||
global,
|
||||
BluetoothRemoteGATTServerBinding::Wrap)
|
||||
}
|
||||
|
||||
fn get_bluetooth_thread(&self) -> IpcSender<BluetoothMethodMsg> {
|
||||
|
@ -80,7 +80,7 @@ impl BluetoothRemoteGATTServer {
|
|||
let service = receiver.recv().unwrap();
|
||||
match service {
|
||||
Ok(service) => {
|
||||
Ok(BluetoothRemoteGATTService::new(self.global().r(),
|
||||
Ok(BluetoothRemoteGATTService::new(self.global().r().as_global_scope(),
|
||||
&self.device.get(),
|
||||
DOMString::from(service.uuid),
|
||||
service.is_primary,
|
||||
|
@ -112,7 +112,7 @@ impl BluetoothRemoteGATTServer {
|
|||
match services_vec {
|
||||
Ok(service_vec) => {
|
||||
Ok(service_vec.into_iter()
|
||||
.map(|service| BluetoothRemoteGATTService::new(self.global().r(),
|
||||
.map(|service| BluetoothRemoteGATTService::new(self.global().r().as_global_scope(),
|
||||
&self.device.get(),
|
||||
DOMString::from(service.uuid),
|
||||
service.is_primary,
|
||||
|
|
|
@ -7,7 +7,6 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding;
|
|||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
|
||||
use dom::bindings::error::Error::{self, Security};
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, MutHeap, Root};
|
||||
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::DOMString;
|
||||
|
@ -16,6 +15,7 @@ use dom::bluetoothcharacteristicproperties::BluetoothCharacteristicProperties;
|
|||
use dom::bluetoothdevice::BluetoothDevice;
|
||||
use dom::bluetoothremotegattcharacteristic::BluetoothRemoteGATTCharacteristic;
|
||||
use dom::bluetoothuuid::{BluetoothCharacteristicUUID, BluetoothServiceUUID, BluetoothUUID};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::promise::Promise;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use net_traits::bluetooth_thread::BluetoothMethodMsg;
|
||||
|
@ -46,7 +46,7 @@ impl BluetoothRemoteGATTService {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef,
|
||||
pub fn new(global: &GlobalScope,
|
||||
device: &BluetoothDevice,
|
||||
uuid: DOMString,
|
||||
isPrimary: bool,
|
||||
|
@ -84,7 +84,10 @@ impl BluetoothRemoteGATTService {
|
|||
let characteristic = receiver.recv().unwrap();
|
||||
match characteristic {
|
||||
Ok(characteristic) => {
|
||||
let properties = BluetoothCharacteristicProperties::new(self.global().r(),
|
||||
let global = self.global();
|
||||
let global = global.r();
|
||||
let global = global.as_global_scope();
|
||||
let properties = BluetoothCharacteristicProperties::new(global,
|
||||
characteristic.broadcast,
|
||||
characteristic.read,
|
||||
characteristic.write_without_response,
|
||||
|
@ -94,7 +97,7 @@ impl BluetoothRemoteGATTService {
|
|||
characteristic.authenticated_signed_writes,
|
||||
characteristic.reliable_write,
|
||||
characteristic.writable_auxiliaries);
|
||||
Ok(BluetoothRemoteGATTCharacteristic::new(self.global().r(),
|
||||
Ok(BluetoothRemoteGATTCharacteristic::new(global,
|
||||
self,
|
||||
DOMString::from(characteristic.uuid),
|
||||
&properties,
|
||||
|
@ -127,7 +130,10 @@ impl BluetoothRemoteGATTService {
|
|||
match characteristics_vec {
|
||||
Ok(characteristic_vec) => {
|
||||
for characteristic in characteristic_vec {
|
||||
let properties = BluetoothCharacteristicProperties::new(self.global().r(),
|
||||
let global = self.global();
|
||||
let global = global.r();
|
||||
let global = global.as_global_scope();
|
||||
let properties = BluetoothCharacteristicProperties::new(global,
|
||||
characteristic.broadcast,
|
||||
characteristic.read,
|
||||
characteristic.write_without_response,
|
||||
|
@ -137,7 +143,7 @@ impl BluetoothRemoteGATTService {
|
|||
characteristic.authenticated_signed_writes,
|
||||
characteristic.reliable_write,
|
||||
characteristic.writable_auxiliaries);
|
||||
characteristics.push(BluetoothRemoteGATTCharacteristic::new(self.global().r(),
|
||||
characteristics.push(BluetoothRemoteGATTCharacteristic::new(global,
|
||||
self,
|
||||
DOMString::from(characteristic.uuid),
|
||||
&properties,
|
||||
|
@ -167,7 +173,7 @@ impl BluetoothRemoteGATTService {
|
|||
let service = receiver.recv().unwrap();
|
||||
match service {
|
||||
Ok(service) => {
|
||||
Ok(BluetoothRemoteGATTService::new(self.global().r(),
|
||||
Ok(BluetoothRemoteGATTService::new(self.global().r().as_global_scope(),
|
||||
&self.device.get(),
|
||||
DOMString::from(service.uuid),
|
||||
service.is_primary,
|
||||
|
@ -201,7 +207,7 @@ impl BluetoothRemoteGATTService {
|
|||
match services_vec {
|
||||
Ok(service_vec) => {
|
||||
Ok(service_vec.into_iter()
|
||||
.map(|service| BluetoothRemoteGATTService::new(self.global().r(),
|
||||
.map(|service| BluetoothRemoteGATTService::new(self.global().r().as_global_scope(),
|
||||
&self.device.get(),
|
||||
DOMString::from(service.uuid),
|
||||
service.is_primary,
|
||||
|
|
|
@ -9,11 +9,11 @@ use dom::bindings::cell::DOMRefCell;
|
|||
use dom::bindings::codegen::Bindings::CanvasGradientBinding;
|
||||
use dom::bindings::codegen::Bindings::CanvasGradientBinding::CanvasGradientMethods;
|
||||
use dom::bindings::error::{Error, ErrorResult};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::num::Finite;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::globalscope::GlobalScope;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#canvasgradient
|
||||
#[dom_struct]
|
||||
|
@ -38,7 +38,7 @@ impl CanvasGradient {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef, style: CanvasGradientStyle) -> Root<CanvasGradient> {
|
||||
pub fn new(global: &GlobalScope, style: CanvasGradientStyle) -> Root<CanvasGradient> {
|
||||
reflect_dom_object(box CanvasGradient::new_inherited(style),
|
||||
global,
|
||||
CanvasGradientBinding::Wrap)
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
use canvas_traits::{FillOrStrokeStyle, RepetitionStyle, SurfaceStyle};
|
||||
use dom::bindings::codegen::Bindings::CanvasPatternBinding;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::canvasgradient::ToFillOrStrokeStyle;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use euclid::size::Size2D;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#canvaspattern
|
||||
|
@ -43,7 +43,7 @@ impl CanvasPattern {
|
|||
origin_clean: origin_clean,
|
||||
}
|
||||
}
|
||||
pub fn new(global: GlobalRef,
|
||||
pub fn new(global: &GlobalScope,
|
||||
surface_data: Vec<u8>,
|
||||
surface_size: Size2D<i32>,
|
||||
repeat: RepetitionStyle,
|
||||
|
|
|
@ -140,7 +140,7 @@ impl CanvasRenderingContext2D {
|
|||
size: Size2D<i32>)
|
||||
-> Root<CanvasRenderingContext2D> {
|
||||
reflect_dom_object(box CanvasRenderingContext2D::new_inherited(global, canvas, size),
|
||||
global,
|
||||
global.as_global_scope(),
|
||||
CanvasRenderingContext2DBinding::Wrap)
|
||||
}
|
||||
|
||||
|
@ -1016,12 +1016,12 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
|
||||
let sw = cmp::max(1, sw.abs().to_u32().unwrap());
|
||||
let sh = cmp::max(1, sh.abs().to_u32().unwrap());
|
||||
Ok(ImageData::new(self.global().r(), sw, sh, None))
|
||||
Ok(ImageData::new(self.global().r().as_global_scope(), sw, sh, None))
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createimagedata
|
||||
fn CreateImageData_(&self, imagedata: &ImageData) -> Fallible<Root<ImageData>> {
|
||||
Ok(ImageData::new(self.global().r(),
|
||||
Ok(ImageData::new(self.global().r().as_global_scope(),
|
||||
imagedata.Width(),
|
||||
imagedata.Height(),
|
||||
None))
|
||||
|
@ -1077,7 +1077,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
chunk[2] = UNPREMULTIPLY_TABLE[256 * alpha + chunk[2] as usize];
|
||||
}
|
||||
|
||||
Ok(ImageData::new(self.global().r(), sw, sh, Some(data)))
|
||||
Ok(ImageData::new(self.global().r().as_global_scope(), sw, sh, Some(data)))
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-putimagedata
|
||||
|
@ -1121,7 +1121,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
x1: Finite<f64>,
|
||||
y1: Finite<f64>)
|
||||
-> Root<CanvasGradient> {
|
||||
CanvasGradient::new(self.global().r(),
|
||||
CanvasGradient::new(self.global().r().as_global_scope(),
|
||||
CanvasGradientStyle::Linear(LinearGradientStyle::new(*x0,
|
||||
*y0,
|
||||
*x1,
|
||||
|
@ -1142,7 +1142,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
return Err(Error::IndexSize);
|
||||
}
|
||||
|
||||
Ok(CanvasGradient::new(self.global().r(),
|
||||
Ok(CanvasGradient::new(self.global().r().as_global_scope(),
|
||||
CanvasGradientStyle::Radial(RadialGradientStyle::new(*x0,
|
||||
*y0,
|
||||
*r0,
|
||||
|
@ -1182,7 +1182,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
}
|
||||
|
||||
if let Ok(rep) = RepetitionStyle::from_str(&repetition) {
|
||||
Ok(CanvasPattern::new(self.global().r(),
|
||||
Ok(CanvasPattern::new(self.global().r().as_global_scope(),
|
||||
image_data,
|
||||
image_size,
|
||||
rep,
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
use dom::bindings::codegen::Bindings::ClientBinding::{ClientMethods, Wrap};
|
||||
use dom::bindings::codegen::Bindings::ClientBinding::FrameType;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::JS;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
|
@ -36,7 +35,9 @@ impl Client {
|
|||
}
|
||||
|
||||
pub fn new(window: &Window) -> Root<Client> {
|
||||
reflect_dom_object(box Client::new_inherited(window.get_url()), GlobalRef::Window(window), Wrap)
|
||||
reflect_dom_object(box Client::new_inherited(window.get_url()),
|
||||
window,
|
||||
Wrap)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ use dom::bindings::js::Root;
|
|||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use string_cache::Atom;
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -32,13 +33,13 @@ impl CloseEvent {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new_uninitialized(global: GlobalRef) -> Root<CloseEvent> {
|
||||
pub fn new_uninitialized(global: &GlobalScope) -> Root<CloseEvent> {
|
||||
reflect_dom_object(box CloseEvent::new_inherited(false, 0, DOMString::new()),
|
||||
global,
|
||||
CloseEventBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef,
|
||||
pub fn new(global: &GlobalScope,
|
||||
type_: Atom,
|
||||
bubbles: EventBubbles,
|
||||
cancelable: EventCancelable,
|
||||
|
@ -63,7 +64,7 @@ impl CloseEvent {
|
|||
-> Fallible<Root<CloseEvent>> {
|
||||
let bubbles = EventBubbles::from(init.parent.bubbles);
|
||||
let cancelable = EventCancelable::from(init.parent.cancelable);
|
||||
Ok(CloseEvent::new(global,
|
||||
Ok(CloseEvent::new(global.as_global_scope(),
|
||||
Atom::from(type_),
|
||||
bubbles,
|
||||
cancelable,
|
||||
|
|
|
@ -8,9 +8,9 @@ use dom::bindings::codegen::Bindings::CryptoBinding;
|
|||
use dom::bindings::codegen::Bindings::CryptoBinding::CryptoMethods;
|
||||
use dom::bindings::conversions::array_buffer_view_data;
|
||||
use dom::bindings::error::{Error, Fallible};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use js::jsapi::{JSContext, JSObject};
|
||||
use js::jsapi::{JS_GetArrayBufferViewType, Type};
|
||||
use rand::{OsRng, Rng};
|
||||
|
@ -33,7 +33,7 @@ impl Crypto {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef) -> Root<Crypto> {
|
||||
pub fn new(global: &GlobalScope) -> Root<Crypto> {
|
||||
reflect_dom_object(box Crypto::new_inherited(), global, CryptoBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
use cssparser::ToCss;
|
||||
use dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::{self, CSSStyleDeclarationMethods};
|
||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
|
@ -71,7 +70,7 @@ impl CSSStyleDeclaration {
|
|||
reflect_dom_object(box CSSStyleDeclaration::new_inherited(owner,
|
||||
pseudo,
|
||||
modification_access),
|
||||
GlobalRef::Window(global),
|
||||
global,
|
||||
CSSStyleDeclarationBinding::Wrap)
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ use dom::bindings::js::{MutHeapJSVal, Root};
|
|||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::event::Event;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use js::jsapi::{HandleValue, JSContext};
|
||||
use js::jsval::JSVal;
|
||||
use string_cache::Atom;
|
||||
|
@ -32,12 +33,12 @@ impl CustomEvent {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new_uninitialized(global: GlobalRef) -> Root<CustomEvent> {
|
||||
pub fn new_uninitialized(global: &GlobalScope) -> Root<CustomEvent> {
|
||||
reflect_dom_object(box CustomEvent::new_inherited(),
|
||||
global,
|
||||
CustomEventBinding::Wrap)
|
||||
}
|
||||
pub fn new(global: GlobalRef,
|
||||
pub fn new(global: &GlobalScope,
|
||||
type_: Atom,
|
||||
bubbles: bool,
|
||||
cancelable: bool,
|
||||
|
@ -52,7 +53,7 @@ impl CustomEvent {
|
|||
type_: DOMString,
|
||||
init: &CustomEventBinding::CustomEventInit)
|
||||
-> Fallible<Root<CustomEvent>> {
|
||||
Ok(CustomEvent::new(global,
|
||||
Ok(CustomEvent::new(global.as_global_scope(),
|
||||
Atom::from(type_),
|
||||
init.parent.bubbles,
|
||||
init.parent.cancelable,
|
||||
|
|
|
@ -1848,7 +1848,7 @@ impl Document {
|
|||
doc_loader,
|
||||
referrer,
|
||||
referrer_policy),
|
||||
GlobalRef::Window(window),
|
||||
window,
|
||||
DocumentBinding::Wrap);
|
||||
{
|
||||
let node = document.upcast::<Node>();
|
||||
|
@ -2325,13 +2325,13 @@ impl DocumentMethods for Document {
|
|||
"mouseevents" | "mouseevent" =>
|
||||
Ok(Root::upcast(MouseEvent::new_uninitialized(&self.window))),
|
||||
"customevent" =>
|
||||
Ok(Root::upcast(CustomEvent::new_uninitialized(GlobalRef::Window(&self.window)))),
|
||||
Ok(Root::upcast(CustomEvent::new_uninitialized(self.window.upcast()))),
|
||||
"htmlevents" | "events" | "event" | "svgevents" =>
|
||||
Ok(Event::new_uninitialized(GlobalRef::Window(&self.window))),
|
||||
Ok(Event::new_uninitialized(&self.window.upcast())),
|
||||
"keyboardevent" =>
|
||||
Ok(Root::upcast(KeyboardEvent::new_uninitialized(&self.window))),
|
||||
"messageevent" =>
|
||||
Ok(Root::upcast(MessageEvent::new_uninitialized(GlobalRef::Window(&self.window)))),
|
||||
Ok(Root::upcast(MessageEvent::new_uninitialized(self.window.upcast()))),
|
||||
"touchevent" =>
|
||||
Ok(Root::upcast(
|
||||
TouchEvent::new_uninitialized(&self.window,
|
||||
|
@ -2341,25 +2341,25 @@ impl DocumentMethods for Document {
|
|||
)
|
||||
)),
|
||||
"webglcontextevent" =>
|
||||
Ok(Root::upcast(WebGLContextEvent::new_uninitialized(GlobalRef::Window(&self.window)))),
|
||||
Ok(Root::upcast(WebGLContextEvent::new_uninitialized(self.window.upcast()))),
|
||||
"storageevent" => {
|
||||
let USVString(url) = self.URL();
|
||||
Ok(Root::upcast(StorageEvent::new_uninitialized(&self.window, DOMString::from(url))))
|
||||
},
|
||||
"progressevent" =>
|
||||
Ok(Root::upcast(ProgressEvent::new_uninitialized(&self.window))),
|
||||
Ok(Root::upcast(ProgressEvent::new_uninitialized(self.window.upcast()))),
|
||||
"focusevent" =>
|
||||
Ok(Root::upcast(FocusEvent::new_uninitialized(GlobalRef::Window(&self.window)))),
|
||||
Ok(Root::upcast(FocusEvent::new_uninitialized(self.window.upcast()))),
|
||||
"errorevent" =>
|
||||
Ok(Root::upcast(ErrorEvent::new_uninitialized(GlobalRef::Window(&self.window)))),
|
||||
Ok(Root::upcast(ErrorEvent::new_uninitialized(self.window.upcast()))),
|
||||
"closeevent" =>
|
||||
Ok(Root::upcast(CloseEvent::new_uninitialized(GlobalRef::Window(&self.window)))),
|
||||
Ok(Root::upcast(CloseEvent::new_uninitialized(self.window.upcast()))),
|
||||
"popstateevent" =>
|
||||
Ok(Root::upcast(PopStateEvent::new_uninitialized(GlobalRef::Window(&self.window)))),
|
||||
Ok(Root::upcast(PopStateEvent::new_uninitialized(self.window.upcast()))),
|
||||
"hashchangeevent" =>
|
||||
Ok(Root::upcast(HashChangeEvent::new_uninitialized(GlobalRef::Window(&self.window)))),
|
||||
Ok(Root::upcast(HashChangeEvent::new_uninitialized(&self.window.upcast()))),
|
||||
"pagetransitionevent" =>
|
||||
Ok(Root::upcast(PageTransitionEvent::new_uninitialized(GlobalRef::Window(&self.window)))),
|
||||
Ok(Root::upcast(PageTransitionEvent::new_uninitialized(self.window.upcast()))),
|
||||
_ =>
|
||||
Err(Error::NotSupported),
|
||||
}
|
||||
|
@ -2993,7 +2993,7 @@ impl DocumentProgressHandler {
|
|||
fn dispatch_load(&self) {
|
||||
let document = self.addr.root();
|
||||
let window = document.window();
|
||||
let event = Event::new(GlobalRef::Window(window),
|
||||
let event = Event::new(window.upcast(),
|
||||
atom!("load"),
|
||||
EventBubbles::DoesNotBubble,
|
||||
EventCancelable::NotCancelable);
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
use dom::bindings::codegen::Bindings::DOMExceptionBinding;
|
||||
use dom::bindings::codegen::Bindings::DOMExceptionBinding::DOMExceptionConstants;
|
||||
use dom::bindings::codegen::Bindings::DOMExceptionBinding::DOMExceptionMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::globalscope::GlobalScope;
|
||||
|
||||
#[repr(u16)]
|
||||
#[derive(JSTraceable, Copy, Clone, Debug, HeapSizeOf)]
|
||||
|
@ -52,7 +52,7 @@ impl DOMException {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef, code: DOMErrorName) -> Root<DOMException> {
|
||||
pub fn new(global: &GlobalScope, code: DOMErrorName) -> Root<DOMException> {
|
||||
reflect_dom_object(box DOMException::new_inherited(code),
|
||||
global,
|
||||
DOMExceptionBinding::Wrap)
|
||||
|
|
|
@ -8,7 +8,6 @@ use dom::bindings::codegen::Bindings::DOMImplementationBinding::DOMImplementatio
|
|||
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
||||
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
|
@ -43,7 +42,7 @@ impl DOMImplementation {
|
|||
pub fn new(document: &Document) -> Root<DOMImplementation> {
|
||||
let window = document.window();
|
||||
reflect_dom_object(box DOMImplementation::new_inherited(document),
|
||||
GlobalRef::Window(window),
|
||||
window,
|
||||
DOMImplementationBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ use dom::bindings::inheritance::Castable;
|
|||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::dommatrixreadonly::{dommatrixinit_to_matrix, DOMMatrixReadOnly, entries_to_matrix};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use euclid::Matrix4D;
|
||||
|
||||
|
||||
|
@ -20,7 +21,7 @@ pub struct DOMMatrix {
|
|||
|
||||
impl DOMMatrix {
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn new(global: GlobalRef, is2D: bool, matrix: Matrix4D<f64>) -> Root<Self> {
|
||||
pub fn new(global: &GlobalScope, is2D: bool, matrix: Matrix4D<f64>) -> Root<Self> {
|
||||
let dommatrix = Self::new_inherited(is2D, matrix);
|
||||
reflect_dom_object(box dommatrix, global, Wrap)
|
||||
}
|
||||
|
@ -40,7 +41,7 @@ impl DOMMatrix {
|
|||
pub fn Constructor_(global: GlobalRef, entries: Vec<f64>) -> Fallible<Root<Self>> {
|
||||
entries_to_matrix(&entries[..])
|
||||
.map(|(is2D, matrix)| {
|
||||
Self::new(global, is2D, matrix)
|
||||
Self::new(global.as_global_scope(), is2D, matrix)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -48,11 +49,11 @@ impl DOMMatrix {
|
|||
pub fn FromMatrix(global: GlobalRef, other: &DOMMatrixInit) -> Fallible<Root<Self>> {
|
||||
dommatrixinit_to_matrix(&other)
|
||||
.map(|(is2D, matrix)| {
|
||||
Self::new(global, is2D, matrix)
|
||||
Self::new(global.as_global_scope(), is2D, matrix)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn from_readonly(global: GlobalRef, ro: &DOMMatrixReadOnly) -> Root<Self> {
|
||||
pub fn from_readonly(global: &GlobalScope, ro: &DOMMatrixReadOnly) -> Root<Self> {
|
||||
Self::new(global, ro.is_2d(), ro.matrix().clone())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ use dom::bindings::js::Root;
|
|||
use dom::bindings::reflector::{reflect_dom_object, Reflectable, Reflector};
|
||||
use dom::dommatrix::DOMMatrix;
|
||||
use dom::dompoint::DOMPoint;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use euclid::{Matrix4D, Point4D, Radians};
|
||||
use std::cell::{Cell, Ref};
|
||||
use std::f64;
|
||||
|
@ -26,7 +27,7 @@ pub struct DOMMatrixReadOnly {
|
|||
|
||||
impl DOMMatrixReadOnly {
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn new(global: GlobalRef, is2D: bool, matrix: Matrix4D<f64>) -> Root<Self> {
|
||||
pub fn new(global: &GlobalScope, is2D: bool, matrix: Matrix4D<f64>) -> Root<Self> {
|
||||
let dommatrix = Self::new_inherited(is2D, matrix);
|
||||
reflect_dom_object(box dommatrix, global, Wrap)
|
||||
}
|
||||
|
@ -41,14 +42,14 @@ impl DOMMatrixReadOnly {
|
|||
|
||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly
|
||||
pub fn Constructor(global: GlobalRef) -> Fallible<Root<Self>> {
|
||||
Ok(Self::new(global, true, Matrix4D::identity()))
|
||||
Ok(Self::new(global.as_global_scope(), true, Matrix4D::identity()))
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly-numbersequence
|
||||
pub fn Constructor_(global: GlobalRef, entries: Vec<f64>) -> Fallible<Root<Self>> {
|
||||
entries_to_matrix(&entries[..])
|
||||
.map(|(is2D, matrix)| {
|
||||
Self::new(global, is2D, matrix)
|
||||
Self::new(global.as_global_scope(), is2D, matrix)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -56,7 +57,7 @@ impl DOMMatrixReadOnly {
|
|||
pub fn FromMatrix(global: GlobalRef, other: &DOMMatrixInit) -> Fallible<Root<Self>> {
|
||||
dommatrixinit_to_matrix(&other)
|
||||
.map(|(is2D, matrix)| {
|
||||
Self::new(global, is2D, matrix)
|
||||
Self::new(global.as_global_scope(), is2D, matrix)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -463,48 +464,50 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
|
|||
|
||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-translate
|
||||
fn Translate(&self, tx: f64, ty: f64, tz: f64) -> Root<DOMMatrix> {
|
||||
DOMMatrix::from_readonly(self.global().r(), self).TranslateSelf(tx, ty, tz)
|
||||
DOMMatrix::from_readonly(self.global().r().as_global_scope(), self).TranslateSelf(tx, ty, tz)
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-scale
|
||||
fn Scale(&self, scaleX: f64, scaleY: Option<f64>, scaleZ: f64,
|
||||
originX: f64, originY: f64, originZ: f64) -> Root<DOMMatrix> {
|
||||
DOMMatrix::from_readonly(self.global().r(), self).ScaleSelf(scaleX, scaleY, scaleZ, originX, originY, originZ)
|
||||
DOMMatrix::from_readonly(self.global().r().as_global_scope(), self)
|
||||
.ScaleSelf(scaleX, scaleY, scaleZ, originX, originY, originZ)
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-scale3d
|
||||
fn Scale3d(&self, scale: f64, originX: f64, originY: f64, originZ: f64) -> Root<DOMMatrix> {
|
||||
DOMMatrix::from_readonly(self.global().r(), self).Scale3dSelf(scale, originX, originY, originZ)
|
||||
DOMMatrix::from_readonly(self.global().r().as_global_scope(), self)
|
||||
.Scale3dSelf(scale, originX, originY, originZ)
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotate
|
||||
fn Rotate(&self, rotX: f64, rotY: Option<f64>, rotZ: Option<f64>) -> Root<DOMMatrix> {
|
||||
DOMMatrix::from_readonly(self.global().r(), self).RotateSelf(rotX, rotY, rotZ)
|
||||
DOMMatrix::from_readonly(self.global().r().as_global_scope(), self).RotateSelf(rotX, rotY, rotZ)
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotatefromvector
|
||||
fn RotateFromVector(&self, x: f64, y: f64) -> Root<DOMMatrix> {
|
||||
DOMMatrix::from_readonly(self.global().r(), self).RotateFromVectorSelf(x, y)
|
||||
DOMMatrix::from_readonly(self.global().r().as_global_scope(), self).RotateFromVectorSelf(x, y)
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotateaxisangle
|
||||
fn RotateAxisAngle(&self, x: f64, y: f64, z: f64, angle: f64) -> Root<DOMMatrix> {
|
||||
DOMMatrix::from_readonly(self.global().r(), self).RotateAxisAngleSelf(x, y, z, angle)
|
||||
DOMMatrix::from_readonly(self.global().r().as_global_scope(), self).RotateAxisAngleSelf(x, y, z, angle)
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-skewx
|
||||
fn SkewX(&self, sx: f64) -> Root<DOMMatrix> {
|
||||
DOMMatrix::from_readonly(self.global().r(), self).SkewXSelf(sx)
|
||||
DOMMatrix::from_readonly(self.global().r().as_global_scope(), self).SkewXSelf(sx)
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-skewy
|
||||
fn SkewY(&self, sy: f64) -> Root<DOMMatrix> {
|
||||
DOMMatrix::from_readonly(self.global().r(), self).SkewYSelf(sy)
|
||||
DOMMatrix::from_readonly(self.global().r().as_global_scope(), self).SkewYSelf(sy)
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-multiply
|
||||
fn Multiply(&self, other: &DOMMatrixInit) -> Fallible<Root<DOMMatrix>> {
|
||||
DOMMatrix::from_readonly(self.global().r(), self).MultiplySelf(&other)
|
||||
DOMMatrix::from_readonly(self.global().r().as_global_scope(), self).MultiplySelf(&other)
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipx
|
||||
|
@ -515,7 +518,7 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
|
|||
0.0, 0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0);
|
||||
let matrix = flip.post_mul(&self.matrix.borrow());
|
||||
DOMMatrix::new(self.global().r(), is2D, matrix)
|
||||
DOMMatrix::new(self.global().r().as_global_scope(), is2D, matrix)
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipy
|
||||
|
@ -526,19 +529,24 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
|
|||
0.0, 0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0);
|
||||
let matrix = flip.post_mul(&self.matrix.borrow());
|
||||
DOMMatrix::new(self.global().r(), is2D, matrix)
|
||||
DOMMatrix::new(self.global().r().as_global_scope(), is2D, matrix)
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-inverse
|
||||
fn Inverse(&self) -> Root<DOMMatrix> {
|
||||
DOMMatrix::from_readonly(self.global().r(), self).InvertSelf()
|
||||
DOMMatrix::from_readonly(self.global().r().as_global_scope(), self).InvertSelf()
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-transformpoint
|
||||
fn TransformPoint(&self, point: &DOMPointInit) -> Root<DOMPoint> {
|
||||
let matrix = self.matrix.borrow();
|
||||
let result = matrix.transform_point4d(&Point4D::new(point.x, point.y, point.z, point.w));
|
||||
DOMPoint::new(self.global().r(), result.x as f64, result.y as f64, result.z as f64, result.w as f64)
|
||||
DOMPoint::new(
|
||||
self.global().r().as_global_scope(),
|
||||
result.x as f64,
|
||||
result.y as f64,
|
||||
result.z as f64,
|
||||
result.w as f64)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ impl DOMParser {
|
|||
|
||||
pub fn new(window: &Window) -> Root<DOMParser> {
|
||||
reflect_dom_object(box DOMParser::new_inherited(window),
|
||||
GlobalRef::Window(window),
|
||||
window,
|
||||
DOMParserBinding::Wrap)
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ use dom::bindings::global::GlobalRef;
|
|||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::dompointreadonly::{DOMPointReadOnly, DOMPointWriteMethods};
|
||||
use dom::globalscope::GlobalScope;
|
||||
|
||||
// http://dev.w3.org/fxtf/geometry/Overview.html#dompoint
|
||||
#[dom_struct]
|
||||
|
@ -23,7 +24,7 @@ impl DOMPoint {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef, x: f64, y: f64, z: f64, w: f64) -> Root<DOMPoint> {
|
||||
pub fn new(global: &GlobalScope, x: f64, y: f64, z: f64, w: f64) -> Root<DOMPoint> {
|
||||
reflect_dom_object(box DOMPoint::new_inherited(x, y, z, w), global, Wrap)
|
||||
}
|
||||
|
||||
|
@ -33,10 +34,10 @@ impl DOMPoint {
|
|||
z: f64,
|
||||
w: f64)
|
||||
-> Fallible<Root<DOMPoint>> {
|
||||
Ok(DOMPoint::new(global, x, y, z, w))
|
||||
Ok(DOMPoint::new(global.as_global_scope(), x, y, z, w))
|
||||
}
|
||||
|
||||
pub fn new_from_init(global: GlobalRef, p: &DOMPointInit) -> Root<DOMPoint> {
|
||||
pub fn new_from_init(global: &GlobalScope, p: &DOMPointInit) -> Root<DOMPoint> {
|
||||
DOMPoint::new(global, p.x, p.y, p.z, p.w)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ use dom::bindings::error::Fallible;
|
|||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use std::cell::Cell;
|
||||
|
||||
// http://dev.w3.org/fxtf/geometry/Overview.html#dompointreadonly
|
||||
|
@ -30,7 +31,7 @@ impl DOMPointReadOnly {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef, x: f64, y: f64, z: f64, w: f64) -> Root<DOMPointReadOnly> {
|
||||
pub fn new(global: &GlobalScope, x: f64, y: f64, z: f64, w: f64) -> Root<DOMPointReadOnly> {
|
||||
reflect_dom_object(box DOMPointReadOnly::new_inherited(x, y, z, w),
|
||||
global,
|
||||
Wrap)
|
||||
|
@ -42,7 +43,7 @@ impl DOMPointReadOnly {
|
|||
z: f64,
|
||||
w: f64)
|
||||
-> Fallible<Root<DOMPointReadOnly>> {
|
||||
Ok(DOMPointReadOnly::new(global, x, y, z, w))
|
||||
Ok(DOMPointReadOnly::new(global.as_global_scope(), x, y, z, w))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ use dom::bindings::js::{Root, JS};
|
|||
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||
use dom::dompoint::DOMPoint;
|
||||
use dom::domrect::DOMRect;
|
||||
use dom::globalscope::GlobalScope;
|
||||
|
||||
// https://drafts.fxtf.org/geometry/#DOMQuad
|
||||
#[dom_struct]
|
||||
|
@ -37,7 +38,7 @@ impl DOMQuad {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef,
|
||||
pub fn new(global: &GlobalScope,
|
||||
p1: &DOMPoint,
|
||||
p2: &DOMPoint,
|
||||
p3: &DOMPoint,
|
||||
|
@ -53,6 +54,7 @@ impl DOMQuad {
|
|||
p3: &DOMPointInit,
|
||||
p4: &DOMPointInit)
|
||||
-> Fallible<Root<DOMQuad>> {
|
||||
let global = global.as_global_scope();
|
||||
Ok(DOMQuad::new(global,
|
||||
&*DOMPoint::new_from_init(global, p1),
|
||||
&*DOMPoint::new_from_init(global, p2),
|
||||
|
@ -62,6 +64,7 @@ impl DOMQuad {
|
|||
|
||||
// https://drafts.fxtf.org/geometry/#dom-domquad-fromrect
|
||||
pub fn FromRect(global: GlobalRef, other: &DOMRectInit) -> Root<DOMQuad> {
|
||||
let global = global.as_global_scope();
|
||||
DOMQuad::new(global,
|
||||
&*DOMPoint::new(global, other.x, other.y, 0f64, 1f64),
|
||||
&*DOMPoint::new(global, other.x + other.width, other.y, 0f64, 1f64),
|
||||
|
@ -71,6 +74,7 @@ impl DOMQuad {
|
|||
|
||||
// https://drafts.fxtf.org/geometry/#dom-domquad-fromquad
|
||||
pub fn FromQuad(global: GlobalRef, other: &DOMQuadInit) -> Root<DOMQuad> {
|
||||
let global = global.as_global_scope();
|
||||
DOMQuad::new(global,
|
||||
&DOMPoint::new_from_init(global, &other.p1),
|
||||
&DOMPoint::new_from_init(global, &other.p2),
|
||||
|
@ -107,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 bottom = self.p1.Y().max(self.p2.Y()).max(self.p3.Y()).max(self.p4.Y());
|
||||
|
||||
DOMRect::new(self.global().r(),
|
||||
DOMRect::new(self.global().r().as_global_scope(),
|
||||
left,
|
||||
top,
|
||||
right - left,
|
||||
|
|
|
@ -10,6 +10,7 @@ use dom::bindings::global::GlobalRef;
|
|||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::domrectreadonly::DOMRectReadOnly;
|
||||
use dom::globalscope::GlobalScope;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct DOMRect {
|
||||
|
@ -23,7 +24,7 @@ impl DOMRect {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef, x: f64, y: f64, width: f64, height: f64) -> Root<DOMRect> {
|
||||
pub fn new(global: &GlobalScope, x: f64, y: f64, width: f64, height: f64) -> Root<DOMRect> {
|
||||
reflect_dom_object(box DOMRect::new_inherited(x, y, width, height),
|
||||
global,
|
||||
DOMRectBinding::Wrap)
|
||||
|
@ -35,7 +36,7 @@ impl DOMRect {
|
|||
width: f64,
|
||||
height: f64)
|
||||
-> Fallible<Root<DOMRect>> {
|
||||
Ok(DOMRect::new(global, x, y, width, height))
|
||||
Ok(DOMRect::new(global.as_global_scope(), x, y, width, height))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
use dom::bindings::codegen::Bindings::DOMRectListBinding;
|
||||
use dom::bindings::codegen::Bindings::DOMRectListBinding::DOMRectListMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::domrect::DOMRect;
|
||||
|
@ -30,7 +29,7 @@ impl DOMRectList {
|
|||
where T: Iterator<Item = Root<DOMRect>>
|
||||
{
|
||||
reflect_dom_object(box DOMRectList::new_inherited(rects),
|
||||
GlobalRef::Window(window),
|
||||
window,
|
||||
DOMRectListBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ use dom::bindings::error::Fallible;
|
|||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use std::cell::Cell;
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -29,7 +30,7 @@ impl DOMRectReadOnly {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef,
|
||||
pub fn new(global: &GlobalScope,
|
||||
x: f64,
|
||||
y: f64,
|
||||
width: f64,
|
||||
|
@ -46,7 +47,7 @@ impl DOMRectReadOnly {
|
|||
width: f64,
|
||||
height: f64)
|
||||
-> Fallible<Root<DOMRectReadOnly>> {
|
||||
Ok(DOMRectReadOnly::new(global, x, y, width, height))
|
||||
Ok(DOMRectReadOnly::new(global.as_global_scope(), x, y, width, height))
|
||||
}
|
||||
|
||||
pub fn set_x(&self, value: f64) {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
use dom::bindings::codegen::Bindings::DOMStringMapBinding;
|
||||
use dom::bindings::codegen::Bindings::DOMStringMapBinding::DOMStringMapMethods;
|
||||
use dom::bindings::error::ErrorResult;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::DOMString;
|
||||
|
@ -29,7 +28,7 @@ impl DOMStringMap {
|
|||
pub fn new(element: &HTMLElement) -> Root<DOMStringMap> {
|
||||
let window = window_from_node(element);
|
||||
reflect_dom_object(box DOMStringMap::new_inherited(element),
|
||||
GlobalRef::Window(window.r()),
|
||||
window.r(),
|
||||
DOMStringMapBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ use dom::attr::Attr;
|
|||
use dom::bindings::codegen::Bindings::DOMTokenListBinding;
|
||||
use dom::bindings::codegen::Bindings::DOMTokenListBinding::DOMTokenListMethods;
|
||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::DOMString;
|
||||
|
@ -34,7 +33,7 @@ impl DOMTokenList {
|
|||
pub fn new(element: &Element, local_name: &Atom) -> Root<DOMTokenList> {
|
||||
let window = window_from_node(element);
|
||||
reflect_dom_object(box DOMTokenList::new_inherited(element, local_name.clone()),
|
||||
GlobalRef::Window(window.r()),
|
||||
window.r(),
|
||||
DOMTokenListBinding::Wrap)
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ use dom::bindings::codegen::Bindings::WindowBinding::{ScrollBehavior, ScrollToOp
|
|||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||
use dom::bindings::codegen::UnionTypes::NodeOrString;
|
||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
|
||||
use dom::bindings::js::{JS, LayoutJS, MutNullableHeap};
|
||||
use dom::bindings::js::{Root, RootedReference};
|
||||
|
@ -1589,7 +1588,7 @@ impl ElementMethods for Element {
|
|||
let win = window_from_node(self);
|
||||
let raw_rects = self.upcast::<Node>().content_boxes();
|
||||
let rects = raw_rects.iter().map(|rect| {
|
||||
DOMRect::new(GlobalRef::Window(win.r()),
|
||||
DOMRect::new(win.upcast(),
|
||||
rect.origin.x.to_f64_px(),
|
||||
rect.origin.y.to_f64_px(),
|
||||
rect.size.width.to_f64_px(),
|
||||
|
@ -1602,7 +1601,7 @@ impl ElementMethods for Element {
|
|||
fn GetBoundingClientRect(&self) -> Root<DOMRect> {
|
||||
let win = window_from_node(self);
|
||||
let rect = self.upcast::<Node>().bounding_content_box();
|
||||
DOMRect::new(GlobalRef::Window(win.r()),
|
||||
DOMRect::new(win.upcast(),
|
||||
rect.origin.x.to_f64_px(),
|
||||
rect.origin.y.to_f64_px(),
|
||||
rect.size.width.to_f64_px(),
|
||||
|
|
|
@ -13,6 +13,7 @@ use dom::bindings::js::{MutHeapJSVal, Root};
|
|||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use js::jsapi::{HandleValue, JSContext};
|
||||
use js::jsval::JSVal;
|
||||
use std::cell::Cell;
|
||||
|
@ -41,13 +42,13 @@ impl ErrorEvent {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new_uninitialized(global: GlobalRef) -> Root<ErrorEvent> {
|
||||
pub fn new_uninitialized(global: &GlobalScope) -> Root<ErrorEvent> {
|
||||
reflect_dom_object(box ErrorEvent::new_inherited(),
|
||||
global,
|
||||
ErrorEventBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef,
|
||||
pub fn new(global: &GlobalScope,
|
||||
type_: Atom,
|
||||
bubbles: EventBubbles,
|
||||
cancelable: EventCancelable,
|
||||
|
@ -94,11 +95,16 @@ impl ErrorEvent {
|
|||
// Dictionaries need to be rooted
|
||||
// https://github.com/servo/servo/issues/6381
|
||||
rooted!(in(global.get_cx()) let error = init.error);
|
||||
let event = ErrorEvent::new(global, Atom::from(type_),
|
||||
bubbles, cancelable,
|
||||
msg, file_name,
|
||||
line_num, col_num,
|
||||
error.handle());
|
||||
let event = ErrorEvent::new(
|
||||
global.as_global_scope(),
|
||||
Atom::from(type_),
|
||||
bubbles,
|
||||
cancelable,
|
||||
msg,
|
||||
file_name,
|
||||
line_num,
|
||||
col_num,
|
||||
error.handle());
|
||||
Ok(event)
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
|||
use dom::bindings::str::DOMString;
|
||||
use dom::eventdispatcher::EventStatus;
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use script_thread::Runnable;
|
||||
use std::cell::Cell;
|
||||
use std::default::Default;
|
||||
|
@ -115,13 +116,13 @@ impl Event {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new_uninitialized(global: GlobalRef) -> Root<Event> {
|
||||
pub fn new_uninitialized(global: &GlobalScope) -> Root<Event> {
|
||||
reflect_dom_object(box Event::new_inherited(),
|
||||
global,
|
||||
EventBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef,
|
||||
pub fn new(global: &GlobalScope,
|
||||
type_: Atom,
|
||||
bubbles: EventBubbles,
|
||||
cancelable: EventCancelable) -> Root<Event> {
|
||||
|
@ -135,7 +136,7 @@ impl Event {
|
|||
init: &EventBinding::EventInit) -> Fallible<Root<Event>> {
|
||||
let bubbles = EventBubbles::from(init.bubbles);
|
||||
let cancelable = EventCancelable::from(init.cancelable);
|
||||
Ok(Event::new(global, Atom::from(type_), bubbles, cancelable))
|
||||
Ok(Event::new(global.as_global_scope(), Atom::from(type_), bubbles, cancelable))
|
||||
}
|
||||
|
||||
pub fn init_event(&self, type_: Atom, bubbles: bool, cancelable: bool) {
|
||||
|
|
|
@ -11,6 +11,7 @@ use dom::bindings::js::Root;
|
|||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use std::cell::Cell;
|
||||
use url::Url;
|
||||
|
||||
|
@ -42,8 +43,10 @@ impl EventSource {
|
|||
}
|
||||
}
|
||||
|
||||
fn new(global: GlobalRef, url: Url, with_credentials: bool) -> Root<EventSource> {
|
||||
reflect_dom_object(box EventSource::new_inherited(url, with_credentials), global, Wrap)
|
||||
fn new(global: &GlobalScope, url: Url, with_credentials: bool) -> Root<EventSource> {
|
||||
reflect_dom_object(box EventSource::new_inherited(url, with_credentials),
|
||||
global,
|
||||
Wrap)
|
||||
}
|
||||
|
||||
pub fn Constructor(global: GlobalRef,
|
||||
|
@ -56,7 +59,7 @@ impl EventSource {
|
|||
Err(_) => return Err(Error::Syntax)
|
||||
};
|
||||
// Step 3
|
||||
let event_source = EventSource::new(global, url, event_source_init.withCredentials);
|
||||
let event_source = EventSource::new(global.as_global_scope(), url, event_source_init.withCredentials);
|
||||
// Step 4
|
||||
// Step 5
|
||||
// Step 6
|
||||
|
|
|
@ -500,8 +500,8 @@ impl EventTarget {
|
|||
bubbles: EventBubbles,
|
||||
cancelable: EventCancelable)
|
||||
-> Root<Event> {
|
||||
let global = self.global();
|
||||
let event = Event::new(global.r(), Atom::from(name), bubbles, cancelable);
|
||||
let event = Event::new(
|
||||
self.global().r().as_global_scope(), Atom::from(name), bubbles, cancelable);
|
||||
|
||||
event.fire(self);
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ use dom::bindings::js::Root;
|
|||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::event::Event;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use js::jsapi::{HandleValue, JSContext};
|
||||
use string_cache::Atom;
|
||||
|
||||
|
@ -28,7 +29,7 @@ impl ExtendableEvent {
|
|||
extensions_allowed: true
|
||||
}
|
||||
}
|
||||
pub fn new(global: GlobalRef,
|
||||
pub fn new(global: &GlobalScope,
|
||||
type_: Atom,
|
||||
bubbles: bool,
|
||||
cancelable: bool)
|
||||
|
@ -44,7 +45,7 @@ impl ExtendableEvent {
|
|||
pub fn Constructor(global: GlobalRef,
|
||||
type_: DOMString,
|
||||
init: &ExtendableEventBinding::ExtendableEventInit) -> Fallible<Root<ExtendableEvent>> {
|
||||
Ok(ExtendableEvent::new(global,
|
||||
Ok(ExtendableEvent::new(global.as_global_scope(),
|
||||
Atom::from(type_),
|
||||
init.parent.bubbles,
|
||||
init.parent.cancelable))
|
||||
|
|
|
@ -13,6 +13,7 @@ use dom::bindings::str::DOMString;
|
|||
use dom::event::Event;
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom::extendableevent::ExtendableEvent;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use js::jsapi::{HandleValue, Heap, JSContext};
|
||||
use js::jsval::JSVal;
|
||||
use std::default::Default;
|
||||
|
@ -27,7 +28,7 @@ pub struct ExtendableMessageEvent {
|
|||
}
|
||||
|
||||
impl ExtendableMessageEvent {
|
||||
pub fn new(global: GlobalRef, type_: Atom,
|
||||
pub fn new(global: &GlobalScope, type_: Atom,
|
||||
bubbles: bool, cancelable: bool,
|
||||
data: HandleValue, origin: DOMString, lastEventId: DOMString)
|
||||
-> Root<ExtendableMessageEvent> {
|
||||
|
@ -51,7 +52,8 @@ impl ExtendableMessageEvent {
|
|||
init: &ExtendableMessageEventBinding::ExtendableMessageEventInit)
|
||||
-> Fallible<Root<ExtendableMessageEvent>> {
|
||||
rooted!(in(global.get_cx()) let data = init.data);
|
||||
let ev = ExtendableMessageEvent::new(global, Atom::from(type_),
|
||||
let ev = ExtendableMessageEvent::new(global.as_global_scope(),
|
||||
Atom::from(type_),
|
||||
init.parent.parent.bubbles,
|
||||
init.parent.parent.cancelable,
|
||||
data.handle(),
|
||||
|
@ -66,7 +68,7 @@ impl ExtendableMessageEvent {
|
|||
scope: GlobalRef,
|
||||
message: HandleValue) {
|
||||
let Extendablemessageevent = ExtendableMessageEvent::new(
|
||||
scope, atom!("message"), false, false, message,
|
||||
scope.as_global_scope(), atom!("message"), false, false, message,
|
||||
DOMString::new(), DOMString::new());
|
||||
Extendablemessageevent.upcast::<Event>().fire(target);
|
||||
}
|
||||
|
|
|
@ -7,10 +7,12 @@ use dom::bindings::codegen::Bindings::FileBinding::FileMethods;
|
|||
use dom::bindings::codegen::UnionTypes::BlobOrString;
|
||||
use dom::bindings::error::{Error, Fallible};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::blob::{Blob, BlobImpl, blob_parts_to_bytes};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::window::Window;
|
||||
use net_traits::filemanager_thread::SelectedFile;
|
||||
use time;
|
||||
|
@ -41,7 +43,7 @@ impl File {
|
|||
}
|
||||
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn new(global: GlobalRef, blob_impl: BlobImpl,
|
||||
pub fn new(global: &GlobalScope, blob_impl: BlobImpl,
|
||||
name: DOMString, modified: Option<i64>, typeString: &str) -> Root<File> {
|
||||
reflect_dom_object(box File::new_inherited(blob_impl, name, modified, typeString),
|
||||
global,
|
||||
|
@ -52,9 +54,7 @@ impl File {
|
|||
pub fn new_from_selected(window: &Window, selected: SelectedFile) -> Root<File> {
|
||||
let name = DOMString::from(selected.filename.to_str().expect("File name encoding error"));
|
||||
|
||||
let global = GlobalRef::Window(window);
|
||||
|
||||
File::new(global, BlobImpl::new_from_file(selected.id, selected.filename, selected.size),
|
||||
File::new(window.upcast(), BlobImpl::new_from_file(selected.id, selected.filename, selected.size),
|
||||
name, Some(selected.modified as i64), &selected.type_string)
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,11 @@ impl File {
|
|||
// NOTE: Following behaviour might be removed in future,
|
||||
// see https://github.com/w3c/FileAPI/issues/41
|
||||
let replaced_filename = DOMString::from_string(filename.replace("/", ":"));
|
||||
Ok(File::new(global, BlobImpl::new_from_bytes(bytes), replaced_filename, modified, typeString))
|
||||
Ok(File::new(global.as_global_scope(),
|
||||
BlobImpl::new_from_bytes(bytes),
|
||||
replaced_filename,
|
||||
modified,
|
||||
typeString))
|
||||
}
|
||||
|
||||
pub fn name(&self) -> &DOMString {
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
use dom::bindings::codegen::Bindings::FileListBinding;
|
||||
use dom::bindings::codegen::Bindings::FileListBinding::FileListMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::file::File;
|
||||
|
@ -30,7 +29,7 @@ impl FileList {
|
|||
#[allow(unrooted_must_root)]
|
||||
pub fn new(window: &Window, files: Vec<Root<File>>) -> Root<FileList> {
|
||||
reflect_dom_object(box FileList::new_inherited(files.iter().map(|r| JS::from_ref(&**r)).collect()),
|
||||
GlobalRef::Window(window),
|
||||
window,
|
||||
FileListBinding::Wrap)
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ use dom::blob::Blob;
|
|||
use dom::domexception::{DOMErrorName, DOMException};
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::progressevent::ProgressEvent;
|
||||
use encoding::all::UTF_8;
|
||||
use encoding::label::encoding_from_whatwg_label;
|
||||
|
@ -88,13 +89,13 @@ impl FileReader {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef) -> Root<FileReader> {
|
||||
pub fn new(global: &GlobalScope) -> Root<FileReader> {
|
||||
reflect_dom_object(box FileReader::new_inherited(),
|
||||
global, FileReaderBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn Constructor(global: GlobalRef) -> Fallible<Root<FileReader>> {
|
||||
Ok(FileReader::new(global))
|
||||
Ok(FileReader::new(global.as_global_scope()))
|
||||
}
|
||||
|
||||
//https://w3c.github.io/FileAPI/#dfn-error-steps
|
||||
|
@ -115,7 +116,7 @@ impl FileReader {
|
|||
*fr.result.borrow_mut() = None;
|
||||
|
||||
let global = fr.r().global();
|
||||
let exception = DOMException::new(global.r(), error);
|
||||
let exception = DOMException::new(global.r().as_global_scope(), error);
|
||||
fr.error.set(Some(&exception));
|
||||
|
||||
fr.dispatch_progress_event(atom!("error"), 0, None);
|
||||
|
@ -290,7 +291,7 @@ impl FileReaderMethods for FileReader {
|
|||
*self.result.borrow_mut() = None;
|
||||
|
||||
let global = self.global();
|
||||
let exception = DOMException::new(global.r(), DOMErrorName::AbortError);
|
||||
let exception = DOMException::new(global.r().as_global_scope(), DOMErrorName::AbortError);
|
||||
self.error.set(Some(&exception));
|
||||
|
||||
self.terminate_ongoing_reading();
|
||||
|
@ -319,7 +320,7 @@ impl FileReaderMethods for FileReader {
|
|||
impl FileReader {
|
||||
fn dispatch_progress_event(&self, type_: Atom, loaded: u64, total: Option<u64>) {
|
||||
let global = self.global();
|
||||
let progressevent = ProgressEvent::new(global.r(),
|
||||
let progressevent = ProgressEvent::new(global.r().as_global_scope(),
|
||||
type_, EventBubbles::DoesNotBubble, EventCancelable::NotCancelable,
|
||||
total.is_some(), loaded, total.unwrap_or(0));
|
||||
progressevent.upcast::<Event>().fire(self.upcast());
|
||||
|
@ -338,7 +339,7 @@ impl FileReader {
|
|||
// Step 2
|
||||
if blob.IsClosed() {
|
||||
let global = self.global();
|
||||
let exception = DOMException::new(global.r(), DOMErrorName::InvalidStateError);
|
||||
let exception = DOMException::new(global.r().as_global_scope(), DOMErrorName::InvalidStateError);
|
||||
self.error.set(Some(&exception));
|
||||
|
||||
self.dispatch_progress_event(atom!("error"), 0, None);
|
||||
|
|
|
@ -8,8 +8,7 @@ use dom::bindings::global::GlobalRef;
|
|||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::eventtarget::EventTarget;
|
||||
|
||||
|
||||
use dom::globalscope::GlobalScope;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct FileReaderSync {
|
||||
|
@ -23,12 +22,12 @@ impl FileReaderSync {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef) -> Root<FileReaderSync> {
|
||||
pub fn new(global: &GlobalScope) -> Root<FileReaderSync> {
|
||||
reflect_dom_object(box FileReaderSync::new_inherited(),
|
||||
global, FileReaderSyncBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn Constructor(global: GlobalRef) -> Fallible<Root<FileReaderSync>> {
|
||||
Ok(FileReaderSync::new(global))
|
||||
Ok(FileReaderSync::new(global.as_global_scope()))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ use dom::bindings::reflector::reflect_dom_object;
|
|||
use dom::bindings::str::DOMString;
|
||||
use dom::event::{EventBubbles, EventCancelable};
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::uievent::UIEvent;
|
||||
use dom::window::Window;
|
||||
use std::default::Default;
|
||||
|
@ -31,7 +32,7 @@ impl FocusEvent {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new_uninitialized(global: GlobalRef) -> Root<FocusEvent> {
|
||||
pub fn new_uninitialized(global: &GlobalScope) -> Root<FocusEvent> {
|
||||
reflect_dom_object(box FocusEvent::new_inherited(),
|
||||
global,
|
||||
FocusEventBinding::Wrap)
|
||||
|
@ -44,8 +45,7 @@ impl FocusEvent {
|
|||
view: Option<&Window>,
|
||||
detail: i32,
|
||||
related_target: Option<&EventTarget>) -> Root<FocusEvent> {
|
||||
let event = box FocusEvent::new_inherited();
|
||||
let ev = reflect_dom_object(event, GlobalRef::Window(window), FocusEventBinding::Wrap);
|
||||
let ev = FocusEvent::new_uninitialized(window.upcast());
|
||||
ev.upcast::<UIEvent>().InitUIEvent(type_,
|
||||
bool::from(can_bubble),
|
||||
bool::from(cancelable),
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
use dom::bindings::codegen::Bindings::ForceTouchEventBinding;
|
||||
use dom::bindings::codegen::Bindings::ForceTouchEventBinding::ForceTouchEventMethods;
|
||||
use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::num::Finite;
|
||||
|
@ -32,7 +31,7 @@ impl ForceTouchEvent {
|
|||
type_: DOMString,
|
||||
force: f32) -> Root<ForceTouchEvent> {
|
||||
let event = box ForceTouchEvent::new_inherited(force);
|
||||
let ev = reflect_dom_object(event, GlobalRef::Window(window), ForceTouchEventBinding::Wrap);
|
||||
let ev = reflect_dom_object(event, window, ForceTouchEventBinding::Wrap);
|
||||
ev.upcast::<UIEvent>().InitUIEvent(type_, true, true, Some(window), 0);
|
||||
ev
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
|||
use dom::bindings::str::{DOMString, USVString};
|
||||
use dom::blob::{Blob, BlobImpl};
|
||||
use dom::file::File;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::htmlformelement::{HTMLFormElement, FormDatumValue, FormDatum};
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||
|
@ -45,14 +46,14 @@ impl FormData {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(form: Option<&HTMLFormElement>, global: GlobalRef) -> Root<FormData> {
|
||||
pub fn new(form: Option<&HTMLFormElement>, global: &GlobalScope) -> Root<FormData> {
|
||||
reflect_dom_object(box FormData::new_inherited(form),
|
||||
global, FormDataWrap)
|
||||
}
|
||||
|
||||
pub fn Constructor(global: GlobalRef, form: Option<&HTMLFormElement>) -> Fallible<Root<FormData>> {
|
||||
// TODO: Construct form data set for form if it is supplied
|
||||
Ok(FormData::new(form, global))
|
||||
Ok(FormData::new(form, global.as_global_scope()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,7 +155,7 @@ impl FormData {
|
|||
|
||||
let bytes = blob.get_bytes().unwrap_or(vec![]);
|
||||
|
||||
File::new(global.r(), BlobImpl::new_from_bytes(bytes), name, None, "")
|
||||
File::new(global.r().as_global_scope(), BlobImpl::new_from_bytes(bytes), name, None, "")
|
||||
}
|
||||
|
||||
pub fn datums(&self) -> Vec<FormDatum> {
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::reflector::Reflectable;
|
||||
use dom::eventtarget::EventTarget;
|
||||
use js::jsapi::{JS_GetContext, JS_GetObjectRuntime, JSContext};
|
||||
|
||||
#[dom_struct]
|
||||
pub struct GlobalScope {
|
||||
|
@ -15,4 +17,16 @@ impl GlobalScope {
|
|||
eventtarget: EventTarget::new_inherited(),
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub fn get_cx(&self) -> *mut JSContext {
|
||||
unsafe {
|
||||
let runtime = JS_GetObjectRuntime(
|
||||
self.reflector().get_jsobject().get());
|
||||
assert!(!runtime.is_null());
|
||||
let context = JS_GetContext(runtime);
|
||||
assert!(!context.is_null());
|
||||
context
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ use dom::bindings::js::Root;
|
|||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::str::{DOMString, USVString};
|
||||
use dom::event::Event;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use string_cache::Atom;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#hashchangeevent
|
||||
|
@ -31,14 +32,13 @@ impl HashChangeEvent {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new_uninitialized(global: GlobalRef)
|
||||
-> Root<HashChangeEvent> {
|
||||
pub fn new_uninitialized(global: &GlobalScope) -> Root<HashChangeEvent> {
|
||||
reflect_dom_object(box HashChangeEvent::new_inherited(String::new(), String::new()),
|
||||
global,
|
||||
HashChangeEventBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef,
|
||||
pub fn new(global: &GlobalScope,
|
||||
type_: Atom,
|
||||
bubbles: bool,
|
||||
cancelable: bool,
|
||||
|
@ -59,7 +59,7 @@ impl HashChangeEvent {
|
|||
type_: DOMString,
|
||||
init: &HashChangeEventBinding::HashChangeEventInit)
|
||||
-> Fallible<Root<HashChangeEvent>> {
|
||||
Ok(HashChangeEvent::new(global,
|
||||
Ok(HashChangeEvent::new(global.as_global_scope(),
|
||||
Atom::from(type_),
|
||||
init.parent.bubbles,
|
||||
init.parent.cancelable,
|
||||
|
|
|
@ -10,6 +10,7 @@ use dom::bindings::iterable::Iterable;
|
|||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::{ByteString, is_token};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use hyper::header::Headers as HyperHeaders;
|
||||
use mime::{Mime, TopLevel, SubLevel};
|
||||
use std::cell::Cell;
|
||||
|
@ -43,14 +44,14 @@ impl Headers {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef) -> Root<Headers> {
|
||||
pub fn new(global: &GlobalScope) -> Root<Headers> {
|
||||
reflect_dom_object(box Headers::new_inherited(), global, HeadersWrap)
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#dom-headers
|
||||
pub fn Constructor(global: GlobalRef, init: Option<HeadersInit>)
|
||||
-> Fallible<Root<Headers>> {
|
||||
let dom_headers_new = Headers::new(global);
|
||||
let dom_headers_new = Headers::new(global.as_global_scope());
|
||||
try!(dom_headers_new.fill(init));
|
||||
Ok(dom_headers_new)
|
||||
}
|
||||
|
@ -205,13 +206,13 @@ impl Headers {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn for_request(global: GlobalRef) -> Root<Headers> {
|
||||
pub fn for_request(global: &GlobalScope) -> Root<Headers> {
|
||||
let headers_for_request = Headers::new(global);
|
||||
headers_for_request.guard.set(Guard::Request);
|
||||
headers_for_request
|
||||
}
|
||||
|
||||
pub fn for_response(global: GlobalRef) -> Root<Headers> {
|
||||
pub fn for_response(global: &GlobalScope) -> Root<Headers> {
|
||||
let headers_for_response = Headers::new(global);
|
||||
headers_for_response.guard.set(Guard::Response);
|
||||
headers_for_response
|
||||
|
|
|
@ -6,7 +6,6 @@ use dom::bindings::codegen::Bindings::HistoryBinding;
|
|||
use dom::bindings::codegen::Bindings::HistoryBinding::HistoryMethods;
|
||||
use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods;
|
||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::window::Window;
|
||||
|
@ -31,7 +30,7 @@ impl History {
|
|||
|
||||
pub fn new(window: &Window) -> Root<History> {
|
||||
reflect_dom_object(box History::new_inherited(window),
|
||||
GlobalRef::Window(window),
|
||||
window,
|
||||
HistoryBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
use dom::bindings::codegen::Bindings::HTMLCollectionBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::{JS, Root, MutNullableHeap};
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
|
@ -83,7 +82,7 @@ impl HTMLCollection {
|
|||
#[allow(unrooted_must_root)]
|
||||
pub fn new(window: &Window, root: &Node, filter: Box<CollectionFilter + 'static>) -> Root<HTMLCollection> {
|
||||
reflect_dom_object(box HTMLCollection::new_inherited(root, filter),
|
||||
GlobalRef::Window(window), HTMLCollectionBinding::Wrap)
|
||||
window, HTMLCollectionBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn create(window: &Window, root: &Node,
|
||||
|
|
|
@ -6,7 +6,6 @@ use dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMetho
|
|||
use dom::bindings::codegen::Bindings::HTMLFormControlsCollectionBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLFormControlsCollectionBinding::HTMLFormControlsCollectionMethods;
|
||||
use dom::bindings::codegen::UnionTypes::RadioNodeListOrElement;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
|
||||
use dom::bindings::str::DOMString;
|
||||
|
@ -33,7 +32,7 @@ impl HTMLFormControlsCollection {
|
|||
-> Root<HTMLFormControlsCollection>
|
||||
{
|
||||
reflect_dom_object(box HTMLFormControlsCollection::new_inherited(root, filter),
|
||||
GlobalRef::Window(window),
|
||||
window,
|
||||
HTMLFormControlsCollectionBinding::Wrap)
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElemen
|
|||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||
use dom::bindings::conversions::ToJSValConvertible;
|
||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::{JS, LayoutJS, MutNullableHeap, Root};
|
||||
use dom::bindings::reflector::Reflectable;
|
||||
|
@ -316,7 +315,7 @@ pub fn build_mozbrowser_custom_event(window: &Window, event: MozBrowserEvent) ->
|
|||
rooted!(in(cx) let mut detail = UndefinedValue());
|
||||
let event_name = Atom::from(event.name());
|
||||
unsafe { build_mozbrowser_event_detail(event, cx, detail.handle_mut()); }
|
||||
CustomEvent::new(GlobalRef::Window(window),
|
||||
CustomEvent::new(window.upcast(),
|
||||
event_name,
|
||||
true,
|
||||
true,
|
||||
|
|
|
@ -311,7 +311,7 @@ impl HTMLMediaElement {
|
|||
|
||||
fn fire_simple_event(&self, type_: &str) {
|
||||
let window = window_from_node(self);
|
||||
let event = Event::new(GlobalRef::Window(&*window),
|
||||
let event = Event::new(window.upcast(),
|
||||
Atom::from(type_),
|
||||
EventBubbles::DoesNotBubble,
|
||||
EventCancelable::NotCancelable);
|
||||
|
|
|
@ -9,7 +9,6 @@ use dom::bindings::codegen::Bindings::HTMLOptionsCollectionBinding::HTMLOptionsC
|
|||
use dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::NodeMethods;
|
||||
use dom::bindings::codegen::UnionTypes::{HTMLOptionElementOrHTMLOptGroupElement, HTMLElementOrLong};
|
||||
use dom::bindings::error::{Error, ErrorResult};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::{Root, RootedReference};
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
|
@ -36,7 +35,7 @@ impl HTMLOptionsCollection {
|
|||
-> Root<HTMLOptionsCollection>
|
||||
{
|
||||
reflect_dom_object(box HTMLOptionsCollection::new_inherited(root, filter),
|
||||
GlobalRef::Window(window),
|
||||
window,
|
||||
HTMLOptionsCollectionBinding::Wrap)
|
||||
}
|
||||
|
||||
|
|
|
@ -604,7 +604,7 @@ impl HTMLScriptElement {
|
|||
cancelable: EventCancelable) -> EventStatus {
|
||||
let window = window_from_node(self);
|
||||
let window = window.r();
|
||||
let event = Event::new(GlobalRef::Window(window), type_, bubbles, cancelable);
|
||||
let event = Event::new(window.upcast(), type_, bubbles, cancelable);
|
||||
event.fire(self.upcast())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
use core::nonzero::NonZero;
|
||||
use dom::bindings::codegen::Bindings::ImageDataBinding;
|
||||
use dom::bindings::codegen::Bindings::ImageDataBinding::ImageDataMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use euclid::size::Size2D;
|
||||
use js::jsapi::{Heap, JSContext, JSObject};
|
||||
use js::jsapi::{JS_GetUint8ClampedArrayData, JS_NewUint8ClampedArray};
|
||||
|
@ -27,7 +27,7 @@ pub struct ImageData {
|
|||
|
||||
impl ImageData {
|
||||
#[allow(unsafe_code)]
|
||||
pub fn new(global: GlobalRef, width: u32, height: u32, data: Option<Vec<u8>>) -> Root<ImageData> {
|
||||
pub fn new(global: &GlobalScope, width: u32, height: u32, data: Option<Vec<u8>>) -> Root<ImageData> {
|
||||
let mut imagedata = box ImageData {
|
||||
reflector_: Reflector::new(),
|
||||
width: width,
|
||||
|
|
|
@ -62,7 +62,7 @@ impl KeyboardEvent {
|
|||
|
||||
pub fn new_uninitialized(window: &Window) -> Root<KeyboardEvent> {
|
||||
reflect_dom_object(box KeyboardEvent::new_inherited(),
|
||||
GlobalRef::Window(window),
|
||||
window,
|
||||
KeyboardEventBinding::Wrap)
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
use dom::bindings::codegen::Bindings::LocationBinding;
|
||||
use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods;
|
||||
use dom::bindings::error::{Error, ErrorResult};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::{DOMString, USVString};
|
||||
|
@ -29,7 +28,7 @@ impl Location {
|
|||
|
||||
pub fn new(window: &Window) -> Root<Location> {
|
||||
reflect_dom_object(box Location::new_inherited(window),
|
||||
GlobalRef::Window(window),
|
||||
window,
|
||||
LocationBinding::Wrap)
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::codegen::Bindings::MediaErrorBinding::{self, MediaErrorMethods};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::window::Window;
|
||||
|
@ -24,7 +23,7 @@ impl MediaError {
|
|||
|
||||
pub fn new(window: &Window, code: u16) -> Root<MediaError> {
|
||||
reflect_dom_object(box MediaError::new_inherited(code),
|
||||
GlobalRef::Window(window),
|
||||
window,
|
||||
MediaErrorBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ use dom::bindings::reflector::reflect_dom_object;
|
|||
use dom::bindings::str::DOMString;
|
||||
use dom::event::Event;
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use js::jsapi::{HandleValue, Heap, JSContext};
|
||||
use js::jsval::JSVal;
|
||||
use std::default::Default;
|
||||
|
@ -27,14 +28,14 @@ pub struct MessageEvent {
|
|||
}
|
||||
|
||||
impl MessageEvent {
|
||||
pub fn new_uninitialized(global: GlobalRef) -> Root<MessageEvent> {
|
||||
pub fn new_uninitialized(global: &GlobalScope) -> Root<MessageEvent> {
|
||||
MessageEvent::new_initialized(global,
|
||||
HandleValue::undefined(),
|
||||
DOMString::new(),
|
||||
DOMString::new())
|
||||
}
|
||||
|
||||
pub fn new_initialized(global: GlobalRef,
|
||||
pub fn new_initialized(global: &GlobalScope,
|
||||
data: HandleValue,
|
||||
origin: DOMString,
|
||||
lastEventId: DOMString) -> Root<MessageEvent> {
|
||||
|
@ -48,7 +49,7 @@ impl MessageEvent {
|
|||
reflect_dom_object(ev, global, MessageEventBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef, type_: Atom,
|
||||
pub fn new(global: &GlobalScope, type_: Atom,
|
||||
bubbles: bool, cancelable: bool,
|
||||
data: HandleValue, origin: DOMString, lastEventId: DOMString)
|
||||
-> Root<MessageEvent> {
|
||||
|
@ -67,9 +68,13 @@ impl MessageEvent {
|
|||
// Dictionaries need to be rooted
|
||||
// https://github.com/servo/servo/issues/6381
|
||||
rooted!(in(global.get_cx()) let data = init.data);
|
||||
let ev = MessageEvent::new(global, Atom::from(type_), init.parent.bubbles, init.parent.cancelable,
|
||||
let ev = MessageEvent::new(global.as_global_scope(),
|
||||
Atom::from(type_),
|
||||
init.parent.bubbles,
|
||||
init.parent.cancelable,
|
||||
data.handle(),
|
||||
init.origin.clone(), init.lastEventId.clone());
|
||||
init.origin.clone(),
|
||||
init.lastEventId.clone());
|
||||
Ok(ev)
|
||||
}
|
||||
}
|
||||
|
@ -79,8 +84,13 @@ impl MessageEvent {
|
|||
scope: GlobalRef,
|
||||
message: HandleValue) {
|
||||
let messageevent = MessageEvent::new(
|
||||
scope, atom!("message"), false, false, message,
|
||||
DOMString::new(), DOMString::new());
|
||||
scope.as_global_scope(),
|
||||
atom!("message"),
|
||||
false,
|
||||
false,
|
||||
message,
|
||||
DOMString::new(),
|
||||
DOMString::new());
|
||||
messageevent.upcast::<Event>().fire(target);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
use dom::bindings::codegen::Bindings::MimeTypeArrayBinding;
|
||||
use dom::bindings::codegen::Bindings::MimeTypeArrayBinding::MimeTypeArrayMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::mimetype::MimeType;
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -22,7 +22,7 @@ impl MimeTypeArray {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef) -> Root<MimeTypeArray> {
|
||||
pub fn new(global: &GlobalScope) -> Root<MimeTypeArray> {
|
||||
reflect_dom_object(box MimeTypeArray::new_inherited(),
|
||||
global,
|
||||
MimeTypeArrayBinding::Wrap)
|
||||
|
|
|
@ -53,7 +53,7 @@ impl MouseEvent {
|
|||
|
||||
pub fn new_uninitialized(window: &Window) -> Root<MouseEvent> {
|
||||
reflect_dom_object(box MouseEvent::new_inherited(),
|
||||
GlobalRef::Window(window),
|
||||
window,
|
||||
MouseEventBinding::Wrap)
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
|
|||
use dom::bindings::codegen::Bindings::NamedNodeMapBinding;
|
||||
use dom::bindings::codegen::Bindings::NamedNodeMapBinding::NamedNodeMapMethods;
|
||||
use dom::bindings::error::{Error, Fallible};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::DOMString;
|
||||
|
@ -33,7 +32,7 @@ impl NamedNodeMap {
|
|||
|
||||
pub fn new(window: &Window, elem: &Element) -> Root<NamedNodeMap> {
|
||||
reflect_dom_object(box NamedNodeMap::new_inherited(elem),
|
||||
GlobalRef::Window(window), NamedNodeMapBinding::Wrap)
|
||||
window, NamedNodeMapBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
use dom::bindings::codegen::Bindings::NavigatorBinding;
|
||||
use dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
||||
use dom::bindings::reflector::{Reflector, Reflectable, reflect_dom_object};
|
||||
use dom::bindings::str::DOMString;
|
||||
|
@ -37,7 +36,7 @@ impl Navigator {
|
|||
|
||||
pub fn new(window: &Window) -> Root<Navigator> {
|
||||
reflect_dom_object(box Navigator::new_inherited(),
|
||||
GlobalRef::Window(window),
|
||||
window,
|
||||
NavigatorBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +79,7 @@ impl NavigatorMethods for Navigator {
|
|||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-navigator-bluetooth
|
||||
fn Bluetooth(&self) -> Root<Bluetooth> {
|
||||
self.bluetooth.or_init(|| Bluetooth::new(self.global().r()))
|
||||
self.bluetooth.or_init(|| Bluetooth::new(self.global().r().as_global_scope()))
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#navigatorlanguage
|
||||
|
@ -90,12 +89,12 @@ impl NavigatorMethods for Navigator {
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-plugins
|
||||
fn Plugins(&self) -> Root<PluginArray> {
|
||||
self.plugins.or_init(|| PluginArray::new(self.global().r()))
|
||||
self.plugins.or_init(|| PluginArray::new(self.global().r().as_global_scope()))
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-mimetypes
|
||||
fn MimeTypes(&self) -> Root<MimeTypeArray> {
|
||||
self.mime_types.or_init(|| MimeTypeArray::new(self.global().r()))
|
||||
self.mime_types.or_init(|| MimeTypeArray::new(self.global().r().as_global_scope()))
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-javaenabled
|
||||
|
@ -105,7 +104,9 @@ impl NavigatorMethods for Navigator {
|
|||
|
||||
// https://w3c.github.io/ServiceWorker/#navigator-service-worker-attribute
|
||||
fn ServiceWorker(&self) -> Root<ServiceWorkerContainer> {
|
||||
self.service_worker.or_init(|| ServiceWorkerContainer::new(self.global().r()))
|
||||
self.service_worker.or_init(|| {
|
||||
ServiceWorkerContainer::new(self.global().r().as_global_scope())
|
||||
})
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-cookieenabled
|
||||
|
|
|
@ -20,7 +20,6 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
|||
use dom::bindings::codegen::UnionTypes::NodeOrString;
|
||||
use dom::bindings::conversions::{self, DerivedFrom};
|
||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::inheritance::{Castable, CharacterDataTypeId, ElementTypeId};
|
||||
use dom::bindings::inheritance::{EventTargetTypeId, HTMLElementTypeId, NodeTypeId};
|
||||
use dom::bindings::js::{JS, LayoutJS, MutNullableHeap};
|
||||
|
@ -35,6 +34,7 @@ use dom::documentfragment::DocumentFragment;
|
|||
use dom::documenttype::DocumentType;
|
||||
use dom::element::{Element, ElementCreator};
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::htmlbodyelement::HTMLBodyElement;
|
||||
use dom::htmlcanvaselement::LayoutHTMLCanvasElementHelpers;
|
||||
use dom::htmlcollection::HTMLCollection;
|
||||
|
@ -1339,13 +1339,15 @@ pub enum CloneChildrenFlag {
|
|||
fn as_uintptr<T>(t: &T) -> uintptr_t { t as *const T as uintptr_t }
|
||||
|
||||
impl Node {
|
||||
pub fn reflect_node<N: DerivedFrom<Node> + Reflectable>
|
||||
(node: Box<N>,
|
||||
document: &Document,
|
||||
wrap_fn: extern "Rust" fn(*mut JSContext, GlobalRef, Box<N>) -> Root<N>)
|
||||
-> Root<N> {
|
||||
pub fn reflect_node<N>(
|
||||
node: Box<N>,
|
||||
document: &Document,
|
||||
wrap_fn: extern "Rust" fn(*mut JSContext, &GlobalScope, Box<N>) -> Root<N>)
|
||||
-> Root<N>
|
||||
where N: DerivedFrom<Node> + Reflectable
|
||||
{
|
||||
let window = document.window();
|
||||
reflect_dom_object(node, GlobalRef::Window(window), wrap_fn)
|
||||
reflect_dom_object(node, window, wrap_fn)
|
||||
}
|
||||
|
||||
pub fn new_inherited(doc: &Document) -> Node {
|
||||
|
|
|
@ -9,7 +9,6 @@ use dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilterConstants;
|
|||
use dom::bindings::codegen::Bindings::NodeIteratorBinding;
|
||||
use dom::bindings::codegen::Bindings::NodeIteratorBinding::NodeIteratorMethods;
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, MutHeap, Root};
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::document::Document;
|
||||
|
@ -48,7 +47,7 @@ impl NodeIterator {
|
|||
what_to_show: u32,
|
||||
filter: Filter) -> Root<NodeIterator> {
|
||||
reflect_dom_object(box NodeIterator::new_inherited(root_node, what_to_show, filter),
|
||||
GlobalRef::Window(document.window()),
|
||||
document.window(),
|
||||
NodeIteratorBinding::Wrap)
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||
use dom::bindings::codegen::Bindings::NodeListBinding;
|
||||
use dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference};
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::node::{ChildrenMutation, Node};
|
||||
|
@ -38,7 +37,8 @@ impl NodeList {
|
|||
#[allow(unrooted_must_root)]
|
||||
pub fn new(window: &Window, list_type: NodeListType) -> Root<NodeList> {
|
||||
reflect_dom_object(box NodeList::new_inherited(list_type),
|
||||
GlobalRef::Window(window), NodeListBinding::Wrap)
|
||||
window,
|
||||
NodeListBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn new_simple_list<T>(window: &Window, iter: T) -> Root<NodeList>
|
||||
|
|
|
@ -12,6 +12,7 @@ use dom::bindings::js::Root;
|
|||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::event::Event;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use std::cell::Cell;
|
||||
use string_cache::Atom;
|
||||
|
||||
|
@ -30,13 +31,13 @@ impl PageTransitionEvent {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new_uninitialized(global: GlobalRef) -> Root<PageTransitionEvent> {
|
||||
pub fn new_uninitialized(global: &GlobalScope) -> Root<PageTransitionEvent> {
|
||||
reflect_dom_object(box PageTransitionEvent::new_inherited(),
|
||||
global,
|
||||
PageTransitionEventBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef,
|
||||
pub fn new(global: &GlobalScope,
|
||||
type_: Atom,
|
||||
bubbles: bool,
|
||||
cancelable: bool,
|
||||
|
@ -55,7 +56,7 @@ impl PageTransitionEvent {
|
|||
type_: DOMString,
|
||||
init: &PageTransitionEventBinding::PageTransitionEventInit)
|
||||
-> Fallible<Root<PageTransitionEvent>> {
|
||||
Ok(PageTransitionEvent::new(global,
|
||||
Ok(PageTransitionEvent::new(global.as_global_scope(),
|
||||
Atom::from(type_),
|
||||
init.parent.bubbles,
|
||||
init.parent.cancelable,
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
use dom::bindings::codegen::Bindings::PerformanceBinding;
|
||||
use dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::num::Finite;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
|
@ -38,7 +37,7 @@ impl Performance {
|
|||
reflect_dom_object(box Performance::new_inherited(window,
|
||||
navigation_start,
|
||||
navigation_start_precise),
|
||||
GlobalRef::Window(window),
|
||||
window,
|
||||
PerformanceBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
use dom::bindings::codegen::Bindings::PerformanceTimingBinding;
|
||||
use dom::bindings::codegen::Bindings::PerformanceTimingBinding::PerformanceTimingMethods;
|
||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::document::Document;
|
||||
|
@ -40,7 +39,8 @@ impl PerformanceTiming {
|
|||
let timing = PerformanceTiming::new_inherited(navigation_start,
|
||||
navigation_start_precise,
|
||||
window.Document().r());
|
||||
reflect_dom_object(box timing, GlobalRef::Window(window),
|
||||
reflect_dom_object(box timing,
|
||||
window,
|
||||
PerformanceTimingBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
use dom::bindings::codegen::Bindings::PluginArrayBinding;
|
||||
use dom::bindings::codegen::Bindings::PluginArrayBinding::PluginArrayMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::plugin::Plugin;
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -22,7 +22,7 @@ impl PluginArray {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef) -> Root<PluginArray> {
|
||||
pub fn new(global: &GlobalScope) -> Root<PluginArray> {
|
||||
reflect_dom_object(box PluginArray::new_inherited(),
|
||||
global,
|
||||
PluginArrayBinding::Wrap)
|
||||
|
|
|
@ -12,6 +12,7 @@ use dom::bindings::js::{MutHeapJSVal, Root};
|
|||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::event::Event;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use js::jsapi::{HandleValue, JSContext};
|
||||
use js::jsval::JSVal;
|
||||
use string_cache::Atom;
|
||||
|
@ -32,13 +33,13 @@ impl PopStateEvent {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new_uninitialized(global: GlobalRef) -> Root<PopStateEvent> {
|
||||
pub fn new_uninitialized(global: &GlobalScope) -> Root<PopStateEvent> {
|
||||
reflect_dom_object(box PopStateEvent::new_inherited(),
|
||||
global,
|
||||
PopStateEventBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef,
|
||||
pub fn new(global: &GlobalScope,
|
||||
type_: Atom,
|
||||
bubbles: bool,
|
||||
cancelable: bool,
|
||||
|
@ -58,7 +59,7 @@ impl PopStateEvent {
|
|||
type_: DOMString,
|
||||
init: &PopStateEventBinding::PopStateEventInit)
|
||||
-> Fallible<Root<PopStateEvent>> {
|
||||
Ok(PopStateEvent::new(global,
|
||||
Ok(PopStateEvent::new(global.as_global_scope(),
|
||||
Atom::from(type_),
|
||||
init.parent.bubbles,
|
||||
init.parent.cancelable,
|
||||
|
|
|
@ -12,7 +12,7 @@ use dom::bindings::js::Root;
|
|||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::window::Window;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use string_cache::Atom;
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -32,12 +32,12 @@ impl ProgressEvent {
|
|||
total: total
|
||||
}
|
||||
}
|
||||
pub fn new_uninitialized(window: &Window) -> Root<ProgressEvent> {
|
||||
pub fn new_uninitialized(global: &GlobalScope) -> Root<ProgressEvent> {
|
||||
reflect_dom_object(box ProgressEvent::new_inherited(false, 0, 0),
|
||||
GlobalRef::Window(window),
|
||||
global,
|
||||
ProgressEventBinding::Wrap)
|
||||
}
|
||||
pub fn new(global: GlobalRef, type_: Atom,
|
||||
pub fn new(global: &GlobalScope, type_: Atom,
|
||||
can_bubble: EventBubbles, cancelable: EventCancelable,
|
||||
length_computable: bool, loaded: u64, total: u64) -> Root<ProgressEvent> {
|
||||
let ev = reflect_dom_object(box ProgressEvent::new_inherited(length_computable, loaded, total),
|
||||
|
@ -55,7 +55,7 @@ impl ProgressEvent {
|
|||
-> Fallible<Root<ProgressEvent>> {
|
||||
let bubbles = EventBubbles::from(init.parent.bubbles);
|
||||
let cancelable = EventCancelable::from(init.parent.cancelable);
|
||||
let ev = ProgressEvent::new(global, Atom::from(type_), bubbles, cancelable,
|
||||
let ev = ProgressEvent::new(global.as_global_scope(), Atom::from(type_), bubbles, cancelable,
|
||||
init.lengthComputable, init.loaded, init.total);
|
||||
Ok(ev)
|
||||
}
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::codegen::Bindings::PromiseNativeHandlerBinding;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::trace::JSTraceable;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use heapsize::HeapSizeOf;
|
||||
use js::jsapi::{JSContext, HandleValue};
|
||||
|
||||
|
@ -22,7 +22,7 @@ pub struct PromiseNativeHandler {
|
|||
}
|
||||
|
||||
impl PromiseNativeHandler {
|
||||
pub fn new(global: GlobalRef,
|
||||
pub fn new(global: &GlobalScope,
|
||||
resolve: Option<Box<Callback>>,
|
||||
reject: Option<Box<Callback>>)
|
||||
-> Root<PromiseNativeHandler> {
|
||||
|
|
|
@ -6,7 +6,6 @@ use dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementM
|
|||
use dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods;
|
||||
use dom::bindings::codegen::Bindings::RadioNodeListBinding;
|
||||
use dom::bindings::codegen::Bindings::RadioNodeListBinding::RadioNodeListMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
|
@ -32,7 +31,7 @@ impl RadioNodeList {
|
|||
#[allow(unrooted_must_root)]
|
||||
pub fn new(window: &Window, list_type: NodeListType) -> Root<RadioNodeList> {
|
||||
reflect_dom_object(box RadioNodeList::new_inherited(list_type),
|
||||
GlobalRef::Window(window),
|
||||
window,
|
||||
RadioNodeListBinding::Wrap)
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ impl Range {
|
|||
-> Root<Range> {
|
||||
let range = reflect_dom_object(box Range::new_inherited(start_container, start_offset,
|
||||
end_container, end_offset),
|
||||
GlobalRef::Window(document.window()),
|
||||
document.window(),
|
||||
RangeBinding::Wrap);
|
||||
start_container.ranges().push(WeakRef::new(&range));
|
||||
if start_container != end_container {
|
||||
|
|
|
@ -73,7 +73,7 @@ impl Request {
|
|||
reflect_dom_object(box Request::new_inherited(global,
|
||||
url,
|
||||
is_service_worker_global_scope),
|
||||
global, RequestBinding::Wrap)
|
||||
global.as_global_scope(), RequestBinding::Wrap)
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#dom-request
|
||||
|
@ -305,7 +305,7 @@ impl Request {
|
|||
let r = Request::from_net_request(global,
|
||||
false,
|
||||
request);
|
||||
r.headers.or_init(|| Headers::for_request(r.global().r()));
|
||||
r.headers.or_init(|| Headers::for_request(r.global().r().as_global_scope()));
|
||||
|
||||
// Step 27
|
||||
let mut headers_copy = r.Headers();
|
||||
|
@ -429,11 +429,7 @@ impl Request {
|
|||
let body_used = r.body_used.get();
|
||||
let mime_type = r.mime_type.borrow().clone();
|
||||
let headers_guard = r.Headers().get_guard();
|
||||
let r_clone = reflect_dom_object(
|
||||
box Request::new_inherited(r.global().r(),
|
||||
url,
|
||||
is_service_worker_global_scope),
|
||||
r.global().r(), RequestBinding::Wrap);
|
||||
let r_clone = Request::new(r.global().r(), url, is_service_worker_global_scope);
|
||||
r_clone.request.borrow_mut().pipeline_id.set(req.pipeline_id.get());
|
||||
{
|
||||
let mut borrowed_r_request = r_clone.request.borrow_mut();
|
||||
|
@ -553,7 +549,7 @@ impl RequestMethods for Request {
|
|||
|
||||
// https://fetch.spec.whatwg.org/#dom-request-headers
|
||||
fn Headers(&self) -> Root<Headers> {
|
||||
self.headers.or_init(|| Headers::new(self.global().r()))
|
||||
self.headers.or_init(|| Headers::new(self.global().r().as_global_scope()))
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#dom-request-type
|
||||
|
|
|
@ -14,6 +14,7 @@ use dom::bindings::global::GlobalRef;
|
|||
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
||||
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::{ByteString, USVString};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::headers::{Headers, Guard};
|
||||
use dom::headers::{is_vchar, is_obs_text};
|
||||
use dom::promise::Promise;
|
||||
|
@ -66,7 +67,7 @@ impl Response {
|
|||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#dom-response
|
||||
pub fn new(global: GlobalRef) -> Root<Response> {
|
||||
pub fn new(global: &GlobalScope) -> Root<Response> {
|
||||
reflect_dom_object(box Response::new_inherited(), global, ResponseBinding::Wrap)
|
||||
}
|
||||
|
||||
|
@ -86,7 +87,7 @@ impl Response {
|
|||
}
|
||||
|
||||
// Step 3
|
||||
let r = Response::new(global);
|
||||
let r = Response::new(global.as_global_scope());
|
||||
|
||||
// Step 4
|
||||
*r.status.borrow_mut() = Some(StatusCode::from_u16(init.status));
|
||||
|
@ -139,7 +140,7 @@ impl Response {
|
|||
|
||||
// https://fetch.spec.whatwg.org/#dom-response-error
|
||||
pub fn Error(global: GlobalRef) -> Root<Response> {
|
||||
let r = Response::new(global);
|
||||
let r = Response::new(global.as_global_scope());
|
||||
*r.response_type.borrow_mut() = DOMResponseType::Error;
|
||||
r.Headers().set_guard(Guard::Immutable);
|
||||
*r.raw_status.borrow_mut() = Some((0, b"".to_vec()));
|
||||
|
@ -166,7 +167,7 @@ impl Response {
|
|||
|
||||
// Step 4
|
||||
// see Step 4 continued
|
||||
let r = Response::new(global);
|
||||
let r = Response::new(global.as_global_scope());
|
||||
|
||||
// Step 5
|
||||
*r.status.borrow_mut() = Some(StatusCode::from_u16(status));
|
||||
|
@ -292,7 +293,7 @@ impl ResponseMethods for Response {
|
|||
|
||||
// https://fetch.spec.whatwg.org/#dom-response-headers
|
||||
fn Headers(&self) -> Root<Headers> {
|
||||
self.headers_reflector.or_init(|| Headers::for_response(self.global().r()))
|
||||
self.headers_reflector.or_init(|| Headers::for_response(self.global().r().as_global_scope()))
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#dom-response-clone
|
||||
|
@ -301,7 +302,7 @@ impl ResponseMethods for Response {
|
|||
// TODO: This step relies on body and stream, which are still unimplemented.
|
||||
|
||||
// Step 2
|
||||
let new_response = Response::new(self.global().r());
|
||||
let new_response = Response::new(self.global().r().as_global_scope());
|
||||
new_response.Headers().set_guard(self.Headers().get_guard());
|
||||
|
||||
// https://fetch.spec.whatwg.org/#concept-response-clone
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
use dom::bindings::codegen::Bindings::ScreenBinding;
|
||||
use dom::bindings::codegen::Bindings::ScreenBinding::ScreenMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::window::Window;
|
||||
|
@ -23,7 +22,7 @@ impl Screen {
|
|||
|
||||
pub fn new(window: &Window) -> Root<Screen> {
|
||||
reflect_dom_object(box Screen::new_inherited(),
|
||||
GlobalRef::Window(window),
|
||||
window,
|
||||
ScreenBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ use dom::bindings::cell::DOMRefCell;
|
|||
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
||||
use dom::bindings::codegen::Bindings::ServiceWorkerBinding::{ServiceWorkerMethods, ServiceWorkerState, Wrap};
|
||||
use dom::bindings::error::{ErrorResult, Error};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::refcounted::Trusted;
|
||||
|
@ -15,6 +14,7 @@ use dom::bindings::reflector::{Reflectable, reflect_dom_object};
|
|||
use dom::bindings::str::USVString;
|
||||
use dom::bindings::structuredclone::StructuredCloneData;
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use js::jsapi::{HandleValue, JSContext};
|
||||
use script_thread::Runnable;
|
||||
use script_traits::{ScriptMsg, DOMMessage};
|
||||
|
@ -45,7 +45,7 @@ impl ServiceWorker {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn install_serviceworker(global: GlobalRef,
|
||||
pub fn install_serviceworker(global: &GlobalScope,
|
||||
script_url: Url,
|
||||
scope_url: Url,
|
||||
skip_waiting: bool) -> Root<ServiceWorker> {
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
use dom::bindings::codegen::Bindings::ServiceWorkerContainerBinding::{ServiceWorkerContainerMethods, Wrap};
|
||||
use dom::bindings::codegen::Bindings::ServiceWorkerContainerBinding::RegistrationOptions;
|
||||
use dom::bindings::error::{Error, Fallible};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
||||
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
|
||||
use dom::bindings::str::USVString;
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::serviceworker::ServiceWorker;
|
||||
use dom::serviceworkerregistration::ServiceWorkerRegistration;
|
||||
use script_thread::ScriptThread;
|
||||
|
@ -31,7 +31,7 @@ impl ServiceWorkerContainer {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef) -> Root<ServiceWorkerContainer> {
|
||||
pub fn new(global: &GlobalScope) -> Root<ServiceWorkerContainer> {
|
||||
reflect_dom_object(box ServiceWorkerContainer::new_inherited(), global, Wrap)
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ impl ServiceWorkerContainerMethods for ServiceWorkerContainer {
|
|||
return Err(Error::Type("Scope URL contains forbidden characters".to_owned()));
|
||||
}
|
||||
|
||||
let worker_registration = ServiceWorkerRegistration::new(self.global().r(),
|
||||
let worker_registration = ServiceWorkerRegistration::new(self.global().r().as_global_scope(),
|
||||
script_url,
|
||||
scope.clone(),
|
||||
self);
|
||||
|
|
|
@ -302,8 +302,7 @@ impl ServiceWorkerGlobalScope {
|
|||
}
|
||||
|
||||
fn dispatch_activate(&self) {
|
||||
let global = GlobalRef::Worker(self.upcast::<WorkerGlobalScope>());
|
||||
let event = ExtendableEvent::new(global, atom!("activate"), false, false);
|
||||
let event = ExtendableEvent::new(self.upcast(), atom!("activate"), false, false);
|
||||
let event = (&*event).upcast::<Event>();
|
||||
self.upcast::<EventTarget>().dispatch_event(event);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ use dom::bindings::js::{JS, Root};
|
|||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::str::USVString;
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::serviceworker::ServiceWorker;
|
||||
use dom::serviceworkercontainer::Controllable;
|
||||
use dom::workerglobalscope::prepare_workerscope_init;
|
||||
|
@ -35,7 +36,7 @@ impl ServiceWorkerRegistration {
|
|||
}
|
||||
}
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn new(global: GlobalRef,
|
||||
pub fn new(global: &GlobalScope,
|
||||
script_url: Url,
|
||||
scope: Url,
|
||||
container: &Controllable) -> Root<ServiceWorkerRegistration> {
|
||||
|
|
|
@ -11,7 +11,6 @@ use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
|||
use dom::bindings::codegen::Bindings::HTMLImageElementBinding::HTMLImageElementMethods;
|
||||
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||
use dom::bindings::codegen::Bindings::ServoHTMLParserBinding;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::refcounted::Trusted;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
|
@ -277,8 +276,7 @@ impl ServoHTMLParser {
|
|||
pipeline: pipeline,
|
||||
};
|
||||
|
||||
reflect_dom_object(box parser, GlobalRef::Window(document.window()),
|
||||
ServoHTMLParserBinding::Wrap)
|
||||
reflect_dom_object(box parser, document.window(), ServoHTMLParserBinding::Wrap)
|
||||
}
|
||||
|
||||
#[allow(unrooted_must_root)]
|
||||
|
@ -314,8 +312,7 @@ impl ServoHTMLParser {
|
|||
pipeline: None,
|
||||
};
|
||||
|
||||
reflect_dom_object(box parser, GlobalRef::Window(document.window()),
|
||||
ServoHTMLParserBinding::Wrap)
|
||||
reflect_dom_object(box parser, document.window(), ServoHTMLParserBinding::Wrap)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
use dom::bindings::cell::DOMRefCell;
|
||||
use dom::bindings::codegen::Bindings::ServoXMLParserBinding;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::trace::JSTraceable;
|
||||
|
@ -95,8 +94,7 @@ impl ServoXMLParser {
|
|||
pipeline: pipeline,
|
||||
};
|
||||
|
||||
reflect_dom_object(box parser, GlobalRef::Window(document.window()),
|
||||
ServoXMLParserBinding::Wrap)
|
||||
reflect_dom_object(box parser, document.window(), ServoXMLParserBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn window(&self) -> &Window {
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
use dom::bindings::codegen::Bindings::StorageBinding;
|
||||
use dom::bindings::codegen::Bindings::StorageBinding::StorageMethods;
|
||||
use dom::bindings::error::{Error, ErrorResult};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::refcounted::Trusted;
|
||||
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::storageevent::StorageEvent;
|
||||
use dom::urlhelper::UrlHelper;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
|
@ -35,8 +35,8 @@ impl Storage {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: &GlobalRef, storage_type: StorageType) -> Root<Storage> {
|
||||
reflect_dom_object(box Storage::new_inherited(storage_type), *global, StorageBinding::Wrap)
|
||||
pub fn new(global: &GlobalScope, storage_type: StorageType) -> Root<Storage> {
|
||||
reflect_dom_object(box Storage::new_inherited(storage_type), global, StorageBinding::Wrap)
|
||||
}
|
||||
|
||||
fn get_url(&self) -> Url {
|
||||
|
@ -191,7 +191,7 @@ impl Runnable for StorageEventRunnable {
|
|||
let ev_url = storage.get_url();
|
||||
|
||||
let storage_event = StorageEvent::new(
|
||||
global_ref,
|
||||
global_ref.as_global_scope(),
|
||||
atom!("storage"),
|
||||
EventBubbles::DoesNotBubble, EventCancelable::NotCancelable,
|
||||
this.key.map(DOMString::from), this.old_value.map(DOMString::from), this.new_value.map(DOMString::from),
|
||||
|
|
|
@ -12,6 +12,7 @@ use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference};
|
|||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::storage::Storage;
|
||||
use dom::window::Window;
|
||||
use string_cache::Atom;
|
||||
|
@ -46,11 +47,11 @@ impl StorageEvent {
|
|||
pub fn new_uninitialized(window: &Window,
|
||||
url: DOMString) -> Root<StorageEvent> {
|
||||
reflect_dom_object(box StorageEvent::new_inherited(None, None, None, url, None),
|
||||
GlobalRef::Window(window),
|
||||
window,
|
||||
StorageEventBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef,
|
||||
pub fn new(global: &GlobalScope,
|
||||
type_: Atom,
|
||||
bubbles: EventBubbles,
|
||||
cancelable: EventCancelable,
|
||||
|
@ -80,7 +81,7 @@ impl StorageEvent {
|
|||
let storageArea = init.storageArea.r();
|
||||
let bubbles = EventBubbles::from(init.parent.bubbles);
|
||||
let cancelable = EventCancelable::from(init.parent.cancelable);
|
||||
let event = StorageEvent::new(global, Atom::from(type_),
|
||||
let event = StorageEvent::new(global.as_global_scope(), Atom::from(type_),
|
||||
bubbles, cancelable,
|
||||
key, oldValue, newValue,
|
||||
url, storageArea);
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
use dom::bindings::codegen::Bindings::StyleSheetBinding;
|
||||
use dom::bindings::codegen::Bindings::StyleSheetBinding::StyleSheetMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::DOMString;
|
||||
|
@ -35,7 +34,7 @@ impl StyleSheet {
|
|||
href: Option<DOMString>,
|
||||
title: Option<DOMString>) -> Root<StyleSheet> {
|
||||
reflect_dom_object(box StyleSheet::new_inherited(type_, href, title),
|
||||
GlobalRef::Window(window),
|
||||
window,
|
||||
StyleSheetBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
use dom::bindings::codegen::Bindings::StyleSheetListBinding;
|
||||
use dom::bindings::codegen::Bindings::StyleSheetListBinding::StyleSheetListMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::document::Document;
|
||||
|
@ -29,7 +28,7 @@ impl StyleSheetList {
|
|||
#[allow(unrooted_must_root)]
|
||||
pub fn new(window: &Window, document: JS<Document>) -> Root<StyleSheetList> {
|
||||
reflect_dom_object(box StyleSheetList::new_inherited(document),
|
||||
GlobalRef::Window(window), StyleSheetListBinding::Wrap)
|
||||
window, StyleSheetListBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
|||
use dom::bindings::str::{ByteString, DOMString, USVString};
|
||||
use dom::bindings::weakref::MutableWeakRef;
|
||||
use dom::blob::{Blob, BlobImpl};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::promise::Promise;
|
||||
use dom::promisenativehandler::{PromiseNativeHandler, Callback};
|
||||
use dom::url::URL;
|
||||
|
@ -57,23 +58,23 @@ impl TestBinding {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef) -> Root<TestBinding> {
|
||||
pub fn new(global: &GlobalScope) -> Root<TestBinding> {
|
||||
reflect_dom_object(box TestBinding::new_inherited(),
|
||||
global, TestBindingBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn Constructor(global: GlobalRef) -> Fallible<Root<TestBinding>> {
|
||||
Ok(TestBinding::new(global))
|
||||
Ok(TestBinding::new(global.as_global_scope()))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
pub fn Constructor_(global: GlobalRef, nums: Vec<f64>) -> Fallible<Root<TestBinding>> {
|
||||
Ok(TestBinding::new(global))
|
||||
Ok(TestBinding::new(global.as_global_scope()))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
pub fn Constructor__(global: GlobalRef, num: f64) -> Fallible<Root<TestBinding>> {
|
||||
Ok(TestBinding::new(global))
|
||||
Ok(TestBinding::new(global.as_global_scope()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,7 +114,7 @@ impl TestBindingMethods for TestBinding {
|
|||
fn EnumAttribute(&self) -> TestEnum { TestEnum::_empty }
|
||||
fn SetEnumAttribute(&self, _: TestEnum) {}
|
||||
fn InterfaceAttribute(&self) -> Root<Blob> {
|
||||
Blob::new(self.global().r(), BlobImpl::new_from_bytes(vec![]), "".to_owned())
|
||||
Blob::new(self.global().r().as_global_scope(), BlobImpl::new_from_bytes(vec![]), "".to_owned())
|
||||
}
|
||||
fn SetInterfaceAttribute(&self, _: &Blob) {}
|
||||
fn UnionAttribute(&self) -> HTMLElementOrLong { HTMLElementOrLong::Long(0) }
|
||||
|
@ -209,7 +210,7 @@ impl TestBindingMethods for TestBinding {
|
|||
fn SetAttr_to_automatically_rename(&self, _: DOMString) {}
|
||||
fn GetEnumAttributeNullable(&self) -> Option<TestEnum> { Some(TestEnum::_empty) }
|
||||
fn GetInterfaceAttributeNullable(&self) -> Option<Root<Blob>> {
|
||||
Some(Blob::new(self.global().r(), BlobImpl::new_from_bytes(vec![]), "".to_owned()))
|
||||
Some(Blob::new(self.global().r().as_global_scope(), BlobImpl::new_from_bytes(vec![]), "".to_owned()))
|
||||
}
|
||||
fn SetInterfaceAttributeNullable(&self, _: Option<&Blob>) {}
|
||||
fn GetInterfaceAttributeWeak(&self) -> Option<Root<URL>> {
|
||||
|
@ -264,7 +265,7 @@ impl TestBindingMethods for TestBinding {
|
|||
fn ReceiveByteString(&self) -> ByteString { ByteString::new(vec!()) }
|
||||
fn ReceiveEnum(&self) -> TestEnum { TestEnum::_empty }
|
||||
fn ReceiveInterface(&self) -> Root<Blob> {
|
||||
Blob::new(self.global().r(), BlobImpl::new_from_bytes(vec![]), "".to_owned())
|
||||
Blob::new(self.global().r().as_global_scope(), BlobImpl::new_from_bytes(vec![]), "".to_owned())
|
||||
}
|
||||
fn ReceiveAny(&self, _: *mut JSContext) -> JSVal { NullValue() }
|
||||
fn ReceiveObject(&self, cx: *mut JSContext) -> NonZero<*mut JSObject> {
|
||||
|
@ -287,7 +288,7 @@ impl TestBindingMethods for TestBinding {
|
|||
}
|
||||
fn ReceiveSequence(&self) -> Vec<i32> { vec![1] }
|
||||
fn ReceiveInterfaceSequence(&self) -> Vec<Root<Blob>> {
|
||||
vec![Blob::new(self.global().r(), BlobImpl::new_from_bytes(vec![]), "".to_owned())]
|
||||
vec![Blob::new(self.global().r().as_global_scope(), BlobImpl::new_from_bytes(vec![]), "".to_owned())]
|
||||
}
|
||||
|
||||
fn ReceiveNullableBoolean(&self) -> Option<bool> { Some(false) }
|
||||
|
@ -308,7 +309,7 @@ impl TestBindingMethods for TestBinding {
|
|||
fn ReceiveNullableByteString(&self) -> Option<ByteString> { Some(ByteString::new(vec!())) }
|
||||
fn ReceiveNullableEnum(&self) -> Option<TestEnum> { Some(TestEnum::_empty) }
|
||||
fn ReceiveNullableInterface(&self) -> Option<Root<Blob>> {
|
||||
Some(Blob::new(self.global().r(), BlobImpl::new_from_bytes(vec![]), "".to_owned()))
|
||||
Some(Blob::new(self.global().r().as_global_scope(), BlobImpl::new_from_bytes(vec![]), "".to_owned()))
|
||||
}
|
||||
fn ReceiveNullableObject(&self, cx: *mut JSContext) -> Option<NonZero<*mut JSObject>> {
|
||||
self.GetObjectAttributeNullable(cx)
|
||||
|
@ -691,7 +692,7 @@ impl TestBindingMethods for TestBinding {
|
|||
resolve: Option<Rc<SimpleCallback>>,
|
||||
reject: Option<Rc<SimpleCallback>>) -> Rc<Promise> {
|
||||
let global = self.global();
|
||||
let handler = PromiseNativeHandler::new(global.r(),
|
||||
let handler = PromiseNativeHandler::new(global.r().as_global_scope(),
|
||||
resolve.map(SimpleHandler::new),
|
||||
reject.map(SimpleHandler::new));
|
||||
let p = Promise::new(global.r());
|
||||
|
|
|
@ -11,6 +11,7 @@ use dom::bindings::global::GlobalRef;
|
|||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::globalscope::GlobalScope;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct TestBindingIterable {
|
||||
|
@ -19,7 +20,7 @@ pub struct TestBindingIterable {
|
|||
}
|
||||
|
||||
impl TestBindingIterable {
|
||||
fn new(global: GlobalRef) -> Root<TestBindingIterable> {
|
||||
fn new(global: &GlobalScope) -> Root<TestBindingIterable> {
|
||||
reflect_dom_object(box TestBindingIterable {
|
||||
reflector: Reflector::new(),
|
||||
vals: DOMRefCell::new(vec![]),
|
||||
|
@ -27,7 +28,7 @@ impl TestBindingIterable {
|
|||
}
|
||||
|
||||
pub fn Constructor(global: GlobalRef) -> Fallible<Root<TestBindingIterable>> {
|
||||
Ok(TestBindingIterable::new(global))
|
||||
Ok(TestBindingIterable::new(global.as_global_scope()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ use dom::bindings::iterable::Iterable;
|
|||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::globalscope::GlobalScope;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct TestBindingPairIterable {
|
||||
|
@ -35,7 +36,7 @@ impl Iterable for TestBindingPairIterable {
|
|||
}
|
||||
|
||||
impl TestBindingPairIterable {
|
||||
fn new(global: GlobalRef) -> Root<TestBindingPairIterable> {
|
||||
fn new(global: &GlobalScope) -> Root<TestBindingPairIterable> {
|
||||
reflect_dom_object(box TestBindingPairIterable {
|
||||
reflector: Reflector::new(),
|
||||
map: DOMRefCell::new(vec![]),
|
||||
|
@ -43,7 +44,7 @@ impl TestBindingPairIterable {
|
|||
}
|
||||
|
||||
pub fn Constructor(global: GlobalRef) -> Fallible<Root<TestBindingPairIterable>> {
|
||||
Ok(TestBindingPairIterable::new(global))
|
||||
Ok(TestBindingPairIterable::new(global.as_global_scope()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue