From 7f0706ed42b33ec1da6bf9741811ca97d566ed45 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Mon, 13 Oct 2014 08:20:06 -0400 Subject: Implement a DocumentLoader type that tracks pending loads and notifies the script task when the queue is empty. Dispatch the document load event based on the DocumentLoader's notification. --- components/script/dom/domimplementation.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'components/script/dom/domimplementation.rs') diff --git a/components/script/dom/domimplementation.rs b/components/script/dom/domimplementation.rs index 3400c1d3ea3..d64ad103aa1 100644 --- a/components/script/dom/domimplementation.rs +++ b/components/script/dom/domimplementation.rs @@ -2,6 +2,7 @@ * 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 document_loader::DocumentLoader; use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use dom::bindings::codegen::Bindings::DOMImplementationBinding; use dom::bindings::codegen::Bindings::DOMImplementationBinding::DOMImplementationMethods; @@ -63,11 +64,13 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> { fn CreateDocument(self, namespace: Option, qname: DOMString, maybe_doctype: Option>) -> Fallible> { let doc = self.document.root(); - let win = doc.r().window().root(); + let doc = doc.r(); + let win = doc.window().root(); + let loader = DocumentLoader::new(&*doc.loader()); // Step 1. let doc = Document::new(win.r(), None, IsHTMLDocument::NonHTMLDocument, - None, None, DocumentSource::NotFromParser).root(); + None, None, DocumentSource::NotFromParser, loader).root(); // Step 2-3. let maybe_elem = if qname.is_empty() { None @@ -109,11 +112,13 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> { // https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument fn CreateHTMLDocument(self, title: Option) -> Temporary { let document = self.document.root(); - let win = document.r().window().root(); + let document = document.r(); + let win = document.window().root(); + let loader = DocumentLoader::new(&*document.loader()); // Step 1-2. let doc = Document::new(win.r(), None, IsHTMLDocument::HTMLDocument, None, None, - DocumentSource::NotFromParser).root(); + DocumentSource::NotFromParser, loader).root(); let doc_node: JSRef = NodeCast::from_ref(doc.r()); { -- cgit v1.2.3