diff options
Diffstat (limited to 'components')
56 files changed, 198 insertions, 245 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 3bc6f088a23..8a2ea4ed2c3 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -3438,7 +3438,7 @@ class CGStaticMethod(CGAbstractStaticBindingMethod): nativeName = CGSpecializedMethod.makeNativeName(self.descriptor, self.method) 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]) @@ -3492,7 +3492,7 @@ class CGStaticGetter(CGAbstractStaticBindingMethod): nativeName = CGSpecializedGetter.makeNativeName(self.descriptor, self.attr) 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) return CGList([setupArgs, call]) @@ -3545,7 +3545,7 @@ class CGStaticSetter(CGAbstractStaticBindingMethod): " throw_type_error(cx, \"Not enough arguments to %s setter.\");\n" " return false;\n" "}" % 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) return CGList([checkForArg, call]) @@ -5257,7 +5257,7 @@ let args = CallArgs::from_vp(vp, argc); """) name = self.constructor.identifier.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) return CGList([preamble, callGenerator]) diff --git a/components/script/dom/bindings/mod.rs b/components/script/dom/bindings/mod.rs index 013484a47b9..56cff520ef0 100644 --- a/components/script/dom/bindings/mod.rs +++ b/components/script/dom/bindings/mod.rs @@ -43,8 +43,9 @@ //! [`Fallible<T>`](error/type.Fallible.html). //! Methods that use certain WebIDL types like `any` or `object` will get a //! `*mut JSContext` argument prepended to the argument list. Static methods -//! will be passed a [`GlobalRef`](global/enum.GlobalRef.html) for the relevant -//! global. This argument comes before the `*mut JSContext` argument, if any. +//! will be passed a [`&GlobalScope`](../globalscope/struct.GlobalScope.html) +//! for the relevant global. This argument comes before the `*mut JSContext` +//! argument, if any. //! //! Rust reflections of WebIDL operations (methods) //! ----------------------------------------------- @@ -79,7 +80,7 @@ //! //! A WebIDL constructor is turned into a static class method named //! `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 //! that of a method returning an instance of MyInterface. Constructors are //! always [allowed to throw](#throwing-exceptions). diff --git a/components/script/dom/blob.rs b/components/script/dom/blob.rs index c472554357c..ad8e9a5d898 100644 --- a/components/script/dom/blob.rs +++ b/components/script/dom/blob.rs @@ -7,7 +7,6 @@ use dom::bindings::codegen::Bindings::BlobBinding; use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods; use dom::bindings::codegen::UnionTypes::BlobOrString; use dom::bindings::error::{Error, Fallible}; -use dom::bindings::global::GlobalRef; use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::str::DOMString; @@ -121,7 +120,7 @@ impl Blob { } // https://w3c.github.io/FileAPI/#constructorBlob - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, blobParts: Option<Vec<BlobOrString>>, blobPropertyBag: &BlobBinding::BlobPropertyBag) -> 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 diff --git a/components/script/dom/bluetoothuuid.rs b/components/script/dom/bluetoothuuid.rs index e9669cc8acb..11fb7af94cb 100644 --- a/components/script/dom/bluetoothuuid.rs +++ b/components/script/dom/bluetoothuuid.rs @@ -5,9 +5,9 @@ use dom::bindings::codegen::UnionTypes::StringOrUnsignedLong; use dom::bindings::error::Error::Syntax; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::reflector::Reflector; use dom::bindings::str::DOMString; +use dom::globalscope::GlobalScope; use regex::Regex; 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 { // 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) } // 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) } // 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) } // 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) } } diff --git a/components/script/dom/closeevent.rs b/components/script/dom/closeevent.rs index 7a076df8362..a66af7bd75f 100644 --- a/components/script/dom/closeevent.rs +++ b/components/script/dom/closeevent.rs @@ -6,7 +6,6 @@ use dom::bindings::codegen::Bindings::CloseEventBinding; use dom::bindings::codegen::Bindings::CloseEventBinding::CloseEventMethods; use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; @@ -58,13 +57,13 @@ impl CloseEvent { ev } - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, type_: DOMString, init: &CloseEventBinding::CloseEventInit) -> Fallible<Root<CloseEvent>> { let bubbles = EventBubbles::from(init.parent.bubbles); let cancelable = EventCancelable::from(init.parent.cancelable); - Ok(CloseEvent::new(global.as_global_scope(), + Ok(CloseEvent::new(global, Atom::from(type_), bubbles, cancelable, diff --git a/components/script/dom/comment.rs b/components/script/dom/comment.rs index 2eec7652e25..875544202d7 100644 --- a/components/script/dom/comment.rs +++ b/components/script/dom/comment.rs @@ -5,11 +5,11 @@ use dom::bindings::codegen::Bindings::CommentBinding; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::js::Root; use dom::bindings::str::DOMString; use dom::characterdata::CharacterData; use dom::document::Document; +use dom::globalscope::GlobalScope; use dom::node::Node; /// An HTML comment. @@ -31,8 +31,8 @@ impl Comment { CommentBinding::Wrap) } - pub fn Constructor(global: GlobalRef, data: DOMString) -> Fallible<Root<Comment>> { - let document = global.as_global_scope().as_window().Document(); + pub fn Constructor(global: &GlobalScope, data: DOMString) -> Fallible<Root<Comment>> { + let document = global.as_window().Document(); Ok(Comment::new(data, document.r())) } } diff --git a/components/script/dom/console.rs b/components/script/dom/console.rs index 8350b05b10f..d9df56ebef0 100644 --- a/components/script/dom/console.rs +++ b/components/script/dom/console.rs @@ -3,7 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use devtools_traits::{ConsoleMessage, LogLevel, ScriptToDevtoolsControlMsg}; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::str::DOMString; use dom::globalscope::GlobalScope; @@ -30,71 +29,71 @@ impl Console { impl Console { // 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 { 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 - pub fn Debug(global: GlobalRef, messages: Vec<DOMString>) { + pub fn Debug(global: &GlobalScope, messages: Vec<DOMString>) { for message in messages { 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 - pub fn Info(global: GlobalRef, messages: Vec<DOMString>) { + pub fn Info(global: &GlobalScope, messages: Vec<DOMString>) { for message in messages { 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 - pub fn Warn(global: GlobalRef, messages: Vec<DOMString>) { + pub fn Warn(global: &GlobalScope, messages: Vec<DOMString>) { for message in messages { 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 - pub fn Error(global: GlobalRef, messages: Vec<DOMString>) { + pub fn Error(global: &GlobalScope, messages: Vec<DOMString>) { for message in messages { 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 - pub fn Assert(global: GlobalRef, condition: bool, message: Option<DOMString>) { + pub fn Assert(global: &GlobalScope, condition: bool, message: Option<DOMString>) { if !condition { let message = message.unwrap_or_else(|| DOMString::from("no 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 - pub fn Time(global: GlobalRef, label: DOMString) { - if let Ok(()) = global.as_global_scope().time(label.clone()) { + pub fn Time(global: &GlobalScope, label: DOMString) { + if let Ok(()) = global.time(label.clone()) { let message = DOMString::from(format!("{}: timer started", label)); 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 - pub fn TimeEnd(global: GlobalRef, label: DOMString) { - if let Ok(delta) = global.as_global_scope().time_end(&label) { + pub fn TimeEnd(global: &GlobalScope, label: DOMString) { + if let Ok(delta) = global.time_end(&label) { let message = DOMString::from( format!("{}: {}ms", label, delta) ); println!("{}", message); - Self::send_to_devtools(global.as_global_scope(), LogLevel::Log, message); + Self::send_to_devtools(global, LogLevel::Log, message); }; } } diff --git a/components/script/dom/css.rs b/components/script/dom/css.rs index 105de8ec9c1..f2256007aeb 100644 --- a/components/script/dom/css.rs +++ b/components/script/dom/css.rs @@ -4,9 +4,9 @@ use cssparser::serialize_identifier; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::reflector::Reflector; use dom::bindings::str::DOMString; +use dom::globalscope::GlobalScope; #[dom_struct] pub struct CSS { @@ -15,7 +15,7 @@ pub struct CSS { impl CSS { // 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(); serialize_identifier(&ident, &mut escaped).unwrap(); Ok(DOMString::from(escaped)) diff --git a/components/script/dom/customevent.rs b/components/script/dom/customevent.rs index 043fd98193c..d7e026d69bc 100644 --- a/components/script/dom/customevent.rs +++ b/components/script/dom/customevent.rs @@ -6,7 +6,6 @@ use dom::bindings::codegen::Bindings::CustomEventBinding; use dom::bindings::codegen::Bindings::CustomEventBinding::CustomEventMethods; use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::{MutHeapJSVal, Root}; use dom::bindings::reflector::reflect_dom_object; @@ -48,12 +47,13 @@ impl CustomEvent { ev.init_custom_event(type_, bubbles, cancelable, detail); ev } + #[allow(unsafe_code)] - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, type_: DOMString, init: &CustomEventBinding::CustomEventInit) -> Fallible<Root<CustomEvent>> { - Ok(CustomEvent::new(global.as_global_scope(), + Ok(CustomEvent::new(global, Atom::from(type_), init.parent.bubbles, init.parent.cancelable, diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 0fbf4eb9c0c..bf2088bc15c 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -21,7 +21,6 @@ use dom::bindings::codegen::Bindings::TouchBinding::TouchMethods; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::codegen::UnionTypes::NodeOrString; use dom::bindings::error::{Error, ErrorResult, Fallible}; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId}; use dom::bindings::js::{JS, LayoutJS, MutNullableHeap, Root}; use dom::bindings::js::RootedReference; @@ -1819,8 +1818,8 @@ impl Document { } // https://dom.spec.whatwg.org/#dom-document - pub fn Constructor(global: GlobalRef) -> Fallible<Root<Document>> { - let win = global.as_global_scope().as_window(); + pub fn Constructor(global: &GlobalScope) -> Fallible<Root<Document>> { + let win = global.as_window(); let doc = win.Document(); let doc = doc.r(); let docloader = DocumentLoader::new(&*doc.loader()); diff --git a/components/script/dom/documentfragment.rs b/components/script/dom/documentfragment.rs index bf05e36fce3..e71ce0f2d26 100644 --- a/components/script/dom/documentfragment.rs +++ b/components/script/dom/documentfragment.rs @@ -7,12 +7,12 @@ use dom::bindings::codegen::Bindings::DocumentFragmentBinding::DocumentFragmentM use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::codegen::UnionTypes::NodeOrString; use dom::bindings::error::{ErrorResult, Fallible}; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::Element; +use dom::globalscope::GlobalScope; use dom::htmlcollection::HTMLCollection; use dom::node::{Node, window_from_node}; use dom::nodelist::NodeList; @@ -38,8 +38,8 @@ impl DocumentFragment { DocumentFragmentBinding::Wrap) } - pub fn Constructor(global: GlobalRef) -> Fallible<Root<DocumentFragment>> { - let document = global.as_global_scope().as_window().Document(); + pub fn Constructor(global: &GlobalScope) -> Fallible<Root<DocumentFragment>> { + let document = global.as_window().Document(); Ok(DocumentFragment::new(document.r())) } diff --git a/components/script/dom/dommatrix.rs b/components/script/dom/dommatrix.rs index 2ccf4b126fb..dbe7a27516c 100644 --- a/components/script/dom/dommatrix.rs +++ b/components/script/dom/dommatrix.rs @@ -5,7 +5,6 @@ use dom::bindings::codegen::Bindings::DOMMatrixBinding::{Wrap, DOMMatrixMethods, DOMMatrixInit}; use dom::bindings::codegen::Bindings::DOMMatrixReadOnlyBinding::DOMMatrixReadOnlyMethods; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; @@ -33,23 +32,23 @@ impl 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]) } // 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[..]) .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 - pub fn FromMatrix(global: GlobalRef, other: &DOMMatrixInit) -> Fallible<Root<Self>> { + pub fn FromMatrix(global: &GlobalScope, other: &DOMMatrixInit) -> Fallible<Root<Self>> { dommatrixinit_to_matrix(&other) .map(|(is2D, matrix)| { - Self::new(global.as_global_scope(), is2D, matrix) + Self::new(global, is2D, matrix) }) } diff --git a/components/script/dom/dommatrixreadonly.rs b/components/script/dom/dommatrixreadonly.rs index 23feb88a348..1f4a2fc1446 100644 --- a/components/script/dom/dommatrixreadonly.rs +++ b/components/script/dom/dommatrixreadonly.rs @@ -8,7 +8,6 @@ use dom::bindings::codegen::Bindings::DOMMatrixReadOnlyBinding::{DOMMatrixReadOn use dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit; use dom::bindings::error; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::js::Root; use dom::bindings::reflector::{reflect_dom_object, Reflectable, Reflector}; use dom::dommatrix::DOMMatrix; @@ -41,23 +40,23 @@ impl DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly - pub fn Constructor(global: GlobalRef) -> Fallible<Root<Self>> { - Ok(Self::new(global.as_global_scope(), true, Matrix4D::identity())) + pub fn Constructor(global: &GlobalScope) -> Fallible<Root<Self>> { + Ok(Self::new(global, true, Matrix4D::identity())) } // 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[..]) .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 - pub fn FromMatrix(global: GlobalRef, other: &DOMMatrixInit) -> Fallible<Root<Self>> { + pub fn FromMatrix(global: &GlobalScope, other: &DOMMatrixInit) -> Fallible<Root<Self>> { dommatrixinit_to_matrix(&other) .map(|(is2D, matrix)| { - Self::new(global.as_global_scope(), is2D, matrix) + Self::new(global, is2D, matrix) }) } diff --git a/components/script/dom/domparser.rs b/components/script/dom/domparser.rs index 6d830e40bfd..e73d9bf1aad 100644 --- a/components/script/dom/domparser.rs +++ b/components/script/dom/domparser.rs @@ -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::WindowBinding::WindowMethods; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::bindings::str::DOMString; use dom::document::{Document, IsHTMLDocument}; use dom::document::DocumentSource; +use dom::globalscope::GlobalScope; use dom::window::Window; use parse::html::{ParseContext, parse_html}; use parse::xml::{self, parse_xml}; @@ -42,8 +42,8 @@ impl DOMParser { DOMParserBinding::Wrap) } - pub fn Constructor(global: GlobalRef) -> Fallible<Root<DOMParser>> { - Ok(DOMParser::new(global.as_global_scope().as_window())) + pub fn Constructor(global: &GlobalScope) -> Fallible<Root<DOMParser>> { + Ok(DOMParser::new(global.as_window())) } } diff --git a/components/script/dom/dompoint.rs b/components/script/dom/dompoint.rs index 49a873a25fc..2f77f77c2c1 100644 --- a/components/script/dom/dompoint.rs +++ b/components/script/dom/dompoint.rs @@ -5,7 +5,6 @@ use dom::bindings::codegen::Bindings::DOMPointBinding::{DOMPointInit, DOMPointMethods, Wrap}; use dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::DOMPointReadOnlyMethods; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; use dom::dompointreadonly::{DOMPointReadOnly, DOMPointWriteMethods}; @@ -28,13 +27,13 @@ impl DOMPoint { 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, y: f64, z: f64, w: f64) -> 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> { diff --git a/components/script/dom/dompointreadonly.rs b/components/script/dom/dompointreadonly.rs index f905db356ca..9da4e27a984 100644 --- a/components/script/dom/dompointreadonly.rs +++ b/components/script/dom/dompointreadonly.rs @@ -4,7 +4,6 @@ use dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::{DOMPointReadOnlyMethods, Wrap}; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::globalscope::GlobalScope; @@ -37,13 +36,13 @@ impl DOMPointReadOnly { Wrap) } - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, x: f64, y: f64, z: f64, w: f64) -> Fallible<Root<DOMPointReadOnly>> { - Ok(DOMPointReadOnly::new(global.as_global_scope(), x, y, z, w)) + Ok(DOMPointReadOnly::new(global, x, y, z, w)) } } diff --git a/components/script/dom/domquad.rs b/components/script/dom/domquad.rs index f4a388df284..abe30f80bdd 100644 --- a/components/script/dom/domquad.rs +++ b/components/script/dom/domquad.rs @@ -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::DOMRectReadOnlyBinding::DOMRectInit; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::js::{Root, JS}; use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object}; use dom::dompoint::DOMPoint; @@ -48,13 +47,12 @@ impl DOMQuad { Wrap) } - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, p1: &DOMPointInit, p2: &DOMPointInit, p3: &DOMPointInit, p4: &DOMPointInit) -> Fallible<Root<DOMQuad>> { - let global = global.as_global_scope(); Ok(DOMQuad::new(global, &*DOMPoint::new_from_init(global, p1), &*DOMPoint::new_from_init(global, p2), @@ -63,8 +61,7 @@ impl DOMQuad { } // https://drafts.fxtf.org/geometry/#dom-domquad-fromrect - pub fn FromRect(global: GlobalRef, other: &DOMRectInit) -> Root<DOMQuad> { - let global = global.as_global_scope(); + pub fn FromRect(global: &GlobalScope, other: &DOMRectInit) -> Root<DOMQuad> { DOMQuad::new(global, &*DOMPoint::new(global, other.x, 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 - pub fn FromQuad(global: GlobalRef, other: &DOMQuadInit) -> Root<DOMQuad> { - let global = global.as_global_scope(); + pub fn FromQuad(global: &GlobalScope, other: &DOMQuadInit) -> Root<DOMQuad> { DOMQuad::new(global, &DOMPoint::new_from_init(global, &other.p1), &DOMPoint::new_from_init(global, &other.p2), diff --git a/components/script/dom/domrect.rs b/components/script/dom/domrect.rs index f70eda2ead1..78e1b2db22e 100644 --- a/components/script/dom/domrect.rs +++ b/components/script/dom/domrect.rs @@ -6,7 +6,6 @@ use dom::bindings::codegen::Bindings::DOMRectBinding; use dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods; use dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::DOMRectReadOnlyMethods; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; use dom::domrectreadonly::DOMRectReadOnly; @@ -30,13 +29,13 @@ impl DOMRect { DOMRectBinding::Wrap) } - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, x: f64, y: f64, width: f64, height: f64) -> Fallible<Root<DOMRect>> { - Ok(DOMRect::new(global.as_global_scope(), x, y, width, height)) + Ok(DOMRect::new(global, x, y, width, height)) } } diff --git a/components/script/dom/domrectreadonly.rs b/components/script/dom/domrectreadonly.rs index a9d87ec3947..ef0c7ce2c67 100644 --- a/components/script/dom/domrectreadonly.rs +++ b/components/script/dom/domrectreadonly.rs @@ -4,7 +4,6 @@ use dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::{DOMRectReadOnlyMethods, Wrap}; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::globalscope::GlobalScope; @@ -41,13 +40,13 @@ impl DOMRectReadOnly { Wrap) } - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, x: f64, y: f64, width: f64, height: f64) -> 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) { diff --git a/components/script/dom/errorevent.rs b/components/script/dom/errorevent.rs index 394ce749cdb..edf1118b58c 100644 --- a/components/script/dom/errorevent.rs +++ b/components/script/dom/errorevent.rs @@ -7,7 +7,6 @@ use dom::bindings::codegen::Bindings::ErrorEventBinding; use dom::bindings::codegen::Bindings::ErrorEventBinding::ErrorEventMethods; use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::{MutHeapJSVal, Root}; use dom::bindings::reflector::reflect_dom_object; @@ -71,7 +70,7 @@ impl ErrorEvent { ev } - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, type_: DOMString, init: &ErrorEventBinding::ErrorEventInit) -> Fallible<Root<ErrorEvent>>{ let msg = match init.message.as_ref() { @@ -96,7 +95,7 @@ impl ErrorEvent { // https://github.com/servo/servo/issues/6381 rooted!(in(global.get_cx()) let error = init.error); let event = ErrorEvent::new( - global.as_global_scope(), + global, Atom::from(type_), bubbles, cancelable, diff --git a/components/script/dom/event.rs b/components/script/dom/event.rs index 3f5a7c24c8a..cdbfdafec2e 100644 --- a/components/script/dom/event.rs +++ b/components/script/dom/event.rs @@ -6,7 +6,6 @@ use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::EventBinding; use dom::bindings::codegen::Bindings::EventBinding::{EventConstants, EventMethods}; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::js::{JS, MutNullableHeap, Root}; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::{Reflector, reflect_dom_object}; @@ -131,12 +130,12 @@ impl Event { event } - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, type_: DOMString, init: &EventBinding::EventInit) -> Fallible<Root<Event>> { let bubbles = EventBubbles::from(init.bubbles); 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) { diff --git a/components/script/dom/eventsource.rs b/components/script/dom/eventsource.rs index bf83bed4c5c..f05e73beafa 100644 --- a/components/script/dom/eventsource.rs +++ b/components/script/dom/eventsource.rs @@ -6,7 +6,6 @@ use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::Bindings::EventSourceBinding::{EventSourceInit, EventSourceMethods, Wrap}; use dom::bindings::error::{Error, Fallible}; -use dom::bindings::global::GlobalRef; use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; use dom::bindings::str::DOMString; @@ -49,18 +48,17 @@ impl EventSource { Wrap) } - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, url_str: DOMString, event_source_init: &EventSourceInit) -> Fallible<Root<EventSource>> { - let global_scope = global.as_global_scope(); // Steps 1-2 - let base_url = global_scope.get_url(); + let base_url = global.get_url(); let url = match base_url.join(&*url_str) { Ok(u) => u, Err(_) => return Err(Error::Syntax) }; // 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 5 // Step 6 diff --git a/components/script/dom/extendableevent.rs b/components/script/dom/extendableevent.rs index 1888888e841..d859d8f4724 100644 --- a/components/script/dom/extendableevent.rs +++ b/components/script/dom/extendableevent.rs @@ -5,7 +5,6 @@ use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::ExtendableEventBinding; use dom::bindings::error::{Error, ErrorResult, Fallible}; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; @@ -42,10 +41,10 @@ impl ExtendableEvent { ev } - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, type_: DOMString, init: &ExtendableEventBinding::ExtendableEventInit) -> Fallible<Root<ExtendableEvent>> { - Ok(ExtendableEvent::new(global.as_global_scope(), + Ok(ExtendableEvent::new(global, Atom::from(type_), init.parent.bubbles, init.parent.cancelable)) diff --git a/components/script/dom/extendablemessageevent.rs b/components/script/dom/extendablemessageevent.rs index 8acddbaf7fa..0a5968d1d99 100644 --- a/components/script/dom/extendablemessageevent.rs +++ b/components/script/dom/extendablemessageevent.rs @@ -5,7 +5,6 @@ use dom::bindings::codegen::Bindings::ExtendableMessageEventBinding; use dom::bindings::codegen::Bindings::ExtendableMessageEventBinding::ExtendableMessageEventMethods; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; @@ -47,12 +46,12 @@ impl ExtendableMessageEvent { ev } - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, type_: DOMString, init: &ExtendableMessageEventBinding::ExtendableMessageEventInit) -> Fallible<Root<ExtendableMessageEvent>> { 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_), init.parent.parent.bubbles, init.parent.parent.cancelable, diff --git a/components/script/dom/file.rs b/components/script/dom/file.rs index 6ee2f0c3771..dba94a85e50 100644 --- a/components/script/dom/file.rs +++ b/components/script/dom/file.rs @@ -6,7 +6,6 @@ use dom::bindings::codegen::Bindings::FileBinding; use dom::bindings::codegen::Bindings::FileBinding::FileMethods; use dom::bindings::codegen::UnionTypes::BlobOrString; use dom::bindings::error::{Error, Fallible}; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; @@ -59,7 +58,7 @@ impl File { } // https://w3c.github.io/FileAPI/#file-constructor - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, fileBits: Vec<BlobOrString>, filename: DOMString, filePropertyBag: &FileBinding::FilePropertyBag) @@ -76,11 +75,11 @@ impl File { // NOTE: Following behaviour might be removed in future, // see https://github.com/w3c/FileAPI/issues/41 let replaced_filename = DOMString::from_string(filename.replace("/", ":")); - Ok(File::new(global.as_global_scope(), - BlobImpl::new_from_bytes(bytes), - replaced_filename, - modified, - typeString)) + Ok(File::new(global, + BlobImpl::new_from_bytes(bytes), + replaced_filename, + modified, + typeString)) } pub fn name(&self) -> &DOMString { diff --git a/components/script/dom/filereader.rs b/components/script/dom/filereader.rs index afd291c8f62..4ba5af109be 100644 --- a/components/script/dom/filereader.rs +++ b/components/script/dom/filereader.rs @@ -7,7 +7,6 @@ use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods; use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::Bindings::FileReaderBinding::{self, FileReaderConstants, FileReaderMethods}; use dom::bindings::error::{Error, ErrorResult, Fallible}; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::{JS, MutNullableHeap, Root}; use dom::bindings::refcounted::Trusted; @@ -94,8 +93,8 @@ impl FileReader { global, FileReaderBinding::Wrap) } - pub fn Constructor(global: GlobalRef) -> Fallible<Root<FileReader>> { - Ok(FileReader::new(global.as_global_scope())) + pub fn Constructor(global: &GlobalScope) -> Fallible<Root<FileReader>> { + Ok(FileReader::new(global)) } //https://w3c.github.io/FileAPI/#dfn-error-steps diff --git a/components/script/dom/filereadersync.rs b/components/script/dom/filereadersync.rs index 3e8800a65bf..875843ea0c6 100644 --- a/components/script/dom/filereadersync.rs +++ b/components/script/dom/filereadersync.rs @@ -4,7 +4,6 @@ use dom::bindings::codegen::Bindings::FileReaderSyncBinding; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; use dom::eventtarget::EventTarget; @@ -27,7 +26,7 @@ impl FileReaderSync { global, FileReaderSyncBinding::Wrap) } - pub fn Constructor(global: GlobalRef) -> Fallible<Root<FileReaderSync>> { - Ok(FileReaderSync::new(global.as_global_scope())) + pub fn Constructor(global: &GlobalScope) -> Fallible<Root<FileReaderSync>> { + Ok(FileReaderSync::new(global)) } } diff --git a/components/script/dom/focusevent.rs b/components/script/dom/focusevent.rs index 8d3f6b57256..d06b725286d 100644 --- a/components/script/dom/focusevent.rs +++ b/components/script/dom/focusevent.rs @@ -6,7 +6,6 @@ use dom::bindings::codegen::Bindings::FocusEventBinding; use dom::bindings::codegen::Bindings::FocusEventBinding::FocusEventMethods; use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference}; use dom::bindings::reflector::reflect_dom_object; @@ -54,12 +53,12 @@ impl FocusEvent { ev } - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, type_: DOMString, init: &FocusEventBinding::FocusEventInit) -> Fallible<Root<FocusEvent>> { let bubbles = EventBubbles::from(init.parent.parent.bubbles); 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_, bubbles, cancelable, diff --git a/components/script/dom/formdata.rs b/components/script/dom/formdata.rs index 50747245c21..8bbd46833b3 100644 --- a/components/script/dom/formdata.rs +++ b/components/script/dom/formdata.rs @@ -7,7 +7,6 @@ use dom::bindings::codegen::Bindings::FormDataBinding::FormDataMethods; use dom::bindings::codegen::Bindings::FormDataBinding::FormDataWrap; use dom::bindings::codegen::UnionTypes::FileOrUSVString; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::iterable::Iterable; use dom::bindings::js::Root; use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object}; @@ -51,9 +50,9 @@ impl FormData { 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 - Ok(FormData::new(form, global.as_global_scope())) + Ok(FormData::new(form, global)) } } diff --git a/components/script/dom/hashchangeevent.rs b/components/script/dom/hashchangeevent.rs index c97599b25a3..0fd753c433c 100644 --- a/components/script/dom/hashchangeevent.rs +++ b/components/script/dom/hashchangeevent.rs @@ -6,7 +6,6 @@ use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::HashChangeEventBinding; use dom::bindings::codegen::Bindings::HashChangeEventBinding::HashChangeEventMethods; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; @@ -55,11 +54,11 @@ impl HashChangeEvent { ev } - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, type_: DOMString, init: &HashChangeEventBinding::HashChangeEventInit) -> Fallible<Root<HashChangeEvent>> { - Ok(HashChangeEvent::new(global.as_global_scope(), + Ok(HashChangeEvent::new(global, Atom::from(type_), init.parent.bubbles, init.parent.cancelable, diff --git a/components/script/dom/headers.rs b/components/script/dom/headers.rs index 68c3d92c0ad..02262dbb475 100644 --- a/components/script/dom/headers.rs +++ b/components/script/dom/headers.rs @@ -5,7 +5,6 @@ use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::HeadersBinding::{HeadersInit, HeadersMethods, HeadersWrap}; use dom::bindings::error::{Error, ErrorResult, Fallible}; -use dom::bindings::global::GlobalRef; use dom::bindings::iterable::Iterable; use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; @@ -49,9 +48,9 @@ impl 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>> { - let dom_headers_new = Headers::new(global.as_global_scope()); + let dom_headers_new = Headers::new(global); try!(dom_headers_new.fill(init)); Ok(dom_headers_new) } diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index d96bb0cab3a..489a6821824 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -17,6 +17,7 @@ use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers}; use dom::eventtarget::EventTarget; +use dom::globalscope::GlobalScope; use dom::htmlelement::HTMLElement; use dom::node::{Node, NodeDamage, document_from_node, window_from_node}; use dom::values::UNSIGNED_LONG_MAX; @@ -225,10 +226,10 @@ impl HTMLImageElement { HTMLImageElementBinding::Wrap) } - pub fn Image(global: GlobalRef, + pub fn Image(global: &GlobalScope, width: Option<u32>, 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()); if let Some(w) = width { image.SetWidth(w); diff --git a/components/script/dom/keyboardevent.rs b/components/script/dom/keyboardevent.rs index 812b9f63051..4da24309e18 100644 --- a/components/script/dom/keyboardevent.rs +++ b/components/script/dom/keyboardevent.rs @@ -7,12 +7,12 @@ use dom::bindings::codegen::Bindings::KeyboardEventBinding; use dom::bindings::codegen::Bindings::KeyboardEventBinding::{KeyboardEventConstants, KeyboardEventMethods}; use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::{Root, RootedReference}; use dom::bindings::reflector::reflect_dom_object; use dom::bindings::str::DOMString; use dom::event::Event; +use dom::globalscope::GlobalScope; use dom::uievent::UIEvent; use dom::window::Window; use msg::constellation_msg; @@ -101,10 +101,10 @@ impl KeyboardEvent { ev } - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, type_: DOMString, init: &KeyboardEventBinding::KeyboardEventInit) -> Fallible<Root<KeyboardEvent>> { - let event = KeyboardEvent::new(global.as_global_scope().as_window(), + let event = KeyboardEvent::new(global.as_window(), type_, init.parent.parent.parent.bubbles, init.parent.parent.parent.cancelable, diff --git a/components/script/dom/messageevent.rs b/components/script/dom/messageevent.rs index 8192c8301cf..53143711cf0 100644 --- a/components/script/dom/messageevent.rs +++ b/components/script/dom/messageevent.rs @@ -6,7 +6,6 @@ use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::MessageEventBinding; use dom::bindings::codegen::Bindings::MessageEventBinding::MessageEventMethods; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; @@ -61,14 +60,14 @@ impl MessageEvent { ev } - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, type_: DOMString, init: &MessageEventBinding::MessageEventInit) -> Fallible<Root<MessageEvent>> { // Dictionaries need to be rooted // https://github.com/servo/servo/issues/6381 rooted!(in(global.get_cx()) let data = init.data); - let ev = MessageEvent::new(global.as_global_scope(), + let ev = MessageEvent::new(global, Atom::from(type_), init.parent.bubbles, init.parent.cancelable, diff --git a/components/script/dom/mouseevent.rs b/components/script/dom/mouseevent.rs index 41c7d88dc6d..27a61c79400 100644 --- a/components/script/dom/mouseevent.rs +++ b/components/script/dom/mouseevent.rs @@ -6,13 +6,13 @@ use dom::bindings::codegen::Bindings::MouseEventBinding; use dom::bindings::codegen::Bindings::MouseEventBinding::MouseEventMethods; use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference}; use dom::bindings::reflector::reflect_dom_object; use dom::bindings::str::DOMString; use dom::event::{Event, EventBubbles, EventCancelable}; use dom::eventtarget::EventTarget; +use dom::globalscope::GlobalScope; use dom::uievent::UIEvent; use dom::window::Window; use std::cell::Cell; @@ -82,12 +82,12 @@ impl MouseEvent { ev } - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, type_: DOMString, init: &MouseEventBinding::MouseEventInit) -> Fallible<Root<MouseEvent>> { let bubbles = EventBubbles::from(init.parent.parent.parent.bubbles); 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_, bubbles, cancelable, diff --git a/components/script/dom/pagetransitionevent.rs b/components/script/dom/pagetransitionevent.rs index c25281dcc31..883f3319394 100644 --- a/components/script/dom/pagetransitionevent.rs +++ b/components/script/dom/pagetransitionevent.rs @@ -6,7 +6,6 @@ use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::PageTransitionEventBinding; use dom::bindings::codegen::Bindings::PageTransitionEventBinding::PageTransitionEventMethods; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; @@ -52,11 +51,11 @@ impl PageTransitionEvent { ev } - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, type_: DOMString, init: &PageTransitionEventBinding::PageTransitionEventInit) -> Fallible<Root<PageTransitionEvent>> { - Ok(PageTransitionEvent::new(global.as_global_scope(), + Ok(PageTransitionEvent::new(global, Atom::from(type_), init.parent.bubbles, init.parent.cancelable, diff --git a/components/script/dom/popstateevent.rs b/components/script/dom/popstateevent.rs index 621c9d4199f..7b7af62a6fe 100644 --- a/components/script/dom/popstateevent.rs +++ b/components/script/dom/popstateevent.rs @@ -6,7 +6,6 @@ use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::PopStateEventBinding; use dom::bindings::codegen::Bindings::PopStateEventBinding::PopStateEventMethods; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::{MutHeapJSVal, Root}; use dom::bindings::reflector::reflect_dom_object; @@ -55,11 +54,11 @@ impl PopStateEvent { } #[allow(unsafe_code)] - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, type_: DOMString, init: &PopStateEventBinding::PopStateEventInit) -> Fallible<Root<PopStateEvent>> { - Ok(PopStateEvent::new(global.as_global_scope(), + Ok(PopStateEvent::new(global, Atom::from(type_), init.parent.bubbles, init.parent.cancelable, diff --git a/components/script/dom/progressevent.rs b/components/script/dom/progressevent.rs index 2f25df109fa..189f65412fe 100644 --- a/components/script/dom/progressevent.rs +++ b/components/script/dom/progressevent.rs @@ -6,7 +6,6 @@ use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::ProgressEventBinding; use dom::bindings::codegen::Bindings::ProgressEventBinding::ProgressEventMethods; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; @@ -49,13 +48,13 @@ impl ProgressEvent { } ev } - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, type_: DOMString, init: &ProgressEventBinding::ProgressEventInit) -> Fallible<Root<ProgressEvent>> { let bubbles = EventBubbles::from(init.parent.bubbles); 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); Ok(ev) } diff --git a/components/script/dom/range.rs b/components/script/dom/range.rs index 7e636164da5..480740fa19f 100644 --- a/components/script/dom/range.rs +++ b/components/script/dom/range.rs @@ -11,7 +11,6 @@ use dom::bindings::codegen::Bindings::RangeBinding::RangeMethods; use dom::bindings::codegen::Bindings::TextBinding::TextMethods; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::error::{Error, ErrorResult, Fallible}; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::{CharacterDataTypeId, NodeTypeId}; use dom::bindings::inheritance::Castable; use dom::bindings::js::{JS, MutHeap, Root, RootedReference}; @@ -23,6 +22,7 @@ use dom::characterdata::CharacterData; use dom::document::Document; use dom::documentfragment::DocumentFragment; use dom::element::Element; +use dom::globalscope::GlobalScope; use dom::htmlbodyelement::HTMLBodyElement; use dom::htmlscriptelement::HTMLScriptElement; use dom::node::{Node, UnbindContext}; @@ -70,8 +70,8 @@ impl Range { } // https://dom.spec.whatwg.org/#dom-range - pub fn Constructor(global: GlobalRef) -> Fallible<Root<Range>> { - let document = global.as_global_scope().as_window().Document(); + pub fn Constructor(global: &GlobalScope) -> Fallible<Root<Range>> { + let document = global.as_window().Document(); Ok(Range::new_with_doc(document.r())) } diff --git a/components/script/dom/request.rs b/components/script/dom/request.rs index 664b2ca5302..623a8037f62 100644 --- a/components/script/dom/request.rs +++ b/components/script/dom/request.rs @@ -17,7 +17,6 @@ use dom::bindings::codegen::Bindings::RequestBinding::RequestMode; use dom::bindings::codegen::Bindings::RequestBinding::RequestRedirect; use dom::bindings::codegen::Bindings::RequestBinding::RequestType; use dom::bindings::error::{Error, Fallible}; -use dom::bindings::global::GlobalRef; use dom::bindings::js::{JS, MutNullableHeap, Root}; use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::str::{ByteString, DOMString, USVString}; @@ -78,12 +77,10 @@ impl Request { } // https://fetch.spec.whatwg.org/#dom-request - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, input: RequestInfo, init: &RequestInit) -> Fallible<Root<Request>> { - let global_scope = global.as_global_scope(); - // Step 1 let temporary_request: NetTraitsRequest; @@ -95,7 +92,7 @@ impl Request { // Step 4 // 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 { // Step 5 @@ -112,7 +109,7 @@ impl Request { return Err(Error::Type("Url includes credentials".to_string())) } // Step 5.4 - temporary_request = net_request_from_global(&global_scope, + temporary_request = net_request_from_global(global, url, false); // Step 5.5 @@ -153,7 +150,7 @@ impl Request { // Step 12 let mut request: NetTraitsRequest; - request = net_request_from_global(&global_scope, + request = net_request_from_global(global, temporary_request.current_url(), false); request.method = temporary_request.method; @@ -305,7 +302,7 @@ impl Request { } // Step 26 - let r = Request::from_net_request(&global_scope, + let r = Request::from_net_request(global, false, request); r.headers.or_init(|| Headers::for_request(&r.global_scope())); diff --git a/components/script/dom/response.rs b/components/script/dom/response.rs index 4e7d4967d28..febff29f97b 100644 --- a/components/script/dom/response.rs +++ b/components/script/dom/response.rs @@ -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::XMLHttpRequestBinding::BodyInit; use dom::bindings::error::{Error, Fallible}; -use dom::bindings::global::GlobalRef; use dom::bindings::js::{JS, MutNullableHeap, Root}; use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::str::{ByteString, USVString}; @@ -71,7 +70,7 @@ impl Response { 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>> { // Step 1 if init.status < 200 || init.status > 599 { @@ -87,7 +86,7 @@ impl Response { } // Step 3 - let r = Response::new(global.as_global_scope()); + let r = Response::new(global); // Step 4 *r.status.borrow_mut() = Some(StatusCode::from_u16(init.status)); @@ -139,8 +138,8 @@ impl Response { } // https://fetch.spec.whatwg.org/#dom-response-error - pub fn Error(global: GlobalRef) -> Root<Response> { - let r = Response::new(global.as_global_scope()); + pub fn Error(global: &GlobalScope) -> Root<Response> { + let r = Response::new(global); *r.response_type.borrow_mut() = DOMResponseType::Error; r.Headers().set_guard(Guard::Immutable); *r.raw_status.borrow_mut() = Some((0, b"".to_vec())); @@ -148,11 +147,10 @@ impl Response { } // https://fetch.spec.whatwg.org/#dom-response-redirect - pub fn Redirect(global: GlobalRef, url: USVString, status: u16) -> Fallible<Root<Response>> { - let global_scope = global.as_global_scope(); + pub fn Redirect(global: &GlobalScope, url: USVString, status: u16) -> Fallible<Root<Response>> { // Step 1 // 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); // Step 2 @@ -168,7 +166,7 @@ impl Response { // Step 4 // see Step 4 continued - let r = Response::new(global_scope); + let r = Response::new(global); // Step 5 *r.status.borrow_mut() = Some(StatusCode::from_u16(status)); diff --git a/components/script/dom/storageevent.rs b/components/script/dom/storageevent.rs index 0b4a484ebc0..21c16f1db78 100644 --- a/components/script/dom/storageevent.rs +++ b/components/script/dom/storageevent.rs @@ -6,7 +6,6 @@ use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::StorageEventBinding; use dom::bindings::codegen::Bindings::StorageEventBinding::StorageEventMethods; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference}; use dom::bindings::reflector::reflect_dom_object; @@ -71,7 +70,7 @@ impl StorageEvent { ev } - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, type_: DOMString, init: &StorageEventBinding::StorageEventInit) -> Fallible<Root<StorageEvent>> { let key = init.key.clone(); @@ -81,7 +80,7 @@ impl StorageEvent { let storageArea = init.storageArea.r(); let bubbles = EventBubbles::from(init.parent.bubbles); let cancelable = EventCancelable::from(init.parent.cancelable); - let event = StorageEvent::new(global.as_global_scope(), Atom::from(type_), + let event = StorageEvent::new(global, Atom::from(type_), bubbles, cancelable, key, oldValue, newValue, url, storageArea); diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index eb3defbe6a5..3f4d3dbcaf1 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -21,7 +21,7 @@ use dom::bindings::codegen::UnionTypes::{HTMLElementOrUnsignedLongOrStringOrBool use dom::bindings::codegen::UnionTypes::{StringOrLongSequence, StringOrStringSequence, StringSequenceOrUnsignedLong}; use dom::bindings::codegen::UnionTypes::{StringOrUnsignedLong, StringOrBoolean, UnsignedLongOrBoolean}; 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::mozmap::MozMap; use dom::bindings::num::Finite; @@ -63,18 +63,18 @@ impl TestBinding { global, TestBindingBinding::Wrap) } - pub fn Constructor(global: GlobalRef) -> Fallible<Root<TestBinding>> { - Ok(TestBinding::new(global.as_global_scope())) + pub fn Constructor(global: &GlobalScope) -> Fallible<Root<TestBinding>> { + Ok(TestBinding::new(global)) } #[allow(unused_variables)] - pub fn Constructor_(global: GlobalRef, nums: Vec<f64>) -> Fallible<Root<TestBinding>> { - Ok(TestBinding::new(global.as_global_scope())) + pub fn Constructor_(global: &GlobalScope, nums: Vec<f64>) -> Fallible<Root<TestBinding>> { + Ok(TestBinding::new(global)) } #[allow(unused_variables)] - pub fn Constructor__(global: GlobalRef, num: f64) -> Fallible<Root<TestBinding>> { - Ok(TestBinding::new(global.as_global_scope())) + pub fn Constructor__(global: &GlobalScope, num: f64) -> Fallible<Root<TestBinding>> { + Ok(TestBinding::new(global)) } } @@ -757,17 +757,17 @@ impl TestBindingMethods for TestBinding { } impl TestBinding { - pub fn BooleanAttributeStatic(_: GlobalRef) -> bool { false } - pub fn SetBooleanAttributeStatic(_: GlobalRef, _: bool) {} - pub fn ReceiveVoidStatic(_: GlobalRef) {} - pub fn PrefControlledStaticAttributeDisabled(_: GlobalRef) -> bool { false } - pub fn PrefControlledStaticAttributeEnabled(_: GlobalRef) -> bool { false } - pub fn PrefControlledStaticMethodDisabled(_: GlobalRef) {} - pub fn PrefControlledStaticMethodEnabled(_: GlobalRef) {} - pub fn FuncControlledStaticAttributeDisabled(_: GlobalRef) -> bool { false } - pub fn FuncControlledStaticAttributeEnabled(_: GlobalRef) -> bool { false } - pub fn FuncControlledStaticMethodDisabled(_: GlobalRef) {} - pub fn FuncControlledStaticMethodEnabled(_: GlobalRef) {} + pub fn BooleanAttributeStatic(_: &GlobalScope) -> bool { false } + pub fn SetBooleanAttributeStatic(_: &GlobalScope, _: bool) {} + pub fn ReceiveVoidStatic(_: &GlobalScope) {} + pub fn PrefControlledStaticAttributeDisabled(_: &GlobalScope) -> bool { false } + pub fn PrefControlledStaticAttributeEnabled(_: &GlobalScope) -> bool { false } + pub fn PrefControlledStaticMethodDisabled(_: &GlobalScope) {} + pub fn PrefControlledStaticMethodEnabled(_: &GlobalScope) {} + pub fn FuncControlledStaticAttributeDisabled(_: &GlobalScope) -> bool { false } + pub fn FuncControlledStaticAttributeEnabled(_: &GlobalScope) -> bool { false } + pub fn FuncControlledStaticMethodDisabled(_: &GlobalScope) {} + pub fn FuncControlledStaticMethodEnabled(_: &GlobalScope) {} } #[allow(unsafe_code)] diff --git a/components/script/dom/testbindingiterable.rs b/components/script/dom/testbindingiterable.rs index 6023051d8f6..10045705192 100644 --- a/components/script/dom/testbindingiterable.rs +++ b/components/script/dom/testbindingiterable.rs @@ -7,7 +7,6 @@ use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::TestBindingIterableBinding::{self, TestBindingIterableMethods}; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::bindings::str::DOMString; @@ -27,8 +26,8 @@ impl TestBindingIterable { }, global, TestBindingIterableBinding::Wrap) } - pub fn Constructor(global: GlobalRef) -> Fallible<Root<TestBindingIterable>> { - Ok(TestBindingIterable::new(global.as_global_scope())) + pub fn Constructor(global: &GlobalScope) -> Fallible<Root<TestBindingIterable>> { + Ok(TestBindingIterable::new(global)) } } diff --git a/components/script/dom/testbindingpairiterable.rs b/components/script/dom/testbindingpairiterable.rs index 7e3ad537aa5..f536459c1e9 100644 --- a/components/script/dom/testbindingpairiterable.rs +++ b/components/script/dom/testbindingpairiterable.rs @@ -8,7 +8,6 @@ use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::TestBindingPairIterableBinding; use dom::bindings::codegen::Bindings::TestBindingPairIterableBinding::TestBindingPairIterableMethods; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::iterable::Iterable; use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; @@ -43,8 +42,8 @@ impl TestBindingPairIterable { }, global, TestBindingPairIterableBinding::TestBindingPairIterableWrap) } - pub fn Constructor(global: GlobalRef) -> Fallible<Root<TestBindingPairIterable>> { - Ok(TestBindingPairIterable::new(global.as_global_scope())) + pub fn Constructor(global: &GlobalScope) -> Fallible<Root<TestBindingPairIterable>> { + Ok(TestBindingPairIterable::new(global)) } } diff --git a/components/script/dom/text.rs b/components/script/dom/text.rs index fec47d6fc84..914d415dc0a 100644 --- a/components/script/dom/text.rs +++ b/components/script/dom/text.rs @@ -8,13 +8,13 @@ use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::codegen::Bindings::TextBinding::{self, TextMethods}; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::error::{Error, Fallible}; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; use dom::bindings::js::RootedReference; use dom::bindings::str::DOMString; use dom::characterdata::CharacterData; use dom::document::Document; +use dom::globalscope::GlobalScope; use dom::node::Node; /// An HTML text node. @@ -35,8 +35,8 @@ impl Text { document, TextBinding::Wrap) } - pub fn Constructor(global: GlobalRef, text: DOMString) -> Fallible<Root<Text>> { - let document = global.as_global_scope().as_window().Document(); + pub fn Constructor(global: &GlobalScope, text: DOMString) -> Fallible<Root<Text>> { + let document = global.as_window().Document(); Ok(Text::new(text, document.r())) } } diff --git a/components/script/dom/textdecoder.rs b/components/script/dom/textdecoder.rs index 4d0e18e87f6..db18d9a5be4 100644 --- a/components/script/dom/textdecoder.rs +++ b/components/script/dom/textdecoder.rs @@ -6,7 +6,6 @@ use dom::bindings::codegen::Bindings::TextDecoderBinding; use dom::bindings::codegen::Bindings::TextDecoderBinding::TextDecoderMethods; use dom::bindings::conversions::array_buffer_view_data; use dom::bindings::error::{Error, Fallible}; -use dom::bindings::global::GlobalRef; use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::bindings::str::{DOMString, USVString}; @@ -44,7 +43,7 @@ impl TextDecoder { } /// https://encoding.spec.whatwg.org/#dom-textdecoder - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, label: DOMString, options: &TextDecoderBinding::TextDecoderOptions) -> Fallible<Root<TextDecoder>> { @@ -61,7 +60,7 @@ impl TextDecoder { Some("replacement") => return TextDecoder::make_range_error(), _ => () }; - Ok(TextDecoder::new(global.as_global_scope(), encoding, options.fatal)) + Ok(TextDecoder::new(global, encoding, options.fatal)) } } diff --git a/components/script/dom/textencoder.rs b/components/script/dom/textencoder.rs index 5076c82190d..9c8ad647080 100644 --- a/components/script/dom/textencoder.rs +++ b/components/script/dom/textencoder.rs @@ -6,7 +6,6 @@ use core::nonzero::NonZero; use dom::bindings::codegen::Bindings::TextEncoderBinding; use dom::bindings::codegen::Bindings::TextEncoderBinding::TextEncoderMethods; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::bindings::str::{DOMString, USVString}; @@ -38,8 +37,8 @@ impl TextEncoder { } // https://encoding.spec.whatwg.org/#dom-textencoder - pub fn Constructor(global: GlobalRef) -> Fallible<Root<TextEncoder>> { - Ok(TextEncoder::new(global.as_global_scope())) + pub fn Constructor(global: &GlobalScope) -> Fallible<Root<TextEncoder>> { + Ok(TextEncoder::new(global)) } } diff --git a/components/script/dom/uievent.rs b/components/script/dom/uievent.rs index 698645f5a6c..99e25b80902 100644 --- a/components/script/dom/uievent.rs +++ b/components/script/dom/uievent.rs @@ -6,13 +6,13 @@ use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::UIEventBinding; use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::{JS, MutNullableHeap, RootedReference}; use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; use dom::bindings::str::DOMString; use dom::event::{Event, EventBubbles, EventCancelable}; +use dom::globalscope::GlobalScope; use dom::window::Window; use std::cell::Cell; use std::default::Default; @@ -52,12 +52,12 @@ impl UIEvent { ev } - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, type_: DOMString, init: &UIEventBinding::UIEventInit) -> Fallible<Root<UIEvent>> { let bubbles = EventBubbles::from(init.parent.bubbles); 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_, bubbles, cancelable, init.view.r(), init.detail); diff --git a/components/script/dom/url.rs b/components/script/dom/url.rs index 8912ece7183..9ff223a74c6 100644 --- a/components/script/dom/url.rs +++ b/components/script/dom/url.rs @@ -6,7 +6,6 @@ use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods; use dom::bindings::codegen::Bindings::URLBinding::{self, URLMethods}; use dom::bindings::error::{Error, ErrorResult, Fallible}; -use dom::bindings::global::GlobalRef; use dom::bindings::js::{JS, MutNullableHeap, Root}; use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::str::{DOMString, USVString}; @@ -62,7 +61,7 @@ impl URL { impl URL { // https://url.spec.whatwg.org/#constructors - pub fn Constructor(global: GlobalRef, url: USVString, + pub fn Constructor(global: &GlobalScope, url: USVString, base: Option<USVString>) -> Fallible<Root<URL>> { let parsed_base = match base { @@ -90,7 +89,7 @@ impl URL { }; // Step 5: Skip (see step 8 below). // 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 // on-demand inside `URL::SearchParams`. // Step 9. @@ -98,7 +97,7 @@ impl URL { } // https://url.spec.whatwg.org/#dom-url-domaintoasciidomain - pub fn DomainToASCII(_: GlobalRef, origin: USVString) -> USVString { + pub fn DomainToASCII(_: &GlobalScope, origin: USVString) -> USVString { // Step 1. let ascii_domain = Host::parse(&origin.0); 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)) } // 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 /// 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() { // Generate a dummy id @@ -132,8 +131,7 @@ impl URL { } // https://w3c.github.io/FileAPI/#dfn-revokeObjectURL - pub fn RevokeObjectURL(global: GlobalRef, url: DOMString) { - let global_scope = global.as_global_scope(); + pub fn RevokeObjectURL(global: &GlobalScope, url: DOMString) { /* 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 @@ -143,11 +141,11 @@ impl URL { 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((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 msg = FileManagerThreadMsg::RevokeBlobURL(id, origin, tx); let _ = resource_threads.send(CoreResourceMsg::ToFileManager(msg)); diff --git a/components/script/dom/urlsearchparams.rs b/components/script/dom/urlsearchparams.rs index a7b1672852f..2718f278dc3 100644 --- a/components/script/dom/urlsearchparams.rs +++ b/components/script/dom/urlsearchparams.rs @@ -7,7 +7,6 @@ use dom::bindings::codegen::Bindings::URLSearchParamsBinding; use dom::bindings::codegen::Bindings::URLSearchParamsBinding::URLSearchParamsMethods; use dom::bindings::codegen::UnionTypes::USVStringOrURLSearchParams; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::bindings::str::{DOMString, USVString}; @@ -42,10 +41,10 @@ impl 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>> { // Step 1. - let query = URLSearchParams::new(global.as_global_scope(), None); + let query = URLSearchParams::new(global, None); match init { Some(USVStringOrURLSearchParams::USVString(init)) => { // Step 2. diff --git a/components/script/dom/webglcontextevent.rs b/components/script/dom/webglcontextevent.rs index 01ab7e0eec1..079218ab3ae 100644 --- a/components/script/dom/webglcontextevent.rs +++ b/components/script/dom/webglcontextevent.rs @@ -7,7 +7,6 @@ use dom::bindings::codegen::Bindings::WebGLContextEventBinding; use dom::bindings::codegen::Bindings::WebGLContextEventBinding::WebGLContextEventInit; use dom::bindings::codegen::Bindings::WebGLContextEventBinding::WebGLContextEventMethods; use dom::bindings::error::Fallible; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; @@ -71,7 +70,7 @@ impl WebGLContextEvent { event } - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, type_: DOMString, init: &WebGLContextEventInit) -> Fallible<Root<WebGLContextEvent>> { let status_message = match init.statusMessage.as_ref() { @@ -83,7 +82,7 @@ impl WebGLContextEvent { let cancelable = EventCancelable::from(init.parent.cancelable); - Ok(WebGLContextEvent::new(global.as_global_scope(), + Ok(WebGLContextEvent::new(global, Atom::from(type_), bubbles, cancelable, diff --git a/components/script/dom/websocket.rs b/components/script/dom/websocket.rs index 242f8124721..eb8b3cebf4f 100644 --- a/components/script/dom/websocket.rs +++ b/components/script/dom/websocket.rs @@ -10,7 +10,6 @@ use dom::bindings::codegen::Bindings::WebSocketBinding::{BinaryType, WebSocketMe use dom::bindings::codegen::UnionTypes::StringOrStringSequence; use dom::bindings::conversions::ToJSValConvertible; use dom::bindings::error::{Error, ErrorResult, Fallible}; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; use dom::bindings::refcounted::Trusted; @@ -196,7 +195,7 @@ impl WebSocket { global, WebSocketBinding::Wrap) } - pub fn Constructor(global: GlobalRef, + pub fn Constructor(global: &GlobalScope, url: DOMString, protocols: Option<StringOrStringSequence>) -> Fallible<Root<WebSocket>> { @@ -239,11 +238,10 @@ impl WebSocket { } // Step 6: Origin. - let global_scope = global.as_global_scope(); - let origin = UrlHelper::Origin(&global_scope.get_url()).0; + let origin = UrlHelper::Origin(&global.get_url()).0; // 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 connect_data = WebSocketConnectData { @@ -265,12 +263,12 @@ impl WebSocket { 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); let moved_address = address.clone(); - let sender = global_scope.networking_task_source(); + let sender = global.networking_task_source(); thread::spawn(move || { while let Ok(event) = dom_event_receiver.recv() { match event { diff --git a/components/script/dom/worker.rs b/components/script/dom/worker.rs index 035aa83bdf9..328471be089 100644 --- a/components/script/dom/worker.rs +++ b/components/script/dom/worker.rs @@ -9,7 +9,6 @@ use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::Bindings::WorkerBinding; use dom::bindings::codegen::Bindings::WorkerBinding::WorkerMethods; use dom::bindings::error::{Error, ErrorResult, Fallible, ErrorInfo}; -use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; use dom::bindings::refcounted::Trusted; @@ -72,29 +71,28 @@ impl Worker { // https://html.spec.whatwg.org/multipage/#dom-worker #[allow(unsafe_code)] - pub fn Constructor(global: GlobalRef, script_url: DOMString) -> Fallible<Root<Worker>> { - let global_scope = global.as_global_scope(); + pub fn Constructor(global: &GlobalScope, script_url: DOMString) -> Fallible<Root<Worker>> { // 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, Err(_) => return Err(Error::Syntax), }; let (sender, receiver) = channel(); 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_load_origin = WorkerScriptLoadOrigin { referrer_url: 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 worker_id = global_scope.get_next_worker_id(); - if let Some(ref chan) = global_scope.devtools_chan() { - let pipeline_id = global_scope.pipeline_id(); + let worker_id = global.get_next_worker_id(); + if let Some(ref chan) = global.devtools_chan() { + let pipeline_id = global.pipeline_id(); let title = format!("Worker for {}", worker_url); let page_info = DevtoolsPageInfo { title: title, @@ -105,11 +103,11 @@ impl Worker { 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( 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) } diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 5e7f156931e..a5b09193b7f 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -206,8 +206,8 @@ impl XMLHttpRequest { } // https://xhr.spec.whatwg.org/#constructors - pub fn Constructor(global: GlobalRef) -> Fallible<Root<XMLHttpRequest>> { - Ok(XMLHttpRequest::new(global.as_global_scope())) + pub fn Constructor(global: &GlobalScope) -> Fallible<Root<XMLHttpRequest>> { + Ok(XMLHttpRequest::new(global)) } fn sync_in_window(&self) -> bool { diff --git a/components/script/fetch.rs b/components/script/fetch.rs index b23f8f8f8dd..f7398ca1d30 100644 --- a/components/script/fetch.rs +++ b/components/script/fetch.rs @@ -75,7 +75,7 @@ pub fn Fetch(global: GlobalRef, input: RequestOrUSVString, init: &RequestInit) - let response = Response::new(global_scope); // Step 2 - let request = match Request::Constructor(global, input, init) { + let request = match Request::Constructor(global_scope, input, init) { Err(e) => { promise.reject_error(promise.global().r().get_cx(), e); return promise; |