diff options
author | Ms2ger <ms2ger@gmail.com> | 2014-07-15 22:28:43 +0200 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2014-07-15 22:28:43 +0200 |
commit | d97ec6995773ee79fbde053520bc580e7b33d15d (patch) | |
tree | e5a00cefa1309b80bc8a44287c3cc9059ed4a257 /src/components/script/dom/document.rs | |
parent | f816a92c72e2eb60f733b2cd7072c8542710d5ae (diff) | |
parent | df9d063b36aca184a336b9e67da3ce30bb46cb79 (diff) | |
download | servo-d97ec6995773ee79fbde053520bc580e7b33d15d.tar.gz servo-d97ec6995773ee79fbde053520bc580e7b33d15d.zip |
Merge pull request #2839 from Ms2ger/globals
Introduce abstractions for global scopes; r=Manishearth,larsberg
Diffstat (limited to 'src/components/script/dom/document.rs')
-rw-r--r-- | src/components/script/dom/document.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs index 7bb394d3755..bee7494ed73 100644 --- a/src/components/script/dom/document.rs +++ b/src/components/script/dom/document.rs @@ -2,18 +2,19 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +use dom::bindings::codegen::Bindings::DocumentBinding; use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::InheritTypes::{DocumentDerived, EventCast, HTMLElementCast}; use dom::bindings::codegen::InheritTypes::{HTMLHeadElementCast, TextCast, ElementCast}; use dom::bindings::codegen::InheritTypes::{DocumentTypeCast, HTMLHtmlElementCast, NodeCast}; use dom::bindings::codegen::InheritTypes::EventTargetCast; -use dom::bindings::codegen::Bindings::DocumentBinding; +use dom::bindings::error::{ErrorResult, Fallible, NotSupported, InvalidCharacter}; +use dom::bindings::error::{HierarchyRequest, NamespaceError}; +use dom::bindings::global::{GlobalRef, Window}; use dom::bindings::js::{JS, JSRef, Temporary, OptionalSettable, TemporaryPushable}; use dom::bindings::js::OptionalRootable; use dom::bindings::trace::{Traceable, Untraceable}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; -use dom::bindings::error::{ErrorResult, Fallible, NotSupported, InvalidCharacter}; -use dom::bindings::error::{HierarchyRequest, NamespaceError}; use dom::bindings::utils::{xml_name_type, InvalidXMLName, Name, QName}; use dom::comment::Comment; use dom::customevent::CustomEvent; @@ -222,13 +223,13 @@ impl Document { } // http://dom.spec.whatwg.org/#dom-document - pub fn Constructor(owner: &JSRef<Window>) -> Fallible<Temporary<Document>> { - Ok(Document::new(owner, None, NonHTMLDocument, None)) + pub fn Constructor(global: &GlobalRef) -> Fallible<Temporary<Document>> { + Ok(Document::new(global.as_window(), None, NonHTMLDocument, None)) } pub fn new(window: &JSRef<Window>, url: Option<Url>, doctype: IsHTMLDocument, content_type: Option<DOMString>) -> Temporary<Document> { let document = Document::new_inherited(window, url, doctype, content_type); - let document = reflect_dom_object(box document, window, + let document = reflect_dom_object(box document, &Window(*window), DocumentBinding::Wrap).root(); let node: &JSRef<Node> = NodeCast::from_ref(&*document); @@ -540,8 +541,8 @@ impl<'a> DocumentMethods for JSRef<'a, Document> { // FIXME: Implement CustomEvent (http://dom.spec.whatwg.org/#customevent) "uievents" | "uievent" => Ok(EventCast::from_temporary(UIEvent::new_uninitialized(&*window))), "mouseevents" | "mouseevent" => Ok(EventCast::from_temporary(MouseEvent::new_uninitialized(&*window))), - "customevent" => Ok(EventCast::from_temporary(CustomEvent::new_uninitialized(&*window))), - "htmlevents" | "events" | "event" => Ok(Event::new_uninitialized(&*window)), + "customevent" => Ok(EventCast::from_temporary(CustomEvent::new_uninitialized(&Window(*window)))), + "htmlevents" | "events" | "event" => Ok(Event::new_uninitialized(&Window(*window))), _ => Err(NotSupported) } } |