mirror of
https://github.com/servo/servo.git
synced 2025-06-09 17:13:24 +00:00
Auto merge of #13596 - nox:inline, r=Ms2ger
Get rid of dom::bindings::global Globals in that PR are now represented by the fake IDL interface `GlobalScope`. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13596) <!-- Reviewable:end -->
This commit is contained in:
commit
a6e4b5bb86
170 changed files with 1595 additions and 1742 deletions
|
@ -174,8 +174,6 @@ pub struct Request {
|
||||||
pub body: RefCell<Option<Vec<u8>>>,
|
pub body: RefCell<Option<Vec<u8>>>,
|
||||||
// TODO: client object
|
// TODO: client object
|
||||||
pub is_service_worker_global_scope: bool,
|
pub is_service_worker_global_scope: bool,
|
||||||
// pub client: GlobalRef, // XXXManishearth copy over only the relevant fields of the global scope,
|
|
||||||
// not the entire scope to avoid the libscript dependency
|
|
||||||
pub window: Cell<Window>,
|
pub window: Cell<Window>,
|
||||||
// TODO: target browsing context
|
// TODO: target browsing context
|
||||||
pub keep_alive: Cell<bool>,
|
pub keep_alive: Cell<bool>,
|
||||||
|
|
|
@ -4,12 +4,12 @@
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::FormDataBinding::FormDataMethods;
|
use dom::bindings::codegen::Bindings::FormDataBinding::FormDataMethods;
|
||||||
use dom::bindings::error::{Error, Fallible};
|
use dom::bindings::error::{Error, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::Reflectable;
|
use dom::bindings::reflector::Reflectable;
|
||||||
use dom::bindings::str::USVString;
|
use dom::bindings::str::USVString;
|
||||||
use dom::blob::{Blob, BlobImpl};
|
use dom::blob::{Blob, BlobImpl};
|
||||||
use dom::formdata::FormData;
|
use dom::formdata::FormData;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::promise::Promise;
|
use dom::promise::Promise;
|
||||||
use encoding::all::UTF_8;
|
use encoding::all::UTF_8;
|
||||||
use encoding::types::{DecoderTrap, Encoding};
|
use encoding::types::{DecoderTrap, Encoding};
|
||||||
|
@ -42,11 +42,11 @@ pub enum FetchedData {
|
||||||
// https://fetch.spec.whatwg.org/#concept-body-consume-body
|
// https://fetch.spec.whatwg.org/#concept-body-consume-body
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn consume_body<T: BodyOperations + Reflectable>(object: &T, body_type: BodyType) -> Rc<Promise> {
|
pub fn consume_body<T: BodyOperations + Reflectable>(object: &T, body_type: BodyType) -> Rc<Promise> {
|
||||||
let promise = Promise::new(object.global().r());
|
let promise = Promise::new(&object.global());
|
||||||
|
|
||||||
// Step 1
|
// Step 1
|
||||||
if object.get_body_used() || object.is_locked() {
|
if object.get_body_used() || object.is_locked() {
|
||||||
promise.reject_error(promise.global().r().get_cx(), Error::Type(
|
promise.reject_error(promise.global().get_cx(), Error::Type(
|
||||||
"The response's stream is disturbed or locked".to_string()));
|
"The response's stream is disturbed or locked".to_string()));
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ pub fn consume_body_with_promise<T: BodyOperations + Reflectable>(object: &T,
|
||||||
body_type,
|
body_type,
|
||||||
object.get_mime_type());
|
object.get_mime_type());
|
||||||
|
|
||||||
let cx = promise.global().r().get_cx();
|
let cx = promise.global().get_cx();
|
||||||
match pkg_data_results {
|
match pkg_data_results {
|
||||||
Ok(results) => {
|
Ok(results) => {
|
||||||
match results {
|
match results {
|
||||||
|
@ -98,13 +98,14 @@ fn run_package_data_algorithm<T: BodyOperations + Reflectable>(object: &T,
|
||||||
body_type: BodyType,
|
body_type: BodyType,
|
||||||
mime_type: Ref<Vec<u8>>)
|
mime_type: Ref<Vec<u8>>)
|
||||||
-> Fallible<FetchedData> {
|
-> Fallible<FetchedData> {
|
||||||
let cx = object.global().r().get_cx();
|
let global = object.global();
|
||||||
|
let cx = global.get_cx();
|
||||||
let mime = &*mime_type;
|
let mime = &*mime_type;
|
||||||
match body_type {
|
match body_type {
|
||||||
BodyType::Text => run_text_data_algorithm(bytes),
|
BodyType::Text => run_text_data_algorithm(bytes),
|
||||||
BodyType::Json => run_json_data_algorithm(cx, bytes),
|
BodyType::Json => run_json_data_algorithm(cx, bytes),
|
||||||
BodyType::Blob => run_blob_data_algorithm(object.global().r(), bytes, mime),
|
BodyType::Blob => run_blob_data_algorithm(&global, bytes, mime),
|
||||||
BodyType::FormData => run_form_data_algorithm(object.global().r(), bytes, mime),
|
BodyType::FormData => run_form_data_algorithm(&global, bytes, mime),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +133,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>,
|
bytes: Vec<u8>,
|
||||||
mime: &[u8]) -> Fallible<FetchedData> {
|
mime: &[u8]) -> Fallible<FetchedData> {
|
||||||
let mime_string = if let Ok(s) = String::from_utf8(mime.to_vec()) {
|
let mime_string = if let Ok(s) = String::from_utf8(mime.to_vec()) {
|
||||||
|
@ -144,7 +145,7 @@ fn run_blob_data_algorithm(root: GlobalRef,
|
||||||
Ok(FetchedData::BlobData(blob))
|
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) {
|
let mime_str = if let Ok(s) = str::from_utf8(mime) {
|
||||||
s
|
s
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -13,13 +13,13 @@ use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
|
||||||
use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods;
|
use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods;
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, jsstring_to_str};
|
use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, jsstring_to_str};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::Reflectable;
|
use dom::bindings::reflector::Reflectable;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::browsingcontext::BrowsingContext;
|
use dom::browsingcontext::BrowsingContext;
|
||||||
use dom::element::Element;
|
use dom::element::Element;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::node::Node;
|
use dom::node::Node;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
|
@ -33,7 +33,7 @@ use uuid::Uuid;
|
||||||
|
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub fn handle_evaluate_js(global: &GlobalRef, eval: String, reply: IpcSender<EvaluateJSReply>) {
|
pub fn handle_evaluate_js(global: &GlobalScope, eval: String, reply: IpcSender<EvaluateJSReply>) {
|
||||||
// global.get_cx() returns a valid `JSContext` pointer, so this is safe.
|
// global.get_cx() returns a valid `JSContext` pointer, so this is safe.
|
||||||
let result = unsafe {
|
let result = unsafe {
|
||||||
let cx = global.get_cx();
|
let cx = global.get_cx();
|
||||||
|
@ -245,7 +245,7 @@ pub fn handle_modify_attribute(context: &BrowsingContext,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_wants_live_notifications(global: &GlobalRef, send_notifications: bool) {
|
pub fn handle_wants_live_notifications(global: &GlobalScope, send_notifications: bool) {
|
||||||
global.set_devtools_wants_updates(send_notifications);
|
global.set_devtools_wants_updates(send_notifications);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,7 +271,8 @@ pub fn handle_request_animation_frame(context: &BrowsingContext,
|
||||||
};
|
};
|
||||||
|
|
||||||
let doc = context.active_document();
|
let doc = context.active_document();
|
||||||
let devtools_sender = context.active_window().devtools_chan().unwrap();
|
let devtools_sender =
|
||||||
|
context.active_window().upcast::<GlobalScope>().devtools_chan().unwrap().clone();
|
||||||
doc.request_animation_frame(box move |time| {
|
doc.request_animation_frame(box move |time| {
|
||||||
let msg = ScriptToDevtoolsControlMsg::FramerateTick(actor_name, time);
|
let msg = ScriptToDevtoolsControlMsg::FramerateTick(actor_name, time);
|
||||||
devtools_sender.send(msg).unwrap();
|
devtools_sender.send(msg).unwrap();
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
use devtools_traits::AttrInfo;
|
use devtools_traits::AttrInfo;
|
||||||
use dom::bindings::cell::DOMRefCell;
|
use dom::bindings::cell::DOMRefCell;
|
||||||
use dom::bindings::codegen::Bindings::AttrBinding::{self, AttrMethods};
|
use dom::bindings::codegen::Bindings::AttrBinding::{self, AttrMethods};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{JS, MutNullableHeap};
|
use dom::bindings::js::{JS, MutNullableHeap};
|
||||||
use dom::bindings::js::{LayoutJS, Root, RootedReference};
|
use dom::bindings::js::{LayoutJS, Root, RootedReference};
|
||||||
|
@ -66,7 +65,7 @@ impl Attr {
|
||||||
namespace,
|
namespace,
|
||||||
prefix,
|
prefix,
|
||||||
owner),
|
owner),
|
||||||
GlobalRef::Window(window),
|
window,
|
||||||
AttrBinding::Wrap)
|
AttrBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,12 @@ use dom::bindings::cell::DOMRefCell;
|
||||||
use dom::bindings::codegen::Bindings::BeforeUnloadEventBinding;
|
use dom::bindings::codegen::Bindings::BeforeUnloadEventBinding;
|
||||||
use dom::bindings::codegen::Bindings::BeforeUnloadEventBinding::BeforeUnloadEventMethods;
|
use dom::bindings::codegen::Bindings::BeforeUnloadEventBinding::BeforeUnloadEventMethods;
|
||||||
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use string_cache::Atom;
|
use string_cache::Atom;
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#beforeunloadevent
|
// 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(),
|
reflect_dom_object(box BeforeUnloadEvent::new_inherited(),
|
||||||
global,
|
global,
|
||||||
BeforeUnloadEventBinding::Wrap)
|
BeforeUnloadEventBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: GlobalRef,
|
pub fn new(global: &GlobalScope,
|
||||||
type_: Atom,
|
type_: Atom,
|
||||||
bubbles: EventBubbles,
|
bubbles: EventBubbles,
|
||||||
cancelable: EventCancelable) -> Root<BeforeUnloadEvent> {
|
cancelable: EventCancelable) -> Root<BeforeUnloadEvent> {
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
//! Base classes to work with IDL callbacks.
|
//! Base classes to work with IDL callbacks.
|
||||||
|
|
||||||
use dom::bindings::error::{Error, Fallible, report_pending_exception};
|
use dom::bindings::error::{Error, Fallible, report_pending_exception};
|
||||||
use dom::bindings::global::global_root_from_object;
|
|
||||||
use dom::bindings::reflector::Reflectable;
|
use dom::bindings::reflector::Reflectable;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use js::jsapi::{Heap, MutableHandleObject, RootedObject};
|
use js::jsapi::{Heap, MutableHandleObject, RootedObject};
|
||||||
use js::jsapi::{IsCallable, JSContext, JSObject, JS_WrapObject};
|
use js::jsapi::{IsCallable, JSContext, JSObject, JS_WrapObject};
|
||||||
use js::jsapi::{JSCompartment, JS_EnterCompartment, JS_LeaveCompartment};
|
use js::jsapi::{JSCompartment, JS_EnterCompartment, JS_LeaveCompartment};
|
||||||
|
@ -165,8 +165,8 @@ impl<'a> CallSetup<'a> {
|
||||||
callback: &T,
|
callback: &T,
|
||||||
handling: ExceptionHandling)
|
handling: ExceptionHandling)
|
||||||
-> CallSetup<'a> {
|
-> CallSetup<'a> {
|
||||||
let global = unsafe { global_root_from_object(callback.callback()) };
|
let global = unsafe { GlobalScope::from_object(callback.callback()) };
|
||||||
let cx = global.r().get_cx();
|
let cx = global.get_cx();
|
||||||
|
|
||||||
exception_compartment.ptr = unsafe {
|
exception_compartment.ptr = unsafe {
|
||||||
GetGlobalForObjectCrossCompartment(callback.callback())
|
GetGlobalForObjectCrossCompartment(callback.callback())
|
||||||
|
|
|
@ -817,16 +817,16 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
||||||
{ // Scope for our JSAutoCompartment.
|
{ // Scope for our JSAutoCompartment.
|
||||||
|
|
||||||
rooted!(in(cx) let globalObj = CurrentGlobalOrNull(cx));
|
rooted!(in(cx) let globalObj = CurrentGlobalOrNull(cx));
|
||||||
let promiseGlobal = global_root_from_object_maybe_wrapped(globalObj.handle().get());
|
let promiseGlobal = GlobalScope::from_object_maybe_wrapped(globalObj.handle().get());
|
||||||
|
|
||||||
rooted!(in(cx) let mut valueToResolve = $${val}.get());
|
rooted!(in(cx) let mut valueToResolve = $${val}.get());
|
||||||
if !JS_WrapValue(cx, valueToResolve.handle_mut()) {
|
if !JS_WrapValue(cx, valueToResolve.handle_mut()) {
|
||||||
$*{exceptionCode}
|
$*{exceptionCode}
|
||||||
}
|
}
|
||||||
match Promise::Resolve(promiseGlobal.r(), cx, valueToResolve.handle()) {
|
match Promise::Resolve(&promiseGlobal, cx, valueToResolve.handle()) {
|
||||||
Ok(value) => value,
|
Ok(value) => value,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
throw_dom_exception(cx, promiseGlobal.r(), error);
|
throw_dom_exception(cx, &promiseGlobal, error);
|
||||||
$*{exceptionCode}
|
$*{exceptionCode}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1927,10 +1927,12 @@ class CGImports(CGWrapper):
|
||||||
if t in dictionaries or t in enums:
|
if t in dictionaries or t in enums:
|
||||||
continue
|
continue
|
||||||
if t.isInterface() or t.isNamespace():
|
if t.isInterface() or t.isNamespace():
|
||||||
descriptor = descriptorProvider.getDescriptor(getIdentifier(t).name)
|
name = getIdentifier(t).name
|
||||||
|
descriptor = descriptorProvider.getDescriptor(name)
|
||||||
|
if name != 'GlobalScope':
|
||||||
extras += [descriptor.path]
|
extras += [descriptor.path]
|
||||||
if descriptor.interface.parent:
|
parentName = descriptor.getParentName()
|
||||||
parentName = getIdentifier(descriptor.interface.parent).name
|
if parentName:
|
||||||
descriptor = descriptorProvider.getDescriptor(parentName)
|
descriptor = descriptorProvider.getDescriptor(parentName)
|
||||||
extras += [descriptor.path, descriptor.bindingPath]
|
extras += [descriptor.path, descriptor.bindingPath]
|
||||||
elif t.isType() and t.isMozMap():
|
elif t.isType() and t.isMozMap():
|
||||||
|
@ -2523,7 +2525,8 @@ class CGWrapMethod(CGAbstractMethod):
|
||||||
def __init__(self, descriptor):
|
def __init__(self, descriptor):
|
||||||
assert not descriptor.interface.isCallback()
|
assert not descriptor.interface.isCallback()
|
||||||
assert not descriptor.isGlobal()
|
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')]
|
Argument("Box<%s>" % descriptor.concreteType, 'object')]
|
||||||
retval = 'Root<%s>' % descriptor.concreteType
|
retval = 'Root<%s>' % descriptor.concreteType
|
||||||
CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args,
|
CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args,
|
||||||
|
@ -2754,7 +2757,7 @@ assert!((*cache)[PrototypeList::Constructor::%(id)s as usize].is_null());
|
||||||
getPrototypeProto = "prototype_proto.set(JS_GetObjectPrototype(cx, global))"
|
getPrototypeProto = "prototype_proto.set(JS_GetObjectPrototype(cx, global))"
|
||||||
else:
|
else:
|
||||||
getPrototypeProto = ("%s::GetProtoObject(cx, global, prototype_proto.handle_mut())" %
|
getPrototypeProto = ("%s::GetProtoObject(cx, global, prototype_proto.handle_mut())" %
|
||||||
toBindingNamespace(self.descriptor.prototypeChain[-2]))
|
toBindingNamespace(self.descriptor.getParentName()))
|
||||||
|
|
||||||
code = [CGGeneric("""\
|
code = [CGGeneric("""\
|
||||||
rooted!(in(cx) let mut prototype_proto = ptr::null_mut());
|
rooted!(in(cx) let mut prototype_proto = ptr::null_mut());
|
||||||
|
@ -2808,8 +2811,9 @@ assert!((*cache)[PrototypeList::ID::%(id)s as usize].is_null());
|
||||||
properties["length"] = methodLength(self.descriptor.interface.ctor())
|
properties["length"] = methodLength(self.descriptor.interface.ctor())
|
||||||
else:
|
else:
|
||||||
properties["length"] = 0
|
properties["length"] = 0
|
||||||
if self.descriptor.interface.parent:
|
parentName = self.descriptor.getParentName()
|
||||||
parentName = toBindingNamespace(self.descriptor.getParentName())
|
if parentName:
|
||||||
|
parentName = toBindingNamespace(parentName)
|
||||||
code.append(CGGeneric("""
|
code.append(CGGeneric("""
|
||||||
rooted!(in(cx) let mut interface_proto = ptr::null_mut());
|
rooted!(in(cx) let mut interface_proto = ptr::null_mut());
|
||||||
%s::GetConstructorObject(cx, global, interface_proto.handle_mut());""" % parentName))
|
%s::GetConstructorObject(cx, global, interface_proto.handle_mut());""" % parentName))
|
||||||
|
@ -3164,16 +3168,15 @@ class CGCallGenerator(CGThing):
|
||||||
|
|
||||||
if isFallible:
|
if isFallible:
|
||||||
if static:
|
if static:
|
||||||
glob = ""
|
glob = "&global"
|
||||||
else:
|
else:
|
||||||
glob = " let global = global_root_from_reflector(this);\n"
|
glob = "&this.global()"
|
||||||
|
|
||||||
self.cgRoot.append(CGGeneric(
|
self.cgRoot.append(CGGeneric(
|
||||||
"let result = match result {\n"
|
"let result = match result {\n"
|
||||||
" Ok(result) => result,\n"
|
" Ok(result) => result,\n"
|
||||||
" Err(e) => {\n"
|
" Err(e) => {\n"
|
||||||
"%s"
|
" throw_dom_exception(cx, %s, e);\n"
|
||||||
" throw_dom_exception(cx, global.r(), e);\n"
|
|
||||||
" return%s;\n"
|
" return%s;\n"
|
||||||
" },\n"
|
" },\n"
|
||||||
"};" % (glob, errorResult)))
|
"};" % (glob, errorResult)))
|
||||||
|
@ -3383,7 +3386,7 @@ class CGAbstractStaticBindingMethod(CGAbstractMethod):
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
preamble = CGGeneric("""\
|
preamble = CGGeneric("""\
|
||||||
let global = global_root_from_object(JS_CALLEE(cx, vp).to_object());
|
let global = GlobalScope::from_object(JS_CALLEE(cx, vp).to_object());
|
||||||
""")
|
""")
|
||||||
return CGList([preamble, self.generate_code()])
|
return CGList([preamble, self.generate_code()])
|
||||||
|
|
||||||
|
@ -3435,7 +3438,7 @@ class CGStaticMethod(CGAbstractStaticBindingMethod):
|
||||||
nativeName = CGSpecializedMethod.makeNativeName(self.descriptor,
|
nativeName = CGSpecializedMethod.makeNativeName(self.descriptor,
|
||||||
self.method)
|
self.method)
|
||||||
setupArgs = CGGeneric("let args = CallArgs::from_vp(vp, argc);\n")
|
setupArgs = CGGeneric("let args = CallArgs::from_vp(vp, argc);\n")
|
||||||
call = CGMethodCall(["global.r()"], nativeName, True, self.descriptor, self.method)
|
call = CGMethodCall(["&global"], nativeName, True, self.descriptor, self.method)
|
||||||
return CGList([setupArgs, call])
|
return CGList([setupArgs, call])
|
||||||
|
|
||||||
|
|
||||||
|
@ -3489,7 +3492,7 @@ class CGStaticGetter(CGAbstractStaticBindingMethod):
|
||||||
nativeName = CGSpecializedGetter.makeNativeName(self.descriptor,
|
nativeName = CGSpecializedGetter.makeNativeName(self.descriptor,
|
||||||
self.attr)
|
self.attr)
|
||||||
setupArgs = CGGeneric("let args = CallArgs::from_vp(vp, argc);\n")
|
setupArgs = CGGeneric("let args = CallArgs::from_vp(vp, argc);\n")
|
||||||
call = CGGetterCall(["global.r()"], self.attr.type, nativeName, self.descriptor,
|
call = CGGetterCall(["&global"], self.attr.type, nativeName, self.descriptor,
|
||||||
self.attr)
|
self.attr)
|
||||||
return CGList([setupArgs, call])
|
return CGList([setupArgs, call])
|
||||||
|
|
||||||
|
@ -3542,7 +3545,7 @@ class CGStaticSetter(CGAbstractStaticBindingMethod):
|
||||||
" throw_type_error(cx, \"Not enough arguments to %s setter.\");\n"
|
" throw_type_error(cx, \"Not enough arguments to %s setter.\");\n"
|
||||||
" return false;\n"
|
" return false;\n"
|
||||||
"}" % self.attr.identifier.name)
|
"}" % self.attr.identifier.name)
|
||||||
call = CGSetterCall(["global.r()"], self.attr.type, nativeName, self.descriptor,
|
call = CGSetterCall(["&global"], self.attr.type, nativeName, self.descriptor,
|
||||||
self.attr)
|
self.attr)
|
||||||
return CGList([checkForArg, call])
|
return CGList([checkForArg, call])
|
||||||
|
|
||||||
|
@ -5249,12 +5252,12 @@ class CGClassConstructHook(CGAbstractExternMethod):
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
preamble = CGGeneric("""\
|
preamble = CGGeneric("""\
|
||||||
let global = global_root_from_object(JS_CALLEE(cx, vp).to_object());
|
let global = GlobalScope::from_object(JS_CALLEE(cx, vp).to_object());
|
||||||
let args = CallArgs::from_vp(vp, argc);
|
let args = CallArgs::from_vp(vp, argc);
|
||||||
""")
|
""")
|
||||||
name = self.constructor.identifier.name
|
name = self.constructor.identifier.name
|
||||||
nativeName = MakeNativeName(self.descriptor.binaryNameFor(name))
|
nativeName = MakeNativeName(self.descriptor.binaryNameFor(name))
|
||||||
callGenerator = CGMethodCall(["global.r()"], nativeName, True,
|
callGenerator = CGMethodCall(["&global"], nativeName, True,
|
||||||
self.descriptor, self.constructor)
|
self.descriptor, self.constructor)
|
||||||
return CGList([preamble, callGenerator])
|
return CGList([preamble, callGenerator])
|
||||||
|
|
||||||
|
@ -5496,10 +5499,6 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
||||||
'dom::bindings::codegen::InterfaceObjectMap',
|
'dom::bindings::codegen::InterfaceObjectMap',
|
||||||
'dom::bindings::constant::ConstantSpec',
|
'dom::bindings::constant::ConstantSpec',
|
||||||
'dom::bindings::constant::ConstantVal',
|
'dom::bindings::constant::ConstantVal',
|
||||||
'dom::bindings::global::GlobalRef',
|
|
||||||
'dom::bindings::global::global_root_from_object',
|
|
||||||
'dom::bindings::global::global_root_from_object_maybe_wrapped',
|
|
||||||
'dom::bindings::global::global_root_from_reflector',
|
|
||||||
'dom::bindings::interface::ConstructorClassHook',
|
'dom::bindings::interface::ConstructorClassHook',
|
||||||
'dom::bindings::interface::InterfaceConstructorBehavior',
|
'dom::bindings::interface::InterfaceConstructorBehavior',
|
||||||
'dom::bindings::interface::NonCallbackInterfaceObjectClass',
|
'dom::bindings::interface::NonCallbackInterfaceObjectClass',
|
||||||
|
@ -5593,6 +5592,7 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
||||||
'dom::bindings::weakref::WeakBox',
|
'dom::bindings::weakref::WeakBox',
|
||||||
'dom::bindings::weakref::WeakReferenceable',
|
'dom::bindings::weakref::WeakReferenceable',
|
||||||
'dom::browsingcontext::BrowsingContext',
|
'dom::browsingcontext::BrowsingContext',
|
||||||
|
'dom::globalscope::GlobalScope',
|
||||||
'mem::heap_size_of_raw_self_and_children',
|
'mem::heap_size_of_raw_self_and_children',
|
||||||
'libc',
|
'libc',
|
||||||
'util::prefs::PREFS',
|
'util::prefs::PREFS',
|
||||||
|
@ -5744,6 +5744,7 @@ class CGDescriptor(CGThing):
|
||||||
|
|
||||||
cgThings.append(CGGeneric(str(properties)))
|
cgThings.append(CGGeneric(str(properties)))
|
||||||
|
|
||||||
|
if not descriptor.interface.getExtendedAttribute("Inline"):
|
||||||
if not descriptor.interface.isCallback() and not descriptor.interface.isNamespace():
|
if not descriptor.interface.isCallback() and not descriptor.interface.isNamespace():
|
||||||
cgThings.append(CGGetProtoObjectMethod(descriptor))
|
cgThings.append(CGGetProtoObjectMethod(descriptor))
|
||||||
reexports.append('GetProtoObject')
|
reexports.append('GetProtoObject')
|
||||||
|
@ -5768,10 +5769,14 @@ class CGDescriptor(CGThing):
|
||||||
cgThings = CGWrapper(CGNamespace(toBindingNamespace(descriptor.name),
|
cgThings = CGWrapper(CGNamespace(toBindingNamespace(descriptor.name),
|
||||||
cgThings, public=True),
|
cgThings, public=True),
|
||||||
post='\n')
|
post='\n')
|
||||||
|
|
||||||
|
if reexports:
|
||||||
reexports = ', '.join(map(lambda name: reexportedName(name), reexports))
|
reexports = ', '.join(map(lambda name: reexportedName(name), reexports))
|
||||||
self.cgRoot = CGList([CGGeneric('pub use self::%s::{%s};' % (toBindingNamespace(descriptor.name), reexports)),
|
cgThings = CGList([CGGeneric('pub use self::%s::{%s};' % (toBindingNamespace(descriptor.name), reexports)),
|
||||||
cgThings], '\n')
|
cgThings], '\n')
|
||||||
|
|
||||||
|
self.cgRoot = cgThings
|
||||||
|
|
||||||
def define(self):
|
def define(self):
|
||||||
return self.cgRoot.define()
|
return self.cgRoot.define()
|
||||||
|
|
||||||
|
@ -6799,7 +6804,7 @@ class GlobalGenRoots():
|
||||||
globals_ = CGWrapper(CGIndenter(global_flags), pre="bitflags! {\n", post="\n}")
|
globals_ = CGWrapper(CGIndenter(global_flags), pre="bitflags! {\n", post="\n}")
|
||||||
|
|
||||||
pairs = []
|
pairs = []
|
||||||
for d in config.getDescriptors(hasInterfaceObject=True):
|
for d in config.getDescriptors(hasInterfaceObject=True, isInline=False):
|
||||||
binding = toBindingNamespace(d.name)
|
binding = toBindingNamespace(d.name)
|
||||||
pairs.append((d.name, binding, binding))
|
pairs.append((d.name, binding, binding))
|
||||||
for ctor in d.interface.namedConstructors:
|
for ctor in d.interface.namedConstructors:
|
||||||
|
@ -6927,7 +6932,7 @@ class GlobalGenRoots():
|
||||||
allprotos.append(CGGeneric("\n"))
|
allprotos.append(CGGeneric("\n"))
|
||||||
|
|
||||||
if downcast:
|
if downcast:
|
||||||
hierarchy[descriptor.getParentName()].append(name)
|
hierarchy[descriptor.interface.parent.identifier.name].append(name)
|
||||||
|
|
||||||
typeIdCode = []
|
typeIdCode = []
|
||||||
topTypeVariants = [
|
topTypeVariants = [
|
||||||
|
@ -6959,7 +6964,7 @@ impl Clone for TopTypeId {
|
||||||
|
|
||||||
for base, derived in hierarchy.iteritems():
|
for base, derived in hierarchy.iteritems():
|
||||||
variants = []
|
variants = []
|
||||||
if not config.getInterface(base).getExtendedAttribute("Abstract"):
|
if config.getDescriptor(base).concrete:
|
||||||
variants.append(CGGeneric(base))
|
variants.append(CGGeneric(base))
|
||||||
variants += [CGGeneric(type_id_variant(derivedName)) for derivedName in derived]
|
variants += [CGGeneric(type_id_variant(derivedName)) for derivedName in derived]
|
||||||
derives = "Clone, Copy, Debug, PartialEq"
|
derives = "Clone, Copy, Debug, PartialEq"
|
||||||
|
|
|
@ -88,6 +88,8 @@ class Configuration:
|
||||||
getter = lambda x: x.interface.isJSImplemented()
|
getter = lambda x: x.interface.isJSImplemented()
|
||||||
elif key == 'isGlobal':
|
elif key == 'isGlobal':
|
||||||
getter = lambda x: x.isGlobal()
|
getter = lambda x: x.isGlobal()
|
||||||
|
elif key == 'isInline':
|
||||||
|
getter = lambda x: x.interface.getExtendedAttribute('Inline') is not None
|
||||||
elif key == 'isExposedConditionally':
|
elif key == 'isExposedConditionally':
|
||||||
getter = lambda x: x.interface.isExposedConditionally()
|
getter = lambda x: x.interface.isExposedConditionally()
|
||||||
elif key == 'isIteratorInterface':
|
elif key == 'isIteratorInterface':
|
||||||
|
@ -234,6 +236,7 @@ class Descriptor(DescriptorProvider):
|
||||||
self.concrete = (not self.interface.isCallback() and
|
self.concrete = (not self.interface.isCallback() and
|
||||||
not self.interface.isNamespace() and
|
not self.interface.isNamespace() and
|
||||||
not self.interface.getExtendedAttribute("Abstract") and
|
not self.interface.getExtendedAttribute("Abstract") and
|
||||||
|
not self.interface.getExtendedAttribute("Inline") and
|
||||||
not spiderMonkeyInterface)
|
not spiderMonkeyInterface)
|
||||||
self.hasUnforgeableMembers = (self.concrete and
|
self.hasUnforgeableMembers = (self.concrete and
|
||||||
any(MemberIsUnforgeable(m, self) for m in
|
any(MemberIsUnforgeable(m, self) for m in
|
||||||
|
@ -383,8 +386,12 @@ class Descriptor(DescriptorProvider):
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
def getParentName(self):
|
def getParentName(self):
|
||||||
assert self.interface.parent is not None
|
parent = self.interface.parent
|
||||||
return self.interface.parent.identifier.name
|
while parent:
|
||||||
|
if not parent.getExtendedAttribute("Inline"):
|
||||||
|
return parent.identifier.name
|
||||||
|
parent = parent.parent
|
||||||
|
return None
|
||||||
|
|
||||||
def hasDescendants(self):
|
def hasDescendants(self):
|
||||||
return (self.interface.getUserData("hasConcreteDescendant", False) or
|
return (self.interface.getUserData("hasConcreteDescendant", False) or
|
||||||
|
|
|
@ -1695,7 +1695,8 @@ class IDLInterface(IDLInterfaceOrNamespace):
|
||||||
identifier == "ProbablyShortLivingObject" or
|
identifier == "ProbablyShortLivingObject" or
|
||||||
identifier == "LegacyUnenumerableNamedProperties" or
|
identifier == "LegacyUnenumerableNamedProperties" or
|
||||||
identifier == "NonOrdinaryGetPrototypeOf" or
|
identifier == "NonOrdinaryGetPrototypeOf" or
|
||||||
identifier == "Abstract"):
|
identifier == "Abstract" or
|
||||||
|
identifier == "Inline"):
|
||||||
# Known extended attributes that do not take values
|
# Known extended attributes that do not take values
|
||||||
if not attr.noArguments():
|
if not attr.noArguments():
|
||||||
raise WebIDLError("[%s] must take no arguments" % identifier,
|
raise WebIDLError("[%s] must take no arguments" % identifier,
|
||||||
|
|
12
components/script/dom/bindings/codegen/parser/inline.patch
Normal file
12
components/script/dom/bindings/codegen/parser/inline.patch
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
--- WebIDL.py
|
||||||
|
+++ WebIDL.py
|
||||||
|
@@ -1695,7 +1695,8 @@ class IDLInterface(IDLInterfaceOrNamespace):
|
||||||
|
identifier == "ProbablyShortLivingObject" or
|
||||||
|
identifier == "LegacyUnenumerableNamedProperties" or
|
||||||
|
identifier == "NonOrdinaryGetPrototypeOf" or
|
||||||
|
- identifier == "Abstract"):
|
||||||
|
+ identifier == "Abstract" or
|
||||||
|
+ identifier == "Inline"):
|
||||||
|
# Known extended attributes that do not take values
|
||||||
|
if not attr.noArguments():
|
||||||
|
raise WebIDLError("[%s] must take no arguments" % identifier,
|
|
@ -4,6 +4,7 @@ patch < debug.patch
|
||||||
patch < pref-main-thread.patch
|
patch < pref-main-thread.patch
|
||||||
patch < callback-location.patch
|
patch < callback-location.patch
|
||||||
patch < union-typedef.patch
|
patch < union-typedef.patch
|
||||||
|
patch < inline.patch
|
||||||
|
|
||||||
wget https://hg.mozilla.org/mozilla-central/archive/tip.tar.gz/dom/bindings/parser/tests/ -O tests.tar.gz
|
wget https://hg.mozilla.org/mozilla-central/archive/tip.tar.gz/dom/bindings/parser/tests/ -O tests.tar.gz
|
||||||
rm -r tests
|
rm -r tests
|
||||||
|
|
|
@ -8,9 +8,9 @@ use dom::bindings::codegen::Bindings::DOMExceptionBinding::DOMExceptionMethods;
|
||||||
use dom::bindings::codegen::PrototypeList::proto_id_to_name;
|
use dom::bindings::codegen::PrototypeList::proto_id_to_name;
|
||||||
use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, ToJSValConvertible};
|
use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, ToJSValConvertible};
|
||||||
use dom::bindings::conversions::root_from_object;
|
use dom::bindings::conversions::root_from_object;
|
||||||
use dom::bindings::global::{GlobalRef, global_root_from_context};
|
|
||||||
use dom::bindings::str::USVString;
|
use dom::bindings::str::USVString;
|
||||||
use dom::domexception::{DOMErrorName, DOMException};
|
use dom::domexception::{DOMErrorName, DOMException};
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use js::error::{throw_range_error, throw_type_error};
|
use js::error::{throw_range_error, throw_type_error};
|
||||||
use js::jsapi::HandleObject;
|
use js::jsapi::HandleObject;
|
||||||
use js::jsapi::JSContext;
|
use js::jsapi::JSContext;
|
||||||
|
@ -87,7 +87,7 @@ pub type Fallible<T> = Result<T, Error>;
|
||||||
pub type ErrorResult = Fallible<()>;
|
pub type ErrorResult = Fallible<()>;
|
||||||
|
|
||||||
/// Set a pending exception for the given `result` on `cx`.
|
/// Set a pending exception for the given `result` on `cx`.
|
||||||
pub unsafe fn throw_dom_exception(cx: *mut JSContext, global: GlobalRef, result: Error) {
|
pub unsafe fn throw_dom_exception(cx: *mut JSContext, global: &GlobalScope, result: Error) {
|
||||||
let code = match result {
|
let code = match result {
|
||||||
Error::IndexSize => DOMErrorName::IndexSizeError,
|
Error::IndexSize => DOMErrorName::IndexSizeError,
|
||||||
Error::NotFound => DOMErrorName::NotFoundError,
|
Error::NotFound => DOMErrorName::NotFoundError,
|
||||||
|
@ -245,8 +245,8 @@ pub unsafe fn report_pending_exception(cx: *mut JSContext, dispatch_event: bool)
|
||||||
error_info.message);
|
error_info.message);
|
||||||
|
|
||||||
if dispatch_event {
|
if dispatch_event {
|
||||||
let global = global_root_from_context(cx);
|
GlobalScope::from_context(cx)
|
||||||
global.r().report_an_error(error_info, value.handle());
|
.report_an_error(error_info, value.handle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ pub unsafe fn throw_invalid_this(cx: *mut JSContext, proto_id: u16) {
|
||||||
|
|
||||||
impl Error {
|
impl Error {
|
||||||
/// Convert this error value to a JS value, consuming it in the process.
|
/// Convert this error value to a JS value, consuming it in the process.
|
||||||
pub unsafe fn to_jsval(self, cx: *mut JSContext, global: GlobalRef, rval: MutableHandleValue) {
|
pub unsafe fn to_jsval(self, cx: *mut JSContext, global: &GlobalScope, rval: MutableHandleValue) {
|
||||||
assert!(!JS_IsExceptionPending(cx));
|
assert!(!JS_IsExceptionPending(cx));
|
||||||
throw_dom_exception(cx, global, self);
|
throw_dom_exception(cx, global, self);
|
||||||
assert!(JS_IsExceptionPending(cx));
|
assert!(JS_IsExceptionPending(cx));
|
||||||
|
|
|
@ -1,398 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* 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/. */
|
|
||||||
|
|
||||||
//! Abstractions for global scopes.
|
|
||||||
//!
|
|
||||||
//! This module contains smart pointers to global scopes, to simplify writing
|
|
||||||
//! code that works in workers as well as window scopes.
|
|
||||||
|
|
||||||
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::js::Root;
|
|
||||||
use dom::bindings::reflector::{Reflectable, Reflector};
|
|
||||||
use dom::console::TimerSet;
|
|
||||||
use dom::window;
|
|
||||||
use dom::workerglobalscope::WorkerGlobalScope;
|
|
||||||
use ipc_channel::ipc::IpcSender;
|
|
||||||
use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL};
|
|
||||||
use js::glue::{IsWrapper, UnwrapObject};
|
|
||||||
use js::jsapi::{CurrentGlobalOrNull, Evaluate2, GetGlobalForObjectCrossCompartment};
|
|
||||||
use js::jsapi::{HandleValue, JS_GetClass, JSAutoCompartment, JSContext};
|
|
||||||
use js::jsapi::{JSObject, MutableHandleValue};
|
|
||||||
use js::rust::CompileOptionsWrapper;
|
|
||||||
use libc;
|
|
||||||
use msg::constellation_msg::PipelineId;
|
|
||||||
use net_traits::{CoreResourceThread, IpcSend, ResourceThreads};
|
|
||||||
use profile_traits::{mem, time};
|
|
||||||
use script_runtime::{CommonScriptMsg, EnqueuedPromiseCallback, ScriptChan};
|
|
||||||
use script_runtime::{ScriptPort, maybe_take_panic_result};
|
|
||||||
use script_thread::{MainThreadScriptChan, RunnableWrapper, ScriptThread};
|
|
||||||
use script_traits::{MsDuration, ScriptMsg as ConstellationMsg, TimerEventRequest};
|
|
||||||
use std::ffi::CString;
|
|
||||||
use std::panic;
|
|
||||||
use task_source::file_reading::FileReadingTaskSource;
|
|
||||||
use timers::{OneshotTimerCallback, OneshotTimerHandle};
|
|
||||||
use url::Url;
|
|
||||||
|
|
||||||
/// A freely-copyable reference to a rooted global object.
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
pub enum GlobalRef<'a> {
|
|
||||||
/// A reference to a `Window` object.
|
|
||||||
Window(&'a window::Window),
|
|
||||||
/// A reference to a `WorkerGlobalScope` object.
|
|
||||||
Worker(&'a WorkerGlobalScope),
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A stack-based rooted reference to a global object.
|
|
||||||
pub enum GlobalRoot {
|
|
||||||
/// A root for a `Window` object.
|
|
||||||
Window(Root<window::Window>),
|
|
||||||
/// A root for a `WorkerGlobalScope` object.
|
|
||||||
Worker(Root<WorkerGlobalScope>),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> GlobalRef<'a> {
|
|
||||||
/// Get the `JSContext` for the `JSRuntime` associated with the thread
|
|
||||||
/// this global object is on.
|
|
||||||
pub fn get_cx(&self) -> *mut JSContext {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(ref window) => window.get_cx(),
|
|
||||||
GlobalRef::Worker(ref worker) => worker.get_cx(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extract a `Window`, causing thread failure if the global object is not
|
|
||||||
/// a `Window`.
|
|
||||||
pub fn as_window(&self) -> &window::Window {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(window) => window,
|
|
||||||
GlobalRef::Worker(_) => panic!("expected a Window scope"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the `PipelineId` for this global scope.
|
|
||||||
pub fn pipeline_id(&self) -> PipelineId {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(window) => window.pipeline_id(),
|
|
||||||
GlobalRef::Worker(worker) => worker.pipeline_id(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get a `mem::ProfilerChan` to send messages to the memory profiler thread.
|
|
||||||
pub fn mem_profiler_chan(&self) -> &mem::ProfilerChan {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(window) => window.mem_profiler_chan(),
|
|
||||||
GlobalRef::Worker(worker) => worker.mem_profiler_chan(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get a `time::ProfilerChan` to send messages to the time profiler thread.
|
|
||||||
pub fn time_profiler_chan(&self) -> &time::ProfilerChan {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(window) => window.time_profiler_chan(),
|
|
||||||
GlobalRef::Worker(worker) => worker.time_profiler_chan(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get a `IpcSender` to send messages to the constellation when available.
|
|
||||||
pub fn constellation_chan(&self) -> &IpcSender<ConstellationMsg> {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(window) => window.constellation_chan(),
|
|
||||||
GlobalRef::Worker(worker) => worker.constellation_chan(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the scheduler channel to request timer events.
|
|
||||||
pub fn scheduler_chan(&self) -> &IpcSender<TimerEventRequest> {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(window) => window.scheduler_chan(),
|
|
||||||
GlobalRef::Worker(worker) => worker.scheduler_chan(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get an `IpcSender<ScriptToDevtoolsControlMsg>` to send messages to Devtools
|
|
||||||
/// thread when available.
|
|
||||||
pub fn devtools_chan(&self) -> Option<IpcSender<ScriptToDevtoolsControlMsg>> {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(window) => window.devtools_chan(),
|
|
||||||
GlobalRef::Worker(worker) => worker.devtools_chan(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the `ResourceThreads` for this global scope.
|
|
||||||
pub fn resource_threads(&self) -> ResourceThreads {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(ref window) => window.resource_threads().clone(),
|
|
||||||
GlobalRef::Worker(ref worker) => worker.resource_threads().clone(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the `CoreResourceThread` for this global scope
|
|
||||||
pub fn core_resource_thread(&self) -> CoreResourceThread {
|
|
||||||
self.resource_threads().sender()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get next worker id.
|
|
||||||
pub fn get_next_worker_id(&self) -> WorkerId {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(ref window) => window.get_next_worker_id(),
|
|
||||||
GlobalRef::Worker(ref worker) => worker.get_next_worker_id(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the URL for this global scope.
|
|
||||||
pub fn get_url(&self) -> Url {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(ref window) => window.get_url(),
|
|
||||||
GlobalRef::Worker(ref worker) => worker.get_url().clone(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the [base url](https://html.spec.whatwg.org/multipage/#api-base-url)
|
|
||||||
/// for this global scope.
|
|
||||||
pub fn api_base_url(&self) -> Url {
|
|
||||||
match *self {
|
|
||||||
// https://html.spec.whatwg.org/multipage/#script-settings-for-browsing-contexts:api-base-url
|
|
||||||
GlobalRef::Window(ref window) => window.Document().base_url(),
|
|
||||||
// https://html.spec.whatwg.org/multipage/#script-settings-for-workers:api-base-url
|
|
||||||
GlobalRef::Worker(ref worker) => worker.get_url().clone(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `ScriptChan` used to send messages to the event loop of this global's
|
|
||||||
/// thread.
|
|
||||||
pub fn script_chan(&self) -> Box<ScriptChan + Send> {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(ref window) =>
|
|
||||||
MainThreadScriptChan(window.main_thread_script_chan().clone()).clone(),
|
|
||||||
GlobalRef::Worker(ref worker) => worker.script_chan(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `ScriptChan` used to send messages to the event loop of this global's
|
|
||||||
/// thread.
|
|
||||||
pub fn networking_task_source(&self) -> Box<ScriptChan + Send> {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(ref window) => window.networking_task_source(),
|
|
||||||
GlobalRef::Worker(ref worker) => worker.script_chan(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `ScriptChan` used to send messages to the event loop of this global's
|
|
||||||
/// thread.
|
|
||||||
pub fn file_reading_task_source(&self) -> FileReadingTaskSource {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(ref window) => window.file_reading_task_source(),
|
|
||||||
GlobalRef::Worker(ref worker) => worker.file_reading_task_source(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a new sender/receiver pair that can be used to implement an on-demand
|
|
||||||
/// event loop. Used for implementing web APIs that require blocking semantics
|
|
||||||
/// without resorting to nested event loops.
|
|
||||||
pub fn new_script_pair(&self) -> (Box<ScriptChan + Send>, Box<ScriptPort + Send>) {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(ref window) => window.new_script_pair(),
|
|
||||||
GlobalRef::Worker(ref worker) => worker.new_script_pair(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Process a single event as if it were the next event in the thread queue for
|
|
||||||
/// this global.
|
|
||||||
pub fn process_event(&self, msg: CommonScriptMsg) {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(_) => ScriptThread::process_event(msg),
|
|
||||||
GlobalRef::Worker(ref worker) => worker.process_event(msg),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Evaluate JS code on this global.
|
|
||||||
pub fn evaluate_js_on_global_with_result(
|
|
||||||
&self, code: &str, rval: MutableHandleValue) {
|
|
||||||
self.evaluate_script_on_global_with_result(code, "", rval)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Evaluate a JS script on this global.
|
|
||||||
#[allow(unsafe_code)]
|
|
||||||
pub fn evaluate_script_on_global_with_result(
|
|
||||||
&self, code: &str, filename: &str, rval: MutableHandleValue) {
|
|
||||||
let metadata = time::TimerMetadata {
|
|
||||||
url: if filename.is_empty() {
|
|
||||||
self.get_url().as_str().into()
|
|
||||||
} else {
|
|
||||||
filename.into()
|
|
||||||
},
|
|
||||||
iframe: time::TimerMetadataFrameType::RootWindow,
|
|
||||||
incremental: time::TimerMetadataReflowType::FirstReflow,
|
|
||||||
};
|
|
||||||
time::profile(
|
|
||||||
time::ProfilerCategory::ScriptEvaluate,
|
|
||||||
Some(metadata),
|
|
||||||
self.time_profiler_chan().clone(),
|
|
||||||
|| {
|
|
||||||
let cx = self.get_cx();
|
|
||||||
let globalhandle = self.reflector().get_jsobject();
|
|
||||||
let code: Vec<u16> = code.encode_utf16().collect();
|
|
||||||
let filename = CString::new(filename).unwrap();
|
|
||||||
|
|
||||||
let _ac = JSAutoCompartment::new(cx, globalhandle.get());
|
|
||||||
let options = CompileOptionsWrapper::new(cx, filename.as_ptr(), 1);
|
|
||||||
unsafe {
|
|
||||||
if !Evaluate2(cx, options.ptr, code.as_ptr(),
|
|
||||||
code.len() as libc::size_t,
|
|
||||||
rval) {
|
|
||||||
debug!("error evaluating JS string");
|
|
||||||
report_pending_exception(cx, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(error) = maybe_take_panic_result() {
|
|
||||||
panic::resume_unwind(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Set the `bool` value to indicate whether developer tools has requested
|
|
||||||
/// updates from the global
|
|
||||||
pub fn set_devtools_wants_updates(&self, send_updates: bool) {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(window) => window.set_devtools_wants_updates(send_updates),
|
|
||||||
GlobalRef::Worker(worker) => worker.set_devtools_wants_updates(send_updates),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Schedule the given `callback` to be invoked after at least `duration` milliseconds have
|
|
||||||
/// passed.
|
|
||||||
pub fn schedule_callback(&self,
|
|
||||||
callback: OneshotTimerCallback,
|
|
||||||
duration: MsDuration)
|
|
||||||
-> OneshotTimerHandle {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(window) => window.schedule_callback(callback, duration),
|
|
||||||
GlobalRef::Worker(worker) => worker.schedule_callback(callback, duration),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Unschedule a previously-scheduled callback.
|
|
||||||
pub fn unschedule_callback(&self, handle: OneshotTimerHandle) {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(window) => window.unschedule_callback(handle),
|
|
||||||
GlobalRef::Worker(worker) => worker.unschedule_callback(handle),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the global's timers for the Console API.
|
|
||||||
pub fn console_timers(&self) -> &TimerSet {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(ref window) => window.console_timers(),
|
|
||||||
GlobalRef::Worker(ref worker) => worker.console_timers(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns a wrapper for runnables to ensure they are cancelled if the global
|
|
||||||
/// is being destroyed.
|
|
||||||
pub fn get_runnable_wrapper(&self) -> RunnableWrapper {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(ref window) => window.get_runnable_wrapper(),
|
|
||||||
GlobalRef::Worker(ref worker) => worker.get_runnable_wrapper(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Enqueue a promise callback for subsequent execution.
|
|
||||||
pub fn enqueue_promise_job(&self, job: EnqueuedPromiseCallback) {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(_) => ScriptThread::enqueue_promise_job(job, *self),
|
|
||||||
GlobalRef::Worker(ref worker) => worker.enqueue_promise_job(job),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Start the process of executing the pending promise callbacks. They will be invoked
|
|
||||||
/// in FIFO order, synchronously, at some point in the future.
|
|
||||||
pub fn flush_promise_jobs(&self) {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(_) => ScriptThread::flush_promise_jobs(*self),
|
|
||||||
GlobalRef::Worker(ref worker) => worker.flush_promise_jobs(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// https://html.spec.whatwg.org/multipage/#report-the-error
|
|
||||||
pub fn report_an_error(&self, error_info: ErrorInfo, value: HandleValue) {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(ref window) => window.report_an_error(error_info, value),
|
|
||||||
GlobalRef::Worker(ref worker) => worker.report_an_error(error_info, value),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> Reflectable for GlobalRef<'a> {
|
|
||||||
fn reflector(&self) -> &Reflector {
|
|
||||||
match *self {
|
|
||||||
GlobalRef::Window(ref window) => window.reflector(),
|
|
||||||
GlobalRef::Worker(ref worker) => worker.reflector(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl GlobalRoot {
|
|
||||||
/// Obtain a safe reference to the global object that cannot outlive the
|
|
||||||
/// lifetime of this root.
|
|
||||||
pub fn r(&self) -> GlobalRef {
|
|
||||||
match *self {
|
|
||||||
GlobalRoot::Window(ref window) => GlobalRef::Window(window.r()),
|
|
||||||
GlobalRoot::Worker(ref worker) => GlobalRef::Worker(worker.r()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the global object of the realm that the given DOM object's reflector was created in.
|
|
||||||
pub fn global_root_from_reflector<T: Reflectable>(reflector: &T) -> GlobalRoot {
|
|
||||||
unsafe { global_root_from_object(*reflector.reflector().get_jsobject()) }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the Rust global object from a JS global object.
|
|
||||||
#[allow(unrooted_must_root)]
|
|
||||||
unsafe fn global_root_from_global(global: *mut JSObject) -> GlobalRoot {
|
|
||||||
assert!(!global.is_null());
|
|
||||||
let clasp = JS_GetClass(global);
|
|
||||||
assert!(((*clasp).flags & (JSCLASS_IS_DOMJSCLASS | JSCLASS_IS_GLOBAL)) != 0);
|
|
||||||
match root_from_object(global) {
|
|
||||||
Ok(window) => return GlobalRoot::Window(window),
|
|
||||||
Err(_) => (),
|
|
||||||
}
|
|
||||||
|
|
||||||
match root_from_object(global) {
|
|
||||||
Ok(worker) => return GlobalRoot::Worker(worker),
|
|
||||||
Err(_) => (),
|
|
||||||
}
|
|
||||||
|
|
||||||
panic!("found DOM global that doesn't unwrap to Window or WorkerGlobalScope")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the global object of the realm that the given JS object was created in.
|
|
||||||
#[allow(unrooted_must_root)]
|
|
||||||
pub unsafe fn global_root_from_object(obj: *mut JSObject) -> GlobalRoot {
|
|
||||||
assert!(!obj.is_null());
|
|
||||||
let global = GetGlobalForObjectCrossCompartment(obj);
|
|
||||||
global_root_from_global(global)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the global object for the given JSContext
|
|
||||||
#[allow(unrooted_must_root)]
|
|
||||||
pub unsafe fn global_root_from_context(cx: *mut JSContext) -> GlobalRoot {
|
|
||||||
let global = CurrentGlobalOrNull(cx);
|
|
||||||
global_root_from_global(global)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the global object of the realm that the given JS object was created in,
|
|
||||||
/// after unwrapping any wrappers.
|
|
||||||
pub unsafe fn global_root_from_object_maybe_wrapped(mut obj: *mut JSObject) -> GlobalRoot {
|
|
||||||
if IsWrapper(obj) {
|
|
||||||
obj = UnwrapObject(obj, /* stopAtWindowProxy = */ 0);
|
|
||||||
assert!(!obj.is_null());
|
|
||||||
}
|
|
||||||
global_root_from_object(obj)
|
|
||||||
}
|
|
|
@ -10,10 +10,10 @@ use core::nonzero::NonZero;
|
||||||
use dom::bindings::codegen::Bindings::IterableIteratorBinding::IterableKeyAndValueResult;
|
use dom::bindings::codegen::Bindings::IterableIteratorBinding::IterableKeyAndValueResult;
|
||||||
use dom::bindings::codegen::Bindings::IterableIteratorBinding::IterableKeyOrValueResult;
|
use dom::bindings::codegen::Bindings::IterableIteratorBinding::IterableKeyOrValueResult;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::{JS, Root};
|
use dom::bindings::js::{JS, Root};
|
||||||
use dom::bindings::reflector::{Reflector, Reflectable, MutReflectable, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, Reflectable, MutReflectable, reflect_dom_object};
|
||||||
use dom::bindings::trace::JSTraceable;
|
use dom::bindings::trace::JSTraceable;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use js::conversions::ToJSValConvertible;
|
use js::conversions::ToJSValConvertible;
|
||||||
use js::jsapi::{JSContext, JSObject, MutableHandleValue, MutableHandleObject, HandleValue};
|
use js::jsapi::{JSContext, JSObject, MutableHandleValue, MutableHandleObject, HandleValue};
|
||||||
use js::jsval::UndefinedValue;
|
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.
|
/// Create a new iterator instance for the provided iterable DOM interface.
|
||||||
pub fn new(iterable: &T,
|
pub fn new(iterable: &T,
|
||||||
type_: IteratorType,
|
type_: IteratorType,
|
||||||
wrap: fn(*mut JSContext, GlobalRef, Box<IterableIterator<T>>)
|
wrap: fn(*mut JSContext, &GlobalScope, Box<IterableIterator<T>>)
|
||||||
-> Root<Self>) -> Root<Self> {
|
-> Root<Self>) -> Root<Self> {
|
||||||
let iterator = box IterableIterator {
|
let iterator = box IterableIterator {
|
||||||
reflector: Reflector::new(),
|
reflector: Reflector::new(),
|
||||||
|
@ -93,8 +93,7 @@ impl<T: Reflectable + JSTraceable + Iterable> IterableIterator<T> {
|
||||||
iterable: JS::from_ref(iterable),
|
iterable: JS::from_ref(iterable),
|
||||||
index: Cell::new(0),
|
index: Cell::new(0),
|
||||||
};
|
};
|
||||||
let global = iterable.global();
|
reflect_dom_object(iterator, &*iterable.global(), wrap)
|
||||||
reflect_dom_object(iterator, global.r(), wrap)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the next value from the iterable object.
|
/// Return the next value from the iterable object.
|
||||||
|
|
|
@ -43,8 +43,9 @@
|
||||||
//! [`Fallible<T>`](error/type.Fallible.html).
|
//! [`Fallible<T>`](error/type.Fallible.html).
|
||||||
//! Methods that use certain WebIDL types like `any` or `object` will get a
|
//! Methods that use certain WebIDL types like `any` or `object` will get a
|
||||||
//! `*mut JSContext` argument prepended to the argument list. Static methods
|
//! `*mut JSContext` argument prepended to the argument list. Static methods
|
||||||
//! will be passed a [`GlobalRef`](global/enum.GlobalRef.html) for the relevant
|
//! will be passed a [`&GlobalScope`](../globalscope/struct.GlobalScope.html)
|
||||||
//! global. This argument comes before the `*mut JSContext` argument, if any.
|
//! for the relevant global. This argument comes before the `*mut JSContext`
|
||||||
|
//! argument, if any.
|
||||||
//!
|
//!
|
||||||
//! Rust reflections of WebIDL operations (methods)
|
//! Rust reflections of WebIDL operations (methods)
|
||||||
//! -----------------------------------------------
|
//! -----------------------------------------------
|
||||||
|
@ -79,7 +80,7 @@
|
||||||
//!
|
//!
|
||||||
//! A WebIDL constructor is turned into a static class method named
|
//! A WebIDL constructor is turned into a static class method named
|
||||||
//! `Constructor`. The arguments of this method will be the arguments of the
|
//! `Constructor`. The arguments of this method will be the arguments of the
|
||||||
//! WebIDL constructor, with a `GlobalRef` for the relevant global prepended.
|
//! WebIDL constructor, with a `&GlobalScope` for the relevant global prepended.
|
||||||
//! The return value of the constructor for MyInterface is exactly the same as
|
//! The return value of the constructor for MyInterface is exactly the same as
|
||||||
//! that of a method returning an instance of MyInterface. Constructors are
|
//! that of a method returning an instance of MyInterface. Constructors are
|
||||||
//! always [allowed to throw](#throwing-exceptions).
|
//! always [allowed to throw](#throwing-exceptions).
|
||||||
|
@ -133,7 +134,6 @@ pub mod cell;
|
||||||
pub mod constant;
|
pub mod constant;
|
||||||
pub mod conversions;
|
pub mod conversions;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod global;
|
|
||||||
pub mod guard;
|
pub mod guard;
|
||||||
pub mod inheritance;
|
pub mod inheritance;
|
||||||
pub mod interface;
|
pub mod interface;
|
||||||
|
|
|
@ -4,19 +4,24 @@
|
||||||
|
|
||||||
//! The `Reflector` struct.
|
//! The `Reflector` struct.
|
||||||
|
|
||||||
use dom::bindings::global::{GlobalRef, GlobalRoot, global_root_from_reflector};
|
use dom::bindings::conversions::DerivedFrom;
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use js::jsapi::{HandleObject, JSContext, JSObject};
|
use js::jsapi::{HandleObject, JSContext, JSObject};
|
||||||
use std::cell::UnsafeCell;
|
use std::cell::UnsafeCell;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
/// Create the reflector for a new DOM object and yield ownership to the
|
/// Create the reflector for a new DOM object and yield ownership to the
|
||||||
/// reflector.
|
/// reflector.
|
||||||
pub fn reflect_dom_object<T: Reflectable>(obj: Box<T>,
|
pub fn reflect_dom_object<T, U>(
|
||||||
global: GlobalRef,
|
obj: Box<T>,
|
||||||
wrap_fn: fn(*mut JSContext, GlobalRef, Box<T>) -> Root<T>)
|
global: &U,
|
||||||
-> Root<T> {
|
wrap_fn: fn(*mut JSContext, &GlobalScope, Box<T>) -> Root<T>)
|
||||||
wrap_fn(global.get_cx(), global, obj)
|
-> 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.
|
/// A struct to store a reference to the reflector of a DOM object.
|
||||||
|
@ -74,9 +79,9 @@ pub trait Reflectable {
|
||||||
/// Returns the receiver's reflector.
|
/// Returns the receiver's reflector.
|
||||||
fn reflector(&self) -> &Reflector;
|
fn reflector(&self) -> &Reflector;
|
||||||
|
|
||||||
/// Returns the global object of the realm that the Reflectable was created in.
|
/// Returns the global scope of the realm that the Reflectable was created in.
|
||||||
fn global(&self) -> GlobalRoot where Self: Sized {
|
fn global(&self) -> Root<GlobalScope> where Self: Sized {
|
||||||
global_root_from_reflector(self)
|
GlobalScope::from_reflector(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
//! (https://html.spec.whatwg.org/multipage/#safe-passing-of-structured-data).
|
//! (https://html.spec.whatwg.org/multipage/#safe-passing-of-structured-data).
|
||||||
|
|
||||||
use dom::bindings::error::{Error, Fallible};
|
use dom::bindings::error::{Error, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
use dom::globalscope::GlobalScope;
|
||||||
use js::jsapi::{HandleValue, MutableHandleValue};
|
use js::jsapi::{HandleValue, MutableHandleValue};
|
||||||
use js::jsapi::{JSContext, JS_ReadStructuredClone, JS_STRUCTURED_CLONE_VERSION};
|
use js::jsapi::{JSContext, JS_ReadStructuredClone, JS_STRUCTURED_CLONE_VERSION};
|
||||||
use js::jsapi::{JS_ClearPendingException, JS_WriteStructuredClone};
|
use js::jsapi::{JS_ClearPendingException, JS_WriteStructuredClone};
|
||||||
|
@ -60,7 +60,7 @@ impl StructuredCloneData {
|
||||||
/// Reads a structured clone.
|
/// Reads a structured clone.
|
||||||
///
|
///
|
||||||
/// Panics if `JS_ReadStructuredClone` fails.
|
/// Panics if `JS_ReadStructuredClone` fails.
|
||||||
fn read_clone(global: GlobalRef, data: *mut u64, nbytes: size_t, rval: MutableHandleValue) {
|
fn read_clone(global: &GlobalScope, data: *mut u64, nbytes: size_t, rval: MutableHandleValue) {
|
||||||
unsafe {
|
unsafe {
|
||||||
assert!(JS_ReadStructuredClone(global.get_cx(),
|
assert!(JS_ReadStructuredClone(global.get_cx(),
|
||||||
data,
|
data,
|
||||||
|
@ -73,7 +73,7 @@ impl StructuredCloneData {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Thunk for the actual `read_clone` method. Resolves proper variant for read_clone.
|
/// Thunk for the actual `read_clone` method. Resolves proper variant for read_clone.
|
||||||
pub fn read(self, global: GlobalRef, rval: MutableHandleValue) {
|
pub fn read(self, global: &GlobalScope, rval: MutableHandleValue) {
|
||||||
match self {
|
match self {
|
||||||
StructuredCloneData::Vector(mut vec_msg) => {
|
StructuredCloneData::Vector(mut vec_msg) => {
|
||||||
let nbytes = vec_msg.len();
|
let nbytes = vec_msg.len();
|
||||||
|
|
|
@ -7,10 +7,10 @@ use dom::bindings::codegen::Bindings::BlobBinding;
|
||||||
use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
|
use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
|
||||||
use dom::bindings::codegen::UnionTypes::BlobOrString;
|
use dom::bindings::codegen::UnionTypes::BlobOrString;
|
||||||
use dom::bindings::error::{Error, Fallible};
|
use dom::bindings::error::{Error, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::{JS, Root};
|
use dom::bindings::js::{JS, Root};
|
||||||
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use encoding::all::UTF_8;
|
use encoding::all::UTF_8;
|
||||||
use encoding::types::{EncoderTrap, Encoding};
|
use encoding::types::{EncoderTrap, Encoding};
|
||||||
use ipc_channel::ipc;
|
use ipc_channel::ipc;
|
||||||
|
@ -79,7 +79,9 @@ pub struct Blob {
|
||||||
|
|
||||||
impl Blob {
|
impl Blob {
|
||||||
#[allow(unrooted_must_root)]
|
#[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);
|
let boxed_blob = box Blob::new_inherited(blob_impl, typeString);
|
||||||
reflect_dom_object(boxed_blob, global, BlobBinding::Wrap)
|
reflect_dom_object(boxed_blob, global, BlobBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
@ -99,7 +101,6 @@ impl Blob {
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
fn new_sliced(parent: &Blob, rel_pos: RelativePos,
|
fn new_sliced(parent: &Blob, rel_pos: RelativePos,
|
||||||
relative_content_type: DOMString) -> Root<Blob> {
|
relative_content_type: DOMString) -> Root<Blob> {
|
||||||
let global = parent.global();
|
|
||||||
let blob_impl = match *parent.blob_impl.borrow() {
|
let blob_impl = match *parent.blob_impl.borrow() {
|
||||||
BlobImpl::File(_) => {
|
BlobImpl::File(_) => {
|
||||||
// Create new parent node
|
// Create new parent node
|
||||||
|
@ -115,11 +116,11 @@ impl Blob {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Blob::new(global.r(), blob_impl, relative_content_type.into())
|
Blob::new(&parent.global(), blob_impl, relative_content_type.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/FileAPI/#constructorBlob
|
// https://w3c.github.io/FileAPI/#constructorBlob
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
blobParts: Option<Vec<BlobOrString>>,
|
blobParts: Option<Vec<BlobOrString>>,
|
||||||
blobPropertyBag: &BlobBinding::BlobPropertyBag)
|
blobPropertyBag: &BlobBinding::BlobPropertyBag)
|
||||||
-> Fallible<Root<Blob>> {
|
-> Fallible<Root<Blob>> {
|
||||||
|
@ -142,8 +143,7 @@ impl Blob {
|
||||||
let (buffer, is_new_buffer) = match *f.cache.borrow() {
|
let (buffer, is_new_buffer) = match *f.cache.borrow() {
|
||||||
Some(ref bytes) => (bytes.clone(), false),
|
Some(ref bytes) => (bytes.clone(), false),
|
||||||
None => {
|
None => {
|
||||||
let global = self.global();
|
let bytes = read_file(&self.global(), f.id.clone())?;
|
||||||
let bytes = read_file(global.r(), f.id.clone())?;
|
|
||||||
(bytes, true)
|
(bytes, true)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -188,6 +188,7 @@ impl Blob {
|
||||||
/// valid or invalid Blob URL.
|
/// valid or invalid Blob URL.
|
||||||
fn promote(&self, set_valid: bool) -> Uuid {
|
fn promote(&self, set_valid: bool) -> Uuid {
|
||||||
let mut bytes = vec![];
|
let mut bytes = vec![];
|
||||||
|
let global_url = self.global().get_url();
|
||||||
|
|
||||||
match *self.blob_impl.borrow_mut() {
|
match *self.blob_impl.borrow_mut() {
|
||||||
BlobImpl::Sliced(_, _) => {
|
BlobImpl::Sliced(_, _) => {
|
||||||
|
@ -197,8 +198,7 @@ impl Blob {
|
||||||
}
|
}
|
||||||
BlobImpl::File(ref f) => {
|
BlobImpl::File(ref f) => {
|
||||||
if set_valid {
|
if set_valid {
|
||||||
let global = self.global();
|
let origin = get_blob_origin(&global_url);
|
||||||
let origin = get_blob_origin(&global.r().get_url());
|
|
||||||
let (tx, rx) = ipc::channel().unwrap();
|
let (tx, rx) = ipc::channel().unwrap();
|
||||||
|
|
||||||
let msg = FileManagerThreadMsg::ActivateBlobURL(f.id.clone(), tx, origin.clone());
|
let msg = FileManagerThreadMsg::ActivateBlobURL(f.id.clone(), tx, origin.clone());
|
||||||
|
@ -217,8 +217,7 @@ impl Blob {
|
||||||
BlobImpl::Memory(ref mut bytes_in) => mem::swap(bytes_in, &mut bytes),
|
BlobImpl::Memory(ref mut bytes_in) => mem::swap(bytes_in, &mut bytes),
|
||||||
};
|
};
|
||||||
|
|
||||||
let global = self.global();
|
let origin = get_blob_origin(&global_url);
|
||||||
let origin = get_blob_origin(&global.r().get_url());
|
|
||||||
|
|
||||||
let blob_buf = BlobBuf {
|
let blob_buf = BlobBuf {
|
||||||
filename: None,
|
filename: None,
|
||||||
|
@ -249,9 +248,7 @@ impl Blob {
|
||||||
/// Get a FileID representing sliced parent-blob content
|
/// Get a FileID representing sliced parent-blob content
|
||||||
fn create_sliced_url_id(&self, parent_id: &Uuid,
|
fn create_sliced_url_id(&self, parent_id: &Uuid,
|
||||||
rel_pos: &RelativePos, parent_len: u64) -> Uuid {
|
rel_pos: &RelativePos, parent_len: u64) -> Uuid {
|
||||||
let global = self.global();
|
let origin = get_blob_origin(&self.global().get_url());
|
||||||
|
|
||||||
let origin = get_blob_origin(&global.r().get_url());
|
|
||||||
|
|
||||||
let (tx, rx) = ipc::channel().unwrap();
|
let (tx, rx) = ipc::channel().unwrap();
|
||||||
let msg = FileManagerThreadMsg::AddSlicedURLEntry(parent_id.clone(),
|
let msg = FileManagerThreadMsg::AddSlicedURLEntry(parent_id.clone(),
|
||||||
|
@ -280,8 +277,7 @@ impl Blob {
|
||||||
/// Cleanups at the time of destruction/closing
|
/// Cleanups at the time of destruction/closing
|
||||||
fn clean_up_file_resource(&self) {
|
fn clean_up_file_resource(&self) {
|
||||||
if let BlobImpl::File(ref f) = *self.blob_impl.borrow() {
|
if let BlobImpl::File(ref f) = *self.blob_impl.borrow() {
|
||||||
let global = self.global();
|
let origin = get_blob_origin(&self.global().get_url());
|
||||||
let origin = get_blob_origin(&global.r().get_url());
|
|
||||||
|
|
||||||
let (tx, rx) = ipc::channel().unwrap();
|
let (tx, rx) = ipc::channel().unwrap();
|
||||||
|
|
||||||
|
@ -293,7 +289,7 @@ impl Blob {
|
||||||
|
|
||||||
fn send_to_file_manager(&self, msg: FileManagerThreadMsg) {
|
fn send_to_file_manager(&self, msg: FileManagerThreadMsg) {
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
let resource_threads = global.r().resource_threads();
|
let resource_threads = global.resource_threads();
|
||||||
let _ = resource_threads.send(CoreResourceMsg::ToFileManager(msg));
|
let _ = resource_threads.send(CoreResourceMsg::ToFileManager(msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -306,7 +302,7 @@ impl Drop for Blob {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_file(global: GlobalRef, id: Uuid) -> Result<Vec<u8>, ()> {
|
fn read_file(global: &GlobalScope, id: Uuid) -> Result<Vec<u8>, ()> {
|
||||||
let resource_threads = global.resource_threads();
|
let resource_threads = global.resource_threads();
|
||||||
let (chan, recv) = ipc::channel().map_err(|_|())?;
|
let (chan, recv) = ipc::channel().map_err(|_|())?;
|
||||||
let origin = get_blob_origin(&global.get_url());
|
let origin = get_blob_origin(&global.get_url());
|
||||||
|
|
|
@ -8,13 +8,13 @@ use dom::bindings::codegen::Bindings::BluetoothBinding::{self, BluetoothMethods,
|
||||||
use dom::bindings::codegen::Bindings::BluetoothBinding::RequestDeviceOptions;
|
use dom::bindings::codegen::Bindings::BluetoothBinding::RequestDeviceOptions;
|
||||||
use dom::bindings::error::Error::{self, Security, Type};
|
use dom::bindings::error::Error::{self, Security, Type};
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::bluetoothadvertisingdata::BluetoothAdvertisingData;
|
use dom::bluetoothadvertisingdata::BluetoothAdvertisingData;
|
||||||
use dom::bluetoothdevice::BluetoothDevice;
|
use dom::bluetoothdevice::BluetoothDevice;
|
||||||
use dom::bluetoothuuid::{BluetoothServiceUUID, BluetoothUUID};
|
use dom::bluetoothuuid::{BluetoothServiceUUID, BluetoothUUID};
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::promise::Promise;
|
use dom::promise::Promise;
|
||||||
use ipc_channel::ipc::{self, IpcSender};
|
use ipc_channel::ipc::{self, IpcSender};
|
||||||
use js::conversions::ToJSValConvertible;
|
use js::conversions::ToJSValConvertible;
|
||||||
|
@ -52,16 +52,14 @@ impl Bluetooth {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: GlobalRef) -> Root<Bluetooth> {
|
pub fn new(global: &GlobalScope) -> Root<Bluetooth> {
|
||||||
reflect_dom_object(box Bluetooth::new_inherited(),
|
reflect_dom_object(box Bluetooth::new_inherited(),
|
||||||
global,
|
global,
|
||||||
BluetoothBinding::Wrap)
|
BluetoothBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_bluetooth_thread(&self) -> IpcSender<BluetoothMethodMsg> {
|
fn get_bluetooth_thread(&self) -> IpcSender<BluetoothMethodMsg> {
|
||||||
let global_root = self.global();
|
self.global().as_window().bluetooth_thread()
|
||||||
let global_ref = global_root.r();
|
|
||||||
global_ref.as_window().bluetooth_thread()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn request_device(&self, option: &RequestDeviceOptions) -> Fallible<Root<BluetoothDevice>> {
|
fn request_device(&self, option: &RequestDeviceOptions) -> Fallible<Root<BluetoothDevice>> {
|
||||||
|
@ -105,11 +103,12 @@ impl Bluetooth {
|
||||||
// Step 12-13.
|
// Step 12-13.
|
||||||
match device {
|
match device {
|
||||||
Ok(device) => {
|
Ok(device) => {
|
||||||
let ad_data = BluetoothAdvertisingData::new(self.global().r(),
|
let global = self.global();
|
||||||
|
let ad_data = BluetoothAdvertisingData::new(&global,
|
||||||
device.appearance,
|
device.appearance,
|
||||||
device.tx_power,
|
device.tx_power,
|
||||||
device.rssi);
|
device.rssi);
|
||||||
Ok(BluetoothDevice::new(self.global().r(),
|
Ok(BluetoothDevice::new(&global,
|
||||||
DOMString::from(device.id),
|
DOMString::from(device.id),
|
||||||
device.name.map(DOMString::from),
|
device.name.map(DOMString::from),
|
||||||
&ad_data))
|
&ad_data))
|
||||||
|
@ -271,13 +270,13 @@ fn canonicalize_filter(filter: &BluetoothRequestDeviceFilter) -> Fallible<Blueto
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn result_to_promise<T: ToJSValConvertible>(global_ref: GlobalRef,
|
pub fn result_to_promise<T: ToJSValConvertible>(global: &GlobalScope,
|
||||||
bluetooth_result: Fallible<T>)
|
bluetooth_result: Fallible<T>)
|
||||||
-> Rc<Promise> {
|
-> Rc<Promise> {
|
||||||
let p = Promise::new(global_ref);
|
let p = Promise::new(global);
|
||||||
match bluetooth_result {
|
match bluetooth_result {
|
||||||
Ok(v) => p.resolve_native(p.global().r().get_cx(), &v),
|
Ok(v) => p.resolve_native(p.global().get_cx(), &v),
|
||||||
Err(e) => p.reject_error(p.global().r().get_cx(), e),
|
Err(e) => p.reject_error(p.global().get_cx(), e),
|
||||||
}
|
}
|
||||||
p
|
p
|
||||||
}
|
}
|
||||||
|
@ -298,6 +297,6 @@ impl BluetoothMethods for Bluetooth {
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice
|
||||||
fn RequestDevice(&self, option: &RequestDeviceOptions) -> Rc<Promise> {
|
fn RequestDevice(&self, option: &RequestDeviceOptions) -> Rc<Promise> {
|
||||||
result_to_promise(self.global().r(), self.request_device(option))
|
result_to_promise(&self.global(), self.request_device(option))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::BluetoothAdvertisingDataBinding;
|
use dom::bindings::codegen::Bindings::BluetoothAdvertisingDataBinding;
|
||||||
use dom::bindings::codegen::Bindings::BluetoothAdvertisingDataBinding::BluetoothAdvertisingDataMethods;
|
use dom::bindings::codegen::Bindings::BluetoothAdvertisingDataBinding::BluetoothAdvertisingDataMethods;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothadvertisingdata
|
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothadvertisingdata
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -30,7 +30,7 @@ impl BluetoothAdvertisingData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: GlobalRef,
|
pub fn new(global: &GlobalScope,
|
||||||
appearance: Option<u16>,
|
appearance: Option<u16>,
|
||||||
txPower: Option<i8>,
|
txPower: Option<i8>,
|
||||||
rssi: Option<i8>)
|
rssi: Option<i8>)
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
use dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding;
|
use dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding;
|
||||||
use dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding::
|
use dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding::
|
||||||
BluetoothCharacteristicPropertiesMethods;
|
BluetoothCharacteristicPropertiesMethods;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#characteristicproperties
|
// https://webbluetoothcg.github.io/web-bluetooth/#characteristicproperties
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -49,7 +49,7 @@ impl BluetoothCharacteristicProperties {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: GlobalRef,
|
pub fn new(global: &GlobalScope,
|
||||||
broadcast: bool,
|
broadcast: bool,
|
||||||
read: bool,
|
read: bool,
|
||||||
writeWithoutResponse: bool,
|
writeWithoutResponse: bool,
|
||||||
|
|
|
@ -4,12 +4,12 @@
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::BluetoothDeviceBinding;
|
use dom::bindings::codegen::Bindings::BluetoothDeviceBinding;
|
||||||
use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods;
|
use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::{JS, Root, MutHeap, MutNullableHeap};
|
use dom::bindings::js::{JS, Root, MutHeap, MutNullableHeap};
|
||||||
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::bluetoothadvertisingdata::BluetoothAdvertisingData;
|
use dom::bluetoothadvertisingdata::BluetoothAdvertisingData;
|
||||||
use dom::bluetoothremotegattserver::BluetoothRemoteGATTServer;
|
use dom::bluetoothremotegattserver::BluetoothRemoteGATTServer;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothdevice
|
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothdevice
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -35,7 +35,7 @@ impl BluetoothDevice {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: GlobalRef,
|
pub fn new(global: &GlobalScope,
|
||||||
id: DOMString,
|
id: DOMString,
|
||||||
name: Option<DOMString>,
|
name: Option<DOMString>,
|
||||||
adData: &BluetoothAdvertisingData)
|
adData: &BluetoothAdvertisingData)
|
||||||
|
@ -66,6 +66,8 @@ impl BluetoothDeviceMethods for BluetoothDevice {
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-gatt
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-gatt
|
||||||
fn Gatt(&self) -> Root<BluetoothRemoteGATTServer> {
|
fn Gatt(&self) -> Root<BluetoothRemoteGATTServer> {
|
||||||
self.gatt.or_init(|| BluetoothRemoteGATTServer::new(self.global().r(), self))
|
self.gatt.or_init(|| {
|
||||||
|
BluetoothRemoteGATTServer::new(&self.global(), self)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::Bluetoot
|
||||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
|
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
|
||||||
use dom::bindings::error::{ErrorResult, Fallible};
|
use dom::bindings::error::{ErrorResult, Fallible};
|
||||||
use dom::bindings::error::Error::{self, InvalidModification, Network, NotSupported, Security};
|
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::js::{JS, MutHeap, Root};
|
||||||
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::str::{ByteString, DOMString};
|
use dom::bindings::str::{ByteString, DOMString};
|
||||||
|
@ -23,6 +22,7 @@ use dom::bluetoothcharacteristicproperties::BluetoothCharacteristicProperties;
|
||||||
use dom::bluetoothremotegattdescriptor::BluetoothRemoteGATTDescriptor;
|
use dom::bluetoothremotegattdescriptor::BluetoothRemoteGATTDescriptor;
|
||||||
use dom::bluetoothremotegattservice::BluetoothRemoteGATTService;
|
use dom::bluetoothremotegattservice::BluetoothRemoteGATTService;
|
||||||
use dom::bluetoothuuid::{BluetoothDescriptorUUID, BluetoothUUID};
|
use dom::bluetoothuuid::{BluetoothDescriptorUUID, BluetoothUUID};
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::promise::Promise;
|
use dom::promise::Promise;
|
||||||
use ipc_channel::ipc::{self, IpcSender};
|
use ipc_channel::ipc::{self, IpcSender};
|
||||||
use net_traits::bluetooth_thread::BluetoothMethodMsg;
|
use net_traits::bluetooth_thread::BluetoothMethodMsg;
|
||||||
|
@ -59,7 +59,7 @@ impl BluetoothRemoteGATTCharacteristic {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: GlobalRef,
|
pub fn new(global: &GlobalScope,
|
||||||
service: &BluetoothRemoteGATTService,
|
service: &BluetoothRemoteGATTService,
|
||||||
uuid: DOMString,
|
uuid: DOMString,
|
||||||
properties: &BluetoothCharacteristicProperties,
|
properties: &BluetoothCharacteristicProperties,
|
||||||
|
@ -74,9 +74,7 @@ impl BluetoothRemoteGATTCharacteristic {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_bluetooth_thread(&self) -> IpcSender<BluetoothMethodMsg> {
|
fn get_bluetooth_thread(&self) -> IpcSender<BluetoothMethodMsg> {
|
||||||
let global_root = self.global();
|
self.global().as_window().bluetooth_thread()
|
||||||
let global_ref = global_root.r();
|
|
||||||
global_ref.as_window().bluetooth_thread()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_instance_id(&self) -> String {
|
fn get_instance_id(&self) -> String {
|
||||||
|
@ -95,7 +93,7 @@ impl BluetoothRemoteGATTCharacteristic {
|
||||||
let descriptor = receiver.recv().unwrap();
|
let descriptor = receiver.recv().unwrap();
|
||||||
match descriptor {
|
match descriptor {
|
||||||
Ok(descriptor) => {
|
Ok(descriptor) => {
|
||||||
Ok(BluetoothRemoteGATTDescriptor::new(self.global().r(),
|
Ok(BluetoothRemoteGATTDescriptor::new(&self.global(),
|
||||||
self,
|
self,
|
||||||
DOMString::from(descriptor.uuid),
|
DOMString::from(descriptor.uuid),
|
||||||
descriptor.instance_id))
|
descriptor.instance_id))
|
||||||
|
@ -126,7 +124,7 @@ impl BluetoothRemoteGATTCharacteristic {
|
||||||
match descriptors_vec {
|
match descriptors_vec {
|
||||||
Ok(descriptor_vec) => {
|
Ok(descriptor_vec) => {
|
||||||
Ok(descriptor_vec.into_iter()
|
Ok(descriptor_vec.into_iter()
|
||||||
.map(|desc| BluetoothRemoteGATTDescriptor::new(self.global().r(),
|
.map(|desc| BluetoothRemoteGATTDescriptor::new(&self.global(),
|
||||||
self,
|
self,
|
||||||
DOMString::from(desc.uuid),
|
DOMString::from(desc.uuid),
|
||||||
desc.instance_id))
|
desc.instance_id))
|
||||||
|
@ -214,7 +212,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-getdescriptor
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-getdescriptor
|
||||||
fn GetDescriptor(&self, descriptor: BluetoothDescriptorUUID) -> Rc<Promise> {
|
fn GetDescriptor(&self, descriptor: BluetoothDescriptorUUID) -> Rc<Promise> {
|
||||||
result_to_promise(self.global().r(), self.get_descriptor(descriptor))
|
result_to_promise(&self.global(), self.get_descriptor(descriptor))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
|
@ -222,7 +220,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
|
||||||
fn GetDescriptors(&self,
|
fn GetDescriptors(&self,
|
||||||
descriptor: Option<BluetoothDescriptorUUID>)
|
descriptor: Option<BluetoothDescriptorUUID>)
|
||||||
-> Rc<Promise> {
|
-> Rc<Promise> {
|
||||||
result_to_promise(self.global().r(), self.get_descriptors(descriptor))
|
result_to_promise(&self.global(), self.get_descriptors(descriptor))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-value
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-value
|
||||||
|
@ -233,12 +231,12 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-readvalue
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-readvalue
|
||||||
fn ReadValue(&self) -> Rc<Promise> {
|
fn ReadValue(&self) -> Rc<Promise> {
|
||||||
result_to_promise(self.global().r(), self.read_value())
|
result_to_promise(&self.global(), self.read_value())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-writevalue
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-writevalue
|
||||||
fn WriteValue(&self, value: Vec<u8>) -> Rc<Promise> {
|
fn WriteValue(&self, value: Vec<u8>) -> Rc<Promise> {
|
||||||
result_to_promise(self.global().r(), self.write_value(value))
|
result_to_promise(&self.global(), self.write_value(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,12 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::Bluetoot
|
||||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
|
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
|
||||||
use dom::bindings::error::{ErrorResult, Fallible};
|
use dom::bindings::error::{ErrorResult, Fallible};
|
||||||
use dom::bindings::error::Error::{self, InvalidModification, Network, Security};
|
use dom::bindings::error::Error::{self, InvalidModification, Network, Security};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::{JS, MutHeap, Root};
|
use dom::bindings::js::{JS, MutHeap, Root};
|
||||||
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::str::{ByteString, DOMString};
|
use dom::bindings::str::{ByteString, DOMString};
|
||||||
use dom::bluetooth::result_to_promise;
|
use dom::bluetooth::result_to_promise;
|
||||||
use dom::bluetoothremotegattcharacteristic::{BluetoothRemoteGATTCharacteristic, MAXIMUM_ATTRIBUTE_LENGTH};
|
use dom::bluetoothremotegattcharacteristic::{BluetoothRemoteGATTCharacteristic, MAXIMUM_ATTRIBUTE_LENGTH};
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::promise::Promise;
|
use dom::promise::Promise;
|
||||||
use ipc_channel::ipc::{self, IpcSender};
|
use ipc_channel::ipc::{self, IpcSender};
|
||||||
use net_traits::bluetooth_thread::BluetoothMethodMsg;
|
use net_traits::bluetooth_thread::BluetoothMethodMsg;
|
||||||
|
@ -48,7 +48,7 @@ impl BluetoothRemoteGATTDescriptor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: GlobalRef,
|
pub fn new(global: &GlobalScope,
|
||||||
characteristic: &BluetoothRemoteGATTCharacteristic,
|
characteristic: &BluetoothRemoteGATTCharacteristic,
|
||||||
uuid: DOMString,
|
uuid: DOMString,
|
||||||
instanceID: String)
|
instanceID: String)
|
||||||
|
@ -61,9 +61,7 @@ impl BluetoothRemoteGATTDescriptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_bluetooth_thread(&self) -> IpcSender<BluetoothMethodMsg> {
|
fn get_bluetooth_thread(&self) -> IpcSender<BluetoothMethodMsg> {
|
||||||
let global_root = self.global();
|
self.global().as_window().bluetooth_thread()
|
||||||
let global_ref = global_root.r();
|
|
||||||
global_ref.as_window().bluetooth_thread()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_instance_id(&self) -> String {
|
fn get_instance_id(&self) -> String {
|
||||||
|
@ -137,12 +135,12 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-readvalue
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-readvalue
|
||||||
fn ReadValue(&self) -> Rc<Promise> {
|
fn ReadValue(&self) -> Rc<Promise> {
|
||||||
result_to_promise(self.global().r(), self.read_value())
|
result_to_promise(&self.global(), self.read_value())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-writevalue
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-writevalue
|
||||||
fn WriteValue(&self, value: Vec<u8>) -> Rc<Promise> {
|
fn WriteValue(&self, value: Vec<u8>) -> Rc<Promise> {
|
||||||
result_to_promise(self.global().r(), self.write_value(value))
|
result_to_promise(&self.global(), self.write_value(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding;
|
||||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods;
|
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods;
|
||||||
use dom::bindings::error::{ErrorResult, Fallible};
|
use dom::bindings::error::{ErrorResult, Fallible};
|
||||||
use dom::bindings::error::Error::{self, Security};
|
use dom::bindings::error::Error::{self, Security};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::{JS, MutHeap, Root};
|
use dom::bindings::js::{JS, MutHeap, Root};
|
||||||
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
|
@ -16,6 +15,7 @@ use dom::bluetooth::result_to_promise;
|
||||||
use dom::bluetoothdevice::BluetoothDevice;
|
use dom::bluetoothdevice::BluetoothDevice;
|
||||||
use dom::bluetoothremotegattservice::BluetoothRemoteGATTService;
|
use dom::bluetoothremotegattservice::BluetoothRemoteGATTService;
|
||||||
use dom::bluetoothuuid::{BluetoothServiceUUID, BluetoothUUID};
|
use dom::bluetoothuuid::{BluetoothServiceUUID, BluetoothUUID};
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::promise::Promise;
|
use dom::promise::Promise;
|
||||||
use ipc_channel::ipc::{self, IpcSender};
|
use ipc_channel::ipc::{self, IpcSender};
|
||||||
use net_traits::bluetooth_thread::BluetoothMethodMsg;
|
use net_traits::bluetooth_thread::BluetoothMethodMsg;
|
||||||
|
@ -39,16 +39,14 @@ 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),
|
reflect_dom_object(box BluetoothRemoteGATTServer::new_inherited(device),
|
||||||
global,
|
global,
|
||||||
BluetoothRemoteGATTServerBinding::Wrap)
|
BluetoothRemoteGATTServerBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_bluetooth_thread(&self) -> IpcSender<BluetoothMethodMsg> {
|
fn get_bluetooth_thread(&self) -> IpcSender<BluetoothMethodMsg> {
|
||||||
let global_root = self.global();
|
self.global().as_window().bluetooth_thread()
|
||||||
let global_ref = global_root.r();
|
|
||||||
global_ref.as_window().bluetooth_thread()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-connect
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-connect
|
||||||
|
@ -80,7 +78,7 @@ impl BluetoothRemoteGATTServer {
|
||||||
let service = receiver.recv().unwrap();
|
let service = receiver.recv().unwrap();
|
||||||
match service {
|
match service {
|
||||||
Ok(service) => {
|
Ok(service) => {
|
||||||
Ok(BluetoothRemoteGATTService::new(self.global().r(),
|
Ok(BluetoothRemoteGATTService::new(&self.global(),
|
||||||
&self.device.get(),
|
&self.device.get(),
|
||||||
DOMString::from(service.uuid),
|
DOMString::from(service.uuid),
|
||||||
service.is_primary,
|
service.is_primary,
|
||||||
|
@ -112,7 +110,7 @@ impl BluetoothRemoteGATTServer {
|
||||||
match services_vec {
|
match services_vec {
|
||||||
Ok(service_vec) => {
|
Ok(service_vec) => {
|
||||||
Ok(service_vec.into_iter()
|
Ok(service_vec.into_iter()
|
||||||
.map(|service| BluetoothRemoteGATTService::new(self.global().r(),
|
.map(|service| BluetoothRemoteGATTService::new(&self.global(),
|
||||||
&self.device.get(),
|
&self.device.get(),
|
||||||
DOMString::from(service.uuid),
|
DOMString::from(service.uuid),
|
||||||
service.is_primary,
|
service.is_primary,
|
||||||
|
@ -140,7 +138,7 @@ impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer {
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-connect
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-connect
|
||||||
fn Connect(&self) -> Rc<Promise> {
|
fn Connect(&self) -> Rc<Promise> {
|
||||||
result_to_promise(self.global().r(), self.connect())
|
result_to_promise(&self.global(), self.connect())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-disconnect
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-disconnect
|
||||||
|
@ -163,7 +161,7 @@ impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer {
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-getprimaryservice
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-getprimaryservice
|
||||||
fn GetPrimaryService(&self, service: BluetoothServiceUUID) -> Rc<Promise> {
|
fn GetPrimaryService(&self, service: BluetoothServiceUUID) -> Rc<Promise> {
|
||||||
result_to_promise(self.global().r(), self.get_primary_service(service))
|
result_to_promise(&self.global(), self.get_primary_service(service))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
|
@ -171,6 +169,6 @@ impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer {
|
||||||
fn GetPrimaryServices(&self,
|
fn GetPrimaryServices(&self,
|
||||||
service: Option<BluetoothServiceUUID>)
|
service: Option<BluetoothServiceUUID>)
|
||||||
-> Rc<Promise> {
|
-> Rc<Promise> {
|
||||||
result_to_promise(self.global().r(), self.get_primary_services(service))
|
result_to_promise(&self.global(), self.get_primary_services(service))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding;
|
||||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
|
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
|
||||||
use dom::bindings::error::Error::{self, Security};
|
use dom::bindings::error::Error::{self, Security};
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::{JS, MutHeap, Root};
|
use dom::bindings::js::{JS, MutHeap, Root};
|
||||||
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
|
@ -16,6 +15,7 @@ use dom::bluetoothcharacteristicproperties::BluetoothCharacteristicProperties;
|
||||||
use dom::bluetoothdevice::BluetoothDevice;
|
use dom::bluetoothdevice::BluetoothDevice;
|
||||||
use dom::bluetoothremotegattcharacteristic::BluetoothRemoteGATTCharacteristic;
|
use dom::bluetoothremotegattcharacteristic::BluetoothRemoteGATTCharacteristic;
|
||||||
use dom::bluetoothuuid::{BluetoothCharacteristicUUID, BluetoothServiceUUID, BluetoothUUID};
|
use dom::bluetoothuuid::{BluetoothCharacteristicUUID, BluetoothServiceUUID, BluetoothUUID};
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::promise::Promise;
|
use dom::promise::Promise;
|
||||||
use ipc_channel::ipc::{self, IpcSender};
|
use ipc_channel::ipc::{self, IpcSender};
|
||||||
use net_traits::bluetooth_thread::BluetoothMethodMsg;
|
use net_traits::bluetooth_thread::BluetoothMethodMsg;
|
||||||
|
@ -46,7 +46,7 @@ impl BluetoothRemoteGATTService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: GlobalRef,
|
pub fn new(global: &GlobalScope,
|
||||||
device: &BluetoothDevice,
|
device: &BluetoothDevice,
|
||||||
uuid: DOMString,
|
uuid: DOMString,
|
||||||
isPrimary: bool,
|
isPrimary: bool,
|
||||||
|
@ -61,9 +61,7 @@ impl BluetoothRemoteGATTService {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_bluetooth_thread(&self) -> IpcSender<BluetoothMethodMsg> {
|
fn get_bluetooth_thread(&self) -> IpcSender<BluetoothMethodMsg> {
|
||||||
let global_root = self.global();
|
self.global().as_window().bluetooth_thread()
|
||||||
let global_ref = global_root.r();
|
|
||||||
global_ref.as_window().bluetooth_thread()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_instance_id(&self) -> String {
|
fn get_instance_id(&self) -> String {
|
||||||
|
@ -84,7 +82,8 @@ impl BluetoothRemoteGATTService {
|
||||||
let characteristic = receiver.recv().unwrap();
|
let characteristic = receiver.recv().unwrap();
|
||||||
match characteristic {
|
match characteristic {
|
||||||
Ok(characteristic) => {
|
Ok(characteristic) => {
|
||||||
let properties = BluetoothCharacteristicProperties::new(self.global().r(),
|
let global = self.global();
|
||||||
|
let properties = BluetoothCharacteristicProperties::new(&global,
|
||||||
characteristic.broadcast,
|
characteristic.broadcast,
|
||||||
characteristic.read,
|
characteristic.read,
|
||||||
characteristic.write_without_response,
|
characteristic.write_without_response,
|
||||||
|
@ -94,7 +93,7 @@ impl BluetoothRemoteGATTService {
|
||||||
characteristic.authenticated_signed_writes,
|
characteristic.authenticated_signed_writes,
|
||||||
characteristic.reliable_write,
|
characteristic.reliable_write,
|
||||||
characteristic.writable_auxiliaries);
|
characteristic.writable_auxiliaries);
|
||||||
Ok(BluetoothRemoteGATTCharacteristic::new(self.global().r(),
|
Ok(BluetoothRemoteGATTCharacteristic::new(&global,
|
||||||
self,
|
self,
|
||||||
DOMString::from(characteristic.uuid),
|
DOMString::from(characteristic.uuid),
|
||||||
&properties,
|
&properties,
|
||||||
|
@ -127,7 +126,8 @@ impl BluetoothRemoteGATTService {
|
||||||
match characteristics_vec {
|
match characteristics_vec {
|
||||||
Ok(characteristic_vec) => {
|
Ok(characteristic_vec) => {
|
||||||
for characteristic in characteristic_vec {
|
for characteristic in characteristic_vec {
|
||||||
let properties = BluetoothCharacteristicProperties::new(self.global().r(),
|
let global = self.global();
|
||||||
|
let properties = BluetoothCharacteristicProperties::new(&global,
|
||||||
characteristic.broadcast,
|
characteristic.broadcast,
|
||||||
characteristic.read,
|
characteristic.read,
|
||||||
characteristic.write_without_response,
|
characteristic.write_without_response,
|
||||||
|
@ -137,7 +137,7 @@ impl BluetoothRemoteGATTService {
|
||||||
characteristic.authenticated_signed_writes,
|
characteristic.authenticated_signed_writes,
|
||||||
characteristic.reliable_write,
|
characteristic.reliable_write,
|
||||||
characteristic.writable_auxiliaries);
|
characteristic.writable_auxiliaries);
|
||||||
characteristics.push(BluetoothRemoteGATTCharacteristic::new(self.global().r(),
|
characteristics.push(BluetoothRemoteGATTCharacteristic::new(&global,
|
||||||
self,
|
self,
|
||||||
DOMString::from(characteristic.uuid),
|
DOMString::from(characteristic.uuid),
|
||||||
&properties,
|
&properties,
|
||||||
|
@ -167,7 +167,7 @@ impl BluetoothRemoteGATTService {
|
||||||
let service = receiver.recv().unwrap();
|
let service = receiver.recv().unwrap();
|
||||||
match service {
|
match service {
|
||||||
Ok(service) => {
|
Ok(service) => {
|
||||||
Ok(BluetoothRemoteGATTService::new(self.global().r(),
|
Ok(BluetoothRemoteGATTService::new(&self.global(),
|
||||||
&self.device.get(),
|
&self.device.get(),
|
||||||
DOMString::from(service.uuid),
|
DOMString::from(service.uuid),
|
||||||
service.is_primary,
|
service.is_primary,
|
||||||
|
@ -201,7 +201,7 @@ impl BluetoothRemoteGATTService {
|
||||||
match services_vec {
|
match services_vec {
|
||||||
Ok(service_vec) => {
|
Ok(service_vec) => {
|
||||||
Ok(service_vec.into_iter()
|
Ok(service_vec.into_iter()
|
||||||
.map(|service| BluetoothRemoteGATTService::new(self.global().r(),
|
.map(|service| BluetoothRemoteGATTService::new(&self.global(),
|
||||||
&self.device.get(),
|
&self.device.get(),
|
||||||
DOMString::from(service.uuid),
|
DOMString::from(service.uuid),
|
||||||
service.is_primary,
|
service.is_primary,
|
||||||
|
@ -236,7 +236,7 @@ impl BluetoothRemoteGATTServiceMethods for BluetoothRemoteGATTService {
|
||||||
fn GetCharacteristic(&self,
|
fn GetCharacteristic(&self,
|
||||||
characteristic: BluetoothCharacteristicUUID)
|
characteristic: BluetoothCharacteristicUUID)
|
||||||
-> Rc<Promise> {
|
-> Rc<Promise> {
|
||||||
result_to_promise(self.global().r(), self.get_characteristic(characteristic))
|
result_to_promise(&self.global(), self.get_characteristic(characteristic))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
|
@ -244,7 +244,7 @@ impl BluetoothRemoteGATTServiceMethods for BluetoothRemoteGATTService {
|
||||||
fn GetCharacteristics(&self,
|
fn GetCharacteristics(&self,
|
||||||
characteristic: Option<BluetoothCharacteristicUUID>)
|
characteristic: Option<BluetoothCharacteristicUUID>)
|
||||||
-> Rc<Promise> {
|
-> Rc<Promise> {
|
||||||
result_to_promise(self.global().r(), self.get_characteristics(characteristic))
|
result_to_promise(&self.global(), self.get_characteristics(characteristic))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
|
@ -252,7 +252,7 @@ impl BluetoothRemoteGATTServiceMethods for BluetoothRemoteGATTService {
|
||||||
fn GetIncludedService(&self,
|
fn GetIncludedService(&self,
|
||||||
service: BluetoothServiceUUID)
|
service: BluetoothServiceUUID)
|
||||||
-> Rc<Promise> {
|
-> Rc<Promise> {
|
||||||
result_to_promise(self.global().r(), self.get_included_service(service))
|
result_to_promise(&self.global(), self.get_included_service(service))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
|
@ -260,6 +260,6 @@ impl BluetoothRemoteGATTServiceMethods for BluetoothRemoteGATTService {
|
||||||
fn GetIncludedServices(&self,
|
fn GetIncludedServices(&self,
|
||||||
service: Option<BluetoothServiceUUID>)
|
service: Option<BluetoothServiceUUID>)
|
||||||
-> Rc<Promise> {
|
-> Rc<Promise> {
|
||||||
result_to_promise(self.global().r(), self.get_included_services(service))
|
result_to_promise(&self.global(), self.get_included_services(service))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
use dom::bindings::codegen::UnionTypes::StringOrUnsignedLong;
|
use dom::bindings::codegen::UnionTypes::StringOrUnsignedLong;
|
||||||
use dom::bindings::error::Error::Syntax;
|
use dom::bindings::error::Error::Syntax;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::reflector::Reflector;
|
use dom::bindings::reflector::Reflector;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
pub type UUID = DOMString;
|
pub type UUID = DOMString;
|
||||||
|
@ -271,22 +271,22 @@ const VALID_UUID_REGEX: &'static str = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-
|
||||||
|
|
||||||
impl BluetoothUUID {
|
impl BluetoothUUID {
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-canonicaluuid
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-canonicaluuid
|
||||||
pub fn CanonicalUUID(_: GlobalRef, alias: u32) -> UUID {
|
pub fn CanonicalUUID(_: &GlobalScope, alias: u32) -> UUID {
|
||||||
canonical_uuid(alias)
|
canonical_uuid(alias)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-getservice
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-getservice
|
||||||
pub fn GetService(_: GlobalRef, name: BluetoothServiceUUID) -> Fallible<UUID> {
|
pub fn GetService(_: &GlobalScope, name: BluetoothServiceUUID) -> Fallible<UUID> {
|
||||||
Self::service(name)
|
Self::service(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-getcharacteristic
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-getcharacteristic
|
||||||
pub fn GetCharacteristic(_: GlobalRef, name: BluetoothCharacteristicUUID) -> Fallible<UUID> {
|
pub fn GetCharacteristic(_: &GlobalScope, name: BluetoothCharacteristicUUID) -> Fallible<UUID> {
|
||||||
Self::characteristic(name)
|
Self::characteristic(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-getdescriptor
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-getdescriptor
|
||||||
pub fn GetDescriptor(_: GlobalRef, name: BluetoothDescriptorUUID) -> Fallible<UUID> {
|
pub fn GetDescriptor(_: &GlobalScope, name: BluetoothDescriptorUUID) -> Fallible<UUID> {
|
||||||
Self::descriptor(name)
|
Self::descriptor(name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
use dom::bindings::cell::DOMRefCell;
|
use dom::bindings::cell::DOMRefCell;
|
||||||
use dom::bindings::conversions::{ToJSValConvertible, root_from_handleobject};
|
use dom::bindings::conversions::{ToJSValConvertible, root_from_handleobject};
|
||||||
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference};
|
use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference};
|
||||||
use dom::bindings::proxyhandler::{fill_property_descriptor, get_property_descriptor};
|
use dom::bindings::proxyhandler::{fill_property_descriptor, get_property_descriptor};
|
||||||
use dom::bindings::reflector::{Reflectable, MutReflectable, Reflector};
|
use dom::bindings::reflector::{Reflectable, MutReflectable, Reflector};
|
||||||
|
@ -12,6 +13,7 @@ use dom::bindings::utils::WindowProxyHandler;
|
||||||
use dom::bindings::utils::get_array_index_from_id;
|
use dom::bindings::utils::get_array_index_from_id;
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::element::Element;
|
use dom::element::Element;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use js::JSCLASS_IS_GLOBAL;
|
use js::JSCLASS_IS_GLOBAL;
|
||||||
use js::glue::{CreateWrapperProxyHandler, ProxyTraps, NewWindowProxy};
|
use js::glue::{CreateWrapperProxyHandler, ProxyTraps, NewWindowProxy};
|
||||||
|
@ -150,7 +152,7 @@ impl BrowsingContext {
|
||||||
pub fn find_child_by_id(&self, pipeline_id: PipelineId) -> Option<Root<Window>> {
|
pub fn find_child_by_id(&self, pipeline_id: PipelineId) -> Option<Root<Window>> {
|
||||||
self.children.borrow().iter().find(|context| {
|
self.children.borrow().iter().find(|context| {
|
||||||
let window = context.active_window();
|
let window = context.active_window();
|
||||||
window.pipeline_id() == pipeline_id
|
window.upcast::<GlobalScope>().pipeline_id() == pipeline_id
|
||||||
}).map(|context| context.active_window())
|
}).map(|context| context.active_window())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,11 @@ use dom::bindings::cell::DOMRefCell;
|
||||||
use dom::bindings::codegen::Bindings::CanvasGradientBinding;
|
use dom::bindings::codegen::Bindings::CanvasGradientBinding;
|
||||||
use dom::bindings::codegen::Bindings::CanvasGradientBinding::CanvasGradientMethods;
|
use dom::bindings::codegen::Bindings::CanvasGradientBinding::CanvasGradientMethods;
|
||||||
use dom::bindings::error::{Error, ErrorResult};
|
use dom::bindings::error::{Error, ErrorResult};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::num::Finite;
|
use dom::bindings::num::Finite;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#canvasgradient
|
// https://html.spec.whatwg.org/multipage/#canvasgradient
|
||||||
#[dom_struct]
|
#[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),
|
reflect_dom_object(box CanvasGradient::new_inherited(style),
|
||||||
global,
|
global,
|
||||||
CanvasGradientBinding::Wrap)
|
CanvasGradientBinding::Wrap)
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
|
|
||||||
use canvas_traits::{FillOrStrokeStyle, RepetitionStyle, SurfaceStyle};
|
use canvas_traits::{FillOrStrokeStyle, RepetitionStyle, SurfaceStyle};
|
||||||
use dom::bindings::codegen::Bindings::CanvasPatternBinding;
|
use dom::bindings::codegen::Bindings::CanvasPatternBinding;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::canvasgradient::ToFillOrStrokeStyle;
|
use dom::canvasgradient::ToFillOrStrokeStyle;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use euclid::size::Size2D;
|
use euclid::size::Size2D;
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#canvaspattern
|
// https://html.spec.whatwg.org/multipage/#canvaspattern
|
||||||
|
@ -43,7 +43,7 @@ impl CanvasPattern {
|
||||||
origin_clean: origin_clean,
|
origin_clean: origin_clean,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn new(global: GlobalRef,
|
pub fn new(global: &GlobalScope,
|
||||||
surface_data: Vec<u8>,
|
surface_data: Vec<u8>,
|
||||||
surface_size: Size2D<i32>,
|
surface_size: Size2D<i32>,
|
||||||
repeat: RepetitionStyle,
|
repeat: RepetitionStyle,
|
||||||
|
|
|
@ -20,7 +20,6 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::codegen::UnionTypes::HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D;
|
use dom::bindings::codegen::UnionTypes::HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D;
|
||||||
use dom::bindings::codegen::UnionTypes::StringOrCanvasGradientOrCanvasPattern;
|
use dom::bindings::codegen::UnionTypes::StringOrCanvasGradientOrCanvasPattern;
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{JS, LayoutJS, Root};
|
use dom::bindings::js::{JS, LayoutJS, Root};
|
||||||
use dom::bindings::num::Finite;
|
use dom::bindings::num::Finite;
|
||||||
|
@ -28,6 +27,7 @@ use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::canvasgradient::{CanvasGradient, CanvasGradientStyle, ToFillOrStrokeStyle};
|
use dom::canvasgradient::{CanvasGradient, CanvasGradientStyle, ToFillOrStrokeStyle};
|
||||||
use dom::canvaspattern::CanvasPattern;
|
use dom::canvaspattern::CanvasPattern;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::htmlcanvaselement::HTMLCanvasElement;
|
use dom::htmlcanvaselement::HTMLCanvasElement;
|
||||||
use dom::htmlcanvaselement::utils as canvas_utils;
|
use dom::htmlcanvaselement::utils as canvas_utils;
|
||||||
use dom::htmlimageelement::HTMLImageElement;
|
use dom::htmlimageelement::HTMLImageElement;
|
||||||
|
@ -117,7 +117,7 @@ impl CanvasContextState {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CanvasRenderingContext2D {
|
impl CanvasRenderingContext2D {
|
||||||
fn new_inherited(global: GlobalRef,
|
fn new_inherited(global: &GlobalScope,
|
||||||
canvas: &HTMLCanvasElement,
|
canvas: &HTMLCanvasElement,
|
||||||
size: Size2D<i32>)
|
size: Size2D<i32>)
|
||||||
-> CanvasRenderingContext2D {
|
-> CanvasRenderingContext2D {
|
||||||
|
@ -135,7 +135,7 @@ impl CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: GlobalRef,
|
pub fn new(global: &GlobalScope,
|
||||||
canvas: &HTMLCanvasElement,
|
canvas: &HTMLCanvasElement,
|
||||||
size: Size2D<i32>)
|
size: Size2D<i32>)
|
||||||
-> Root<CanvasRenderingContext2D> {
|
-> Root<CanvasRenderingContext2D> {
|
||||||
|
@ -1016,12 +1016,12 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
|
|
||||||
let sw = cmp::max(1, sw.abs().to_u32().unwrap());
|
let sw = cmp::max(1, sw.abs().to_u32().unwrap());
|
||||||
let sh = cmp::max(1, sh.abs().to_u32().unwrap());
|
let sh = cmp::max(1, sh.abs().to_u32().unwrap());
|
||||||
Ok(ImageData::new(self.global().r(), sw, sh, None))
|
Ok(ImageData::new(&self.global(), sw, sh, None))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createimagedata
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createimagedata
|
||||||
fn CreateImageData_(&self, imagedata: &ImageData) -> Fallible<Root<ImageData>> {
|
fn CreateImageData_(&self, imagedata: &ImageData) -> Fallible<Root<ImageData>> {
|
||||||
Ok(ImageData::new(self.global().r(),
|
Ok(ImageData::new(&self.global(),
|
||||||
imagedata.Width(),
|
imagedata.Width(),
|
||||||
imagedata.Height(),
|
imagedata.Height(),
|
||||||
None))
|
None))
|
||||||
|
@ -1077,7 +1077,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
chunk[2] = UNPREMULTIPLY_TABLE[256 * alpha + chunk[2] as usize];
|
chunk[2] = UNPREMULTIPLY_TABLE[256 * alpha + chunk[2] as usize];
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(ImageData::new(self.global().r(), sw, sh, Some(data)))
|
Ok(ImageData::new(&self.global(), sw, sh, Some(data)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-putimagedata
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-putimagedata
|
||||||
|
@ -1121,7 +1121,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
x1: Finite<f64>,
|
x1: Finite<f64>,
|
||||||
y1: Finite<f64>)
|
y1: Finite<f64>)
|
||||||
-> Root<CanvasGradient> {
|
-> Root<CanvasGradient> {
|
||||||
CanvasGradient::new(self.global().r(),
|
CanvasGradient::new(&self.global(),
|
||||||
CanvasGradientStyle::Linear(LinearGradientStyle::new(*x0,
|
CanvasGradientStyle::Linear(LinearGradientStyle::new(*x0,
|
||||||
*y0,
|
*y0,
|
||||||
*x1,
|
*x1,
|
||||||
|
@ -1142,7 +1142,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
return Err(Error::IndexSize);
|
return Err(Error::IndexSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(CanvasGradient::new(self.global().r(),
|
Ok(CanvasGradient::new(&self.global(),
|
||||||
CanvasGradientStyle::Radial(RadialGradientStyle::new(*x0,
|
CanvasGradientStyle::Radial(RadialGradientStyle::new(*x0,
|
||||||
*y0,
|
*y0,
|
||||||
*r0,
|
*r0,
|
||||||
|
@ -1182,7 +1182,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(rep) = RepetitionStyle::from_str(&repetition) {
|
if let Ok(rep) = RepetitionStyle::from_str(&repetition) {
|
||||||
Ok(CanvasPattern::new(self.global().r(),
|
Ok(CanvasPattern::new(&self.global(),
|
||||||
image_data,
|
image_data,
|
||||||
image_size,
|
image_size,
|
||||||
rep,
|
rep,
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::ClientBinding::{ClientMethods, Wrap};
|
use dom::bindings::codegen::Bindings::ClientBinding::{ClientMethods, Wrap};
|
||||||
use dom::bindings::codegen::Bindings::ClientBinding::FrameType;
|
use dom::bindings::codegen::Bindings::ClientBinding::FrameType;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::JS;
|
use dom::bindings::js::JS;
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
|
@ -36,7 +35,9 @@ impl Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(window: &Window) -> Root<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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,12 @@ use dom::bindings::codegen::Bindings::CloseEventBinding;
|
||||||
use dom::bindings::codegen::Bindings::CloseEventBinding::CloseEventMethods;
|
use dom::bindings::codegen::Bindings::CloseEventBinding::CloseEventMethods;
|
||||||
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use string_cache::Atom;
|
use string_cache::Atom;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -32,13 +32,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()),
|
reflect_dom_object(box CloseEvent::new_inherited(false, 0, DOMString::new()),
|
||||||
global,
|
global,
|
||||||
CloseEventBinding::Wrap)
|
CloseEventBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: GlobalRef,
|
pub fn new(global: &GlobalScope,
|
||||||
type_: Atom,
|
type_: Atom,
|
||||||
bubbles: EventBubbles,
|
bubbles: EventBubbles,
|
||||||
cancelable: EventCancelable,
|
cancelable: EventCancelable,
|
||||||
|
@ -57,7 +57,7 @@ impl CloseEvent {
|
||||||
ev
|
ev
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &CloseEventBinding::CloseEventInit)
|
init: &CloseEventBinding::CloseEventInit)
|
||||||
-> Fallible<Root<CloseEvent>> {
|
-> Fallible<Root<CloseEvent>> {
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
use dom::bindings::codegen::Bindings::CommentBinding;
|
use dom::bindings::codegen::Bindings::CommentBinding;
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::characterdata::CharacterData;
|
use dom::characterdata::CharacterData;
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::node::Node;
|
use dom::node::Node;
|
||||||
|
|
||||||
/// An HTML comment.
|
/// An HTML comment.
|
||||||
|
@ -31,7 +31,7 @@ impl Comment {
|
||||||
CommentBinding::Wrap)
|
CommentBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef, data: DOMString) -> Fallible<Root<Comment>> {
|
pub fn Constructor(global: &GlobalScope, data: DOMString) -> Fallible<Root<Comment>> {
|
||||||
let document = global.as_window().Document();
|
let document = global.as_window().Document();
|
||||||
Ok(Comment::new(data, document.r()))
|
Ok(Comment::new(data, document.r()))
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,25 +3,21 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use devtools_traits::{ConsoleMessage, LogLevel, ScriptToDevtoolsControlMsg};
|
use devtools_traits::{ConsoleMessage, LogLevel, ScriptToDevtoolsControlMsg};
|
||||||
use dom::bindings::cell::DOMRefCell;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use std::collections::HashMap;
|
use dom::globalscope::GlobalScope;
|
||||||
use std::collections::hash_map::Entry;
|
use dom::workerglobalscope::WorkerGlobalScope;
|
||||||
use time::{Timespec, get_time};
|
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Console
|
// https://developer.mozilla.org/en-US/docs/Web/API/Console
|
||||||
pub struct Console(());
|
pub struct Console(());
|
||||||
|
|
||||||
impl Console {
|
impl Console {
|
||||||
fn send_to_devtools(global: GlobalRef, level: LogLevel, message: DOMString) {
|
fn send_to_devtools(global: &GlobalScope, level: LogLevel, message: DOMString) {
|
||||||
if let Some(chan) = global.devtools_chan() {
|
if let Some(chan) = global.devtools_chan() {
|
||||||
let console_message = prepare_message(level, message);
|
let console_message = prepare_message(level, message);
|
||||||
let worker_id = if let GlobalRef::Worker(worker) = global {
|
let worker_id = global.downcast::<WorkerGlobalScope>().map(|worker| {
|
||||||
Some(worker.get_worker_id())
|
worker.get_worker_id()
|
||||||
} else {
|
});
|
||||||
None
|
|
||||||
};
|
|
||||||
let devtools_message = ScriptToDevtoolsControlMsg::ConsoleAPI(
|
let devtools_message = ScriptToDevtoolsControlMsg::ConsoleAPI(
|
||||||
global.pipeline_id(),
|
global.pipeline_id(),
|
||||||
console_message,
|
console_message,
|
||||||
|
@ -33,7 +29,7 @@ impl Console {
|
||||||
|
|
||||||
impl Console {
|
impl Console {
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Console/log
|
// https://developer.mozilla.org/en-US/docs/Web/API/Console/log
|
||||||
pub fn Log(global: GlobalRef, messages: Vec<DOMString>) {
|
pub fn Log(global: &GlobalScope, messages: Vec<DOMString>) {
|
||||||
for message in messages {
|
for message in messages {
|
||||||
println!("{}", message);
|
println!("{}", message);
|
||||||
Self::send_to_devtools(global, LogLevel::Log, message);
|
Self::send_to_devtools(global, LogLevel::Log, message);
|
||||||
|
@ -41,7 +37,7 @@ impl Console {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Console
|
// https://developer.mozilla.org/en-US/docs/Web/API/Console
|
||||||
pub fn Debug(global: GlobalRef, messages: Vec<DOMString>) {
|
pub fn Debug(global: &GlobalScope, messages: Vec<DOMString>) {
|
||||||
for message in messages {
|
for message in messages {
|
||||||
println!("{}", message);
|
println!("{}", message);
|
||||||
Self::send_to_devtools(global, LogLevel::Debug, message);
|
Self::send_to_devtools(global, LogLevel::Debug, message);
|
||||||
|
@ -49,7 +45,7 @@ impl Console {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Console/info
|
// https://developer.mozilla.org/en-US/docs/Web/API/Console/info
|
||||||
pub fn Info(global: GlobalRef, messages: Vec<DOMString>) {
|
pub fn Info(global: &GlobalScope, messages: Vec<DOMString>) {
|
||||||
for message in messages {
|
for message in messages {
|
||||||
println!("{}", message);
|
println!("{}", message);
|
||||||
Self::send_to_devtools(global, LogLevel::Info, message);
|
Self::send_to_devtools(global, LogLevel::Info, message);
|
||||||
|
@ -57,7 +53,7 @@ impl Console {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Console/warn
|
// https://developer.mozilla.org/en-US/docs/Web/API/Console/warn
|
||||||
pub fn Warn(global: GlobalRef, messages: Vec<DOMString>) {
|
pub fn Warn(global: &GlobalScope, messages: Vec<DOMString>) {
|
||||||
for message in messages {
|
for message in messages {
|
||||||
println!("{}", message);
|
println!("{}", message);
|
||||||
Self::send_to_devtools(global, LogLevel::Warn, message);
|
Self::send_to_devtools(global, LogLevel::Warn, message);
|
||||||
|
@ -65,7 +61,7 @@ impl Console {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Console/error
|
// https://developer.mozilla.org/en-US/docs/Web/API/Console/error
|
||||||
pub fn Error(global: GlobalRef, messages: Vec<DOMString>) {
|
pub fn Error(global: &GlobalScope, messages: Vec<DOMString>) {
|
||||||
for message in messages {
|
for message in messages {
|
||||||
println!("{}", message);
|
println!("{}", message);
|
||||||
Self::send_to_devtools(global, LogLevel::Error, message);
|
Self::send_to_devtools(global, LogLevel::Error, message);
|
||||||
|
@ -73,7 +69,7 @@ impl Console {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Console/assert
|
// https://developer.mozilla.org/en-US/docs/Web/API/Console/assert
|
||||||
pub fn Assert(global: GlobalRef, condition: bool, message: Option<DOMString>) {
|
pub fn Assert(global: &GlobalScope, condition: bool, message: Option<DOMString>) {
|
||||||
if !condition {
|
if !condition {
|
||||||
let message = message.unwrap_or_else(|| DOMString::from("no message"));
|
let message = message.unwrap_or_else(|| DOMString::from("no message"));
|
||||||
println!("Assertion failed: {}", message);
|
println!("Assertion failed: {}", message);
|
||||||
|
@ -82,8 +78,8 @@ impl Console {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Console/time
|
// https://developer.mozilla.org/en-US/docs/Web/API/Console/time
|
||||||
pub fn Time(global: GlobalRef, label: DOMString) {
|
pub fn Time(global: &GlobalScope, label: DOMString) {
|
||||||
if let Ok(()) = global.console_timers().time(label.clone()) {
|
if let Ok(()) = global.time(label.clone()) {
|
||||||
let message = DOMString::from(format!("{}: timer started", label));
|
let message = DOMString::from(format!("{}: timer started", label));
|
||||||
println!("{}", message);
|
println!("{}", message);
|
||||||
Self::send_to_devtools(global, LogLevel::Log, message);
|
Self::send_to_devtools(global, LogLevel::Log, message);
|
||||||
|
@ -91,8 +87,8 @@ impl Console {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Console/timeEnd
|
// https://developer.mozilla.org/en-US/docs/Web/API/Console/timeEnd
|
||||||
pub fn TimeEnd(global: GlobalRef, label: DOMString) {
|
pub fn TimeEnd(global: &GlobalScope, label: DOMString) {
|
||||||
if let Ok(delta) = global.console_timers().time_end(&label) {
|
if let Ok(delta) = global.time_end(&label) {
|
||||||
let message = DOMString::from(
|
let message = DOMString::from(
|
||||||
format!("{}: {}ms", label, delta)
|
format!("{}: {}ms", label, delta)
|
||||||
);
|
);
|
||||||
|
@ -102,10 +98,6 @@ impl Console {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn timestamp_in_ms(time: Timespec) -> u64 {
|
|
||||||
(time.sec * 1000 + (time.nsec / 1000000) as i64) as u64
|
|
||||||
}
|
|
||||||
|
|
||||||
fn prepare_message(log_level: LogLevel, message: DOMString) -> ConsoleMessage {
|
fn prepare_message(log_level: LogLevel, message: DOMString) -> ConsoleMessage {
|
||||||
// TODO: Sending fake values for filename, lineNumber and columnNumber in LogMessage; adjust later
|
// TODO: Sending fake values for filename, lineNumber and columnNumber in LogMessage; adjust later
|
||||||
ConsoleMessage {
|
ConsoleMessage {
|
||||||
|
@ -116,32 +108,3 @@ fn prepare_message(log_level: LogLevel, message: DOMString) -> ConsoleMessage {
|
||||||
columnNumber: 1,
|
columnNumber: 1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(HeapSizeOf, JSTraceable)]
|
|
||||||
pub struct TimerSet(DOMRefCell<HashMap<DOMString, u64>>);
|
|
||||||
|
|
||||||
impl TimerSet {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
TimerSet(DOMRefCell::new(Default::default()))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn time(&self, label: DOMString) -> Result<(), ()> {
|
|
||||||
let mut timers = self.0.borrow_mut();
|
|
||||||
if timers.len() >= 10000 {
|
|
||||||
return Err(());
|
|
||||||
}
|
|
||||||
match timers.entry(label) {
|
|
||||||
Entry::Vacant(entry) => {
|
|
||||||
entry.insert(timestamp_in_ms(get_time()));
|
|
||||||
Ok(())
|
|
||||||
},
|
|
||||||
Entry::Occupied(_) => Err(()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn time_end(&self, label: &str) -> Result<u64, ()> {
|
|
||||||
self.0.borrow_mut().remove(label).ok_or(()).map(|start| {
|
|
||||||
timestamp_in_ms(get_time()) - start
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -8,9 +8,9 @@ use dom::bindings::codegen::Bindings::CryptoBinding;
|
||||||
use dom::bindings::codegen::Bindings::CryptoBinding::CryptoMethods;
|
use dom::bindings::codegen::Bindings::CryptoBinding::CryptoMethods;
|
||||||
use dom::bindings::conversions::array_buffer_view_data;
|
use dom::bindings::conversions::array_buffer_view_data;
|
||||||
use dom::bindings::error::{Error, Fallible};
|
use dom::bindings::error::{Error, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use js::jsapi::{JSContext, JSObject};
|
use js::jsapi::{JSContext, JSObject};
|
||||||
use js::jsapi::{JS_GetArrayBufferViewType, Type};
|
use js::jsapi::{JS_GetArrayBufferViewType, Type};
|
||||||
use rand::{OsRng, Rng};
|
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)
|
reflect_dom_object(box Crypto::new_inherited(), global, CryptoBinding::Wrap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
use cssparser::serialize_identifier;
|
use cssparser::serialize_identifier;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::reflector::Reflector;
|
use dom::bindings::reflector::Reflector;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct CSS {
|
pub struct CSS {
|
||||||
|
@ -15,7 +15,7 @@ pub struct CSS {
|
||||||
|
|
||||||
impl CSS {
|
impl CSS {
|
||||||
// http://dev.w3.org/csswg/cssom/#serialize-an-identifier
|
// http://dev.w3.org/csswg/cssom/#serialize-an-identifier
|
||||||
pub fn Escape(_: GlobalRef, ident: DOMString) -> Fallible<DOMString> {
|
pub fn Escape(_: &GlobalScope, ident: DOMString) -> Fallible<DOMString> {
|
||||||
let mut escaped = String::new();
|
let mut escaped = String::new();
|
||||||
serialize_identifier(&ident, &mut escaped).unwrap();
|
serialize_identifier(&ident, &mut escaped).unwrap();
|
||||||
Ok(DOMString::from(escaped))
|
Ok(DOMString::from(escaped))
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
use cssparser::ToCss;
|
use cssparser::ToCss;
|
||||||
use dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::{self, CSSStyleDeclarationMethods};
|
use dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::{self, CSSStyleDeclarationMethods};
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{JS, Root};
|
use dom::bindings::js::{JS, Root};
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
|
@ -71,7 +70,7 @@ impl CSSStyleDeclaration {
|
||||||
reflect_dom_object(box CSSStyleDeclaration::new_inherited(owner,
|
reflect_dom_object(box CSSStyleDeclaration::new_inherited(owner,
|
||||||
pseudo,
|
pseudo,
|
||||||
modification_access),
|
modification_access),
|
||||||
GlobalRef::Window(global),
|
global,
|
||||||
CSSStyleDeclarationBinding::Wrap)
|
CSSStyleDeclarationBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,12 @@ use dom::bindings::codegen::Bindings::CustomEventBinding;
|
||||||
use dom::bindings::codegen::Bindings::CustomEventBinding::CustomEventMethods;
|
use dom::bindings::codegen::Bindings::CustomEventBinding::CustomEventMethods;
|
||||||
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{MutHeapJSVal, Root};
|
use dom::bindings::js::{MutHeapJSVal, Root};
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::event::Event;
|
use dom::event::Event;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use js::jsapi::{HandleValue, JSContext};
|
use js::jsapi::{HandleValue, JSContext};
|
||||||
use js::jsval::JSVal;
|
use js::jsval::JSVal;
|
||||||
use string_cache::Atom;
|
use string_cache::Atom;
|
||||||
|
@ -32,12 +32,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(),
|
reflect_dom_object(box CustomEvent::new_inherited(),
|
||||||
global,
|
global,
|
||||||
CustomEventBinding::Wrap)
|
CustomEventBinding::Wrap)
|
||||||
}
|
}
|
||||||
pub fn new(global: GlobalRef,
|
pub fn new(global: &GlobalScope,
|
||||||
type_: Atom,
|
type_: Atom,
|
||||||
bubbles: bool,
|
bubbles: bool,
|
||||||
cancelable: bool,
|
cancelable: bool,
|
||||||
|
@ -47,8 +47,9 @@ impl CustomEvent {
|
||||||
ev.init_custom_event(type_, bubbles, cancelable, detail);
|
ev.init_custom_event(type_, bubbles, cancelable, detail);
|
||||||
ev
|
ev
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &CustomEventBinding::CustomEventInit)
|
init: &CustomEventBinding::CustomEventInit)
|
||||||
-> Fallible<Root<CustomEvent>> {
|
-> Fallible<Root<CustomEvent>> {
|
||||||
|
|
|
@ -11,12 +11,12 @@ use dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding;
|
||||||
use dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding::DedicatedWorkerGlobalScopeMethods;
|
use dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding::DedicatedWorkerGlobalScopeMethods;
|
||||||
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
||||||
use dom::bindings::error::{ErrorInfo, ErrorResult};
|
use dom::bindings::error::{ErrorInfo, ErrorResult};
|
||||||
use dom::bindings::global::{GlobalRef, global_root_from_context};
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{Root, RootCollection};
|
use dom::bindings::js::{Root, RootCollection};
|
||||||
use dom::bindings::reflector::Reflectable;
|
use dom::bindings::reflector::Reflectable;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::bindings::structuredclone::StructuredCloneData;
|
use dom::bindings::structuredclone::StructuredCloneData;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::messageevent::MessageEvent;
|
use dom::messageevent::MessageEvent;
|
||||||
use dom::worker::{TrustedWorkerAddress, WorkerErrorHandler, WorkerMessageHandler};
|
use dom::worker::{TrustedWorkerAddress, WorkerErrorHandler, WorkerMessageHandler};
|
||||||
use dom::workerglobalscope::WorkerGlobalScope;
|
use dom::workerglobalscope::WorkerGlobalScope;
|
||||||
|
@ -212,7 +212,7 @@ impl DedicatedWorkerGlobalScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
let reporter_name = format!("dedicated-worker-reporter-{}", random::<u64>());
|
let reporter_name = format!("dedicated-worker-reporter-{}", random::<u64>());
|
||||||
scope.mem_profiler_chan().run_with_memory_reporting(|| {
|
scope.upcast::<GlobalScope>().mem_profiler_chan().run_with_memory_reporting(|| {
|
||||||
while let Ok(event) = global.receive_event() {
|
while let Ok(event) = global.receive_event() {
|
||||||
if scope.is_closing() {
|
if scope.is_closing() {
|
||||||
break;
|
break;
|
||||||
|
@ -281,8 +281,8 @@ impl DedicatedWorkerGlobalScope {
|
||||||
let _ac = JSAutoCompartment::new(scope.get_cx(),
|
let _ac = JSAutoCompartment::new(scope.get_cx(),
|
||||||
scope.reflector().get_jsobject().get());
|
scope.reflector().get_jsobject().get());
|
||||||
rooted!(in(scope.get_cx()) let mut message = UndefinedValue());
|
rooted!(in(scope.get_cx()) let mut message = UndefinedValue());
|
||||||
data.read(GlobalRef::Worker(scope), message.handle_mut());
|
data.read(scope.upcast(), message.handle_mut());
|
||||||
MessageEvent::dispatch_jsval(target, GlobalRef::Worker(scope), message.handle());
|
MessageEvent::dispatch_jsval(target, scope.upcast(), message.handle());
|
||||||
},
|
},
|
||||||
WorkerScriptMsg::Common(CommonScriptMsg::RunnableMsg(_, runnable)) => {
|
WorkerScriptMsg::Common(CommonScriptMsg::RunnableMsg(_, runnable)) => {
|
||||||
runnable.handler()
|
runnable.handler()
|
||||||
|
@ -300,14 +300,13 @@ impl DedicatedWorkerGlobalScope {
|
||||||
fn handle_event(&self, event: MixedMessage) {
|
fn handle_event(&self, event: MixedMessage) {
|
||||||
match event {
|
match event {
|
||||||
MixedMessage::FromDevtools(msg) => {
|
MixedMessage::FromDevtools(msg) => {
|
||||||
let global_ref = GlobalRef::Worker(self.upcast());
|
|
||||||
match msg {
|
match msg {
|
||||||
DevtoolScriptControlMsg::EvaluateJS(_pipe_id, string, sender) =>
|
DevtoolScriptControlMsg::EvaluateJS(_pipe_id, string, sender) =>
|
||||||
devtools::handle_evaluate_js(&global_ref, string, sender),
|
devtools::handle_evaluate_js(self.upcast(), string, sender),
|
||||||
DevtoolScriptControlMsg::GetCachedMessages(pipe_id, message_types, sender) =>
|
DevtoolScriptControlMsg::GetCachedMessages(pipe_id, message_types, sender) =>
|
||||||
devtools::handle_get_cached_messages(pipe_id, message_types, sender),
|
devtools::handle_get_cached_messages(pipe_id, message_types, sender),
|
||||||
DevtoolScriptControlMsg::WantsLiveNotifications(_pipe_id, bool_val) =>
|
DevtoolScriptControlMsg::WantsLiveNotifications(_pipe_id, bool_val) =>
|
||||||
devtools::handle_wants_live_notifications(&global_ref, bool_val),
|
devtools::handle_wants_live_notifications(self.upcast(), bool_val),
|
||||||
_ => debug!("got an unusable devtools control message inside the worker!"),
|
_ => debug!("got an unusable devtools control message inside the worker!"),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -342,11 +341,9 @@ impl DedicatedWorkerGlobalScope {
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe extern "C" fn interrupt_callback(cx: *mut JSContext) -> bool {
|
unsafe extern "C" fn interrupt_callback(cx: *mut JSContext) -> bool {
|
||||||
let global = global_root_from_context(cx);
|
let worker =
|
||||||
let worker = match global.r() {
|
Root::downcast::<WorkerGlobalScope>(GlobalScope::from_context(cx))
|
||||||
GlobalRef::Worker(w) => w,
|
.expect("global is not a worker scope");
|
||||||
_ => panic!("global for worker is not a worker scope")
|
|
||||||
};
|
|
||||||
assert!(worker.is::<DedicatedWorkerGlobalScope>());
|
assert!(worker.is::<DedicatedWorkerGlobalScope>());
|
||||||
|
|
||||||
// A false response causes the script to terminate
|
// A false response causes the script to terminate
|
||||||
|
|
|
@ -21,7 +21,6 @@ use dom::bindings::codegen::Bindings::TouchBinding::TouchMethods;
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::codegen::UnionTypes::NodeOrString;
|
use dom::bindings::codegen::UnionTypes::NodeOrString;
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
|
use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
|
||||||
use dom::bindings::js::{JS, LayoutJS, MutNullableHeap, Root};
|
use dom::bindings::js::{JS, LayoutJS, MutNullableHeap, Root};
|
||||||
use dom::bindings::js::RootedReference;
|
use dom::bindings::js::RootedReference;
|
||||||
|
@ -45,6 +44,7 @@ use dom::eventdispatcher::EventStatus;
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
use dom::focusevent::FocusEvent;
|
use dom::focusevent::FocusEvent;
|
||||||
use dom::forcetouchevent::ForceTouchEvent;
|
use dom::forcetouchevent::ForceTouchEvent;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::hashchangeevent::HashChangeEvent;
|
use dom::hashchangeevent::HashChangeEvent;
|
||||||
use dom::htmlanchorelement::HTMLAnchorElement;
|
use dom::htmlanchorelement::HTMLAnchorElement;
|
||||||
use dom::htmlappletelement::HTMLAppletElement;
|
use dom::htmlappletelement::HTMLAppletElement;
|
||||||
|
@ -650,8 +650,9 @@ impl Document {
|
||||||
// Update the focus state for all elements in the focus chain.
|
// Update the focus state for all elements in the focus chain.
|
||||||
// https://html.spec.whatwg.org/multipage/#focus-chain
|
// https://html.spec.whatwg.org/multipage/#focus-chain
|
||||||
if focus_type == FocusType::Element {
|
if focus_type == FocusType::Element {
|
||||||
let event = ConstellationMsg::Focus(self.window.pipeline_id());
|
let global_scope = self.window.upcast::<GlobalScope>();
|
||||||
self.window.constellation_chan().send(event).unwrap();
|
let event = ConstellationMsg::Focus(global_scope.pipeline_id());
|
||||||
|
global_scope.constellation_chan().send(event).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -669,8 +670,10 @@ impl Document {
|
||||||
/// Sends this document's title to the compositor.
|
/// Sends this document's title to the compositor.
|
||||||
pub fn send_title_to_compositor(&self) {
|
pub fn send_title_to_compositor(&self) {
|
||||||
let window = self.window();
|
let window = self.window();
|
||||||
window.constellation_chan()
|
let global_scope = window.upcast::<GlobalScope>();
|
||||||
.send(ConstellationMsg::SetTitle(window.pipeline_id(),
|
global_scope
|
||||||
|
.constellation_chan()
|
||||||
|
.send(ConstellationMsg::SetTitle(global_scope.pipeline_id(),
|
||||||
Some(String::from(self.Title()))))
|
Some(String::from(self.Title()))))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
@ -723,7 +726,7 @@ impl Document {
|
||||||
let event = ConstellationMsg::ForwardMouseButtonEvent(pipeline_id,
|
let event = ConstellationMsg::ForwardMouseButtonEvent(pipeline_id,
|
||||||
mouse_event_type,
|
mouse_event_type,
|
||||||
button, child_point);
|
button, child_point);
|
||||||
self.window.constellation_chan().send(event).unwrap();
|
self.window.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -961,7 +964,7 @@ impl Document {
|
||||||
let child_point = client_point - child_origin;
|
let child_point = client_point - child_origin;
|
||||||
|
|
||||||
let event = ConstellationMsg::ForwardMouseMoveEvent(pipeline_id, child_point);
|
let event = ConstellationMsg::ForwardMouseMoveEvent(pipeline_id, child_point);
|
||||||
self.window.constellation_chan().send(event).unwrap();
|
self.window.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1356,10 +1359,11 @@ impl Document {
|
||||||
pub fn trigger_mozbrowser_event(&self, event: MozBrowserEvent) {
|
pub fn trigger_mozbrowser_event(&self, event: MozBrowserEvent) {
|
||||||
if PREFS.is_mozbrowser_enabled() {
|
if PREFS.is_mozbrowser_enabled() {
|
||||||
if let Some((parent_pipeline_id, _)) = self.window.parent_info() {
|
if let Some((parent_pipeline_id, _)) = self.window.parent_info() {
|
||||||
|
let global_scope = self.window.upcast::<GlobalScope>();
|
||||||
let event = ConstellationMsg::MozBrowserEvent(parent_pipeline_id,
|
let event = ConstellationMsg::MozBrowserEvent(parent_pipeline_id,
|
||||||
Some(self.window.pipeline_id()),
|
Some(global_scope.pipeline_id()),
|
||||||
event);
|
event);
|
||||||
self.window.constellation_chan().send(event).unwrap();
|
global_scope.constellation_chan().send(event).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1379,10 +1383,11 @@ impl Document {
|
||||||
//
|
//
|
||||||
// TODO: Should tick animation only when document is visible
|
// TODO: Should tick animation only when document is visible
|
||||||
if !self.running_animation_callbacks.get() {
|
if !self.running_animation_callbacks.get() {
|
||||||
|
let global_scope = self.window.upcast::<GlobalScope>();
|
||||||
let event = ConstellationMsg::ChangeRunningAnimationsState(
|
let event = ConstellationMsg::ChangeRunningAnimationsState(
|
||||||
self.window.pipeline_id(),
|
global_scope.pipeline_id(),
|
||||||
AnimationState::AnimationCallbacksPresent);
|
AnimationState::AnimationCallbacksPresent);
|
||||||
self.window.constellation_chan().send(event).unwrap();
|
global_scope.constellation_chan().send(event).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
ident
|
ident
|
||||||
|
@ -1418,9 +1423,10 @@ impl Document {
|
||||||
if self.animation_frame_list.borrow().is_empty() {
|
if self.animation_frame_list.borrow().is_empty() {
|
||||||
mem::swap(&mut *self.animation_frame_list.borrow_mut(),
|
mem::swap(&mut *self.animation_frame_list.borrow_mut(),
|
||||||
&mut animation_frame_list);
|
&mut animation_frame_list);
|
||||||
let event = ConstellationMsg::ChangeRunningAnimationsState(self.window.pipeline_id(),
|
let global_scope = self.window.upcast::<GlobalScope>();
|
||||||
|
let event = ConstellationMsg::ChangeRunningAnimationsState(global_scope.pipeline_id(),
|
||||||
AnimationState::NoAnimationCallbacksPresent);
|
AnimationState::NoAnimationCallbacksPresent);
|
||||||
self.window.constellation_chan().send(event).unwrap();
|
global_scope.constellation_chan().send(event).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
self.running_animation_callbacks.set(false);
|
self.running_animation_callbacks.set(false);
|
||||||
|
@ -1478,7 +1484,8 @@ impl Document {
|
||||||
let loader = self.loader.borrow();
|
let loader = self.loader.borrow();
|
||||||
if !loader.is_blocked() && !loader.events_inhibited() {
|
if !loader.is_blocked() && !loader.events_inhibited() {
|
||||||
let win = self.window();
|
let win = self.window();
|
||||||
let msg = MainThreadScriptMsg::DocumentLoadsComplete(win.pipeline_id());
|
let msg = MainThreadScriptMsg::DocumentLoadsComplete(
|
||||||
|
win.upcast::<GlobalScope>().pipeline_id());
|
||||||
win.main_thread_script_chan().send(msg).unwrap();
|
win.main_thread_script_chan().send(msg).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1576,9 +1583,10 @@ impl Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn notify_constellation_load(&self) {
|
pub fn notify_constellation_load(&self) {
|
||||||
let pipeline_id = self.window.pipeline_id();
|
let global_scope = self.window.upcast::<GlobalScope>();
|
||||||
|
let pipeline_id = global_scope.pipeline_id();
|
||||||
let load_event = ConstellationMsg::LoadComplete(pipeline_id);
|
let load_event = ConstellationMsg::LoadComplete(pipeline_id);
|
||||||
self.window.constellation_chan().send(load_event).unwrap();
|
global_scope.constellation_chan().send(load_event).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_current_parser(&self, script: Option<ParserRef>) {
|
pub fn set_current_parser(&self, script: Option<ParserRef>) {
|
||||||
|
@ -1810,7 +1818,7 @@ impl Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document
|
// https://dom.spec.whatwg.org/#dom-document
|
||||||
pub fn Constructor(global: GlobalRef) -> Fallible<Root<Document>> {
|
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<Document>> {
|
||||||
let win = global.as_window();
|
let win = global.as_window();
|
||||||
let doc = win.Document();
|
let doc = win.Document();
|
||||||
let doc = doc.r();
|
let doc = doc.r();
|
||||||
|
@ -1848,7 +1856,7 @@ impl Document {
|
||||||
doc_loader,
|
doc_loader,
|
||||||
referrer,
|
referrer,
|
||||||
referrer_policy),
|
referrer_policy),
|
||||||
GlobalRef::Window(window),
|
window,
|
||||||
DocumentBinding::Wrap);
|
DocumentBinding::Wrap);
|
||||||
{
|
{
|
||||||
let node = document.upcast::<Node>();
|
let node = document.upcast::<Node>();
|
||||||
|
@ -2325,13 +2333,13 @@ impl DocumentMethods for Document {
|
||||||
"mouseevents" | "mouseevent" =>
|
"mouseevents" | "mouseevent" =>
|
||||||
Ok(Root::upcast(MouseEvent::new_uninitialized(&self.window))),
|
Ok(Root::upcast(MouseEvent::new_uninitialized(&self.window))),
|
||||||
"customevent" =>
|
"customevent" =>
|
||||||
Ok(Root::upcast(CustomEvent::new_uninitialized(GlobalRef::Window(&self.window)))),
|
Ok(Root::upcast(CustomEvent::new_uninitialized(self.window.upcast()))),
|
||||||
"htmlevents" | "events" | "event" | "svgevents" =>
|
"htmlevents" | "events" | "event" | "svgevents" =>
|
||||||
Ok(Event::new_uninitialized(GlobalRef::Window(&self.window))),
|
Ok(Event::new_uninitialized(&self.window.upcast())),
|
||||||
"keyboardevent" =>
|
"keyboardevent" =>
|
||||||
Ok(Root::upcast(KeyboardEvent::new_uninitialized(&self.window))),
|
Ok(Root::upcast(KeyboardEvent::new_uninitialized(&self.window))),
|
||||||
"messageevent" =>
|
"messageevent" =>
|
||||||
Ok(Root::upcast(MessageEvent::new_uninitialized(GlobalRef::Window(&self.window)))),
|
Ok(Root::upcast(MessageEvent::new_uninitialized(self.window.upcast()))),
|
||||||
"touchevent" =>
|
"touchevent" =>
|
||||||
Ok(Root::upcast(
|
Ok(Root::upcast(
|
||||||
TouchEvent::new_uninitialized(&self.window,
|
TouchEvent::new_uninitialized(&self.window,
|
||||||
|
@ -2341,25 +2349,25 @@ impl DocumentMethods for Document {
|
||||||
)
|
)
|
||||||
)),
|
)),
|
||||||
"webglcontextevent" =>
|
"webglcontextevent" =>
|
||||||
Ok(Root::upcast(WebGLContextEvent::new_uninitialized(GlobalRef::Window(&self.window)))),
|
Ok(Root::upcast(WebGLContextEvent::new_uninitialized(self.window.upcast()))),
|
||||||
"storageevent" => {
|
"storageevent" => {
|
||||||
let USVString(url) = self.URL();
|
let USVString(url) = self.URL();
|
||||||
Ok(Root::upcast(StorageEvent::new_uninitialized(&self.window, DOMString::from(url))))
|
Ok(Root::upcast(StorageEvent::new_uninitialized(&self.window, DOMString::from(url))))
|
||||||
},
|
},
|
||||||
"progressevent" =>
|
"progressevent" =>
|
||||||
Ok(Root::upcast(ProgressEvent::new_uninitialized(&self.window))),
|
Ok(Root::upcast(ProgressEvent::new_uninitialized(self.window.upcast()))),
|
||||||
"focusevent" =>
|
"focusevent" =>
|
||||||
Ok(Root::upcast(FocusEvent::new_uninitialized(GlobalRef::Window(&self.window)))),
|
Ok(Root::upcast(FocusEvent::new_uninitialized(self.window.upcast()))),
|
||||||
"errorevent" =>
|
"errorevent" =>
|
||||||
Ok(Root::upcast(ErrorEvent::new_uninitialized(GlobalRef::Window(&self.window)))),
|
Ok(Root::upcast(ErrorEvent::new_uninitialized(self.window.upcast()))),
|
||||||
"closeevent" =>
|
"closeevent" =>
|
||||||
Ok(Root::upcast(CloseEvent::new_uninitialized(GlobalRef::Window(&self.window)))),
|
Ok(Root::upcast(CloseEvent::new_uninitialized(self.window.upcast()))),
|
||||||
"popstateevent" =>
|
"popstateevent" =>
|
||||||
Ok(Root::upcast(PopStateEvent::new_uninitialized(GlobalRef::Window(&self.window)))),
|
Ok(Root::upcast(PopStateEvent::new_uninitialized(self.window.upcast()))),
|
||||||
"hashchangeevent" =>
|
"hashchangeevent" =>
|
||||||
Ok(Root::upcast(HashChangeEvent::new_uninitialized(GlobalRef::Window(&self.window)))),
|
Ok(Root::upcast(HashChangeEvent::new_uninitialized(&self.window.upcast()))),
|
||||||
"pagetransitionevent" =>
|
"pagetransitionevent" =>
|
||||||
Ok(Root::upcast(PageTransitionEvent::new_uninitialized(GlobalRef::Window(&self.window)))),
|
Ok(Root::upcast(PageTransitionEvent::new_uninitialized(self.window.upcast()))),
|
||||||
_ =>
|
_ =>
|
||||||
Err(Error::NotSupported),
|
Err(Error::NotSupported),
|
||||||
}
|
}
|
||||||
|
@ -2719,7 +2727,10 @@ impl DocumentMethods for Document {
|
||||||
|
|
||||||
let url = self.url();
|
let url = self.url();
|
||||||
let (tx, rx) = ipc::channel().unwrap();
|
let (tx, rx) = ipc::channel().unwrap();
|
||||||
let _ = self.window.resource_threads().send(GetCookiesForUrl((*url).clone(), tx, NonHTTP));
|
let _ = self.window
|
||||||
|
.upcast::<GlobalScope>()
|
||||||
|
.resource_threads()
|
||||||
|
.send(GetCookiesForUrl((*url).clone(), tx, NonHTTP));
|
||||||
let cookies = rx.recv().unwrap();
|
let cookies = rx.recv().unwrap();
|
||||||
Ok(cookies.map_or(DOMString::new(), DOMString::from))
|
Ok(cookies.map_or(DOMString::new(), DOMString::from))
|
||||||
}
|
}
|
||||||
|
@ -2736,6 +2747,7 @@ impl DocumentMethods for Document {
|
||||||
|
|
||||||
let url = self.url();
|
let url = self.url();
|
||||||
let _ = self.window
|
let _ = self.window
|
||||||
|
.upcast::<GlobalScope>()
|
||||||
.resource_threads()
|
.resource_threads()
|
||||||
.send(SetCookiesForUrl((*url).clone(), String::from(cookie), NonHTTP));
|
.send(SetCookiesForUrl((*url).clone(), String::from(cookie), NonHTTP));
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -2993,7 +3005,7 @@ impl DocumentProgressHandler {
|
||||||
fn dispatch_load(&self) {
|
fn dispatch_load(&self) {
|
||||||
let document = self.addr.root();
|
let document = self.addr.root();
|
||||||
let window = document.window();
|
let window = document.window();
|
||||||
let event = Event::new(GlobalRef::Window(window),
|
let event = Event::new(window.upcast(),
|
||||||
atom!("load"),
|
atom!("load"),
|
||||||
EventBubbles::DoesNotBubble,
|
EventBubbles::DoesNotBubble,
|
||||||
EventCancelable::NotCancelable);
|
EventCancelable::NotCancelable);
|
||||||
|
|
|
@ -7,12 +7,12 @@ use dom::bindings::codegen::Bindings::DocumentFragmentBinding::DocumentFragmentM
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::codegen::UnionTypes::NodeOrString;
|
use dom::bindings::codegen::UnionTypes::NodeOrString;
|
||||||
use dom::bindings::error::{ErrorResult, Fallible};
|
use dom::bindings::error::{ErrorResult, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::element::Element;
|
use dom::element::Element;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::htmlcollection::HTMLCollection;
|
use dom::htmlcollection::HTMLCollection;
|
||||||
use dom::node::{Node, window_from_node};
|
use dom::node::{Node, window_from_node};
|
||||||
use dom::nodelist::NodeList;
|
use dom::nodelist::NodeList;
|
||||||
|
@ -38,7 +38,7 @@ impl DocumentFragment {
|
||||||
DocumentFragmentBinding::Wrap)
|
DocumentFragmentBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef) -> Fallible<Root<DocumentFragment>> {
|
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<DocumentFragment>> {
|
||||||
let document = global.as_window().Document();
|
let document = global.as_window().Document();
|
||||||
|
|
||||||
Ok(DocumentFragment::new(document.r()))
|
Ok(DocumentFragment::new(document.r()))
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
use dom::bindings::codegen::Bindings::DOMExceptionBinding;
|
use dom::bindings::codegen::Bindings::DOMExceptionBinding;
|
||||||
use dom::bindings::codegen::Bindings::DOMExceptionBinding::DOMExceptionConstants;
|
use dom::bindings::codegen::Bindings::DOMExceptionBinding::DOMExceptionConstants;
|
||||||
use dom::bindings::codegen::Bindings::DOMExceptionBinding::DOMExceptionMethods;
|
use dom::bindings::codegen::Bindings::DOMExceptionBinding::DOMExceptionMethods;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
|
|
||||||
#[repr(u16)]
|
#[repr(u16)]
|
||||||
#[derive(JSTraceable, Copy, Clone, Debug, HeapSizeOf)]
|
#[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),
|
reflect_dom_object(box DOMException::new_inherited(code),
|
||||||
global,
|
global,
|
||||||
DOMExceptionBinding::Wrap)
|
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::DocumentBinding::DocumentMethods;
|
||||||
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{JS, Root};
|
use dom::bindings::js::{JS, Root};
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
|
@ -43,7 +42,7 @@ impl DOMImplementation {
|
||||||
pub fn new(document: &Document) -> Root<DOMImplementation> {
|
pub fn new(document: &Document) -> Root<DOMImplementation> {
|
||||||
let window = document.window();
|
let window = document.window();
|
||||||
reflect_dom_object(box DOMImplementation::new_inherited(document),
|
reflect_dom_object(box DOMImplementation::new_inherited(document),
|
||||||
GlobalRef::Window(window),
|
window,
|
||||||
DOMImplementationBinding::Wrap)
|
DOMImplementationBinding::Wrap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
use dom::bindings::codegen::Bindings::DOMMatrixBinding::{Wrap, DOMMatrixMethods, DOMMatrixInit};
|
use dom::bindings::codegen::Bindings::DOMMatrixBinding::{Wrap, DOMMatrixMethods, DOMMatrixInit};
|
||||||
use dom::bindings::codegen::Bindings::DOMMatrixReadOnlyBinding::DOMMatrixReadOnlyMethods;
|
use dom::bindings::codegen::Bindings::DOMMatrixReadOnlyBinding::DOMMatrixReadOnlyMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::dommatrixreadonly::{dommatrixinit_to_matrix, DOMMatrixReadOnly, entries_to_matrix};
|
use dom::dommatrixreadonly::{dommatrixinit_to_matrix, DOMMatrixReadOnly, entries_to_matrix};
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use euclid::Matrix4D;
|
use euclid::Matrix4D;
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ pub struct DOMMatrix {
|
||||||
|
|
||||||
impl DOMMatrix {
|
impl DOMMatrix {
|
||||||
#[allow(unrooted_must_root)]
|
#[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);
|
let dommatrix = Self::new_inherited(is2D, matrix);
|
||||||
reflect_dom_object(box dommatrix, global, Wrap)
|
reflect_dom_object(box dommatrix, global, Wrap)
|
||||||
}
|
}
|
||||||
|
@ -32,12 +32,12 @@ impl DOMMatrix {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-dommatrix
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-dommatrix
|
||||||
pub fn Constructor(global: GlobalRef) -> Fallible<Root<Self>> {
|
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<Self>> {
|
||||||
Self::Constructor_(global, vec![1.0, 0.0, 0.0, 1.0, 0.0, 0.0])
|
Self::Constructor_(global, vec![1.0, 0.0, 0.0, 1.0, 0.0, 0.0])
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-dommatrix-numbersequence
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-dommatrix-numbersequence
|
||||||
pub fn Constructor_(global: GlobalRef, entries: Vec<f64>) -> Fallible<Root<Self>> {
|
pub fn Constructor_(global: &GlobalScope, entries: Vec<f64>) -> Fallible<Root<Self>> {
|
||||||
entries_to_matrix(&entries[..])
|
entries_to_matrix(&entries[..])
|
||||||
.map(|(is2D, matrix)| {
|
.map(|(is2D, matrix)| {
|
||||||
Self::new(global, is2D, matrix)
|
Self::new(global, is2D, matrix)
|
||||||
|
@ -45,14 +45,14 @@ impl DOMMatrix {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-frommatrix
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-frommatrix
|
||||||
pub fn FromMatrix(global: GlobalRef, other: &DOMMatrixInit) -> Fallible<Root<Self>> {
|
pub fn FromMatrix(global: &GlobalScope, other: &DOMMatrixInit) -> Fallible<Root<Self>> {
|
||||||
dommatrixinit_to_matrix(&other)
|
dommatrixinit_to_matrix(&other)
|
||||||
.map(|(is2D, matrix)| {
|
.map(|(is2D, matrix)| {
|
||||||
Self::new(global, is2D, matrix)
|
Self::new(global, 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())
|
Self::new(global, ro.is_2d(), ro.matrix().clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,11 @@ use dom::bindings::codegen::Bindings::DOMMatrixReadOnlyBinding::{DOMMatrixReadOn
|
||||||
use dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit;
|
use dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit;
|
||||||
use dom::bindings::error;
|
use dom::bindings::error;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::{reflect_dom_object, Reflectable, Reflector};
|
use dom::bindings::reflector::{reflect_dom_object, Reflectable, Reflector};
|
||||||
use dom::dommatrix::DOMMatrix;
|
use dom::dommatrix::DOMMatrix;
|
||||||
use dom::dompoint::DOMPoint;
|
use dom::dompoint::DOMPoint;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use euclid::{Matrix4D, Point4D, Radians};
|
use euclid::{Matrix4D, Point4D, Radians};
|
||||||
use std::cell::{Cell, Ref};
|
use std::cell::{Cell, Ref};
|
||||||
use std::f64;
|
use std::f64;
|
||||||
|
@ -26,7 +26,7 @@ pub struct DOMMatrixReadOnly {
|
||||||
|
|
||||||
impl DOMMatrixReadOnly {
|
impl DOMMatrixReadOnly {
|
||||||
#[allow(unrooted_must_root)]
|
#[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);
|
let dommatrix = Self::new_inherited(is2D, matrix);
|
||||||
reflect_dom_object(box dommatrix, global, Wrap)
|
reflect_dom_object(box dommatrix, global, Wrap)
|
||||||
}
|
}
|
||||||
|
@ -40,12 +40,12 @@ impl DOMMatrixReadOnly {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly
|
||||||
pub fn Constructor(global: GlobalRef) -> Fallible<Root<Self>> {
|
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<Self>> {
|
||||||
Ok(Self::new(global, true, Matrix4D::identity()))
|
Ok(Self::new(global, true, Matrix4D::identity()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly-numbersequence
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly-numbersequence
|
||||||
pub fn Constructor_(global: GlobalRef, entries: Vec<f64>) -> Fallible<Root<Self>> {
|
pub fn Constructor_(global: &GlobalScope, entries: Vec<f64>) -> Fallible<Root<Self>> {
|
||||||
entries_to_matrix(&entries[..])
|
entries_to_matrix(&entries[..])
|
||||||
.map(|(is2D, matrix)| {
|
.map(|(is2D, matrix)| {
|
||||||
Self::new(global, is2D, matrix)
|
Self::new(global, is2D, matrix)
|
||||||
|
@ -53,7 +53,7 @@ impl DOMMatrixReadOnly {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-frommatrix
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-frommatrix
|
||||||
pub fn FromMatrix(global: GlobalRef, other: &DOMMatrixInit) -> Fallible<Root<Self>> {
|
pub fn FromMatrix(global: &GlobalScope, other: &DOMMatrixInit) -> Fallible<Root<Self>> {
|
||||||
dommatrixinit_to_matrix(&other)
|
dommatrixinit_to_matrix(&other)
|
||||||
.map(|(is2D, matrix)| {
|
.map(|(is2D, matrix)| {
|
||||||
Self::new(global, is2D, matrix)
|
Self::new(global, is2D, matrix)
|
||||||
|
@ -463,48 +463,50 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-translate
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-translate
|
||||||
fn Translate(&self, tx: f64, ty: f64, tz: f64) -> Root<DOMMatrix> {
|
fn Translate(&self, tx: f64, ty: f64, tz: f64) -> Root<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(self.global().r(), self).TranslateSelf(tx, ty, tz)
|
DOMMatrix::from_readonly(&self.global(), self).TranslateSelf(tx, ty, tz)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-scale
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-scale
|
||||||
fn Scale(&self, scaleX: f64, scaleY: Option<f64>, scaleZ: f64,
|
fn Scale(&self, scaleX: f64, scaleY: Option<f64>, scaleZ: f64,
|
||||||
originX: f64, originY: f64, originZ: f64) -> Root<DOMMatrix> {
|
originX: f64, originY: f64, originZ: f64) -> Root<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(self.global().r(), self).ScaleSelf(scaleX, scaleY, scaleZ, originX, originY, originZ)
|
DOMMatrix::from_readonly(&self.global(), self)
|
||||||
|
.ScaleSelf(scaleX, scaleY, scaleZ, originX, originY, originZ)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-scale3d
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-scale3d
|
||||||
fn Scale3d(&self, scale: f64, originX: f64, originY: f64, originZ: f64) -> Root<DOMMatrix> {
|
fn Scale3d(&self, scale: f64, originX: f64, originY: f64, originZ: f64) -> Root<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(self.global().r(), self).Scale3dSelf(scale, originX, originY, originZ)
|
DOMMatrix::from_readonly(&self.global(), self)
|
||||||
|
.Scale3dSelf(scale, originX, originY, originZ)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotate
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotate
|
||||||
fn Rotate(&self, rotX: f64, rotY: Option<f64>, rotZ: Option<f64>) -> Root<DOMMatrix> {
|
fn Rotate(&self, rotX: f64, rotY: Option<f64>, rotZ: Option<f64>) -> Root<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(self.global().r(), self).RotateSelf(rotX, rotY, rotZ)
|
DOMMatrix::from_readonly(&self.global(), self).RotateSelf(rotX, rotY, rotZ)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotatefromvector
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotatefromvector
|
||||||
fn RotateFromVector(&self, x: f64, y: f64) -> Root<DOMMatrix> {
|
fn RotateFromVector(&self, x: f64, y: f64) -> Root<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(self.global().r(), self).RotateFromVectorSelf(x, y)
|
DOMMatrix::from_readonly(&self.global(), self).RotateFromVectorSelf(x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotateaxisangle
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotateaxisangle
|
||||||
fn RotateAxisAngle(&self, x: f64, y: f64, z: f64, angle: f64) -> Root<DOMMatrix> {
|
fn RotateAxisAngle(&self, x: f64, y: f64, z: f64, angle: f64) -> Root<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(self.global().r(), self).RotateAxisAngleSelf(x, y, z, angle)
|
DOMMatrix::from_readonly(&self.global(), self).RotateAxisAngleSelf(x, y, z, angle)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-skewx
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-skewx
|
||||||
fn SkewX(&self, sx: f64) -> Root<DOMMatrix> {
|
fn SkewX(&self, sx: f64) -> Root<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(self.global().r(), self).SkewXSelf(sx)
|
DOMMatrix::from_readonly(&self.global(), self).SkewXSelf(sx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-skewy
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-skewy
|
||||||
fn SkewY(&self, sy: f64) -> Root<DOMMatrix> {
|
fn SkewY(&self, sy: f64) -> Root<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(self.global().r(), self).SkewYSelf(sy)
|
DOMMatrix::from_readonly(&self.global(), self).SkewYSelf(sy)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-multiply
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-multiply
|
||||||
fn Multiply(&self, other: &DOMMatrixInit) -> Fallible<Root<DOMMatrix>> {
|
fn Multiply(&self, other: &DOMMatrixInit) -> Fallible<Root<DOMMatrix>> {
|
||||||
DOMMatrix::from_readonly(self.global().r(), self).MultiplySelf(&other)
|
DOMMatrix::from_readonly(&self.global(), self).MultiplySelf(&other)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipx
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipx
|
||||||
|
@ -515,7 +517,7 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
|
||||||
0.0, 0.0, 1.0, 0.0,
|
0.0, 0.0, 1.0, 0.0,
|
||||||
0.0, 0.0, 0.0, 1.0);
|
0.0, 0.0, 0.0, 1.0);
|
||||||
let matrix = flip.post_mul(&self.matrix.borrow());
|
let matrix = flip.post_mul(&self.matrix.borrow());
|
||||||
DOMMatrix::new(self.global().r(), is2D, matrix)
|
DOMMatrix::new(&self.global(), is2D, matrix)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipy
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipy
|
||||||
|
@ -526,19 +528,24 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
|
||||||
0.0, 0.0, 1.0, 0.0,
|
0.0, 0.0, 1.0, 0.0,
|
||||||
0.0, 0.0, 0.0, 1.0);
|
0.0, 0.0, 0.0, 1.0);
|
||||||
let matrix = flip.post_mul(&self.matrix.borrow());
|
let matrix = flip.post_mul(&self.matrix.borrow());
|
||||||
DOMMatrix::new(self.global().r(), is2D, matrix)
|
DOMMatrix::new(&self.global(), is2D, matrix)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-inverse
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-inverse
|
||||||
fn Inverse(&self) -> Root<DOMMatrix> {
|
fn Inverse(&self) -> Root<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(self.global().r(), self).InvertSelf()
|
DOMMatrix::from_readonly(&self.global(), self).InvertSelf()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-transformpoint
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-transformpoint
|
||||||
fn TransformPoint(&self, point: &DOMPointInit) -> Root<DOMPoint> {
|
fn TransformPoint(&self, point: &DOMPointInit) -> Root<DOMPoint> {
|
||||||
let matrix = self.matrix.borrow();
|
let matrix = self.matrix.borrow();
|
||||||
let result = matrix.transform_point4d(&Point4D::new(point.x, point.y, point.z, point.w));
|
let result = matrix.transform_point4d(&Point4D::new(point.x, point.y, point.z, point.w));
|
||||||
DOMPoint::new(self.global().r(), result.x as f64, result.y as f64, result.z as f64, result.w as f64)
|
DOMPoint::new(
|
||||||
|
&self.global(),
|
||||||
|
result.x as f64,
|
||||||
|
result.y as f64,
|
||||||
|
result.z as f64,
|
||||||
|
result.w as f64)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,12 +12,12 @@ use dom::bindings::codegen::Bindings::DOMParserBinding::SupportedType::Text_xml;
|
||||||
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentReadyState;
|
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentReadyState;
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::{JS, Root};
|
use dom::bindings::js::{JS, Root};
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::document::{Document, IsHTMLDocument};
|
use dom::document::{Document, IsHTMLDocument};
|
||||||
use dom::document::DocumentSource;
|
use dom::document::DocumentSource;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use parse::html::{ParseContext, parse_html};
|
use parse::html::{ParseContext, parse_html};
|
||||||
use parse::xml::{self, parse_xml};
|
use parse::xml::{self, parse_xml};
|
||||||
|
@ -38,11 +38,11 @@ impl DOMParser {
|
||||||
|
|
||||||
pub fn new(window: &Window) -> Root<DOMParser> {
|
pub fn new(window: &Window) -> Root<DOMParser> {
|
||||||
reflect_dom_object(box DOMParser::new_inherited(window),
|
reflect_dom_object(box DOMParser::new_inherited(window),
|
||||||
GlobalRef::Window(window),
|
window,
|
||||||
DOMParserBinding::Wrap)
|
DOMParserBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef) -> Fallible<Root<DOMParser>> {
|
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<DOMParser>> {
|
||||||
Ok(DOMParser::new(global.as_window()))
|
Ok(DOMParser::new(global.as_window()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
use dom::bindings::codegen::Bindings::DOMPointBinding::{DOMPointInit, DOMPointMethods, Wrap};
|
use dom::bindings::codegen::Bindings::DOMPointBinding::{DOMPointInit, DOMPointMethods, Wrap};
|
||||||
use dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::DOMPointReadOnlyMethods;
|
use dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::DOMPointReadOnlyMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::dompointreadonly::{DOMPointReadOnly, DOMPointWriteMethods};
|
use dom::dompointreadonly::{DOMPointReadOnly, DOMPointWriteMethods};
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
|
|
||||||
// http://dev.w3.org/fxtf/geometry/Overview.html#dompoint
|
// http://dev.w3.org/fxtf/geometry/Overview.html#dompoint
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -23,11 +23,11 @@ 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)
|
reflect_dom_object(box DOMPoint::new_inherited(x, y, z, w), global, Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
x: f64,
|
x: f64,
|
||||||
y: f64,
|
y: f64,
|
||||||
z: f64,
|
z: f64,
|
||||||
|
@ -36,7 +36,7 @@ impl DOMPoint {
|
||||||
Ok(DOMPoint::new(global, x, y, z, w))
|
Ok(DOMPoint::new(global, 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)
|
DOMPoint::new(global, p.x, p.y, p.z, p.w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::{DOMPointReadOnlyMethods, Wrap};
|
use dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::{DOMPointReadOnlyMethods, Wrap};
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
|
||||||
// http://dev.w3.org/fxtf/geometry/Overview.html#dompointreadonly
|
// http://dev.w3.org/fxtf/geometry/Overview.html#dompointreadonly
|
||||||
|
@ -30,13 +30,13 @@ 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),
|
reflect_dom_object(box DOMPointReadOnly::new_inherited(x, y, z, w),
|
||||||
global,
|
global,
|
||||||
Wrap)
|
Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
x: f64,
|
x: f64,
|
||||||
y: f64,
|
y: f64,
|
||||||
z: f64,
|
z: f64,
|
||||||
|
|
|
@ -6,11 +6,11 @@ use dom::bindings::codegen::Bindings::DOMPointBinding::{DOMPointInit, DOMPointMe
|
||||||
use dom::bindings::codegen::Bindings::DOMQuadBinding::{DOMQuadInit, DOMQuadMethods, Wrap};
|
use dom::bindings::codegen::Bindings::DOMQuadBinding::{DOMQuadInit, DOMQuadMethods, Wrap};
|
||||||
use dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::DOMRectInit;
|
use dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::DOMRectInit;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::{Root, JS};
|
use dom::bindings::js::{Root, JS};
|
||||||
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||||
use dom::dompoint::DOMPoint;
|
use dom::dompoint::DOMPoint;
|
||||||
use dom::domrect::DOMRect;
|
use dom::domrect::DOMRect;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry/#DOMQuad
|
// https://drafts.fxtf.org/geometry/#DOMQuad
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -37,7 +37,7 @@ impl DOMQuad {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: GlobalRef,
|
pub fn new(global: &GlobalScope,
|
||||||
p1: &DOMPoint,
|
p1: &DOMPoint,
|
||||||
p2: &DOMPoint,
|
p2: &DOMPoint,
|
||||||
p3: &DOMPoint,
|
p3: &DOMPoint,
|
||||||
|
@ -47,7 +47,7 @@ impl DOMQuad {
|
||||||
Wrap)
|
Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
p1: &DOMPointInit,
|
p1: &DOMPointInit,
|
||||||
p2: &DOMPointInit,
|
p2: &DOMPointInit,
|
||||||
p3: &DOMPointInit,
|
p3: &DOMPointInit,
|
||||||
|
@ -61,7 +61,7 @@ impl DOMQuad {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry/#dom-domquad-fromrect
|
// https://drafts.fxtf.org/geometry/#dom-domquad-fromrect
|
||||||
pub fn FromRect(global: GlobalRef, other: &DOMRectInit) -> Root<DOMQuad> {
|
pub fn FromRect(global: &GlobalScope, other: &DOMRectInit) -> Root<DOMQuad> {
|
||||||
DOMQuad::new(global,
|
DOMQuad::new(global,
|
||||||
&*DOMPoint::new(global, other.x, other.y, 0f64, 1f64),
|
&*DOMPoint::new(global, other.x, other.y, 0f64, 1f64),
|
||||||
&*DOMPoint::new(global, other.x + other.width, other.y, 0f64, 1f64),
|
&*DOMPoint::new(global, other.x + other.width, other.y, 0f64, 1f64),
|
||||||
|
@ -70,7 +70,7 @@ impl DOMQuad {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry/#dom-domquad-fromquad
|
// https://drafts.fxtf.org/geometry/#dom-domquad-fromquad
|
||||||
pub fn FromQuad(global: GlobalRef, other: &DOMQuadInit) -> Root<DOMQuad> {
|
pub fn FromQuad(global: &GlobalScope, other: &DOMQuadInit) -> Root<DOMQuad> {
|
||||||
DOMQuad::new(global,
|
DOMQuad::new(global,
|
||||||
&DOMPoint::new_from_init(global, &other.p1),
|
&DOMPoint::new_from_init(global, &other.p1),
|
||||||
&DOMPoint::new_from_init(global, &other.p2),
|
&DOMPoint::new_from_init(global, &other.p2),
|
||||||
|
@ -107,7 +107,7 @@ impl DOMQuadMethods for DOMQuad {
|
||||||
let right = self.p1.X().max(self.p2.X()).max(self.p3.X()).max(self.p4.X());
|
let right = self.p1.X().max(self.p2.X()).max(self.p3.X()).max(self.p4.X());
|
||||||
let bottom = self.p1.Y().max(self.p2.Y()).max(self.p3.Y()).max(self.p4.Y());
|
let bottom = self.p1.Y().max(self.p2.Y()).max(self.p3.Y()).max(self.p4.Y());
|
||||||
|
|
||||||
DOMRect::new(self.global().r(),
|
DOMRect::new(&self.global(),
|
||||||
left,
|
left,
|
||||||
top,
|
top,
|
||||||
right - left,
|
right - left,
|
||||||
|
|
|
@ -6,10 +6,10 @@ use dom::bindings::codegen::Bindings::DOMRectBinding;
|
||||||
use dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods;
|
use dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods;
|
||||||
use dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::DOMRectReadOnlyMethods;
|
use dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::DOMRectReadOnlyMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::domrectreadonly::DOMRectReadOnly;
|
use dom::domrectreadonly::DOMRectReadOnly;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct DOMRect {
|
pub struct DOMRect {
|
||||||
|
@ -23,13 +23,13 @@ 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),
|
reflect_dom_object(box DOMRect::new_inherited(x, y, width, height),
|
||||||
global,
|
global,
|
||||||
DOMRectBinding::Wrap)
|
DOMRectBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
x: f64,
|
x: f64,
|
||||||
y: f64,
|
y: f64,
|
||||||
width: f64,
|
width: f64,
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::DOMRectListBinding;
|
use dom::bindings::codegen::Bindings::DOMRectListBinding;
|
||||||
use dom::bindings::codegen::Bindings::DOMRectListBinding::DOMRectListMethods;
|
use dom::bindings::codegen::Bindings::DOMRectListBinding::DOMRectListMethods;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::{JS, Root};
|
use dom::bindings::js::{JS, Root};
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::domrect::DOMRect;
|
use dom::domrect::DOMRect;
|
||||||
|
@ -30,7 +29,7 @@ impl DOMRectList {
|
||||||
where T: Iterator<Item = Root<DOMRect>>
|
where T: Iterator<Item = Root<DOMRect>>
|
||||||
{
|
{
|
||||||
reflect_dom_object(box DOMRectList::new_inherited(rects),
|
reflect_dom_object(box DOMRectList::new_inherited(rects),
|
||||||
GlobalRef::Window(window),
|
window,
|
||||||
DOMRectListBinding::Wrap)
|
DOMRectListBinding::Wrap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::{DOMRectReadOnlyMethods, Wrap};
|
use dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::{DOMRectReadOnlyMethods, Wrap};
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -29,7 +29,7 @@ impl DOMRectReadOnly {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: GlobalRef,
|
pub fn new(global: &GlobalScope,
|
||||||
x: f64,
|
x: f64,
|
||||||
y: f64,
|
y: f64,
|
||||||
width: f64,
|
width: f64,
|
||||||
|
@ -40,7 +40,7 @@ impl DOMRectReadOnly {
|
||||||
Wrap)
|
Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
x: f64,
|
x: f64,
|
||||||
y: f64,
|
y: f64,
|
||||||
width: f64,
|
width: f64,
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
use dom::bindings::codegen::Bindings::DOMStringMapBinding;
|
use dom::bindings::codegen::Bindings::DOMStringMapBinding;
|
||||||
use dom::bindings::codegen::Bindings::DOMStringMapBinding::DOMStringMapMethods;
|
use dom::bindings::codegen::Bindings::DOMStringMapBinding::DOMStringMapMethods;
|
||||||
use dom::bindings::error::ErrorResult;
|
use dom::bindings::error::ErrorResult;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::{JS, Root};
|
use dom::bindings::js::{JS, Root};
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
|
@ -29,7 +28,7 @@ impl DOMStringMap {
|
||||||
pub fn new(element: &HTMLElement) -> Root<DOMStringMap> {
|
pub fn new(element: &HTMLElement) -> Root<DOMStringMap> {
|
||||||
let window = window_from_node(element);
|
let window = window_from_node(element);
|
||||||
reflect_dom_object(box DOMStringMap::new_inherited(element),
|
reflect_dom_object(box DOMStringMap::new_inherited(element),
|
||||||
GlobalRef::Window(window.r()),
|
window.r(),
|
||||||
DOMStringMapBinding::Wrap)
|
DOMStringMapBinding::Wrap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ use dom::attr::Attr;
|
||||||
use dom::bindings::codegen::Bindings::DOMTokenListBinding;
|
use dom::bindings::codegen::Bindings::DOMTokenListBinding;
|
||||||
use dom::bindings::codegen::Bindings::DOMTokenListBinding::DOMTokenListMethods;
|
use dom::bindings::codegen::Bindings::DOMTokenListBinding::DOMTokenListMethods;
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::{JS, Root};
|
use dom::bindings::js::{JS, Root};
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
|
@ -34,7 +33,7 @@ impl DOMTokenList {
|
||||||
pub fn new(element: &Element, local_name: &Atom) -> Root<DOMTokenList> {
|
pub fn new(element: &Element, local_name: &Atom) -> Root<DOMTokenList> {
|
||||||
let window = window_from_node(element);
|
let window = window_from_node(element);
|
||||||
reflect_dom_object(box DOMTokenList::new_inherited(element, local_name.clone()),
|
reflect_dom_object(box DOMTokenList::new_inherited(element, local_name.clone()),
|
||||||
GlobalRef::Window(window.r()),
|
window.r(),
|
||||||
DOMTokenListBinding::Wrap)
|
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::Bindings::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::codegen::UnionTypes::NodeOrString;
|
use dom::bindings::codegen::UnionTypes::NodeOrString;
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
|
use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
|
||||||
use dom::bindings::js::{JS, LayoutJS, MutNullableHeap};
|
use dom::bindings::js::{JS, LayoutJS, MutNullableHeap};
|
||||||
use dom::bindings::js::{Root, RootedReference};
|
use dom::bindings::js::{Root, RootedReference};
|
||||||
|
@ -1589,7 +1588,7 @@ impl ElementMethods for Element {
|
||||||
let win = window_from_node(self);
|
let win = window_from_node(self);
|
||||||
let raw_rects = self.upcast::<Node>().content_boxes();
|
let raw_rects = self.upcast::<Node>().content_boxes();
|
||||||
let rects = raw_rects.iter().map(|rect| {
|
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.x.to_f64_px(),
|
||||||
rect.origin.y.to_f64_px(),
|
rect.origin.y.to_f64_px(),
|
||||||
rect.size.width.to_f64_px(),
|
rect.size.width.to_f64_px(),
|
||||||
|
@ -1602,7 +1601,7 @@ impl ElementMethods for Element {
|
||||||
fn GetBoundingClientRect(&self) -> Root<DOMRect> {
|
fn GetBoundingClientRect(&self) -> Root<DOMRect> {
|
||||||
let win = window_from_node(self);
|
let win = window_from_node(self);
|
||||||
let rect = self.upcast::<Node>().bounding_content_box();
|
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.x.to_f64_px(),
|
||||||
rect.origin.y.to_f64_px(),
|
rect.origin.y.to_f64_px(),
|
||||||
rect.size.width.to_f64_px(),
|
rect.size.width.to_f64_px(),
|
||||||
|
|
|
@ -7,12 +7,12 @@ use dom::bindings::codegen::Bindings::ErrorEventBinding;
|
||||||
use dom::bindings::codegen::Bindings::ErrorEventBinding::ErrorEventMethods;
|
use dom::bindings::codegen::Bindings::ErrorEventBinding::ErrorEventMethods;
|
||||||
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{MutHeapJSVal, Root};
|
use dom::bindings::js::{MutHeapJSVal, Root};
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use js::jsapi::{HandleValue, JSContext};
|
use js::jsapi::{HandleValue, JSContext};
|
||||||
use js::jsval::JSVal;
|
use js::jsval::JSVal;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
@ -41,13 +41,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(),
|
reflect_dom_object(box ErrorEvent::new_inherited(),
|
||||||
global,
|
global,
|
||||||
ErrorEventBinding::Wrap)
|
ErrorEventBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: GlobalRef,
|
pub fn new(global: &GlobalScope,
|
||||||
type_: Atom,
|
type_: Atom,
|
||||||
bubbles: EventBubbles,
|
bubbles: EventBubbles,
|
||||||
cancelable: EventCancelable,
|
cancelable: EventCancelable,
|
||||||
|
@ -70,7 +70,7 @@ impl ErrorEvent {
|
||||||
ev
|
ev
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &ErrorEventBinding::ErrorEventInit) -> Fallible<Root<ErrorEvent>>{
|
init: &ErrorEventBinding::ErrorEventInit) -> Fallible<Root<ErrorEvent>>{
|
||||||
let msg = match init.message.as_ref() {
|
let msg = match init.message.as_ref() {
|
||||||
|
@ -94,10 +94,15 @@ impl ErrorEvent {
|
||||||
// Dictionaries need to be rooted
|
// Dictionaries need to be rooted
|
||||||
// https://github.com/servo/servo/issues/6381
|
// https://github.com/servo/servo/issues/6381
|
||||||
rooted!(in(global.get_cx()) let error = init.error);
|
rooted!(in(global.get_cx()) let error = init.error);
|
||||||
let event = ErrorEvent::new(global, Atom::from(type_),
|
let event = ErrorEvent::new(
|
||||||
bubbles, cancelable,
|
global,
|
||||||
msg, file_name,
|
Atom::from(type_),
|
||||||
line_num, col_num,
|
bubbles,
|
||||||
|
cancelable,
|
||||||
|
msg,
|
||||||
|
file_name,
|
||||||
|
line_num,
|
||||||
|
col_num,
|
||||||
error.handle());
|
error.handle());
|
||||||
Ok(event)
|
Ok(event)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,13 @@ use dom::bindings::cell::DOMRefCell;
|
||||||
use dom::bindings::codegen::Bindings::EventBinding;
|
use dom::bindings::codegen::Bindings::EventBinding;
|
||||||
use dom::bindings::codegen::Bindings::EventBinding::{EventConstants, EventMethods};
|
use dom::bindings::codegen::Bindings::EventBinding::{EventConstants, EventMethods};
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
||||||
use dom::bindings::refcounted::Trusted;
|
use dom::bindings::refcounted::Trusted;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::eventdispatcher::EventStatus;
|
use dom::eventdispatcher::EventStatus;
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use script_thread::Runnable;
|
use script_thread::Runnable;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
|
@ -115,13 +115,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(),
|
reflect_dom_object(box Event::new_inherited(),
|
||||||
global,
|
global,
|
||||||
EventBinding::Wrap)
|
EventBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: GlobalRef,
|
pub fn new(global: &GlobalScope,
|
||||||
type_: Atom,
|
type_: Atom,
|
||||||
bubbles: EventBubbles,
|
bubbles: EventBubbles,
|
||||||
cancelable: EventCancelable) -> Root<Event> {
|
cancelable: EventCancelable) -> Root<Event> {
|
||||||
|
@ -130,7 +130,7 @@ impl Event {
|
||||||
event
|
event
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &EventBinding::EventInit) -> Fallible<Root<Event>> {
|
init: &EventBinding::EventInit) -> Fallible<Root<Event>> {
|
||||||
let bubbles = EventBubbles::from(init.bubbles);
|
let bubbles = EventBubbles::from(init.bubbles);
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
use devtools_traits::{StartedTimelineMarker, TimelineMarker, TimelineMarkerType};
|
use devtools_traits::{StartedTimelineMarker, TimelineMarker, TimelineMarkerType};
|
||||||
use dom::bindings::callback::ExceptionHandling::Report;
|
use dom::bindings::callback::ExceptionHandling::Report;
|
||||||
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||||
use dom::bindings::global::GlobalRoot;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{JS, Root, RootedReference};
|
use dom::bindings::js::{JS, Root, RootedReference};
|
||||||
use dom::bindings::reflector::Reflectable;
|
use dom::bindings::reflector::Reflectable;
|
||||||
|
@ -52,8 +51,8 @@ fn dispatch_to_listeners(event: &Event, target: &EventTarget, event_path: &[&Eve
|
||||||
assert!(!event.stop_propagation());
|
assert!(!event.stop_propagation());
|
||||||
assert!(!event.stop_immediate());
|
assert!(!event.stop_immediate());
|
||||||
|
|
||||||
let window = match target.global() {
|
let window = match Root::downcast::<Window>(target.global()) {
|
||||||
GlobalRoot::Window(window) => {
|
Some(window) => {
|
||||||
if window.need_emit_timeline_marker(TimelineMarkerType::DOMEvent) {
|
if window.need_emit_timeline_marker(TimelineMarkerType::DOMEvent) {
|
||||||
Some(window)
|
Some(window)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -6,11 +6,11 @@ use dom::bindings::cell::DOMRefCell;
|
||||||
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
||||||
use dom::bindings::codegen::Bindings::EventSourceBinding::{EventSourceInit, EventSourceMethods, Wrap};
|
use dom::bindings::codegen::Bindings::EventSourceBinding::{EventSourceInit, EventSourceMethods, Wrap};
|
||||||
use dom::bindings::error::{Error, Fallible};
|
use dom::bindings::error::{Error, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
@ -42,11 +42,13 @@ impl EventSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new(global: GlobalRef, url: Url, with_credentials: bool) -> Root<EventSource> {
|
fn new(global: &GlobalScope, url: Url, with_credentials: bool) -> Root<EventSource> {
|
||||||
reflect_dom_object(box EventSource::new_inherited(url, with_credentials), global, Wrap)
|
reflect_dom_object(box EventSource::new_inherited(url, with_credentials),
|
||||||
|
global,
|
||||||
|
Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
url_str: DOMString,
|
url_str: DOMString,
|
||||||
event_source_init: &EventSourceInit) -> Fallible<Root<EventSource>> {
|
event_source_init: &EventSourceInit) -> Fallible<Root<EventSource>> {
|
||||||
// Steps 1-2
|
// Steps 1-2
|
||||||
|
|
|
@ -154,8 +154,7 @@ impl CompiledEventListener {
|
||||||
match *handler {
|
match *handler {
|
||||||
CommonEventHandler::ErrorEventHandler(ref handler) => {
|
CommonEventHandler::ErrorEventHandler(ref handler) => {
|
||||||
if let Some(event) = event.downcast::<ErrorEvent>() {
|
if let Some(event) = event.downcast::<ErrorEvent>() {
|
||||||
let global = object.global();
|
let cx = object.global().get_cx();
|
||||||
let cx = global.r().get_cx();
|
|
||||||
rooted!(in(cx) let error = event.Error(cx));
|
rooted!(in(cx) let error = event.Error(cx));
|
||||||
let return_value = handler.Call_(object,
|
let return_value = handler.Call_(object,
|
||||||
EventOrString::String(event.Message()),
|
EventOrString::String(event.Message()),
|
||||||
|
@ -201,8 +200,7 @@ impl CompiledEventListener {
|
||||||
|
|
||||||
CommonEventHandler::EventHandler(ref handler) => {
|
CommonEventHandler::EventHandler(ref handler) => {
|
||||||
if let Ok(value) = handler.Call_(object, event, exception_handle) {
|
if let Ok(value) = handler.Call_(object, event, exception_handle) {
|
||||||
let global = object.global();
|
let cx = object.global().get_cx();
|
||||||
let cx = global.r().get_cx();
|
|
||||||
rooted!(in(cx) let value = value);
|
rooted!(in(cx) let value = value);
|
||||||
let value = value.handle();
|
let value = value.handle();
|
||||||
|
|
||||||
|
@ -500,8 +498,7 @@ impl EventTarget {
|
||||||
bubbles: EventBubbles,
|
bubbles: EventBubbles,
|
||||||
cancelable: EventCancelable)
|
cancelable: EventCancelable)
|
||||||
-> Root<Event> {
|
-> Root<Event> {
|
||||||
let global = self.global();
|
let event = Event::new(&self.global(), Atom::from(name), bubbles, cancelable);
|
||||||
let event = Event::new(global.r(), Atom::from(name), bubbles, cancelable);
|
|
||||||
|
|
||||||
event.fire(self);
|
event.fire(self);
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||||
use dom::bindings::codegen::Bindings::ExtendableEventBinding;
|
use dom::bindings::codegen::Bindings::ExtendableEventBinding;
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::event::Event;
|
use dom::event::Event;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use js::jsapi::{HandleValue, JSContext};
|
use js::jsapi::{HandleValue, JSContext};
|
||||||
use string_cache::Atom;
|
use string_cache::Atom;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ impl ExtendableEvent {
|
||||||
extensions_allowed: true
|
extensions_allowed: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn new(global: GlobalRef,
|
pub fn new(global: &GlobalScope,
|
||||||
type_: Atom,
|
type_: Atom,
|
||||||
bubbles: bool,
|
bubbles: bool,
|
||||||
cancelable: bool)
|
cancelable: bool)
|
||||||
|
@ -41,7 +41,7 @@ impl ExtendableEvent {
|
||||||
ev
|
ev
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &ExtendableEventBinding::ExtendableEventInit) -> Fallible<Root<ExtendableEvent>> {
|
init: &ExtendableEventBinding::ExtendableEventInit) -> Fallible<Root<ExtendableEvent>> {
|
||||||
Ok(ExtendableEvent::new(global,
|
Ok(ExtendableEvent::new(global,
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
use dom::bindings::codegen::Bindings::ExtendableMessageEventBinding;
|
use dom::bindings::codegen::Bindings::ExtendableMessageEventBinding;
|
||||||
use dom::bindings::codegen::Bindings::ExtendableMessageEventBinding::ExtendableMessageEventMethods;
|
use dom::bindings::codegen::Bindings::ExtendableMessageEventBinding::ExtendableMessageEventMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
|
@ -13,6 +12,7 @@ use dom::bindings::str::DOMString;
|
||||||
use dom::event::Event;
|
use dom::event::Event;
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
use dom::extendableevent::ExtendableEvent;
|
use dom::extendableevent::ExtendableEvent;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use js::jsapi::{HandleValue, Heap, JSContext};
|
use js::jsapi::{HandleValue, Heap, JSContext};
|
||||||
use js::jsval::JSVal;
|
use js::jsval::JSVal;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
|
@ -27,7 +27,7 @@ pub struct ExtendableMessageEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExtendableMessageEvent {
|
impl ExtendableMessageEvent {
|
||||||
pub fn new(global: GlobalRef, type_: Atom,
|
pub fn new(global: &GlobalScope, type_: Atom,
|
||||||
bubbles: bool, cancelable: bool,
|
bubbles: bool, cancelable: bool,
|
||||||
data: HandleValue, origin: DOMString, lastEventId: DOMString)
|
data: HandleValue, origin: DOMString, lastEventId: DOMString)
|
||||||
-> Root<ExtendableMessageEvent> {
|
-> Root<ExtendableMessageEvent> {
|
||||||
|
@ -46,12 +46,13 @@ impl ExtendableMessageEvent {
|
||||||
ev
|
ev
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &ExtendableMessageEventBinding::ExtendableMessageEventInit)
|
init: &ExtendableMessageEventBinding::ExtendableMessageEventInit)
|
||||||
-> Fallible<Root<ExtendableMessageEvent>> {
|
-> Fallible<Root<ExtendableMessageEvent>> {
|
||||||
rooted!(in(global.get_cx()) let data = init.data);
|
rooted!(in(global.get_cx()) let data = init.data);
|
||||||
let ev = ExtendableMessageEvent::new(global, Atom::from(type_),
|
let ev = ExtendableMessageEvent::new(global,
|
||||||
|
Atom::from(type_),
|
||||||
init.parent.parent.bubbles,
|
init.parent.parent.bubbles,
|
||||||
init.parent.parent.cancelable,
|
init.parent.parent.cancelable,
|
||||||
data.handle(),
|
data.handle(),
|
||||||
|
@ -63,7 +64,7 @@ impl ExtendableMessageEvent {
|
||||||
|
|
||||||
impl ExtendableMessageEvent {
|
impl ExtendableMessageEvent {
|
||||||
pub fn dispatch_jsval(target: &EventTarget,
|
pub fn dispatch_jsval(target: &EventTarget,
|
||||||
scope: GlobalRef,
|
scope: &GlobalScope,
|
||||||
message: HandleValue) {
|
message: HandleValue) {
|
||||||
let Extendablemessageevent = ExtendableMessageEvent::new(
|
let Extendablemessageevent = ExtendableMessageEvent::new(
|
||||||
scope, atom!("message"), false, false, message,
|
scope, atom!("message"), false, false, message,
|
||||||
|
|
|
@ -6,11 +6,12 @@ use dom::bindings::codegen::Bindings::FileBinding;
|
||||||
use dom::bindings::codegen::Bindings::FileBinding::FileMethods;
|
use dom::bindings::codegen::Bindings::FileBinding::FileMethods;
|
||||||
use dom::bindings::codegen::UnionTypes::BlobOrString;
|
use dom::bindings::codegen::UnionTypes::BlobOrString;
|
||||||
use dom::bindings::error::{Error, Fallible};
|
use dom::bindings::error::{Error, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::blob::{Blob, BlobImpl, blob_parts_to_bytes};
|
use dom::blob::{Blob, BlobImpl, blob_parts_to_bytes};
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use net_traits::filemanager_thread::SelectedFile;
|
use net_traits::filemanager_thread::SelectedFile;
|
||||||
use time;
|
use time;
|
||||||
|
@ -41,7 +42,7 @@ impl File {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[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> {
|
name: DOMString, modified: Option<i64>, typeString: &str) -> Root<File> {
|
||||||
reflect_dom_object(box File::new_inherited(blob_impl, name, modified, typeString),
|
reflect_dom_object(box File::new_inherited(blob_impl, name, modified, typeString),
|
||||||
global,
|
global,
|
||||||
|
@ -52,14 +53,12 @@ impl File {
|
||||||
pub fn new_from_selected(window: &Window, selected: SelectedFile) -> Root<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 name = DOMString::from(selected.filename.to_str().expect("File name encoding error"));
|
||||||
|
|
||||||
let global = GlobalRef::Window(window);
|
File::new(window.upcast(), BlobImpl::new_from_file(selected.id, selected.filename, selected.size),
|
||||||
|
|
||||||
File::new(global, BlobImpl::new_from_file(selected.id, selected.filename, selected.size),
|
|
||||||
name, Some(selected.modified as i64), &selected.type_string)
|
name, Some(selected.modified as i64), &selected.type_string)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/FileAPI/#file-constructor
|
// https://w3c.github.io/FileAPI/#file-constructor
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
fileBits: Vec<BlobOrString>,
|
fileBits: Vec<BlobOrString>,
|
||||||
filename: DOMString,
|
filename: DOMString,
|
||||||
filePropertyBag: &FileBinding::FilePropertyBag)
|
filePropertyBag: &FileBinding::FilePropertyBag)
|
||||||
|
@ -76,7 +75,11 @@ impl File {
|
||||||
// NOTE: Following behaviour might be removed in future,
|
// NOTE: Following behaviour might be removed in future,
|
||||||
// see https://github.com/w3c/FileAPI/issues/41
|
// see https://github.com/w3c/FileAPI/issues/41
|
||||||
let replaced_filename = DOMString::from_string(filename.replace("/", ":"));
|
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,
|
||||||
|
BlobImpl::new_from_bytes(bytes),
|
||||||
|
replaced_filename,
|
||||||
|
modified,
|
||||||
|
typeString))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn name(&self) -> &DOMString {
|
pub fn name(&self) -> &DOMString {
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::FileListBinding;
|
use dom::bindings::codegen::Bindings::FileListBinding;
|
||||||
use dom::bindings::codegen::Bindings::FileListBinding::FileListMethods;
|
use dom::bindings::codegen::Bindings::FileListBinding::FileListMethods;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::{JS, Root};
|
use dom::bindings::js::{JS, Root};
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::file::File;
|
use dom::file::File;
|
||||||
|
@ -30,7 +29,7 @@ impl FileList {
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, files: Vec<Root<File>>) -> Root<FileList> {
|
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()),
|
reflect_dom_object(box FileList::new_inherited(files.iter().map(|r| JS::from_ref(&**r)).collect()),
|
||||||
GlobalRef::Window(window),
|
window,
|
||||||
FileListBinding::Wrap)
|
FileListBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
|
||||||
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
||||||
use dom::bindings::codegen::Bindings::FileReaderBinding::{self, FileReaderConstants, FileReaderMethods};
|
use dom::bindings::codegen::Bindings::FileReaderBinding::{self, FileReaderConstants, FileReaderMethods};
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
||||||
use dom::bindings::refcounted::Trusted;
|
use dom::bindings::refcounted::Trusted;
|
||||||
|
@ -17,6 +16,7 @@ use dom::blob::Blob;
|
||||||
use dom::domexception::{DOMErrorName, DOMException};
|
use dom::domexception::{DOMErrorName, DOMException};
|
||||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::progressevent::ProgressEvent;
|
use dom::progressevent::ProgressEvent;
|
||||||
use encoding::all::UTF_8;
|
use encoding::all::UTF_8;
|
||||||
use encoding::label::encoding_from_whatwg_label;
|
use encoding::label::encoding_from_whatwg_label;
|
||||||
|
@ -88,12 +88,12 @@ impl FileReader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: GlobalRef) -> Root<FileReader> {
|
pub fn new(global: &GlobalScope) -> Root<FileReader> {
|
||||||
reflect_dom_object(box FileReader::new_inherited(),
|
reflect_dom_object(box FileReader::new_inherited(),
|
||||||
global, FileReaderBinding::Wrap)
|
global, FileReaderBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef) -> Fallible<Root<FileReader>> {
|
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<FileReader>> {
|
||||||
Ok(FileReader::new(global))
|
Ok(FileReader::new(global))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,8 +114,7 @@ impl FileReader {
|
||||||
fr.change_ready_state(FileReaderReadyState::Done);
|
fr.change_ready_state(FileReaderReadyState::Done);
|
||||||
*fr.result.borrow_mut() = None;
|
*fr.result.borrow_mut() = None;
|
||||||
|
|
||||||
let global = fr.r().global();
|
let exception = DOMException::new(&fr.global(), error);
|
||||||
let exception = DOMException::new(global.r(), error);
|
|
||||||
fr.error.set(Some(&exception));
|
fr.error.set(Some(&exception));
|
||||||
|
|
||||||
fr.dispatch_progress_event(atom!("error"), 0, None);
|
fr.dispatch_progress_event(atom!("error"), 0, None);
|
||||||
|
@ -289,8 +288,7 @@ impl FileReaderMethods for FileReader {
|
||||||
// Steps 1 & 3
|
// Steps 1 & 3
|
||||||
*self.result.borrow_mut() = None;
|
*self.result.borrow_mut() = None;
|
||||||
|
|
||||||
let global = self.global();
|
let exception = DOMException::new(&self.global(), DOMErrorName::AbortError);
|
||||||
let exception = DOMException::new(global.r(), DOMErrorName::AbortError);
|
|
||||||
self.error.set(Some(&exception));
|
self.error.set(Some(&exception));
|
||||||
|
|
||||||
self.terminate_ongoing_reading();
|
self.terminate_ongoing_reading();
|
||||||
|
@ -318,8 +316,7 @@ impl FileReaderMethods for FileReader {
|
||||||
|
|
||||||
impl FileReader {
|
impl FileReader {
|
||||||
fn dispatch_progress_event(&self, type_: Atom, loaded: u64, total: Option<u64>) {
|
fn dispatch_progress_event(&self, type_: Atom, loaded: u64, total: Option<u64>) {
|
||||||
let global = self.global();
|
let progressevent = ProgressEvent::new(&self.global(),
|
||||||
let progressevent = ProgressEvent::new(global.r(),
|
|
||||||
type_, EventBubbles::DoesNotBubble, EventCancelable::NotCancelable,
|
type_, EventBubbles::DoesNotBubble, EventCancelable::NotCancelable,
|
||||||
total.is_some(), loaded, total.unwrap_or(0));
|
total.is_some(), loaded, total.unwrap_or(0));
|
||||||
progressevent.upcast::<Event>().fire(self.upcast());
|
progressevent.upcast::<Event>().fire(self.upcast());
|
||||||
|
@ -336,9 +333,9 @@ impl FileReader {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState);
|
||||||
}
|
}
|
||||||
// Step 2
|
// Step 2
|
||||||
if blob.IsClosed() {
|
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
let exception = DOMException::new(global.r(), DOMErrorName::InvalidStateError);
|
if blob.IsClosed() {
|
||||||
|
let exception = DOMException::new(&global, DOMErrorName::InvalidStateError);
|
||||||
self.error.set(Some(&exception));
|
self.error.set(Some(&exception));
|
||||||
|
|
||||||
self.dispatch_progress_event(atom!("error"), 0, None);
|
self.dispatch_progress_event(atom!("error"), 0, None);
|
||||||
|
@ -358,8 +355,9 @@ impl FileReader {
|
||||||
let fr = Trusted::new(self);
|
let fr = Trusted::new(self);
|
||||||
let gen_id = self.generation_id.get();
|
let gen_id = self.generation_id.get();
|
||||||
|
|
||||||
let wrapper = self.global().r().get_runnable_wrapper();
|
let global = self.global();
|
||||||
let task_source = self.global().r().file_reading_task_source();
|
let wrapper = global.get_runnable_wrapper();
|
||||||
|
let task_source = global.file_reading_task_source();
|
||||||
|
|
||||||
spawn_named("file reader async operation".to_owned(), move || {
|
spawn_named("file reader async operation".to_owned(), move || {
|
||||||
perform_annotated_read_operation(gen_id, load_data, blob_contents, fr, task_source, wrapper)
|
perform_annotated_read_operation(gen_id, load_data, blob_contents, fr, task_source, wrapper)
|
||||||
|
|
|
@ -4,12 +4,10 @@
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::FileReaderSyncBinding;
|
use dom::bindings::codegen::Bindings::FileReaderSyncBinding;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct FileReaderSync {
|
pub struct FileReaderSync {
|
||||||
|
@ -23,12 +21,12 @@ impl FileReaderSync {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: GlobalRef) -> Root<FileReaderSync> {
|
pub fn new(global: &GlobalScope) -> Root<FileReaderSync> {
|
||||||
reflect_dom_object(box FileReaderSync::new_inherited(),
|
reflect_dom_object(box FileReaderSync::new_inherited(),
|
||||||
global, FileReaderSyncBinding::Wrap)
|
global, FileReaderSyncBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef) -> Fallible<Root<FileReaderSync>> {
|
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<FileReaderSync>> {
|
||||||
Ok(FileReaderSync::new(global))
|
Ok(FileReaderSync::new(global))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,13 @@ use dom::bindings::codegen::Bindings::FocusEventBinding;
|
||||||
use dom::bindings::codegen::Bindings::FocusEventBinding::FocusEventMethods;
|
use dom::bindings::codegen::Bindings::FocusEventBinding::FocusEventMethods;
|
||||||
use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
|
use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference};
|
use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference};
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::event::{EventBubbles, EventCancelable};
|
use dom::event::{EventBubbles, EventCancelable};
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::uievent::UIEvent;
|
use dom::uievent::UIEvent;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
|
@ -31,7 +31,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(),
|
reflect_dom_object(box FocusEvent::new_inherited(),
|
||||||
global,
|
global,
|
||||||
FocusEventBinding::Wrap)
|
FocusEventBinding::Wrap)
|
||||||
|
@ -44,8 +44,7 @@ impl FocusEvent {
|
||||||
view: Option<&Window>,
|
view: Option<&Window>,
|
||||||
detail: i32,
|
detail: i32,
|
||||||
related_target: Option<&EventTarget>) -> Root<FocusEvent> {
|
related_target: Option<&EventTarget>) -> Root<FocusEvent> {
|
||||||
let event = box FocusEvent::new_inherited();
|
let ev = FocusEvent::new_uninitialized(window.upcast());
|
||||||
let ev = reflect_dom_object(event, GlobalRef::Window(window), FocusEventBinding::Wrap);
|
|
||||||
ev.upcast::<UIEvent>().InitUIEvent(type_,
|
ev.upcast::<UIEvent>().InitUIEvent(type_,
|
||||||
bool::from(can_bubble),
|
bool::from(can_bubble),
|
||||||
bool::from(cancelable),
|
bool::from(cancelable),
|
||||||
|
@ -54,12 +53,13 @@ impl FocusEvent {
|
||||||
ev
|
ev
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &FocusEventBinding::FocusEventInit) -> Fallible<Root<FocusEvent>> {
|
init: &FocusEventBinding::FocusEventInit) -> Fallible<Root<FocusEvent>> {
|
||||||
let bubbles = EventBubbles::from(init.parent.parent.bubbles);
|
let bubbles = EventBubbles::from(init.parent.parent.bubbles);
|
||||||
let cancelable = EventCancelable::from(init.parent.parent.cancelable);
|
let cancelable = EventCancelable::from(init.parent.parent.cancelable);
|
||||||
let event = FocusEvent::new(global.as_window(), type_,
|
let event = FocusEvent::new(global.as_window(),
|
||||||
|
type_,
|
||||||
bubbles,
|
bubbles,
|
||||||
cancelable,
|
cancelable,
|
||||||
init.parent.view.r(),
|
init.parent.view.r(),
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
use dom::bindings::codegen::Bindings::ForceTouchEventBinding;
|
use dom::bindings::codegen::Bindings::ForceTouchEventBinding;
|
||||||
use dom::bindings::codegen::Bindings::ForceTouchEventBinding::ForceTouchEventMethods;
|
use dom::bindings::codegen::Bindings::ForceTouchEventBinding::ForceTouchEventMethods;
|
||||||
use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
|
use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::num::Finite;
|
use dom::bindings::num::Finite;
|
||||||
|
@ -32,7 +31,7 @@ impl ForceTouchEvent {
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
force: f32) -> Root<ForceTouchEvent> {
|
force: f32) -> Root<ForceTouchEvent> {
|
||||||
let event = box ForceTouchEvent::new_inherited(force);
|
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.upcast::<UIEvent>().InitUIEvent(type_, true, true, Some(window), 0);
|
||||||
ev
|
ev
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,13 +7,13 @@ use dom::bindings::codegen::Bindings::FormDataBinding::FormDataMethods;
|
||||||
use dom::bindings::codegen::Bindings::FormDataBinding::FormDataWrap;
|
use dom::bindings::codegen::Bindings::FormDataBinding::FormDataWrap;
|
||||||
use dom::bindings::codegen::UnionTypes::FileOrUSVString;
|
use dom::bindings::codegen::UnionTypes::FileOrUSVString;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::iterable::Iterable;
|
use dom::bindings::iterable::Iterable;
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::str::{DOMString, USVString};
|
use dom::bindings::str::{DOMString, USVString};
|
||||||
use dom::blob::{Blob, BlobImpl};
|
use dom::blob::{Blob, BlobImpl};
|
||||||
use dom::file::File;
|
use dom::file::File;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::htmlformelement::{HTMLFormElement, FormDatumValue, FormDatum};
|
use dom::htmlformelement::{HTMLFormElement, FormDatumValue, FormDatum};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||||
|
@ -45,12 +45,12 @@ 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),
|
reflect_dom_object(box FormData::new_inherited(form),
|
||||||
global, FormDataWrap)
|
global, FormDataWrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef, form: Option<&HTMLFormElement>) -> Fallible<Root<FormData>> {
|
pub fn Constructor(global: &GlobalScope, form: Option<&HTMLFormElement>) -> Fallible<Root<FormData>> {
|
||||||
// TODO: Construct form data set for form if it is supplied
|
// TODO: Construct form data set for form if it is supplied
|
||||||
Ok(FormData::new(form, global))
|
Ok(FormData::new(form, global))
|
||||||
}
|
}
|
||||||
|
@ -145,8 +145,6 @@ impl FormDataMethods for FormData {
|
||||||
|
|
||||||
impl FormData {
|
impl FormData {
|
||||||
fn get_file(&self, blob: &Blob, opt_filename: Option<USVString>) -> Root<File> {
|
fn get_file(&self, blob: &Blob, opt_filename: Option<USVString>) -> Root<File> {
|
||||||
let global = self.global();
|
|
||||||
|
|
||||||
let name = match opt_filename {
|
let name = match opt_filename {
|
||||||
Some(filename) => DOMString::from(filename.0),
|
Some(filename) => DOMString::from(filename.0),
|
||||||
None => DOMString::from(""),
|
None => DOMString::from(""),
|
||||||
|
@ -154,7 +152,7 @@ impl FormData {
|
||||||
|
|
||||||
let bytes = blob.get_bytes().unwrap_or(vec![]);
|
let bytes = blob.get_bytes().unwrap_or(vec![]);
|
||||||
|
|
||||||
File::new(global.r(), BlobImpl::new_from_bytes(bytes), name, None, "")
|
File::new(&self.global(), BlobImpl::new_from_bytes(bytes), name, None, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn datums(&self) -> Vec<FormDatum> {
|
pub fn datums(&self) -> Vec<FormDatum> {
|
||||||
|
|
524
components/script/dom/globalscope.rs
Normal file
524
components/script/dom/globalscope.rs
Normal file
|
@ -0,0 +1,524 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* 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 devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId};
|
||||||
|
use dom::bindings::cell::DOMRefCell;
|
||||||
|
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::{JS, MutNullableHeap, Root};
|
||||||
|
use dom::bindings::reflector::Reflectable;
|
||||||
|
use dom::bindings::str::DOMString;
|
||||||
|
use dom::crypto::Crypto;
|
||||||
|
use dom::dedicatedworkerglobalscope::DedicatedWorkerGlobalScope;
|
||||||
|
use dom::errorevent::ErrorEvent;
|
||||||
|
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
|
use dom::eventdispatcher::EventStatus;
|
||||||
|
use dom::eventtarget::EventTarget;
|
||||||
|
use dom::window::Window;
|
||||||
|
use dom::workerglobalscope::WorkerGlobalScope;
|
||||||
|
use ipc_channel::ipc::IpcSender;
|
||||||
|
use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL};
|
||||||
|
use js::glue::{IsWrapper, UnwrapObject};
|
||||||
|
use js::jsapi::{CurrentGlobalOrNull, GetGlobalForObjectCrossCompartment};
|
||||||
|
use js::jsapi::{HandleValue, Evaluate2, JSAutoCompartment, JSContext};
|
||||||
|
use js::jsapi::{JSObject, JS_GetClass, JS_GetContext};
|
||||||
|
use js::jsapi::{JS_GetObjectRuntime, MutableHandleValue};
|
||||||
|
use js::rust::CompileOptionsWrapper;
|
||||||
|
use libc;
|
||||||
|
use msg::constellation_msg::PipelineId;
|
||||||
|
use net_traits::{CoreResourceThread, ResourceThreads, IpcSend};
|
||||||
|
use profile_traits::{mem, time};
|
||||||
|
use script_runtime::{CommonScriptMsg, EnqueuedPromiseCallback, ScriptChan};
|
||||||
|
use script_runtime::{ScriptPort, maybe_take_panic_result};
|
||||||
|
use script_thread::{MainThreadScriptChan, RunnableWrapper, ScriptThread};
|
||||||
|
use script_traits::{MsDuration, ScriptMsg as ConstellationMsg, TimerEvent};
|
||||||
|
use script_traits::{TimerEventId, TimerEventRequest, TimerSource};
|
||||||
|
use std::cell::Cell;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
use std::collections::hash_map::Entry;
|
||||||
|
use std::ffi::CString;
|
||||||
|
use std::panic;
|
||||||
|
use task_source::file_reading::FileReadingTaskSource;
|
||||||
|
use time::{Timespec, get_time};
|
||||||
|
use timers::{IsInterval, OneshotTimerCallback, OneshotTimerHandle};
|
||||||
|
use timers::{OneshotTimers, TimerCallback};
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
|
#[dom_struct]
|
||||||
|
pub struct GlobalScope {
|
||||||
|
eventtarget: EventTarget,
|
||||||
|
crypto: MutNullableHeap<JS<Crypto>>,
|
||||||
|
next_worker_id: Cell<WorkerId>,
|
||||||
|
|
||||||
|
/// Pipeline id associated with this global.
|
||||||
|
pipeline_id: PipelineId,
|
||||||
|
|
||||||
|
/// A flag to indicate whether the developer tools has requested
|
||||||
|
/// live updates from the worker.
|
||||||
|
devtools_wants_updates: Cell<bool>,
|
||||||
|
|
||||||
|
/// Timers used by the Console API.
|
||||||
|
console_timers: DOMRefCell<HashMap<DOMString, u64>>,
|
||||||
|
|
||||||
|
/// For providing instructions to an optional devtools server.
|
||||||
|
#[ignore_heap_size_of = "channels are hard"]
|
||||||
|
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
||||||
|
|
||||||
|
/// For sending messages to the memory profiler.
|
||||||
|
#[ignore_heap_size_of = "channels are hard"]
|
||||||
|
mem_profiler_chan: mem::ProfilerChan,
|
||||||
|
|
||||||
|
/// For sending messages to the time profiler.
|
||||||
|
#[ignore_heap_size_of = "channels are hard"]
|
||||||
|
time_profiler_chan: time::ProfilerChan,
|
||||||
|
|
||||||
|
/// A handle for communicating messages to the constellation thread.
|
||||||
|
#[ignore_heap_size_of = "channels are hard"]
|
||||||
|
constellation_chan: IpcSender<ConstellationMsg>,
|
||||||
|
|
||||||
|
#[ignore_heap_size_of = "channels are hard"]
|
||||||
|
scheduler_chan: IpcSender<TimerEventRequest>,
|
||||||
|
|
||||||
|
/// https://html.spec.whatwg.org/multipage/#in-error-reporting-mode
|
||||||
|
in_error_reporting_mode: Cell<bool>,
|
||||||
|
|
||||||
|
/// Associated resource threads for use by DOM objects like XMLHttpRequest,
|
||||||
|
/// including resource_thread, filemanager_thread and storage_thread
|
||||||
|
resource_threads: ResourceThreads,
|
||||||
|
|
||||||
|
timers: OneshotTimers,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GlobalScope {
|
||||||
|
pub fn new_inherited(
|
||||||
|
pipeline_id: PipelineId,
|
||||||
|
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
||||||
|
mem_profiler_chan: mem::ProfilerChan,
|
||||||
|
time_profiler_chan: time::ProfilerChan,
|
||||||
|
constellation_chan: IpcSender<ConstellationMsg>,
|
||||||
|
scheduler_chan: IpcSender<TimerEventRequest>,
|
||||||
|
resource_threads: ResourceThreads,
|
||||||
|
timer_event_chan: IpcSender<TimerEvent>)
|
||||||
|
-> Self {
|
||||||
|
GlobalScope {
|
||||||
|
eventtarget: EventTarget::new_inherited(),
|
||||||
|
crypto: Default::default(),
|
||||||
|
next_worker_id: Cell::new(WorkerId(0)),
|
||||||
|
pipeline_id: pipeline_id,
|
||||||
|
devtools_wants_updates: Default::default(),
|
||||||
|
console_timers: DOMRefCell::new(Default::default()),
|
||||||
|
devtools_chan: devtools_chan,
|
||||||
|
mem_profiler_chan: mem_profiler_chan,
|
||||||
|
time_profiler_chan: time_profiler_chan,
|
||||||
|
constellation_chan: constellation_chan,
|
||||||
|
scheduler_chan: scheduler_chan.clone(),
|
||||||
|
in_error_reporting_mode: Default::default(),
|
||||||
|
resource_threads: resource_threads,
|
||||||
|
timers: OneshotTimers::new(timer_event_chan, scheduler_chan),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the global scope of the realm that the given DOM object's reflector
|
||||||
|
/// was created in.
|
||||||
|
#[allow(unsafe_code)]
|
||||||
|
pub fn from_reflector<T: Reflectable>(reflector: &T) -> Root<Self> {
|
||||||
|
unsafe { GlobalScope::from_object(*reflector.reflector().get_jsobject()) }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the global scope of the realm that the given JS object was created in.
|
||||||
|
#[allow(unsafe_code)]
|
||||||
|
pub unsafe fn from_object(obj: *mut JSObject) -> Root<Self> {
|
||||||
|
assert!(!obj.is_null());
|
||||||
|
let global = GetGlobalForObjectCrossCompartment(obj);
|
||||||
|
global_scope_from_global(global)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the global scope for the given JSContext
|
||||||
|
#[allow(unsafe_code)]
|
||||||
|
pub unsafe fn from_context(cx: *mut JSContext) -> Root<Self> {
|
||||||
|
let global = CurrentGlobalOrNull(cx);
|
||||||
|
global_scope_from_global(global)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the global object of the realm that the given JS object
|
||||||
|
/// was created in, after unwrapping any wrappers.
|
||||||
|
#[allow(unsafe_code)]
|
||||||
|
pub unsafe fn from_object_maybe_wrapped(mut obj: *mut JSObject) -> Root<Self> {
|
||||||
|
if IsWrapper(obj) {
|
||||||
|
obj = UnwrapObject(obj, /* stopAtWindowProxy = */ 0);
|
||||||
|
assert!(!obj.is_null());
|
||||||
|
}
|
||||||
|
GlobalScope::from_object(obj)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn crypto(&self) -> Root<Crypto> {
|
||||||
|
self.crypto.or_init(|| Crypto::new(self))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get next worker id.
|
||||||
|
pub fn get_next_worker_id(&self) -> WorkerId {
|
||||||
|
let worker_id = self.next_worker_id.get();
|
||||||
|
let WorkerId(id_num) = worker_id;
|
||||||
|
self.next_worker_id.set(WorkerId(id_num + 1));
|
||||||
|
worker_id
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn live_devtools_updates(&self) -> bool {
|
||||||
|
self.devtools_wants_updates.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_devtools_wants_updates(&self, value: bool) {
|
||||||
|
self.devtools_wants_updates.set(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn time(&self, label: DOMString) -> Result<(), ()> {
|
||||||
|
let mut timers = self.console_timers.borrow_mut();
|
||||||
|
if timers.len() >= 10000 {
|
||||||
|
return Err(());
|
||||||
|
}
|
||||||
|
match timers.entry(label) {
|
||||||
|
Entry::Vacant(entry) => {
|
||||||
|
entry.insert(timestamp_in_ms(get_time()));
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
Entry::Occupied(_) => Err(()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn time_end(&self, label: &str) -> Result<u64, ()> {
|
||||||
|
self.console_timers.borrow_mut().remove(label).ok_or(()).map(|start| {
|
||||||
|
timestamp_in_ms(get_time()) - start
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get an `&IpcSender<ScriptToDevtoolsControlMsg>` to send messages
|
||||||
|
/// to the devtools thread when available.
|
||||||
|
pub fn devtools_chan(&self) -> Option<&IpcSender<ScriptToDevtoolsControlMsg>> {
|
||||||
|
self.devtools_chan.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get a sender to the memory profiler thread.
|
||||||
|
pub fn mem_profiler_chan(&self) -> &mem::ProfilerChan {
|
||||||
|
&self.mem_profiler_chan
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get a sender to the time profiler thread.
|
||||||
|
pub fn time_profiler_chan(&self) -> &time::ProfilerChan {
|
||||||
|
&self.time_profiler_chan
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get a sender to the constellation thread.
|
||||||
|
pub fn constellation_chan(&self) -> &IpcSender<ConstellationMsg> {
|
||||||
|
&self.constellation_chan
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn scheduler_chan(&self) -> &IpcSender<TimerEventRequest> {
|
||||||
|
&self.scheduler_chan
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the `PipelineId` for this global scope.
|
||||||
|
pub fn pipeline_id(&self) -> PipelineId {
|
||||||
|
self.pipeline_id
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the [base url](https://html.spec.whatwg.org/multipage/#api-base-url)
|
||||||
|
/// for this global scope.
|
||||||
|
pub fn api_base_url(&self) -> Url {
|
||||||
|
if let Some(window) = self.downcast::<Window>() {
|
||||||
|
// https://html.spec.whatwg.org/multipage/#script-settings-for-browsing-contexts:api-base-url
|
||||||
|
return window.Document().base_url();
|
||||||
|
}
|
||||||
|
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
||||||
|
// https://html.spec.whatwg.org/multipage/#script-settings-for-workers:api-base-url
|
||||||
|
return worker.get_url().clone();
|
||||||
|
}
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the URL for this global scope.
|
||||||
|
pub fn get_url(&self) -> Url {
|
||||||
|
if let Some(window) = self.downcast::<Window>() {
|
||||||
|
return window.get_url();
|
||||||
|
}
|
||||||
|
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
||||||
|
return worker.get_url().clone();
|
||||||
|
}
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Extract a `Window`, panic if the global object is not a `Window`.
|
||||||
|
pub fn as_window(&self) -> &Window {
|
||||||
|
self.downcast::<Window>().expect("expected a Window scope")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// https://html.spec.whatwg.org/multipage/#report-the-error
|
||||||
|
pub fn report_an_error(&self, error_info: ErrorInfo, value: HandleValue) {
|
||||||
|
// Step 1.
|
||||||
|
if self.in_error_reporting_mode.get() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 2.
|
||||||
|
self.in_error_reporting_mode.set(true);
|
||||||
|
|
||||||
|
// Steps 3-12.
|
||||||
|
// FIXME(#13195): muted errors.
|
||||||
|
let event = ErrorEvent::new(self,
|
||||||
|
atom!("error"),
|
||||||
|
EventBubbles::DoesNotBubble,
|
||||||
|
EventCancelable::Cancelable,
|
||||||
|
error_info.message.as_str().into(),
|
||||||
|
error_info.filename.as_str().into(),
|
||||||
|
error_info.lineno,
|
||||||
|
error_info.column,
|
||||||
|
value);
|
||||||
|
|
||||||
|
// Step 13.
|
||||||
|
let event_status = event.upcast::<Event>().fire(self.upcast::<EventTarget>());
|
||||||
|
|
||||||
|
// Step 15
|
||||||
|
if event_status == EventStatus::NotCanceled {
|
||||||
|
if let Some(dedicated) = self.downcast::<DedicatedWorkerGlobalScope>() {
|
||||||
|
dedicated.forward_error_to_worker_object(error_info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 14
|
||||||
|
self.in_error_reporting_mode.set(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the `&ResourceThreads` for this global scope.
|
||||||
|
pub fn resource_threads(&self) -> &ResourceThreads {
|
||||||
|
&self.resource_threads
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the `CoreResourceThread` for this global scope.
|
||||||
|
pub fn core_resource_thread(&self) -> CoreResourceThread {
|
||||||
|
self.resource_threads().sender()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `ScriptChan` to send messages to the event loop of this global scope.
|
||||||
|
pub fn script_chan(&self) -> Box<ScriptChan + Send> {
|
||||||
|
if let Some(window) = self.downcast::<Window>() {
|
||||||
|
return MainThreadScriptChan(window.main_thread_script_chan().clone()).clone();
|
||||||
|
}
|
||||||
|
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
||||||
|
return worker.script_chan();
|
||||||
|
}
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `ScriptChan` to send messages to the networking task source of
|
||||||
|
/// this of this global scope.
|
||||||
|
pub fn networking_task_source(&self) -> Box<ScriptChan + Send> {
|
||||||
|
if let Some(window) = self.downcast::<Window>() {
|
||||||
|
return window.networking_task_source();
|
||||||
|
}
|
||||||
|
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
||||||
|
return worker.script_chan();
|
||||||
|
}
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Evaluate JS code on this global scope.
|
||||||
|
pub fn evaluate_js_on_global_with_result(
|
||||||
|
&self, code: &str, rval: MutableHandleValue) {
|
||||||
|
self.evaluate_script_on_global_with_result(code, "", rval)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Evaluate a JS script on this global scope.
|
||||||
|
#[allow(unsafe_code)]
|
||||||
|
pub fn evaluate_script_on_global_with_result(
|
||||||
|
&self, code: &str, filename: &str, rval: MutableHandleValue) {
|
||||||
|
let metadata = time::TimerMetadata {
|
||||||
|
url: if filename.is_empty() {
|
||||||
|
self.get_url().as_str().into()
|
||||||
|
} else {
|
||||||
|
filename.into()
|
||||||
|
},
|
||||||
|
iframe: time::TimerMetadataFrameType::RootWindow,
|
||||||
|
incremental: time::TimerMetadataReflowType::FirstReflow,
|
||||||
|
};
|
||||||
|
time::profile(
|
||||||
|
time::ProfilerCategory::ScriptEvaluate,
|
||||||
|
Some(metadata),
|
||||||
|
self.time_profiler_chan().clone(),
|
||||||
|
|| {
|
||||||
|
let cx = self.get_cx();
|
||||||
|
let globalhandle = self.reflector().get_jsobject();
|
||||||
|
let code: Vec<u16> = code.encode_utf16().collect();
|
||||||
|
let filename = CString::new(filename).unwrap();
|
||||||
|
|
||||||
|
let _ac = JSAutoCompartment::new(cx, globalhandle.get());
|
||||||
|
let options = CompileOptionsWrapper::new(cx, filename.as_ptr(), 1);
|
||||||
|
unsafe {
|
||||||
|
if !Evaluate2(cx, options.ptr, code.as_ptr(),
|
||||||
|
code.len() as libc::size_t,
|
||||||
|
rval) {
|
||||||
|
debug!("error evaluating JS string");
|
||||||
|
report_pending_exception(cx, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(error) = maybe_take_panic_result() {
|
||||||
|
panic::resume_unwind(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn schedule_callback(
|
||||||
|
&self, callback: OneshotTimerCallback, duration: MsDuration)
|
||||||
|
-> OneshotTimerHandle {
|
||||||
|
self.timers.schedule_callback(callback, duration, self.timer_source())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unschedule_callback(&self, handle: OneshotTimerHandle) {
|
||||||
|
self.timers.unschedule_callback(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_timeout_or_interval(
|
||||||
|
&self,
|
||||||
|
callback: TimerCallback,
|
||||||
|
arguments: Vec<HandleValue>,
|
||||||
|
timeout: i32,
|
||||||
|
is_interval: IsInterval)
|
||||||
|
-> i32 {
|
||||||
|
self.timers.set_timeout_or_interval(
|
||||||
|
self, callback, arguments, timeout, is_interval, self.timer_source())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn clear_timeout_or_interval(&self, handle: i32) {
|
||||||
|
self.timers.clear_timeout_or_interval(self, handle)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn fire_timer(&self, handle: TimerEventId) {
|
||||||
|
self.timers.fire_timer(handle, self)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn resume(&self) {
|
||||||
|
self.timers.resume()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn suspend(&self) {
|
||||||
|
self.timers.suspend()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn slow_down_timers(&self) {
|
||||||
|
self.timers.slow_down()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn speed_up_timers(&self) {
|
||||||
|
self.timers.speed_up()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn timer_source(&self) -> TimerSource {
|
||||||
|
if self.is::<Window>() {
|
||||||
|
return TimerSource::FromWindow(self.pipeline_id());
|
||||||
|
}
|
||||||
|
if self.is::<WorkerGlobalScope>() {
|
||||||
|
return TimerSource::FromWorker;
|
||||||
|
}
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns a wrapper for runnables to ensure they are cancelled if
|
||||||
|
/// the global scope is being destroyed.
|
||||||
|
pub fn get_runnable_wrapper(&self) -> RunnableWrapper {
|
||||||
|
if let Some(window) = self.downcast::<Window>() {
|
||||||
|
return window.get_runnable_wrapper();
|
||||||
|
}
|
||||||
|
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
||||||
|
return worker.get_runnable_wrapper();
|
||||||
|
}
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Start the process of executing the pending promise callbacks. They will be invoked
|
||||||
|
/// in FIFO order, synchronously, at some point in the future.
|
||||||
|
pub fn flush_promise_jobs(&self) {
|
||||||
|
if self.is::<Window>() {
|
||||||
|
return ScriptThread::flush_promise_jobs(self);
|
||||||
|
}
|
||||||
|
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
||||||
|
return worker.flush_promise_jobs();
|
||||||
|
}
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Enqueue a promise callback for subsequent execution.
|
||||||
|
pub fn enqueue_promise_job(&self, job: EnqueuedPromiseCallback) {
|
||||||
|
if self.is::<Window>() {
|
||||||
|
return ScriptThread::enqueue_promise_job(job, self);
|
||||||
|
}
|
||||||
|
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
||||||
|
return worker.enqueue_promise_job(job);
|
||||||
|
}
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a new sender/receiver pair that can be used to implement an on-demand
|
||||||
|
/// event loop. Used for implementing web APIs that require blocking semantics
|
||||||
|
/// without resorting to nested event loops.
|
||||||
|
pub fn new_script_pair(&self) -> (Box<ScriptChan + Send>, Box<ScriptPort + Send>) {
|
||||||
|
if let Some(window) = self.downcast::<Window>() {
|
||||||
|
return window.new_script_pair();
|
||||||
|
}
|
||||||
|
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
||||||
|
return worker.new_script_pair();
|
||||||
|
}
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Process a single event as if it were the next event
|
||||||
|
/// in the thread queue for this global scope.
|
||||||
|
pub fn process_event(&self, msg: CommonScriptMsg) {
|
||||||
|
if self.is::<Window>() {
|
||||||
|
return ScriptThread::process_event(msg);
|
||||||
|
}
|
||||||
|
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
||||||
|
return worker.process_event(msg);
|
||||||
|
}
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Channel to send messages to the file reading task source of
|
||||||
|
/// this of this global scope.
|
||||||
|
pub fn file_reading_task_source(&self) -> FileReadingTaskSource {
|
||||||
|
if let Some(window) = self.downcast::<Window>() {
|
||||||
|
return window.file_reading_task_source();
|
||||||
|
}
|
||||||
|
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
||||||
|
return worker.file_reading_task_source();
|
||||||
|
}
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn timestamp_in_ms(time: Timespec) -> u64 {
|
||||||
|
(time.sec * 1000 + (time.nsec / 1000000) as i64) as u64
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the Rust global scope from a JS global object.
|
||||||
|
#[allow(unsafe_code)]
|
||||||
|
unsafe fn global_scope_from_global(global: *mut JSObject) -> Root<GlobalScope> {
|
||||||
|
assert!(!global.is_null());
|
||||||
|
let clasp = JS_GetClass(global);
|
||||||
|
assert!(((*clasp).flags & (JSCLASS_IS_DOMJSCLASS | JSCLASS_IS_GLOBAL)) != 0);
|
||||||
|
root_from_object(global).unwrap()
|
||||||
|
}
|
|
@ -6,12 +6,12 @@ use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||||
use dom::bindings::codegen::Bindings::HashChangeEventBinding;
|
use dom::bindings::codegen::Bindings::HashChangeEventBinding;
|
||||||
use dom::bindings::codegen::Bindings::HashChangeEventBinding::HashChangeEventMethods;
|
use dom::bindings::codegen::Bindings::HashChangeEventBinding::HashChangeEventMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::str::{DOMString, USVString};
|
use dom::bindings::str::{DOMString, USVString};
|
||||||
use dom::event::Event;
|
use dom::event::Event;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use string_cache::Atom;
|
use string_cache::Atom;
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#hashchangeevent
|
// https://html.spec.whatwg.org/multipage/#hashchangeevent
|
||||||
|
@ -31,14 +31,13 @@ impl HashChangeEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_uninitialized(global: GlobalRef)
|
pub fn new_uninitialized(global: &GlobalScope) -> Root<HashChangeEvent> {
|
||||||
-> Root<HashChangeEvent> {
|
|
||||||
reflect_dom_object(box HashChangeEvent::new_inherited(String::new(), String::new()),
|
reflect_dom_object(box HashChangeEvent::new_inherited(String::new(), String::new()),
|
||||||
global,
|
global,
|
||||||
HashChangeEventBinding::Wrap)
|
HashChangeEventBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: GlobalRef,
|
pub fn new(global: &GlobalScope,
|
||||||
type_: Atom,
|
type_: Atom,
|
||||||
bubbles: bool,
|
bubbles: bool,
|
||||||
cancelable: bool,
|
cancelable: bool,
|
||||||
|
@ -55,7 +54,7 @@ impl HashChangeEvent {
|
||||||
ev
|
ev
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &HashChangeEventBinding::HashChangeEventInit)
|
init: &HashChangeEventBinding::HashChangeEventInit)
|
||||||
-> Fallible<Root<HashChangeEvent>> {
|
-> Fallible<Root<HashChangeEvent>> {
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
use dom::bindings::cell::DOMRefCell;
|
use dom::bindings::cell::DOMRefCell;
|
||||||
use dom::bindings::codegen::Bindings::HeadersBinding::{HeadersInit, HeadersMethods, HeadersWrap};
|
use dom::bindings::codegen::Bindings::HeadersBinding::{HeadersInit, HeadersMethods, HeadersWrap};
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::iterable::Iterable;
|
use dom::bindings::iterable::Iterable;
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::str::{ByteString, is_token};
|
use dom::bindings::str::{ByteString, is_token};
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use hyper::header::Headers as HyperHeaders;
|
use hyper::header::Headers as HyperHeaders;
|
||||||
use mime::{Mime, TopLevel, SubLevel};
|
use mime::{Mime, TopLevel, SubLevel};
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
@ -43,12 +43,12 @@ 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)
|
reflect_dom_object(box Headers::new_inherited(), global, HeadersWrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://fetch.spec.whatwg.org/#dom-headers
|
// https://fetch.spec.whatwg.org/#dom-headers
|
||||||
pub fn Constructor(global: GlobalRef, init: Option<HeadersInit>)
|
pub fn Constructor(global: &GlobalScope, init: Option<HeadersInit>)
|
||||||
-> Fallible<Root<Headers>> {
|
-> Fallible<Root<Headers>> {
|
||||||
let dom_headers_new = Headers::new(global);
|
let dom_headers_new = Headers::new(global);
|
||||||
try!(dom_headers_new.fill(init));
|
try!(dom_headers_new.fill(init));
|
||||||
|
@ -205,13 +205,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);
|
let headers_for_request = Headers::new(global);
|
||||||
headers_for_request.guard.set(Guard::Request);
|
headers_for_request.guard.set(Guard::Request);
|
||||||
headers_for_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);
|
let headers_for_response = Headers::new(global);
|
||||||
headers_for_response.guard.set(Guard::Response);
|
headers_for_response.guard.set(Guard::Response);
|
||||||
headers_for_response
|
headers_for_response
|
||||||
|
|
|
@ -6,9 +6,10 @@ use dom::bindings::codegen::Bindings::HistoryBinding;
|
||||||
use dom::bindings::codegen::Bindings::HistoryBinding::HistoryMethods;
|
use dom::bindings::codegen::Bindings::HistoryBinding::HistoryMethods;
|
||||||
use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods;
|
use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods;
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::global::GlobalRef;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{JS, Root};
|
use dom::bindings::js::{JS, Root};
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use ipc_channel::ipc;
|
use ipc_channel::ipc;
|
||||||
use msg::constellation_msg::TraversalDirection;
|
use msg::constellation_msg::TraversalDirection;
|
||||||
|
@ -31,26 +32,28 @@ impl History {
|
||||||
|
|
||||||
pub fn new(window: &Window) -> Root<History> {
|
pub fn new(window: &Window) -> Root<History> {
|
||||||
reflect_dom_object(box History::new_inherited(window),
|
reflect_dom_object(box History::new_inherited(window),
|
||||||
GlobalRef::Window(window),
|
window,
|
||||||
HistoryBinding::Wrap)
|
HistoryBinding::Wrap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl History {
|
impl History {
|
||||||
fn traverse_history(&self, direction: TraversalDirection) {
|
fn traverse_history(&self, direction: TraversalDirection) {
|
||||||
let pipeline = self.window.pipeline_id();
|
let global_scope = self.window.upcast::<GlobalScope>();
|
||||||
|
let pipeline = global_scope.pipeline_id();
|
||||||
let msg = ConstellationMsg::TraverseHistory(Some(pipeline), direction);
|
let msg = ConstellationMsg::TraverseHistory(Some(pipeline), direction);
|
||||||
let _ = self.window.constellation_chan().send(msg);
|
let _ = global_scope.constellation_chan().send(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HistoryMethods for History {
|
impl HistoryMethods for History {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-history-length
|
// https://html.spec.whatwg.org/multipage/#dom-history-length
|
||||||
fn Length(&self) -> u32 {
|
fn Length(&self) -> u32 {
|
||||||
let pipeline = self.window.pipeline_id();
|
let global_scope = self.window.upcast::<GlobalScope>();
|
||||||
|
let pipeline = global_scope.pipeline_id();
|
||||||
let (sender, recv) = ipc::channel().expect("Failed to create channel to send jsh length.");
|
let (sender, recv) = ipc::channel().expect("Failed to create channel to send jsh length.");
|
||||||
let msg = ConstellationMsg::JointSessionHistoryLength(pipeline, sender);
|
let msg = ConstellationMsg::JointSessionHistoryLength(pipeline, sender);
|
||||||
let _ = self.window.constellation_chan().send(msg);
|
let _ = global_scope.constellation_chan().send(msg);
|
||||||
recv.recv().unwrap()
|
recv.recv().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ use dom::bindings::str::DOMString;
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
|
use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::htmlelement::HTMLElement;
|
use dom::htmlelement::HTMLElement;
|
||||||
use dom::node::{Node, document_from_node, window_from_node};
|
use dom::node::{Node, document_from_node, window_from_node};
|
||||||
use dom::virtualmethods::VirtualMethods;
|
use dom::virtualmethods::VirtualMethods;
|
||||||
|
@ -137,7 +138,7 @@ impl VirtualMethods for HTMLBodyElement {
|
||||||
let document = window.Document();
|
let document = window.Document();
|
||||||
document.set_reflow_timeout(time::precise_time_ns() + INITIAL_REFLOW_DELAY);
|
document.set_reflow_timeout(time::precise_time_ns() + INITIAL_REFLOW_DELAY);
|
||||||
let event = ConstellationMsg::HeadParsed;
|
let event = ConstellationMsg::HeadParsed;
|
||||||
window.constellation_chan().send(event).unwrap();
|
window.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
|
fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
|
||||||
|
|
|
@ -12,7 +12,6 @@ use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLContext
|
||||||
use dom::bindings::codegen::UnionTypes::CanvasRenderingContext2DOrWebGLRenderingContext;
|
use dom::bindings::codegen::UnionTypes::CanvasRenderingContext2DOrWebGLRenderingContext;
|
||||||
use dom::bindings::conversions::ConversionResult;
|
use dom::bindings::conversions::ConversionResult;
|
||||||
use dom::bindings::error::{Error, Fallible};
|
use dom::bindings::error::{Error, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{HeapGCValue, JS, LayoutJS, Root};
|
use dom::bindings::js::{HeapGCValue, JS, LayoutJS, Root};
|
||||||
use dom::bindings::num::Finite;
|
use dom::bindings::num::Finite;
|
||||||
|
@ -20,6 +19,7 @@ use dom::bindings::str::DOMString;
|
||||||
use dom::canvasrenderingcontext2d::{CanvasRenderingContext2D, LayoutCanvasRenderingContext2DHelpers};
|
use dom::canvasrenderingcontext2d::{CanvasRenderingContext2D, LayoutCanvasRenderingContext2DHelpers};
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
|
use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::htmlelement::HTMLElement;
|
use dom::htmlelement::HTMLElement;
|
||||||
use dom::node::{Node, window_from_node};
|
use dom::node::{Node, window_from_node};
|
||||||
use dom::virtualmethods::VirtualMethods;
|
use dom::virtualmethods::VirtualMethods;
|
||||||
|
@ -142,7 +142,7 @@ impl HTMLCanvasElement {
|
||||||
if self.context.borrow().is_none() {
|
if self.context.borrow().is_none() {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
let size = self.get_size();
|
let size = self.get_size();
|
||||||
let context = CanvasRenderingContext2D::new(GlobalRef::Window(window.r()), self, size);
|
let context = CanvasRenderingContext2D::new(window.upcast::<GlobalScope>(), self, size);
|
||||||
*self.context.borrow_mut() = Some(CanvasContext::Context2d(JS::from_ref(&*context)));
|
*self.context.borrow_mut() = Some(CanvasContext::Context2d(JS::from_ref(&*context)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ impl HTMLCanvasElement {
|
||||||
GLContextAttributes::default()
|
GLContextAttributes::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let maybe_ctx = WebGLRenderingContext::new(GlobalRef::Window(window.r()), self, size, attrs);
|
let maybe_ctx = WebGLRenderingContext::new(window.upcast(), self, size, attrs);
|
||||||
|
|
||||||
*self.context.borrow_mut() = maybe_ctx.map( |ctx| CanvasContext::WebGL(JS::from_ref(&*ctx)));
|
*self.context.borrow_mut() = maybe_ctx.map( |ctx| CanvasContext::WebGL(JS::from_ref(&*ctx)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::HTMLCollectionBinding;
|
use dom::bindings::codegen::Bindings::HTMLCollectionBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods;
|
use dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{JS, Root, MutNullableHeap};
|
use dom::bindings::js::{JS, Root, MutNullableHeap};
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
|
@ -83,7 +82,7 @@ impl HTMLCollection {
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, root: &Node, filter: Box<CollectionFilter + 'static>) -> Root<HTMLCollection> {
|
pub fn new(window: &Window, root: &Node, filter: Box<CollectionFilter + 'static>) -> Root<HTMLCollection> {
|
||||||
reflect_dom_object(box HTMLCollection::new_inherited(root, filter),
|
reflect_dom_object(box HTMLCollection::new_inherited(root, filter),
|
||||||
GlobalRef::Window(window), HTMLCollectionBinding::Wrap)
|
window, HTMLCollectionBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create(window: &Window, root: &Node,
|
pub fn create(window: &Window, root: &Node,
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
use dom::attr::Attr;
|
use dom::attr::Attr;
|
||||||
use dom::bindings::codegen::Bindings::HTMLDetailsElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLDetailsElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLDetailsElementBinding::HTMLDetailsElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLDetailsElementBinding::HTMLDetailsElementMethods;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::refcounted::Trusted;
|
use dom::bindings::refcounted::Trusted;
|
||||||
|
@ -79,7 +78,7 @@ impl VirtualMethods for HTMLDetailsElement {
|
||||||
element: details,
|
element: details,
|
||||||
toggle_number: counter
|
toggle_number: counter
|
||||||
};
|
};
|
||||||
let _ = task_source.queue(runnable, GlobalRef::Window(&window));
|
let _ = task_source.queue(runnable, window.upcast());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ use dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMetho
|
||||||
use dom::bindings::codegen::Bindings::HTMLFormControlsCollectionBinding;
|
use dom::bindings::codegen::Bindings::HTMLFormControlsCollectionBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLFormControlsCollectionBinding::HTMLFormControlsCollectionMethods;
|
use dom::bindings::codegen::Bindings::HTMLFormControlsCollectionBinding::HTMLFormControlsCollectionMethods;
|
||||||
use dom::bindings::codegen::UnionTypes::RadioNodeListOrElement;
|
use dom::bindings::codegen::UnionTypes::RadioNodeListOrElement;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
|
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
|
@ -33,7 +32,7 @@ impl HTMLFormControlsCollection {
|
||||||
-> Root<HTMLFormControlsCollection>
|
-> Root<HTMLFormControlsCollection>
|
||||||
{
|
{
|
||||||
reflect_dom_object(box HTMLFormControlsCollection::new_inherited(root, filter),
|
reflect_dom_object(box HTMLFormControlsCollection::new_inherited(root, filter),
|
||||||
GlobalRef::Window(window),
|
window,
|
||||||
HTMLFormControlsCollectionBinding::Wrap)
|
HTMLFormControlsCollectionBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +66,6 @@ impl HTMLFormControlsCollectionMethods for HTMLFormControlsCollection {
|
||||||
let once = iter::once(Root::upcast::<Node>(elem));
|
let once = iter::once(Root::upcast::<Node>(elem));
|
||||||
let list = once.chain(peekable.map(Root::upcast));
|
let list = once.chain(peekable.map(Root::upcast));
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
let global = global.r();
|
|
||||||
let window = global.as_window();
|
let window = global.as_window();
|
||||||
Some(RadioNodeListOrElement::RadioNodeList(RadioNodeList::new_simple_list(window, list)))
|
Some(RadioNodeListOrElement::RadioNodeList(RadioNodeList::new_simple_list(window, list)))
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ use dom::bindings::codegen::Bindings::HTMLFormElementBinding::HTMLFormElementMet
|
||||||
use dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods;
|
||||||
use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods;
|
||||||
use dom::bindings::conversions::DerivedFrom;
|
use dom::bindings::conversions::DerivedFrom;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
|
use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
|
||||||
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
||||||
use dom::bindings::refcounted::Trusted;
|
use dom::bindings::refcounted::Trusted;
|
||||||
|
@ -24,6 +23,7 @@ use dom::element::Element;
|
||||||
use dom::event::{EventBubbles, EventCancelable};
|
use dom::event::{EventBubbles, EventCancelable};
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
use dom::file::File;
|
use dom::file::File;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::htmlbuttonelement::HTMLButtonElement;
|
use dom::htmlbuttonelement::HTMLButtonElement;
|
||||||
use dom::htmlcollection::CollectionFilter;
|
use dom::htmlcollection::CollectionFilter;
|
||||||
use dom::htmldatalistelement::HTMLDataListElement;
|
use dom::htmldatalistelement::HTMLDataListElement;
|
||||||
|
@ -436,14 +436,14 @@ impl HTMLFormElement {
|
||||||
// Step 2
|
// Step 2
|
||||||
let nav = box PlannedNavigation {
|
let nav = box PlannedNavigation {
|
||||||
load_data: load_data,
|
load_data: load_data,
|
||||||
pipeline_id: window.pipeline_id(),
|
pipeline_id: window.upcast::<GlobalScope>().pipeline_id(),
|
||||||
script_chan: window.main_thread_script_chan().clone(),
|
script_chan: window.main_thread_script_chan().clone(),
|
||||||
generation_id: self.generation_id.get(),
|
generation_id: self.generation_id.get(),
|
||||||
form: Trusted::new(self)
|
form: Trusted::new(self)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Step 3
|
// Step 3
|
||||||
window.dom_manipulation_task_source().queue(nav, GlobalRef::Window(&window)).unwrap();
|
window.dom_manipulation_task_source().queue(nav, window.upcast()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Interactively validate the constraints of form elements
|
/// Interactively validate the constraints of form elements
|
||||||
|
|
|
@ -18,7 +18,6 @@ use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElemen
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::conversions::ToJSValConvertible;
|
use dom::bindings::conversions::ToJSValConvertible;
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{JS, LayoutJS, MutNullableHeap, Root};
|
use dom::bindings::js::{JS, LayoutJS, MutNullableHeap, Root};
|
||||||
use dom::bindings::reflector::Reflectable;
|
use dom::bindings::reflector::Reflectable;
|
||||||
|
@ -30,6 +29,7 @@ use dom::domtokenlist::DOMTokenList;
|
||||||
use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
|
use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
|
||||||
use dom::event::Event;
|
use dom::event::Event;
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::htmlelement::HTMLElement;
|
use dom::htmlelement::HTMLElement;
|
||||||
use dom::node::{Node, NodeDamage, UnbindContext, document_from_node, window_from_node};
|
use dom::node::{Node, NodeDamage, UnbindContext, document_from_node, window_from_node};
|
||||||
use dom::urlhelper::UrlHelper;
|
use dom::urlhelper::UrlHelper;
|
||||||
|
@ -126,9 +126,10 @@ impl HTMLIFrameElement {
|
||||||
let private_iframe = self.privatebrowsing();
|
let private_iframe = self.privatebrowsing();
|
||||||
let frame_type = if self.Mozbrowser() { FrameType::MozBrowserIFrame } else { FrameType::IFrame };
|
let frame_type = if self.Mozbrowser() { FrameType::MozBrowserIFrame } else { FrameType::IFrame };
|
||||||
|
|
||||||
|
let global_scope = window.upcast::<GlobalScope>();
|
||||||
let load_info = IFrameLoadInfo {
|
let load_info = IFrameLoadInfo {
|
||||||
load_data: load_data,
|
load_data: load_data,
|
||||||
parent_pipeline_id: window.pipeline_id(),
|
parent_pipeline_id: global_scope.pipeline_id(),
|
||||||
old_pipeline_id: old_pipeline_id,
|
old_pipeline_id: old_pipeline_id,
|
||||||
new_pipeline_id: new_pipeline_id,
|
new_pipeline_id: new_pipeline_id,
|
||||||
sandbox: sandboxed,
|
sandbox: sandboxed,
|
||||||
|
@ -136,7 +137,8 @@ impl HTMLIFrameElement {
|
||||||
frame_type: frame_type,
|
frame_type: frame_type,
|
||||||
replace: replace,
|
replace: replace,
|
||||||
};
|
};
|
||||||
window.constellation_chan()
|
global_scope
|
||||||
|
.constellation_chan()
|
||||||
.send(ConstellationMsg::ScriptLoadedURLInIFrame(load_info))
|
.send(ConstellationMsg::ScriptLoadedURLInIFrame(load_info))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -217,7 +219,7 @@ impl HTMLIFrameElement {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
let window = window.r();
|
let window = window.r();
|
||||||
let msg = ConstellationMsg::SetVisible(pipeline_id, visible);
|
let msg = ConstellationMsg::SetVisible(pipeline_id, visible);
|
||||||
window.constellation_chan().send(msg).unwrap();
|
window.upcast::<GlobalScope>().constellation_chan().send(msg).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +318,7 @@ pub fn build_mozbrowser_custom_event(window: &Window, event: MozBrowserEvent) ->
|
||||||
rooted!(in(cx) let mut detail = UndefinedValue());
|
rooted!(in(cx) let mut detail = UndefinedValue());
|
||||||
let event_name = Atom::from(event.name());
|
let event_name = Atom::from(event.name());
|
||||||
unsafe { build_mozbrowser_event_detail(event, cx, detail.handle_mut()); }
|
unsafe { build_mozbrowser_event_detail(event, cx, detail.handle_mut()); }
|
||||||
CustomEvent::new(GlobalRef::Window(window),
|
CustomEvent::new(window.upcast(),
|
||||||
event_name,
|
event_name,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
|
@ -408,7 +410,7 @@ pub fn Navigate(iframe: &HTMLIFrameElement, direction: TraversalDirection) -> Er
|
||||||
if iframe.upcast::<Node>().is_in_doc() {
|
if iframe.upcast::<Node>().is_in_doc() {
|
||||||
let window = window_from_node(iframe);
|
let window = window_from_node(iframe);
|
||||||
let msg = ConstellationMsg::TraverseHistory(iframe.pipeline_id(), direction);
|
let msg = ConstellationMsg::TraverseHistory(iframe.pipeline_id(), direction);
|
||||||
window.constellation_chan().send(msg).unwrap();
|
window.upcast::<GlobalScope>().constellation_chan().send(msg).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -642,7 +644,7 @@ impl VirtualMethods for HTMLIFrameElement {
|
||||||
(Some(sender), Some(receiver))
|
(Some(sender), Some(receiver))
|
||||||
};
|
};
|
||||||
let msg = ConstellationMsg::RemoveIFrame(pipeline_id, sender);
|
let msg = ConstellationMsg::RemoveIFrame(pipeline_id, sender);
|
||||||
window.constellation_chan().send(msg).unwrap();
|
window.upcast::<GlobalScope>().constellation_chan().send(msg).unwrap();
|
||||||
if let Some(receiver) = receiver {
|
if let Some(receiver) = receiver {
|
||||||
receiver.recv().unwrap()
|
receiver.recv().unwrap()
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ use dom::bindings::codegen::Bindings::HTMLImageElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLImageElementBinding::HTMLImageElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLImageElementBinding::HTMLImageElementMethods;
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{LayoutJS, Root};
|
use dom::bindings::js::{LayoutJS, Root};
|
||||||
use dom::bindings::refcounted::Trusted;
|
use dom::bindings::refcounted::Trusted;
|
||||||
|
@ -17,6 +16,7 @@ use dom::bindings::str::DOMString;
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
|
use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::htmlelement::HTMLElement;
|
use dom::htmlelement::HTMLElement;
|
||||||
use dom::node::{Node, NodeDamage, document_from_node, window_from_node};
|
use dom::node::{Node, NodeDamage, document_from_node, window_from_node};
|
||||||
use dom::values::UNSIGNED_LONG_MAX;
|
use dom::values::UNSIGNED_LONG_MAX;
|
||||||
|
@ -191,7 +191,7 @@ impl HTMLImageElement {
|
||||||
src: src.into(),
|
src: src.into(),
|
||||||
};
|
};
|
||||||
let task = window.dom_manipulation_task_source();
|
let task = window.dom_manipulation_task_source();
|
||||||
let _ = task.queue(runnable, GlobalRef::Window(window));
|
let _ = task.queue(runnable, window.upcast());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ impl HTMLImageElement {
|
||||||
HTMLImageElementBinding::Wrap)
|
HTMLImageElementBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Image(global: GlobalRef,
|
pub fn Image(global: &GlobalScope,
|
||||||
width: Option<u32>,
|
width: Option<u32>,
|
||||||
height: Option<u32>) -> Fallible<Root<HTMLImageElement>> {
|
height: Option<u32>) -> Fallible<Root<HTMLImageElement>> {
|
||||||
let document = global.as_window().Document();
|
let document = global.as_window().Document();
|
||||||
|
|
|
@ -21,6 +21,7 @@ use dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
use dom::file::File;
|
use dom::file::File;
|
||||||
use dom::filelist::FileList;
|
use dom::filelist::FileList;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::htmlelement::HTMLElement;
|
use dom::htmlelement::HTMLElement;
|
||||||
use dom::htmlfieldsetelement::HTMLFieldSetElement;
|
use dom::htmlfieldsetelement::HTMLFieldSetElement;
|
||||||
use dom::htmlformelement::{FormControl, FormDatum, FormDatumValue, FormSubmitter, HTMLFormElement};
|
use dom::htmlformelement::{FormControl, FormDatum, FormDatumValue, FormSubmitter, HTMLFormElement};
|
||||||
|
@ -128,7 +129,7 @@ static DEFAULT_MIN_LENGTH: i32 = -1;
|
||||||
|
|
||||||
impl HTMLInputElement {
|
impl HTMLInputElement {
|
||||||
fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLInputElement {
|
fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLInputElement {
|
||||||
let chan = document.window().constellation_chan().clone();
|
let chan = document.window().upcast::<GlobalScope>().constellation_chan().clone();
|
||||||
HTMLInputElement {
|
HTMLInputElement {
|
||||||
htmlelement:
|
htmlelement:
|
||||||
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE | IN_READ_WRITE_STATE,
|
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE | IN_READ_WRITE_STATE,
|
||||||
|
@ -794,7 +795,7 @@ impl HTMLInputElement {
|
||||||
fn select_files(&self, opt_test_paths: Option<Vec<DOMString>>) {
|
fn select_files(&self, opt_test_paths: Option<Vec<DOMString>>) {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
let origin = get_blob_origin(&window.get_url());
|
let origin = get_blob_origin(&window.get_url());
|
||||||
let resource_threads = window.resource_threads();
|
let resource_threads = window.upcast::<GlobalScope>().resource_threads();
|
||||||
|
|
||||||
let mut files: Vec<Root<File>> = vec![];
|
let mut files: Vec<Root<File>> = vec![];
|
||||||
let mut error = None;
|
let mut error = None;
|
||||||
|
|
|
@ -18,6 +18,7 @@ use dom::document::Document;
|
||||||
use dom::domtokenlist::DOMTokenList;
|
use dom::domtokenlist::DOMTokenList;
|
||||||
use dom::element::{AttributeMutation, Element, ElementCreator};
|
use dom::element::{AttributeMutation, Element, ElementCreator};
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::htmlelement::HTMLElement;
|
use dom::htmlelement::HTMLElement;
|
||||||
use dom::node::{Node, document_from_node, window_from_node};
|
use dom::node::{Node, document_from_node, window_from_node};
|
||||||
use dom::virtualmethods::VirtualMethods;
|
use dom::virtualmethods::VirtualMethods;
|
||||||
|
@ -266,7 +267,7 @@ impl HTMLLinkElement {
|
||||||
credentials_mode: CredentialsMode::Include,
|
credentials_mode: CredentialsMode::Include,
|
||||||
use_url_credentials: true,
|
use_url_credentials: true,
|
||||||
origin: document.url().clone(),
|
origin: document.url().clone(),
|
||||||
pipeline_id: Some(self.global().r().pipeline_id()),
|
pipeline_id: Some(self.global().pipeline_id()),
|
||||||
referrer_url: Some(document.url().clone()),
|
referrer_url: Some(document.url().clone()),
|
||||||
referrer_policy: referrer_policy,
|
referrer_policy: referrer_policy,
|
||||||
.. RequestInit::default()
|
.. RequestInit::default()
|
||||||
|
@ -280,7 +281,7 @@ impl HTMLLinkElement {
|
||||||
match document.base_url().join(href) {
|
match document.base_url().join(href) {
|
||||||
Ok(url) => {
|
Ok(url) => {
|
||||||
let event = ConstellationMsg::NewFavicon(url.clone());
|
let event = ConstellationMsg::NewFavicon(url.clone());
|
||||||
document.window().constellation_chan().send(event).unwrap();
|
document.window().upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
|
||||||
|
|
||||||
let mozbrowser_event = match *sizes {
|
let mozbrowser_event = match *sizes {
|
||||||
Some(ref sizes) => MozBrowserEvent::IconChange(rel.to_owned(), url.to_string(), sizes.to_owned()),
|
Some(ref sizes) => MozBrowserEvent::IconChange(rel.to_owned(), url.to_string(), sizes.to_owned()),
|
||||||
|
|
|
@ -12,7 +12,6 @@ use dom::bindings::codegen::Bindings::HTMLMediaElementBinding::HTMLMediaElementC
|
||||||
use dom::bindings::codegen::Bindings::HTMLMediaElementBinding::HTMLMediaElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLMediaElementBinding::HTMLMediaElementMethods;
|
||||||
use dom::bindings::codegen::Bindings::MediaErrorBinding::MediaErrorConstants::*;
|
use dom::bindings::codegen::Bindings::MediaErrorBinding::MediaErrorConstants::*;
|
||||||
use dom::bindings::codegen::Bindings::MediaErrorBinding::MediaErrorMethods;
|
use dom::bindings::codegen::Bindings::MediaErrorBinding::MediaErrorMethods;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{Root, MutNullableHeap, JS};
|
use dom::bindings::js::{Root, MutNullableHeap, JS};
|
||||||
use dom::bindings::refcounted::Trusted;
|
use dom::bindings::refcounted::Trusted;
|
||||||
|
@ -276,7 +275,7 @@ impl HTMLMediaElement {
|
||||||
elem: Trusted::new(self),
|
elem: Trusted::new(self),
|
||||||
};
|
};
|
||||||
let win = window_from_node(self);
|
let win = window_from_node(self);
|
||||||
let _ = win.dom_manipulation_task_source().queue(task, GlobalRef::Window(&win));
|
let _ = win.dom_manipulation_task_source().queue(task, win.upcast());
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#internal-pause-steps step 2.2
|
// https://html.spec.whatwg.org/multipage/#internal-pause-steps step 2.2
|
||||||
|
@ -300,18 +299,18 @@ impl HTMLMediaElement {
|
||||||
elem: Trusted::new(self),
|
elem: Trusted::new(self),
|
||||||
};
|
};
|
||||||
let win = window_from_node(self);
|
let win = window_from_node(self);
|
||||||
let _ = win.dom_manipulation_task_source().queue(task, GlobalRef::Window(&win));
|
let _ = win.dom_manipulation_task_source().queue(task, win.upcast());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn queue_fire_simple_event(&self, type_: &'static str) {
|
fn queue_fire_simple_event(&self, type_: &'static str) {
|
||||||
let win = window_from_node(self);
|
let win = window_from_node(self);
|
||||||
let task = box FireSimpleEventTask::new(self, type_);
|
let task = box FireSimpleEventTask::new(self, type_);
|
||||||
let _ = win.dom_manipulation_task_source().queue(task, GlobalRef::Window(&win));
|
let _ = win.dom_manipulation_task_source().queue(task, win.upcast());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fire_simple_event(&self, type_: &str) {
|
fn fire_simple_event(&self, type_: &str) {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
let event = Event::new(GlobalRef::Window(&*window),
|
let event = Event::new(window.upcast(),
|
||||||
Atom::from(type_),
|
Atom::from(type_),
|
||||||
EventBubbles::DoesNotBubble,
|
EventBubbles::DoesNotBubble,
|
||||||
EventCancelable::NotCancelable);
|
EventCancelable::NotCancelable);
|
||||||
|
@ -533,8 +532,8 @@ impl HTMLMediaElement {
|
||||||
|
|
||||||
fn queue_dedicated_media_source_failure_steps(&self) {
|
fn queue_dedicated_media_source_failure_steps(&self) {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
let _ = window.dom_manipulation_task_source().queue(box DedicatedMediaSourceFailureTask::new(self),
|
let _ = window.dom_manipulation_task_source().queue(
|
||||||
GlobalRef::Window(&window));
|
box DedicatedMediaSourceFailureTask::new(self), window.upcast());
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dedicated-media-source-failure-steps
|
// https://html.spec.whatwg.org/multipage/#dedicated-media-source-failure-steps
|
||||||
|
|
|
@ -9,7 +9,6 @@ use dom::bindings::codegen::Bindings::HTMLOptionsCollectionBinding::HTMLOptionsC
|
||||||
use dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::NodeMethods;
|
use dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::NodeMethods;
|
||||||
use dom::bindings::codegen::UnionTypes::{HTMLOptionElementOrHTMLOptGroupElement, HTMLElementOrLong};
|
use dom::bindings::codegen::UnionTypes::{HTMLOptionElementOrHTMLOptGroupElement, HTMLElementOrLong};
|
||||||
use dom::bindings::error::{Error, ErrorResult};
|
use dom::bindings::error::{Error, ErrorResult};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{Root, RootedReference};
|
use dom::bindings::js::{Root, RootedReference};
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
|
@ -36,7 +35,7 @@ impl HTMLOptionsCollection {
|
||||||
-> Root<HTMLOptionsCollection>
|
-> Root<HTMLOptionsCollection>
|
||||||
{
|
{
|
||||||
reflect_dom_object(box HTMLOptionsCollection::new_inherited(root, filter),
|
reflect_dom_object(box HTMLOptionsCollection::new_inherited(root, filter),
|
||||||
GlobalRef::Window(window),
|
window,
|
||||||
HTMLOptionsCollectionBinding::Wrap)
|
HTMLOptionsCollectionBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
||||||
use dom::bindings::codegen::Bindings::HTMLScriptElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLScriptElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLScriptElementBinding::HTMLScriptElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLScriptElementBinding::HTMLScriptElementMethods;
|
||||||
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{JS, Root};
|
use dom::bindings::js::{JS, Root};
|
||||||
use dom::bindings::js::RootedReference;
|
use dom::bindings::js::RootedReference;
|
||||||
|
@ -21,6 +20,7 @@ use dom::document::Document;
|
||||||
use dom::element::{AttributeMutation, Element, ElementCreator};
|
use dom::element::{AttributeMutation, Element, ElementCreator};
|
||||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
use dom::eventdispatcher::EventStatus;
|
use dom::eventdispatcher::EventStatus;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::htmlelement::HTMLElement;
|
use dom::htmlelement::HTMLElement;
|
||||||
use dom::node::{ChildrenMutation, CloneChildrenFlag, Node};
|
use dom::node::{ChildrenMutation, CloneChildrenFlag, Node};
|
||||||
use dom::node::{document_from_node, window_from_node};
|
use dom::node::{document_from_node, window_from_node};
|
||||||
|
@ -242,7 +242,7 @@ fn fetch_a_classic_script(script: &HTMLScriptElement,
|
||||||
_ => CredentialsMode::Include,
|
_ => CredentialsMode::Include,
|
||||||
},
|
},
|
||||||
origin: doc.url().clone(),
|
origin: doc.url().clone(),
|
||||||
pipeline_id: Some(script.global().r().pipeline_id()),
|
pipeline_id: Some(script.global().pipeline_id()),
|
||||||
referrer_url: Some(doc.url().clone()),
|
referrer_url: Some(doc.url().clone()),
|
||||||
referrer_policy: doc.get_referrer_policy(),
|
referrer_policy: doc.get_referrer_policy(),
|
||||||
.. RequestInit::default()
|
.. RequestInit::default()
|
||||||
|
@ -504,7 +504,7 @@ impl HTMLScriptElement {
|
||||||
// Step 5.a.2.
|
// Step 5.a.2.
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
rooted!(in(window.get_cx()) let mut rval = UndefinedValue());
|
rooted!(in(window.get_cx()) let mut rval = UndefinedValue());
|
||||||
GlobalRef::Window(&window).evaluate_script_on_global_with_result(
|
window.upcast::<GlobalScope>().evaluate_script_on_global_with_result(
|
||||||
&script.text, script.url.as_str(), rval.handle_mut());
|
&script.text, script.url.as_str(), rval.handle_mut());
|
||||||
|
|
||||||
// Step 6.
|
// Step 6.
|
||||||
|
@ -604,7 +604,7 @@ impl HTMLScriptElement {
|
||||||
cancelable: EventCancelable) -> EventStatus {
|
cancelable: EventCancelable) -> EventStatus {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
let window = window.r();
|
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())
|
event.fire(self.upcast())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ use dom::document::Document;
|
||||||
use dom::element::{AttributeMutation, Element};
|
use dom::element::{AttributeMutation, Element};
|
||||||
use dom::element::RawLayoutElementHelpers;
|
use dom::element::RawLayoutElementHelpers;
|
||||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::htmlelement::HTMLElement;
|
use dom::htmlelement::HTMLElement;
|
||||||
use dom::htmlfieldsetelement::HTMLFieldSetElement;
|
use dom::htmlfieldsetelement::HTMLFieldSetElement;
|
||||||
use dom::htmlformelement::{FormControl, HTMLFormElement};
|
use dom::htmlformelement::{FormControl, HTMLFormElement};
|
||||||
|
@ -99,7 +100,7 @@ impl HTMLTextAreaElement {
|
||||||
fn new_inherited(local_name: Atom,
|
fn new_inherited(local_name: Atom,
|
||||||
prefix: Option<DOMString>,
|
prefix: Option<DOMString>,
|
||||||
document: &Document) -> HTMLTextAreaElement {
|
document: &Document) -> HTMLTextAreaElement {
|
||||||
let chan = document.window().constellation_chan().clone();
|
let chan = document.window().upcast::<GlobalScope>().constellation_chan().clone();
|
||||||
HTMLTextAreaElement {
|
HTMLTextAreaElement {
|
||||||
htmlelement:
|
htmlelement:
|
||||||
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE | IN_READ_WRITE_STATE,
|
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE | IN_READ_WRITE_STATE,
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
use core::nonzero::NonZero;
|
use core::nonzero::NonZero;
|
||||||
use dom::bindings::codegen::Bindings::ImageDataBinding;
|
use dom::bindings::codegen::Bindings::ImageDataBinding;
|
||||||
use dom::bindings::codegen::Bindings::ImageDataBinding::ImageDataMethods;
|
use dom::bindings::codegen::Bindings::ImageDataBinding::ImageDataMethods;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use euclid::size::Size2D;
|
use euclid::size::Size2D;
|
||||||
use js::jsapi::{Heap, JSContext, JSObject};
|
use js::jsapi::{Heap, JSContext, JSObject};
|
||||||
use js::jsapi::{JS_GetUint8ClampedArrayData, JS_NewUint8ClampedArray};
|
use js::jsapi::{JS_GetUint8ClampedArrayData, JS_NewUint8ClampedArray};
|
||||||
|
@ -27,7 +27,7 @@ pub struct ImageData {
|
||||||
|
|
||||||
impl ImageData {
|
impl ImageData {
|
||||||
#[allow(unsafe_code)]
|
#[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 {
|
let mut imagedata = box ImageData {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
width: width,
|
width: width,
|
||||||
|
|
|
@ -7,12 +7,12 @@ use dom::bindings::codegen::Bindings::KeyboardEventBinding;
|
||||||
use dom::bindings::codegen::Bindings::KeyboardEventBinding::{KeyboardEventConstants, KeyboardEventMethods};
|
use dom::bindings::codegen::Bindings::KeyboardEventBinding::{KeyboardEventConstants, KeyboardEventMethods};
|
||||||
use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
|
use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{Root, RootedReference};
|
use dom::bindings::js::{Root, RootedReference};
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::event::Event;
|
use dom::event::Event;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::uievent::UIEvent;
|
use dom::uievent::UIEvent;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use msg::constellation_msg;
|
use msg::constellation_msg;
|
||||||
|
@ -62,7 +62,7 @@ impl KeyboardEvent {
|
||||||
|
|
||||||
pub fn new_uninitialized(window: &Window) -> Root<KeyboardEvent> {
|
pub fn new_uninitialized(window: &Window) -> Root<KeyboardEvent> {
|
||||||
reflect_dom_object(box KeyboardEvent::new_inherited(),
|
reflect_dom_object(box KeyboardEvent::new_inherited(),
|
||||||
GlobalRef::Window(window),
|
window,
|
||||||
KeyboardEventBinding::Wrap)
|
KeyboardEventBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,10 +101,11 @@ impl KeyboardEvent {
|
||||||
ev
|
ev
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &KeyboardEventBinding::KeyboardEventInit) -> Fallible<Root<KeyboardEvent>> {
|
init: &KeyboardEventBinding::KeyboardEventInit) -> Fallible<Root<KeyboardEvent>> {
|
||||||
let event = KeyboardEvent::new(global.as_window(), type_,
|
let event = KeyboardEvent::new(global.as_window(),
|
||||||
|
type_,
|
||||||
init.parent.parent.parent.bubbles,
|
init.parent.parent.parent.bubbles,
|
||||||
init.parent.parent.parent.cancelable,
|
init.parent.parent.parent.cancelable,
|
||||||
init.parent.parent.view.r(),
|
init.parent.parent.view.r(),
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
use dom::bindings::codegen::Bindings::LocationBinding;
|
use dom::bindings::codegen::Bindings::LocationBinding;
|
||||||
use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods;
|
use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods;
|
||||||
use dom::bindings::error::{Error, ErrorResult};
|
use dom::bindings::error::{Error, ErrorResult};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::{JS, Root};
|
use dom::bindings::js::{JS, Root};
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::str::{DOMString, USVString};
|
use dom::bindings::str::{DOMString, USVString};
|
||||||
|
@ -29,7 +28,7 @@ impl Location {
|
||||||
|
|
||||||
pub fn new(window: &Window) -> Root<Location> {
|
pub fn new(window: &Window) -> Root<Location> {
|
||||||
reflect_dom_object(box Location::new_inherited(window),
|
reflect_dom_object(box Location::new_inherited(window),
|
||||||
GlobalRef::Window(window),
|
window,
|
||||||
LocationBinding::Wrap)
|
LocationBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::MediaErrorBinding::{self, MediaErrorMethods};
|
use dom::bindings::codegen::Bindings::MediaErrorBinding::{self, MediaErrorMethods};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
|
@ -24,7 +23,7 @@ impl MediaError {
|
||||||
|
|
||||||
pub fn new(window: &Window, code: u16) -> Root<MediaError> {
|
pub fn new(window: &Window, code: u16) -> Root<MediaError> {
|
||||||
reflect_dom_object(box MediaError::new_inherited(code),
|
reflect_dom_object(box MediaError::new_inherited(code),
|
||||||
GlobalRef::Window(window),
|
window,
|
||||||
MediaErrorBinding::Wrap)
|
MediaErrorBinding::Wrap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,13 @@ use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||||
use dom::bindings::codegen::Bindings::MessageEventBinding;
|
use dom::bindings::codegen::Bindings::MessageEventBinding;
|
||||||
use dom::bindings::codegen::Bindings::MessageEventBinding::MessageEventMethods;
|
use dom::bindings::codegen::Bindings::MessageEventBinding::MessageEventMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::event::Event;
|
use dom::event::Event;
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use js::jsapi::{HandleValue, Heap, JSContext};
|
use js::jsapi::{HandleValue, Heap, JSContext};
|
||||||
use js::jsval::JSVal;
|
use js::jsval::JSVal;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
|
@ -27,14 +27,14 @@ pub struct MessageEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MessageEvent {
|
impl MessageEvent {
|
||||||
pub fn new_uninitialized(global: GlobalRef) -> Root<MessageEvent> {
|
pub fn new_uninitialized(global: &GlobalScope) -> Root<MessageEvent> {
|
||||||
MessageEvent::new_initialized(global,
|
MessageEvent::new_initialized(global,
|
||||||
HandleValue::undefined(),
|
HandleValue::undefined(),
|
||||||
DOMString::new(),
|
DOMString::new(),
|
||||||
DOMString::new())
|
DOMString::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_initialized(global: GlobalRef,
|
pub fn new_initialized(global: &GlobalScope,
|
||||||
data: HandleValue,
|
data: HandleValue,
|
||||||
origin: DOMString,
|
origin: DOMString,
|
||||||
lastEventId: DOMString) -> Root<MessageEvent> {
|
lastEventId: DOMString) -> Root<MessageEvent> {
|
||||||
|
@ -48,7 +48,7 @@ impl MessageEvent {
|
||||||
reflect_dom_object(ev, global, MessageEventBinding::Wrap)
|
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,
|
bubbles: bool, cancelable: bool,
|
||||||
data: HandleValue, origin: DOMString, lastEventId: DOMString)
|
data: HandleValue, origin: DOMString, lastEventId: DOMString)
|
||||||
-> Root<MessageEvent> {
|
-> Root<MessageEvent> {
|
||||||
|
@ -60,27 +60,36 @@ impl MessageEvent {
|
||||||
ev
|
ev
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &MessageEventBinding::MessageEventInit)
|
init: &MessageEventBinding::MessageEventInit)
|
||||||
-> Fallible<Root<MessageEvent>> {
|
-> Fallible<Root<MessageEvent>> {
|
||||||
// Dictionaries need to be rooted
|
// Dictionaries need to be rooted
|
||||||
// https://github.com/servo/servo/issues/6381
|
// https://github.com/servo/servo/issues/6381
|
||||||
rooted!(in(global.get_cx()) let data = init.data);
|
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,
|
||||||
|
Atom::from(type_),
|
||||||
|
init.parent.bubbles,
|
||||||
|
init.parent.cancelable,
|
||||||
data.handle(),
|
data.handle(),
|
||||||
init.origin.clone(), init.lastEventId.clone());
|
init.origin.clone(),
|
||||||
|
init.lastEventId.clone());
|
||||||
Ok(ev)
|
Ok(ev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MessageEvent {
|
impl MessageEvent {
|
||||||
pub fn dispatch_jsval(target: &EventTarget,
|
pub fn dispatch_jsval(target: &EventTarget,
|
||||||
scope: GlobalRef,
|
scope: &GlobalScope,
|
||||||
message: HandleValue) {
|
message: HandleValue) {
|
||||||
let messageevent = MessageEvent::new(
|
let messageevent = MessageEvent::new(
|
||||||
scope, atom!("message"), false, false, message,
|
scope,
|
||||||
DOMString::new(), DOMString::new());
|
atom!("message"),
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
message,
|
||||||
|
DOMString::new(),
|
||||||
|
DOMString::new());
|
||||||
messageevent.upcast::<Event>().fire(target);
|
messageevent.upcast::<Event>().fire(target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::MimeTypeArrayBinding;
|
use dom::bindings::codegen::Bindings::MimeTypeArrayBinding;
|
||||||
use dom::bindings::codegen::Bindings::MimeTypeArrayBinding::MimeTypeArrayMethods;
|
use dom::bindings::codegen::Bindings::MimeTypeArrayBinding::MimeTypeArrayMethods;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::mimetype::MimeType;
|
use dom::mimetype::MimeType;
|
||||||
|
|
||||||
#[dom_struct]
|
#[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(),
|
reflect_dom_object(box MimeTypeArray::new_inherited(),
|
||||||
global,
|
global,
|
||||||
MimeTypeArrayBinding::Wrap)
|
MimeTypeArrayBinding::Wrap)
|
||||||
|
|
|
@ -276,6 +276,7 @@ pub mod filereadersync;
|
||||||
pub mod focusevent;
|
pub mod focusevent;
|
||||||
pub mod forcetouchevent;
|
pub mod forcetouchevent;
|
||||||
pub mod formdata;
|
pub mod formdata;
|
||||||
|
pub mod globalscope;
|
||||||
pub mod hashchangeevent;
|
pub mod hashchangeevent;
|
||||||
pub mod headers;
|
pub mod headers;
|
||||||
pub mod history;
|
pub mod history;
|
||||||
|
|
|
@ -6,13 +6,13 @@ use dom::bindings::codegen::Bindings::MouseEventBinding;
|
||||||
use dom::bindings::codegen::Bindings::MouseEventBinding::MouseEventMethods;
|
use dom::bindings::codegen::Bindings::MouseEventBinding::MouseEventMethods;
|
||||||
use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
|
use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference};
|
use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference};
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::uievent::UIEvent;
|
use dom::uievent::UIEvent;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
@ -53,7 +53,7 @@ impl MouseEvent {
|
||||||
|
|
||||||
pub fn new_uninitialized(window: &Window) -> Root<MouseEvent> {
|
pub fn new_uninitialized(window: &Window) -> Root<MouseEvent> {
|
||||||
reflect_dom_object(box MouseEvent::new_inherited(),
|
reflect_dom_object(box MouseEvent::new_inherited(),
|
||||||
GlobalRef::Window(window),
|
window,
|
||||||
MouseEventBinding::Wrap)
|
MouseEventBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,12 +82,13 @@ impl MouseEvent {
|
||||||
ev
|
ev
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &MouseEventBinding::MouseEventInit) -> Fallible<Root<MouseEvent>> {
|
init: &MouseEventBinding::MouseEventInit) -> Fallible<Root<MouseEvent>> {
|
||||||
let bubbles = EventBubbles::from(init.parent.parent.parent.bubbles);
|
let bubbles = EventBubbles::from(init.parent.parent.parent.bubbles);
|
||||||
let cancelable = EventCancelable::from(init.parent.parent.parent.cancelable);
|
let cancelable = EventCancelable::from(init.parent.parent.parent.cancelable);
|
||||||
let event = MouseEvent::new(global.as_window(), type_,
|
let event = MouseEvent::new(global.as_window(),
|
||||||
|
type_,
|
||||||
bubbles,
|
bubbles,
|
||||||
cancelable,
|
cancelable,
|
||||||
init.parent.parent.view.r(),
|
init.parent.parent.view.r(),
|
||||||
|
|
|
@ -7,7 +7,6 @@ use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
|
||||||
use dom::bindings::codegen::Bindings::NamedNodeMapBinding;
|
use dom::bindings::codegen::Bindings::NamedNodeMapBinding;
|
||||||
use dom::bindings::codegen::Bindings::NamedNodeMapBinding::NamedNodeMapMethods;
|
use dom::bindings::codegen::Bindings::NamedNodeMapBinding::NamedNodeMapMethods;
|
||||||
use dom::bindings::error::{Error, Fallible};
|
use dom::bindings::error::{Error, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::{JS, Root};
|
use dom::bindings::js::{JS, Root};
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
|
@ -33,7 +32,7 @@ impl NamedNodeMap {
|
||||||
|
|
||||||
pub fn new(window: &Window, elem: &Element) -> Root<NamedNodeMap> {
|
pub fn new(window: &Window, elem: &Element) -> Root<NamedNodeMap> {
|
||||||
reflect_dom_object(box NamedNodeMap::new_inherited(elem),
|
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;
|
||||||
use dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods;
|
use dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
||||||
use dom::bindings::reflector::{Reflector, Reflectable, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, Reflectable, reflect_dom_object};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
|
@ -37,7 +36,7 @@ impl Navigator {
|
||||||
|
|
||||||
pub fn new(window: &Window) -> Root<Navigator> {
|
pub fn new(window: &Window) -> Root<Navigator> {
|
||||||
reflect_dom_object(box Navigator::new_inherited(),
|
reflect_dom_object(box Navigator::new_inherited(),
|
||||||
GlobalRef::Window(window),
|
window,
|
||||||
NavigatorBinding::Wrap)
|
NavigatorBinding::Wrap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +79,7 @@ impl NavigatorMethods for Navigator {
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-navigator-bluetooth
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-navigator-bluetooth
|
||||||
fn Bluetooth(&self) -> Root<Bluetooth> {
|
fn Bluetooth(&self) -> Root<Bluetooth> {
|
||||||
self.bluetooth.or_init(|| Bluetooth::new(self.global().r()))
|
self.bluetooth.or_init(|| Bluetooth::new(&self.global()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#navigatorlanguage
|
// https://html.spec.whatwg.org/multipage/#navigatorlanguage
|
||||||
|
@ -90,12 +89,12 @@ impl NavigatorMethods for Navigator {
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-plugins
|
// https://html.spec.whatwg.org/multipage/#dom-navigator-plugins
|
||||||
fn Plugins(&self) -> Root<PluginArray> {
|
fn Plugins(&self) -> Root<PluginArray> {
|
||||||
self.plugins.or_init(|| PluginArray::new(self.global().r()))
|
self.plugins.or_init(|| PluginArray::new(&self.global()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-mimetypes
|
// https://html.spec.whatwg.org/multipage/#dom-navigator-mimetypes
|
||||||
fn MimeTypes(&self) -> Root<MimeTypeArray> {
|
fn MimeTypes(&self) -> Root<MimeTypeArray> {
|
||||||
self.mime_types.or_init(|| MimeTypeArray::new(self.global().r()))
|
self.mime_types.or_init(|| MimeTypeArray::new(&self.global()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-javaenabled
|
// 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
|
// https://w3c.github.io/ServiceWorker/#navigator-service-worker-attribute
|
||||||
fn ServiceWorker(&self) -> Root<ServiceWorkerContainer> {
|
fn ServiceWorker(&self) -> Root<ServiceWorkerContainer> {
|
||||||
self.service_worker.or_init(|| ServiceWorkerContainer::new(self.global().r()))
|
self.service_worker.or_init(|| {
|
||||||
|
ServiceWorkerContainer::new(&self.global())
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-cookieenabled
|
// 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::codegen::UnionTypes::NodeOrString;
|
||||||
use dom::bindings::conversions::{self, DerivedFrom};
|
use dom::bindings::conversions::{self, DerivedFrom};
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::{Castable, CharacterDataTypeId, ElementTypeId};
|
use dom::bindings::inheritance::{Castable, CharacterDataTypeId, ElementTypeId};
|
||||||
use dom::bindings::inheritance::{EventTargetTypeId, HTMLElementTypeId, NodeTypeId};
|
use dom::bindings::inheritance::{EventTargetTypeId, HTMLElementTypeId, NodeTypeId};
|
||||||
use dom::bindings::js::{JS, LayoutJS, MutNullableHeap};
|
use dom::bindings::js::{JS, LayoutJS, MutNullableHeap};
|
||||||
|
@ -35,6 +34,7 @@ use dom::documentfragment::DocumentFragment;
|
||||||
use dom::documenttype::DocumentType;
|
use dom::documenttype::DocumentType;
|
||||||
use dom::element::{Element, ElementCreator};
|
use dom::element::{Element, ElementCreator};
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::htmlbodyelement::HTMLBodyElement;
|
use dom::htmlbodyelement::HTMLBodyElement;
|
||||||
use dom::htmlcanvaselement::LayoutHTMLCanvasElementHelpers;
|
use dom::htmlcanvaselement::LayoutHTMLCanvasElementHelpers;
|
||||||
use dom::htmlcollection::HTMLCollection;
|
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 }
|
fn as_uintptr<T>(t: &T) -> uintptr_t { t as *const T as uintptr_t }
|
||||||
|
|
||||||
impl Node {
|
impl Node {
|
||||||
pub fn reflect_node<N: DerivedFrom<Node> + Reflectable>
|
pub fn reflect_node<N>(
|
||||||
(node: Box<N>,
|
node: Box<N>,
|
||||||
document: &Document,
|
document: &Document,
|
||||||
wrap_fn: extern "Rust" fn(*mut JSContext, GlobalRef, Box<N>) -> Root<N>)
|
wrap_fn: extern "Rust" fn(*mut JSContext, &GlobalScope, Box<N>) -> Root<N>)
|
||||||
-> Root<N> {
|
-> Root<N>
|
||||||
|
where N: DerivedFrom<Node> + Reflectable
|
||||||
|
{
|
||||||
let window = document.window();
|
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 {
|
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;
|
||||||
use dom::bindings::codegen::Bindings::NodeIteratorBinding::NodeIteratorMethods;
|
use dom::bindings::codegen::Bindings::NodeIteratorBinding::NodeIteratorMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::{JS, MutHeap, Root};
|
use dom::bindings::js::{JS, MutHeap, Root};
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
|
@ -48,7 +47,7 @@ impl NodeIterator {
|
||||||
what_to_show: u32,
|
what_to_show: u32,
|
||||||
filter: Filter) -> Root<NodeIterator> {
|
filter: Filter) -> Root<NodeIterator> {
|
||||||
reflect_dom_object(box NodeIterator::new_inherited(root_node, what_to_show, filter),
|
reflect_dom_object(box NodeIterator::new_inherited(root_node, what_to_show, filter),
|
||||||
GlobalRef::Window(document.window()),
|
document.window(),
|
||||||
NodeIteratorBinding::Wrap)
|
NodeIteratorBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
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