mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Pass a &GlobalScope to WebIDL static methods and constructors
This commit is contained in:
parent
1fd470889d
commit
19108aa330
56 changed files with 198 additions and 245 deletions
|
@ -3438,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.r().as_global_scope()"], nativeName, True, self.descriptor, self.method)
|
||||||
return CGList([setupArgs, call])
|
return CGList([setupArgs, call])
|
||||||
|
|
||||||
|
|
||||||
|
@ -3492,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.r().as_global_scope()"], self.attr.type, nativeName, self.descriptor,
|
||||||
self.attr)
|
self.attr)
|
||||||
return CGList([setupArgs, call])
|
return CGList([setupArgs, call])
|
||||||
|
|
||||||
|
@ -3545,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.r().as_global_scope()"], self.attr.type, nativeName, self.descriptor,
|
||||||
self.attr)
|
self.attr)
|
||||||
return CGList([checkForArg, call])
|
return CGList([checkForArg, call])
|
||||||
|
|
||||||
|
@ -5257,7 +5257,7 @@ 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.r().as_global_scope()"], nativeName, True,
|
||||||
self.descriptor, self.constructor)
|
self.descriptor, self.constructor)
|
||||||
return CGList([preamble, callGenerator])
|
return CGList([preamble, callGenerator])
|
||||||
|
|
||||||
|
|
|
@ -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).
|
||||||
|
|
|
@ -7,7 +7,6 @@ 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;
|
||||||
|
@ -121,7 +120,7 @@ impl Blob {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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>> {
|
||||||
|
@ -134,7 +133,7 @@ impl Blob {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Blob::new(global.as_global_scope(), BlobImpl::new_from_bytes(bytes), blobPropertyBag.type_.to_string()))
|
Ok(Blob::new(global, BlobImpl::new_from_bytes(bytes), blobPropertyBag.type_.to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a slice to inner data, this might incur synchronous read and caching
|
/// Get a slice to inner data, this might incur synchronous read and caching
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ 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;
|
||||||
|
@ -58,13 +57,13 @@ 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>> {
|
||||||
let bubbles = EventBubbles::from(init.parent.bubbles);
|
let bubbles = EventBubbles::from(init.parent.bubbles);
|
||||||
let cancelable = EventCancelable::from(init.parent.cancelable);
|
let cancelable = EventCancelable::from(init.parent.cancelable);
|
||||||
Ok(CloseEvent::new(global.as_global_scope(),
|
Ok(CloseEvent::new(global,
|
||||||
Atom::from(type_),
|
Atom::from(type_),
|
||||||
bubbles,
|
bubbles,
|
||||||
cancelable,
|
cancelable,
|
||||||
|
|
|
@ -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,8 +31,8 @@ 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_global_scope().as_window().Document();
|
let document = global.as_window().Document();
|
||||||
Ok(Comment::new(data, document.r()))
|
Ok(Comment::new(data, document.r()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 devtools_traits::{ConsoleMessage, LogLevel, ScriptToDevtoolsControlMsg};
|
use devtools_traits::{ConsoleMessage, LogLevel, ScriptToDevtoolsControlMsg};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
|
@ -30,71 +29,71 @@ 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.as_global_scope(), LogLevel::Log, message);
|
Self::send_to_devtools(global, LogLevel::Log, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.as_global_scope(), LogLevel::Debug, message);
|
Self::send_to_devtools(global, LogLevel::Debug, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.as_global_scope(), LogLevel::Info, message);
|
Self::send_to_devtools(global, LogLevel::Info, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.as_global_scope(), LogLevel::Warn, message);
|
Self::send_to_devtools(global, LogLevel::Warn, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.as_global_scope(), LogLevel::Error, message);
|
Self::send_to_devtools(global, LogLevel::Error, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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);
|
||||||
Self::send_to_devtools(global.as_global_scope(), LogLevel::Error, message);
|
Self::send_to_devtools(global, LogLevel::Error, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.as_global_scope().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.as_global_scope(), LogLevel::Log, message);
|
Self::send_to_devtools(global, LogLevel::Log, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.as_global_scope().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)
|
||||||
);
|
);
|
||||||
println!("{}", message);
|
println!("{}", message);
|
||||||
Self::send_to_devtools(global.as_global_scope(), LogLevel::Log, message);
|
Self::send_to_devtools(global, LogLevel::Log, message);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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))
|
||||||
|
|
|
@ -6,7 +6,6 @@ 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;
|
||||||
|
@ -48,12 +47,13 @@ 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>> {
|
||||||
Ok(CustomEvent::new(global.as_global_scope(),
|
Ok(CustomEvent::new(global,
|
||||||
Atom::from(type_),
|
Atom::from(type_),
|
||||||
init.parent.bubbles,
|
init.parent.bubbles,
|
||||||
init.parent.cancelable,
|
init.parent.cancelable,
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -1819,8 +1818,8 @@ 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_global_scope().as_window();
|
let win = global.as_window();
|
||||||
let doc = win.Document();
|
let doc = win.Document();
|
||||||
let doc = doc.r();
|
let doc = doc.r();
|
||||||
let docloader = DocumentLoader::new(&*doc.loader());
|
let docloader = DocumentLoader::new(&*doc.loader());
|
||||||
|
|
|
@ -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,8 +38,8 @@ 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_global_scope().as_window().Document();
|
let document = global.as_window().Document();
|
||||||
|
|
||||||
Ok(DocumentFragment::new(document.r()))
|
Ok(DocumentFragment::new(document.r()))
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
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;
|
||||||
|
@ -33,23 +32,23 @@ 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.as_global_scope(), is2D, matrix)
|
Self::new(global, is2D, matrix)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.as_global_scope(), is2D, matrix)
|
Self::new(global, is2D, matrix)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ 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;
|
||||||
|
@ -41,23 +40,23 @@ 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.as_global_scope(), 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.as_global_scope(), is2D, matrix)
|
Self::new(global, is2D, matrix)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.as_global_scope(), is2D, matrix)
|
Self::new(global, is2D, matrix)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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};
|
||||||
|
@ -42,8 +42,8 @@ impl DOMParser {
|
||||||
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_global_scope().as_window()))
|
Ok(DOMParser::new(global.as_window()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
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};
|
||||||
|
@ -28,13 +27,13 @@ impl 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,
|
||||||
w: f64)
|
w: f64)
|
||||||
-> Fallible<Root<DOMPoint>> {
|
-> Fallible<Root<DOMPoint>> {
|
||||||
Ok(DOMPoint::new(global.as_global_scope(), x, y, z, w))
|
Ok(DOMPoint::new(global, x, y, z, w))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_from_init(global: &GlobalScope, p: &DOMPointInit) -> Root<DOMPoint> {
|
pub fn new_from_init(global: &GlobalScope, p: &DOMPointInit) -> Root<DOMPoint> {
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
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 dom::globalscope::GlobalScope;
|
||||||
|
@ -37,13 +36,13 @@ impl DOMPointReadOnly {
|
||||||
Wrap)
|
Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
x: f64,
|
x: f64,
|
||||||
y: f64,
|
y: f64,
|
||||||
z: f64,
|
z: f64,
|
||||||
w: f64)
|
w: f64)
|
||||||
-> Fallible<Root<DOMPointReadOnly>> {
|
-> Fallible<Root<DOMPointReadOnly>> {
|
||||||
Ok(DOMPointReadOnly::new(global.as_global_scope(), x, y, z, w))
|
Ok(DOMPointReadOnly::new(global, x, y, z, w))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ 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;
|
||||||
|
@ -48,13 +47,12 @@ 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,
|
||||||
p4: &DOMPointInit)
|
p4: &DOMPointInit)
|
||||||
-> Fallible<Root<DOMQuad>> {
|
-> Fallible<Root<DOMQuad>> {
|
||||||
let global = global.as_global_scope();
|
|
||||||
Ok(DOMQuad::new(global,
|
Ok(DOMQuad::new(global,
|
||||||
&*DOMPoint::new_from_init(global, p1),
|
&*DOMPoint::new_from_init(global, p1),
|
||||||
&*DOMPoint::new_from_init(global, p2),
|
&*DOMPoint::new_from_init(global, p2),
|
||||||
|
@ -63,8 +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> {
|
||||||
let global = global.as_global_scope();
|
|
||||||
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),
|
||||||
|
@ -73,8 +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> {
|
||||||
let global = global.as_global_scope();
|
|
||||||
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),
|
||||||
|
|
|
@ -6,7 +6,6 @@ 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;
|
||||||
|
@ -30,13 +29,13 @@ impl DOMRect {
|
||||||
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,
|
||||||
height: f64)
|
height: f64)
|
||||||
-> Fallible<Root<DOMRect>> {
|
-> Fallible<Root<DOMRect>> {
|
||||||
Ok(DOMRect::new(global.as_global_scope(), x, y, width, height))
|
Ok(DOMRect::new(global, x, y, width, height))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
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 dom::globalscope::GlobalScope;
|
||||||
|
@ -41,13 +40,13 @@ 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,
|
||||||
height: f64)
|
height: f64)
|
||||||
-> Fallible<Root<DOMRectReadOnly>> {
|
-> Fallible<Root<DOMRectReadOnly>> {
|
||||||
Ok(DOMRectReadOnly::new(global.as_global_scope(), x, y, width, height))
|
Ok(DOMRectReadOnly::new(global, x, y, width, height))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_x(&self, value: f64) {
|
pub fn set_x(&self, value: f64) {
|
||||||
|
|
|
@ -7,7 +7,6 @@ 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;
|
||||||
|
@ -71,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() {
|
||||||
|
@ -96,7 +95,7 @@ impl ErrorEvent {
|
||||||
// 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(
|
let event = ErrorEvent::new(
|
||||||
global.as_global_scope(),
|
global,
|
||||||
Atom::from(type_),
|
Atom::from(type_),
|
||||||
bubbles,
|
bubbles,
|
||||||
cancelable,
|
cancelable,
|
||||||
|
|
|
@ -6,7 +6,6 @@ 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};
|
||||||
|
@ -131,12 +130,12 @@ 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);
|
||||||
let cancelable = EventCancelable::from(init.cancelable);
|
let cancelable = EventCancelable::from(init.cancelable);
|
||||||
Ok(Event::new(global.as_global_scope(), Atom::from(type_), bubbles, cancelable))
|
Ok(Event::new(global, Atom::from(type_), bubbles, cancelable))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init_event(&self, type_: Atom, bubbles: bool, cancelable: bool) {
|
pub fn init_event(&self, type_: Atom, bubbles: bool, cancelable: bool) {
|
||||||
|
|
|
@ -6,7 +6,6 @@ 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;
|
||||||
|
@ -49,18 +48,17 @@ impl EventSource {
|
||||||
Wrap)
|
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>> {
|
||||||
let global_scope = global.as_global_scope();
|
|
||||||
// Steps 1-2
|
// Steps 1-2
|
||||||
let base_url = global_scope.get_url();
|
let base_url = global.get_url();
|
||||||
let url = match base_url.join(&*url_str) {
|
let url = match base_url.join(&*url_str) {
|
||||||
Ok(u) => u,
|
Ok(u) => u,
|
||||||
Err(_) => return Err(Error::Syntax)
|
Err(_) => return Err(Error::Syntax)
|
||||||
};
|
};
|
||||||
// Step 3
|
// Step 3
|
||||||
let event_source = EventSource::new(global_scope, url, event_source_init.withCredentials);
|
let event_source = EventSource::new(global, url, event_source_init.withCredentials);
|
||||||
// Step 4
|
// Step 4
|
||||||
// Step 5
|
// Step 5
|
||||||
// Step 6
|
// Step 6
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
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;
|
||||||
|
@ -42,10 +41,10 @@ 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.as_global_scope(),
|
Ok(ExtendableEvent::new(global,
|
||||||
Atom::from(type_),
|
Atom::from(type_),
|
||||||
init.parent.bubbles,
|
init.parent.bubbles,
|
||||||
init.parent.cancelable))
|
init.parent.cancelable))
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -47,12 +46,12 @@ 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.as_global_scope(),
|
let ev = ExtendableMessageEvent::new(global,
|
||||||
Atom::from(type_),
|
Atom::from(type_),
|
||||||
init.parent.parent.bubbles,
|
init.parent.parent.bubbles,
|
||||||
init.parent.parent.cancelable,
|
init.parent.parent.cancelable,
|
||||||
|
|
|
@ -6,7 +6,6 @@ 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::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;
|
||||||
|
@ -59,7 +58,7 @@ impl File {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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,11 +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.as_global_scope(),
|
Ok(File::new(global,
|
||||||
BlobImpl::new_from_bytes(bytes),
|
BlobImpl::new_from_bytes(bytes),
|
||||||
replaced_filename,
|
replaced_filename,
|
||||||
modified,
|
modified,
|
||||||
typeString))
|
typeString))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn name(&self) -> &DOMString {
|
pub fn name(&self) -> &DOMString {
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -94,8 +93,8 @@ impl FileReader {
|
||||||
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.as_global_scope()))
|
Ok(FileReader::new(global))
|
||||||
}
|
}
|
||||||
|
|
||||||
//https://w3c.github.io/FileAPI/#dfn-error-steps
|
//https://w3c.github.io/FileAPI/#dfn-error-steps
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
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;
|
||||||
|
@ -27,7 +26,7 @@ impl FileReaderSync {
|
||||||
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.as_global_scope()))
|
Ok(FileReaderSync::new(global))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ 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;
|
||||||
|
@ -54,12 +53,12 @@ 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_global_scope().as_window(),
|
let event = FocusEvent::new(global.as_window(),
|
||||||
type_,
|
type_,
|
||||||
bubbles,
|
bubbles,
|
||||||
cancelable,
|
cancelable,
|
||||||
|
|
|
@ -7,7 +7,6 @@ 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};
|
||||||
|
@ -51,9 +50,9 @@ impl FormData {
|
||||||
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.as_global_scope()))
|
Ok(FormData::new(form, global))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ 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;
|
||||||
|
@ -55,11 +54,11 @@ 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>> {
|
||||||
Ok(HashChangeEvent::new(global.as_global_scope(),
|
Ok(HashChangeEvent::new(global,
|
||||||
Atom::from(type_),
|
Atom::from(type_),
|
||||||
init.parent.bubbles,
|
init.parent.bubbles,
|
||||||
init.parent.cancelable,
|
init.parent.cancelable,
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
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};
|
||||||
|
@ -49,9 +48,9 @@ impl Headers {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.as_global_scope());
|
let dom_headers_new = Headers::new(global);
|
||||||
try!(dom_headers_new.fill(init));
|
try!(dom_headers_new.fill(init));
|
||||||
Ok(dom_headers_new)
|
Ok(dom_headers_new)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,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;
|
||||||
|
@ -225,10 +226,10 @@ 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_global_scope().as_window().Document();
|
let document = global.as_window().Document();
|
||||||
let image = HTMLImageElement::new(atom!("img"), None, document.r());
|
let image = HTMLImageElement::new(atom!("img"), None, document.r());
|
||||||
if let Some(w) = width {
|
if let Some(w) = width {
|
||||||
image.SetWidth(w);
|
image.SetWidth(w);
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -101,10 +101,10 @@ 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_global_scope().as_window(),
|
let event = KeyboardEvent::new(global.as_window(),
|
||||||
type_,
|
type_,
|
||||||
init.parent.parent.parent.bubbles,
|
init.parent.parent.parent.bubbles,
|
||||||
init.parent.parent.parent.cancelable,
|
init.parent.parent.parent.cancelable,
|
||||||
|
|
|
@ -6,7 +6,6 @@ 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;
|
||||||
|
@ -61,14 +60,14 @@ 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.as_global_scope(),
|
let ev = MessageEvent::new(global,
|
||||||
Atom::from(type_),
|
Atom::from(type_),
|
||||||
init.parent.bubbles,
|
init.parent.bubbles,
|
||||||
init.parent.cancelable,
|
init.parent.cancelable,
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -82,12 +82,12 @@ 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_global_scope().as_window(),
|
let event = MouseEvent::new(global.as_window(),
|
||||||
type_,
|
type_,
|
||||||
bubbles,
|
bubbles,
|
||||||
cancelable,
|
cancelable,
|
||||||
|
|
|
@ -6,7 +6,6 @@ use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||||
use dom::bindings::codegen::Bindings::PageTransitionEventBinding;
|
use dom::bindings::codegen::Bindings::PageTransitionEventBinding;
|
||||||
use dom::bindings::codegen::Bindings::PageTransitionEventBinding::PageTransitionEventMethods;
|
use dom::bindings::codegen::Bindings::PageTransitionEventBinding::PageTransitionEventMethods;
|
||||||
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;
|
||||||
|
@ -52,11 +51,11 @@ impl PageTransitionEvent {
|
||||||
ev
|
ev
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &PageTransitionEventBinding::PageTransitionEventInit)
|
init: &PageTransitionEventBinding::PageTransitionEventInit)
|
||||||
-> Fallible<Root<PageTransitionEvent>> {
|
-> Fallible<Root<PageTransitionEvent>> {
|
||||||
Ok(PageTransitionEvent::new(global.as_global_scope(),
|
Ok(PageTransitionEvent::new(global,
|
||||||
Atom::from(type_),
|
Atom::from(type_),
|
||||||
init.parent.bubbles,
|
init.parent.bubbles,
|
||||||
init.parent.cancelable,
|
init.parent.cancelable,
|
||||||
|
|
|
@ -6,7 +6,6 @@ use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||||
use dom::bindings::codegen::Bindings::PopStateEventBinding;
|
use dom::bindings::codegen::Bindings::PopStateEventBinding;
|
||||||
use dom::bindings::codegen::Bindings::PopStateEventBinding::PopStateEventMethods;
|
use dom::bindings::codegen::Bindings::PopStateEventBinding::PopStateEventMethods;
|
||||||
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;
|
||||||
|
@ -55,11 +54,11 @@ impl PopStateEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &PopStateEventBinding::PopStateEventInit)
|
init: &PopStateEventBinding::PopStateEventInit)
|
||||||
-> Fallible<Root<PopStateEvent>> {
|
-> Fallible<Root<PopStateEvent>> {
|
||||||
Ok(PopStateEvent::new(global.as_global_scope(),
|
Ok(PopStateEvent::new(global,
|
||||||
Atom::from(type_),
|
Atom::from(type_),
|
||||||
init.parent.bubbles,
|
init.parent.bubbles,
|
||||||
init.parent.cancelable,
|
init.parent.cancelable,
|
||||||
|
|
|
@ -6,7 +6,6 @@ use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||||
use dom::bindings::codegen::Bindings::ProgressEventBinding;
|
use dom::bindings::codegen::Bindings::ProgressEventBinding;
|
||||||
use dom::bindings::codegen::Bindings::ProgressEventBinding::ProgressEventMethods;
|
use dom::bindings::codegen::Bindings::ProgressEventBinding::ProgressEventMethods;
|
||||||
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;
|
||||||
|
@ -49,13 +48,13 @@ impl ProgressEvent {
|
||||||
}
|
}
|
||||||
ev
|
ev
|
||||||
}
|
}
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &ProgressEventBinding::ProgressEventInit)
|
init: &ProgressEventBinding::ProgressEventInit)
|
||||||
-> Fallible<Root<ProgressEvent>> {
|
-> Fallible<Root<ProgressEvent>> {
|
||||||
let bubbles = EventBubbles::from(init.parent.bubbles);
|
let bubbles = EventBubbles::from(init.parent.bubbles);
|
||||||
let cancelable = EventCancelable::from(init.parent.cancelable);
|
let cancelable = EventCancelable::from(init.parent.cancelable);
|
||||||
let ev = ProgressEvent::new(global.as_global_scope(), Atom::from(type_), bubbles, cancelable,
|
let ev = ProgressEvent::new(global, Atom::from(type_), bubbles, cancelable,
|
||||||
init.lengthComputable, init.loaded, init.total);
|
init.lengthComputable, init.loaded, init.total);
|
||||||
Ok(ev)
|
Ok(ev)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ use dom::bindings::codegen::Bindings::RangeBinding::RangeMethods;
|
||||||
use dom::bindings::codegen::Bindings::TextBinding::TextMethods;
|
use dom::bindings::codegen::Bindings::TextBinding::TextMethods;
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::inheritance::{CharacterDataTypeId, NodeTypeId};
|
use dom::bindings::inheritance::{CharacterDataTypeId, NodeTypeId};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{JS, MutHeap, Root, RootedReference};
|
use dom::bindings::js::{JS, MutHeap, Root, RootedReference};
|
||||||
|
@ -23,6 +22,7 @@ use dom::characterdata::CharacterData;
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::documentfragment::DocumentFragment;
|
use dom::documentfragment::DocumentFragment;
|
||||||
use dom::element::Element;
|
use dom::element::Element;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::htmlbodyelement::HTMLBodyElement;
|
use dom::htmlbodyelement::HTMLBodyElement;
|
||||||
use dom::htmlscriptelement::HTMLScriptElement;
|
use dom::htmlscriptelement::HTMLScriptElement;
|
||||||
use dom::node::{Node, UnbindContext};
|
use dom::node::{Node, UnbindContext};
|
||||||
|
@ -70,8 +70,8 @@ impl Range {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range
|
// https://dom.spec.whatwg.org/#dom-range
|
||||||
pub fn Constructor(global: GlobalRef) -> Fallible<Root<Range>> {
|
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<Range>> {
|
||||||
let document = global.as_global_scope().as_window().Document();
|
let document = global.as_window().Document();
|
||||||
Ok(Range::new_with_doc(document.r()))
|
Ok(Range::new_with_doc(document.r()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ use dom::bindings::codegen::Bindings::RequestBinding::RequestMode;
|
||||||
use dom::bindings::codegen::Bindings::RequestBinding::RequestRedirect;
|
use dom::bindings::codegen::Bindings::RequestBinding::RequestRedirect;
|
||||||
use dom::bindings::codegen::Bindings::RequestBinding::RequestType;
|
use dom::bindings::codegen::Bindings::RequestBinding::RequestType;
|
||||||
use dom::bindings::error::{Error, Fallible};
|
use dom::bindings::error::{Error, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
use dom::bindings::js::{JS, MutNullableHeap, 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, USVString};
|
use dom::bindings::str::{ByteString, DOMString, USVString};
|
||||||
|
@ -78,12 +77,10 @@ impl Request {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://fetch.spec.whatwg.org/#dom-request
|
// https://fetch.spec.whatwg.org/#dom-request
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
input: RequestInfo,
|
input: RequestInfo,
|
||||||
init: &RequestInit)
|
init: &RequestInit)
|
||||||
-> Fallible<Root<Request>> {
|
-> Fallible<Root<Request>> {
|
||||||
let global_scope = global.as_global_scope();
|
|
||||||
|
|
||||||
// Step 1
|
// Step 1
|
||||||
let temporary_request: NetTraitsRequest;
|
let temporary_request: NetTraitsRequest;
|
||||||
|
|
||||||
|
@ -95,7 +92,7 @@ impl Request {
|
||||||
|
|
||||||
// Step 4
|
// Step 4
|
||||||
// TODO: `entry settings object` is not implemented in Servo yet.
|
// TODO: `entry settings object` is not implemented in Servo yet.
|
||||||
let base_url = global_scope.get_url();
|
let base_url = global.get_url();
|
||||||
|
|
||||||
match input {
|
match input {
|
||||||
// Step 5
|
// Step 5
|
||||||
|
@ -112,7 +109,7 @@ impl Request {
|
||||||
return Err(Error::Type("Url includes credentials".to_string()))
|
return Err(Error::Type("Url includes credentials".to_string()))
|
||||||
}
|
}
|
||||||
// Step 5.4
|
// Step 5.4
|
||||||
temporary_request = net_request_from_global(&global_scope,
|
temporary_request = net_request_from_global(global,
|
||||||
url,
|
url,
|
||||||
false);
|
false);
|
||||||
// Step 5.5
|
// Step 5.5
|
||||||
|
@ -153,7 +150,7 @@ impl Request {
|
||||||
|
|
||||||
// Step 12
|
// Step 12
|
||||||
let mut request: NetTraitsRequest;
|
let mut request: NetTraitsRequest;
|
||||||
request = net_request_from_global(&global_scope,
|
request = net_request_from_global(global,
|
||||||
temporary_request.current_url(),
|
temporary_request.current_url(),
|
||||||
false);
|
false);
|
||||||
request.method = temporary_request.method;
|
request.method = temporary_request.method;
|
||||||
|
@ -305,7 +302,7 @@ impl Request {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 26
|
// Step 26
|
||||||
let r = Request::from_net_request(&global_scope,
|
let r = Request::from_net_request(global,
|
||||||
false,
|
false,
|
||||||
request);
|
request);
|
||||||
r.headers.or_init(|| Headers::for_request(&r.global_scope()));
|
r.headers.or_init(|| Headers::for_request(&r.global_scope()));
|
||||||
|
|
|
@ -10,7 +10,6 @@ use dom::bindings::codegen::Bindings::ResponseBinding;
|
||||||
use dom::bindings::codegen::Bindings::ResponseBinding::{ResponseMethods, ResponseType as DOMResponseType};
|
use dom::bindings::codegen::Bindings::ResponseBinding::{ResponseMethods, ResponseType as DOMResponseType};
|
||||||
use dom::bindings::codegen::Bindings::XMLHttpRequestBinding::BodyInit;
|
use dom::bindings::codegen::Bindings::XMLHttpRequestBinding::BodyInit;
|
||||||
use dom::bindings::error::{Error, Fallible};
|
use dom::bindings::error::{Error, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
||||||
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::str::{ByteString, USVString};
|
use dom::bindings::str::{ByteString, USVString};
|
||||||
|
@ -71,7 +70,7 @@ impl Response {
|
||||||
reflect_dom_object(box Response::new_inherited(), global, ResponseBinding::Wrap)
|
reflect_dom_object(box Response::new_inherited(), global, ResponseBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef, body: Option<BodyInit>, init: &ResponseBinding::ResponseInit)
|
pub fn Constructor(global: &GlobalScope, body: Option<BodyInit>, init: &ResponseBinding::ResponseInit)
|
||||||
-> Fallible<Root<Response>> {
|
-> Fallible<Root<Response>> {
|
||||||
// Step 1
|
// Step 1
|
||||||
if init.status < 200 || init.status > 599 {
|
if init.status < 200 || init.status > 599 {
|
||||||
|
@ -87,7 +86,7 @@ impl Response {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 3
|
// Step 3
|
||||||
let r = Response::new(global.as_global_scope());
|
let r = Response::new(global);
|
||||||
|
|
||||||
// Step 4
|
// Step 4
|
||||||
*r.status.borrow_mut() = Some(StatusCode::from_u16(init.status));
|
*r.status.borrow_mut() = Some(StatusCode::from_u16(init.status));
|
||||||
|
@ -139,8 +138,8 @@ impl Response {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://fetch.spec.whatwg.org/#dom-response-error
|
// https://fetch.spec.whatwg.org/#dom-response-error
|
||||||
pub fn Error(global: GlobalRef) -> Root<Response> {
|
pub fn Error(global: &GlobalScope) -> Root<Response> {
|
||||||
let r = Response::new(global.as_global_scope());
|
let r = Response::new(global);
|
||||||
*r.response_type.borrow_mut() = DOMResponseType::Error;
|
*r.response_type.borrow_mut() = DOMResponseType::Error;
|
||||||
r.Headers().set_guard(Guard::Immutable);
|
r.Headers().set_guard(Guard::Immutable);
|
||||||
*r.raw_status.borrow_mut() = Some((0, b"".to_vec()));
|
*r.raw_status.borrow_mut() = Some((0, b"".to_vec()));
|
||||||
|
@ -148,11 +147,10 @@ impl Response {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://fetch.spec.whatwg.org/#dom-response-redirect
|
// https://fetch.spec.whatwg.org/#dom-response-redirect
|
||||||
pub fn Redirect(global: GlobalRef, url: USVString, status: u16) -> Fallible<Root<Response>> {
|
pub fn Redirect(global: &GlobalScope, url: USVString, status: u16) -> Fallible<Root<Response>> {
|
||||||
let global_scope = global.as_global_scope();
|
|
||||||
// Step 1
|
// Step 1
|
||||||
// TODO: `entry settings object` is not implemented in Servo yet.
|
// TODO: `entry settings object` is not implemented in Servo yet.
|
||||||
let base_url = global_scope.get_url();
|
let base_url = global.get_url();
|
||||||
let parsed_url = base_url.join(&url.0);
|
let parsed_url = base_url.join(&url.0);
|
||||||
|
|
||||||
// Step 2
|
// Step 2
|
||||||
|
@ -168,7 +166,7 @@ impl Response {
|
||||||
|
|
||||||
// Step 4
|
// Step 4
|
||||||
// see Step 4 continued
|
// see Step 4 continued
|
||||||
let r = Response::new(global_scope);
|
let r = Response::new(global);
|
||||||
|
|
||||||
// Step 5
|
// Step 5
|
||||||
*r.status.borrow_mut() = Some(StatusCode::from_u16(status));
|
*r.status.borrow_mut() = Some(StatusCode::from_u16(status));
|
||||||
|
|
|
@ -6,7 +6,6 @@ use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||||
use dom::bindings::codegen::Bindings::StorageEventBinding;
|
use dom::bindings::codegen::Bindings::StorageEventBinding;
|
||||||
use dom::bindings::codegen::Bindings::StorageEventBinding::StorageEventMethods;
|
use dom::bindings::codegen::Bindings::StorageEventBinding::StorageEventMethods;
|
||||||
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;
|
||||||
|
@ -71,7 +70,7 @@ impl StorageEvent {
|
||||||
ev
|
ev
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &StorageEventBinding::StorageEventInit) -> Fallible<Root<StorageEvent>> {
|
init: &StorageEventBinding::StorageEventInit) -> Fallible<Root<StorageEvent>> {
|
||||||
let key = init.key.clone();
|
let key = init.key.clone();
|
||||||
|
@ -81,7 +80,7 @@ impl StorageEvent {
|
||||||
let storageArea = init.storageArea.r();
|
let storageArea = init.storageArea.r();
|
||||||
let bubbles = EventBubbles::from(init.parent.bubbles);
|
let bubbles = EventBubbles::from(init.parent.bubbles);
|
||||||
let cancelable = EventCancelable::from(init.parent.cancelable);
|
let cancelable = EventCancelable::from(init.parent.cancelable);
|
||||||
let event = StorageEvent::new(global.as_global_scope(), Atom::from(type_),
|
let event = StorageEvent::new(global, Atom::from(type_),
|
||||||
bubbles, cancelable,
|
bubbles, cancelable,
|
||||||
key, oldValue, newValue,
|
key, oldValue, newValue,
|
||||||
url, storageArea);
|
url, storageArea);
|
||||||
|
|
|
@ -21,7 +21,7 @@ use dom::bindings::codegen::UnionTypes::{HTMLElementOrUnsignedLongOrStringOrBool
|
||||||
use dom::bindings::codegen::UnionTypes::{StringOrLongSequence, StringOrStringSequence, StringSequenceOrUnsignedLong};
|
use dom::bindings::codegen::UnionTypes::{StringOrLongSequence, StringOrStringSequence, StringSequenceOrUnsignedLong};
|
||||||
use dom::bindings::codegen::UnionTypes::{StringOrUnsignedLong, StringOrBoolean, UnsignedLongOrBoolean};
|
use dom::bindings::codegen::UnionTypes::{StringOrUnsignedLong, StringOrBoolean, UnsignedLongOrBoolean};
|
||||||
use dom::bindings::error::{Error, Fallible};
|
use dom::bindings::error::{Error, Fallible};
|
||||||
use dom::bindings::global::{GlobalRef, global_root_from_context};
|
use dom::bindings::global::global_root_from_context;
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::mozmap::MozMap;
|
use dom::bindings::mozmap::MozMap;
|
||||||
use dom::bindings::num::Finite;
|
use dom::bindings::num::Finite;
|
||||||
|
@ -63,18 +63,18 @@ impl TestBinding {
|
||||||
global, TestBindingBinding::Wrap)
|
global, TestBindingBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef) -> Fallible<Root<TestBinding>> {
|
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<TestBinding>> {
|
||||||
Ok(TestBinding::new(global.as_global_scope()))
|
Ok(TestBinding::new(global))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
pub fn Constructor_(global: GlobalRef, nums: Vec<f64>) -> Fallible<Root<TestBinding>> {
|
pub fn Constructor_(global: &GlobalScope, nums: Vec<f64>) -> Fallible<Root<TestBinding>> {
|
||||||
Ok(TestBinding::new(global.as_global_scope()))
|
Ok(TestBinding::new(global))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
pub fn Constructor__(global: GlobalRef, num: f64) -> Fallible<Root<TestBinding>> {
|
pub fn Constructor__(global: &GlobalScope, num: f64) -> Fallible<Root<TestBinding>> {
|
||||||
Ok(TestBinding::new(global.as_global_scope()))
|
Ok(TestBinding::new(global))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -757,17 +757,17 @@ impl TestBindingMethods for TestBinding {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestBinding {
|
impl TestBinding {
|
||||||
pub fn BooleanAttributeStatic(_: GlobalRef) -> bool { false }
|
pub fn BooleanAttributeStatic(_: &GlobalScope) -> bool { false }
|
||||||
pub fn SetBooleanAttributeStatic(_: GlobalRef, _: bool) {}
|
pub fn SetBooleanAttributeStatic(_: &GlobalScope, _: bool) {}
|
||||||
pub fn ReceiveVoidStatic(_: GlobalRef) {}
|
pub fn ReceiveVoidStatic(_: &GlobalScope) {}
|
||||||
pub fn PrefControlledStaticAttributeDisabled(_: GlobalRef) -> bool { false }
|
pub fn PrefControlledStaticAttributeDisabled(_: &GlobalScope) -> bool { false }
|
||||||
pub fn PrefControlledStaticAttributeEnabled(_: GlobalRef) -> bool { false }
|
pub fn PrefControlledStaticAttributeEnabled(_: &GlobalScope) -> bool { false }
|
||||||
pub fn PrefControlledStaticMethodDisabled(_: GlobalRef) {}
|
pub fn PrefControlledStaticMethodDisabled(_: &GlobalScope) {}
|
||||||
pub fn PrefControlledStaticMethodEnabled(_: GlobalRef) {}
|
pub fn PrefControlledStaticMethodEnabled(_: &GlobalScope) {}
|
||||||
pub fn FuncControlledStaticAttributeDisabled(_: GlobalRef) -> bool { false }
|
pub fn FuncControlledStaticAttributeDisabled(_: &GlobalScope) -> bool { false }
|
||||||
pub fn FuncControlledStaticAttributeEnabled(_: GlobalRef) -> bool { false }
|
pub fn FuncControlledStaticAttributeEnabled(_: &GlobalScope) -> bool { false }
|
||||||
pub fn FuncControlledStaticMethodDisabled(_: GlobalRef) {}
|
pub fn FuncControlledStaticMethodDisabled(_: &GlobalScope) {}
|
||||||
pub fn FuncControlledStaticMethodEnabled(_: GlobalRef) {}
|
pub fn FuncControlledStaticMethodEnabled(_: &GlobalScope) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
use dom::bindings::cell::DOMRefCell;
|
use dom::bindings::cell::DOMRefCell;
|
||||||
use dom::bindings::codegen::Bindings::TestBindingIterableBinding::{self, TestBindingIterableMethods};
|
use dom::bindings::codegen::Bindings::TestBindingIterableBinding::{self, TestBindingIterableMethods};
|
||||||
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::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
|
@ -27,8 +26,8 @@ impl TestBindingIterable {
|
||||||
}, global, TestBindingIterableBinding::Wrap)
|
}, global, TestBindingIterableBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef) -> Fallible<Root<TestBindingIterable>> {
|
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<TestBindingIterable>> {
|
||||||
Ok(TestBindingIterable::new(global.as_global_scope()))
|
Ok(TestBindingIterable::new(global))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ use dom::bindings::cell::DOMRefCell;
|
||||||
use dom::bindings::codegen::Bindings::TestBindingPairIterableBinding;
|
use dom::bindings::codegen::Bindings::TestBindingPairIterableBinding;
|
||||||
use dom::bindings::codegen::Bindings::TestBindingPairIterableBinding::TestBindingPairIterableMethods;
|
use dom::bindings::codegen::Bindings::TestBindingPairIterableBinding::TestBindingPairIterableMethods;
|
||||||
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::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
|
@ -43,8 +42,8 @@ impl TestBindingPairIterable {
|
||||||
}, global, TestBindingPairIterableBinding::TestBindingPairIterableWrap)
|
}, global, TestBindingPairIterableBinding::TestBindingPairIterableWrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef) -> Fallible<Root<TestBindingPairIterable>> {
|
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<TestBindingPairIterable>> {
|
||||||
Ok(TestBindingPairIterable::new(global.as_global_scope()))
|
Ok(TestBindingPairIterable::new(global))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,13 @@ use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||||
use dom::bindings::codegen::Bindings::TextBinding::{self, TextMethods};
|
use dom::bindings::codegen::Bindings::TextBinding::{self, TextMethods};
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
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::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::js::RootedReference;
|
use dom::bindings::js::RootedReference;
|
||||||
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 text node.
|
/// An HTML text node.
|
||||||
|
@ -35,8 +35,8 @@ impl Text {
|
||||||
document, TextBinding::Wrap)
|
document, TextBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef, text: DOMString) -> Fallible<Root<Text>> {
|
pub fn Constructor(global: &GlobalScope, text: DOMString) -> Fallible<Root<Text>> {
|
||||||
let document = global.as_global_scope().as_window().Document();
|
let document = global.as_window().Document();
|
||||||
Ok(Text::new(text, document.r()))
|
Ok(Text::new(text, document.r()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ use dom::bindings::codegen::Bindings::TextDecoderBinding;
|
||||||
use dom::bindings::codegen::Bindings::TextDecoderBinding::TextDecoderMethods;
|
use dom::bindings::codegen::Bindings::TextDecoderBinding::TextDecoderMethods;
|
||||||
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::bindings::str::{DOMString, USVString};
|
use dom::bindings::str::{DOMString, USVString};
|
||||||
|
@ -44,7 +43,7 @@ impl TextDecoder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://encoding.spec.whatwg.org/#dom-textdecoder
|
/// https://encoding.spec.whatwg.org/#dom-textdecoder
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
label: DOMString,
|
label: DOMString,
|
||||||
options: &TextDecoderBinding::TextDecoderOptions)
|
options: &TextDecoderBinding::TextDecoderOptions)
|
||||||
-> Fallible<Root<TextDecoder>> {
|
-> Fallible<Root<TextDecoder>> {
|
||||||
|
@ -61,7 +60,7 @@ impl TextDecoder {
|
||||||
Some("replacement") => return TextDecoder::make_range_error(),
|
Some("replacement") => return TextDecoder::make_range_error(),
|
||||||
_ => ()
|
_ => ()
|
||||||
};
|
};
|
||||||
Ok(TextDecoder::new(global.as_global_scope(), encoding, options.fatal))
|
Ok(TextDecoder::new(global, encoding, options.fatal))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ use core::nonzero::NonZero;
|
||||||
use dom::bindings::codegen::Bindings::TextEncoderBinding;
|
use dom::bindings::codegen::Bindings::TextEncoderBinding;
|
||||||
use dom::bindings::codegen::Bindings::TextEncoderBinding::TextEncoderMethods;
|
use dom::bindings::codegen::Bindings::TextEncoderBinding::TextEncoderMethods;
|
||||||
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::bindings::str::{DOMString, USVString};
|
use dom::bindings::str::{DOMString, USVString};
|
||||||
|
@ -38,8 +37,8 @@ impl TextEncoder {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://encoding.spec.whatwg.org/#dom-textencoder
|
// https://encoding.spec.whatwg.org/#dom-textencoder
|
||||||
pub fn Constructor(global: GlobalRef) -> Fallible<Root<TextEncoder>> {
|
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<TextEncoder>> {
|
||||||
Ok(TextEncoder::new(global.as_global_scope()))
|
Ok(TextEncoder::new(global))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,13 @@ use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||||
use dom::bindings::codegen::Bindings::UIEventBinding;
|
use dom::bindings::codegen::Bindings::UIEventBinding;
|
||||||
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, RootedReference};
|
use dom::bindings::js::{JS, MutNullableHeap, RootedReference};
|
||||||
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 dom::window::Window;
|
use dom::window::Window;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
|
@ -52,12 +52,12 @@ impl UIEvent {
|
||||||
ev
|
ev
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &UIEventBinding::UIEventInit) -> Fallible<Root<UIEvent>> {
|
init: &UIEventBinding::UIEventInit) -> Fallible<Root<UIEvent>> {
|
||||||
let bubbles = EventBubbles::from(init.parent.bubbles);
|
let bubbles = EventBubbles::from(init.parent.bubbles);
|
||||||
let cancelable = EventCancelable::from(init.parent.cancelable);
|
let cancelable = EventCancelable::from(init.parent.cancelable);
|
||||||
let event = UIEvent::new(global.as_global_scope().as_window(),
|
let event = UIEvent::new(global.as_window(),
|
||||||
type_,
|
type_,
|
||||||
bubbles, cancelable,
|
bubbles, cancelable,
|
||||||
init.view.r(), init.detail);
|
init.view.r(), init.detail);
|
||||||
|
|
|
@ -6,7 +6,6 @@ use dom::bindings::cell::DOMRefCell;
|
||||||
use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
|
use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
|
||||||
use dom::bindings::codegen::Bindings::URLBinding::{self, URLMethods};
|
use dom::bindings::codegen::Bindings::URLBinding::{self, URLMethods};
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
|
||||||
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
use dom::bindings::js::{JS, MutNullableHeap, 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};
|
||||||
|
@ -62,7 +61,7 @@ impl URL {
|
||||||
|
|
||||||
impl URL {
|
impl URL {
|
||||||
// https://url.spec.whatwg.org/#constructors
|
// https://url.spec.whatwg.org/#constructors
|
||||||
pub fn Constructor(global: GlobalRef, url: USVString,
|
pub fn Constructor(global: &GlobalScope, url: USVString,
|
||||||
base: Option<USVString>)
|
base: Option<USVString>)
|
||||||
-> Fallible<Root<URL>> {
|
-> Fallible<Root<URL>> {
|
||||||
let parsed_base = match base {
|
let parsed_base = match base {
|
||||||
|
@ -90,7 +89,7 @@ impl URL {
|
||||||
};
|
};
|
||||||
// Step 5: Skip (see step 8 below).
|
// Step 5: Skip (see step 8 below).
|
||||||
// Steps 6-7.
|
// Steps 6-7.
|
||||||
let result = URL::new(global.as_global_scope(), parsed_url);
|
let result = URL::new(global, parsed_url);
|
||||||
// Step 8: Instead of construcing a new `URLSearchParams` object here, construct it
|
// Step 8: Instead of construcing a new `URLSearchParams` object here, construct it
|
||||||
// on-demand inside `URL::SearchParams`.
|
// on-demand inside `URL::SearchParams`.
|
||||||
// Step 9.
|
// Step 9.
|
||||||
|
@ -98,7 +97,7 @@ impl URL {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-url-domaintoasciidomain
|
// https://url.spec.whatwg.org/#dom-url-domaintoasciidomain
|
||||||
pub fn DomainToASCII(_: GlobalRef, origin: USVString) -> USVString {
|
pub fn DomainToASCII(_: &GlobalScope, origin: USVString) -> USVString {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let ascii_domain = Host::parse(&origin.0);
|
let ascii_domain = Host::parse(&origin.0);
|
||||||
if let Ok(Host::Domain(string)) = ascii_domain {
|
if let Ok(Host::Domain(string)) = ascii_domain {
|
||||||
|
@ -110,15 +109,15 @@ impl URL {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn DomainToUnicode(_: GlobalRef, origin: USVString) -> USVString {
|
pub fn DomainToUnicode(_: &GlobalScope, origin: USVString) -> USVString {
|
||||||
USVString(domain_to_unicode(&origin.0))
|
USVString(domain_to_unicode(&origin.0))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/FileAPI/#dfn-createObjectURL
|
// https://w3c.github.io/FileAPI/#dfn-createObjectURL
|
||||||
pub fn CreateObjectURL(global: GlobalRef, blob: &Blob) -> DOMString {
|
pub fn CreateObjectURL(global: &GlobalScope, blob: &Blob) -> DOMString {
|
||||||
/// XXX: Second field is an unicode-serialized Origin, it is a temporary workaround
|
/// XXX: Second field is an unicode-serialized Origin, it is a temporary workaround
|
||||||
/// and should not be trusted. See issue https://github.com/servo/servo/issues/11722
|
/// and should not be trusted. See issue https://github.com/servo/servo/issues/11722
|
||||||
let origin = get_blob_origin(&global.as_global_scope().get_url());
|
let origin = get_blob_origin(&global.get_url());
|
||||||
|
|
||||||
if blob.IsClosed() {
|
if blob.IsClosed() {
|
||||||
// Generate a dummy id
|
// Generate a dummy id
|
||||||
|
@ -132,8 +131,7 @@ impl URL {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/FileAPI/#dfn-revokeObjectURL
|
// https://w3c.github.io/FileAPI/#dfn-revokeObjectURL
|
||||||
pub fn RevokeObjectURL(global: GlobalRef, url: DOMString) {
|
pub fn RevokeObjectURL(global: &GlobalScope, url: DOMString) {
|
||||||
let global_scope = global.as_global_scope();
|
|
||||||
/*
|
/*
|
||||||
If the url refers to a Blob that has a readability state of CLOSED OR
|
If the url refers to a Blob that has a readability state of CLOSED OR
|
||||||
if the value provided for the url argument is not a Blob URL, OR
|
if the value provided for the url argument is not a Blob URL, OR
|
||||||
|
@ -143,11 +141,11 @@ impl URL {
|
||||||
|
|
||||||
NOTE: The first step is unnecessary, since closed blobs do not exist in the store
|
NOTE: The first step is unnecessary, since closed blobs do not exist in the store
|
||||||
*/
|
*/
|
||||||
let origin = get_blob_origin(&global_scope.get_url());
|
let origin = get_blob_origin(&global.get_url());
|
||||||
|
|
||||||
if let Ok(url) = Url::parse(&url) {
|
if let Ok(url) = Url::parse(&url) {
|
||||||
if let Ok((id, _, _)) = parse_blob_url(&url) {
|
if let Ok((id, _, _)) = parse_blob_url(&url) {
|
||||||
let resource_threads = global_scope.resource_threads();
|
let resource_threads = global.resource_threads();
|
||||||
let (tx, rx) = ipc::channel().unwrap();
|
let (tx, rx) = ipc::channel().unwrap();
|
||||||
let msg = FileManagerThreadMsg::RevokeBlobURL(id, origin, tx);
|
let msg = FileManagerThreadMsg::RevokeBlobURL(id, origin, tx);
|
||||||
let _ = resource_threads.send(CoreResourceMsg::ToFileManager(msg));
|
let _ = resource_threads.send(CoreResourceMsg::ToFileManager(msg));
|
||||||
|
|
|
@ -7,7 +7,6 @@ use dom::bindings::codegen::Bindings::URLSearchParamsBinding;
|
||||||
use dom::bindings::codegen::Bindings::URLSearchParamsBinding::URLSearchParamsMethods;
|
use dom::bindings::codegen::Bindings::URLSearchParamsBinding::URLSearchParamsMethods;
|
||||||
use dom::bindings::codegen::UnionTypes::USVStringOrURLSearchParams;
|
use dom::bindings::codegen::UnionTypes::USVStringOrURLSearchParams;
|
||||||
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::bindings::str::{DOMString, USVString};
|
use dom::bindings::str::{DOMString, USVString};
|
||||||
|
@ -42,10 +41,10 @@ impl URLSearchParams {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams
|
// https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams
|
||||||
pub fn Constructor(global: GlobalRef, init: Option<USVStringOrURLSearchParams>) ->
|
pub fn Constructor(global: &GlobalScope, init: Option<USVStringOrURLSearchParams>) ->
|
||||||
Fallible<Root<URLSearchParams>> {
|
Fallible<Root<URLSearchParams>> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let query = URLSearchParams::new(global.as_global_scope(), None);
|
let query = URLSearchParams::new(global, None);
|
||||||
match init {
|
match init {
|
||||||
Some(USVStringOrURLSearchParams::USVString(init)) => {
|
Some(USVStringOrURLSearchParams::USVString(init)) => {
|
||||||
// Step 2.
|
// Step 2.
|
||||||
|
|
|
@ -7,7 +7,6 @@ use dom::bindings::codegen::Bindings::WebGLContextEventBinding;
|
||||||
use dom::bindings::codegen::Bindings::WebGLContextEventBinding::WebGLContextEventInit;
|
use dom::bindings::codegen::Bindings::WebGLContextEventBinding::WebGLContextEventInit;
|
||||||
use dom::bindings::codegen::Bindings::WebGLContextEventBinding::WebGLContextEventMethods;
|
use dom::bindings::codegen::Bindings::WebGLContextEventBinding::WebGLContextEventMethods;
|
||||||
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;
|
||||||
|
@ -71,7 +70,7 @@ impl WebGLContextEvent {
|
||||||
event
|
event
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &WebGLContextEventInit) -> Fallible<Root<WebGLContextEvent>> {
|
init: &WebGLContextEventInit) -> Fallible<Root<WebGLContextEvent>> {
|
||||||
let status_message = match init.statusMessage.as_ref() {
|
let status_message = match init.statusMessage.as_ref() {
|
||||||
|
@ -83,7 +82,7 @@ impl WebGLContextEvent {
|
||||||
|
|
||||||
let cancelable = EventCancelable::from(init.parent.cancelable);
|
let cancelable = EventCancelable::from(init.parent.cancelable);
|
||||||
|
|
||||||
Ok(WebGLContextEvent::new(global.as_global_scope(),
|
Ok(WebGLContextEvent::new(global,
|
||||||
Atom::from(type_),
|
Atom::from(type_),
|
||||||
bubbles,
|
bubbles,
|
||||||
cancelable,
|
cancelable,
|
||||||
|
|
|
@ -10,7 +10,6 @@ use dom::bindings::codegen::Bindings::WebSocketBinding::{BinaryType, WebSocketMe
|
||||||
use dom::bindings::codegen::UnionTypes::StringOrStringSequence;
|
use dom::bindings::codegen::UnionTypes::StringOrStringSequence;
|
||||||
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::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::refcounted::Trusted;
|
use dom::bindings::refcounted::Trusted;
|
||||||
|
@ -196,7 +195,7 @@ impl WebSocket {
|
||||||
global, WebSocketBinding::Wrap)
|
global, WebSocketBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: GlobalRef,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
url: DOMString,
|
url: DOMString,
|
||||||
protocols: Option<StringOrStringSequence>)
|
protocols: Option<StringOrStringSequence>)
|
||||||
-> Fallible<Root<WebSocket>> {
|
-> Fallible<Root<WebSocket>> {
|
||||||
|
@ -239,11 +238,10 @@ impl WebSocket {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 6: Origin.
|
// Step 6: Origin.
|
||||||
let global_scope = global.as_global_scope();
|
let origin = UrlHelper::Origin(&global.get_url()).0;
|
||||||
let origin = UrlHelper::Origin(&global_scope.get_url()).0;
|
|
||||||
|
|
||||||
// Step 7.
|
// Step 7.
|
||||||
let ws = WebSocket::new(global_scope, resource_url.clone());
|
let ws = WebSocket::new(global, resource_url.clone());
|
||||||
let address = Trusted::new(ws.r());
|
let address = Trusted::new(ws.r());
|
||||||
|
|
||||||
let connect_data = WebSocketConnectData {
|
let connect_data = WebSocketConnectData {
|
||||||
|
@ -265,12 +263,12 @@ impl WebSocket {
|
||||||
action_receiver: resource_action_receiver,
|
action_receiver: resource_action_receiver,
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = global_scope.core_resource_thread().send(WebsocketConnect(connect, connect_data));
|
let _ = global.core_resource_thread().send(WebsocketConnect(connect, connect_data));
|
||||||
|
|
||||||
*ws.sender.borrow_mut() = Some(dom_action_sender);
|
*ws.sender.borrow_mut() = Some(dom_action_sender);
|
||||||
|
|
||||||
let moved_address = address.clone();
|
let moved_address = address.clone();
|
||||||
let sender = global_scope.networking_task_source();
|
let sender = global.networking_task_source();
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
while let Ok(event) = dom_event_receiver.recv() {
|
while let Ok(event) = dom_event_receiver.recv() {
|
||||||
match event {
|
match event {
|
||||||
|
|
|
@ -9,7 +9,6 @@ use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
||||||
use dom::bindings::codegen::Bindings::WorkerBinding;
|
use dom::bindings::codegen::Bindings::WorkerBinding;
|
||||||
use dom::bindings::codegen::Bindings::WorkerBinding::WorkerMethods;
|
use dom::bindings::codegen::Bindings::WorkerBinding::WorkerMethods;
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible, ErrorInfo};
|
use dom::bindings::error::{Error, ErrorResult, Fallible, ErrorInfo};
|
||||||
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;
|
||||||
|
@ -72,29 +71,28 @@ impl Worker {
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-worker
|
// https://html.spec.whatwg.org/multipage/#dom-worker
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub fn Constructor(global: GlobalRef, script_url: DOMString) -> Fallible<Root<Worker>> {
|
pub fn Constructor(global: &GlobalScope, script_url: DOMString) -> Fallible<Root<Worker>> {
|
||||||
let global_scope = global.as_global_scope();
|
|
||||||
// Step 2-4.
|
// Step 2-4.
|
||||||
let worker_url = match global_scope.api_base_url().join(&script_url) {
|
let worker_url = match global.api_base_url().join(&script_url) {
|
||||||
Ok(url) => url,
|
Ok(url) => url,
|
||||||
Err(_) => return Err(Error::Syntax),
|
Err(_) => return Err(Error::Syntax),
|
||||||
};
|
};
|
||||||
|
|
||||||
let (sender, receiver) = channel();
|
let (sender, receiver) = channel();
|
||||||
let closing = Arc::new(AtomicBool::new(false));
|
let closing = Arc::new(AtomicBool::new(false));
|
||||||
let worker = Worker::new(global_scope, sender.clone(), closing.clone());
|
let worker = Worker::new(global, sender.clone(), closing.clone());
|
||||||
let worker_ref = Trusted::new(worker.r());
|
let worker_ref = Trusted::new(worker.r());
|
||||||
|
|
||||||
let worker_load_origin = WorkerScriptLoadOrigin {
|
let worker_load_origin = WorkerScriptLoadOrigin {
|
||||||
referrer_url: None,
|
referrer_url: None,
|
||||||
referrer_policy: None,
|
referrer_policy: None,
|
||||||
pipeline_id: Some(global_scope.pipeline_id()),
|
pipeline_id: Some(global.pipeline_id()),
|
||||||
};
|
};
|
||||||
|
|
||||||
let (devtools_sender, devtools_receiver) = ipc::channel().unwrap();
|
let (devtools_sender, devtools_receiver) = ipc::channel().unwrap();
|
||||||
let worker_id = global_scope.get_next_worker_id();
|
let worker_id = global.get_next_worker_id();
|
||||||
if let Some(ref chan) = global_scope.devtools_chan() {
|
if let Some(ref chan) = global.devtools_chan() {
|
||||||
let pipeline_id = global_scope.pipeline_id();
|
let pipeline_id = global.pipeline_id();
|
||||||
let title = format!("Worker for {}", worker_url);
|
let title = format!("Worker for {}", worker_url);
|
||||||
let page_info = DevtoolsPageInfo {
|
let page_info = DevtoolsPageInfo {
|
||||||
title: title,
|
title: title,
|
||||||
|
@ -105,11 +103,11 @@ impl Worker {
|
||||||
page_info));
|
page_info));
|
||||||
}
|
}
|
||||||
|
|
||||||
let init = prepare_workerscope_init(global_scope, Some(devtools_sender));
|
let init = prepare_workerscope_init(global, Some(devtools_sender));
|
||||||
|
|
||||||
DedicatedWorkerGlobalScope::run_worker_scope(
|
DedicatedWorkerGlobalScope::run_worker_scope(
|
||||||
init, worker_url, devtools_receiver, worker.runtime.clone(), worker_ref,
|
init, worker_url, devtools_receiver, worker.runtime.clone(), worker_ref,
|
||||||
global_scope.script_chan(), sender, receiver, worker_load_origin, closing);
|
global.script_chan(), sender, receiver, worker_load_origin, closing);
|
||||||
|
|
||||||
Ok(worker)
|
Ok(worker)
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,8 +206,8 @@ impl XMLHttpRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#constructors
|
// https://xhr.spec.whatwg.org/#constructors
|
||||||
pub fn Constructor(global: GlobalRef) -> Fallible<Root<XMLHttpRequest>> {
|
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<XMLHttpRequest>> {
|
||||||
Ok(XMLHttpRequest::new(global.as_global_scope()))
|
Ok(XMLHttpRequest::new(global))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sync_in_window(&self) -> bool {
|
fn sync_in_window(&self) -> bool {
|
||||||
|
|
|
@ -75,7 +75,7 @@ pub fn Fetch(global: GlobalRef, input: RequestOrUSVString, init: &RequestInit) -
|
||||||
let response = Response::new(global_scope);
|
let response = Response::new(global_scope);
|
||||||
|
|
||||||
// Step 2
|
// Step 2
|
||||||
let request = match Request::Constructor(global, input, init) {
|
let request = match Request::Constructor(global_scope, input, init) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
promise.reject_error(promise.global().r().get_cx(), e);
|
promise.reject_error(promise.global().r().get_cx(), e);
|
||||||
return promise;
|
return promise;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue